Fixed code quality

This commit is contained in:
shekhar-cis 2022-03-17 15:09:04 +05:30
parent d783465a3f
commit 348bee0a06
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
2 changed files with 36 additions and 23 deletions

View File

@ -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()

View File

@ -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
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'