Merge pull request #10 from cis-navjot-g/newwork

wokred on addressbook search functionality implementation
This commit is contained in:
lakshyacis 2019-08-08 12:31:14 +05:30 committed by GitHub
commit 543d2d5cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 19 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ dist
docs/_*/*
docs/autodoc/
pyan/
.buildozer/
bin/

View File

@ -11,9 +11,12 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
sqlStatementBase = '''
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
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:
@ -24,6 +27,7 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
else:
sqlStatementParts.append(xAddress + " = ? ")
sqlArguments.append(account)
if folder is not "addressbook":
if folder is not None:
if folder == "new":
folder = "inbox"

View File

@ -290,10 +290,20 @@ class AddressBook(Screen):
Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts."""
data = sqlQuery("SELECT label, address from addressbook")
if data:
for item in data:
"""Clock Schdule for method AddressBook"""
self.loadAddresslist(None, 'All', '')
print(dt)
def loadAddresslist(self, account, where="", what=""):
"""Clock Schdule for method AddressBook"""
if state.searcing_text:
where = ['label', 'address']
what = state.searcing_text
xAddress = ''
queryreturn = kivy_helper_search.search_sql(
xAddress, account, "addressbook", where, what, False)
if queryreturn:
for item in queryreturn:
meny = TwoLineAvatarIconListItem(
text=item[0],
secondary_text=item[1],
@ -1088,6 +1098,9 @@ class NavigateApp(App):
if state.search_screen == 'inbox':
self.root.ids.sc1.clear_widgets()
self.root.ids.sc1.add_widget(Inbox())
elif state.search_screen == 'addressbook':
self.root.ids.sc11.clear_widgets()
self.root.ids.sc11.add_widget(AddressBook())
else:
self.root.ids.sc4.clear_widgets()
self.root.ids.sc4.add_widget(Sent())
@ -1095,7 +1108,7 @@ class NavigateApp(App):
def check_search_screen(self, instance):
"""Method show search button only on inbox or sent screen."""
if instance.text == 'Inbox' or instance.text == 'Sent':
if instance.text in ['Inbox', 'Sent', 'Address Book']:
if not self.root.ids.search_bar.children:
self.root.ids.search_bar.add_widget(
MDIconButton(icon='magnify'))
@ -1103,13 +1116,10 @@ class NavigateApp(App):
id='search_field', hint_text='Search icon')
text_field.bind(text=self.searchQuery)
self.root.ids.search_bar.add_widget(text_field)
state.searcing_text = ''
self.root.ids.sc1.clear_widgets()
self.root.ids.sc4.clear_widgets()
self.root.ids.sc1.add_widget(Inbox())
self.root.ids.sc4.add_widget(Sent())
self.root.ids.search_bar.children[0].text = ''
else:
self.root.ids.search_bar.clear_widgets()
state.searcing_text = ''
return
def add_search_bar(self):