Moved json loader to separate file
This commit is contained in:
parent
8b7755fb49
commit
c91cba8928
|
@ -35,7 +35,7 @@
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: dp(40)
|
height: dp(40)
|
||||||
IdentitySpinner:
|
CustomSpinner:
|
||||||
id: btn
|
id: btn
|
||||||
background_color: app.theme_cls.primary_dark
|
background_color: app.theme_cls.primary_dark
|
||||||
values: app.variable_1
|
values: app.variable_1
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
if root.is_camara_attached(): app.set_screen('scanscreen')
|
if root.is_camara_attached(): app.set_screen('scanscreen')
|
||||||
else: root.camera_alert()
|
else: root.camera_alert()
|
||||||
on_press:
|
on_press:
|
||||||
app.root.ids.id_scanscreen.get_screen('composer')
|
app.root.ids.is_scanscreen.get_screen('composer')
|
||||||
|
|
||||||
MyMDTextField:
|
MyMDTextField:
|
||||||
id: subject
|
id: subject
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
height:"35dp"
|
height:"35dp"
|
||||||
NavigationItem:
|
NavigationItem:
|
||||||
height: dp(48)
|
height: dp(48)
|
||||||
IdentitySpinner:
|
CustomSpinner:
|
||||||
id: identity_dropdown
|
id: identity_dropdown
|
||||||
pos_hint:{"x":0,"y":0}
|
pos_hint:{"x":0,"y":0}
|
||||||
option_cls: Factory.get("MySpinnerOption")
|
option_cls: Factory.get("MySpinnerOption")
|
||||||
|
@ -223,7 +223,7 @@ MDNavigationLayout:
|
||||||
Sent:
|
Sent:
|
||||||
id:sc4
|
id:sc4
|
||||||
Trash:
|
Trash:
|
||||||
id:id_trash
|
id:sc5
|
||||||
Login:
|
Login:
|
||||||
id:sc6
|
id:sc6
|
||||||
Random:
|
Random:
|
||||||
|
@ -247,7 +247,7 @@ MDNavigationLayout:
|
||||||
Allmails:
|
Allmails:
|
||||||
id:sc17
|
id:sc17
|
||||||
ScanScreen:
|
ScanScreen:
|
||||||
id:id_scanscreen
|
id:is_scanscreen
|
||||||
|
|
||||||
MDNavigationDrawer:
|
MDNavigationDrawer:
|
||||||
id: nav_drawer
|
id: nav_drawer
|
||||||
|
|
|
@ -7,16 +7,11 @@ Bitmessage android(mobile) interface
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
import importlib
|
|
||||||
import logging
|
import logging
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.properties import (
|
|
||||||
ListProperty
|
|
||||||
)
|
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
|
|
||||||
from kivymd.app import MDApp
|
from kivymd.app import MDApp
|
||||||
|
@ -35,40 +30,16 @@ from pybitmessage.bitmessagekivy.base_navigation import (
|
||||||
BaseNavigationDrawerSubheader, BaseContentNavigationDrawer,
|
BaseNavigationDrawerSubheader, BaseContentNavigationDrawer,
|
||||||
BaseIdentitySpinner
|
BaseIdentitySpinner
|
||||||
)
|
)
|
||||||
from pybitmessage.bmconfigparser import config
|
from pybitmessage.bmconfigparser import config # noqa: F401
|
||||||
from pybitmessage.bitmessagekivy import identiconGeneration
|
from pybitmessage.bitmessagekivy import identiconGeneration
|
||||||
from pybitmessage.bitmessagekivy.get_platform import platform
|
from pybitmessage.bitmessagekivy.get_platform import platform
|
||||||
from pybitmessage.bitmessagekivy.baseclass.common import toast
|
from pybitmessage.bitmessagekivy.baseclass.common import toast, load_image_path, get_identity_list
|
||||||
|
from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json
|
||||||
|
|
||||||
from pybitmessage.bitmessagekivy.baseclass.popup import AddAddressPopup
|
from pybitmessage.bitmessagekivy.baseclass.popup import AddAddressPopup
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
data_screen_dict = {}
|
|
||||||
|
|
||||||
|
|
||||||
def load_screen_json(data_file="screens_data.json"):
|
|
||||||
"""Load screens data from json"""
|
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), data_file)) as read_file:
|
|
||||||
all_data = json.load(read_file)
|
|
||||||
data_screens = list(all_data.keys())
|
|
||||||
|
|
||||||
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()
|
|
||||||
data_screen_dict[import_to] = importlib.import_module(import_from, import_to)
|
|
||||||
return data_screens, all_data, 'success'
|
|
||||||
|
|
||||||
|
|
||||||
def get_identity_list():
|
|
||||||
"""Get list of identities and access 'identity_list' variable in .kv file"""
|
|
||||||
identity_list = ListProperty(
|
|
||||||
addr for addr in config.addresses() if config.getboolean(str(addr), 'enabled')
|
|
||||||
)
|
|
||||||
return identity_list
|
|
||||||
|
|
||||||
|
|
||||||
class Lang(BaseLanguage):
|
class Lang(BaseLanguage):
|
||||||
"""UI Language"""
|
"""UI Language"""
|
||||||
|
@ -110,13 +81,14 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
title = "PyBitmessage"
|
title = "PyBitmessage"
|
||||||
identity_list = get_identity_list()
|
identity_list = get_identity_list()
|
||||||
image_path = KivyStateVariables().image_dir
|
image_path = load_image_path()
|
||||||
tr = Lang("en") # for changing in franch replace en with fr
|
tr = Lang("en") # for changing in franch replace en with fr
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(NavigateApp, self).__init__()
|
super(NavigateApp, self).__init__()
|
||||||
self.data_screens, self.all_data, response = load_screen_json()
|
self.data_screens, self.all_data, self.data_screen_dict, response = load_screen_json()
|
||||||
self.kivy_state_obj = KivyStateVariables()
|
self.kivy_state_obj = KivyStateVariables()
|
||||||
|
self.image_dir = load_image_path()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
"""Method builds the widget"""
|
"""Method builds the widget"""
|
||||||
|
@ -224,7 +196,7 @@ class NavigateApp(MDApp):
|
||||||
"""This method is rotating loader for few seconds"""
|
"""This method is rotating loader for few seconds"""
|
||||||
if instance.text == 'Trash':
|
if instance.text == 'Trash':
|
||||||
self.root.ids.id_trash.clear_widgets()
|
self.root.ids.id_trash.clear_widgets()
|
||||||
self.root.ids.id_trash.add_widget(data_screen_dict['Trash'].Trash())
|
self.root.ids.id_trash.add_widget(self.data_screen_dict['Trash'].Trash())
|
||||||
try:
|
try:
|
||||||
self.root.ids.id_trash.children[1].active = False
|
self.root.ids.id_trash.children[1].active = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from pybitmessage.bitmessagekivy.mpybit import load_screen_json
|
from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json
|
||||||
from .common import skip_screen_checks
|
from .common import skip_screen_checks
|
||||||
from .common import ordered
|
from .common import ordered
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user