kivy toolbar title updated with new ehancements

This commit is contained in:
surbhi 2019-07-17 14:20:27 +05:30
parent 92b0f45f2e
commit 4a695795da
No known key found for this signature in database
GPG Key ID: 88928762974D3618
5 changed files with 371 additions and 66 deletions

View File

@ -1,3 +1,4 @@
#:import Toolbar kivymd.toolbar.Toolbar #:import Toolbar kivymd.toolbar.Toolbar
#:import ThemeManager kivymd.theming.ThemeManager #:import ThemeManager kivymd.theming.ThemeManager
#:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer #:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer
@ -34,6 +35,7 @@
#:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem #:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem
#:import MDFloatingActionButton kivymd.button.MDFloatingActionButton #:import MDFloatingActionButton kivymd.button.MDFloatingActionButton
#:import Factory kivy.factory.Factory #:import Factory kivy.factory.Factory
#:import MDTextButton kivymd.button.MDTextButton
#:set color_button (0.784, 0.443, 0.216, 1) # brown #:set color_button (0.784, 0.443, 0.216, 1) # brown
#:set color_button_pressed (0.659, 0.522, 0.431, 1) # darker brown #:set color_button_pressed (0.659, 0.522, 0.431, 1) # darker brown
@ -67,6 +69,7 @@
values: app.variable_1 values: app.variable_1
on_text:app.getCurrentAccountData(self.text) on_text:app.getCurrentAccountData(self.text)
on_press: app.limit_spinner() on_press: app.limit_spinner()
ArrowImg:
NavigationDrawerIconButton: NavigationDrawerIconButton:
id: inbox_cnt id: inbox_cnt
icon: 'email-open' icon: 'email-open'
@ -80,10 +83,11 @@
on_release: app.root.ids.scr_mngr.current = 'sent' on_release: app.root.ids.scr_mngr.current = 'sent'
badge_text: app.mail_count(self.text) badge_text: app.mail_count(self.text)
NavigationDrawerIconButton: NavigationDrawerIconButton:
id: draft_cnt
icon: 'message-draw' icon: 'message-draw'
text: "Draft" text: "Draft"
on_release: app.root.ids.scr_mngr.current = 'inbox' on_release: app.root.ids.scr_mngr.current = 'draft'
badge_text: "99+" badge_text: app.mail_count(self.text)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Starred" text: "Starred"
icon:'star' icon:'star'
@ -147,6 +151,7 @@ NavigationLayout:
orientation: 'vertical' orientation: 'vertical'
Toolbar: Toolbar:
id: toolbar id: toolbar
title: app.current_address_label()
opacity: 1 if app.addressexist() else 0 opacity: 1 if app.addressexist() else 0
disabled: False if app.addressexist() else True disabled: False if app.addressexist() else True
md_bg_color: app.theme_cls.primary_color md_bg_color: app.theme_cls.primary_color
@ -197,6 +202,9 @@ NavigationLayout:
id:sc14 id:sc14
ShowQRCode: ShowQRCode:
id:sc15 id:sc15
Draft:
id:sc16
<Inbox>: <Inbox>:
name: 'inbox' name: 'inbox'
@ -225,9 +233,12 @@ NavigationLayout:
<Draft>: <Draft>:
name: 'draft' name: 'draft'
Label: ScrollView:
text:"I have a good dialox box" do_scroll_x: False
color: 0,0,0,1 MDList:
id: ml
ComposerButton:
<Test>: <Test>:
name: 'test' name: 'test'
Label: Label:
@ -258,8 +269,10 @@ NavigationLayout:
hint_text: 'type or select sender address' hint_text: 'type or select sender address'
size_hint_y: None size_hint_y: None
height: 100 height: 100
font_size: '13sp'
multiline: False multiline: False
required: True required: True
allow_copy: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
BoxLayout: BoxLayout:
@ -269,9 +282,13 @@ NavigationLayout:
background_color: app.theme_cls.primary_dark background_color: app.theme_cls.primary_dark
id: btn id: btn
values: app.variable_1 values: app.variable_1
on_text: ti.text = self.text on_text: ti.text = self.text if self.text != 'Select' else ''
option_cls: Factory.get("MySpinnerOption") option_cls: Factory.get("MySpinnerOption")
background_color: color_button if self.state == 'normal' else color_button_pressed
background_down: 'atlas://data/images/defaulttheme/spinner'
color: color_font
font_size: '12.5sp' font_size: '12.5sp'
ArrowImg:
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
@ -282,6 +299,7 @@ NavigationLayout:
MyTextInput: MyTextInput:
id: txt_input id: txt_input
size_hint_y: None size_hint_y: None
font_size: '13sp'
height: 100 height: 100
hint_text: 'type or search recipients address starting with BM-' hint_text: 'type or search recipients address starting with BM-'
RV: RV:
@ -291,6 +309,7 @@ NavigationLayout:
hint_text: 'subject' hint_text: 'subject'
required: True required: True
height: 100 height: 100
font_size: '13sp'
size_hint_y: None size_hint_y: None
multiline: False multiline: False
helper_text_mode: "on_error" helper_text_mode: "on_error"
@ -300,6 +319,7 @@ NavigationLayout:
multiline: True multiline: True
hint_text: 'body' hint_text: 'body'
size_hint_y: None size_hint_y: None
font_size: '13sp'
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
BoxLayout: BoxLayout:
@ -308,14 +328,24 @@ NavigationLayout:
MDRaisedButton: MDRaisedButton:
size_hint: 1, None size_hint: 1, None
height: dp(40) height: dp(40)
text: 'send'
on_press: root.send() on_press: root.send()
MDLabel:
font_style: 'Title'
text: 'send'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: 1, None size_hint: 1, None
height: dp(40) height: dp(40)
text: 'reset'
on_press: app.root.ids.scr_mngr.current = 'random' on_press: app.root.ids.scr_mngr.current = 'random'
MDLabel:
font_style: 'Title'
text: 'reset'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<MyTextInput>: <MyTextInput>:
readonly: False readonly: False
@ -357,7 +387,8 @@ NavigationLayout:
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
size_hint_y: None size_hint_y: None
height: dp(700) height: dp(750)
padding: dp(10)
BoxLayout: BoxLayout:
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
@ -404,9 +435,15 @@ NavigationLayout:
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .5 size_hint: .5, .35
text: 'proceed' height: dp(40)
on_press: app.root.ids.scr_mngr.current = 'random' on_press: app.root.ids.scr_mngr.current = 'random'
MDLabel:
font_style: 'Title'
text: 'proceed'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<Random>: <Random>:
name: 'random' name: 'random'
@ -415,8 +452,8 @@ NavigationLayout:
orientation: 'vertical' orientation: 'vertical'
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
padding: dp(48) padding: dp(20)
spacing: 200 spacing: 100
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -439,13 +476,19 @@ NavigationLayout:
hint_text: "Label" hint_text: "Label"
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
BoxLayout:
AnchorLayout:
MDRaisedButton: MDRaisedButton:
text: 'next' size_hint: .5, None
size_hint_y: 0.13 height: dp(40)
size_hint_x: 0.8
pos_hint: {'x': .1, 'y': 0.3}
opposite_colors: True
on_release: root.generateaddress() on_release: root.generateaddress()
opposite_colors: True
MDLabel:
font_style: 'Title'
text: 'next'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<AddressSuccessful>: <AddressSuccessful>:
name: 'add_sucess' name: 'add_sucess'
@ -466,25 +509,40 @@ NavigationLayout:
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .6, .55
height: dp(40)
MDLabel:
font_style: 'Title'
text: 'Server' text: 'Server'
on_press: app.root.ids.scr_mngr.current = 'random' font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "DATA SETTINGS" text: "DATA SETTINGS"
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .6, .55
height: dp(40)
MDLabel:
font_style: 'Title'
text: 'Import or export data' text: 'Import or export data'
on_press: app.root.ids.scr_mngr.current = 'random' font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "OTHER SETTINGS" text: "OTHER SETTINGS"
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .6, .55
height: dp(40)
MDLabel:
font_style: 'Title'
text: 'Restart background service' text: 'Restart background service'
on_press: app.root.ids.scr_mngr.current = 'random' font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDLabel: MDLabel:
@ -549,7 +607,7 @@ NavigationLayout:
orientation: 'vertical' orientation: 'vertical'
MDTextField: MDTextField:
id: label id: label
multiline: True multiline: False
hint_text: "Label" hint_text: "Label"
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
@ -612,8 +670,14 @@ NavigationLayout:
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .5 size_hint: .6, .35
height: dp(40)
MDLabel:
font_style: 'Title'
text: root.text_variable_1 text: root.text_variable_1
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
MDTab: MDTab:
name: 'processes' name: 'processes'
text: 'Processes' text: 'Processes'
@ -628,30 +692,53 @@ NavigationLayout:
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .7, .6
height: dp(40)
MDLabel:
font_style: 'Title'
text: root.text_variable_2 text: root.text_variable_2
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "Brodcast" text: "Brodcast"
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .7, .6
height: dp(40)
MDLabel:
font_style: 'Title'
text: root.text_variable_3 text: root.text_variable_3
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "publickeys" text: "publickeys"
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .7, .6
height: dp(40)
MDLabel:
font_style: 'Title'
text: root.text_variable_4 text: root.text_variable_4
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "objects" text: "objects"
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
size_hint: .8, .6 size_hint: .7, .6
height: dp(40)
MDLabel:
font_style: 'Title'
text: root.text_variable_5 text: root.text_variable_5
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<MailDetail>: <MailDetail>:
name: 'mailDetail' name: 'mailDetail'
@ -689,17 +776,27 @@ NavigationLayout:
halign: 'left' halign: 'left'
bold: True bold: True
BoxLayout: BoxLayout:
spacing:50 spacing:20
MDRaisedButton: MDRaisedButton:
size_hint: 1, None size_hint: 1, None
height: dp(40) height: dp(40)
text: 'Reply' if root.page_type == 'inbox' else 'Copy'
on_press: root.inbox_reply() if root.page_type == 'inbox' else root.copy_sent_mail() on_press: root.inbox_reply() if root.page_type == 'inbox' else root.copy_sent_mail()
MDLabel:
font_style: 'Title'
text: 'Reply' if root.page_type == 'inbox' else 'Copy'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
MDRaisedButton: MDRaisedButton:
size_hint: 1, None size_hint: 1, None
height: dp(40) height: dp(40)
text: 'Delete'
on_press: root.delete_mail() on_press: root.delete_mail()
MDLabel:
font_style: 'Title'
text: 'Delete'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<ComposerButton@BoxLayout>: <ComposerButton@BoxLayout>:
size_hint_y: None size_hint_y: None
@ -715,7 +812,7 @@ NavigationLayout:
elevation_normal: 8 elevation_normal: 8
md_bg_color: [0.941, 0, 0,1] md_bg_color: [0.941, 0, 0,1]
on_press: app.root.ids.scr_mngr.current = 'create' on_press: app.root.ids.scr_mngr.current = 'create'
on_release: app.clear_composer() on_press: app.clear_composer()
<MyaddDetailPopup>: <MyaddDetailPopup>:
id: myadd_popup id: myadd_popup
@ -872,3 +969,10 @@ NavigationLayout:
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
id: qr id: qr
<ArrowImg@Image>:
source: './images/down-arrow.png' if self.parent.is_open == True else './images/right-arrow.png'
size: 15, 15
x: self.parent.x + self.parent.width - self.width - 5
y: self.parent.y + self.parent.height/2 - self.height + 5

View File

@ -47,7 +47,6 @@ import kivy_helper_search
from kivy.core.window import Window from kivy.core.window import Window
from functools import partial from functools import partial
from kivy.uix.carousel import Carousel from kivy.uix.carousel import Carousel
from kivy.garden.qrcode import QRCodeWidget
from kivy.utils import platform from kivy.utils import platform
@ -101,7 +100,8 @@ class Inbox(Screen):
carousel.data_index = 0 carousel.data_index = 0
carousel.min_move = 0.2 carousel.min_move = 0.2
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_color = (1, 0, 0, .5) del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1)
del_btn.bind(on_press=partial(self.delete, item['receivedTime'])) del_btn.bind(on_press=partial(self.delete, item['receivedTime']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
@ -135,8 +135,13 @@ class Inbox(Screen):
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete inbox mail from inbox listing""" """Delete inbox mail from inbox listing"""
state.navigation_drawer_obj = self.parent.parent.parent.parent.children[2].children[0].children[0].children[0].children
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(data_index)) sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(data_index))
msg_count_objs = self.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)
msg_count_objs.trash_cnt.badge_text = str(int(state.trash_count) + 1)
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) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
@ -208,7 +213,22 @@ class AddressBook(Screen):
meny = TwoLineAvatarIconListItem(text=item[0], secondary_text=item[1], theme_text_color='Custom',text_color=NavigateApp().theme_cls.primary_color) meny = TwoLineAvatarIconListItem(text=item[0], secondary_text=item[1], theme_text_color='Custom',text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item[0][0].upper()))) meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item[0][0].upper())))
meny.bind(on_press = partial(self.addBook_detail, item[1], item[0])) meny.bind(on_press = partial(self.addBook_detail, item[1], item[0]))
self.ids.ml.add_widget(meny) # self.ids.ml.add_widget(meny)
carousel = Carousel(direction='right')
if platform == 'android':
carousel.height = 140
carousel.size_hint_y = None
carousel.ignore_perpendicular_swipes = True
carousel.data_index = 0
carousel.min_move = 0.2
del_btn = Button(text='Delete')
del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1)
del_btn.bind(on_press=partial(self.delete_address, item[1]))
carousel.add_widget(del_btn)
carousel.add_widget(meny)
carousel.index=1
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',
@ -228,6 +248,12 @@ class AddressBook(Screen):
p.open() p.open()
p.set_addbook_data(address, label) p.set_addbook_data(address, label)
def delete_address(self, address, instance, *args):
"""Delete inbox mail from inbox listing"""
self.ids.ml.remove_widget(instance.parent.parent)
sqlExecute("DELETE FROM addressbook WHERE address = '{}';".format(address))
class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior, class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior,
RecycleBoxLayout): RecycleBoxLayout):
''' Adds selection and focus behaviour to the view. ''' ''' Adds selection and focus behaviour to the view. '''
@ -491,7 +517,6 @@ class Sent(Screen):
xAddress = 'fromaddress' xAddress = 'fromaddress'
queryreturn = kivy_helper_search.search_sql( queryreturn = kivy_helper_search.search_sql(
xAddress, account, "sent", where, what, False) xAddress, account, "sent", where, what, False)
state.totalSentMail = len(queryreturn)
if state.msg_counter_objs and state.association == state.check_sent_acc: if state.msg_counter_objs and state.association == state.check_sent_acc:
state.msg_counter_objs.send_cnt.badge_text = str(len(queryreturn)) state.msg_counter_objs.send_cnt.badge_text = str(len(queryreturn))
state.sent_count = str(int(state.sent_count) + 1) state.sent_count = str(int(state.sent_count) + 1)
@ -513,7 +538,8 @@ class Sent(Screen):
carousel.data_index = 0 carousel.data_index = 0
carousel.min_move = 0.2 carousel.min_move = 0.2
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_color = (1, 0, 0, .5) del_btn.background_normal = ''
del_btn.background_color = (1.0, 0.0, 0.0, 1.0)
del_btn.bind(on_press=partial(self.delete, item['lastactiontime'])) del_btn.bind(on_press=partial(self.delete, item['lastactiontime']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
@ -628,9 +654,9 @@ class NavigateApp(App):
obj_1 = ObjectProperty() obj_1 = ObjectProperty()
variable_1 = ListProperty(BMConfigParser().addresses()) variable_1 = ListProperty(BMConfigParser().addresses())
nav_drawer = ObjectProperty() nav_drawer = ObjectProperty()
total_sentmail = str(state.totalSentMail)
state.screen_density = Window.size state.screen_density = Window.size
title = "PyBitmessage" title = "PyBitmessage"
imgstatus = False
count = 0 count = 0
menu_items = [ menu_items = [
{'viewclass': 'MDMenuItem', {'viewclass': 'MDMenuItem',
@ -692,24 +718,30 @@ class NavigateApp(App):
def getCurrentAccountData(self, text): def getCurrentAccountData(self, text):
"""Get Current Address Account Data.""" """Get Current Address Account Data."""
address_label = self.current_address_label(BMConfigParser().get(text, 'label'))
self.root_window.children[1].ids.toolbar.title = address_label
state.association = text state.association = text
self.root.ids.sc1.clear_widgets() self.root.ids.sc1.clear_widgets()
self.root.ids.sc4.clear_widgets() self.root.ids.sc4.clear_widgets()
self.root.ids.sc5.clear_widgets() self.root.ids.sc5.clear_widgets()
self.root.ids.sc16.clear_widgets()
self.root.ids.sc1.add_widget(Inbox()) self.root.ids.sc1.add_widget(Inbox())
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.add_widget(Sent())
self.root.ids.sc5.add_widget(Trash()) self.root.ids.sc5.add_widget(Trash())
self.root.ids.sc16.add_widget(Draft())
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
msg_counter_objs = self.root_window.children[1].children[2].children[0].ids msg_counter_objs = self.root_window.children[1].children[2].children[0].ids
state.sent_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'sent' ;".format(state.association))[0][0]) state.sent_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'sent' ;".format(state.association))[0][0])
state.inbox_count = str(sqlQuery("SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and folder = 'inbox' ;".format(state.association))[0][0]) state.inbox_count = str(sqlQuery("SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' 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 folder = 'trash') AS SumCount".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 folder = 'trash') AS SumCount".format(state.association))[0][0])
state.draft_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'draft' ;".format(state.association))[0][0])
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
msg_counter_objs.trash_cnt.badge_text = state.trash_count msg_counter_objs.trash_cnt.badge_text = state.trash_count
msg_counter_objs.draft_cnt.badge_text = state.draft_count
def getInboxMessageDetail(self, instance): def getInboxMessageDetail(self, instance):
@ -748,18 +780,34 @@ class NavigateApp(App):
spinner_obj.dropdown_cls.max_height = spinner_obj.height* max + max * 4 spinner_obj.dropdown_cls.max_height = spinner_obj.height* max + max * 4
def on_key(self, window, key, *args): def on_key(self, window, key, *args):
"""This method is used for going on previous screen"""
if key == 27: # the esc key if key == 27: # the esc key
if self.root.ids.scr_mngr.current_screen.name == "mailDetail": if self.root.ids.scr_mngr.current == "mailDetail":
self.root.ids.scr_mngr.current = 'sent' self.root.ids.scr_mngr.current = 'sent' if state.detailPageType == 'sent' else 'inbox'
# this is for direction of the screen comesup # this is for direction of the screen comesup
# self.root.ids.scr_mngr.transition.direction = 'right' elif self.root.ids.scr_mngr.current == "create":
return True composer_objs = self.root
elif self.root.ids.scr_mngr.current_screen.name == "create": from_addr = str(self.root.children[1].children[0].children[0].children[0].children[0].ids.ti.text)
to_addr = str(self.root.children[1].children[0].children[0].children[0].children[0].ids.txt_input.text)
if from_addr and to_addr:
Draft().draft_msg(composer_objs)
# self.root.ids.scr_mngr.current
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
return True elif self.root.ids.scr_mngr.current == "showqrcode":
self.root.ids.scr_mngr.current = 'myaddress'
elif self.root.ids.scr_mngr.current == "random":
self.root.ids.scr_mngr.current = 'login'
else: else:
self.root.ids.scr_mngr.current = 'inbox'
self.root.ids.scr_mngr.transition.direction = 'right'
self.root.ids.scr_mngr.transition.bind(on_complete=self.restart)
return True return True
def restart(self, *args):
"""this method is used to set transition direction"""
self.root.ids.scr_mngr.transition.direction = 'left'
self.root.ids.scr_mngr.transition.unbind(on_complete=self.restart)
def status_dispatching(self, data): def status_dispatching(self, data):
ackData, message = data ackData, message = data
if state.ackdata == ackData: if state.ackdata == ackData:
@ -769,7 +817,7 @@ class NavigateApp(App):
"""if slow down the nwe will make new composer edit screen""" """if slow down the nwe will make new composer edit screen"""
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 = '' composer_obj.btn.text = 'Select'
composer_obj.txt_input.text = '' composer_obj.txt_input.text = ''
composer_obj.subject.text = '' composer_obj.subject.text = ''
@ -792,6 +840,19 @@ class NavigateApp(App):
elif text == 'Trash': elif text == 'Trash':
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(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 folder = 'trash') AS SumCount".format(state.association))[0][0])
return state.trash_count return state.trash_count
elif text == 'Draft':
state.draft_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{1}' and folder = '{0}' ;".format(text.lower(), state.association))[0][0])
return state.draft_count
def current_address_label(self, current_address = None):
if BMConfigParser().addresses() or current_address:
if current_address:
first_name = current_address
else:
first_name = BMConfigParser().get(BMConfigParser().addresses()[0], 'label')
f_name = first_name.split()
return f_name[0][:14]+ '...' if len(f_name[0])>15 else f_name[0]
return ''
class GrashofPopup(Popup): class GrashofPopup(Popup):
@ -805,6 +866,15 @@ class GrashofPopup(Popup):
self.size_hint_x = 0.7 self.size_hint_x = 0.7
def savecontact(self): def savecontact(self):
my_addresses = self.parent.children[1].children[2].children[0].ids.btn.values
entered_text = str(self.ids.label.text)
if entered_text in my_addresses:
self.ids.label.focus = True
self.ids.label.helper_text = 'Please Enter corrent address'
elif entered_text == '':
self.ids.label.focus = True
self.ids.label.helper_text = 'This field is required'
label = self.ids.label.text label = self.ids.label.text
address = self.ids.address.text address = self.ids.address.text
if label and address: if label and address:
@ -904,16 +974,23 @@ class MailDetail(Screen):
self.status = data[0][4] self.status = data[0][4]
def delete_mail(self): def delete_mail(self):
msg_count_objs =self.parent.parent.parent.parent.parent.children[2].children[0].ids
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
sqlExecute("UPDATE sent SET folder = 'trash' WHERE lastactiontime = {};".format(state.sentMailTime)) sqlExecute("UPDATE sent SET folder = 'trash' WHERE lastactiontime = {};".format(state.sentMailTime))
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1)
self.parent.parent.screens[3].clear_widgets() self.parent.parent.screens[3].clear_widgets()
self.parent.parent.screens[3].add_widget(Sent()) self.parent.parent.screens[3].add_widget(Sent())
self.parent.parent.current = 'sent' self.parent.parent.current = 'sent'
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(state.sentMailTime)) sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(state.sentMailTime))
msg_count_objs.inbox_cnt.badge_text = str(int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1)
self.parent.parent.screens[0].clear_widgets() self.parent.parent.screens[0].clear_widgets()
self.parent.parent.screens[0].add_widget(Inbox()) self.parent.parent.screens[0].add_widget(Inbox())
self.parent.parent.current = 'inbox' self.parent.parent.current = 'inbox'
msg_count_objs.trash_cnt.badge_text = 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())
@ -1006,4 +1083,128 @@ class ShowQRCode(Screen):
def qrdisplay(self): def qrdisplay(self):
self.ids.qr.clear_widgets() self.ids.qr.clear_widgets()
if platform == 'android':
from kivy.garden.qrcode import QRCodeWidget
self.ids.qr.add_widget(QRCodeWidget(data=self.manager.get_parent_window().children[0].address)) self.ids.qr.add_widget(QRCodeWidget(data=self.manager.get_parent_window().children[0].address))
class Draft(Screen):
"""Draft screen is used to show the list of draft messages."""
data = ListProperty()
def __init__(self, *args, **kwargs):
super(Draft, self).__init__(*args, **kwargs)
if state.association == '':
if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0]
Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0):
"""Clock Schdule for method draft accounts."""
self.sentaccounts()
print(dt)
def sentaccounts(self):
"""Load draft accounts."""
account = state.association
self.loadSent(account, 'All', '')
def loadSent(self, account, where="", what=""):
"""Load draft list for Draft messages."""
xAddress = 'fromaddress'
queryreturn = kivy_helper_search.search_sql(
xAddress, account, "draft", where, what, False)
if state.msg_counter_objs:
state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn))
if queryreturn:
for mail in queryreturn:
third_text = mail[3].replace('\n', ' ')
self.data.append({'text': mail[1].strip(), 'secondary_text': mail[2][:10] + '...........' if len(mail[2]) > 10 else mail[2] + '\n' + " " + (third_text[:25] + '...!') if len(third_text) > 25 else third_text, 'lastactiontime': mail[6]})
for item in self.data:
meny = TwoLineAvatarIconListItem(text='Draft', secondary_text=item['text'], theme_text_color= 'Custom',text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(source='./images/avatar.png'))
# wimg = Image(source='/home/cis/transparent1.png', size= (10, 10))
# meny.bind(on_press = partial(self.sent_detail, item['lastactiontime']))
carousel = Carousel(direction='right')
# carousel = MDCardPost(text_post='Card with text',swipe=True, callback=callback)
if platform == 'android':
carousel.height = 150
carousel.size_hint_y = None
carousel.ignore_perpendicular_swipes = True
carousel.data_index = 0
carousel.min_move = 0.2
del_btn = Button(text='Delete')
del_btn.background_normal = ''
del_btn.background_color = (1.0, 0.0, 0.0, 1.0)
del_btn.bind(on_press=partial(self.delete_draft, item['lastactiontime']))
carousel.add_widget(del_btn)
carousel.add_widget(meny)
carousel.index=1
self.ids.ml.add_widget(carousel)
else:
content = MDLabel(font_style='Body1',
theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!",
halign='center',
bold=True,
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content)
def delete_draft(self, data_index, instance, *args):
"""This method is used to delete draft message permanently"""
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(data_index))
try:
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.draft_count) > 0:
msg_count_objs.draft_cnt.badge_text = str(int(state.draft_count) - 1)
state.draft_count = str(int(state.draft_count) - 1)
self.ids.ml.remove_widget(instance.parent.parent)
def draft_msg(self, src_object):
"""This method is used for saving draft mails"""
composer_object = src_object.children[1].children[0].children[0].children[0].children[0].ids
fromAddress = str(composer_object.ti.text)
toAddress = str(composer_object.txt_input.text)
subject = str(composer_object.subject.text)
message = str(composer_object.body.text)
encoding = 3
sendMessageToPeople = True
if sendMessageToPeople:
from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
from addresses import *
toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red'
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload
ackdata = genAckPayload(streamNumber, stealthLevel)
t = ()
sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'',
toAddress,
ripe,
fromAddress,
subject,
message,
ackdata,
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'draft',
encoding,
BMConfigParser().getint('bitmessagesettings', 'ttl'))
state.msg_counter_objs = src_object.children[2].children[0].ids
state.draft_count = str(int(state.draft_count) + 1)
src_object.ids.sc16.clear_widgets()
src_object.ids.sc16.add_widget(Draft())
return

BIN
src/images/down-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/images/right-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -74,8 +74,6 @@ kivyapp = None
navinstance = None navinstance = None
totalSentMail = 0
sentMailTime = 0 sentMailTime = 0
myAddressObj = None myAddressObj = None
@ -97,3 +95,5 @@ sent_count = 0
inbox_count = 0 inbox_count = 0
trash_count = 0 trash_count = 0
draft_count = 0