kivy mock [base file import fixing]
This commit is contained in:
parent
e9054a4d37
commit
3c78e30c8c
|
@ -238,13 +238,17 @@ class NavigateApp(MDApp):
|
||||||
'{0}.kv'.format(all_data[kv]["kv_string"]),
|
'{0}.kv'.format(all_data[kv]["kv_string"]),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
print('{0}.kv'.format(all_data[kv]["kv_string"]))
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
# self.obj_1 = AddressBook()
|
# self.obj_1 = AddressBook()
|
||||||
kivysignalthread = UIkivySignaler()
|
kivysignalthread = UIkivySignaler()
|
||||||
kivysignalthread.daemon = True
|
kivysignalthread.daemon = True
|
||||||
kivysignalthread.start()
|
kivysignalthread.start()
|
||||||
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
||||||
return Builder.load_file(
|
# return Builder.load_file(
|
||||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
# os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||||
|
# return Builder.load_file('/home/cis/Bitmessagepeter/KivyPoject/PyBitmessage/src/tests/mock/pybitmessage/main.kv')
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Running the widgets"""
|
"""Running the widgets"""
|
||||||
|
@ -270,27 +274,28 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def getCurrentAccountData(self, text):
|
def getCurrentAccountData(self, text):
|
||||||
"""Get Current Address Account Data"""
|
"""Get Current Address Account Data"""
|
||||||
print('getCurrentAccountData 273 ---------------------------------')
|
# print('getCurrentAccountData 273 ---------------------------------')
|
||||||
if text != '':
|
# if text != '':
|
||||||
if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
# if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
||||||
self.load_selected_Image(text)
|
# self.load_selected_Image(text)
|
||||||
else:
|
# else:
|
||||||
self.set_identicon(text)
|
# self.set_identicon(text)
|
||||||
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
# self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
||||||
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
# self.root.ids.content_drawer.ids.reset_image.disabled = True
|
||||||
address_label = self.current_address_label(
|
# address_label = self.current_address_label(
|
||||||
BMConfigParser().get(text, 'label'), text)
|
# BMConfigParser().get(text, 'label'), text)
|
||||||
|
|
||||||
self.root_window.children[1].ids.toolbar.title = address_label
|
# self.root_window.children[1].ids.toolbar.title = address_label
|
||||||
state.association = text
|
# state.association = text
|
||||||
state.searcing_text = ''
|
# state.searcing_text = ''
|
||||||
LoadingPopup().open()
|
# LoadingPopup().open()
|
||||||
self.set_message_count()
|
# self.set_message_count()
|
||||||
for nav_obj in self.root.ids.content_drawer.children[
|
# for nav_obj in self.root.ids.content_drawer.children[
|
||||||
0].children[0].children[0].children:
|
# 0].children[0].children[0].children:
|
||||||
nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
# nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
||||||
self.fileManagerSetting()
|
# self.fileManagerSetting()
|
||||||
Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
# Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
||||||
|
pass
|
||||||
|
|
||||||
def fileManagerSetting(self):
|
def fileManagerSetting(self):
|
||||||
"""This method is for file manager setting"""
|
"""This method is for file manager setting"""
|
||||||
|
@ -303,26 +308,27 @@ class NavigateApp(MDApp):
|
||||||
"""This method set the current accout data on all the screens"""
|
"""This method set the current accout data on all the screens"""
|
||||||
print('setCurrentAccountData 304 ---------------------------------')
|
print('setCurrentAccountData 304 ---------------------------------')
|
||||||
|
|
||||||
self.root.ids.sc1.ids.ml.clear_widgets()
|
# self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc1.loadMessagelist(state.association)
|
# self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
|
|
||||||
self.root.ids.sc4.ids.ml.clear_widgets()
|
# self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc4.children[2].children[2].ids.search_field.text = ''
|
# self.root.ids.sc4.children[2].children[2].ids.search_field.text = ''
|
||||||
self.root.ids.sc4.loadSent(state.association)
|
# self.root.ids.sc4.loadSent(state.association)
|
||||||
|
|
||||||
self.root.ids.sc16.clear_widgets()
|
# self.root.ids.sc16.clear_widgets()
|
||||||
self.root.ids.sc16.add_widget(Draft())
|
# self.root.ids.sc16.add_widget(Draft())
|
||||||
|
|
||||||
self.root.ids.sc5.clear_widgets()
|
# self.root.ids.sc5.clear_widgets()
|
||||||
self.root.ids.sc5.add_widget(Trash())
|
# self.root.ids.sc5.add_widget(Trash())
|
||||||
|
|
||||||
self.root.ids.sc17.clear_widgets()
|
# self.root.ids.sc17.clear_widgets()
|
||||||
self.root.ids.sc17.add_widget(Allmails())
|
# self.root.ids.sc17.add_widget(Allmails())
|
||||||
|
|
||||||
self.root.ids.sc10.ids.ml.clear_widgets()
|
# self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc10.init_ui()
|
# self.root.ids.sc10.init_ui()
|
||||||
|
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getCurrentAccount():
|
def getCurrentAccount():
|
||||||
|
@ -382,39 +388,40 @@ class NavigateApp(MDApp):
|
||||||
return is_available
|
return is_available
|
||||||
|
|
||||||
def savecontact(self, instance):
|
def savecontact(self, instance):
|
||||||
"""Method is used for saving contacts"""
|
# """Method is used for saving contacts"""
|
||||||
pupup_obj = self.add_popup.content_cls
|
# pupup_obj = self.add_popup.content_cls
|
||||||
label = pupup_obj.ids.label.text.strip()
|
# label = pupup_obj.ids.label.text.strip()
|
||||||
address = pupup_obj.ids.address.text.strip()
|
# address = pupup_obj.ids.address.text.strip()
|
||||||
if label == '' and address == '':
|
# if label == '' and address == '':
|
||||||
pupup_obj.ids.label.focus = True
|
# pupup_obj.ids.label.focus = True
|
||||||
pupup_obj.ids.address.focus = True
|
# pupup_obj.ids.address.focus = True
|
||||||
elif address == '':
|
# elif address == '':
|
||||||
pupup_obj.ids.address.focus = True
|
# pupup_obj.ids.address.focus = True
|
||||||
elif label == '':
|
# elif label == '':
|
||||||
pupup_obj.ids.label.focus = True
|
# pupup_obj.ids.label.focus = True
|
||||||
else:
|
# else:
|
||||||
pupup_obj.ids.address.focus = True
|
# pupup_obj.ids.address.focus = True
|
||||||
# pupup_obj.ids.label.focus = True
|
# # pupup_obj.ids.label.focus = True
|
||||||
|
|
||||||
stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
# stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
||||||
folder="addressbook")]
|
# folder="addressbook")]
|
||||||
stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
# stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
||||||
folder="addressbook")]
|
# folder="addressbook")]
|
||||||
if label and address and address not in stored_address \
|
# if label and address and address not in stored_address \
|
||||||
and label not in stored_labels and pupup_obj.valid:
|
# and label not in stored_labels and pupup_obj.valid:
|
||||||
# state.navinstance = self.parent.children[1]
|
# # state.navinstance = self.parent.children[1]
|
||||||
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
# queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
||||||
self.add_popup.dismiss()
|
# self.add_popup.dismiss()
|
||||||
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
# sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
||||||
try:
|
# try:
|
||||||
rootIds = self.root.ids
|
# rootIds = self.root.ids
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
rootIds = state.kivyapp.root.ids
|
# rootIds = state.kivyapp.root.ids
|
||||||
rootIds.sc11.ids.ml.clear_widgets()
|
# rootIds.sc11.ids.ml.clear_widgets()
|
||||||
rootIds.sc11.loadAddresslist(None, 'All', '')
|
# rootIds.sc11.loadAddresslist(None, 'All', '')
|
||||||
rootIds.scr_mngr.current = 'addressbook'
|
# rootIds.scr_mngr.current = 'addressbook'
|
||||||
toast('Saved')
|
# toast('Saved')
|
||||||
|
pass
|
||||||
|
|
||||||
def close_pop(self, instance):
|
def close_pop(self, instance):
|
||||||
"""Pop is Canceled"""
|
"""Pop is Canceled"""
|
||||||
|
@ -451,19 +458,19 @@ class NavigateApp(MDApp):
|
||||||
|
|
||||||
def get_default_logo(self, instance):
|
def get_default_logo(self, instance):
|
||||||
"""Getting default logo image"""
|
"""Getting default logo image"""
|
||||||
if self.variable_1:
|
# if self.variable_1:
|
||||||
first_addr = self.variable_1[0]
|
# first_addr = self.variable_1[0]
|
||||||
if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
# if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
||||||
if os.path.exists(
|
# if os.path.exists(
|
||||||
state.imageDir + '/default_identicon/{}.png'.format(first_addr)):
|
# state.imageDir + '/default_identicon/{}.png'.format(first_addr)):
|
||||||
return state.imageDir + '/default_identicon/{}.png'.format(
|
# return state.imageDir + '/default_identicon/{}.png'.format(
|
||||||
first_addr)
|
# first_addr)
|
||||||
else:
|
# else:
|
||||||
img = identiconGeneration.generate(first_addr)
|
# img = identiconGeneration.generate(first_addr)
|
||||||
instance.texture = img.texture
|
# instance.texture = img.texture
|
||||||
return
|
# return
|
||||||
return state.imageDir + '/drawer_logo1.png'
|
# return state.imageDir + '/drawer_logo1.png'
|
||||||
|
pass
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addressexist():
|
def addressexist():
|
||||||
print('addressexist 469 --------------------------')
|
print('addressexist 469 --------------------------')
|
||||||
|
@ -473,232 +480,240 @@ class NavigateApp(MDApp):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def on_key(self, window, key, *args):
|
def on_key(self, window, key, *args):
|
||||||
# pylint: disable=inconsistent-return-statements, too-many-branches
|
pass
|
||||||
"""Method is used for going on previous screen"""
|
# # pylint: disable=inconsistent-return-statements, too-many-branches
|
||||||
if key == 27:
|
# """Method is used for going on previous screen"""
|
||||||
if state.in_search_mode and self.root.ids.scr_mngr.current not in [
|
# if key == 27:
|
||||||
"mailDetail", "create"]:
|
# if state.in_search_mode and self.root.ids.scr_mngr.current not in [
|
||||||
self.closeSearchScreen()
|
# "mailDetail", "create"]:
|
||||||
elif self.root.ids.scr_mngr.current == "mailDetail":
|
# self.closeSearchScreen()
|
||||||
self.root.ids.scr_mngr.current = 'sent'\
|
# elif self.root.ids.scr_mngr.current == "mailDetail":
|
||||||
if state.detailPageType == 'sent' else 'inbox' \
|
# self.root.ids.scr_mngr.current = 'sent'\
|
||||||
if state.detailPageType == 'inbox' else 'draft'
|
# if state.detailPageType == 'sent' else 'inbox' \
|
||||||
self.back_press()
|
# if state.detailPageType == 'inbox' else 'draft'
|
||||||
if state.in_search_mode and state.searcing_text:
|
# self.back_press()
|
||||||
toolbar_obj = self.root.ids.toolbar
|
# if state.in_search_mode and state.searcing_text:
|
||||||
toolbar_obj.left_action_items = [
|
# toolbar_obj = self.root.ids.toolbar
|
||||||
['arrow-left', lambda x: self.closeSearchScreen()]]
|
# toolbar_obj.left_action_items = [
|
||||||
toolbar_obj.right_action_items = []
|
# ['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
self.root.ids.toolbar.title = ''
|
# toolbar_obj.right_action_items = []
|
||||||
elif self.root.ids.scr_mngr.current == "create":
|
# self.root.ids.toolbar.title = ''
|
||||||
self.save_draft()
|
# elif self.root.ids.scr_mngr.current == "create":
|
||||||
self.set_common_header()
|
# self.save_draft()
|
||||||
state.in_composer = False
|
# self.set_common_header()
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
# state.in_composer = False
|
||||||
elif self.root.ids.scr_mngr.current == "showqrcode":
|
# self.root.ids.scr_mngr.current = 'inbox'
|
||||||
self.set_common_header()
|
# elif self.root.ids.scr_mngr.current == "showqrcode":
|
||||||
self.root.ids.scr_mngr.current = 'myaddress'
|
# self.set_common_header()
|
||||||
elif self.root.ids.scr_mngr.current == "random":
|
# self.root.ids.scr_mngr.current = 'myaddress'
|
||||||
self.root.ids.scr_mngr.current = 'login'
|
# elif self.root.ids.scr_mngr.current == "random":
|
||||||
elif self.root.ids.scr_mngr.current == 'pay-options':
|
# self.root.ids.scr_mngr.current = 'login'
|
||||||
self.set_common_header()
|
# elif self.root.ids.scr_mngr.current == 'pay-options':
|
||||||
self.root.ids.scr_mngr.current = 'payment'
|
# self.set_common_header()
|
||||||
elif self.root.ids.scr_mngr.current == 'chroom':
|
# self.root.ids.scr_mngr.current = 'payment'
|
||||||
if state.association:
|
# elif self.root.ids.scr_mngr.current == 'chroom':
|
||||||
address_label = self.current_address_label(
|
# if state.association:
|
||||||
BMConfigParser().get(
|
# address_label = self.current_address_label(
|
||||||
state.association, 'label'), state.association)
|
# BMConfigParser().get(
|
||||||
self.root.ids.toolbar.title = address_label
|
# state.association, 'label'), state.association)
|
||||||
self.set_common_header()
|
# self.root.ids.toolbar.title = address_label
|
||||||
self.root.ids.scr_mngr.transition = FallOutTransition()
|
# self.set_common_header()
|
||||||
self.root.ids.scr_mngr.current = 'chlist'
|
# self.root.ids.scr_mngr.transition = FallOutTransition()
|
||||||
self.root.ids.scr_mngr.transition = SlideTransition()
|
# self.root.ids.scr_mngr.current = 'chlist'
|
||||||
else:
|
# self.root.ids.scr_mngr.transition = SlideTransition()
|
||||||
if state.kivyapp.variable_1:
|
# else:
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
# if state.kivyapp.variable_1:
|
||||||
self.root.ids.scr_mngr.transition.direction = 'right'
|
# self.root.ids.scr_mngr.current = 'inbox'
|
||||||
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
# self.root.ids.scr_mngr.transition.direction = 'right'
|
||||||
return True
|
# self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
||||||
elif key == 13 and state.searcing_text and not state.in_composer:
|
# return True
|
||||||
if state.search_screen == 'inbox':
|
# elif key == 13 and state.searcing_text and not state.in_composer:
|
||||||
self.root.ids.sc1.children[1].active = True
|
# if state.search_screen == 'inbox':
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# self.root.ids.sc1.children[1].active = True
|
||||||
elif state.search_screen == 'addressbook':
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
self.root.ids.sc11.children[1].active = True
|
# elif state.search_screen == 'addressbook':
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# self.root.ids.sc11.children[1].active = True
|
||||||
elif state.search_screen == 'myaddress':
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
self.loadMyAddressScreen(True)
|
# elif state.search_screen == 'myaddress':
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# self.loadMyAddressScreen(True)
|
||||||
elif state.search_screen == 'sent':
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
self.root.ids.sc4.children[1].active = True
|
# elif state.search_screen == 'sent':
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# self.root.ids.sc4.children[1].active = True
|
||||||
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
|
||||||
def search_callback(self, dt=0):
|
def search_callback(self, dt=0):
|
||||||
"""Show data after loader is loaded"""
|
"""Show data after loader is loaded"""
|
||||||
if state.search_screen == 'inbox':
|
# if state.search_screen == 'inbox':
|
||||||
self.root.ids.sc1.ids.ml.clear_widgets()
|
# self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc1.loadMessagelist(state.association)
|
# self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
self.root.ids.sc1.children[1].active = False
|
# self.root.ids.sc1.children[1].active = False
|
||||||
elif state.search_screen == 'addressbook':
|
# elif state.search_screen == 'addressbook':
|
||||||
self.root.ids.sc11.ids.ml.clear_widgets()
|
# self.root.ids.sc11.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
# self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
self.root.ids.sc11.children[1].active = False
|
# self.root.ids.sc11.children[1].active = False
|
||||||
elif state.search_screen == 'myaddress':
|
# elif state.search_screen == 'myaddress':
|
||||||
self.root.ids.sc10.ids.ml.clear_widgets()
|
# self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc10.init_ui()
|
# self.root.ids.sc10.init_ui()
|
||||||
self.loadMyAddressScreen(False)
|
# self.loadMyAddressScreen(False)
|
||||||
else:
|
# else:
|
||||||
self.root.ids.sc4.ids.ml.clear_widgets()
|
# self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc4.loadSent(state.association)
|
# self.root.ids.sc4.loadSent(state.association)
|
||||||
self.root.ids.sc4.children[1].active = False
|
# self.root.ids.sc4.children[1].active = False
|
||||||
self.root.ids.scr_mngr.current = state.search_screen
|
# self.root.ids.scr_mngr.current = state.search_screen
|
||||||
|
pass
|
||||||
|
|
||||||
def loadMyAddressScreen(self, action):
|
def loadMyAddressScreen(self, action):
|
||||||
"""loadMyAddressScreen method spin the loader"""
|
# """loadMyAddressScreen method spin the loader"""
|
||||||
if len(self.root.ids.sc10.children) <= 2:
|
# if len(self.root.ids.sc10.children) <= 2:
|
||||||
self.root.ids.sc10.children[0].active = action
|
# self.root.ids.sc10.children[0].active = action
|
||||||
else:
|
# else:
|
||||||
self.root.ids.sc10.children[1].active = action
|
# self.root.ids.sc10.children[1].active = action
|
||||||
|
pass
|
||||||
def save_draft(self):
|
def save_draft(self):
|
||||||
"""Saving drafts messages"""
|
# """Saving drafts messages"""
|
||||||
composer_objs = self.root
|
# composer_objs = self.root
|
||||||
from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
|
# from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
|
||||||
# to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
|
# # to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
|
||||||
if from_addr and state.detailPageType != 'draft' \
|
# if from_addr and state.detailPageType != 'draft' \
|
||||||
and not state.in_sent_method:
|
# and not state.in_sent_method:
|
||||||
Draft().draft_msg(composer_objs)
|
# Draft().draft_msg(composer_objs)
|
||||||
return
|
# return
|
||||||
|
pass
|
||||||
|
|
||||||
def reset(self, *args):
|
def reset(self, *args):
|
||||||
"""Set transition direction"""
|
# """Set transition direction"""
|
||||||
self.root.ids.scr_mngr.transition.direction = 'left'
|
# self.root.ids.scr_mngr.transition.direction = 'left'
|
||||||
self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
|
# self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
|
||||||
|
pass
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def status_dispatching(data):
|
def status_dispatching(data):
|
||||||
"""Dispatching Status acknowledgment"""
|
# """Dispatching Status acknowledgment"""
|
||||||
ackData, message = data
|
# ackData, message = data
|
||||||
if state.ackdata == ackData:
|
# if state.ackdata == ackData:
|
||||||
state.status.status = message
|
# state.status.status = message
|
||||||
|
pass
|
||||||
|
|
||||||
def clear_composer(self):
|
def clear_composer(self):
|
||||||
"""If slow down, the new composer edit screen"""
|
# """If slow down, the new composer edit screen"""
|
||||||
self.set_navbar_for_composer()
|
# self.set_navbar_for_composer()
|
||||||
composer_obj = self.root.ids.sc3.children[1].ids
|
# composer_obj = self.root.ids.sc3.children[1].ids
|
||||||
composer_obj.ti.text = ''
|
# composer_obj.ti.text = ''
|
||||||
composer_obj.btn.text = 'Select'
|
# composer_obj.btn.text = 'Select'
|
||||||
composer_obj.txt_input.text = ''
|
# composer_obj.txt_input.text = ''
|
||||||
composer_obj.subject.text = ''
|
# composer_obj.subject.text = ''
|
||||||
composer_obj.body.text = ''
|
# composer_obj.body.text = ''
|
||||||
state.in_composer = True
|
# state.in_composer = True
|
||||||
state.in_sent_method = False
|
# state.in_sent_method = False
|
||||||
|
pass
|
||||||
|
|
||||||
def set_navbar_for_composer(self):
|
def set_navbar_for_composer(self):
|
||||||
"""Clearing toolbar data when composer open"""
|
# """Clearing toolbar data when composer open"""
|
||||||
self.root.ids.toolbar.left_action_items = [
|
# self.root.ids.toolbar.left_action_items = [
|
||||||
['arrow-left', lambda x: self.back_press()]]
|
# ['arrow-left', lambda x: self.back_press()]]
|
||||||
self.root.ids.toolbar.right_action_items = [
|
# self.root.ids.toolbar.right_action_items = [
|
||||||
['refresh',
|
# ['refresh',
|
||||||
lambda x: self.root.ids.sc3.children[1].reset_composer()],
|
# lambda x: self.root.ids.sc3.children[1].reset_composer()],
|
||||||
['send',
|
# ['send',
|
||||||
lambda x: self.root.ids.sc3.children[1].send(self)]]
|
# lambda x: self.root.ids.sc3.children[1].send(self)]]
|
||||||
|
pass
|
||||||
def set_toolbar_for_QrCode(self):
|
def set_toolbar_for_QrCode(self):
|
||||||
"""This method is use for setting Qr code toolbar."""
|
# """This method is use for setting Qr code toolbar."""
|
||||||
self.root.ids.toolbar.left_action_items = [
|
# self.root.ids.toolbar.left_action_items = [
|
||||||
['arrow-left', lambda x: self.back_press()]]
|
# ['arrow-left', lambda x: self.back_press()]]
|
||||||
self.root.ids.toolbar.right_action_items = []
|
# self.root.ids.toolbar.right_action_items = []
|
||||||
|
pass
|
||||||
|
|
||||||
def set_common_header(self):
|
def set_common_header(self):
|
||||||
"""Common header for all window"""
|
# """Common header for all window"""
|
||||||
self.root.ids.toolbar.right_action_items = [
|
# self.root.ids.toolbar.right_action_items = [
|
||||||
['account-plus', lambda x: self.addingtoaddressbook()]]
|
# ['account-plus', lambda x: self.addingtoaddressbook()]]
|
||||||
|
# # self.root.ids.toolbar.left_action_items = [
|
||||||
|
# # ['menu', lambda x: self.root.toggle_nav_drawer()]]
|
||||||
# self.root.ids.toolbar.left_action_items = [
|
# self.root.ids.toolbar.left_action_items = [
|
||||||
# ['menu', lambda x: self.root.toggle_nav_drawer()]]
|
# ['menu', lambda x: self.root.ids.nav_drawer.set_state("toggle")]]
|
||||||
self.root.ids.toolbar.left_action_items = [
|
# return
|
||||||
['menu', lambda x: self.root.ids.nav_drawer.set_state("toggle")]]
|
pass
|
||||||
return
|
|
||||||
|
|
||||||
def back_press(self):
|
def back_press(self):
|
||||||
"""Method for, reverting composer to previous page"""
|
# """Method for, reverting composer to previous page"""
|
||||||
if self.root.ids.scr_mngr.current == 'create':
|
# if self.root.ids.scr_mngr.current == 'create':
|
||||||
self.save_draft()
|
# self.save_draft()
|
||||||
if self.root.ids.scr_mngr.current == \
|
# if self.root.ids.scr_mngr.current == \
|
||||||
'mailDetail' and state.in_search_mode:
|
# 'mailDetail' and state.in_search_mode:
|
||||||
toolbar_obj = self.root.ids.toolbar
|
# toolbar_obj = self.root.ids.toolbar
|
||||||
toolbar_obj.left_action_items = [
|
# toolbar_obj.left_action_items = [
|
||||||
['arrow-left', lambda x: self.closeSearchScreen()]]
|
# ['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
toolbar_obj.right_action_items = []
|
# toolbar_obj.right_action_items = []
|
||||||
self.root.ids.toolbar.title = ''
|
# self.root.ids.toolbar.title = ''
|
||||||
else:
|
# else:
|
||||||
self.set_common_header()
|
# self.set_common_header()
|
||||||
if self.root.ids.scr_mngr.current == 'chroom' and state.association:
|
# if self.root.ids.scr_mngr.current == 'chroom' and state.association:
|
||||||
self.root.ids.scr_mngr.transition = FallOutTransition()
|
# self.root.ids.scr_mngr.transition = FallOutTransition()
|
||||||
address_label = self.current_address_label(
|
# address_label = self.current_address_label(
|
||||||
BMConfigParser().get(
|
# BMConfigParser().get(
|
||||||
state.association, 'label'), state.association)
|
# state.association, 'label'), state.association)
|
||||||
self.root.ids.toolbar.title = address_label
|
# self.root.ids.toolbar.title = address_label
|
||||||
self.root.ids.scr_mngr.current = 'inbox' \
|
# self.root.ids.scr_mngr.current = 'inbox' \
|
||||||
if state.in_composer else 'allmails'\
|
# if state.in_composer else 'allmails'\
|
||||||
if state.is_allmail else state.detailPageType\
|
# if state.is_allmail else state.detailPageType\
|
||||||
if state.detailPageType else 'myaddress'\
|
# if state.detailPageType else 'myaddress'\
|
||||||
if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\
|
# if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\
|
||||||
if self.root.ids.scr_mngr.current == 'pay-options' else 'chlist'\
|
# if self.root.ids.scr_mngr.current == 'pay-options' else 'chlist'\
|
||||||
if self.root.ids.scr_mngr.current == 'chroom' else 'inbox'
|
# if self.root.ids.scr_mngr.current == 'chroom' else 'inbox'
|
||||||
if self.root.ids.scr_mngr.current == 'chlist':
|
# if self.root.ids.scr_mngr.current == 'chlist':
|
||||||
self.root.ids.scr_mngr.transition = SlideTransition()
|
# self.root.ids.scr_mngr.transition = SlideTransition()
|
||||||
self.root.ids.scr_mngr.transition.direction = 'right'
|
# self.root.ids.scr_mngr.transition.direction = 'right'
|
||||||
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
# self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
||||||
if state.is_allmail or state.detailPageType == 'draft':
|
# if state.is_allmail or state.detailPageType == 'draft':
|
||||||
state.is_allmail = False
|
# state.is_allmail = False
|
||||||
state.detailPageType = ''
|
# state.detailPageType = ''
|
||||||
state.in_composer = False
|
# state.in_composer = False
|
||||||
|
pass
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_inbox_count():
|
def get_inbox_count():
|
||||||
"""Getting inbox count"""
|
# """Getting inbox count"""
|
||||||
state.inbox_count = str(sqlQuery(
|
# state.inbox_count = str(sqlQuery(
|
||||||
"SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
|
# "SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
|
||||||
" folder = 'inbox' ;".format(state.association))[0][0])
|
# " folder = 'inbox' ;".format(state.association))[0][0])
|
||||||
|
pass
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_sent_count():
|
def get_sent_count():
|
||||||
"""Getting sent count"""
|
# """Getting sent count"""
|
||||||
state.sent_count = str(sqlQuery(
|
# state.sent_count = str(sqlQuery(
|
||||||
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
# "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
||||||
" folder = 'sent' ;".format(state.association))[0][0])
|
# " folder = 'sent' ;".format(state.association))[0][0])
|
||||||
|
pass
|
||||||
def set_message_count(self):
|
def set_message_count(self):
|
||||||
"""Setting message count"""
|
"""Setting message count"""
|
||||||
msg_counter_objs = state.kivyapp.root.children[0].children[0].ids
|
# msg_counter_objs = state.kivyapp.root.children[0].children[0].ids
|
||||||
# try:
|
# try:
|
||||||
# msg_counter_objs = (
|
# msg_counter_objs = (
|
||||||
# self.root_window.children[0].children[2].children[0].ids)
|
# self.root_window.children[0].children[2].children[0].ids)
|
||||||
# except Exception:
|
# except Exception:
|
||||||
# msg_counter_objs = (
|
# msg_counter_objs = (
|
||||||
# self.root_window.children[2].children[2].children[0].ids)
|
# self.root_window.children[2].children[2].children[0].ids)
|
||||||
self.get_inbox_count()
|
# self.get_inbox_count()
|
||||||
self.get_sent_count()
|
# self.get_sent_count()
|
||||||
state.trash_count = str(sqlQuery(
|
# state.trash_count = str(sqlQuery(
|
||||||
"SELECT (SELECT count(*) FROM sent"
|
# "SELECT (SELECT count(*) FROM sent"
|
||||||
" where fromaddress = '{0}' and folder = 'trash' )"
|
# " where fromaddress = '{0}' and folder = 'trash' )"
|
||||||
"+(SELECT count(*) FROM inbox where toaddress = '{0}' and"
|
# "+(SELECT count(*) FROM inbox where toaddress = '{0}' and"
|
||||||
" folder = 'trash') AS SumCount".format(state.association))[0][0])
|
# " folder = 'trash') AS SumCount".format(state.association))[0][0])
|
||||||
state.draft_count = str(sqlQuery(
|
# state.draft_count = str(sqlQuery(
|
||||||
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
# "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
||||||
" folder = 'draft' ;".format(state.association))[0][0])
|
# " folder = 'draft' ;".format(state.association))[0][0])
|
||||||
state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
# state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
||||||
if msg_counter_objs:
|
# if msg_counter_objs:
|
||||||
msg_counter_objs.send_cnt.badge_text = state.sent_count
|
# msg_counter_objs.send_cnt.badge_text = state.sent_count
|
||||||
msg_counter_objs.inbox_cnt.badge_text = state.inbox_count
|
# msg_counter_objs.inbox_cnt.badge_text = state.inbox_count
|
||||||
msg_counter_objs.trash_cnt.badge_text = state.trash_count
|
# msg_counter_objs.trash_cnt.badge_text = state.trash_count
|
||||||
msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
# msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
||||||
msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
# msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||||
|
pass
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
"""Setting message count"""
|
# """Setting message count"""
|
||||||
self.set_message_count()
|
# self.set_message_count()
|
||||||
|
pass
|
||||||
|
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
# def on_stop():
|
# def on_stop():
|
||||||
|
@ -729,192 +744,199 @@ class NavigateApp(MDApp):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def searchQuery(self, instance):
|
def searchQuery(self, instance):
|
||||||
"""Showing searched mails"""
|
# """Showing searched mails"""
|
||||||
state.search_screen = self.root.ids.scr_mngr.current
|
# state.search_screen = self.root.ids.scr_mngr.current
|
||||||
state.searcing_text = str(instance.text).strip()
|
# state.searcing_text = str(instance.text).strip()
|
||||||
if instance.focus and state.searcing_text:
|
# if instance.focus and state.searcing_text:
|
||||||
toolbar_obj = self.root.ids.toolbar
|
# toolbar_obj = self.root.ids.toolbar
|
||||||
toolbar_obj.left_action_items = [
|
# toolbar_obj.left_action_items = [
|
||||||
['arrow-left', lambda x: self.closeSearchScreen()]]
|
# ['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
toolbar_obj.right_action_items = []
|
# toolbar_obj.right_action_items = []
|
||||||
self.root.ids.toolbar.title = ''
|
# self.root.ids.toolbar.title = ''
|
||||||
state.in_search_mode = True
|
# state.in_search_mode = True
|
||||||
|
pass
|
||||||
|
|
||||||
def closeSearchScreen(self):
|
def closeSearchScreen(self):
|
||||||
"""Function for close search screen"""
|
"""Function for close search screen"""
|
||||||
self.set_common_header()
|
# self.set_common_header()
|
||||||
if state.association:
|
# if state.association:
|
||||||
address_label = self.current_address_label(
|
# address_label = self.current_address_label(
|
||||||
BMConfigParser().get(
|
# BMConfigParser().get(
|
||||||
state.association, 'label'), state.association)
|
# state.association, 'label'), state.association)
|
||||||
self.root.ids.toolbar.title = address_label
|
# self.root.ids.toolbar.title = address_label
|
||||||
state.searcing_text = ''
|
# state.searcing_text = ''
|
||||||
self.refreshScreen()
|
# self.refreshScreen()
|
||||||
state.in_search_mode = False
|
# state.in_search_mode = False
|
||||||
|
pass
|
||||||
|
|
||||||
def refreshScreen(self):
|
def refreshScreen(self):
|
||||||
"""Method show search button only on inbox or sent screen"""
|
# """Method show search button only on inbox or sent screen"""
|
||||||
# pylint: disable=unused-variable
|
# # pylint: disable=unused-variable
|
||||||
state.searcing_text = ''
|
# state.searcing_text = ''
|
||||||
if state.search_screen == 'inbox':
|
# if state.search_screen == 'inbox':
|
||||||
self.root.ids.sc1.ids.inbox_search.ids.search_field.text = ''
|
# self.root.ids.sc1.ids.inbox_search.ids.search_field.text = ''
|
||||||
# try:
|
# # try:
|
||||||
# self.root.ids.sc1.children[
|
# # self.root.ids.sc1.children[
|
||||||
# 3].children[2].ids.search_field.text = ''
|
# # 3].children[2].ids.search_field.text = ''
|
||||||
# except Exception:
|
# # except Exception:
|
||||||
# self.root.ids.sc1.children[
|
# # self.root.ids.sc1.children[
|
||||||
# 2].children[2].ids.search_field.text = ''
|
# # 2].children[2].ids.search_field.text = ''
|
||||||
self.root.ids.sc1.children[1].active = True
|
# self.root.ids.sc1.children[1].active = True
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
elif state.search_screen == 'addressbook':
|
# elif state.search_screen == 'addressbook':
|
||||||
self.root.ids.sc11.ids.address_search.ids.search_field.text = ''
|
# self.root.ids.sc11.ids.address_search.ids.search_field.text = ''
|
||||||
# self.root.ids.sc11.children[
|
# # self.root.ids.sc11.children[
|
||||||
# 2].children[2].ids.search_field.text = ''
|
# # 2].children[2].ids.search_field.text = ''
|
||||||
self.root.ids.sc11.children[
|
# self.root.ids.sc11.children[
|
||||||
1].active = True
|
# 1].active = True
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
elif state.search_screen == 'myaddress':
|
# elif state.search_screen == 'myaddress':
|
||||||
self.root.ids.sc10.ids.search_bar.ids.search_field.text = ''
|
# self.root.ids.sc10.ids.search_bar.ids.search_field.text = ''
|
||||||
# try:
|
# # try:
|
||||||
# self.root.ids.sc10.children[
|
# # self.root.ids.sc10.children[
|
||||||
# 1].children[2].ids.search_field.text = ''
|
# # 1].children[2].ids.search_field.text = ''
|
||||||
# except Exception:
|
# # except Exception:
|
||||||
# self.root.ids.sc10.children[
|
# # self.root.ids.sc10.children[
|
||||||
# 2].children[2].ids.search_field.text = ''
|
# # 2].children[2].ids.search_field.text = ''
|
||||||
self.loadMyAddressScreen(True)
|
# self.loadMyAddressScreen(True)
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
else:
|
# else:
|
||||||
self.root.ids.sc4.ids.sent_search.ids.search_field.text = ''
|
# self.root.ids.sc4.ids.sent_search.ids.search_field.text = ''
|
||||||
# self.root.ids.sc4.children[
|
# # self.root.ids.sc4.children[
|
||||||
# 2].children[2].ids.search_field.text = ''
|
# # 2].children[2].ids.search_field.text = ''
|
||||||
self.root.ids.sc4.children[1].active = True
|
# self.root.ids.sc4.children[1].active = True
|
||||||
Clock.schedule_once(self.search_callback, 0.5)
|
# Clock.schedule_once(self.search_callback, 0.5)
|
||||||
return
|
# return
|
||||||
|
pass
|
||||||
|
|
||||||
def set_identicon(self, text):
|
def set_identicon(self, text):
|
||||||
"""Show identicon in address spinner"""
|
# """Show identicon in address spinner"""
|
||||||
img = identiconGeneration.generate(text)
|
# img = identiconGeneration.generate(text)
|
||||||
# self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
# # self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
||||||
# below line is for displaing logo
|
# # below line is for displaing logo
|
||||||
self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
# self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
||||||
|
pass
|
||||||
def set_mail_detail_header(self):
|
def set_mail_detail_header(self):
|
||||||
"""Setting the details of the page"""
|
# """Setting the details of the page"""
|
||||||
if state.association and state.in_search_mode:
|
# if state.association and state.in_search_mode:
|
||||||
address_label = self.current_address_label(
|
# address_label = self.current_address_label(
|
||||||
BMConfigParser().get(
|
# BMConfigParser().get(
|
||||||
state.association, 'label'), state.association)
|
# state.association, 'label'), state.association)
|
||||||
self.root.ids.toolbar.title = address_label
|
# self.root.ids.toolbar.title = address_label
|
||||||
toolbar_obj = self.root.ids.toolbar
|
# toolbar_obj = self.root.ids.toolbar
|
||||||
toolbar_obj.left_action_items = [
|
# toolbar_obj.left_action_items = [
|
||||||
['arrow-left', lambda x: self.back_press()]]
|
# ['arrow-left', lambda x: self.back_press()]]
|
||||||
delete_btn = ['delete-forever',
|
# delete_btn = ['delete-forever',
|
||||||
lambda x: self.root.ids.sc14.delete_mail()]
|
# lambda x: self.root.ids.sc14.delete_mail()]
|
||||||
dynamic_list = []
|
# dynamic_list = []
|
||||||
if state.detailPageType == 'inbox':
|
# if state.detailPageType == 'inbox':
|
||||||
dynamic_list = [
|
# dynamic_list = [
|
||||||
['reply', lambda x: self.root.ids.sc14.inbox_reply()],
|
# ['reply', lambda x: self.root.ids.sc14.inbox_reply()],
|
||||||
delete_btn]
|
# delete_btn]
|
||||||
elif state.detailPageType == 'sent':
|
# elif state.detailPageType == 'sent':
|
||||||
dynamic_list = [delete_btn]
|
# dynamic_list = [delete_btn]
|
||||||
elif state.detailPageType == 'draft':
|
# elif state.detailPageType == 'draft':
|
||||||
dynamic_list = [
|
# dynamic_list = [
|
||||||
['pencil', lambda x: self.root.ids.sc14.write_msg(self)],
|
# ['pencil', lambda x: self.root.ids.sc14.write_msg(self)],
|
||||||
delete_btn]
|
# delete_btn]
|
||||||
toolbar_obj.right_action_items = dynamic_list
|
# toolbar_obj.right_action_items = dynamic_list
|
||||||
|
pass
|
||||||
def load_screen(self, instance):
|
def load_screen(self, instance):
|
||||||
"""This method is used for loading screen on every click"""
|
# """This method is used for loading screen on every click"""
|
||||||
if instance.text == 'Inbox':
|
# if instance.text == 'Inbox':
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
# self.root.ids.scr_mngr.current = 'inbox'
|
||||||
self.root.ids.sc1.children[1].active = True
|
# self.root.ids.sc1.children[1].active = True
|
||||||
elif instance.text == 'All Mails':
|
# elif instance.text == 'All Mails':
|
||||||
self.root.ids.scr_mngr.current = 'allmails'
|
# self.root.ids.scr_mngr.current = 'allmails'
|
||||||
try:
|
# try:
|
||||||
self.root.ids.sc17.children[1].active = True
|
# self.root.ids.sc17.children[1].active = True
|
||||||
except Exception:
|
# except Exception:
|
||||||
self.root.ids.sc17.children[0].children[1].active = True
|
# self.root.ids.sc17.children[0].children[1].active = True
|
||||||
elif instance.text == 'Trash':
|
# elif instance.text == 'Trash':
|
||||||
self.root.ids.scr_mngr.current = 'trash'
|
# self.root.ids.scr_mngr.current = 'trash'
|
||||||
try:
|
# try:
|
||||||
self.root.ids.sc5.children[1].active = True
|
# self.root.ids.sc5.children[1].active = True
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
self.root.ids.sc5.children[0].children[1].active = True
|
# self.root.ids.sc5.children[0].children[1].active = True
|
||||||
Clock.schedule_once(partial(self.load_screen_callback, instance), 1)
|
# Clock.schedule_once(partial(self.load_screen_callback, instance), 1)
|
||||||
|
pass
|
||||||
|
|
||||||
def load_screen_callback(self, instance, dt=0):
|
def load_screen_callback(self, instance, dt=0):
|
||||||
"""This method is rotating loader for few seconds"""
|
# """This method is rotating loader for few seconds"""
|
||||||
if instance.text == 'Inbox':
|
# if instance.text == 'Inbox':
|
||||||
self.root.ids.sc1.ids.ml.clear_widgets()
|
# self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc1.loadMessagelist(state.association)
|
# self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
self.root.ids.sc1.children[1].active = False
|
# self.root.ids.sc1.children[1].active = False
|
||||||
elif instance.text == 'All Mails':
|
# elif instance.text == 'All Mails':
|
||||||
self.root.ids.sc17.clear_widgets()
|
# self.root.ids.sc17.clear_widgets()
|
||||||
self.root.ids.sc17.add_widget(Allmails())
|
# self.root.ids.sc17.add_widget(Allmails())
|
||||||
try:
|
# try:
|
||||||
self.root.ids.sc17.children[1].active = False
|
# self.root.ids.sc17.children[1].active = False
|
||||||
except Exception:
|
# except Exception:
|
||||||
self.root.ids.sc17.children[0].children[1].active = False
|
# self.root.ids.sc17.children[0].children[1].active = False
|
||||||
elif instance.text == 'Trash':
|
# elif instance.text == 'Trash':
|
||||||
# self.root.ids.sc5.ids.ml.clear_widgets()
|
# # self.root.ids.sc5.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc5.init_ui(0)
|
# # self.root.ids.sc5.init_ui(0)
|
||||||
self.root.ids.sc5.clear_widgets()
|
# self.root.ids.sc5.clear_widgets()
|
||||||
self.root.ids.sc5.add_widget(Trash())
|
# self.root.ids.sc5.add_widget(Trash())
|
||||||
try:
|
# try:
|
||||||
self.root.ids.sc5.children[1].active = False
|
# self.root.ids.sc5.children[1].active = False
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
self.root.ids.sc5.children[0].children[1].active = False
|
# self.root.ids.sc5.children[0].children[1].active = False
|
||||||
|
pass
|
||||||
def on_request_close(self, *args): # pylint: disable=no-self-use
|
def on_request_close(self, *args): # pylint: disable=no-self-use
|
||||||
"""This method is for app closing request"""
|
"""This method is for app closing request"""
|
||||||
AppClosingPopup().open()
|
AppClosingPopup().open()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def file_manager_open(self):
|
def file_manager_open(self):
|
||||||
"""This method open the file manager of local system"""
|
# """This method open the file manager of local system"""
|
||||||
from kivymd.uix.filemanager import MDFileManager
|
# from kivymd.uix.filemanager import MDFileManager
|
||||||
|
|
||||||
if not self.file_manager:
|
# if not self.file_manager:
|
||||||
self.file_manager = MDFileManager(
|
# self.file_manager = MDFileManager(
|
||||||
exit_manager=self.exit_manager,
|
# exit_manager=self.exit_manager,
|
||||||
select_path=self.select_path,
|
# select_path=self.select_path,
|
||||||
ext=['.png', '.jpg']
|
# ext=['.png', '.jpg']
|
||||||
)
|
# )
|
||||||
self.file_manager.previous = False
|
# self.file_manager.previous = False
|
||||||
self.file_manager.current_path = '/'
|
# self.file_manager.current_path = '/'
|
||||||
if platform == 'android':
|
# if platform == 'android':
|
||||||
from android.permissions import request_permissions, Permission, check_permission
|
# from android.permissions import request_permissions, Permission, check_permission
|
||||||
if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \
|
# if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \
|
||||||
check_permission(Permission.READ_EXTERNAL_STORAGE):
|
# check_permission(Permission.READ_EXTERNAL_STORAGE):
|
||||||
self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
|
# self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
|
||||||
self.manager_open = True
|
# self.manager_open = True
|
||||||
else:
|
# else:
|
||||||
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
|
# request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
|
||||||
else:
|
# else:
|
||||||
self.file_manager.show(os.environ["HOME"])
|
# self.file_manager.show(os.environ["HOME"])
|
||||||
self.manager_open = True
|
# self.manager_open = True
|
||||||
|
pass
|
||||||
|
|
||||||
def select_path(self, path):
|
def select_path(self, path):
|
||||||
"""This method is used to save the select image"""
|
"""This method is used to save the select image"""
|
||||||
try:
|
# try:
|
||||||
from PIL import Image as PilImage
|
# from PIL import Image as PilImage
|
||||||
newImg = PilImage.open(path).resize((300, 300))
|
# newImg = PilImage.open(path).resize((300, 300))
|
||||||
if platform == 'android':
|
# if platform == 'android':
|
||||||
android_path = os.path.join(
|
# android_path = os.path.join(
|
||||||
os.environ['ANDROID_PRIVATE'] + '/app' + '/images' + '/kivy/')
|
# os.environ['ANDROID_PRIVATE'] + '/app' + '/images' + '/kivy/')
|
||||||
if not os.path.exists(android_path + '/default_identicon/'):
|
# if not os.path.exists(android_path + '/default_identicon/'):
|
||||||
os.makedirs(android_path + '/default_identicon/')
|
# os.makedirs(android_path + '/default_identicon/')
|
||||||
newImg.save('{1}/default_identicon/{0}.png'.format(
|
# newImg.save('{1}/default_identicon/{0}.png'.format(
|
||||||
state.association, android_path))
|
# state.association, android_path))
|
||||||
else:
|
# else:
|
||||||
if not os.path.exists(state.imageDir + '/default_identicon/'):
|
# if not os.path.exists(state.imageDir + '/default_identicon/'):
|
||||||
os.makedirs(state.imageDir + '/default_identicon/')
|
# os.makedirs(state.imageDir + '/default_identicon/')
|
||||||
newImg.save(state.imageDir + '/default_identicon/{0}.png'.format(state.association))
|
# newImg.save(state.imageDir + '/default_identicon/{0}.png'.format(state.association))
|
||||||
self.load_selected_Image(state.association)
|
# self.load_selected_Image(state.association)
|
||||||
toast('Image changed')
|
# toast('Image changed')
|
||||||
except Exception:
|
# except Exception:
|
||||||
toast('Exit')
|
# toast('Exit')
|
||||||
self.exit_manager()
|
# self.exit_manager()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def exit_manager(self, *args):
|
def exit_manager(self, *args):
|
||||||
"""Called when the user reaches the root of the directory tree."""
|
"""Called when the user reaches the root of the directory tree."""
|
||||||
|
@ -922,64 +944,68 @@ class NavigateApp(MDApp):
|
||||||
self.file_manager.close()
|
self.file_manager.close()
|
||||||
|
|
||||||
def load_selected_Image(self, curerentAddr):
|
def load_selected_Image(self, curerentAddr):
|
||||||
"""This method load the selected image on screen"""
|
# """This method load the selected image on screen"""
|
||||||
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
# top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
||||||
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
# # spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
||||||
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
# # spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
||||||
top_box_obj.source = state.imageDir + '/default_identicon/{0}.png'.format(curerentAddr)
|
# top_box_obj.source = state.imageDir + '/default_identicon/{0}.png'.format(curerentAddr)
|
||||||
self.root.ids.content_drawer.ids.reset_image.opacity = 1
|
# self.root.ids.content_drawer.ids.reset_image.opacity = 1
|
||||||
self.root.ids.content_drawer.ids.reset_image.disabled = False
|
# self.root.ids.content_drawer.ids.reset_image.disabled = False
|
||||||
top_box_obj.reload()
|
# top_box_obj.reload()
|
||||||
|
pass
|
||||||
# spinner_img_obj.reload()
|
# spinner_img_obj.reload()
|
||||||
|
|
||||||
def rest_default_avatar_img(self):
|
def rest_default_avatar_img(self):
|
||||||
"""set default avatar generated image"""
|
# """set default avatar generated image"""
|
||||||
self.set_identicon(state.association)
|
# self.set_identicon(state.association)
|
||||||
img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
# img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
||||||
try:
|
# try:
|
||||||
if os.path.exists(img_path):
|
# if os.path.exists(img_path):
|
||||||
os.remove(img_path)
|
# os.remove(img_path)
|
||||||
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
# self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
||||||
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
# self.root.ids.content_drawer.ids.reset_image.disabled = True
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
pass
|
# pass
|
||||||
toast('Avatar reset')
|
# toast('Avatar reset')
|
||||||
|
pass
|
||||||
|
|
||||||
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
||||||
"""Copy the data from mail detail page"""
|
# """Copy the data from mail detail page"""
|
||||||
Clipboard.copy(text)
|
# Clipboard.copy(text)
|
||||||
toast('Copied')
|
# toast('Copied')
|
||||||
|
pass
|
||||||
|
|
||||||
def reset_login_screen(self):
|
def reset_login_screen(self):
|
||||||
"""This method is used for clearing random screen"""
|
"""This method is used for clearing random screen"""
|
||||||
if self.root.ids.sc7.ids.add_random_bx.children:
|
# if self.root.ids.sc7.ids.add_random_bx.children:
|
||||||
self.root.ids.sc7.ids.add_random_bx.clear_widgets()
|
# self.root.ids.sc7.ids.add_random_bx.clear_widgets()
|
||||||
|
pass
|
||||||
|
|
||||||
def open_payment_layout(self, sku):
|
def open_payment_layout(self, sku):
|
||||||
"""It basically open up a payment layout for kivy Ui"""
|
"""It basically open up a payment layout for kivy Ui"""
|
||||||
pml = PaymentMethodLayout()
|
# pml = PaymentMethodLayout()
|
||||||
self.product_id = sku
|
# self.product_id = sku
|
||||||
self.custom_sheet = MDCustomBottomSheet(screen=pml)
|
# self.custom_sheet = MDCustomBottomSheet(screen=pml)
|
||||||
self.custom_sheet.open()
|
# self.custom_sheet.open()
|
||||||
|
pass
|
||||||
def initiate_purchase(self, method_name):
|
def initiate_purchase(self, method_name):
|
||||||
"""initiate_purchase module"""
|
"""initiate_purchase module"""
|
||||||
print("Purchasing {} through {}".format(self.product_id, method_name))
|
# print("Purchasing {} through {}".format(self.product_id, method_name))
|
||||||
|
pass
|
||||||
def _after_scan(self, text):
|
def _after_scan(self, text):
|
||||||
# if platform == 'android':
|
# if platform == 'android':
|
||||||
# toast_txt = cast(CharSequence, String(text))
|
# toast_txt = cast(CharSequence, String(text))
|
||||||
# show_toast(toast_txt, Toast.LENGTH_SHORT)
|
# show_toast(toast_txt, Toast.LENGTH_SHORT)
|
||||||
if self.root.ids.sc23.previous_open_screen == 'composer':
|
# if self.root.ids.sc23.previous_open_screen == 'composer':
|
||||||
self.root.ids.sc3.children[1].ids.txt_input.text = text
|
# self.root.ids.sc3.children[1].ids.txt_input.text = text
|
||||||
self.root.ids.scr_mngr.current = 'create'
|
# self.root.ids.scr_mngr.current = 'create'
|
||||||
elif self.root.ids.sc23.previous_open_screen:
|
# elif self.root.ids.sc23.previous_open_screen:
|
||||||
back_screen = self.root.ids.sc23.previous_open_screen
|
# back_screen = self.root.ids.sc23.previous_open_screen
|
||||||
self.root.ids.scr_mngr.current = 'inbox' if back_screen == 'scanscreen' else back_screen
|
# self.root.ids.scr_mngr.current = 'inbox' if back_screen == 'scanscreen' else back_screen
|
||||||
add_obj = self.root.ids.sc23.pop_up_instance
|
# add_obj = self.root.ids.sc23.pop_up_instance
|
||||||
add_obj.content_cls.ids.address.text = text
|
# add_obj.content_cls.ids.address.text = text
|
||||||
Clock.schedule_once(partial(self.open_popup, add_obj), .5)
|
# Clock.schedule_once(partial(self.open_popup, add_obj), .5)
|
||||||
|
pass
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def open_popup(instance, dt):
|
def open_popup(instance, dt):
|
||||||
"""This method is used for opening popup"""
|
"""This method is used for opening popup"""
|
||||||
|
|
278
src/tests/mock/pybitmessage/addresses.py
Normal file
278
src/tests/mock/pybitmessage/addresses.py
Normal file
|
@ -0,0 +1,278 @@
|
||||||
|
"""
|
||||||
|
Operations with addresses
|
||||||
|
"""
|
||||||
|
# pylint: disable=redefined-outer-name,inconsistent-return-statements
|
||||||
|
import hashlib
|
||||||
|
from binascii import hexlify, unhexlify
|
||||||
|
from struct import pack, unpack
|
||||||
|
|
||||||
|
from debug import logger
|
||||||
|
|
||||||
|
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||||
|
|
||||||
|
|
||||||
|
def encodeBase58(num, alphabet=ALPHABET):
|
||||||
|
"""Encode a number in Base X
|
||||||
|
|
||||||
|
Args:
|
||||||
|
num: The number to encode
|
||||||
|
alphabet: The alphabet to use for encoding
|
||||||
|
"""
|
||||||
|
if num == 0:
|
||||||
|
return alphabet[0]
|
||||||
|
arr = []
|
||||||
|
base = len(alphabet)
|
||||||
|
while num:
|
||||||
|
rem = num % base
|
||||||
|
num = num // base
|
||||||
|
arr.append(alphabet[rem])
|
||||||
|
arr.reverse()
|
||||||
|
return ''.join(arr)
|
||||||
|
|
||||||
|
|
||||||
|
def decodeBase58(string, alphabet=ALPHABET):
|
||||||
|
"""Decode a Base X encoded string into the number
|
||||||
|
|
||||||
|
Args:
|
||||||
|
string: The encoded string
|
||||||
|
alphabet: The alphabet to use for encoding
|
||||||
|
"""
|
||||||
|
base = len(alphabet)
|
||||||
|
num = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
for char in string:
|
||||||
|
num *= base
|
||||||
|
num += alphabet.index(char)
|
||||||
|
# ValueError
|
||||||
|
except:
|
||||||
|
# character not found (like a space character or a 0)
|
||||||
|
return 0
|
||||||
|
return num
|
||||||
|
|
||||||
|
|
||||||
|
class varintEncodeError(Exception):
|
||||||
|
"""Exception class for encoding varint"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class varintDecodeError(Exception):
|
||||||
|
"""Exception class for decoding varint data"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def encodeVarint(integer):
|
||||||
|
"""Convert integer into varint bytes"""
|
||||||
|
if integer < 0:
|
||||||
|
raise varintEncodeError('varint cannot be < 0')
|
||||||
|
if integer < 253:
|
||||||
|
return pack('>B', integer)
|
||||||
|
if integer >= 253 and integer < 65536:
|
||||||
|
return pack('>B', 253) + pack('>H', integer)
|
||||||
|
if integer >= 65536 and integer < 4294967296:
|
||||||
|
return pack('>B', 254) + pack('>I', integer)
|
||||||
|
if integer >= 4294967296 and integer < 18446744073709551616:
|
||||||
|
return pack('>B', 255) + pack('>Q', integer)
|
||||||
|
if integer >= 18446744073709551616:
|
||||||
|
raise varintEncodeError('varint cannot be >= 18446744073709551616')
|
||||||
|
|
||||||
|
|
||||||
|
def decodeVarint(data):
|
||||||
|
"""
|
||||||
|
Decodes an encoded varint to an integer and returns it.
|
||||||
|
Per protocol v3, the encoded value must be encoded with
|
||||||
|
the minimum amount of data possible or else it is malformed.
|
||||||
|
Returns a tuple: (theEncodedValue, theSizeOfTheVarintInBytes)
|
||||||
|
"""
|
||||||
|
if not data:
|
||||||
|
return (0, 0)
|
||||||
|
firstByte, = unpack('>B', data[0:1])
|
||||||
|
if firstByte < 253:
|
||||||
|
# encodes 0 to 252
|
||||||
|
# the 1 is the length of the varint
|
||||||
|
return (firstByte, 1)
|
||||||
|
if firstByte == 253:
|
||||||
|
# encodes 253 to 65535
|
||||||
|
if len(data) < 3:
|
||||||
|
raise varintDecodeError(
|
||||||
|
'The first byte of this varint as an integer is %s'
|
||||||
|
' but the total length is only %s. It needs to be'
|
||||||
|
' at least 3.' % (firstByte, len(data)))
|
||||||
|
encodedValue, = unpack('>H', data[1:3])
|
||||||
|
if encodedValue < 253:
|
||||||
|
raise varintDecodeError(
|
||||||
|
'This varint does not encode the value with the lowest'
|
||||||
|
' possible number of bytes.')
|
||||||
|
return (encodedValue, 3)
|
||||||
|
if firstByte == 254:
|
||||||
|
# encodes 65536 to 4294967295
|
||||||
|
if len(data) < 5:
|
||||||
|
raise varintDecodeError(
|
||||||
|
'The first byte of this varint as an integer is %s'
|
||||||
|
' but the total length is only %s. It needs to be'
|
||||||
|
' at least 5.' % (firstByte, len(data)))
|
||||||
|
encodedValue, = unpack('>I', data[1:5])
|
||||||
|
if encodedValue < 65536:
|
||||||
|
raise varintDecodeError(
|
||||||
|
'This varint does not encode the value with the lowest'
|
||||||
|
' possible number of bytes.')
|
||||||
|
return (encodedValue, 5)
|
||||||
|
if firstByte == 255:
|
||||||
|
# encodes 4294967296 to 18446744073709551615
|
||||||
|
if len(data) < 9:
|
||||||
|
raise varintDecodeError(
|
||||||
|
'The first byte of this varint as an integer is %s'
|
||||||
|
' but the total length is only %s. It needs to be'
|
||||||
|
' at least 9.' % (firstByte, len(data)))
|
||||||
|
encodedValue, = unpack('>Q', data[1:9])
|
||||||
|
if encodedValue < 4294967296:
|
||||||
|
raise varintDecodeError(
|
||||||
|
'This varint does not encode the value with the lowest'
|
||||||
|
' possible number of bytes.')
|
||||||
|
return (encodedValue, 9)
|
||||||
|
|
||||||
|
|
||||||
|
def calculateInventoryHash(data):
|
||||||
|
"""Calculate inventory hash from object data"""
|
||||||
|
sha = hashlib.new('sha512')
|
||||||
|
sha2 = hashlib.new('sha512')
|
||||||
|
sha.update(data)
|
||||||
|
sha2.update(sha.digest())
|
||||||
|
return sha2.digest()[0:32]
|
||||||
|
|
||||||
|
|
||||||
|
def encodeAddress(version, stream, ripe):
|
||||||
|
"""Convert ripe to address"""
|
||||||
|
if version >= 2 and version < 4:
|
||||||
|
if len(ripe) != 20:
|
||||||
|
raise Exception(
|
||||||
|
'Programming error in encodeAddress: The length of'
|
||||||
|
' a given ripe hash was not 20.'
|
||||||
|
)
|
||||||
|
if ripe[:2] == '\x00\x00':
|
||||||
|
ripe = ripe[2:]
|
||||||
|
elif ripe[:1] == '\x00':
|
||||||
|
ripe = ripe[1:]
|
||||||
|
elif version == 4:
|
||||||
|
if len(ripe) != 20:
|
||||||
|
raise Exception(
|
||||||
|
'Programming error in encodeAddress: The length of'
|
||||||
|
' a given ripe hash was not 20.')
|
||||||
|
ripe = ripe.lstrip('\x00'.encode('utf-8'))
|
||||||
|
|
||||||
|
storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||||
|
|
||||||
|
# Generate the checksum
|
||||||
|
sha = hashlib.new('sha512')
|
||||||
|
sha.update(storedBinaryData)
|
||||||
|
currentHash = sha.digest()
|
||||||
|
sha = hashlib.new('sha512')
|
||||||
|
sha.update(currentHash)
|
||||||
|
checksum = sha.digest()[0:4]
|
||||||
|
|
||||||
|
asInt = int(hexlify(storedBinaryData) + hexlify(checksum), 16)
|
||||||
|
return 'BM-' + encodeBase58(asInt)
|
||||||
|
|
||||||
|
|
||||||
|
def decodeAddress(address):
|
||||||
|
"""
|
||||||
|
returns (status, address version number, stream number,
|
||||||
|
data (almost certainly a ripe hash))
|
||||||
|
"""
|
||||||
|
# pylint: disable=too-many-return-statements,too-many-statements
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
|
address = str(address).strip()
|
||||||
|
|
||||||
|
if address[:3] == 'BM-':
|
||||||
|
integer = decodeBase58(address[3:])
|
||||||
|
else:
|
||||||
|
integer = decodeBase58(address)
|
||||||
|
if integer == 0:
|
||||||
|
status = 'invalidcharacters'
|
||||||
|
return status, 0, 0, ''
|
||||||
|
# after converting to hex, the string will be prepended
|
||||||
|
# with a 0x and appended with a L
|
||||||
|
hexdata = hex(integer)[2:]
|
||||||
|
|
||||||
|
if len(hexdata) % 2 != 0:
|
||||||
|
hexdata = '0' + hexdata
|
||||||
|
|
||||||
|
data = unhexlify(hexdata)
|
||||||
|
checksum = data[-4:]
|
||||||
|
|
||||||
|
sha = hashlib.new('sha512')
|
||||||
|
sha.update(data[:-4])
|
||||||
|
currentHash = sha.digest()
|
||||||
|
sha = hashlib.new('sha512')
|
||||||
|
sha.update(currentHash)
|
||||||
|
|
||||||
|
if checksum != sha.digest()[0:4]:
|
||||||
|
status = 'checksumfailed'
|
||||||
|
return status, 0, 0, ''
|
||||||
|
|
||||||
|
try:
|
||||||
|
addressVersionNumber, bytesUsedByVersionNumber = decodeVarint(data[:9])
|
||||||
|
except varintDecodeError as e:
|
||||||
|
logger.error(str(e))
|
||||||
|
status = 'varintmalformed'
|
||||||
|
return status, 0, 0, ''
|
||||||
|
|
||||||
|
if addressVersionNumber > 4:
|
||||||
|
logger.error('cannot decode address version numbers this high')
|
||||||
|
status = 'versiontoohigh'
|
||||||
|
return status, 0, 0, ''
|
||||||
|
elif addressVersionNumber == 0:
|
||||||
|
logger.error('cannot decode address version numbers of zero.')
|
||||||
|
status = 'versiontoohigh'
|
||||||
|
return status, 0, 0, ''
|
||||||
|
|
||||||
|
try:
|
||||||
|
streamNumber, bytesUsedByStreamNumber = \
|
||||||
|
decodeVarint(data[bytesUsedByVersionNumber:])
|
||||||
|
except varintDecodeError as e:
|
||||||
|
logger.error(str(e))
|
||||||
|
status = 'varintmalformed'
|
||||||
|
return status, 0, 0, ''
|
||||||
|
|
||||||
|
status = 'success'
|
||||||
|
if addressVersionNumber == 1:
|
||||||
|
return status, addressVersionNumber, streamNumber, data[-24:-4]
|
||||||
|
# elif addressVersionNumber == 2 or addressVersionNumber == 3:
|
||||||
|
elif addressVersionNumber in (2, 3):
|
||||||
|
embeddedRipeData = \
|
||||||
|
data[bytesUsedByVersionNumber + bytesUsedByStreamNumber:-4]
|
||||||
|
if len(embeddedRipeData) == 19:
|
||||||
|
return status, addressVersionNumber, streamNumber, \
|
||||||
|
'\x00' + embeddedRipeData
|
||||||
|
elif len(embeddedRipeData) == 20:
|
||||||
|
return status, addressVersionNumber, streamNumber, \
|
||||||
|
embeddedRipeData
|
||||||
|
elif len(embeddedRipeData) == 18:
|
||||||
|
return status, addressVersionNumber, streamNumber, \
|
||||||
|
'\x00\x00'.encode('utf-8') + embeddedRipeData
|
||||||
|
elif len(embeddedRipeData) < 18:
|
||||||
|
return 'ripetooshort', 0, 0, ''
|
||||||
|
elif len(embeddedRipeData) > 20:
|
||||||
|
return 'ripetoolong', 0, 0, ''
|
||||||
|
return 'otherproblem', 0, 0, ''
|
||||||
|
elif addressVersionNumber == 4:
|
||||||
|
embeddedRipeData = \
|
||||||
|
data[bytesUsedByVersionNumber + bytesUsedByStreamNumber:-4]
|
||||||
|
if embeddedRipeData[0:1] == '\x00':
|
||||||
|
# In order to enforce address non-malleability, encoded
|
||||||
|
# RIPE data must have NULL bytes removed from the front
|
||||||
|
return 'encodingproblem', 0, 0, ''
|
||||||
|
elif len(embeddedRipeData) > 20:
|
||||||
|
return 'ripetoolong', 0, 0, ''
|
||||||
|
elif len(embeddedRipeData) < 4:
|
||||||
|
return 'ripetooshort', 0, 0, ''
|
||||||
|
x00string = '\x00'.encode('utf-8') * (20 - len(embeddedRipeData))
|
||||||
|
|
||||||
|
return status, addressVersionNumber, streamNumber, \
|
||||||
|
x00string + embeddedRipeData
|
||||||
|
|
||||||
|
|
||||||
|
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
|
0
src/tests/mock/pybitmessage/baseclass/__init__.py
Normal file
0
src/tests/mock/pybitmessage/baseclass/__init__.py
Normal file
|
@ -1,6 +1,6 @@
|
||||||
from turtle import pd
|
from turtle import pd
|
||||||
from bitmessagekivy.get_platform import platform
|
from pybitmessage.get_platform import platform
|
||||||
from bitmessagekivy import kivy_helper_search
|
from pybitmessage import kivy_helper_search
|
||||||
from helper_sql import sqlExecute
|
from helper_sql import sqlExecute
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
@ -15,11 +15,11 @@ from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
avatarImageFirstLetter, toast,
|
avatarImageFirstLetter, toast,
|
||||||
ThemeClsColor, SwipeToDeleteItem
|
ThemeClsColor, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
from pybitmessage.baseclass.popup import AddbookDetailPopup
|
||||||
|
|
||||||
|
|
||||||
class AddressBook(Screen):
|
class AddressBook(Screen):
|
||||||
|
|
|
@ -11,13 +11,13 @@ from kivymd.uix.label import MDLabel
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
showLimitedCnt, toast, ThemeClsColor,
|
showLimitedCnt, toast, ThemeClsColor,
|
||||||
avatarImageFirstLetter, CutsomSwipeToDeleteItem,
|
avatarImageFirstLetter, CutsomSwipeToDeleteItem,
|
||||||
ShowTimeHistoy
|
ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from pybitmessage.baseclass.maildetail import MailDetail
|
||||||
# from bitmessagekivy.baseclass.trash import Trash
|
# from pybitmessage.baseclass.trash import Trash
|
||||||
|
|
||||||
|
|
||||||
class Allmails(Screen):
|
class Allmails(Screen):
|
||||||
|
|
|
@ -8,7 +8,8 @@ from kivymd.uix.list import (
|
||||||
)
|
)
|
||||||
from kivy.uix.image import Image
|
from kivy.uix.image import Image
|
||||||
from kivymd.uix.label import MDLabel
|
from kivymd.uix.label import MDLabel
|
||||||
from bitmessagekivy.get_platform import platform
|
from pybitmessage.get_platform import platform
|
||||||
|
platform = "linux"
|
||||||
from kivymd.toast import kivytoast
|
from kivymd.toast import kivytoast
|
||||||
from kivymd.uix.card import MDCardSwipe
|
from kivymd.uix.card import MDCardSwipe
|
||||||
from kivymd.uix.chip import MDChip
|
from kivymd.uix.chip import MDChip
|
||||||
|
@ -27,7 +28,7 @@ data_screens = {
|
||||||
"Factory": "MailDetail()",
|
"Factory": "MailDetail()",
|
||||||
"name_screen": "mailDetail",
|
"name_screen": "mailDetail",
|
||||||
"object": 0,
|
"object": 0,
|
||||||
"Import": "from bitmessagekivy.baseclass.maildetail import MailDetail",
|
"Import": "from pybitmessage.baseclass.maildetail import MailDetail",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from bitmessagekivy import kivy_helper_search
|
from pybitmessage import kivy_helper_search
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from helper_sql import sqlExecute
|
from helper_sql import sqlExecute
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
@ -15,11 +15,11 @@ from kivymd.uix.label import MDLabel
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
showLimitedCnt, toast, ThemeClsColor,
|
showLimitedCnt, toast, ThemeClsColor,
|
||||||
SwipeToDeleteItem, ShowTimeHistoy
|
SwipeToDeleteItem, ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from pybitmessage.baseclass.maildetail import MailDetail
|
||||||
|
|
||||||
|
|
||||||
class Draft(Screen):
|
class Draft(Screen):
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# from bitmessagekivy.get_platform import platform
|
# from pybitmessage.get_platform import platform
|
||||||
# from bitmessagekivy import identiconGeneration
|
# from pybitmessage import identiconGeneration
|
||||||
from bitmessagekivy import kivy_helper_search
|
|
||||||
from bmconfigparser import BMConfigParser
|
# from pybitmessage import kivy_helper_search
|
||||||
from helper_sql import sqlExecute
|
# from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
|
from ..helper_sql import sqlExecute
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.metrics import dp
|
from kivy.metrics import dp
|
||||||
|
@ -13,15 +14,15 @@ from kivy.properties import (
|
||||||
from kivy.uix.screenmanager import Screen
|
from kivy.uix.screenmanager import Screen
|
||||||
from kivymd.uix.label import MDLabel
|
from kivymd.uix.label import MDLabel
|
||||||
|
|
||||||
import state
|
from .. import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from .common import (
|
||||||
showLimitedCnt, avatarImageFirstLetter,
|
showLimitedCnt, avatarImageFirstLetter,
|
||||||
ThemeClsColor, toast, SwipeToDeleteItem,
|
ThemeClsColor, toast, SwipeToDeleteItem,
|
||||||
ShowTimeHistoy
|
ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from.maildetail import MailDetail
|
||||||
from bitmessagekivy.baseclass.trash import Trash
|
from .trash import Trash
|
||||||
|
|
||||||
|
|
||||||
class Inbox(Screen):
|
class Inbox(Screen):
|
||||||
|
@ -112,9 +113,10 @@ class Inbox(Screen):
|
||||||
|
|
||||||
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
||||||
"""This method is used for retrieving inbox data"""
|
"""This method is used for retrieving inbox data"""
|
||||||
self.queryreturn = kivy_helper_search.search_sql(
|
# self.queryreturn = kivy_helper_search.search_sql(
|
||||||
xAddress, self.account, "inbox", where, what, False, start_indx, end_indx
|
# xAddress, self.account, "inbox", where, what, False, start_indx, end_indx
|
||||||
)
|
# )
|
||||||
|
pass
|
||||||
|
|
||||||
def set_mdList(self, data):
|
def set_mdList(self, data):
|
||||||
"""This method is used to create the mdList"""
|
"""This method is used to create the mdList"""
|
||||||
|
|
|
@ -9,7 +9,7 @@ from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import toast
|
from pybitmessage.baseclass.common import toast
|
||||||
|
|
||||||
|
|
||||||
class Login(Screen):
|
class Login(Screen):
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from bitmessagekivy.get_platform import platform
|
# from pybitmessage.get_platform import platform
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
platform = "linux"
|
||||||
|
from ..helper_sql import sqlExecute, sqlQuery
|
||||||
|
|
||||||
from kivy.core.clipboard import Clipboard
|
from kivy.core.clipboard import Clipboard
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
@ -19,12 +20,12 @@ from kivymd.uix.list import (
|
||||||
)
|
)
|
||||||
from kivy.uix.screenmanager import Screen
|
from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
import state
|
from .. import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from .common import (
|
||||||
toast, avatarImageFirstLetter, ShowTimeHistoy
|
toast, avatarImageFirstLetter, ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.popup import SenderDetailPopup
|
from .popup import SenderDetailPopup
|
||||||
|
|
||||||
|
|
||||||
class OneLineListTitle(OneLineListItem):
|
class OneLineListTitle(OneLineListItem):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from bitmessagekivy.get_platform import platform
|
from pybitmessage.get_platform import platform
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
@ -30,7 +30,7 @@ import state
|
||||||
import queues
|
import queues
|
||||||
|
|
||||||
from addresses import decodeAddress, addBMIfNotPresent
|
from addresses import decodeAddress, addBMIfNotPresent
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
toast, showLimitedCnt
|
toast, showLimitedCnt
|
||||||
)
|
)
|
||||||
from kivymd.uix.textfield import MDTextField
|
from kivymd.uix.textfield import MDTextField
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from bitmessagekivy.get_platform import platform
|
from pybitmessage.get_platform import platform
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
@ -19,11 +19,11 @@ from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
avatarImageFirstLetter, AvatarSampleWidget, ThemeClsColor,
|
avatarImageFirstLetter, AvatarSampleWidget, ThemeClsColor,
|
||||||
toast
|
toast
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.popup import MyaddDetailPopup
|
from pybitmessage.baseclass.popup import MyaddDetailPopup
|
||||||
|
|
||||||
|
|
||||||
class ToggleBtn(IRightBodyTouch, MDSwitch):
|
class ToggleBtn(IRightBodyTouch, MDSwitch):
|
||||||
|
|
|
@ -12,7 +12,7 @@ from kivymd.uix.list import (
|
||||||
)
|
)
|
||||||
|
|
||||||
# from bmconfigparser import BMConfigParser
|
# from bmconfigparser import BMConfigParser
|
||||||
from bitmessagekivy.baseclass.common import toast
|
from pybitmessage.baseclass.common import toast
|
||||||
|
|
||||||
# import queues
|
# import queues
|
||||||
import state
|
import state
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from bitmessagekivy.get_platform import platform
|
from ..get_platform import platform
|
||||||
from bitmessagekivy import kivy_helper_search
|
from .. import kivy_helper_search
|
||||||
|
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.metrics import dp
|
from kivy.metrics import dp
|
||||||
|
@ -8,11 +8,11 @@ from kivy.properties import StringProperty
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.uix.popup import Popup
|
from kivy.uix.popup import Popup
|
||||||
|
|
||||||
import state
|
from .. import state
|
||||||
from addresses import decodeAddress
|
from ..addresses import decodeAddress
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import toast
|
from .common import toast
|
||||||
|
|
||||||
|
|
||||||
class LoadingPopup(Popup):
|
class LoadingPopup(Popup):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import state
|
import state
|
||||||
from bitmessagekivy.baseclass.common import toast
|
from pybitmessage.baseclass.common import toast
|
||||||
from kivy.uix.screenmanager import Screen
|
from kivy.uix.screenmanager import Screen
|
||||||
from kivy.properties import StringProperty
|
from kivy.properties import StringProperty
|
||||||
from kivy_garden.qrcode import QRCodeWidget
|
from kivy_garden.qrcode import QRCodeWidget
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from bitmessagekivy.get_platform import platform
|
from pybitmessage.get_platform import platform
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# from bitmessagekivy import identiconGeneration
|
# from pybitmessage import identiconGeneration
|
||||||
from bitmessagekivy import kivy_helper_search
|
from pybitmessage import kivy_helper_search
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from helper_sql import sqlExecute
|
from helper_sql import sqlExecute
|
||||||
|
@ -12,11 +12,11 @@ from kivymd.uix.label import MDLabel
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
|
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
|
||||||
toast, SwipeToDeleteItem, ShowTimeHistoy
|
toast, SwipeToDeleteItem, ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from pybitmessage.baseclass.maildetail import MailDetail
|
||||||
|
|
||||||
|
|
||||||
class Sent(Screen):
|
class Sent(Screen):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from bitmessagekivy.get_platform import platform
|
from pybitmessage.get_platform import platform
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
@ -14,7 +14,7 @@ from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from pybitmessage.baseclass.common import (
|
||||||
toast, showLimitedCnt, ThemeClsColor,
|
toast, showLimitedCnt, ThemeClsColor,
|
||||||
CutsomSwipeToDeleteItem, ShowTimeHistoy,
|
CutsomSwipeToDeleteItem, ShowTimeHistoy,
|
||||||
avatarImageFirstLetter
|
avatarImageFirstLetter
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
from datetime import datetime
|
|
||||||
from kivy.core.window import Window
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.metrics import dp
|
|
||||||
from kivymd.uix.list import (
|
|
||||||
ILeftBody,
|
|
||||||
IRightBodyTouch,
|
|
||||||
)
|
|
||||||
from kivy.uix.image import Image
|
|
||||||
from kivymd.uix.label import MDLabel
|
|
||||||
from bitmessagekivy.get_platform import platform
|
|
||||||
from kivymd.toast import kivytoast
|
|
||||||
from kivymd.uix.card import MDCardSwipe
|
|
||||||
from kivymd.uix.chip import MDChip
|
|
||||||
from kivy.properties import (
|
|
||||||
NumericProperty,
|
|
||||||
StringProperty
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
ThemeClsColor = [0.12, 0.58, 0.95, 1]
|
|
||||||
|
|
||||||
|
|
||||||
data_screens = {
|
|
||||||
"MailDetail": {
|
|
||||||
"kv_string": "maildetail",
|
|
||||||
"Factory": "MailDetail()",
|
|
||||||
"name_screen": "mailDetail",
|
|
||||||
"object": 0,
|
|
||||||
"Import": "from bitmessagekivy.baseclass.maildetail import MailDetail",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def chipTag(text):
|
|
||||||
"""This method is used for showing chip tag"""
|
|
||||||
obj = MDChip()
|
|
||||||
# obj.size_hint = (None, None)
|
|
||||||
obj.size_hint = (0.16 if platform == "android" else 0.08, None)
|
|
||||||
obj.text = text
|
|
||||||
obj.icon = ""
|
|
||||||
obj.pos_hint = {
|
|
||||||
"center_x": 0.91 if platform == "android" else 0.94,
|
|
||||||
"center_y": 0.3
|
|
||||||
}
|
|
||||||
obj.height = dp(18)
|
|
||||||
obj.text_color = (1, 1, 1, 1)
|
|
||||||
obj.radius = [8]
|
|
||||||
return obj
|
|
||||||
|
|
||||||
|
|
||||||
# def initailize_detail_page(manager):
|
|
||||||
# if not manager.has_screen(
|
|
||||||
# data_screens['MailDetail']["name_screen"]
|
|
||||||
# ):
|
|
||||||
# Builder.load_file(
|
|
||||||
# os.path.join(
|
|
||||||
# # os.environ["KITCHEN_SINK_ROOT"],
|
|
||||||
# os.path.dirname(os.path.dirname(__file__)),
|
|
||||||
# "kv",
|
|
||||||
# "maildetail.kv",
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
# if "Import" in data_screens['MailDetail']:
|
|
||||||
# exec(data_screens['MailDetail']["Import"])
|
|
||||||
# screen_object = eval(data_screens['MailDetail']["Factory"])
|
|
||||||
# data_screens['MailDetail']["object"] = screen_object
|
|
||||||
# manager.add_widget(screen_object)
|
|
||||||
# manager.current = data_screens['MailDetail']["name_screen"]
|
|
||||||
|
|
||||||
|
|
||||||
def toast(text):
|
|
||||||
"""Method will display the toast message"""
|
|
||||||
kivytoast.toast(text)
|
|
||||||
|
|
||||||
def showLimitedCnt(total_msg):
|
|
||||||
"""This method set the total count limit in badge_text"""
|
|
||||||
return "99+" if total_msg > 99 else str(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()
|
|
||||||
elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9:
|
|
||||||
img_latter = letter_string[0]
|
|
||||||
else:
|
|
||||||
img_latter = '!'
|
|
||||||
except ValueError:
|
|
||||||
img_latter = '!'
|
|
||||||
return img_latter if img_latter else '!'
|
|
||||||
|
|
||||||
|
|
||||||
def AddTimeWidget(time): # pylint: disable=redefined-outer-name, W0201
|
|
||||||
"""This method is used to create TimeWidget"""
|
|
||||||
action_time = TimeTagRightSampleWidget(
|
|
||||||
text=str(ShowTimeHistoy(time)),
|
|
||||||
font_style="Caption",
|
|
||||||
size=[120, 140] if platform == "android" else [64, 80],
|
|
||||||
)
|
|
||||||
action_time.font_size = "11sp"
|
|
||||||
return action_time
|
|
||||||
|
|
||||||
|
|
||||||
def ShowTimeHistoy(act_time):
|
|
||||||
"""This method is used to return the message sent or receive time"""
|
|
||||||
action_time = datetime.fromtimestamp(int(act_time))
|
|
||||||
crnt_date = datetime.now()
|
|
||||||
duration = crnt_date - action_time
|
|
||||||
display_data = (
|
|
||||||
action_time.strftime("%d/%m/%Y")
|
|
||||||
if duration.days >= 365
|
|
||||||
else action_time.strftime("%I:%M %p").lstrip("0")
|
|
||||||
if duration.days == 0 and crnt_date.strftime("%d/%m/%Y") == action_time.strftime("%d/%m/%Y")
|
|
||||||
else action_time.strftime("%d %b")
|
|
||||||
)
|
|
||||||
return display_data
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
|
||||||
class AvatarSampleWidget(ILeftBody, Image):
|
|
||||||
"""AvatarSampleWidget class for kivy Ui"""
|
|
||||||
|
|
||||||
|
|
||||||
class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
|
|
||||||
"""TimeTagRightSampleWidget class for Ui"""
|
|
||||||
|
|
||||||
|
|
||||||
class SwipeToDeleteItem(MDCardSwipe):
|
|
||||||
"""Swipe delete class for App UI"""
|
|
||||||
text = StringProperty()
|
|
||||||
cla = Window.size[0] / 2
|
|
||||||
# cla = 800
|
|
||||||
swipe_distance = NumericProperty(cla)
|
|
||||||
opening_time = NumericProperty(0.5)
|
|
||||||
|
|
||||||
|
|
||||||
class CutsomSwipeToDeleteItem(MDCardSwipe):
|
|
||||||
"""Custom swipe delete class for App UI"""
|
|
||||||
text = StringProperty()
|
|
||||||
cla = Window.size[0] / 2
|
|
||||||
swipe_distance = NumericProperty(cla)
|
|
||||||
opening_time = NumericProperty(0.5)
|
|
|
@ -35,7 +35,6 @@ def _get_platform():
|
||||||
return "linux"
|
return "linux"
|
||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
platform = _get_platform()
|
platform = _get_platform()
|
||||||
|
|
||||||
if platform not in ("android", "unknown"):
|
if platform not in ("android", "unknown"):
|
||||||
|
|
74
src/tests/mock/pybitmessage/kivy_helper_search.py
Normal file
74
src/tests/mock/pybitmessage/kivy_helper_search.py
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
"""
|
||||||
|
Sql queries for bitmessagekivy
|
||||||
|
"""
|
||||||
|
from pybitmessage.helper_sql import sqlQuery
|
||||||
|
|
||||||
|
|
||||||
|
def search_sql(
|
||||||
|
xAddress="toaddress", account=None, folder="inbox", where=None,
|
||||||
|
what=None, unreadOnly=False, start_indx=0, end_indx=20):
|
||||||
|
# pylint: disable=too-many-arguments, too-many-branches
|
||||||
|
"""Method helping for searching mails"""
|
||||||
|
if what is not None and what != "":
|
||||||
|
what = "%" + what + "%"
|
||||||
|
else:
|
||||||
|
what = None
|
||||||
|
if folder in ("sent", "draft"):
|
||||||
|
sqlStatementBase = (
|
||||||
|
'''SELECT toaddress, fromaddress, subject, message, status,'''
|
||||||
|
''' ackdata, senttime FROM sent '''
|
||||||
|
)
|
||||||
|
elif folder == "addressbook":
|
||||||
|
sqlStatementBase = '''SELECT label, address From addressbook '''
|
||||||
|
else:
|
||||||
|
sqlStatementBase = (
|
||||||
|
'''SELECT folder, msgid, toaddress, message, fromaddress,'''
|
||||||
|
''' subject, received, read FROM inbox '''
|
||||||
|
)
|
||||||
|
sqlStatementParts = []
|
||||||
|
sqlArguments = []
|
||||||
|
if account is not None:
|
||||||
|
if xAddress == 'both':
|
||||||
|
sqlStatementParts.append("(fromaddress = ? OR toaddress = ?)")
|
||||||
|
sqlArguments.append(account)
|
||||||
|
sqlArguments.append(account)
|
||||||
|
else:
|
||||||
|
sqlStatementParts.append(xAddress + " = ? ")
|
||||||
|
sqlArguments.append(account)
|
||||||
|
if folder != "addressbook":
|
||||||
|
if folder is not None:
|
||||||
|
if folder == "new":
|
||||||
|
folder = "inbox"
|
||||||
|
unreadOnly = True
|
||||||
|
sqlStatementParts.append("folder = ? ")
|
||||||
|
sqlArguments.append(folder)
|
||||||
|
else:
|
||||||
|
sqlStatementParts.append("folder != ?")
|
||||||
|
sqlArguments.append("trash")
|
||||||
|
if what is not None:
|
||||||
|
for colmns in where:
|
||||||
|
if len(where) > 1:
|
||||||
|
if where[0] == colmns:
|
||||||
|
filter_col = "(%s LIKE ?" % (colmns)
|
||||||
|
else:
|
||||||
|
filter_col += " or %s LIKE ? )" % (colmns)
|
||||||
|
else:
|
||||||
|
filter_col = "%s LIKE ?" % (colmns)
|
||||||
|
sqlArguments.append(what)
|
||||||
|
sqlStatementParts.append(filter_col)
|
||||||
|
if unreadOnly:
|
||||||
|
sqlStatementParts.append("read = 0")
|
||||||
|
if sqlStatementParts:
|
||||||
|
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
|
||||||
|
# if folder in ("sent", "draft"):
|
||||||
|
if folder in ("sent", "draft"):
|
||||||
|
sqlStatementBase += \
|
||||||
|
"ORDER BY senttime DESC limit {0}, {1}".format(
|
||||||
|
start_indx, end_indx)
|
||||||
|
elif folder == "inbox":
|
||||||
|
sqlStatementBase += \
|
||||||
|
"ORDER BY received DESC limit {0}, {1}".format(
|
||||||
|
start_indx, end_indx)
|
||||||
|
# elif folder == "addressbook":
|
||||||
|
# sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx)
|
||||||
|
return sqlQuery(sqlStatementBase, sqlArguments)
|
|
@ -12,7 +12,7 @@ Bitmessage android(mobile) interface
|
||||||
import platform
|
import platform
|
||||||
import os
|
import os
|
||||||
# import identiconGeneration
|
# import identiconGeneration
|
||||||
# from bitmessagekivy import kivy_helper_search
|
# from pybitmessage import kivy_helper_search
|
||||||
from pybitmessage.uikivysignaler import UIkivySignaler
|
from pybitmessage.uikivysignaler import UIkivySignaler
|
||||||
from pybitmessage.bmconfigparser import BMConfigParser
|
from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
# from debug import logger
|
# from debug import logger
|
||||||
|
@ -258,6 +258,7 @@ class NavigateApp(MDApp):
|
||||||
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
||||||
# return Builder.load_file('/home/cis/Bitmessagepeter/KivyPoject/PyBitmessage/src/tests/mock/pybitmessage/main.kv')
|
# return Builder.load_file('/home/cis/Bitmessagepeter/KivyPoject/PyBitmessage/src/tests/mock/pybitmessage/main.kv')
|
||||||
# import pdb; pdb.set_trace()
|
# import pdb; pdb.set_trace()
|
||||||
|
print("path: $$$$$$$: ", os.path.join(os.path.dirname(__file__),'main.kv'))
|
||||||
return Builder.load_file(
|
return Builder.load_file(
|
||||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user