From 8a49e1ab6b4ea527d4707dea4b63b311b7b07303 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Mon, 14 Mar 2022 15:16:04 +0530 Subject: [PATCH 01/13] Add an additional file for addressbook widgets --- src/bitmessagekivy/baseclass/addressbook.py | 79 +++++++++---------- .../baseclass/addressbook_widgets.py | 59 +++++++------- src/bitmessagekivy/kv/login.kv | 2 +- 3 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index 0eb08462..eea47860 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -1,4 +1,3 @@ -from turtle import pd from bitmessagekivy.get_platform import platform from bitmessagekivy import kivy_helper_search from helper_sql import sqlExecute @@ -22,7 +21,8 @@ from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.popup import AddbookDetailPopup from bitmessagekivy.baseclass.addressbook_widgets import HelperAddressBook -class AddressBook(Screen): + +class AddressBook(Screen, HelperAddressBook): """AddressBook Screen class for kivy Ui""" queryreturn = ListProperty() @@ -58,6 +58,7 @@ class AddressBook(Screen): self.set_mdList(0, 20) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) else: + """This is still exprimental, may need to make changes somewhere""" # content = MDLabel( # font_style='Caption', # theme_text_color='Primary', @@ -66,18 +67,7 @@ class AddressBook(Screen): # halign='center', # size_hint_y=None, # valign='top') - self.ids.ml.add_widget(HelperAddressBook.default_label_while_empty()) - - # def show_default_content(self): - # content = MDLabel( - # font_style='Caption', - # theme_text_color='Primary', - # text="No contact found!" if state.searcing_text - # else "No contact found yet...... ", - # halign='center', - # size_hint_y=None, - # valign='top') - # return content + self.ids.ml.add_widget(self.default_label_when_empty()) def set_mdList(self, start_index, end_index): """Creating the mdList""" @@ -127,34 +117,34 @@ class AddressBook(Screen): if instance.state == 'closed': instance.ids.delete_msg.disabled = True if instance.open_progress == 0.0: - HelperAddressBook.address_detail_popup(self, address, label, instance) - # obj = AddbookDetailPopup() - # self.address_label = obj.address_label = label - # self.address = obj.address = address - # width = .9 if platform == 'android' else .8 - # self.addbook_popup = MDDialog( - # type="custom", - # size_hint=(width, .25), - # content_cls=obj, - # buttons=[ - # MDRaisedButton( - # text="Send message to", - # on_release=self.send_message_to, - # ), - # MDRaisedButton( - # text="Save", - # on_release=self.update_addbook_label, - # ), - # MDRaisedButton( - # text="Cancel", - # on_release=self.close_pop, - # ), - # ], - # ) - # # self.addbook_popup.set_normal_height() - # self.addbook_popup = HelperAddressBook.address_detail_popup(self) - # self.addbook_popup.auto_dismiss = False - # self.addbook_popup.open() + obj = AddbookDetailPopup() + self.address_label = obj.address_label = label + self.address = obj.address = address + width = .9 if platform == 'android' else .8 + self.addbook_popup = MDDialog( + type="custom", + size_hint=(width, .25), + content_cls=obj, + buttons=[ + MDRaisedButton( + text="Send message to", + on_release=self.send_message_to, + ), + MDRaisedButton( + text="Save", + on_release=self.update_addbook_label, + ), + MDRaisedButton( + text="Cancel", + on_release=self.close_pop, + ), + ], + ) + # self.addbook_popup.set_normal_height() + self.addbook_popup = HelperAddressBook.address_detail_popup(self) + self.addbook_popup.auto_dismiss = False + self.addbook_popup.open() + # HelperAddressBook.address_detail_popup(address, label, instance,) else: instance.ids.delete_msg.disabled = False @@ -190,7 +180,7 @@ class AddressBook(Screen): state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '') self.addbook_popup.dismiss() toast('Saved') - + def send_message_to(self, instance): """Method used to fill to_address of composer autofield""" state.kivyapp.set_navbar_for_composer() @@ -202,3 +192,6 @@ class AddressBook(Screen): window_obj.sc3.children[1].ids.body.text = '' window_obj.scr_mngr.current = 'create' self.addbook_popup.dismiss() + + + diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index 0521a90a..ee6c22c5 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -7,9 +7,13 @@ from kivymd.uix.dialog import MDDialog from kivymd.uix.label import MDLabel from bitmessagekivy.baseclass.popup import AddbookDetailPopup +# from bitmessagekivy.baseclass.addressbook import AddressBook class HelperAddressBook: - def default_label_while_empty(): + """Widget used in Addressbook are here""" + + @staticmethod + def default_label_when_empty(): content = MDLabel( font_style='Caption', theme_text_color='Primary', @@ -20,29 +24,30 @@ class HelperAddressBook: valign='top') return content - def address_detail_popup(self, address, label, instance): - obj = AddbookDetailPopup() - self.address_label = obj.address_label = label - self.address = obj.address = address - width = .9 if platform == 'android' else .8 - self.addbook_popup = MDDialog( - type="custom", - size_hint=(width, .25), - content_cls=obj, - buttons=[ - MDRaisedButton( - text="Send message to", - on_release=self.send_message_to, - ), - MDRaisedButton( - text="Save", - on_release=self.update_addbook_label, - ), - MDRaisedButton( - text="Cancel", - on_release=self.close_pop, - ), - ], - ) - self.addbook_popup.auto_dismiss = False - self.addbook_popup.open() + # @staticmethod + # def address_detail_popup(address, label, instance, **args): + # obj = AddbookDetailPopup() + # address_label = obj.address_label = label + # address = obj.address = address + # width = .9 if platform == 'android' else .8 + # addbook_popup = MDDialog( + # type="custom", + # size_hint=(width, .25), + # content_cls=obj, + # buttons=[ + # MDRaisedButton( + # text="Send message to", + # on_release=AddressBook.send_message_to, + # ), + # MDRaisedButton( + # text="Save", + # on_release=AddressBook.update_addbook_label, + # ), + # MDRaisedButton( + # text="Cancel", + # on_release=AddressBook.close_pop, + # ), + # ], + # ) + # addbook_popup.auto_dismiss = False + # addbook_popup.open() diff --git a/src/bitmessagekivy/kv/login.kv b/src/bitmessagekivy/kv/login.kv index ffa922e1..992938dc 100644 --- a/src/bitmessagekivy/kv/login.kv +++ b/src/bitmessagekivy/kv/login.kv @@ -80,7 +80,7 @@ icon: "chevron-double-right" text: app.tr._("Proceed Next") on_release: - app.root.set_screen('random') + app.set_screen('random') on_press: app.root.ids.sc7.reset_address_label() From d783465a3f6a55dfa49cb36ae5a3c5f68508ac36 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Tue, 15 Mar 2022 18:45:08 +0530 Subject: [PATCH 02/13] Fixed widget calling by depen-injection --- src/bitmessagekivy/baseclass/addressbook.py | 48 +++++++++-------- .../baseclass/addressbook_widgets.py | 51 +++++++++---------- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index eea47860..5f8b3a07 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -67,7 +67,7 @@ class AddressBook(Screen, HelperAddressBook): # halign='center', # size_hint_y=None, # valign='top') - self.ids.ml.add_widget(self.default_label_when_empty()) + self.ids.ml.add_widget(self.default_label_when_empty()) def set_mdList(self, start_index, end_index): """Creating the mdList""" @@ -121,30 +121,31 @@ class AddressBook(Screen, HelperAddressBook): self.address_label = obj.address_label = label self.address = obj.address = address width = .9 if platform == 'android' else .8 - self.addbook_popup = MDDialog( - type="custom", - size_hint=(width, .25), - content_cls=obj, - buttons=[ - MDRaisedButton( - text="Send message to", - on_release=self.send_message_to, - ), - MDRaisedButton( - text="Save", - on_release=self.update_addbook_label, - ), - MDRaisedButton( - text="Cancel", - on_release=self.close_pop, - ), - ], - ) + # self.addbook_popup = MDDialog( + # type="custom", + # size_hint=(width, .25), + # content_cls=obj, + # buttons=[ + # MDRaisedButton( + # text="Send message to", + # on_release=self.send_message_to, + # ), + # MDRaisedButton( + # text="Save", + # on_release=self.update_addbook_label, + # ), + # MDRaisedButton( + # text="Cancel", + # on_release=self.close_pop, + # ), + # ], + # ) # self.addbook_popup.set_normal_height() - self.addbook_popup = HelperAddressBook.address_detail_popup(self) + self.addbook_popup = self.address_detail_popup( + self.send_message_to, self.update_addbook_label, + self.close_pop, width=width, obj=obj) self.addbook_popup.auto_dismiss = False self.addbook_popup.open() - # HelperAddressBook.address_detail_popup(address, label, instance,) else: instance.ids.delete_msg.disabled = False @@ -192,6 +193,3 @@ class AddressBook(Screen, HelperAddressBook): window_obj.sc3.children[1].ids.body.text = '' window_obj.scr_mngr.current = 'create' self.addbook_popup.dismiss() - - - diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index ee6c22c5..f756d94f 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -7,7 +7,7 @@ from kivymd.uix.dialog import MDDialog from kivymd.uix.label import MDLabel from bitmessagekivy.baseclass.popup import AddbookDetailPopup -# from bitmessagekivy.baseclass.addressbook import AddressBook + class HelperAddressBook: """Widget used in Addressbook are here""" @@ -17,6 +17,7 @@ class HelperAddressBook: content = MDLabel( font_style='Caption', theme_text_color='Primary', + # TODO: searcing_text(typo), need to create a kivy_state.py and add kivy related variables text="No contact found!" if state.searcing_text else "No contact found yet...... ", halign='center', @@ -24,30 +25,24 @@ class HelperAddressBook: valign='top') return content - # @staticmethod - # def address_detail_popup(address, label, instance, **args): - # obj = AddbookDetailPopup() - # address_label = obj.address_label = label - # address = obj.address = address - # width = .9 if platform == 'android' else .8 - # addbook_popup = MDDialog( - # type="custom", - # size_hint=(width, .25), - # content_cls=obj, - # buttons=[ - # MDRaisedButton( - # text="Send message to", - # on_release=AddressBook.send_message_to, - # ), - # MDRaisedButton( - # text="Save", - # on_release=AddressBook.update_addbook_label, - # ), - # MDRaisedButton( - # text="Cancel", - # on_release=AddressBook.close_pop, - # ), - # ], - # ) - # addbook_popup.auto_dismiss = False - # addbook_popup.open() + def address_detail_popup(self, send_message, update_address, close_popup, width, obj): + retval = MDDialog( + type="custom", + size_hint=(width, .25), + content_cls=obj, + buttons=[ + MDRaisedButton( + text="Send message to", + on_release=send_message, + ), + MDRaisedButton( + text="Save", + on_release=update_address, + ), + MDRaisedButton( + text="Cancel", + on_release=close_popup, + ), + ], + ) + return retval \ No newline at end of file From 348bee0a06d15657f88e0a9b4e0cd6f620ee8323 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Thu, 17 Mar 2022 15:09:04 +0530 Subject: [PATCH 03/13] Fixed code quality --- src/bitmessagekivy/baseclass/addressbook.py | 32 ++++++++++--------- .../baseclass/addressbook_widgets.py | 27 +++++++++++----- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index 5f8b3a07..b0ec16af 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -14,6 +14,7 @@ from kivy.uix.screenmanager import Screen import state +from debug import logger from bitmessagekivy.baseclass.common import ( avatarImageFirstLetter, toast, ThemeClsColor, SwipeToDeleteItem @@ -39,7 +40,7 @@ class AddressBook(Screen, HelperAddressBook): def init_ui(self, dt=0): """Clock Schdule for method AddressBook""" self.loadAddresslist(None, 'All', '') - print(dt) + logger.debug(dt) def loadAddresslist(self, account, where="", what=""): """Clock Schdule for method AddressBook""" @@ -142,8 +143,8 @@ class AddressBook(Screen, HelperAddressBook): # ) # self.addbook_popup.set_normal_height() self.addbook_popup = self.address_detail_popup( - self.send_message_to, self.update_addbook_label, - self.close_pop, width=width, obj=obj) + obj, self.send_message_to, self.update_addbook_label, + self.close_pop, width) self.addbook_popup.auto_dismiss = False self.addbook_popup.open() else: @@ -156,7 +157,7 @@ class AddressBook(Screen, HelperAddressBook): if self.ids.ml.children is not None: self.ids.tag_label.text = '' sqlExecute( - "DELETE FROM addressbook WHERE address = '{}';".format(address)) + "DELETE FROM addressbook WHERE address = ?", address) toast('Address Deleted') def close_pop(self, instance): @@ -174,22 +175,23 @@ class AddressBook(Screen, HelperAddressBook): stored_labels.remove(label) if label and label not in stored_labels: sqlExecute( - "UPDATE addressbook SET label = '{}' WHERE" - " address = '{}';".format( - label, self.addbook_popup.content_cls.address)) + "UPDATE addressbook SET label = ? WHERE" + "address = ?", label, self.addbook_popup.content_cls.address) state.kivyapp.root.ids.sc11.ids.ml.clear_widgets() state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '') self.addbook_popup.dismiss() toast('Saved') - + def send_message_to(self, instance): """Method used to fill to_address of composer autofield""" state.kivyapp.set_navbar_for_composer() - window_obj = state.kivyapp.root.ids - window_obj.sc3.children[1].ids.txt_input.text = self.address - window_obj.sc3.children[1].ids.ti.text = '' - window_obj.sc3.children[1].ids.btn.text = 'Select' - window_obj.sc3.children[1].ids.subject.text = '' - window_obj.sc3.children[1].ids.body.text = '' - window_obj.scr_mngr.current = 'create' + # import pdb; pdb.set_trace() + self.compose_message(None, self.address, None, None) + # window_obj = state.kivyapp.root.ids + # window_obj.sc3.children[1].ids.txt_input.text = self.address + # window_obj.sc3.children[1].ids.ti.text = '' + # window_obj.sc3.children[1].ids.btn.text = 'Select' + # window_obj.sc3.children[1].ids.subject.text = '' + # window_obj.sc3.children[1].ids.body.text = '' + # window_obj.scr_mngr.current = 'create' self.addbook_popup.dismiss() diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index f756d94f..fac856b0 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -9,7 +9,7 @@ from kivymd.uix.label import MDLabel from bitmessagekivy.baseclass.popup import AddbookDetailPopup -class HelperAddressBook: +class HelperAddressBook(object): """Widget used in Addressbook are here""" @staticmethod @@ -17,15 +17,13 @@ class HelperAddressBook: content = MDLabel( font_style='Caption', theme_text_color='Primary', - # TODO: searcing_text(typo), need to create a kivy_state.py and add kivy related variables + # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables text="No contact found!" if state.searcing_text - else "No contact found yet...... ", - halign='center', - size_hint_y=None, - valign='top') + else "No contact found yet...... ", halign='center', size_hint_y=None, valign='top') return content - def address_detail_popup(self, send_message, update_address, close_popup, width, obj): + @staticmethod + def address_detail_popup(obj, send_message, update_address, close_popup, width): retval = MDDialog( type="custom", size_hint=(width, .25), @@ -45,4 +43,17 @@ class HelperAddressBook: ), ], ) - return retval \ No newline at end of file + return retval + + @staticmethod + def compose_message(from_addr=None, to_addr=None, subject=None, body=None): + window_obj = state.kivyapp.root.ids + if to_addr: + window_obj.sc3.children[1].ids.txt_input.text = to_addr + if from_addr: + window_obj.sc3.children[1].ids.txt_input.text = from_addr + window_obj.sc3.children[1].ids.ti.text = '' + window_obj.sc3.children[1].ids.btn.text = 'Select' + window_obj.sc3.children[1].ids.subject.text = '' + window_obj.sc3.children[1].ids.body.text = '' + window_obj.scr_mngr.current = 'create' From e8805ce19c834f8f5d46f9bb12c8a4bdcf8f19a5 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 30 Mar 2022 18:35:15 +0530 Subject: [PATCH 04/13] Constant for empty screen label --- src/bitmessagekivy/baseclass/addressbook.py | 6 +++-- .../baseclass/addressbook_widgets.py | 25 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index b0ec16af..7fcff0f6 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -13,6 +13,7 @@ from kivymd.uix.label import MDLabel from kivy.uix.screenmanager import Screen import state +import os from debug import logger from bitmessagekivy.baseclass.common import ( @@ -83,8 +84,9 @@ class AddressBook(Screen, HelperAddressBook): # listItem.add_widget(AvatarSampleWidget( # source=state.imageDir + '/text_images/{}.png'.format( # avatarImageFirstLetter(item[0].strip())))) - image = state.imageDir + "/text_images/{}.png".format( - avatarImageFirstLetter(item[0].strip())) + image = os.path.join( + state.imageDir, "text_images", "{}.png".format(avatarImageFirstLetter(item[0].strip())) + ) message_row.ids.avater_img.source = image listItem.bind(on_release=partial( self.addBook_detail, item[1], item[0], message_row)) diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index fac856b0..3b5560d1 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -8,19 +8,26 @@ from kivymd.uix.label import MDLabel from bitmessagekivy.baseclass.popup import AddbookDetailPopup +no_address_found = "No contact found yet...??..." +empty_search_label = "No contact found!??" -class HelperAddressBook(object): - """Widget used in Addressbook are here""" + + +class DefaultLabelMixin(object): @staticmethod def default_label_when_empty(): - content = MDLabel( - font_style='Caption', - theme_text_color='Primary', - # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables - text="No contact found!" if state.searcing_text - else "No contact found yet...... ", halign='center', size_hint_y=None, valign='top') - return content + content = MDLabel( + font_style='Caption', + theme_text_color='Primary', + # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables + text=empty_search_label if state.searcing_text else no_address_found, + halign='center', size_hint_y=None, valign='top') + return content + + +class HelperAddressBook(DefaultLabelMixin): + """Widget used in Addressbook are here""" @staticmethod def address_detail_popup(obj, send_message, update_address, close_popup, width): From f48b96aa0d659c5738c8ed83f70cc6aaed2381f8 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Fri, 22 Apr 2022 17:52:27 +0530 Subject: [PATCH 05/13] Moved empty_screen() to common.py --- src/bitmessagekivy/baseclass/addressbook.py | 6 ++-- .../baseclass/addressbook_widgets.py | 29 ++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/bitmessagekivy/baseclass/addressbook.py b/src/bitmessagekivy/baseclass/addressbook.py index 7fcff0f6..ce89169c 100644 --- a/src/bitmessagekivy/baseclass/addressbook.py +++ b/src/bitmessagekivy/baseclass/addressbook.py @@ -17,7 +17,7 @@ import os from debug import logger from bitmessagekivy.baseclass.common import ( - avatarImageFirstLetter, toast, + avatarImageFirstLetter, toast, empty_screen_label, ThemeClsColor, SwipeToDeleteItem ) from bitmessagekivy.baseclass.popup import AddbookDetailPopup @@ -31,6 +31,8 @@ class AddressBook(Screen, HelperAddressBook): has_refreshed = True address_label = StringProperty() address = StringProperty() + label_str = "No contact found yet......" + no_search_res_found = "No search result found" def __init__(self, *args, **kwargs): """Getting AddressBook Details""" @@ -69,7 +71,7 @@ class AddressBook(Screen, HelperAddressBook): # halign='center', # size_hint_y=None, # valign='top') - self.ids.ml.add_widget(self.default_label_when_empty()) + self.ids.ml.add_widget(empty_screen_label(self.label_str, self.no_search_res_found)) def set_mdList(self, start_index, end_index): """Creating the mdList""" diff --git a/src/bitmessagekivy/baseclass/addressbook_widgets.py b/src/bitmessagekivy/baseclass/addressbook_widgets.py index 3b5560d1..49b47b5a 100644 --- a/src/bitmessagekivy/baseclass/addressbook_widgets.py +++ b/src/bitmessagekivy/baseclass/addressbook_widgets.py @@ -8,23 +8,26 @@ from kivymd.uix.label import MDLabel from bitmessagekivy.baseclass.popup import AddbookDetailPopup -no_address_found = "No contact found yet...??..." -empty_search_label = "No contact found!??" +label_str = "No contact found yet......" +no_search_res_found = "No contact found!" class DefaultLabelMixin(object): - - @staticmethod - def default_label_when_empty(): - content = MDLabel( - font_style='Caption', - theme_text_color='Primary', - # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables - text=empty_search_label if state.searcing_text else no_address_found, - halign='center', size_hint_y=None, valign='top') - return content - + pass +""" + # @staticmethod + # def default_label_when_empty(): + # content = MDLabel( + # font_style='Caption', + # theme_text_color='Primary', + # # TODO: searcing_text(typo) need to create a kivy_state.py and add kivy related variables + # text=no_search_res_found if state.searcing_text else label_str, + # halign='center', + # size_hint_y=None, + # valign='top') + # return content +""" class HelperAddressBook(DefaultLabelMixin): """Widget used in Addressbook are here""" From fda5f94f7d6654ffc09decbfaaf0c2d5355c3cc4 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Fri, 29 Apr 2022 19:06:04 +0530 Subject: [PATCH 06/13] Add kivy state file --- src/bitmessagekivy/kivy_state.py | 36 ++++++++++++++++++++++++++++++++ src/bitmessagekivy/mpybit.py | 9 +++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/bitmessagekivy/kivy_state.py diff --git a/src/bitmessagekivy/kivy_state.py b/src/bitmessagekivy/kivy_state.py new file mode 100644 index 00000000..f5388b77 --- /dev/null +++ b/src/bitmessagekivy/kivy_state.py @@ -0,0 +1,36 @@ +# pylint: disable=too-many-instance-attributes, too-few-public-methods + +""" +Kivy State variables are assigned here, they are separated from state.py +================================= +""" + + +class KivyStateVariables(object): + """This Class hold all the kivy state variables""" + + def __init__(self): + self.association = '' + self.navinstance = None + self.mail_id = 0 + self.myAddressObj = None + self.detailPageType = None + self.ackdata = None + self.status = None + self.screen_density = None + self.msg_counter_objs = None + self.check_sent_acc = None + self.sent_count = 0 + self.inbox_count = 0 + self.trash_count = 0 + self.draft_count = 0 + self.all_count = 0 + self.searcing_text = '' + self.search_screen = '' + self.send_draft_mail = None + self.is_allmail = False + self.in_composer = False + self.availabe_credit = 0 + self.in_sent_method = False + self.in_search_mode = False + self.imageDir = None diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 054e512f..25c5384e 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -61,6 +61,9 @@ from bitmessagekivy.baseclass.common import toast from qr_scanner.zbarcam import ZBarCam from pyzbar.pyzbar import ZBarSymbol +# import pdb; pdb.set_trace() +from bitmessagekivy.kivy_state import KivyStateVariables + if platform != "android": from kivy.config import Config Config.set("input", "mouse", "mouse, multitouch_on_demand") @@ -208,8 +211,12 @@ class CustomSpinner(Spinner): class NavigateApp(MDApp): """Navigation Layout of class""" # pylint: disable=too-many-public-methods,inconsistent-return-statements - + kivyy = KivyStateVariables() # theme_cls = ThemeManager() + def __init__(self): + super(NavigateApp, self).__init__() + self.kivy_state_obj = KivyStateVariables() + previous_date = ObjectProperty() obj_1 = ObjectProperty() variable_1 = ListProperty(addr for addr in BMConfigParser().addresses() From 61558c387bc0cb2dc05d54f46a4ea2bb41140e42 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Fri, 22 Apr 2022 17:56:02 +0530 Subject: [PATCH 07/13] Defined empty_screen_label() --- src/bitmessagekivy/baseclass/common.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bitmessagekivy/baseclass/common.py b/src/bitmessagekivy/baseclass/common.py index 70b750fd..4130a6cd 100644 --- a/src/bitmessagekivy/baseclass/common.py +++ b/src/bitmessagekivy/baseclass/common.py @@ -17,6 +17,10 @@ from kivy.properties import ( StringProperty ) +from kivymd.uix.label import MDLabel + +import state + ThemeClsColor = [0.12, 0.58, 0.95, 1] @@ -142,3 +146,16 @@ class CutsomSwipeToDeleteItem(MDCardSwipe): cla = Window.size[0] / 2 swipe_distance = NumericProperty(cla) opening_time = NumericProperty(0.5) + + +def empty_screen_label(label_str=None, no_search_res_found=None): + """This function returns default message while no address is there.""" + # empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!" + content = MDLabel( + font_style='Caption', + theme_text_color='Primary', + text=no_search_res_found if state.searcing_text else label_str, + halign='center', + size_hint_y=None, + valign='top') + return content From b3508bc888b1b9d3303d98a825a3c9eb33f12c5e Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Mon, 2 May 2022 15:57:07 +0530 Subject: [PATCH 08/13] Add mdlist_content length function --- src/bitmessagekivy/baseclass/common.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/bitmessagekivy/baseclass/common.py b/src/bitmessagekivy/baseclass/common.py index 4130a6cd..38e93e40 100644 --- a/src/bitmessagekivy/baseclass/common.py +++ b/src/bitmessagekivy/baseclass/common.py @@ -16,12 +16,10 @@ from kivy.properties import ( NumericProperty, StringProperty ) - from kivymd.uix.label import MDLabel import state - ThemeClsColor = [0.12, 0.58, 0.95, 1] @@ -74,7 +72,7 @@ def chipTag(text): def toast(text): - """Method will display the toast message""" + """Function will display the toast message""" kivytoast.toast(text) def showLimitedCnt(total_msg): @@ -85,8 +83,8 @@ def showLimitedCnt(total_msg): def avatarImageFirstLetter(letter_string): """This function is used to the first letter for the avatar image""" try: - if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z': - img_latter = letter_string[0].upper() + if letter_string.title()[0] >= 'A' and letter_string.title()[0] <= 'Z': + img_latter = letter_string.title()[0] elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9: img_latter = letter_string[0] else: @@ -149,8 +147,7 @@ class CutsomSwipeToDeleteItem(MDCardSwipe): def empty_screen_label(label_str=None, no_search_res_found=None): - """This function returns default message while no address is there.""" - # empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!" + """Returns default text on screen when no address is there.""" content = MDLabel( font_style='Caption', theme_text_color='Primary', @@ -159,3 +156,15 @@ def empty_screen_label(label_str=None, no_search_res_found=None): size_hint_y=None, valign='top') return content + + +def mdlist_message_content(queryreturn, data, max_len=None, min_len=None): + for mail in queryreturn: + third_text = mail[3].replace('\n', ' ') + data.append({ + 'text': mail[1].strip(), + 'secondary_text': mail[2][:10] + '...........' if len( + mail[2]) > 10 else mail[2] + '\n' + " " + ( + third_text[:25] + '...!') if len( + third_text) > 25 else third_text, + 'ackdata': mail[5], 'senttime': mail[6]}) From e9e8fff1c2edddb5bb57132cbd601276e3076ec3 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Tue, 3 May 2022 17:21:10 +0530 Subject: [PATCH 09/13] Update imaget set function --- src/bitmessagekivy/baseclass/common.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/bitmessagekivy/baseclass/common.py b/src/bitmessagekivy/baseclass/common.py index 38e93e40..eae8459b 100644 --- a/src/bitmessagekivy/baseclass/common.py +++ b/src/bitmessagekivy/baseclass/common.py @@ -83,16 +83,14 @@ def showLimitedCnt(total_msg): def avatarImageFirstLetter(letter_string): """This function is used to the first letter for the avatar image""" try: - if letter_string.title()[0] >= 'A' and letter_string.title()[0] <= 'Z': - img_latter = letter_string.title()[0] - elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9: - img_latter = letter_string[0] + if isinstance(letter_string, int): + return letter_string[0] + elif isinstance(letter_string, str) and letter_string[0].isalnum(): + return letter_string.title()[0] else: - img_latter = '!' - except ValueError: - img_latter = '!' - return img_latter if img_latter else '!' - + return '!' + except IndexError: + return '!' def AddTimeWidget(time): # pylint: disable=redefined-outer-name, W0201 """This method is used to create TimeWidget""" @@ -158,7 +156,7 @@ def empty_screen_label(label_str=None, no_search_res_found=None): return content -def mdlist_message_content(queryreturn, data, max_len=None, min_len=None): +def mdlist_message_content(queryreturn, data, max_len=25, min_len=10): for mail in queryreturn: third_text = mail[3].replace('\n', ' ') data.append({ From 337c186865dc5d130216b17df461268593c3cb3d Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 4 May 2022 21:07:35 +0530 Subject: [PATCH 10/13] Add identity enable/disable function in addresses.py --- src/addresses.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/addresses.py b/src/addresses.py index c3c61466..192c819f 100644 --- a/src/addresses.py +++ b/src/addresses.py @@ -8,6 +8,8 @@ from struct import pack, unpack from debug import logger +from bmconfigparser import BMConfigParser + ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" @@ -276,3 +278,15 @@ def addBMIfNotPresent(address): """Prepend BM- to an address if it doesn't already have it""" address = str(address).strip() return address if address[:3] == 'BM-' else 'BM-' + address + + +def disable_addresses(address): + """"To disable the Address""" + BMConfigParser().set(str(address), 'enabled', 'false') + BMConfigParser().save() + + +def enable_addresses(address): + """"To enable the Address""" + BMConfigParser().set(address, 'enabled', 'true') + BMConfigParser().save() From 15630ed5a58654be8294261e343b71dfa3d4221f Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 4 May 2022 21:09:07 +0530 Subject: [PATCH 11/13] Separate search_address backend from kivy --- src/bmconfigparser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index a7e1b673..30a6be4b 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -194,3 +194,8 @@ class BMConfigParser(configparser.ConfigParser): if value < 0 or value > 8: return False return True + + @staticmethod + def search_addresses(address, searched_text): + return [x for x in [BMConfigParser().get(address, 'label').lower(), address.lower()] + if searched_text in x] From 652ea73f37e4a472ce08afa7e11bc11f01ff45a0 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 4 May 2022 21:11:32 +0530 Subject: [PATCH 12/13] Add kivy_state.py --- src/bitmessagekivy/kivy_state.py | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/bitmessagekivy/kivy_state.py diff --git a/src/bitmessagekivy/kivy_state.py b/src/bitmessagekivy/kivy_state.py new file mode 100644 index 00000000..f5388b77 --- /dev/null +++ b/src/bitmessagekivy/kivy_state.py @@ -0,0 +1,36 @@ +# pylint: disable=too-many-instance-attributes, too-few-public-methods + +""" +Kivy State variables are assigned here, they are separated from state.py +================================= +""" + + +class KivyStateVariables(object): + """This Class hold all the kivy state variables""" + + def __init__(self): + self.association = '' + self.navinstance = None + self.mail_id = 0 + self.myAddressObj = None + self.detailPageType = None + self.ackdata = None + self.status = None + self.screen_density = None + self.msg_counter_objs = None + self.check_sent_acc = None + self.sent_count = 0 + self.inbox_count = 0 + self.trash_count = 0 + self.draft_count = 0 + self.all_count = 0 + self.searcing_text = '' + self.search_screen = '' + self.send_draft_mail = None + self.is_allmail = False + self.in_composer = False + self.availabe_credit = 0 + self.in_sent_method = False + self.in_search_mode = False + self.imageDir = None From 25d58c2a0cff9772e0c9df15f291bdf4b39c5806 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Thu, 5 May 2022 15:33:24 +0530 Subject: [PATCH 13/13] Add enable/disable method in bmconfigparser & initialize kivy state variable inside NavigateApp --- src/bitmessagekivy/mpybit.py | 1 - src/bmconfigparser.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 25c5384e..1a435689 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -211,7 +211,6 @@ class CustomSpinner(Spinner): class NavigateApp(MDApp): """Navigation Layout of class""" # pylint: disable=too-many-public-methods,inconsistent-return-statements - kivyy = KivyStateVariables() # theme_cls = ThemeManager() def __init__(self): super(NavigateApp, self).__init__() diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index 30a6be4b..228fff0a 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -199,3 +199,13 @@ class BMConfigParser(configparser.ConfigParser): def search_addresses(address, searched_text): return [x for x in [BMConfigParser().get(address, 'label').lower(), address.lower()] if searched_text in x] + + def disable_address(self, address): + """"To disable the Address""" + self.set(str(address), 'enabled', 'false') + self.save() + + def enable_address(self, address): + """"To enable the Address""" + self.set(address, 'enabled', 'true') + self.save()