Merge pull request #31 from jaicis/kivyfixes

worked on implementing new featurs
This commit is contained in:
navjotcis 2020-01-18 21:55:49 +05:30 committed by GitHub
commit 6f6a02dbee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 203 additions and 108 deletions

View File

@ -12,7 +12,7 @@ from kivy.uix.image import Image as kiImage
# constants # constants
RESOLUTION = 128, 128 RESOLUTION = 300, 300
V_RESOLUTION = 7, 7 V_RESOLUTION = 7, 7
BACKGROUND_COLOR = 255, 255, 255, 255 BACKGROUND_COLOR = 255, 255, 255, 255
MODE = "RGB" MODE = "RGB"

View File

@ -1,12 +1,5 @@
<Allmails>: <Allmails>:
name: 'allmails' name: 'allmails'
#FloatLayout:
# MDScrollViewRefreshLayout:
# id: refresh_layout
# refresh_callback: root.refresh_callback
# root_layout: root.set_root_layout()
# MDList:
# id: ml
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
spacing: dp(5) spacing: dp(5)

View File

@ -16,6 +16,9 @@
id: search_field id: search_field
hint_text: 'Search' hint_text: 'Search'
on_text: app.searchQuery(self) on_text: app.searchQuery(self)
canvas.before:
Color:
rgba: (0,0,0,1)
<Loader@MDSpinner>: <Loader@MDSpinner>:
id: spinner id: spinner

View File

@ -8,7 +8,7 @@
spacing: 15 spacing: 15
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
MDTextField: MyMDTextField:
id: ti id: ti
hint_text: 'type or select sender address' hint_text: 'type or select sender address'
size_hint_y: None size_hint_y: None
@ -21,7 +21,7 @@
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
height: dp(40) height: dp(40)
Spinner: CustomSpinner:
id: btn id: btn
background_color: app.theme_cls.primary_dark background_color: app.theme_cls.primary_dark
values: app.variable_1 values: app.variable_1
@ -46,7 +46,7 @@
hint_text: 'type, select or scan QR code for recipients address' hint_text: 'type, select or scan QR code for recipients address'
RV: RV:
id: rv id: rv
MDTextField: MyMDTextField:
id: subject id: subject
hint_text: 'subject' hint_text: 'subject'
required: True required: True
@ -56,7 +56,7 @@
multiline: False multiline: False
helper_text_mode: "on_error" helper_text_mode: "on_error"
MDTextField: MyMDTextField:
id: body id: body
multiline: True multiline: True
hint_text: 'body' hint_text: 'body'
@ -99,3 +99,9 @@
height: self.minimum_height height: self.minimum_height
orientation: 'vertical' orientation: 'vertical'
multiselect: False multiselect: False
<MyMDTextField@MDTextField>:
canvas.before:
Color:
rgba: (0,0,0,1)

View File

@ -89,6 +89,9 @@
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
on_text: root.add_validation(self) on_text: root.add_validation(self)
canvas.before:
Color:
rgba: (0,0,0,1)
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:

View File

@ -37,12 +37,18 @@
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
on_text: root.checkLabel_valid(self) on_text: root.checkLabel_valid(self)
canvas.before:
Color:
rgba: (0,0,0,1)
MDTextField: MDTextField:
id: address id: address
hint_text: "Address" hint_text: "Address"
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
on_text: root.checkAddress_valid(self) on_text: root.checkAddress_valid(self)
canvas.before:
Color:
rgba: (0,0,0,1)
BoxLayout: BoxLayout:
spacing:5 spacing:5
orientation: 'horizontal' orientation: 'horizontal'
@ -112,6 +118,9 @@
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"
on_text: root.checkLabel_valid(self) on_text: root.checkLabel_valid(self)
canvas.before:
Color:
rgba: (0,0,0,1)
MDLabel: MDLabel:
font_style: 'Subtitle2' font_style: 'Subtitle2'
theme_text_color: 'Primary' theme_text_color: 'Primary'

View File

@ -29,12 +29,26 @@
color: color_font color: color_font
<NavigationItem> <NavigationItem>
theme_text_color: 'Custom' on_press: root.active = not root.active
divider: None active_color: root.theme_cls.primary_color if root.active else root.theme_cls.text_color
IconLeftWidget: IconLeftWidget:
icon: root.icon icon: root.icon
theme_text_color: "Custom"
text_color: root.active_color
BadgeText:
text: f"{root.badge_text}"
theme_text_color: "Custom"
text_color: root.active_color
halign: 'right'
<NavigationDrawerDivider>:
canvas:
Color:
rgba: self.theme_cls.divider_color
Line:
points: root.x, root.y + dp(8), root.x + self.width, root.y + dp(8)
<ContentNavigationDrawer> <ContentNavigationDrawer>
@ -53,7 +67,8 @@
x: root.parent.x x: root.parent.x
pos_hint: {"top": 1} pos_hint: {"top": 1}
Image: Image:
source: './images/drawer_logo1.png' #source: './images/drawer_logo1.png'
source: app.get_default_logo()
ScrollView: ScrollView:
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -63,12 +78,15 @@
cols: 1 cols: 1
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
NavigationDrawerDivider:
NavigationDrawerSubheader:
text: "Accounts"
NavigationItem: NavigationItem:
Spinner: CustomSpinner:
id: btn id: btn
pos_hint:{"x":0,"y":.1} pos_hint:{"x":0,"y":0}
option_cls: Factory.get("MySpinnerOption") option_cls: Factory.get("MySpinnerOption")
font_size: '11.9sp' font_size: '10.9sp'
text: app.getDefaultAccData() text: app.getDefaultAccData()
background_color: color_button if self.state == 'normal' else color_button_pressed background_color: color_button if self.state == 'normal' else color_button_pressed
background_down: 'atlas://data/images/defaulttheme/spinner' background_down: 'atlas://data/images/defaulttheme/spinner'
@ -82,38 +100,45 @@
size: self.parent.height/2, self.parent.height/2 size: self.parent.height/2, self.parent.height/2
ArrowImg: ArrowImg:
NavigationItem: NavigationItem:
id: inbox_cnt
text: 'Inbox' text: 'Inbox'
icon: 'email-open' icon: 'email-open'
divider: None divider: None
badge_text: "0"
on_release: app.root.ids.scr_mngr.current = 'inbox' on_release: app.root.ids.scr_mngr.current = 'inbox'
on_release: root.parent.toggle_nav_drawer() on_release: root.parent.toggle_nav_drawer()
on_press: app.load_screen(self) on_press: app.load_screen(self)
NavigationItem: NavigationItem:
id: send_cnt
text: 'Sent' text: 'Sent'
icon: 'send' icon: 'send'
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'sent' on_release: app.root.ids.scr_mngr.current = 'sent'
on_release: root.parent.toggle_nav_drawer() on_release: root.parent.toggle_nav_drawer()
NavigationItem: NavigationItem:
id: draft_cnt
text: 'Draft' text: 'Draft'
icon: 'message-draw' icon: 'message-draw'
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'draft' on_release: app.root.ids.scr_mngr.current = 'draft'
on_release: root.parent.toggle_nav_drawer() on_release: root.parent.toggle_nav_drawer()
NavigationItem: NavigationItem:
id: trash_cnt
text: 'Trash' text: 'Trash'
icon: 'delete' icon: 'delete'
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'trash' on_release: app.root.ids.scr_mngr.current = 'trash'
on_release: root.parent.toggle_nav_drawer() on_release: root.parent.toggle_nav_drawer()
NavigationItem: NavigationItem:
id: allmail_cnt
text: 'All Mails' text: 'All Mails'
icon: 'contact-mail' icon: 'contact-mail'
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'allmails' on_release: app.root.ids.scr_mngr.current = 'allmails'
on_release: root.parent.toggle_nav_drawer() on_release: root.parent.toggle_nav_drawer()
on_press: app.load_screen(self) on_press: app.load_screen(self)
NavigationDrawerDivider:
NavigationDrawerSubheader:
text: "All labels"
NavigationItem: NavigationItem:
text: 'Address Book' text: 'Address Book'
icon: 'book-multiple' icon: 'book-multiple'

View File

@ -16,6 +16,7 @@ from kivy.clock import Clock
from kivy.core.clipboard import Clipboard from kivy.core.clipboard import Clipboard
from kivy.core.window import Window from kivy.core.window import Window
from kivy.lang import Builder from kivy.lang import Builder
from kivy.metrics import dp
from kivy.properties import ( from kivy.properties import (
BooleanProperty, BooleanProperty,
ListProperty, ListProperty,
@ -49,7 +50,10 @@ from kivymd.uix.list import (
TwoLineListItem, TwoLineListItem,
OneLineIconListItem, OneLineIconListItem,
OneLineAvatarListItem, OneLineAvatarListItem,
IRightBody IRightBody,
OneLineAvatarIconListItem,
IRightBodyTouch,
OneLineListItem
) )
# from kivymd.uix.navigationdrawer import ( # from kivymd.uix.navigationdrawer import (
# MDNavigationDrawer, # MDNavigationDrawer,
@ -79,6 +83,11 @@ def toast(text):
return return
def showLimitedCnt(total_msg):
"""This method set the total count limit in badge_text"""
return "99+" if total_msg > 99 else str(total_msg)
class Inbox(Screen): class Inbox(Screen):
"""Inbox Screen uses screen to show widgets of screens""" """Inbox Screen uses screen to show widgets of screens"""
@ -115,8 +124,7 @@ class Inbox(Screen):
self.inboxDataQuery(xAddress, where, what) self.inboxDataQuery(xAddress, where, what)
if self.queryreturn: if self.queryreturn:
state.kivyapp.get_inbox_count() state.kivyapp.get_inbox_count()
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids self.set_inboxCount(state.inbox_count)
# src_mng_obj.inbox_cnt.badge_text = state.inbox_count
for mail in self.queryreturn: for mail in self.queryreturn:
# third_text = mail[3].replace('\n', ' ') # third_text = mail[3].replace('\n', ' ')
data.append({ data.append({
@ -130,6 +138,7 @@ class Inbox(Screen):
self.children[2].children[0].children[0].bind( self.children[2].children[0].children[0].bind(
scroll_y=self.check_scroll_y) scroll_y=self.check_scroll_y)
else: else:
self.set_inboxCount('0')
content = MDLabel( content = MDLabel(
font_style='Caption', font_style='Caption',
theme_text_color='Primary', theme_text_color='Primary',
@ -140,8 +149,13 @@ class Inbox(Screen):
valign='top') valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def set_inboxCount(self, msgCnt):
"""This method is used to sent inbox message count"""
src_mng_obj = state.kivyapp.root.ids.content_drawer.ids.inbox_cnt
src_mng_obj.children[0].children[0].text = showLimitedCnt(int(msgCnt))
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20): def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
"""This method used for retrieving inbox data""" """This method is used for retrieving inbox data"""
self.queryreturn = kivy_helper_search.search_sql( self.queryreturn = kivy_helper_search.search_sql(
xAddress, xAddress,
self.account, self.account,
@ -245,12 +259,9 @@ class Inbox(Screen):
self.parent.parent.parent.parent.parent.children[ self.parent.parent.parent.parent.parent.children[
2].children[0].ids) 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 = showLimitedCnt(int(state.inbox_count) - 1)
int(state.inbox_count) - 1) msg_count_objs.trash_cnt.badge_text = showLimitedCnt(int(state.trash_count) + 1)
msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.allmail_cnt.badge_text = showLimitedCnt(int(state.all_count) - 1)
int(state.trash_count) + 1)
msg_count_objs.allmail_cnt.badge_text = str(
int(state.all_count) - 1)
state.inbox_count = str( state.inbox_count = str(
int(state.inbox_count) - 1) int(state.inbox_count) - 1)
state.trash_count = str( state.trash_count = str(
@ -295,10 +306,6 @@ class Inbox(Screen):
Clock.schedule_once(refresh_callback, 1) Clock.schedule_once(refresh_callback, 1)
# def set_root_layout(self):
# """Setting root layout"""
# return self.parent.parent.parent
class MyAddress(Screen): class MyAddress(Screen):
"""MyAddress screen uses screen to show widgets of screens""" """MyAddress screen uses screen to show widgets of screens"""
@ -586,7 +593,7 @@ class DropDownWidget(BoxLayout):
fromAddress = str(self.ids.ti.text) fromAddress = str(self.ids.ti.text)
toAddress = str(self.ids.txt_input.text) toAddress = str(self.ids.txt_input.text)
subject = self.ids.subject.text.strip() subject = self.ids.subject.text.strip()
message = self.ids.subject.text.strip() message = self.ids.body.text.strip()
encoding = 3 encoding = 3
print("message: ", self.ids.body.text) print("message: ", self.ids.body.text)
sendMessageToPeople = True sendMessageToPeople = True
@ -929,6 +936,7 @@ class Sent(Screen):
self.has_refreshed = True self.has_refreshed = True
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
self.set_sentCount('0')
content = MDLabel( content = MDLabel(
font_style='Caption', font_style='Caption',
theme_text_color='Primary', theme_text_color='Primary',
@ -1043,8 +1051,8 @@ class Sent(Screen):
@staticmethod @staticmethod
def set_sentCount(total_sent): def set_sentCount(total_sent):
"""Set the total no. of sent message count""" """Set the total no. of sent message count"""
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids src_mng_obj = state.kivyapp.root.ids.content_drawer.ids.send_cnt
# src_mng_obj.send_cnt.badge_text = str(total_sent) src_mng_obj.children[0].children[0].text = showLimitedCnt(int(total_sent))
state.sent_count = str(total_sent) state.sent_count = str(total_sent)
def sent_detail(self, ackdata, *args): def sent_detail(self, ackdata, *args):
@ -1061,19 +1069,11 @@ class Sent(Screen):
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete sent mail from sent mail listing""" """Delete sent mail from sent mail listing"""
# try: msg_count_objs = self.parent.parent.ids.content_drawer.ids
# msg_count_objs = self.parent.parent.parent.parent.children[
# 2].children[0].ids
# except Exception:
# msg_count_objs = self.parent.parent.parent.parent.parent.children[
# 2].children[0].ids
if int(state.sent_count) > 0: if int(state.sent_count) > 0:
# msg_count_objs.send_cnt.badge_text = str( msg_count_objs.send_cnt.children[0].children[0].text = showLimitedCnt(int(state.sent_count) - 1)
# int(state.sent_count) - 1) msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt(int(state.trash_count) + 1)
# msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt(int(state.all_count) - 1)
# int(state.trash_count) + 1)
# msg_count_objs.allmail_cnt.badge_text = str(
# int(state.all_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
@ -1132,9 +1132,11 @@ class Trash(Screen):
self.ids.identi_tag.children[0].text = 'Trash' self.ids.identi_tag.children[0].text = 'Trash'
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids # src_mng_obj = state.kivyapp.root.children[2].children[0].ids
# src_mng_obj.trash_cnt.badge_text = state.trash_count # src_mng_obj.trash_cnt.badge_text = state.trash_count
self.set_TrashCnt(state.trash_count)
self.set_mdList() self.set_mdList()
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
self.set_TrashCnt('0')
content = MDLabel( content = MDLabel(
font_style='Caption', font_style='Caption',
theme_text_color='Primary', theme_text_color='Primary',
@ -1158,6 +1160,11 @@ class Trash(Screen):
" ORDER BY actionTime DESC limit {1}, {2}".format( " ORDER BY actionTime DESC limit {1}, {2}".format(
state.association, start_indx, end_indx)) state.association, start_indx, end_indx))
def set_TrashCnt(self, Count):
"""This method is used to set trash message count"""
trashCnt_obj = state.kivyapp.root.ids.content_drawer.ids.trash_cnt
trashCnt_obj.children[0].children[0].text = showLimitedCnt(int(Count))
def set_mdList(self): def set_mdList(self):
"""This method is used to create the mdlist""" """This method is used to create the mdlist"""
total_trash_msg = len(self.ids.ml.children) total_trash_msg = len(self.ids.ml.children)
@ -1247,10 +1254,10 @@ class Trash(Screen):
elif self.table_name == 'sent': elif self.table_name == 'sent':
sqlExecute( sqlExecute(
"DELETE FROM sent WHERE ackdata = ?;", self.delete_index) "DELETE FROM sent WHERE ackdata = ?;", self.delete_index)
msg_count_objs = state.kivyapp.root.children[2].children[0].ids
if int(state.trash_count) > 0: if int(state.trash_count) > 0:
# 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)
self.set_TrashCnt(int(state.trash_count) - 1)
state.trash_count = str(int(state.trash_count) - 1) state.trash_count = str(int(state.trash_count) - 1)
Clock.schedule_once(self.callback_for_screen_load, 1) Clock.schedule_once(self.callback_for_screen_load, 1)
@ -1306,7 +1313,7 @@ class NavigateApp(MDApp):
kivysignalthread = UIkivySignaler() kivysignalthread = UIkivySignaler()
kivysignalthread.daemon = True kivysignalthread.daemon = True
kivysignalthread.start() kivysignalthread.start()
Window.bind(on_keyboard=self.on_key) Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_closee)
return Builder.load_file( return Builder.load_file(
os.path.join(os.path.dirname(__file__), 'main.kv')) os.path.join(os.path.dirname(__file__), 'main.kv'))
@ -1410,6 +1417,14 @@ class NavigateApp(MDApp):
BMConfigParser().addresses()[0]) BMConfigParser().addresses()[0])
return './images/no_identicons.png' return './images/no_identicons.png'
@staticmethod
def get_default_logo():
"""Getting default logo image"""
if BMConfigParser().addresses():
return './images/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0])
return './images/drawer_logo1.png'
@staticmethod @staticmethod
def addressexist(): def addressexist():
"""Checking address existence""" """Checking address existence"""
@ -1693,9 +1708,9 @@ class NavigateApp(MDApp):
def set_identicon(self, text): def set_identicon(self, text):
"""Show identicon in address spinner""" """Show identicon in address spinner"""
img = identiconGeneration.generate(text) img = identiconGeneration.generate(text)
# self.root.children[2].children[0].ids.btn.children[1].texture = ( self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
# img.texture) #below line is for displaing logo
self.root.children[0].children[0].ids.btn.texture = (img.texture) self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
def set_mail_detail_header(self): def set_mail_detail_header(self):
"""Setting the details of the page""" """Setting the details of the page"""
@ -1748,6 +1763,23 @@ class NavigateApp(MDApp):
except Exception: except Exception:
self.root.ids.sc17.children[0].children[1].active = False self.root.ids.sc17.children[0].children[1].active = False
def on_request_closee(self, *args):
box = BoxLayout(orientation='vertical')
box.add_widget(Label(
text=(
"Bitmessage isn't connected to the network.\n"
"If you quit now, it may cause delivery delays.\n"
"Wait until connected and the synchronisation finishes?")))
mybutton = Button(text='Yes', size_hint=(1, 0.50))
box.add_widget(mybutton)
mybutton2 = Button(text='No', size_hint=(1, 0.50))
box.add_widget(mybutton2)
mybutton3 = Button(text='Cancel', size_hint=(1, 0.50))
box.add_widget(mybutton3)
popup = Popup(title="Window close", content=box, size_hint=(None, None), size=(500, 300))
popup.open()
return True
class GrashofPopup(Popup): class GrashofPopup(Popup):
"""Moule for save contacts and error messages""" """Moule for save contacts and error messages"""
@ -1925,14 +1957,10 @@ class MailDetail(Screen):
self.message = data[0][3] self.message = data[0][3]
if len(data[0]) == 6: if len(data[0]) == 6:
self.status = data[0][4] self.status = data[0][4]
state.write_msg = {'to_addr': self.to_addr,
'from_addr': self.from_addr,
'subject': self.subject,
'message': self.message}
def delete_mail(self): def delete_mail(self):
"""Method for mail delete""" """Method for mail delete"""
msg_count_objs = state.kivyapp.root.children[2].children[0].ids msg_count_objs = state.kivyapp.root.ids.content_drawer.ids
state.searcing_text = '' state.searcing_text = ''
self.children[0].children[0].active = True self.children[0].children[0].active = True
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
@ -1941,7 +1969,7 @@ class MailDetail(Screen):
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash' WHERE" "UPDATE sent SET folder = 'trash' WHERE"
" ackdata = ?;", state.mail_id) " ackdata = ?;", state.mail_id)
# msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.children[0].children[0].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].ids.ml.clear_widgets() self.parent.screens[3].ids.ml.clear_widgets()
self.parent.screens[3].loadSent(state.association) self.parent.screens[3].loadSent(state.association)
@ -1953,25 +1981,25 @@ class MailDetail(Screen):
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE" "UPDATE inbox SET folder = 'trash' WHERE"
" msgid = ?;", state.mail_id) " msgid = ?;", state.mail_id)
# msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.children[0].children[0].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].ids.ml.clear_widgets() self.parent.screens[0].ids.ml.clear_widgets()
self.parent.screens[0].loadMessagelist(state.association) self.parent.screens[0].loadMessagelist(state.association)
elif state.detailPageType == 'draft': elif state.detailPageType == 'draft':
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", state.mail_id) sqlExecute("DELETE FROM sent WHERE ackdata = ?;", state.mail_id)
# msg_count_objs.draft_cnt.badge_text = str( msg_count_objs.draft_cnt.children[0].children[0].text = str(
# 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.parent.screens[15].clear_widgets() self.parent.screens[15].clear_widgets()
self.parent.screens[15].add_widget(Draft()) self.parent.screens[15].add_widget(Draft())
if state.detailPageType != 'draft': if state.detailPageType != 'draft':
# msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.trash_cnt.children[0].children[0].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.children[0].children[0].text = str(
# int(state.all_count) - 1) int(state.all_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
self.parent.screens[4].clear_widgets() self.parent.screens[4].clear_widgets()
@ -2007,16 +2035,16 @@ class MailDetail(Screen):
def write_msg(self, navApp): def write_msg(self, navApp):
"""Write on draft mail""" """Write on draft mail"""
state.send_draft_mail = state.mail_id state.send_draft_mail = state.mail_id
# composer_ids = ( data = sqlQuery(
# self.parent.parent.parent.parent.parent.ids.sc3.children[1].ids) "select toaddress, fromaddress, subject, message from sent where"
" ackdata = ?;", state.mail_id)
composer_ids = ( composer_ids = (
self.parent.parent.ids.sc3.children[1].ids) self.parent.parent.ids.sc3.children[1].ids)
composer_ids.ti.text = state.write_msg['from_addr'] composer_ids.ti.text = data[0][1]
composer_ids.btn.text = state.write_msg['from_addr'] composer_ids.btn.text = data[0][1]
composer_ids.txt_input.text = state.write_msg['to_addr'] composer_ids.txt_input.text = data[0][0]
composer_ids.subject.text = state.write_msg[ composer_ids.subject.text = data[0][2] if data[0][2] != '(no subject)' else ''
'subject'] if state.write_msg['subject'] != '(no subject)' else '' composer_ids.body.text = data[0][3]
composer_ids.body.text = state.write_msg['message']
self.parent.current = 'create' self.parent.current = 'create'
navApp.set_navbar_for_composer() navApp.set_navbar_for_composer()
@ -2178,15 +2206,14 @@ class Draft(Screen):
self.ids.identi_tag.children[0].text = '' self.ids.identi_tag.children[0].text = ''
self.draftDataQuery(xAddress, where, what) self.draftDataQuery(xAddress, where, what)
if state.msg_counter_objs: if state.msg_counter_objs:
state.msg_counter_objs.draft_cnt.badge_text = str( state.msg_counter_objs.draft_cnt.children[0].children[0].text = showLimitedCnt(len(self.queryreturn))
len(self.queryreturn))
if self.queryreturn: if self.queryreturn:
self.ids.identi_tag.children[0].text = 'Draft' self.ids.identi_tag.children[0].text = 'Draft'
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids self.set_draftCnt(state.draft_count)
# src_mng_obj.draft_cnt.badge_text = state.draft_count
self.set_mdList() self.set_mdList()
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
self.set_draftCnt('0')
content = MDLabel( content = MDLabel(
font_style='Caption', font_style='Caption',
theme_text_color='Primary', theme_text_color='Primary',
@ -2208,6 +2235,11 @@ class Draft(Screen):
start_indx, start_indx,
end_indx) end_indx)
def set_draftCnt(self, Count):
"""This method set the count of draft mails"""
draftCnt_obj = state.kivyapp.root.ids.content_drawer.ids.draft_cnt
draftCnt_obj.children[0].children[0].text = showLimitedCnt(int(Count))
def set_mdList(self): def set_mdList(self):
"""This method is used to create mdlist""" """This method is used to create mdlist"""
data = [] data = []
@ -2291,6 +2323,7 @@ class Draft(Screen):
# msg_count_objs.draft_cnt.badge_text = str( # msg_count_objs.draft_cnt.badge_text = str(
# 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.set_draftCnt(state.draft_count)
if int(state.draft_count) <= 0: if int(state.draft_count) <= 0:
self.ids.identi_tag.children[0].text = '' self.ids.identi_tag.children[0].text = ''
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
@ -2381,12 +2414,12 @@ class Allmails(Screen):
state.kivyapp.get_sent_count() state.kivyapp.get_sent_count()
state.all_count = str( state.all_count = str(
int(state.sent_count) + int(state.inbox_count)) int(state.sent_count) + int(state.inbox_count))
# state.kivyapp.root.children[2].children[ self.set_AllmailCnt(state.all_count)
# 0].ids.allmail_cnt.badge_text = state.all_count
self.set_mdlist() self.set_mdlist()
# self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y) # self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y)
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y) self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
else: else:
self.set_AllmailCnt('0')
content = MDLabel( content = MDLabel(
font_style='Caption', font_style='Caption',
theme_text_color='Primary', theme_text_color='Primary',
@ -2408,6 +2441,11 @@ class Allmails(Screen):
" ORDER BY actionTime DESC limit {1}, {2}".format( " ORDER BY actionTime DESC limit {1}, {2}".format(
self.account, start_indx, end_indx)) self.account, start_indx, end_indx))
def set_AllmailCnt(self, Count):
"""This method is used to set allmails message count"""
allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt
allmailCnt_obj.children[0].children[0].text = showLimitedCnt(int(Count))
def set_mdlist(self): def set_mdlist(self):
"""This method is used to create mdList for allmaills""" """This method is used to create mdList for allmaills"""
data_exist = len(self.ids.ml.children) data_exist = len(self.ids.ml.children)
@ -2483,30 +2521,23 @@ class Allmails(Screen):
unique_id) unique_id)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
try: try:
# msg_count_objs = self.parent.parent.parent.parent.parent.children[ msg_count_objs = self.parent.parent.ids.content_drawer.ids
# 2].children[0].ids nav_lay_obj = self.parent.parent.ids
nav_lay_obj = self.parent.parent.parent.ids
except Exception: except Exception:
msg_count_objs = ( msg_count_objs = self.parent.parent.parent.ids.content_drawer.ids
self.parent.parent.parent.parent.parent.parent.children[ nav_lay_obj = self.parent.parent.parent.ids
2].children[0].ids)
nav_lay_obj = self.parent.parent.parent.parent.parent.parent.ids
if folder == 'inbox': if folder == 'inbox':
# msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.children[0].children[0].text = showLimitedCnt(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.ids.ml.clear_widgets() nav_lay_obj.sc1.ids.ml.clear_widgets()
nav_lay_obj.sc1.loadMessagelist(state.association) nav_lay_obj.sc1.loadMessagelist(state.association)
else: else:
# msg_count_objs.send_cnt.badge_text = str( msg_count_objs.send_cnt.children[0].children[0].text = showLimitedCnt(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.ids.ml.clear_widgets() nav_lay_obj.sc4.ids.ml.clear_widgets()
nav_lay_obj.sc4.loadSent(state.association) nav_lay_obj.sc4.loadSent(state.association)
# msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt(int(state.trash_count) + 1)
# int(state.trash_count) + 1) msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt(int(state.all_count) - 1)
# msg_count_objs.allmail_cnt.badge_text = str(
# int(state.all_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
if int(state.all_count) <= 0: if int(state.all_count) <= 0:
@ -2531,13 +2562,6 @@ class Allmails(Screen):
self.tick = 0 self.tick = 0
Clock.schedule_once(refresh_callback, 1) Clock.schedule_once(refresh_callback, 1)
def set_root_layout(self):
"""Setting root layout"""
try:
return self.manager.parent.parent
except Exception:
return state.kivyapp.root.ids.float_box
def avatarImageFirstLetter(letter_string): def avatarImageFirstLetter(letter_string):
"""This function is used to the first letter for the avatar image""" """This function is used to the first letter for the avatar image"""
@ -2587,6 +2611,40 @@ class AddressDropdown(OneLineIconListItem):
pass pass
class NavigationItem(OneLineAvatarListItem): class BadgeText(IRightBodyTouch, MDLabel):
pass
class NavigationItem(OneLineAvatarIconListItem):
"""NavigationItem class is for button behaviour""" """NavigationItem class is for button behaviour"""
badge_text = StringProperty()
icon = StringProperty() icon = StringProperty()
active = BooleanProperty(False)
class NavigationDrawerDivider(OneLineListItem):
"""
A small full-width divider that can be placed
in the :class:`MDNavigationDrawer`
"""
disabled = True
divider = None
_txt_top_pad = NumericProperty(dp(8))
_txt_bot_pad = NumericProperty(dp(8))
def __init__(self, **kwargs):
super(OneLineListItem, self).__init__(**kwargs)
self.height = dp(16)
class NavigationDrawerSubheader(OneLineListItem):
"""
A subheader for separating content in :class:`MDNavigationDrawer`
Works well alongside :class:`NavigationDrawerDivider`
"""
disabled = True
divider = None
theme_text_color = 'Secondary'

View File

@ -103,8 +103,6 @@ is_allmail = False
in_composer = False in_composer = False
write_msg = {}
availabe_credit = 0 availabe_credit = 0
in_sent_method = False in_sent_method = False