worekd on draft mail detail page or sent draft mail functionality

This commit is contained in:
Navjot 2019-08-19 16:36:24 +05:30
parent 41001d02dc
commit a3964aee5a
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
3 changed files with 90 additions and 49 deletions

View File

@ -828,10 +828,10 @@ NavigationLayout:
MDRaisedButton: MDRaisedButton:
size_hint: 1, None size_hint: 1, None
height: dp(40) height: dp(40)
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() if root.page_type == 'sent' else root.write_msg()
MDLabel: MDLabel:
font_style: 'Title' font_style: 'Title'
text: 'Reply' if root.page_type == 'inbox' else 'Copy' text: 'Reply' if root.page_type == 'inbox' else 'Copy' if root.page_type == 'sent' else 'Write'
font_size: '13sp' font_size: '13sp'
color: (1,1,1,1) color: (1,1,1,1)
halign: 'center' halign: 'center'

View File

@ -475,6 +475,14 @@ class DropDownWidget(BoxLayout):
status, addressVersionNumber, streamNumber, ripe = \ status, addressVersionNumber, streamNumber, ripe = \
decodeAddress(toAddress) decodeAddress(toAddress)
if status == 'success': if status == 'success':
if state.detailPageType == 'draft' and state.send_draft_mail:
sqlExecute(
"UPDATE sent SET toaddress = '{0}', fromaddress ='{1}' , subject = '{2}', message = '{3}', folder = 'sent' \
WHERE lastactiontime = '{4}';".format(toAddress, fromAddress, subject, message, state.send_draft_mail))
self.parent.parent.screens[15].clear_widgets()
self.parent.parent.screens[15].add_widget(Draft())
state.detailPageType = 'draft'
else:
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' statusIconColor = 'red'
@ -513,6 +521,8 @@ class DropDownWidget(BoxLayout):
.parent.parent.children[0].children[2].children[0].ids .parent.parent.children[0].children[2].children[0].ids
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.screens[16].clear_widgets()
self.parent.parent.screens[16].add_widget(Allmails())
toLabel = '' toLabel = ''
queues.workerQueue.put(('sendmessage', toAddress)) queues.workerQueue.put(('sendmessage', toAddress))
print "sqlExecute successfully #######################" print "sqlExecute successfully #######################"
@ -984,10 +994,12 @@ class NavigateApp(App):
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.sc16.clear_widgets()
self.root.ids.sc17.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.sc16.add_widget(Draft())
self.root.ids.sc17.add_widget(Allmails())
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
msg_counter_objs = \ msg_counter_objs = \
@ -1008,12 +1020,14 @@ class NavigateApp(App):
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \ "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
folder = 'draft' ;".format(state.association))[0][0]) folder = 'draft' ;".format(state.association))[0][0])
state.all_count = str(int(state.sent_count) + int(state.inbox_count))
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 msg_counter_objs.draft_cnt.badge_text = state.draft_count
msg_counter_objs.allmail_cnt.badge_text = state.all_count
@staticmethod @staticmethod
def getCurrentAccount(): def getCurrentAccount():
@ -1048,7 +1062,8 @@ class NavigateApp(App):
if key == 27: if key == 27:
if self.root.ids.scr_mngr.current == "mailDetail": if self.root.ids.scr_mngr.current == "mailDetail":
self.root.ids.scr_mngr.current = \ self.root.ids.scr_mngr.current = \
'sent' if state.detailPageType == 'sent' else 'inbox' 'sent' if state.detailPageType == 'sent' else 'inbox' if state.detailPageType == 'inbox' else 'draft'
if state.detailPageType in ['sent', 'inbox']:
self.add_search_bar() self.add_search_bar()
elif self.root.ids.scr_mngr.current == "create": elif self.root.ids.scr_mngr.current == "create":
composer_objs = self.root composer_objs = self.root
@ -1056,7 +1071,7 @@ class NavigateApp(App):
0].children[0].children[0].ids.ti.text) 0].children[0].children[0].ids.ti.text)
to_addr = str(self.root.children[1].children[0].children[ to_addr = str(self.root.children[1].children[0].children[
0].children[0].children[0].ids.txt_input.text) 0].children[0].children[0].ids.txt_input.text)
if from_addr and to_addr: if from_addr and to_addr and state.detailPageType != 'draft':
Draft().draft_msg(composer_objs) Draft().draft_msg(composer_objs)
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
self.add_search_bar() self.add_search_bar()
@ -1132,8 +1147,8 @@ class NavigateApp(App):
return state.draft_count return state.draft_count
elif text == 'All Mails': elif text == 'All Mails':
state.all_count = str(sqlQuery( state.all_count = str(sqlQuery(
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}'\ "SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and \
and folder != 'trash' )+(SELECT count(*) FROM inbox where \ folder = 'sent' )+(SELECT count(*) FROM inbox where \
toaddress = '{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.all_count return state.all_count
@ -1319,7 +1334,7 @@ class MailDetail(Screen):
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method MailDetail mails.""" """Clock Schdule for method MailDetail mails."""
self.page_type = state.detailPageType if state.detailPageType else '' self.page_type = state.detailPageType if state.detailPageType else ''
if state.detailPageType == 'sent': if state.detailPageType == 'sent' or state.detailPageType == 'draft':
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message, status, \ "select toaddress, fromaddress, subject, message, status, \
ackdata from sent where lastactiontime = {};".format( ackdata from sent where lastactiontime = {};".format(
@ -1337,7 +1352,7 @@ class MailDetail(Screen):
"""Assigning mail details.""" """Assigning mail details."""
self.to_addr = data[0][0] self.to_addr = data[0][0]
self.from_addr = data[0][1] self.from_addr = data[0][1]
self.subject = data[0][2].upper() self.subject = data[0][2].upper() if data[0][2].upper() else '(no subject)'
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]
@ -1389,6 +1404,17 @@ class MailDetail(Screen):
"""Method used for copying sent mail to the composer.""" """Method used for copying sent mail to the composer."""
pass pass
def write_msg(self):
"""This method is used to write on draft mail."""
state.send_draft_mail = state.sentMailTime
composer_ids = self.parent.parent.parent.parent.parent.ids.sc3.children[0].ids
composer_ids.ti.text = self.from_addr
composer_ids.btn.text = self.from_addr
composer_ids.txt_input.text = self.to_addr
composer_ids.subject.text = '' if self.subject == '(no subject)' else self.subject.lower()
composer_ids.body.text = self.message
self.parent.parent.current = 'create'
class MyaddDetailPopup(Popup): class MyaddDetailPopup(Popup):
"""MyaddDetailPopup pop is used for showing my address detail.""" """MyaddDetailPopup pop is used for showing my address detail."""
@ -1520,9 +1546,9 @@ class Draft(Screen):
xAddress, account, "draft", where, what, False) xAddress, account, "draft", where, what, False)
if state.msg_counter_objs: if state.msg_counter_objs:
state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn)) state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn))
state.all_count = str(int(state.all_count) + 1) # state.all_count = str(int(state.all_count) + 1)
state.msg_counter_objs.allmail_cnt.badge_text = state.all_count # state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
state.msg_counter_objs = None # state.msg_counter_objs = None
if queryreturn: if queryreturn:
for mail in queryreturn: for mail in queryreturn:
@ -1542,6 +1568,8 @@ class Draft(Screen):
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/avatar.png')) source='./images/avatar.png'))
meny.bind(on_press=partial(
self.draft_detail, item['lastactiontime']))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
if platform == 'android': if platform == 'android':
carousel.height = 150 carousel.height = 150
@ -1571,6 +1599,17 @@ class Draft(Screen):
valign='top') valign='top')
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def draft_detail(self, lastsenttime, *args):
state.detailPageType = 'draft'
state.sentMailTime = lastsenttime
if self.manager:
src_mng_obj = self.manager
else:
src_mng_obj = self.parent.parent
src_mng_obj.screens[13].clear_widgets()
src_mng_obj.screens[13].add_widget(MailDetail())
src_mng_obj.current = 'mailDetail'
def delete_draft(self, data_index, instance, *args): def delete_draft(self, data_index, instance, *args):
"""Method used to delete draft message permanently.""" """Method used to delete draft message permanently."""
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format( sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
@ -1694,8 +1733,8 @@ class Allmails(Screen):
inbox WHERE folder = 'inbox' and toaddress = '{}';".format( inbox WHERE folder = 'inbox' and toaddress = '{}';".format(
account)) account))
sent_and_draft = sqlQuery( sent_and_draft = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder from\ "SELECT toaddress, fromaddress, subject, message, folder from sent \
sent WHERE folder != 'trash' and fromaddress = '{}';".format( WHERE folder = 'sent' and fromaddress = '{}';".format(
account)) account))
all_mails = inbox + sent_and_draft all_mails = inbox + sent_and_draft

View File

@ -103,3 +103,5 @@ all_count = 0
searcing_text = '' searcing_text = ''
search_screen = '' search_screen = ''
send_draft_mail = None