Toast functionality Fixes

This commit is contained in:
lakshyacis 2019-08-13 17:24:04 +05:30
commit ddcf2064aa
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
3 changed files with 102 additions and 29 deletions

View File

@ -197,7 +197,7 @@ NavigationLayout:
MDTextField: MDTextField:
id: search_field id: search_field
hint_text: 'Search icon' hint_text: 'Search'
on_text: app.searchQuery(self) on_text: app.searchQuery(self)
ScreenManager: ScreenManager:
id: scr_mngr id: scr_mngr
@ -369,7 +369,7 @@ NavigationLayout:
MDRaisedButton: MDRaisedButton:
size_hint: 1, None size_hint: 1, None
height: dp(40) height: dp(40)
on_press: app.root.ids.scr_mngr.current = 'random' on_press: root.reset_composer()
MDLabel: MDLabel:
font_style: 'Title' font_style: 'Title'
text: 'reset' text: 'reset'
@ -667,6 +667,7 @@ NavigationLayout:
size_hint: 1.5, None size_hint: 1.5, None
height: dp(40) height: dp(40)
on_press: root.dismiss() on_press: root.dismiss()
on_press: root.close_pop()
MDLabel: MDLabel:
font_style: 'Title' font_style: 'Title'
text: 'Cancel' text: 'Cancel'
@ -914,6 +915,7 @@ NavigationLayout:
size_hint: 1.5, None size_hint: 1.5, None
height: dp(40) height: dp(40)
on_press: root.dismiss() on_press: root.dismiss()
on_press: root.close_pop()
MDLabel: MDLabel:
font_style: 'Title' font_style: 'Title'
text: 'Cancel' text: 'Cancel'
@ -990,6 +992,7 @@ NavigationLayout:
size_hint: 1.5, None size_hint: 1.5, None
height: dp(40) height: dp(40)
on_press: root.dismiss() on_press: root.dismiss()
on_press: root.close_pop()
MDLabel: MDLabel:
font_style: 'Title' font_style: 'Title'
text: 'Cancel' text: 'Cancel'

View File

@ -48,6 +48,14 @@ from kivy.uix.spinner import Spinner
from kivymd.textfields import MDTextField from kivymd.textfields import MDTextField
def toast(text):
"""Method will display the toast message."""
if platform == 'linux':
from kivymd.toast.kivytoast import toast
toast(text)
return
class Navigatorss(MDNavigationDrawer): class Navigatorss(MDNavigationDrawer):
"""Navigators class contains image, title and logo.""" """Navigators class contains image, title and logo."""
@ -138,7 +146,8 @@ class Inbox(Screen):
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="No message found!" if state.searcing_text
else "yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center',
bold=True, bold=True,
size_hint_y=None, size_hint_y=None,
@ -165,7 +174,7 @@ class Inbox(Screen):
"UPDATE inbox SET folder = 'trash' WHERE received = {};".format( "UPDATE inbox SET folder = 'trash' WHERE received = {};".format(
data_index)) data_index))
msg_count_objs = \ msg_count_objs = \
self.parent.parent.parent.parent.children[2].children[0].ids 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)
@ -174,6 +183,7 @@ class Inbox(Screen):
state.inbox_count = str(int(state.inbox_count) - 1) state.inbox_count = str(int(state.inbox_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
toast('Deleted')
self.update_trash() self.update_trash()
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
@ -220,9 +230,14 @@ class MyAddress(Screen):
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock Schdule for method inbox accounts."""
if BMConfigParser().addresses() or state.kivyapp.variable_1: addresses_list = state.kivyapp.variable_1
if state.searcing_text:
filtered_list = filter(lambda addr: self.filter_address(
addr), BMConfigParser().addresses())
addresses_list = filtered_list
if addresses_list:
data = [] data = []
for address in state.kivyapp.variable_1: for address in addresses_list:
data.append({ data.append({
'text': BMConfigParser().get(address, 'label'), 'text': BMConfigParser().get(address, 'label'),
'secondary_text': address}) 'secondary_text': address})
@ -244,13 +259,16 @@ class MyAddress(Screen):
content = MDLabel( content = MDLabel(
font_style='Body1', font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="yet no address is created by user!!!!!!!!!!!!!", text="No address found!" if state.searcing_text
else "yet no address is created by user!!!!!!!!!!!!!",
halign='center', halign='center',
bold=True, bold=True,
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: try:
self.manager.parent.parent\
.parent.ids.search_bar.clear_widgets()
self.manager.current = 'login' self.manager.current = 'login'
except Exception as e: except Exception as e:
pass pass
@ -278,6 +296,16 @@ class MyAddress(Screen):
Clock.schedule_once(refresh_callback, 1) Clock.schedule_once(refresh_callback, 1)
def filter_address(self, address):
"""Method will filter the my address list data."""
if filter(lambda x: (
state.searcing_text).lower() in x, [
BMConfigParser().get(
address,
'label').lower(), address.lower()]):
return True
return False
class AddressBook(Screen): class AddressBook(Screen):
"""AddressBook Screen uses screen to show widgets of screens.""" """AddressBook Screen uses screen to show widgets of screens."""
@ -332,9 +360,11 @@ class AddressBook(Screen):
carousel.index = 1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="No Contact Found yet...... ", text="No contact found!" if state.searcing_text
else "No contact found yet...... ",
halign='center', halign='center',
bold=True, bold=True,
size_hint_y=None, size_hint_y=None,
@ -469,10 +499,10 @@ class DropDownWidget(BoxLayout):
self.ids.ti.text = '' self.ids.ti.text = ''
self.ids.subject.text = '' self.ids.subject.text = ''
self.ids.txt_input.text = '' self.ids.txt_input.text = ''
self.parent.parent.current = 'sent' self.parent.parent.current = 'inbox'
self.ids.btn.text = 'select' self.ids.btn.text = 'select'
self.ids.ti.text = '' self.ids.ti.text = ''
toast('send')
return None return None
else: else:
msg = 'Enter a valid recipients address' msg = 'Enter a valid recipients address'
@ -508,6 +538,14 @@ class DropDownWidget(BoxLayout):
self.but.bind(on_press=self.main_pop.dismiss) self.but.bind(on_press=self.main_pop.dismiss)
self.main_pop.open() self.main_pop.open()
def reset_composer(self):
"""Method will reset composer."""
self.ids.ti.text = ''
self.ids.btn.text = 'Select'
self.ids.txt_input.text = ''
self.ids.subject.text = ''
self.ids.body.text = ''
class MyTextInput(TextInput): class MyTextInput(TextInput):
"""Takes the text input in the field.""" """Takes the text input in the field."""
@ -626,6 +664,7 @@ class Random(Screen):
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.clear_widgets()
self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress()) self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress())
toast('New address created')
class AddressSuccessful(Screen): class AddressSuccessful(Screen):
@ -721,7 +760,8 @@ class Sent(Screen):
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="No message found!" if state.searcing_text
else "yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center',
bold=True, bold=True,
size_hint_y=None, size_hint_y=None,
@ -760,6 +800,7 @@ class Sent(Screen):
"UPDATE sent SET folder = 'trash' \ "UPDATE sent SET folder = 'trash' \
WHERE lastactiontime = {};".format(data_index)) WHERE lastactiontime = {};".format(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
toast('Deleted')
self.update_trash() self.update_trash()
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
@ -930,11 +971,11 @@ class NavigateApp(App):
folder = 'sent' ;".format(state.association))[0][0]) folder = 'sent' ;".format(state.association))[0][0])
state.inbox_count = str( state.inbox_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and \ "SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and \
folder = 'inbox' ;".format(state.association))[0][0]) folder = 'inbox' ;".format(state.association))[0][0])
state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \ state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \
where fromaddress = '{0}' and folder = 'trash' ) \ where fromaddress = '{0}' and folder = 'trash' ) \
+(SELECT count(*) FROM inbox where fromaddress = '{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(
@ -1013,6 +1054,8 @@ class NavigateApp(App):
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.root.ids.toolbar.left_action_items = ''
# self.root.ids.myButton.opacity = 0
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 = ''
@ -1039,7 +1082,7 @@ class NavigateApp(App):
return state.sent_count return state.sent_count
elif text == 'Inbox': elif text == 'Inbox':
state.inbox_count = str(sqlQuery( state.inbox_count = str(sqlQuery(
"SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \ "SELECT COUNT(*) FROM {0} WHERE toaddress = '{1}' and \
folder = '{0}' ;".format( folder = '{0}' ;".format(
text.lower(), state.association))[0][0]) text.lower(), state.association))[0][0])
return state.inbox_count return state.inbox_count
@ -1047,7 +1090,7 @@ class NavigateApp(App):
state.trash_count = str(sqlQuery( state.trash_count = str(sqlQuery(
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' \ "SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' \
and folder = 'trash' )+(SELECT count(*) FROM inbox where \ and folder = 'trash' )+(SELECT count(*) FROM inbox where \
fromaddress = '{0}' and folder = 'trash') AS SumCount".format( toaddress = '{0}' and folder = 'trash') AS SumCount".format(
state.association))[0][0]) state.association))[0][0])
return state.trash_count return state.trash_count
elif text == 'Draft': elif text == 'Draft':
@ -1079,6 +1122,9 @@ class NavigateApp(App):
elif state.search_screen == 'addressbook': elif state.search_screen == 'addressbook':
self.root.ids.sc11.clear_widgets() self.root.ids.sc11.clear_widgets()
self.root.ids.sc11.add_widget(AddressBook()) self.root.ids.sc11.add_widget(AddressBook())
elif state.search_screen == 'myaddress':
self.root.ids.sc10.clear_widgets()
self.root.ids.sc10.add_widget(MyAddress())
else: else:
self.root.ids.sc4.clear_widgets() self.root.ids.sc4.clear_widgets()
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.add_widget(Sent())
@ -1086,12 +1132,12 @@ class NavigateApp(App):
def check_search_screen(self, instance): def check_search_screen(self, instance):
"""Method show search button only on inbox or sent screen.""" """Method show search button only on inbox or sent screen."""
if instance.text in ['Inbox', 'Sent', 'Address Book']: if instance.text in ['Inbox', 'Sent', 'Address Book', 'My Addresses']:
if not self.root.ids.search_bar.children: if not self.root.ids.search_bar.children:
self.root.ids.search_bar.add_widget( self.root.ids.search_bar.add_widget(
MDIconButton(icon='magnify')) MDIconButton(icon='magnify'))
text_field = MDTextField( text_field = MDTextField(
id='search_field', hint_text='Search icon') id='search_field', hint_text='Search')
text_field.bind(text=self.searchQuery) text_field.bind(text=self.searchQuery)
self.root.ids.search_bar.add_widget(text_field) self.root.ids.search_bar.add_widget(text_field)
self.root.ids.search_bar.children[0].text = '' self.root.ids.search_bar.children[0].text = ''
@ -1105,7 +1151,7 @@ class NavigateApp(App):
if not self.root.ids.search_bar.children: if not self.root.ids.search_bar.children:
self.root.ids.search_bar.add_widget(MDIconButton(icon='magnify')) self.root.ids.search_bar.add_widget(MDIconButton(icon='magnify'))
text_field = MDTextField( text_field = MDTextField(
id='search_field', hint_text='Search icon') id='search_field', hint_text='Search')
text_field.bind(text=self.searchQuery) text_field.bind(text=self.searchQuery)
self.root.ids.search_bar.add_widget(text_field) self.root.ids.search_bar.add_widget(text_field)
@ -1137,12 +1183,15 @@ class GrashofPopup(Popup):
label = self.ids.label.text label = self.ids.label.text
address = self.ids.address.text address = self.ids.address.text
if label and address: stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
folder="addressbook")]
if label and address and address not in stored_address:
state.navinstance = self.parent.children[1] state.navinstance = self.parent.children[1]
queues.UISignalQueue.put(('rerenderAddressBook', '')) queues.UISignalQueue.put(('rerenderAddressBook', ''))
self.dismiss() self.dismiss()
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address) sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
self.parent.children[1].ids.scr_mngr.current = 'addressbook' self.parent.children[1].ids.scr_mngr.current = 'addressbook'
toast('Saved')
def show_error_message(self): def show_error_message(self):
"""Showing error message.""" """Showing error message."""
@ -1163,6 +1212,10 @@ class GrashofPopup(Popup):
action=lambda *x: self.dialog.dismiss()) action=lambda *x: self.dialog.dismiss())
self.dialog.open() self.dialog.open()
def close_pop(self):
"""Pop is Canceled."""
toast('Canceled')
class AvatarSampleWidget(ILeftBody, Image): class AvatarSampleWidget(ILeftBody, Image):
"""Avatar Sample Widget.""" """Avatar Sample Widget."""
@ -1276,6 +1329,7 @@ class MailDetail(Screen):
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
self.parent.parent.screens[4].clear_widgets() self.parent.parent.screens[4].clear_widgets()
self.parent.parent.screens[4].add_widget(Trash()) self.parent.parent.screens[4].add_widget(Trash())
toast('Deleted')
def inbox_reply(self): def inbox_reply(self):
"""Method used for replying inbox messages.""" """Method used for replying inbox messages."""
@ -1326,6 +1380,10 @@ class MyaddDetailPopup(Popup):
window_obj.scr_mngr.current = 'create' window_obj.scr_mngr.current = 'create'
self.dismiss() self.dismiss()
def close_pop(self):
"""Pop is Canceled."""
toast('Canceled')
class AddbookDetailPopup(Popup): class AddbookDetailPopup(Popup):
"""AddbookDetailPopup pop is used for showing my address detail.""" """AddbookDetailPopup pop is used for showing my address detail."""
@ -1356,6 +1414,7 @@ class AddbookDetailPopup(Popup):
self.parent.children[1].ids.sc11.clear_widgets() self.parent.children[1].ids.sc11.clear_widgets()
self.parent.children[1].ids.sc11.add_widget(AddressBook()) self.parent.children[1].ids.sc11.add_widget(AddressBook())
self.dismiss() self.dismiss()
toast('Saved')
def send_message_to(self): def send_message_to(self):
"""Method used to fill to_address of composer autofield.""" """Method used to fill to_address of composer autofield."""
@ -1368,16 +1427,22 @@ class AddbookDetailPopup(Popup):
window_obj.scr_mngr.current = 'create' window_obj.scr_mngr.current = 'create'
self.dismiss() self.dismiss()
def close_pop(self):
"""Pop is Canceled."""
toast('Canceled')
class ShowQRCode(Screen): class ShowQRCode(Screen):
"""ShowQRCode Screen uses to show the detail of mails.""" """ShowQRCode Screen uses to show the detail of mails."""
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.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(
data=self.manager.get_parent_window().children[0].address)) data=self.manager.get_parent_window().children[0].address))
toast('Show QR code')
class Draft(Screen): class Draft(Screen):
@ -1473,6 +1538,7 @@ class Draft(Screen):
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)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
toast('Deleted')
def draft_msg(self, src_object): def draft_msg(self, src_object):
"""Method used for saving draft mails.""" """Method used for saving draft mails."""
@ -1519,6 +1585,7 @@ class Draft(Screen):
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()
src_object.ids.sc16.add_widget(Draft()) src_object.ids.sc16.add_widget(Draft())
toast('Save draft')
return return
@ -1534,4 +1601,7 @@ class CustomSpinner(Spinner):
def remove_search_bar(obj): def remove_search_bar(obj):
"""Remove search bar.""" """Remove search bar."""
try:
obj.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets() obj.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets()
except Exception as e:
obj.parent.parent.parent.parent.ids.search_bar.clear_widgets()

View File

@ -1,10 +1,10 @@
[app] [app]
# (str) Title of your application # (str) Title of your application
title = messageapp title = bitapp
# (str) Package name # (str) Package name
package.name = messageapp package.name = bitapp
# (str) Package domain (needed for android/ios packaging) # (str) Package domain (needed for android/ios packaging)
package.domain = org.test package.domain = org.test