2022-08-05 13:08:37 +02:00
|
|
|
# pylint: disable=no-name-in-module, too-few-public-methods
|
|
|
|
|
2022-08-04 18:29:02 +02:00
|
|
|
|
2021-06-11 19:14:57 +02:00
|
|
|
"""
|
2022-08-04 18:29:02 +02:00
|
|
|
Bitmessage android(mobile) interface
|
2021-06-11 19:14:57 +02:00
|
|
|
"""
|
|
|
|
|
2022-08-05 13:08:37 +02:00
|
|
|
import ast
|
2022-08-04 18:29:02 +02:00
|
|
|
import os
|
2022-08-08 12:56:08 +02:00
|
|
|
import importlib
|
2022-08-04 18:29:02 +02:00
|
|
|
|
2022-08-05 13:08:37 +02:00
|
|
|
from kivy.lang import Builder
|
2022-08-04 18:29:02 +02:00
|
|
|
from kivy.lang import Observable
|
|
|
|
|
2022-08-05 13:08:37 +02:00
|
|
|
from kivymd.app import MDApp
|
2022-08-04 18:29:02 +02:00
|
|
|
|
2022-08-05 13:08:37 +02:00
|
|
|
from pybitmessage.semaphores import kivyuisignaler
|
|
|
|
from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables
|
2022-08-04 18:29:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(os.path.dirname(__file__), "screens_data.json")) as read_file:
|
|
|
|
all_data = ast.literal_eval(read_file.read())
|
|
|
|
data_screens = list(all_data.keys())
|
|
|
|
|
2022-08-08 12:56:08 +02:00
|
|
|
for key in all_data:
|
|
|
|
if all_data[key]['Import']:
|
|
|
|
import_data = all_data.get(key)['Import']
|
|
|
|
import_to = import_data.split("import")[1].strip()
|
|
|
|
import_from = import_data.split("import")[0].split('from')[1].strip()
|
|
|
|
importlib.import_module(import_from, import_to)
|
2022-08-04 18:29:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Lang(Observable):
|
2022-08-05 13:08:37 +02:00
|
|
|
"""UI Language"""
|
|
|
|
|
2022-08-04 18:29:02 +02:00
|
|
|
observers = []
|
|
|
|
lang = None
|
|
|
|
|
|
|
|
def __init__(self, defaultlang):
|
|
|
|
super(Lang, self).__init__()
|
|
|
|
self.ugettext = None
|
|
|
|
self.lang = defaultlang
|
|
|
|
|
2022-08-05 13:08:37 +02:00
|
|
|
@staticmethod
|
|
|
|
def _(text):
|
2022-08-04 18:29:02 +02:00
|
|
|
return text
|
|
|
|
|
|
|
|
|
|
|
|
class NavigateApp(MDApp):
|
|
|
|
"""Navigation Layout of class"""
|
2022-05-05 12:35:14 +02:00
|
|
|
def __init__(self):
|
|
|
|
super(NavigateApp, self).__init__()
|
|
|
|
self.kivy_state_obj = KivyStateVariables()
|
2021-06-11 19:14:57 +02:00
|
|
|
|
2022-08-04 18:29:02 +02:00
|
|
|
title = "PyBitmessage"
|
|
|
|
tr = Lang("en") # for changing in franch replace en with fr
|
|
|
|
|
2022-08-05 13:08:37 +02:00
|
|
|
def build(self): # pylint:disable=no-self-use
|
2021-06-11 19:14:57 +02:00
|
|
|
"""Method builds the widget"""
|
2022-08-04 18:29:02 +02:00
|
|
|
for kv in data_screens:
|
|
|
|
Builder.load_file(
|
|
|
|
os.path.join(
|
|
|
|
os.path.dirname(__file__),
|
|
|
|
'kv',
|
|
|
|
'{0}.kv'.format(all_data[kv]["kv_string"]),
|
|
|
|
)
|
|
|
|
)
|
2022-08-05 13:08:37 +02:00
|
|
|
return Builder.load_file(os.path.join(os.path.dirname(__file__), 'main.kv'))
|
2022-08-04 18:29:02 +02:00
|
|
|
|
|
|
|
def set_screen(self, screen_name):
|
2022-08-05 13:08:37 +02:00
|
|
|
"""Set the screen name when navigate to other screens"""
|
2022-08-04 18:29:02 +02:00
|
|
|
self.root.ids.scr_mngr.current = screen_name
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
"""Running the widgets"""
|
|
|
|
kivyuisignaler.release()
|
|
|
|
super(NavigateApp, self).run()
|