Add address enable/disable function to addresses

This commit is contained in:
shekhar-cis 2022-05-04 19:25:30 +05:30
parent c3a39229a0
commit b01764a5a9
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
2 changed files with 17 additions and 18 deletions

View File

@ -31,6 +31,9 @@ from bitmessagekivy.baseclass.common import (
avatarImageFirstLetter, AvatarSampleWidget, ThemeClsColor, avatarImageFirstLetter, AvatarSampleWidget, ThemeClsColor,
toast toast
) )
from addresses import disable_addresses, enable_addresses
from bitmessagekivy.baseclass.popup import MyaddDetailPopup from bitmessagekivy.baseclass.popup import MyaddDetailPopup
from bitmessagekivy.baseclass.myaddress_widgets import HelperMyAddress from bitmessagekivy.baseclass.myaddress_widgets import HelperMyAddress
@ -217,20 +220,16 @@ class MyAddress(Screen, HelperMyAddress):
@staticmethod @staticmethod
def filter_address(address): def filter_address(address):
"""Method will filter the my address list data""" """Method will filter the my address list data"""
if [ # import pdb; pdb.set_trace()
x for x in [ searched_text = state.searcing_text.lower()
BMConfigParser().get(address, 'label').lower(), if BMConfigParser().search_addresses(address, searched_text):
address.lower()
]
if (state.searcing_text).lower() in x
]:
return True return True
return False 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): def disable_address_ui(self, address, instance):
"""This method is use for disabling address""" """This method is used to disable addresses from UI"""
BMConfigParser().set(str(address), 'enabled', 'false') BMConfigParser().enable_addresses(address)
BMConfigParser().save()
instance.parent.parent.theme_text_color = 'Primary' instance.parent.parent.theme_text_color = 'Primary'
instance.parent.parent.canvas.children[3].rgba = [0.5, 0.5, 0.5, 0.5] instance.parent.parent.canvas.children[3].rgba = [0.5, 0.5, 0.5, 0.5]
# try: # try:
@ -240,10 +239,9 @@ class MyAddress(Screen, HelperMyAddress):
toast('Address disabled') toast('Address disabled')
Clock.schedule_once(self.address_permision_callback, 0) Clock.schedule_once(self.address_permision_callback, 0)
def enableAddress(self, address, instance): def enable_address_ui(self, address, instance):
"""This method is use for enabling address""" """This method is used to enable addresses from UI"""
BMConfigParser().set(address, 'enabled', 'true') BMConfigParser().disable_addresses(address)
BMConfigParser().save()
instance.parent.parent.theme_text_color = 'Custom' instance.parent.parent.theme_text_color = 'Custom'
instance.parent.parent.canvas.children[3].rgba = [0, 0, 0, 0] instance.parent.parent.canvas.children[3].rgba = [0, 0, 0, 0]
# try: # try:
@ -265,6 +263,6 @@ class MyAddress(Screen, HelperMyAddress):
"""This method is used for enable or disable address""" """This method is used for enable or disable address"""
addr = instance.parent.parent.secondary_text addr = instance.parent.parent.secondary_text
if instance.active: if instance.active:
self.enableAddress(addr, instance) self.enable_address_ui(addr, instance)
else: else:
self.disableAddress(addr, instance) self.disable_address_ui(addr, instance)

View File

@ -65,8 +65,9 @@ class HelperMyAddress(DefaultLabelMixin):
@staticmethod @staticmethod
def inactive_address_popup(width, callback_for_menu_items): def inactive_address_popup(width, callback_for_menu_items):
"""This method shows the warning popup if the address is inactive""" """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( dialog_box = MDDialog(
text='Address is not currently active. Please click on Toggle button to active it.', text=dialog_text,
size_hint=(width, .25), size_hint=(width, .25),
buttons=[ buttons=[
MDFlatButton( MDFlatButton(