From b01764a5a9f141c050957f3416fc706a8fba92c0 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Wed, 4 May 2022 19:25:30 +0530 Subject: [PATCH] Add address enable/disable function to addresses --- src/bitmessagekivy/baseclass/myaddress.py | 32 +++++++++---------- .../baseclass/myaddress_widgets.py | 3 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/bitmessagekivy/baseclass/myaddress.py b/src/bitmessagekivy/baseclass/myaddress.py index a003a10c..d3b9574d 100644 --- a/src/bitmessagekivy/baseclass/myaddress.py +++ b/src/bitmessagekivy/baseclass/myaddress.py @@ -31,6 +31,9 @@ from bitmessagekivy.baseclass.common import ( avatarImageFirstLetter, AvatarSampleWidget, ThemeClsColor, toast ) + +from addresses import disable_addresses, enable_addresses + from bitmessagekivy.baseclass.popup import MyaddDetailPopup from bitmessagekivy.baseclass.myaddress_widgets import HelperMyAddress @@ -217,20 +220,16 @@ class MyAddress(Screen, HelperMyAddress): @staticmethod def filter_address(address): """Method will filter the my address list data""" - if [ - x for x in [ - BMConfigParser().get(address, 'label').lower(), - address.lower() - ] - if (state.searcing_text).lower() in x - ]: + # import pdb; pdb.set_trace() + searched_text = state.searcing_text.lower() + if BMConfigParser().search_addresses(address, searched_text): return True return False + # if [x for x in [BMConfigParser().get(address, 'label').lower(), address.lower()] if (state.searcing_text).lower() in x]: - def disableAddress(self, address, instance): - """This method is use for disabling address""" - BMConfigParser().set(str(address), 'enabled', 'false') - BMConfigParser().save() + def disable_address_ui(self, address, instance): + """This method is used to disable addresses from UI""" + BMConfigParser().enable_addresses(address) instance.parent.parent.theme_text_color = 'Primary' instance.parent.parent.canvas.children[3].rgba = [0.5, 0.5, 0.5, 0.5] # try: @@ -240,10 +239,9 @@ class MyAddress(Screen, HelperMyAddress): toast('Address disabled') Clock.schedule_once(self.address_permision_callback, 0) - def enableAddress(self, address, instance): - """This method is use for enabling address""" - BMConfigParser().set(address, 'enabled', 'true') - BMConfigParser().save() + def enable_address_ui(self, address, instance): + """This method is used to enable addresses from UI""" + BMConfigParser().disable_addresses(address) instance.parent.parent.theme_text_color = 'Custom' instance.parent.parent.canvas.children[3].rgba = [0, 0, 0, 0] # try: @@ -265,6 +263,6 @@ class MyAddress(Screen, HelperMyAddress): """This method is used for enable or disable address""" addr = instance.parent.parent.secondary_text if instance.active: - self.enableAddress(addr, instance) + self.enable_address_ui(addr, instance) else: - self.disableAddress(addr, instance) + self.disable_address_ui(addr, instance) diff --git a/src/bitmessagekivy/baseclass/myaddress_widgets.py b/src/bitmessagekivy/baseclass/myaddress_widgets.py index d4bd70f4..94202cd5 100644 --- a/src/bitmessagekivy/baseclass/myaddress_widgets.py +++ b/src/bitmessagekivy/baseclass/myaddress_widgets.py @@ -65,8 +65,9 @@ class HelperMyAddress(DefaultLabelMixin): @staticmethod def inactive_address_popup(width, callback_for_menu_items): """This method shows the warning popup if the address is inactive""" + dialog_text = 'Address is not currently active. Please click on Toggle button to active it.' dialog_box = MDDialog( - text='Address is not currently active. Please click on Toggle button to active it.', + text=dialog_text, size_hint=(width, .25), buttons=[ MDFlatButton(