From 3457c0d84b3e42c964a33ee5f44c68b06487ab78 Mon Sep 17 00:00:00 2001 From: Mohammad Osama Khan Date: Thu, 20 Oct 2022 21:50:43 +0530 Subject: [PATCH] Added filemanager and image reset icon --- src/bitmessagekivy/main.kv | 12 +++- src/bitmessagekivy/mpybit.py | 98 ++++++++++++++++++++++++++- src/bitmessagekivy/screens_data.json | 4 ++ src/images/kivy/drawer_logo1.png | Bin 0 -> 5930 bytes 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 src/images/kivy/drawer_logo1.png diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index 86dc5936..d55b5f9c 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -69,8 +69,8 @@ on_release: app.rest_default_avatar_img() theme_text_color: "Custom" text_color: app.theme_cls.primary_color - opacity: 0 - disabled: True + opacity: 1 if app.have_any_address() else 0 + disabled: False if app.have_any_address() else True MDIconButton: id: file_manager @@ -81,6 +81,9 @@ on_release: app.file_manager_open() theme_text_color: "Custom" text_color: app.theme_cls.primary_color + opacity: 1 if app.have_any_address() else 0 + disabled: False if app.have_any_address() else True + BoxLayout: id: top_box size_hint_y: None @@ -113,9 +116,11 @@ text: 'Select Address' option_cls: Factory.get("MySpinnerOption") font_size: '12.5sp' + text: app.getDefaultAccData(self) color: color_font background_normal: '' background_color: app.theme_cls.primary_color + on_text: app.getCurrentAccountData(self.text) ArrowImg: NavigationItem: id: inbox_cnt @@ -201,6 +206,9 @@ MDNavigationLayout: MDTopAppBar: id: toolbar + title: app.format_address_and_label() + opacity: 1 if app.have_any_address() else 0 + disabled: False if app.have_any_address() else True pos_hint: {"top": 1} md_bg_color: app.theme_cls.primary_color elevation: 10 diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 078da423..e02f3326 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -39,8 +39,9 @@ from pybitmessage.bitmessagekivy.get_platform import platform 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, AddressChangingLoader from pybitmessage.bitmessagekivy.baseclass.login import * # noqa: F401, F403 +from pybitmessage.bitmessagekivy.uikivysignaler import UIkivySignaler from pybitmessage.mock.helper_startup import loadConfig @@ -121,6 +122,9 @@ class NavigateApp(MDApp): def run(self): """Running the widgets""" loadConfig() + kivysignalthread = UIkivySignaler() + kivysignalthread.daemon = True + kivysignalthread.start() self.kivy_state_obj.kivyui_ready.set() super(NavigateApp, self).run() @@ -191,7 +195,10 @@ class NavigateApp(MDApp): def load_screen(self, instance): """This method is used for loading screen on every click""" - if instance.text == 'Trash': + if instance.text == 'Inbox': + self.root.ids.scr_mngr.current = 'inbox' + self.root.ids.id_inbox.children[1].active = True + elif instance.text == 'Trash': self.root.ids.scr_mngr.current = 'trash' try: self.root.ids.id_trash.children[1].active = True @@ -201,7 +208,11 @@ class NavigateApp(MDApp): def load_screen_callback(self, instance, dt=0): """This method is rotating loader for few seconds""" - if instance.text == 'Trash': + if instance.text == 'Inbox': + self.root.ids.id_inbox.ids.ml.clear_widgets() + self.root.ids.id_inbox.loadMessagelist(self.kivy_state_obj.selected_address) + self.root.ids.id_inbox.children[1].active = False + elif instance.text == 'Trash': self.root.ids.id_trash.clear_widgets() self.root.ids.id_trash.add_widget(self.data_screen_dict['Trash'].Trash()) try: @@ -209,6 +220,80 @@ class NavigateApp(MDApp): except Exception as e: self.root.ids.id_trash.children[0].children[1].active = False + @staticmethod + def get_enabled_addresses(): + """Getting list of all the enabled addresses""" + addresses = [addr for addr in config.addresses() + if config.getboolean(str(addr), 'enabled')] + return addresses + + @staticmethod + def format_address(address): + """Formatting address""" + return " ({0})".format(address) + + @staticmethod + def format_label(label): + """Formatting label""" + if label: + f_name = label.split() + truncate_string = '...' + f_name_max_length = 15 + formatted_label = f_name[0][:14].capitalize() + truncate_string if len( + f_name[0]) > f_name_max_length else f_name[0].capitalize() + return formatted_label + return '' + + @staticmethod + def format_address_and_label(address=None): + """Getting formatted address information""" + if not address: + try: + address = NavigateApp.get_enabled_addresses()[0] + except IndexError: + return '' + return "{0}{1}".format( + NavigateApp.format_label(config.get(address, "label")), + NavigateApp.format_address(address) + ) + + def getDefaultAccData(self, instance): + """Getting Default Account Data""" + if self.identity_list: + self.kivy_state_obj.selected_address = first_addr = self.identity_list[0] + return first_addr + return 'Select Address' + + def getCurrentAccountData(self, text): + """Get Current Address Account Data""" + if text != '': + if os.path.exists(os.path.join( + self.image_dir, 'default_identicon', '{}.png'.format(text)) + ): + self.load_selected_Image(text) + else: + self.set_identicon(text) + self.root.ids.content_drawer.ids.reset_image.opacity = 0 + self.root.ids.content_drawer.ids.reset_image.disabled = True + address_label = self.format_address_and_label(text) + self.root_window.children[1].ids.toolbar.title = address_label + self.kivy_state_obj.selected_address = text + AddressChangingLoader().open() + for nav_obj in self.root.ids.content_drawer.children[ + 0].children[0].children[0].children: + nav_obj.active = True if nav_obj.text == 'Inbox' else False + self.fileManagerSetting() + Clock.schedule_once(self.setCurrentAccountData, 0.5) + + def setCurrentAccountData(self, dt=0): + """This method set the current accout data on all the screens""" + self.root.ids.id_inbox.ids.ml.clear_widgets() + self.root.ids.id_inbox.loadMessagelist(self.kivy_state_obj.selected_address) + + self.root.ids.id_sent.ids.ml.clear_widgets() + self.root.ids.id_sent.children[2].children[2].ids.search_field.text = '' + self.root.ids.id_sent.loadSent(self.kivy_state_obj.selected_address) + def fileManagerSetting(self): """This method is for file manager setting""" if not self.root.ids.content_drawer.ids.file_manager.opacity and \ @@ -317,6 +402,13 @@ class NavigateApp(MDApp): return return os.path.join(self.image_dir, 'drawer_logo1.png') + @staticmethod + def have_any_address(): + """Checking existance of any address""" + if config.addresses(): + return True + return False + def reset_login_screen(self): """This method is used for clearing the widgets of random screen""" if self.root.ids.id_newidentity.ids.add_random_bx.children: diff --git a/src/bitmessagekivy/screens_data.json b/src/bitmessagekivy/screens_data.json index 8d21571a..47aeb7ed 100644 --- a/src/bitmessagekivy/screens_data.json +++ b/src/bitmessagekivy/screens_data.json @@ -46,5 +46,9 @@ "kv_string": "trash", "name_screen": "trash", "Import": "from pybitmessage.bitmessagekivy.baseclass.trash import Trash" + }, + "Popups": { + "kv_string": "popup", + "Import": "from pybitmessage.bitmessagekivy.baseclass.popup import *" } } diff --git a/src/images/kivy/drawer_logo1.png b/src/images/kivy/drawer_logo1.png new file mode 100644 index 0000000000000000000000000000000000000000..256f9be6b6eaddbb35b6cec8ee026544f585d07f GIT binary patch literal 5930 zcmcI|Wmpu@v-c7bl1jHrBT5JoOLun&NF%*;=b|7X-Q5Bru{26I(kw_WEZr;}Qp@H4 zyzj?*zuo&`&U`pCXJ*bb_57kV)fEVyQ$Gg)00c^kvf57^`b0fA=uc-&*0a(lhU=4gqXV)Cs=v~t&lzllS9SNLjvC!?zCMDuPTeMH)O*73 zF=HqvlPBaeGau8=9g)TMc>9Fdb-+Z>xcf1SG!DDE6@ITPC^v>zxtx5@oHQ}QLmdaL z04%ipLi!*0RoJ8=c5$R=jt4M|SbD*=Wut;7h2Xh_C60CPp1R~Sz%bS`p3Sg2sn3%6 z$#qgdEdh4sVXUvR3k3=6G^8)BL#2zrnu<>vQU9BlmrG?Nt5?3Q0mzvMsd;#M+gwNDEjm;J^pzJg;T)A)uzDq^j4EvU|iXrpnk9 zHLu~U9N8@YdK}h+^uE5j+Ha}0&#FTU@6LvUe2%Is7N<20b)K}gGy~>#IMP_GZSRrI z5;N}w2&Lla%32BNp>8#`RW^`~xU3eF#>@A2*`R=1b!R=tW7K}G+1=D`xZrq>w*WrK z1e+TE^NL>=X+N)}^P#=79Achut~G!9C8rYk=-cys(DjxKEQ5bM;I`|5PYV`p^YB?7 zU%s3PpuYawC?vmkLR4Ja804dKcbJr;W#%FKk8!^1_iod|K{ot9epXhkXz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