Merge pull request #38 from navjotcis/newwork

worked on alter search approch or making app preformance faster
This commit is contained in:
lakshyacis 2019-09-30 15:53:48 +05:30 committed by GitHub
commit 19d6588db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 149 additions and 158 deletions

View File

@ -82,52 +82,52 @@
text: "Inbox" text: "Inbox"
on_release: app.root.ids.scr_mngr.current = 'inbox' on_release: app.root.ids.scr_mngr.current = 'inbox'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
id: send_cnt id: send_cnt
icon: 'send' icon: 'send'
text: "Sent" text: "Sent"
on_release: app.root.ids.scr_mngr.current = 'sent' on_release: app.root.ids.scr_mngr.current = 'sent'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
id: draft_cnt id: draft_cnt
icon: 'message-draw' icon: 'message-draw'
text: "Draft" text: "Draft"
on_release: app.root.ids.scr_mngr.current = 'draft' on_release: app.root.ids.scr_mngr.current = 'draft'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Starred" text: "Starred"
icon:'star' icon:'star'
on_release: app.root.ids.scr_mngr.current = 'starred' on_release: app.root.ids.scr_mngr.current = 'starred'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'archive' icon: 'archive'
text: "Archieve" text: "Archieve"
on_release: app.root.ids.scr_mngr.current = 'archieve' on_release: app.root.ids.scr_mngr.current = 'archieve'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email-open-outline' icon: 'email-open-outline'
text: "Spam" text: "Spam"
on_release: app.root.ids.scr_mngr.current = 'spam' on_release: app.root.ids.scr_mngr.current = 'spam'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
id: trash_cnt id: trash_cnt
icon: 'delete' icon: 'delete'
text: "Trash" text: "Trash"
on_release: app.root.ids.scr_mngr.current = 'trash' on_release: app.root.ids.scr_mngr.current = 'trash'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
id: allmail_cnt id: allmail_cnt
text: "All Mails" text: "All Mails"
icon:'contact-mail' icon:'contact-mail'
on_release: app.root.ids.scr_mngr.current = 'allmails' on_release: app.root.ids.scr_mngr.current = 'allmails'
badge_text: "0" badge_text: "0"
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerDivider: NavigationDrawerDivider:
NavigationDrawerSubheader: NavigationDrawerSubheader:
text: "All labels" text: "All labels"
@ -135,37 +135,37 @@
text: "Address Book" text: "Address Book"
icon:'book-multiple' icon:'book-multiple'
on_release: app.root.ids.scr_mngr.current = 'addressbook' on_release: app.root.ids.scr_mngr.current = 'addressbook'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Settings" text: "Settings"
icon:'settings' icon:'settings'
on_release: app.root.ids.scr_mngr.current = 'set' on_release: app.root.ids.scr_mngr.current = 'set'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Subscriptions/Payment" text: "Subscriptions/Payment"
icon:'wallet' icon:'wallet'
on_release: app.root.ids.scr_mngr.current = 'payment' on_release: app.root.ids.scr_mngr.current = 'payment'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Credits" text: "Credits"
icon:'wallet' icon:'wallet'
on_release: app.root.ids.scr_mngr.current = 'credits' on_release: app.root.ids.scr_mngr.current = 'credits'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "new address" text: "new address"
icon:'account-plus' icon:'account-plus'
on_release: app.root.ids.scr_mngr.current = 'login' on_release: app.root.ids.scr_mngr.current = 'login'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Network Status" text: "Network Status"
icon:'server-network' icon:'server-network'
on_release: app.root.ids.scr_mngr.current = 'networkstat' on_release: app.root.ids.scr_mngr.current = 'networkstat'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "My Addresses" text: "My Addresses"
icon:'account-multiple' icon:'account-multiple'
on_release: app.root.ids.scr_mngr.current = 'myaddress' on_release: app.root.ids.scr_mngr.current = 'myaddress'
on_press: app.check_search_screen(self) on_press: app.refreshScreen(self)
NavigationLayout: NavigationLayout:
id: nav_layout id: nav_layout
@ -186,18 +186,6 @@ NavigationLayout:
background_hue: '500' background_hue: '500'
left_action_items: [['menu', lambda x: app.root.toggle_nav_drawer()]] left_action_items: [['menu', lambda x: app.root.toggle_nav_drawer()]]
right_action_items: [['account-plus', lambda x: app.addingtoaddressbook()]] right_action_items: [['account-plus', lambda x: app.addingtoaddressbook()]]
BoxLayout:
id: search_bar
size_hint_y: None
height: self.minimum_height
MDIconButton:
icon: 'magnify'
MDTextField:
id: search_field
hint_text: 'Search'
on_text: app.searchQuery(self)
ScreenManager: ScreenManager:
id: scr_mngr id: scr_mngr
@ -246,21 +234,30 @@ NavigationLayout:
<Inbox>: <Inbox>:
name: 'inbox' name: 'inbox'
FloatLayout: BoxLayout:
MDScrollViewRefreshLayout: orientation: 'vertical'
id: refresh_layout spacing: dp(10)
refresh_callback: root.refresh_callback SearchBar:
root_layout: root FloatLayout:
MDList: MDScrollViewRefreshLayout:
id: ml id: refresh_layout
refresh_callback: root.refresh_callback
root_layout: root
MDList:
id: ml
ComposerButton: ComposerButton:
<Sent>: <Sent>:
name: 'sent' name: 'sent'
ScrollView: BoxLayout:
do_scroll_x: False orientation: 'vertical'
MDList: SearchBar:
id: ml BoxLayout:
orientation:'vertical'
ScrollView:
do_scroll_x: False
MDList:
id: ml
ComposerButton: ComposerButton:
<Trash>: <Trash>:
@ -654,23 +651,29 @@ NavigationLayout:
<MyAddress>: <MyAddress>:
name: 'myaddress' name: 'myaddress'
FloatLayout: BoxLayout:
MDScrollViewRefreshLayout: orientation: 'vertical'
id: refresh_layout SearchBar:
refresh_callback: root.refresh_callback FloatLayout:
root_layout: root MDScrollViewRefreshLayout:
MDList: id: refresh_layout
id: ml refresh_callback: root.refresh_callback
root_layout: root
MDList:
id: ml
ComposerButton: ComposerButton:
<AddressBook>: <AddressBook>:
name: 'addressbook' name: 'addressbook'
BoxLayout: BoxLayout:
orientation:'vertical' orientation: 'vertical'
ScrollView: SearchBar:
do_scroll_x: False BoxLayout:
MDList: orientation:'vertical'
id: ml ScrollView:
do_scroll_x: False
MDList:
id: ml
ComposerButton: ComposerButton:
<Payment>: <Payment>:
@ -1223,3 +1226,17 @@ NavigationLayout:
size: 15, 15 size: 15, 15
x: self.parent.x + self.parent.width - self.width - 5 x: self.parent.x + self.parent.width - self.width - 5
y: self.parent.y + self.parent.height/2 - self.height + 5 y: self.parent.y + self.parent.height/2 - self.height + 5
<SearchBar@BoxLayout>:
id: search_bar
size_hint_y: None
height: self.minimum_height
MDIconButton:
icon: 'magnify'
MDTextField:
id: search_field
hint_text: 'Search'
on_text: app.searchQuery(self)

View File

@ -79,8 +79,6 @@ class Navigatorss(MDNavigationDrawer):
class Inbox(Screen): class Inbox(Screen):
"""Inbox Screen uses screen to show widgets of screens.""" """Inbox Screen uses screen to show widgets of screens."""
data = ListProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method Parsing the address.""" """Method Parsing the address."""
super(Inbox, self).__init__(*args, **kwargs) super(Inbox, self).__init__(*args, **kwargs)
@ -168,7 +166,6 @@ class Inbox(Screen):
def inbox_detail(self, receivedTime, *args): def inbox_detail(self, receivedTime, *args):
"""Load inbox page details.""" """Load inbox page details."""
remove_search_bar(self)
state.detailPageType = 'inbox' state.detailPageType = 'inbox'
state.sentMailTime = receivedTime state.sentMailTime = receivedTime
if self.manager: if self.manager:
@ -184,8 +181,12 @@ class Inbox(Screen):
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE received = {};".format( "UPDATE inbox SET folder = 'trash' WHERE received = {};".format(
data_index)) data_index))
msg_count_objs = \ try:
self.parent.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = \
self.parent.parent.parent.parent.children[2].children[0].ids
except Exception as e:
msg_count_objs = \
self.parent.parent.parent.parent.parent.children[2].children[0].ids
if int(state.inbox_count) > 0: if int(state.inbox_count) > 0:
msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.badge_text = str(
int(state.inbox_count) - 1) int(state.inbox_count) - 1)
@ -226,13 +227,10 @@ class Inbox(Screen):
"""Method updates the state of application, While the spinner remains on the screen.""" """Method updates the state of application, While the spinner remains on the screen."""
def refresh_callback(interval): def refresh_callback(interval):
"""Method used for loading the inbox screen data.""" """Method used for loading the inbox screen data."""
state.searcing_text = ''
self.children[2].children[1].ids.search_field.text = ''
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
self.remove_widget(self.children[1]) self.loadMessagelist(state.association)
try:
screens_obj = self.parent.screens[0]
except Exception:
screens_obj = self.parent.parent.screens[0]
screens_obj.add_widget(Inbox())
self.ids.refresh_layout.refresh_done() self.ids.refresh_layout.refresh_done()
self.tick = 0 self.tick = 0
@ -284,12 +282,11 @@ class MyAddress(Screen):
size_hint_y=None, size_hint_y=None,
valign='top') valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
try: if not state.searcing_text:
self.manager.parent.parent\ try:
.parent.ids.search_bar.clear_widgets() self.manager.current = 'login'
self.manager.current = 'login' except Exception:
except Exception: pass
pass
@staticmethod @staticmethod
def myadd_detail(fromaddress, label, *args): def myadd_detail(fromaddress, label, *args):
@ -303,13 +300,10 @@ class MyAddress(Screen):
"""Method updates the state of application, While the spinner remains on the screen.""" """Method updates the state of application, While the spinner remains on the screen."""
def refresh_callback(interval): def refresh_callback(interval):
"""Method used for loading the myaddress screen data.""" """Method used for loading the myaddress screen data."""
state.searcing_text = ''
self.children[2].children[1].ids.search_field.text = ''
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
self.remove_widget(self.children[1]) self.init_ui()
try:
screens_obj = self.parent.screens[9]
except Exception:
screens_obj = self.parent.parent.screens[9]
screens_obj.add_widget(MyAddress())
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)
@ -386,8 +380,8 @@ class AddressBook(Screen):
@staticmethod @staticmethod
def refreshs(*args): def refreshs(*args):
"""Refresh the Widget.""" """Refresh the Widget."""
state.navinstance.ids.sc11.clear_widgets() state.navinstance.ids.sc11.ids.ml.clear_widgets()
state.navinstance.ids.sc11.add_widget(AddressBook()) state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
@staticmethod @staticmethod
def addBook_detail(address, label, *args): def addBook_detail(address, label, *args):
@ -523,8 +517,8 @@ class DropDownWidget(BoxLayout):
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[0].children[2].children[0].ids .parent.parent.children[0].children[2].children[0].ids
self.parent.parent.screens[3].clear_widgets() self.parent.parent.screens[3].ids.ml.clear_widgets()
self.parent.parent.screens[3].add_widget(Sent()) self.parent.parent.screens[3].loadSent(state.association)
self.parent.parent.screens[16].clear_widgets() self.parent.parent.screens[16].clear_widgets()
self.parent.parent.screens[16].add_widget(Allmails()) self.parent.parent.screens[16].add_widget(Allmails())
toLabel = '' toLabel = ''
@ -701,9 +695,8 @@ class Random(Screen):
self.ids.label.text = '' self.ids.label.text = ''
self.parent.parent.parent.parent.ids.toolbar.opacity = 1 self.parent.parent.parent.parent.ids.toolbar.opacity = 1
self.parent.parent.parent.parent.ids.toolbar.disabled = False self.parent.parent.parent.parent.ids.toolbar.disabled = False
self.parent.parent.parent.parent.ids.sc10.clear_widgets() self.parent.parent.parent.parent.ids.sc10.ids.ml.clear_widgets()
self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress()) self.parent.parent.parent.parent.ids.sc10.init_ui()
navApp.add_search_bar()
toast('New address created') toast('New address created')
@ -715,9 +708,6 @@ class AddressSuccessful(Screen):
class Sent(Screen): class Sent(Screen):
"""Sent Screen uses screen to show widgets of screens.""" """Sent Screen uses screen to show widgets of screens."""
data = ListProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Association with the screen.""" """Association with the screen."""
super(Sent, self).__init__(*args, **kwargs) super(Sent, self).__init__(*args, **kwargs)
@ -742,6 +732,7 @@ class Sent(Screen):
where = ['subject', 'message'] where = ['subject', 'message']
what = state.searcing_text what = state.searcing_text
xAddress = 'fromaddress' xAddress = 'fromaddress'
data = []
queryreturn = kivy_helper_search.search_sql( queryreturn = kivy_helper_search.search_sql(
xAddress, account, "sent", where, what, False) xAddress, account, "sent", where, what, False)
if state.msg_counter_objs and state.association == \ if state.msg_counter_objs and state.association == \
@ -757,13 +748,13 @@ class Sent(Screen):
src_mng_obj.send_cnt.badge_text = str(len(queryreturn)) src_mng_obj.send_cnt.badge_text = str(len(queryreturn))
state.sent_count = str(len(queryreturn)) state.sent_count = str(len(queryreturn))
for mail in queryreturn: for mail in queryreturn:
self.data.append({ data.append({
'text': mail[1].strip(), 'text': mail[1].strip(),
'secondary_text': mail[2][:50] + '........' if len( 'secondary_text': mail[2][:50] + '........' if len(
mail[2]) >= 50 else ( mail[2]) >= 50 else (
mail[2] + ',' + mail[3].replace('\n', ''))[0:50] + '........', mail[2] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
'lastactiontime': mail[6]}) 'lastactiontime': mail[6]})
for item in self.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'],
@ -808,7 +799,6 @@ class Sent(Screen):
def sent_detail(self, lastsenttime, *args): def sent_detail(self, lastsenttime, *args):
"""Load sent mail details.""" """Load sent mail details."""
remove_search_bar(self)
state.detailPageType = 'sent' state.detailPageType = 'sent'
state.sentMailTime = lastsenttime state.sentMailTime = lastsenttime
if self.manager: if self.manager:
@ -1031,8 +1021,9 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
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
self.root.ids.sc1.clear_widgets() state.searcing_text = ''
self.root.ids.sc1.add_widget(Inbox()) self.root.ids.sc1.ids.ml.clear_widgets()
self.root.ids.sc1.loadMessagelist(state.association)
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
msg_counter_objs = \ msg_counter_objs = \
@ -1135,7 +1126,6 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.scr_mngr.current = 'login' self.root.ids.scr_mngr.current = 'login'
else: else:
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
self.add_search_bar()
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)
return True return True
@ -1155,7 +1145,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
def clear_composer(self): def clear_composer(self):
"""If slow down the nwe will make new composer edit screen.""" """If slow down the nwe will make new composer edit screen."""
self.set_navbar_for_composer() self.set_navbar_for_composer()
self.root.ids.search_bar.clear_widgets() # self.root.ids.search_bar.clear_widgets()
composer_obj = self.root.ids.sc3.children[0].ids composer_obj = self.root.ids.sc3.children[0].ids
composer_obj.ti.text = '' composer_obj.ti.text = ''
composer_obj.btn.text = 'Select' composer_obj.btn.text = 'Select'
@ -1183,8 +1173,6 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
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
else:
self.add_search_bar()
state.detailPageType = '' state.detailPageType = ''
state.in_composer = False state.in_composer = False
@ -1211,66 +1199,60 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
return label + address return label + address
return '' return ''
def searchQuery(self, instance, *args): def searchQuery(self, instance):
"""Method used for showing searched mails.""" """Method used for 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 state.search_screen == 'inbox': if state.search_screen == 'inbox':
self.root.ids.sc1.clear_widgets() self.root.ids.sc1.ids.ml.clear_widgets()
self.root.ids.sc1.add_widget(Inbox()) self.root.ids.sc1.loadMessagelist(state.association)
elif state.search_screen == 'addressbook': elif state.search_screen == 'addressbook':
self.root.ids.sc11.clear_widgets() self.root.ids.sc11.ids.ml.clear_widgets()
self.root.ids.sc11.add_widget(AddressBook()) self.root.ids.sc11.loadAddresslist(None, 'All', '')
elif state.search_screen == 'myaddress': elif state.search_screen == 'myaddress':
self.root.ids.sc10.clear_widgets() self.root.ids.sc10.ids.ml.clear_widgets()
self.root.ids.sc10.add_widget(MyAddress()) self.root.ids.sc10.init_ui()
else: else:
self.root.ids.sc4.clear_widgets() self.root.ids.sc4.ids.ml.clear_widgets()
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.loadSent(state.association)
self.root.ids.scr_mngr.current = state.search_screen self.root.ids.scr_mngr.current = state.search_screen
def clearSreeen(self, text): def refreshScreen(self, instance):
"""Method is used for clear screen""" """Method show search button only on inbox or sent screen."""
if text == 'Sent': state.searcing_text = ''
self.root.ids.sc4.clear_widgets() if instance.text == 'Sent':
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.ids.ml.clear_widgets()
elif text == 'Draft': self.root.ids.sc4.children[1].children[1].ids.search_field.text = ''
self.root.ids.sc4.loadSent(state.association)
elif instance.text == 'Inbox':
self.root.ids.sc1.ids.ml.clear_widgets()
try:
self.root.ids.sc1.children[2].children[1].ids.search_field.text = ''
except Exception as e:
self.root.ids.sc1.children[1].children[1].ids.search_field.text = ''
self.root.ids.sc1.loadMessagelist(state.association)
elif instance.text == 'Draft':
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())
elif text == 'Trash': elif instance.text == 'Trash':
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())
elif 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())
elif instance.text == 'Address Book':
def check_search_screen(self, instance): self.root.ids.sc11.ids.ml.clear_widgets()
"""Method show search button only on inbox or sent screen.""" self.root.ids.sc11.children[1].children[1].ids.search_field.text = ''
if instance.text in ['Sent', 'Draft', 'Trash', 'All Mails']: self.root.ids.sc11.loadAddresslist(None, 'All', '')
self.clearSreeen(instance.text) elif instance.text == 'My Addresses':
if instance.text in ['Inbox', 'Sent', 'Address Book', 'My Addresses']: self.root.ids.sc10.ids.ml.clear_widgets()
if not self.root.ids.search_bar.children: try:
self.root.ids.search_bar.add_widget( self.root.ids.sc10.children[1].children[1].ids.search_field.text = ''
MDIconButton(icon='magnify')) except Exception as e:
text_field = MDTextField( self.root.ids.sc10.children[2].children[1].ids.search_field.text = ''
id='search_field', hint_text='Search') self.root.ids.sc10.init_ui()
text_field.bind(text=self.searchQuery)
self.root.ids.search_bar.add_widget(text_field)
self.root.ids.search_bar.children[0].text = ''
else:
self.root.ids.search_bar.clear_widgets()
state.searcing_text = ''
return return
def add_search_bar(self):
"""Method used for adding search function on screen"""
if not self.root.ids.search_bar.children:
self.root.ids.search_bar.add_widget(MDIconButton(icon='magnify'))
text_field = MDTextField(
id='search_field', hint_text='Search')
text_field.bind(text=self.searchQuery)
self.root.ids.search_bar.add_widget(text_field)
def set_identicon(self, text): def set_identicon(self, text):
"""This method is use for showing identicon in address spinner""" """This method is use for showing identicon in address spinner"""
img = identiconGeneration.generate(text) img = identiconGeneration.generate(text)
@ -1477,8 +1459,8 @@ class MailDetail(Screen):
lastactiontime = {};".format(state.sentMailTime)) lastactiontime = {};".format(state.sentMailTime))
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
self.parent.screens[3].clear_widgets() self.parent.screens[3].ids.ml.clear_widgets()
self.parent.screens[3].add_widget(Sent()) self.parent.screens[3].loadSent(state.association)
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE \ "UPDATE inbox SET folder = 'trash' WHERE \
@ -1486,8 +1468,8 @@ class MailDetail(Screen):
# msg_count_objs.inbox_cnt.badge_text = str( # msg_count_objs.inbox_cnt.badge_text = str(
# int(state.inbox_count) - 1) # int(state.inbox_count) - 1)
# state.inbox_count = str(int(state.inbox_count) - 1) # state.inbox_count = str(int(state.inbox_count) - 1)
self.parent.screens[0].clear_widgets() self.parent.screens[0].ids.ml.clear_widgets()
self.parent.screens[0].add_widget(Inbox()) self.parent.screens[0].loadMessagelist(state.association)
elif state.detailPageType == 'draft': elif state.detailPageType == 'draft':
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format( sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
state.sentMailTime)) state.sentMailTime))
@ -1519,6 +1501,7 @@ class MailDetail(Screen):
composer_obj.btn.text = data[0][0] composer_obj.btn.text = data[0][0]
composer_obj.txt_input.text = data[0][1] composer_obj.txt_input.text = data[0][1]
composer_obj.subject.text = data[0][2] composer_obj.subject.text = data[0][2]
composer_obj.body.text = ''
state.kivyapp.root.ids.sc3.children[0].ids.rv.data = '' state.kivyapp.root.ids.sc3.children[0].ids.rv.data = ''
self.parent.current = 'create' self.parent.current = 'create'
state.kivyapp.set_navbar_for_composer() state.kivyapp.set_navbar_for_composer()
@ -1603,8 +1586,8 @@ class AddbookDetailPopup(Popup):
if str(self.ids.add_label.text): if str(self.ids.add_label.text):
sqlExecute("UPDATE addressbook SET label = '{}' WHERE \ sqlExecute("UPDATE addressbook SET label = '{}' WHERE \
address = '{}';".format(str(self.ids.add_label.text), address)) address = '{}';".format(str(self.ids.add_label.text), address))
self.parent.children[1].ids.sc11.clear_widgets() self.parent.children[1].ids.sc11.ids.ml.clear_widgets()
self.parent.children[1].ids.sc11.add_widget(AddressBook()) self.parent.children[1].ids.sc11.loadAddresslist(None, 'All', '')
self.dismiss() self.dismiss()
toast('Saved') toast('Saved')
@ -1630,7 +1613,7 @@ class ShowQRCode(Screen):
def qrdisplay(self): def qrdisplay(self):
"""Method used for showing QR Code.""" """Method used for showing QR Code."""
self.manager.parent.parent.parent.ids.search_bar.clear_widgets() # self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
self.ids.qr.clear_widgets() self.ids.qr.clear_widgets()
from kivy.garden.qrcode import QRCodeWidget from kivy.garden.qrcode import QRCodeWidget
self.ids.qr.add_widget(QRCodeWidget( self.ids.qr.add_widget(QRCodeWidget(
@ -1659,9 +1642,9 @@ class Draft(Screen):
def sentaccounts(self): def sentaccounts(self):
"""Load draft accounts.""" """Load draft accounts."""
account = state.association account = state.association
self.loadSent(account, 'All', '') self.loadDraft(account, 'All', '')
def loadSent(self, account, where="", what=""): def loadDraft(self, account, where="", what=""):
"""Load draft list for Draft messages.""" """Load draft list for Draft messages."""
xAddress = 'fromaddress' xAddress = 'fromaddress'
queryreturn = kivy_helper_search.search_sql( queryreturn = kivy_helper_search.search_sql(
@ -1807,14 +1790,6 @@ class CustomSpinner(Spinner):
self.dropdown_cls.max_height = Window.size[1] / 3 self.dropdown_cls.max_height = Window.size[1] / 3
def remove_search_bar(obj):
"""Remove search bar."""
try:
obj.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets()
except Exception:
obj.parent.parent.parent.parent.ids.search_bar.clear_widgets()
class Allmails(Screen): class Allmails(Screen):
"""all mails Screen uses screen to show widgets of screens.""" """all mails Screen uses screen to show widgets of screens."""
@ -1894,7 +1869,6 @@ class Allmails(Screen):
def mail_detail(self, unique_id, folder, *args): def mail_detail(self, unique_id, folder, *args):
"""Load sent and inbox mail details.""" """Load sent and inbox mail details."""
remove_search_bar(self)
state.detailPageType = folder state.detailPageType = folder
state.is_allmail = True state.is_allmail = True
state.sentMailTime = unique_id state.sentMailTime = unique_id
@ -1929,14 +1903,14 @@ class Allmails(Screen):
msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.badge_text = str(
int(state.inbox_count) - 1) int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1) state.inbox_count = str(int(state.inbox_count) - 1)
nav_lay_obj.sc1.clear_widgets() nav_lay_obj.sc1.ids.ml.clear_widgets()
nav_lay_obj.sc1.add_widget(Inbox()) 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.clear_widgets() nav_lay_obj.sc4.ids.ml.clear_widgets()
nav_lay_obj.sc4.add_widget(Sent()) 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( msg_count_objs.allmail_cnt.badge_text = str(