From f5d0b3dd59ba69744ec8b3970aaf39d494cfa4e9 Mon Sep 17 00:00:00 2001 From: cis Date: Thu, 8 Aug 2019 21:50:58 +0530 Subject: [PATCH 1/2] worked on implementing search for myaddress and fixed issues --- src/bitmessagekivy/mpybit.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 53f37dbb..dfc600a2 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -222,8 +222,13 @@ class MyAddress(Screen): def init_ui(self, dt=0): """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 + data = [] - for address in state.kivyapp.variable_1: + for address in addresses_list: data.append({ 'text': BMConfigParser().get(address, 'label'), 'secondary_text': address}) @@ -253,6 +258,7 @@ class MyAddress(Screen): valign='top') self.ids.ml.add_widget(content) try: + self.manager.parent.parent.parent.ids.search_bar.clear_widgets() self.manager.current = 'login' except Exception as e: pass @@ -280,6 +286,13 @@ class MyAddress(Screen): Clock.schedule_once(refresh_callback, 1) + def filter_address(self, address): + '''This method will filter the my address list data''' + # if (state.searcing_text).lower() in BMConfigParser().get(address, 'label') or (state.searcing_text).lower() in address: + if filter(lambda x: (state.searcing_text).lower() in x, [BMConfigParser().get(address, 'label').lower(), address.lower()]): + return True + return False + class AddressBook(Screen): """AddressBook Screen uses screen to show widgets of screens.""" @@ -471,7 +484,7 @@ class DropDownWidget(BoxLayout): self.ids.ti.text = '' self.ids.subject.text = '' self.ids.txt_input.text = '' - self.parent.parent.current = 'sent' + self.parent.parent.current = 'inbox' self.ids.btn.text = 'select' self.ids.ti.text = '' @@ -944,11 +957,11 @@ class NavigateApp(App): folder = 'sent' ;".format(state.association))[0][0]) state.inbox_count = str( sqlQuery( - "SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and \ + "SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and \ folder = 'inbox' ;".format(state.association))[0][0]) state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \ 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]) state.draft_count = str( sqlQuery( @@ -1061,7 +1074,7 @@ class NavigateApp(App): return state.sent_count elif text == 'Inbox': state.inbox_count = str(sqlQuery( - "SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \ + "SELECT COUNT(*) FROM {0} WHERE toaddress = '{1}' and \ folder = '{0}' ;".format( text.lower(), state.association))[0][0]) return state.inbox_count @@ -1069,7 +1082,7 @@ class NavigateApp(App): state.trash_count = str(sqlQuery( "SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' \ 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]) return state.trash_count elif text == 'Draft': @@ -1101,6 +1114,9 @@ class NavigateApp(App): elif state.search_screen == 'addressbook': self.root.ids.sc11.clear_widgets() 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: self.root.ids.sc4.clear_widgets() self.root.ids.sc4.add_widget(Sent()) @@ -1108,7 +1124,7 @@ class NavigateApp(App): def check_search_screen(self, instance): """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: self.root.ids.search_bar.add_widget( MDIconButton(icon='magnify')) From 8758c4fc9be0f8cdf0af77137f2cf961ead257c0 Mon Sep 17 00:00:00 2001 From: Navjot Date: Tue, 13 Aug 2019 12:58:15 +0530 Subject: [PATCH 2/2] wokred on implementing toast functionality and fixed issues --- src/bitmessagekivy/main.kv | 7 ++-- src/bitmessagekivy/mpybit.py | 68 +++++++++++++++++++++++++++--------- src/buildozer.spec | 6 ++-- 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index 4b72022b..1188ecb4 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -197,7 +197,7 @@ NavigationLayout: MDTextField: id: search_field - hint_text: 'Search icon' + hint_text: 'Search' on_text: app.searchQuery(self) ScreenManager: id: scr_mngr @@ -369,7 +369,7 @@ NavigationLayout: MDRaisedButton: size_hint: 1, None height: dp(40) - on_press: app.root.ids.scr_mngr.current = 'random' + on_press: root.reset_composer() MDLabel: font_style: 'Title' text: 'reset' @@ -667,6 +667,7 @@ NavigationLayout: size_hint: 1.5, None height: dp(40) on_press: root.dismiss() + on_press: root.close_pop() MDLabel: font_style: 'Title' text: 'Cancel' @@ -914,6 +915,7 @@ NavigationLayout: size_hint: 1.5, None height: dp(40) on_press: root.dismiss() + on_press: root.close_pop() MDLabel: font_style: 'Title' text: 'Cancel' @@ -990,6 +992,7 @@ NavigationLayout: size_hint: 1.5, None height: dp(40) on_press: root.dismiss() + on_press: root.close_pop() MDLabel: font_style: 'Title' text: 'Cancel' diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index dfc600a2..319f3260 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -48,6 +48,12 @@ from kivy.uix.spinner import Spinner from kivymd.textfields import MDTextField +def toast(text): + if platform == 'linux': + from kivymd.toast.kivytoast import toast + toast(text) + return + class Navigatorss(MDNavigationDrawer): """Navigators class contains image, title and logo.""" @@ -139,7 +145,7 @@ class Inbox(Screen): content = MDLabel( font_style='Body1', 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', bold=True, size_hint_y=None, @@ -166,7 +172,7 @@ class Inbox(Screen): "UPDATE inbox SET folder = 'trash' WHERE received = {};".format( data_index)) 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: msg_count_objs.inbox_cnt.badge_text = str( int(state.inbox_count) - 1) @@ -175,6 +181,7 @@ class Inbox(Screen): state.inbox_count = str(int(state.inbox_count) - 1) state.trash_count = str(int(state.trash_count) + 1) self.ids.ml.remove_widget(instance.parent.parent) + toast('Deleted') self.update_trash() def archive(self, data_index, instance, *args): @@ -221,12 +228,11 @@ class MyAddress(Screen): def init_ui(self, dt=0): """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 - + 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 = [] for address in addresses_list: data.append({ @@ -251,7 +257,7 @@ class MyAddress(Screen): content = MDLabel( font_style='Body1', 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', bold=True, size_hint_y=None, @@ -349,7 +355,7 @@ class AddressBook(Screen): else: content = MDLabel(font_style='Body1', theme_text_color='Primary', - text="No Contact Found yet...... ", + text="No contact found!" if state.searcing_text else "No contact found yet...... ", halign='center', bold=True, size_hint_y=None, @@ -487,7 +493,7 @@ class DropDownWidget(BoxLayout): self.parent.parent.current = 'inbox' self.ids.btn.text = 'select' self.ids.ti.text = '' - + toast('send') return None else: msg = 'Enter a valid recipients address' @@ -523,6 +529,13 @@ class DropDownWidget(BoxLayout): self.but.bind(on_press=self.main_pop.dismiss) self.main_pop.open() + def reset_composer(self): + 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): """Takes the text input in the field.""" @@ -642,6 +655,7 @@ class Random(Screen): 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.add_widget(MyAddress()) + toast('New address created') class AddressSuccessful(Screen): @@ -738,7 +752,7 @@ class Sent(Screen): content = MDLabel( font_style='Body1', 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', bold=True, size_hint_y=None, @@ -777,6 +791,7 @@ class Sent(Screen): "UPDATE sent SET folder = 'trash' \ WHERE lastactiontime = {};".format(data_index)) self.ids.ml.remove_widget(instance.parent.parent) + toast('Deleted') self.update_trash() def archive(self, data_index, instance, *args): @@ -1048,6 +1063,8 @@ class NavigateApp(App): def clear_composer(self): """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() composer_obj = self.root.ids.sc3.children[0].ids composer_obj.ti.text = '' @@ -1129,7 +1146,7 @@ class NavigateApp(App): self.root.ids.search_bar.add_widget( MDIconButton(icon='magnify')) text_field = MDTextField( - id='search_field', hint_text='Search icon') + id='search_field', hint_text='Search') text_field.bind(text=self.searchQuery) self.root.ids.search_bar.add_widget(text_field) self.root.ids.search_bar.children[0].text = '' @@ -1143,7 +1160,7 @@ class NavigateApp(App): 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 icon') + id='search_field', hint_text='Search') text_field.bind(text=self.searchQuery) self.root.ids.search_bar.add_widget(text_field) @@ -1175,12 +1192,14 @@ class GrashofPopup(Popup): label = self.ids.label.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] queues.UISignalQueue.put(('rerenderAddressBook', '')) self.dismiss() sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address) self.parent.children[1].ids.scr_mngr.current = 'addressbook' + toast('Saved') def show_error_message(self): """Showing error message.""" @@ -1201,6 +1220,8 @@ class GrashofPopup(Popup): action=lambda *x: self.dialog.dismiss()) self.dialog.open() + def close_pop(self): + toast('Canceled') class AvatarSampleWidget(ILeftBody, Image): """Avatar Sample Widget.""" @@ -1314,6 +1335,7 @@ class MailDetail(Screen): state.trash_count = str(int(state.trash_count) + 1) self.parent.parent.screens[4].clear_widgets() self.parent.parent.screens[4].add_widget(Trash()) + toast('Deleted') def inbox_reply(self): """Method used for replying inbox messages.""" @@ -1364,6 +1386,9 @@ class MyaddDetailPopup(Popup): window_obj.scr_mngr.current = 'create' self.dismiss() + def close_pop(self): + toast('Canceled') + class AddbookDetailPopup(Popup): """AddbookDetailPopup pop is used for showing my address detail.""" @@ -1394,6 +1419,7 @@ class AddbookDetailPopup(Popup): self.parent.children[1].ids.sc11.clear_widgets() self.parent.children[1].ids.sc11.add_widget(AddressBook()) self.dismiss() + toast('Saved') def send_message_to(self): """Method used to fill to_address of composer autofield.""" @@ -1406,16 +1432,21 @@ class AddbookDetailPopup(Popup): window_obj.scr_mngr.current = 'create' self.dismiss() + def close_pop(self): + toast('Canceled') + class ShowQRCode(Screen): """ShowQRCode Screen uses to show the detail of mails.""" def qrdisplay(self): """Method used for showing QR Code.""" + self.manager.parent.parent.parent.ids.search_bar.clear_widgets() self.ids.qr.clear_widgets() from kivy.garden.qrcode import QRCodeWidget self.ids.qr.add_widget(QRCodeWidget( data=self.manager.get_parent_window().children[0].address)) + toast('Show QR code') class Draft(Screen): @@ -1511,6 +1542,7 @@ class Draft(Screen): int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1) self.ids.ml.remove_widget(instance.parent.parent) + toast('Deleted') def draft_msg(self, src_object): """Method used for saving draft mails.""" @@ -1557,6 +1589,7 @@ class Draft(Screen): state.draft_count = str(int(state.draft_count) + 1) src_object.ids.sc16.clear_widgets() src_object.ids.sc16.add_widget(Draft()) + toast('Save draft') return @@ -1572,4 +1605,7 @@ class CustomSpinner(Spinner): def remove_search_bar(self): """Remove search bar.""" - self.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets() + try: + self.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets() + except Exception as e: + self.parent.parent.parent.parent.ids.search_bar.clear_widgets() diff --git a/src/buildozer.spec b/src/buildozer.spec index f6fdacde..82858554 100644 --- a/src/buildozer.spec +++ b/src/buildozer.spec @@ -1,10 +1,10 @@ [app] # (str) Title of your application -title = messageapp +title = bitapp # (str) Package name -package.name = messageapp +package.name = bitapp # (str) Package domain (needed for android/ios packaging) package.domain = org.test @@ -284,4 +284,4 @@ warn_on_root = 1 # # Then, invoke the command line with the "demo" profile: # -#buildozer --profile demo android debug \ No newline at end of file +#buildozer --profile demo android debug