Merge pull request #70 from navjotcis/codequalitykivy

kivy fixes
This commit is contained in:
lakshyacis 2019-12-24 18:26:19 +05:30 committed by GitHub
commit 4813f9106a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 114 additions and 219 deletions

View File

@ -13,7 +13,6 @@ from kivy.clock import Clock
from kivy.core.clipboard import Clipboard from kivy.core.clipboard import Clipboard
from kivy.core.window import Window from kivy.core.window import Window
from kivy.lang import Builder from kivy.lang import Builder
from kivy.metrics import dp
from kivy.properties import ( from kivy.properties import (
BooleanProperty, BooleanProperty,
ListProperty, ListProperty,
@ -93,7 +92,7 @@ class Inbox(Screen):
@staticmethod @staticmethod
def set_defaultAddress(): def set_defaultAddress():
"""This method set default address""" """This method set's default address"""
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0] state.association = BMConfigParser().addresses()[0]
@ -134,46 +133,31 @@ class Inbox(Screen):
scroll_y=self.check_scroll_y) scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
text="No message found!" if state.searcing_text text="No message found!" if state.searcing_text
else "yet no message for this account!!!!!!!!!!!!!", else "yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
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 used for retrieving inbox data""" """This method used for retrieving inbox data"""
self.queryreturn = kivy_helper_search.search_sql( self.queryreturn = kivy_helper_search.search_sql(
xAddress, xAddress, self.account, "inbox", where, what,
self.account, False, start_indx, end_indx)
"inbox",
where,
what,
False,
start_indx,
end_indx)
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"""
total_message = len(self.ids.ml.children) total_message = len(self.ids.ml.children)
for item in data: for item in data:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item['text'], text=item['text'], secondary_text=item['secondary_text'],
secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget( meny.add_widget(AvatarSampleWidget(
AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter( avatarImageFirstLetter(item['secondary_text'].strip()))))
item['secondary_text'].strip())))) meny.bind(on_press=partial(self.inbox_detail, item['msgid']))
meny.bind(
on_press=partial(
self.inbox_detail, item['msgid']))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
carousel.height = meny.height carousel.height = meny.height
carousel.size_hint_y = None carousel.size_hint_y = None
@ -183,16 +167,12 @@ class Inbox(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1) del_btn.background_color = (1, 0, 0, 1)
del_btn.bind( del_btn.bind(on_press=partial(self.delete, item['msgid']))
on_press=partial(
self.delete, item['msgid']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
ach_btn = Button(text='Achieve') ach_btn = Button(text='Achieve')
ach_btn.background_color = (0, 1, 0, 1) ach_btn.background_color = (0, 1, 0, 1)
ach_btn.bind( ach_btn.bind(on_press=partial(self.archive, item['msgid']))
on_press=partial(
self.archive, item['msgid']))
carousel.add_widget(ach_btn) carousel.add_widget(ach_btn)
carousel.index = 1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
@ -200,7 +180,7 @@ class Inbox(Screen):
self.has_refreshed = True if total_message != update_message else False self.has_refreshed = True if total_message != update_message else False
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""This method is used to load data on scroll""" """Loads data on scroll"""
if self.children[2].children[0].children[ if self.children[2].children[0].children[
0].scroll_y <= -0.0 and self.has_refreshed: 0].scroll_y <= -0.0 and self.has_refreshed:
self.children[2].children[0].children[0].scroll_y = 0.06 self.children[2].children[0].children[0].scroll_y = 0.06
@ -273,8 +253,8 @@ class Inbox(Screen):
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""Archive inbox mail from inbox listing""" """Archive inbox mail from inbox listing"""
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;",
data_index)) str(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
@ -300,7 +280,6 @@ class Inbox(Screen):
self.has_refreshed = True self.has_refreshed = True
self.ids.refresh_layout.refresh_done() self.ids.refresh_layout.refresh_done()
self.tick = 0 self.tick = 0
Clock.schedule_once(refresh_callback, 1) Clock.schedule_once(refresh_callback, 1)
# def set_root_layout(self): # def set_root_layout(self):
@ -321,13 +300,16 @@ class MyAddress(Screen):
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock schdule for method Myaddress accounts""" """Clock schdule for method Myaddress accounts"""
# pylint: disable=unnecessary-lambda, deprecated-lambda
self.addresses_list = state.kivyapp.variable_1 self.addresses_list = state.kivyapp.variable_1
if state.searcing_text: if state.searcing_text:
self.ids.refresh_layout.scroll_y = 1.0 self.ids.refresh_layout.scroll_y = 1.0
filtered_list = filter( # filtered_list = filter(
lambda addr: self.filter_address( # lambda addr: self.filter_address(
addr), BMConfigParser().addresses()) # addr), BMConfigParser().addresses())
filtered_list = [
x
for x in BMConfigParser().addresses()
if self.filter_address(x)]
self.addresses_list = filtered_list self.addresses_list = filtered_list
self.addresses_list = [obj for obj in reversed(self.addresses_list)] self.addresses_list = [obj for obj in reversed(self.addresses_list)]
self.ids.identi_tag.children[0].text = '' self.ids.identi_tag.children[0].text = ''
@ -338,14 +320,10 @@ class MyAddress(Screen):
self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y) self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
text="No address found!" if state.searcing_text text="No address found!" if state.searcing_text
else "yet no address is created by user!!!!!!!!!!!!!", else "yet no address is created by user!!!!!!!!!!!!!",
halign='center', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
if not state.searcing_text and not self.is_add_created: if not state.searcing_text and not self.is_add_created:
try: try:
@ -362,8 +340,7 @@ class MyAddress(Screen):
'secondary_text': address}) 'secondary_text': address})
for item in data: for item in data:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item['text'], text=item['text'], secondary_text=item['secondary_text'],
secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
@ -415,10 +392,12 @@ class MyAddress(Screen):
@staticmethod @staticmethod
def filter_address(address): def filter_address(address):
"""Method will filter the my address list data""" """Method will filter the my address list data"""
# pylint: disable=deprecated-lambda # if filter(lambda x: (state.searcing_text).lower() in x, [
if filter(lambda x: (state.searcing_text).lower() in x, [ # BMConfigParser().get(
BMConfigParser().get( # address, 'label').lower(), address.lower()]):
address, 'label').lower(), address.lower()]): if [x for x in [BMConfigParser().get(
address, 'label').lower(), address.lower()] if (
state.searcing_text).lower() in x]:
return True return True
return False return False
@ -460,23 +439,17 @@ class AddressBook(Screen):
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
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', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def set_mdList(self, start_index, end_index): def set_mdList(self, start_index, end_index):
"""Creating the mdList""" """Creating the mdList"""
for item in self.queryreturn[start_index:end_index]: for item in self.queryreturn[start_index:end_index]:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item[0], text=item[0], secondary_text=item[1], theme_text_color='Custom',
secondary_text=item[1],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
@ -606,15 +579,10 @@ class DropDownWidget(BoxLayout):
if state.detailPageType == 'draft' \ if state.detailPageType == 'draft' \
and state.send_draft_mail: and state.send_draft_mail:
sqlExecute( sqlExecute(
"UPDATE sent SET toaddress = ?" "UPDATE sent SET toaddress = ?, fromaddress = ? ,"
", fromaddress = ? , subject = ?" " subject = ?, message = ?, folder = 'sent' WHERE"
", message = ?, folder = 'sent'" " ackdata = ?;", toAddress, fromAddress, subject,
" WHERE ackdata = ?;", message, str(state.send_draft_mail))
toAddress,
fromAddress,
subject,
message,
str(state.send_draft_mail))
self.parent.parent.screens[15].clear_widgets() self.parent.parent.screens[15].clear_widgets()
self.parent.parent.screens[15].add_widget(Draft()) self.parent.parent.screens[15].add_widget(Draft())
else: else:
@ -636,27 +604,15 @@ class DropDownWidget(BoxLayout):
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'', '', toAddress, ripe, fromAddress, subject, message,
toAddress, ackdata, int(time.time()), int(time.time()), 0,
ripe, 'msgqueued', 0, 'sent', encoding,
fromAddress,
subject,
message,
ackdata,
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'sent',
encoding,
BMConfigParser().getint( BMConfigParser().getint(
'bitmessagesettings', 'ttl')) 'bitmessagesettings', 'ttl'))
state.check_sent_acc = fromAddress state.check_sent_acc = fromAddress
state.msg_counter_objs = self.parent.parent.parent.parent\ state.msg_counter_objs = self.parent.parent.parent.parent\
.parent.parent.children[2].children[0].ids .parent.parent.children[2].children[0].ids
if state.detailPageType == 'draft' \ if state.detailPageType == 'draft' and state.send_draft_mail:
and state.send_draft_mail:
state.draft_count = str(int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1)
state.msg_counter_objs.draft_cnt.badge_text = state.draft_count state.msg_counter_objs.draft_cnt.badge_text = state.draft_count
state.detailPageType = '' state.detailPageType = ''
@ -745,7 +701,7 @@ class MyTextInput(TextInput):
self.parent.height = 400 self.parent.height = 400
def keyboard_on_key_down(self, window, keycode, text, modifiers): def keyboard_on_key_down(self, window, keycode, text, modifiers):
"""Key Down""" """Keyboard on key Down"""
if self.suggestion_text and keycode[1] == 'tab': if self.suggestion_text and keycode[1] == 'tab':
self.insert_text(self.suggestion_text + ' ') self.insert_text(self.suggestion_text + ' ')
return True return True
@ -774,7 +730,7 @@ class Payment(Screen):
class Credits(Screen): class Credits(Screen):
"""Credits Module""" """Module for screen screen"""
available_credits = StringProperty('{0}'.format('0')) available_credits = StringProperty('{0}'.format('0'))
@ -791,7 +747,8 @@ class NetworkStat(Screen):
'Processed {0} per-to-per messages'.format('0')) 'Processed {0} per-to-per messages'.format('0'))
text_variable_3 = StringProperty( text_variable_3 = StringProperty(
'Processed {0} brodcast messages'.format('0')) 'Processed {0} brodcast messages'.format('0'))
text_variable_4 = StringProperty('Processed {0} public keys'.format('0')) text_variable_4 = StringProperty(
'Processed {0} public keys'.format('0'))
text_variable_5 = StringProperty( text_variable_5 = StringProperty(
'Processed {0} object to be synced'.format('0')) 'Processed {0} object to be synced'.format('0'))
@ -840,10 +797,8 @@ class Random(Screen):
if entered_label and entered_label not in lables: if entered_label and entered_label not in lables:
toast('Address Creating...') toast('Address Creating...')
queues.addressGeneratorQueue.put(( queues.addressGeneratorQueue.put((
'createRandomAddress', 'createRandomAddress', 4, streamNumberForAddress, label, 1,
4, streamNumberForAddress, "", eighteenByteRipe, nonceTrialsPerByte,
label, 1, "", eighteenByteRipe,
nonceTrialsPerByte,
payloadLengthExtraBytes)) payloadLengthExtraBytes))
self.ids.label.text = '' self.ids.label.text = ''
self.parent.parent.children[1].opacity = 1 self.parent.parent.children[1].opacity = 1
@ -927,43 +882,31 @@ class Sent(Screen):
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
text="No message found!" if state.searcing_text text="No message found!" if state.searcing_text
else "yet no message for this account!!!!!!!!!!!!!", else "yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def sentDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20): def sentDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
"""This method is used to retrieving data from sent table""" """This method is used to retrieving data from sent table"""
self.queryreturn = kivy_helper_search.search_sql( self.queryreturn = kivy_helper_search.search_sql(
xAddress, xAddress, self.account, "sent", where, what,
self.account, False, start_indx, end_indx)
"sent",
where,
what,
False,
start_indx,
end_indx)
def set_mdlist(self, data, set_index=0): def set_mdlist(self, data, set_index=0):
"""This method is used to create the mdList""" """This method is used to create the mdList"""
total_sent_msg = len(self.ids.ml.children) total_sent_msg = len(self.ids.ml.children)
for item in data: for item in data:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item['text'], text=item['text'], secondary_text=item['secondary_text'],
secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip())))) avatarImageFirstLetter(item['secondary_text'].strip()))))
meny.bind(on_press=partial( meny.bind(on_press=partial(self.sent_detail, item['ackdata']))
self.sent_detail, item['ackdata']))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
carousel.height = meny.height carousel.height = meny.height
carousel.size_hint_y = None carousel.size_hint_y = None
@ -973,14 +916,12 @@ class Sent(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1) del_btn.background_color = (1, 0, 0, 1)
del_btn.bind(on_press=partial( del_btn.bind(on_press=partial(self.delete, item['ackdata']))
self.delete, item['ackdata']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
ach_btn = Button(text='Achieve') ach_btn = Button(text='Achieve')
ach_btn.background_color = (0, 1, 0, 1) ach_btn.background_color = (0, 1, 0, 1)
ach_btn.bind(on_press=partial( ach_btn.bind(on_press=partial(self.archive, item['ackdata']))
self.archive, item['ackdata']))
carousel.add_widget(ach_btn) carousel.add_widget(ach_btn)
carousel.index = 1 carousel.index = 1
self.ids.ml.add_widget(carousel, index=set_index) self.ids.ml.add_widget(carousel, index=set_index)
@ -1088,8 +1029,8 @@ class Sent(Screen):
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""Archive sent mail from sent mail listing""" """Archive sent mail from sent mail listing"""
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash'" "UPDATE sent SET folder = 'trash' WHERE ackdata = ?;",
" WHERE ackdata = ?;", str(data_index)) str(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
@ -1134,13 +1075,9 @@ class Trash(Screen):
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
text="yet no trashed message for this account!!!!!!!!!!!!!", text="yet no trashed message for this account!!!!!!!!!!!!!",
halign='center', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def trashDataQuery(self, start_indx, end_indx): def trashDataQuery(self, start_indx, end_indx):
@ -1222,10 +1159,8 @@ class Trash(Screen):
width = .8 if platform == 'android' else .55 width = .8 if platform == 'android' else .55
delete_msg_dialog = MDDialog( delete_msg_dialog = MDDialog(
text='Are you sure you want to delete this' text='Are you sure you want to delete this'
' message permanently from trash?', ' message permanently from trash?', title='',
title='', size_hint=(width, .25), text_button_ok='Yes',
size_hint=(width, .25),
text_button_ok='Yes',
text_button_cancel='No', text_button_cancel='No',
events_callback=self.callback_for_delete_msg) events_callback=self.callback_for_delete_msg)
delete_msg_dialog.open() delete_msg_dialog.open()
@ -1241,11 +1176,13 @@ class Trash(Screen):
"""Deleting message from trash""" """Deleting message from trash"""
self.children[1].active = True self.children[1].active = True
if self.table_name == 'inbox': if self.table_name == 'inbox':
sqlExecute("DELETE FROM inbox WHERE msgid = ?;", str( sqlExecute(
self.delete_index)) "DELETE FROM inbox WHERE msgid = ?;",
str(self.delete_index))
elif self.table_name == 'sent': elif self.table_name == 'sent':
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str( sqlExecute(
self.delete_index)) "DELETE FROM sent WHERE ackdata = ?;",
str(self.delete_index))
msg_count_objs = state.kivyapp.root.children[2].children[0].ids msg_count_objs = state.kivyapp.root.children[2].children[0].ids
if int(state.trash_count) > 0: if int(state.trash_count) > 0:
msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.trash_cnt.badge_text = str(
@ -1292,20 +1229,13 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
imgstatus = False imgstatus = False
count = 0 count = 0
menu_items = [ menu_items = [
{'viewclass': 'MDMenuItem', {'viewclass': 'MDMenuItem', 'text': 'Example item'},
'text': 'Example item'}, {'viewclass': 'MDMenuItem', 'text': 'Example item'},
{'viewclass': 'MDMenuItem', {'viewclass': 'MDMenuItem', 'text': 'Example item'},
'text': 'Example item'}, {'viewclass': 'MDMenuItem', 'text': 'Example item'},
{'viewclass': 'MDMenuItem', {'viewclass': 'MDMenuItem', 'text': 'Example item'},
'text': 'Example item'}, {'viewclass': 'MDMenuItem', 'text': 'Example item'},
{'viewclass': 'MDMenuItem', {'viewclass': 'MDMenuItem', 'text': 'Example item'},
'text': 'Example item'},
{'viewclass': 'MDMenuItem',
'text': 'Example item'},
{'viewclass': 'MDMenuItem',
'text': 'Example item'},
{'viewclass': 'MDMenuItem',
'text': 'Example item'},
] ]
def build(self): def build(self):
@ -1397,8 +1327,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
img.texture.save('{1}/images/default_identicon/{0}.png'.format( img.texture.save('{1}/images/default_identicon/{0}.png'.format(
BMConfigParser().addresses()[0], android_path)) BMConfigParser().addresses()[0], android_path))
else: else:
img.texture.save( img.texture.save('./images/default_identicon/{}.png'.format(
'./images/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0])) BMConfigParser().addresses()[0]))
return BMConfigParser().addresses()[0] return BMConfigParser().addresses()[0]
return 'Select Address' return 'Select Address'
@ -1565,16 +1494,14 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
@staticmethod @staticmethod
def get_inbox_count(): def get_inbox_count():
"""Getting inbox count""" """Getting inbox count"""
state.inbox_count = str( state.inbox_count = str(sqlQuery(
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])
@staticmethod @staticmethod
def get_sent_count(): def get_sent_count():
"""Getting sent count""" """Getting sent count"""
state.sent_count = str( state.sent_count = str(sqlQuery(
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])
@ -1593,12 +1520,10 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
" 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( state.draft_count = str(sqlQuery(
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
@ -1970,8 +1895,8 @@ class MailDetail(Screen):
self.parent.screens[0].loadMessagelist(state.association) self.parent.screens[0].loadMessagelist(state.association)
elif state.detailPageType == 'draft': elif state.detailPageType == 'draft':
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str( sqlExecute(
state.mail_id)) "DELETE FROM sent WHERE ackdata = ?;", str(state.mail_id))
msg_count_objs.draft_cnt.badge_text = str( msg_count_objs.draft_cnt.badge_text = str(
int(state.draft_count) - 1) int(state.draft_count) - 1)
state.draft_count = str(int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1)
@ -2195,27 +2120,17 @@ class Draft(Screen):
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!", text="yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def draftDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20): def draftDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
"""This methosd is for retrieving draft messages""" """This methosd is for retrieving draft messages"""
self.queryreturn = kivy_helper_search.search_sql( self.queryreturn = kivy_helper_search.search_sql(
xAddress, xAddress, self.account, "draft", where, what,
self.account, False, start_indx, end_indx)
"draft",
where,
what,
False,
start_indx,
end_indx)
def set_mdList(self): def set_mdList(self):
"""This method is used to create mdlist""" """This method is used to create mdlist"""
@ -2232,8 +2147,7 @@ class Draft(Screen):
'ackdata': mail[5]}) 'ackdata': mail[5]})
for item in data: for item in data:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text='Draft', text='Draft', secondary_text=item['text'],
secondary_text=item['text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
@ -2249,8 +2163,7 @@ class Draft(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1) del_btn.background_color = (1, 0, 0, 1)
del_btn.bind(on_press=partial( del_btn.bind(on_press=partial(self.delete_draft, item['ackdata']))
self.delete_draft, item['ackdata']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
carousel.index = 1 carousel.index = 1
@ -2323,23 +2236,10 @@ class Draft(Screen):
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '', toAddress, ripe,
'', fromAddress, subject, message, ackdata, int(time.time()),
toAddress, int(time.time()), 0, 'msgqueued', 0, 'draft', encoding,
ripe,
fromAddress,
subject,
message,
ackdata,
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'draft',
encoding,
BMConfigParser().getint('bitmessagesettings', 'ttl')) BMConfigParser().getint('bitmessagesettings', 'ttl'))
state.msg_counter_objs = src_object.children[2].children[0].ids state.msg_counter_objs = src_object.children[2].children[0].ids
state.draft_count = str(int(state.draft_count) + 1) state.draft_count = str(int(state.draft_count) + 1)
src_object.ids.sc16.clear_widgets() src_object.ids.sc16.clear_widgets()
@ -2395,13 +2295,9 @@ class Allmails(Screen):
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1', theme_text_color='Primary',
theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!", text="yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center', bold=True, size_hint_y=None, valign='top')
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def allMessageQuery(self, start_indx, end_indx): def allMessageQuery(self, start_indx, end_indx):
@ -2483,12 +2379,12 @@ class Allmails(Screen):
"""Delete inbox mail from all mail listing""" """Delete inbox mail from all mail listing"""
if folder == 'inbox': if folder == 'inbox':
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;",
unique_id)) str(unique_id))
else: else:
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash' WHERE ackdata = ?;", str( "UPDATE sent SET folder = 'trash' WHERE ackdata = ?;",
unique_id)) str(unique_id))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
try: try:
msg_count_objs = self.parent.parent.parent.parent.parent.children[ msg_count_objs = self.parent.parent.parent.parent.parent.children[
@ -2505,15 +2401,12 @@ class Allmails(Screen):
nav_lay_obj.sc1.ids.ml.clear_widgets() nav_lay_obj.sc1.ids.ml.clear_widgets()
nav_lay_obj.sc1.loadMessagelist(state.association) nav_lay_obj.sc1.loadMessagelist(state.association)
else: else:
msg_count_objs.send_cnt.badge_text = str( msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
nav_lay_obj.sc4.ids.ml.clear_widgets() nav_lay_obj.sc4.ids.ml.clear_widgets()
nav_lay_obj.sc4.loadSent(state.association) nav_lay_obj.sc4.loadSent(state.association)
msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.trash_cnt.badge_text = str(int(state.trash_count) + 1)
int(state.trash_count) + 1) msg_count_objs.allmail_cnt.badge_text = str(int(state.all_count) - 1)
msg_count_objs.allmail_cnt.badge_text = str(
int(state.all_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
if int(state.all_count) <= 0: if int(state.all_count) <= 0:

View File

@ -1,12 +1,15 @@
"""
Ui Singnaler for kivy interface
"""
from threading import Thread from threading import Thread
import state
import queues import queues
import state
from semaphores import kivyuisignaler from semaphores import kivyuisignaler
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure
class UIkivySignaler(Thread): class UIkivySignaler(Thread):
"""Kivy ui signaler"""
def run(self): def run(self):
kivyuisignaler.acquire() kivyuisignaler.acquire()
@ -14,13 +17,12 @@ class UIkivySignaler(Thread):
try: try:
command, data = queues.UISignalQueue.get() command, data = queues.UISignalQueue.get()
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
label, address, streamNumber = data address = data[1]
state.kivyapp.variable_1.append(address) state.kivyapp.variable_1.append(address)
# elif command == 'rerenderAddressBook': # elif command == 'rerenderAddressBook':
# state.kivyapp.obj_1.refreshs() # state.kivyapp.obj_1.refreshs()
# Need to discuss this # Need to discuss this
elif command == 'updateSentItemStatusByAckdata': elif command == 'updateSentItemStatusByAckdata':
state.kivyapp.status_dispatching(data) state.kivyapp.status_dispatching(data)
except Exception as e: except Exception as e:
print(e) print e