Fixed code quality
This commit is contained in:
parent
d783465a3f
commit
348bee0a06
|
@ -14,6 +14,7 @@ from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
|
from debug import logger
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
avatarImageFirstLetter, toast,
|
avatarImageFirstLetter, toast,
|
||||||
ThemeClsColor, SwipeToDeleteItem
|
ThemeClsColor, SwipeToDeleteItem
|
||||||
|
@ -39,7 +40,7 @@ class AddressBook(Screen, HelperAddressBook):
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""Clock Schdule for method AddressBook"""
|
"""Clock Schdule for method AddressBook"""
|
||||||
self.loadAddresslist(None, 'All', '')
|
self.loadAddresslist(None, 'All', '')
|
||||||
print(dt)
|
logger.debug(dt)
|
||||||
|
|
||||||
def loadAddresslist(self, account, where="", what=""):
|
def loadAddresslist(self, account, where="", what=""):
|
||||||
"""Clock Schdule for method AddressBook"""
|
"""Clock Schdule for method AddressBook"""
|
||||||
|
@ -142,8 +143,8 @@ class AddressBook(Screen, HelperAddressBook):
|
||||||
# )
|
# )
|
||||||
# self.addbook_popup.set_normal_height()
|
# self.addbook_popup.set_normal_height()
|
||||||
self.addbook_popup = self.address_detail_popup(
|
self.addbook_popup = self.address_detail_popup(
|
||||||
self.send_message_to, self.update_addbook_label,
|
obj, self.send_message_to, self.update_addbook_label,
|
||||||
self.close_pop, width=width, obj=obj)
|
self.close_pop, width)
|
||||||
self.addbook_popup.auto_dismiss = False
|
self.addbook_popup.auto_dismiss = False
|
||||||
self.addbook_popup.open()
|
self.addbook_popup.open()
|
||||||
else:
|
else:
|
||||||
|
@ -156,7 +157,7 @@ class AddressBook(Screen, HelperAddressBook):
|
||||||
if self.ids.ml.children is not None:
|
if self.ids.ml.children is not None:
|
||||||
self.ids.tag_label.text = ''
|
self.ids.tag_label.text = ''
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
"DELETE FROM addressbook WHERE address = '{}';".format(address))
|
"DELETE FROM addressbook WHERE address = ?", address)
|
||||||
toast('Address Deleted')
|
toast('Address Deleted')
|
||||||
|
|
||||||
def close_pop(self, instance):
|
def close_pop(self, instance):
|
||||||
|
@ -174,9 +175,8 @@ class AddressBook(Screen, HelperAddressBook):
|
||||||
stored_labels.remove(label)
|
stored_labels.remove(label)
|
||||||
if label and label not in stored_labels:
|
if label and label not in stored_labels:
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
"UPDATE addressbook SET label = '{}' WHERE"
|
"UPDATE addressbook SET label = ? WHERE"
|
||||||
" address = '{}';".format(
|
"address = ?", label, self.addbook_popup.content_cls.address)
|
||||||
label, self.addbook_popup.content_cls.address))
|
|
||||||
state.kivyapp.root.ids.sc11.ids.ml.clear_widgets()
|
state.kivyapp.root.ids.sc11.ids.ml.clear_widgets()
|
||||||
state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '')
|
state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
self.addbook_popup.dismiss()
|
self.addbook_popup.dismiss()
|
||||||
|
@ -185,11 +185,13 @@ class AddressBook(Screen, HelperAddressBook):
|
||||||
def send_message_to(self, instance):
|
def send_message_to(self, instance):
|
||||||
"""Method used to fill to_address of composer autofield"""
|
"""Method used to fill to_address of composer autofield"""
|
||||||
state.kivyapp.set_navbar_for_composer()
|
state.kivyapp.set_navbar_for_composer()
|
||||||
window_obj = state.kivyapp.root.ids
|
# import pdb; pdb.set_trace()
|
||||||
window_obj.sc3.children[1].ids.txt_input.text = self.address
|
self.compose_message(None, self.address, None, None)
|
||||||
window_obj.sc3.children[1].ids.ti.text = ''
|
# window_obj = state.kivyapp.root.ids
|
||||||
window_obj.sc3.children[1].ids.btn.text = 'Select'
|
# window_obj.sc3.children[1].ids.txt_input.text = self.address
|
||||||
window_obj.sc3.children[1].ids.subject.text = ''
|
# window_obj.sc3.children[1].ids.ti.text = ''
|
||||||
window_obj.sc3.children[1].ids.body.text = ''
|
# window_obj.sc3.children[1].ids.btn.text = 'Select'
|
||||||
window_obj.scr_mngr.current = 'create'
|
# 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()
|
self.addbook_popup.dismiss()
|
||||||
|
|
|
@ -9,7 +9,7 @@ from kivymd.uix.label import MDLabel
|
||||||
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
||||||
|
|
||||||
|
|
||||||
class HelperAddressBook:
|
class HelperAddressBook(object):
|
||||||
"""Widget used in Addressbook are here"""
|
"""Widget used in Addressbook are here"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -17,15 +17,13 @@ class HelperAddressBook:
|
||||||
content = MDLabel(
|
content = MDLabel(
|
||||||
font_style='Caption',
|
font_style='Caption',
|
||||||
theme_text_color='Primary',
|
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
|
text="No contact found!" if state.searcing_text
|
||||||
else "No contact found yet...... ",
|
else "No contact found yet...... ", halign='center', size_hint_y=None, valign='top')
|
||||||
halign='center',
|
|
||||||
size_hint_y=None,
|
|
||||||
valign='top')
|
|
||||||
return content
|
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(
|
retval = MDDialog(
|
||||||
type="custom",
|
type="custom",
|
||||||
size_hint=(width, .25),
|
size_hint=(width, .25),
|
||||||
|
@ -46,3 +44,16 @@ 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'
|
||||||
|
|
Reference in New Issue
Block a user