From d079ad26d9cd0f7f03b5122126013714fd3cb684 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 7 Sep 2022 21:05:18 +0530 Subject: [PATCH] Add method to get default logo --- src/bitmessagekivy/mpybit.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 5cce7e94..1f17d542 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -258,9 +258,9 @@ class NavigateApp(MDApp): self.kivy_state_obj.association, android_path) ) else: - if not os.path.exists(self.kivy_state_obj.image_dir + '/default_identicon/'): - os.makedirs(self.kivy_state_obj.image_dir + '/default_identicon/') - newImg.save(self.kivy_state_obj.image_dir + '/default_identicon/{0}.png'.format( + if not os.path.exists(self.image_dir.image_dir + '/default_identicon/'): + os.makedirs(self.image_dir.image_dir + '/default_identicon/') + newImg.save(self.image_dir.image_dir + '/default_identicon/{0}.png'.format( self.kivy_state_obj.association) ) self.load_selected_Image(self.kivy_state_obj.association) @@ -277,7 +277,7 @@ class NavigateApp(MDApp): def load_selected_Image(self, curerentAddr): """This method load the selected image on screen""" top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0] - top_box_obj.source = self.kivy_state_obj.image_dir + '/default_identicon/{0}.png'.format(curerentAddr) + top_box_obj.source = self.image_dir.image_dir + '/default_identicon/{0}.png'.format(curerentAddr) self.root.ids.content_drawer.ids.reset_image.opacity = 1 self.root.ids.content_drawer.ids.reset_image.disabled = False top_box_obj.reload() @@ -285,7 +285,7 @@ class NavigateApp(MDApp): def rest_default_avatar_img(self): """set default avatar generated image""" self.set_identicon(self.kivy_state_obj.association) - img_path = self.kivy_state_obj.image_dir + '/default_identicon/{}.png'.format( + img_path = self.image_dir.image_dir + '/default_identicon/{}.png'.format( self.kivy_state_obj.association ) try: @@ -297,6 +297,21 @@ class NavigateApp(MDApp): pass toast('Avatar reset') + def get_default_logo(self, instance): + """Getting default logo image""" + if self.identity_list: + first_addr = self.identity_list[0] + if config.getboolean(str(first_addr), 'enabled'): + if os.path.exists( + self.image_dir.imageDir + '/default_identicon/{}.png'.format(first_addr)): + return self.image_dir.imageDir + '/default_identicon/{}.png'.format( + first_addr) + else: + img = identiconGeneration.generate(first_addr) + instance.texture = img.texture + return + return self.image_dir.imageDir + '/drawer_logo1.png' + 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: