worekd on draft mail detail page or sent draft mail functionality
This commit is contained in:
parent
41001d02dc
commit
a3964aee5a
|
@ -828,10 +828,10 @@ NavigationLayout:
|
|||
MDRaisedButton:
|
||||
size_hint: 1, None
|
||||
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:
|
||||
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'
|
||||
color: (1,1,1,1)
|
||||
halign: 'center'
|
||||
|
|
|
@ -475,44 +475,54 @@ class DropDownWidget(BoxLayout):
|
|||
status, addressVersionNumber, streamNumber, ripe = \
|
||||
decodeAddress(toAddress)
|
||||
if status == 'success':
|
||||
from addresses import addBMIfNotPresent
|
||||
toAddress = addBMIfNotPresent(toAddress)
|
||||
statusIconColor = 'red'
|
||||
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
||||
print "addressVersionNumber > 4 \
|
||||
or addressVersionNumber <= 1"
|
||||
if streamNumber > 1 or streamNumber == 0:
|
||||
print "streamNumber > 1 or streamNumber == 0"
|
||||
if statusIconColor == 'red':
|
||||
print "shared.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,
|
||||
'sent',
|
||||
encoding,
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||
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
|
||||
toAddress = addBMIfNotPresent(toAddress)
|
||||
statusIconColor = 'red'
|
||||
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
||||
print "addressVersionNumber > 4 \
|
||||
or addressVersionNumber <= 1"
|
||||
if streamNumber > 1 or streamNumber == 0:
|
||||
print "streamNumber > 1 or streamNumber == 0"
|
||||
if statusIconColor == 'red':
|
||||
print "shared.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,
|
||||
'sent',
|
||||
encoding,
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||
state.check_sent_acc = fromAddress
|
||||
state.msg_counter_objs = self.parent.parent.parent.parent\
|
||||
.parent.parent.children[0].children[2].children[0].ids
|
||||
self.parent.parent.screens[3].clear_widgets()
|
||||
self.parent.parent.screens[3].add_widget(Sent())
|
||||
self.parent.parent.screens[16].clear_widgets()
|
||||
self.parent.parent.screens[16].add_widget(Allmails())
|
||||
toLabel = ''
|
||||
queues.workerQueue.put(('sendmessage', toAddress))
|
||||
print "sqlExecute successfully #######################"
|
||||
|
@ -984,10 +994,12 @@ class NavigateApp(App):
|
|||
self.root.ids.sc4.clear_widgets()
|
||||
self.root.ids.sc5.clear_widgets()
|
||||
self.root.ids.sc16.clear_widgets()
|
||||
self.root.ids.sc17.clear_widgets()
|
||||
self.root.ids.sc1.add_widget(Inbox())
|
||||
self.root.ids.sc4.add_widget(Sent())
|
||||
self.root.ids.sc5.add_widget(Trash())
|
||||
self.root.ids.sc16.add_widget(Draft())
|
||||
self.root.ids.sc17.add_widget(Allmails())
|
||||
self.root.ids.scr_mngr.current = 'inbox'
|
||||
|
||||
msg_counter_objs = \
|
||||
|
@ -1008,12 +1020,14 @@ class NavigateApp(App):
|
|||
sqlQuery(
|
||||
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
|
||||
folder = 'draft' ;".format(state.association))[0][0])
|
||||
state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
||||
|
||||
if msg_counter_objs:
|
||||
msg_counter_objs.send_cnt.badge_text = state.sent_count
|
||||
msg_counter_objs.inbox_cnt.badge_text = state.inbox_count
|
||||
msg_counter_objs.trash_cnt.badge_text = state.trash_count
|
||||
msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
||||
msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||
|
||||
@staticmethod
|
||||
def getCurrentAccount():
|
||||
|
@ -1048,15 +1062,16 @@ class NavigateApp(App):
|
|||
if key == 27:
|
||||
if self.root.ids.scr_mngr.current == "mailDetail":
|
||||
self.root.ids.scr_mngr.current = \
|
||||
'sent' if state.detailPageType == 'sent' else 'inbox'
|
||||
self.add_search_bar()
|
||||
'sent' if state.detailPageType == 'sent' else 'inbox' if state.detailPageType == 'inbox' else 'draft'
|
||||
if state.detailPageType in ['sent', 'inbox']:
|
||||
self.add_search_bar()
|
||||
elif self.root.ids.scr_mngr.current == "create":
|
||||
composer_objs = self.root
|
||||
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:
|
||||
if from_addr and to_addr and state.detailPageType != 'draft':
|
||||
Draft().draft_msg(composer_objs)
|
||||
self.root.ids.scr_mngr.current = 'inbox'
|
||||
self.add_search_bar()
|
||||
|
@ -1132,9 +1147,9 @@ class NavigateApp(App):
|
|||
return state.draft_count
|
||||
elif text == 'All Mails':
|
||||
state.all_count = str(sqlQuery(
|
||||
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}'\
|
||||
and folder != 'trash' )+(SELECT count(*) FROM inbox where \
|
||||
toaddress = '{0}' and folder != 'trash') AS SumCount".format(
|
||||
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and \
|
||||
folder = 'sent' )+(SELECT count(*) FROM inbox where \
|
||||
toaddress = '{0}' and folder != 'trash') AS SumCount".format(
|
||||
state.association))[0][0])
|
||||
return state.all_count
|
||||
|
||||
|
@ -1319,7 +1334,7 @@ class MailDetail(Screen):
|
|||
def init_ui(self, dt=0):
|
||||
"""Clock Schdule for method MailDetail mails."""
|
||||
self.page_type = state.detailPageType if state.detailPageType else ''
|
||||
if state.detailPageType == 'sent':
|
||||
if state.detailPageType == 'sent' or state.detailPageType == 'draft':
|
||||
data = sqlQuery(
|
||||
"select toaddress, fromaddress, subject, message, status, \
|
||||
ackdata from sent where lastactiontime = {};".format(
|
||||
|
@ -1337,7 +1352,7 @@ class MailDetail(Screen):
|
|||
"""Assigning mail details."""
|
||||
self.to_addr = data[0][0]
|
||||
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]
|
||||
if len(data[0]) == 6:
|
||||
self.status = data[0][4]
|
||||
|
@ -1389,6 +1404,17 @@ class MailDetail(Screen):
|
|||
"""Method used for copying sent mail to the composer."""
|
||||
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):
|
||||
"""MyaddDetailPopup pop is used for showing my address detail."""
|
||||
|
@ -1520,9 +1546,9 @@ class Draft(Screen):
|
|||
xAddress, account, "draft", where, what, False)
|
||||
if state.msg_counter_objs:
|
||||
state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn))
|
||||
state.all_count = str(int(state.all_count) + 1)
|
||||
state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||
state.msg_counter_objs = None
|
||||
# state.all_count = str(int(state.all_count) + 1)
|
||||
# state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||
# state.msg_counter_objs = None
|
||||
|
||||
if queryreturn:
|
||||
for mail in queryreturn:
|
||||
|
@ -1542,6 +1568,8 @@ class Draft(Screen):
|
|||
text_color=NavigateApp().theme_cls.primary_color)
|
||||
meny.add_widget(AvatarSampleWidget(
|
||||
source='./images/avatar.png'))
|
||||
meny.bind(on_press=partial(
|
||||
self.draft_detail, item['lastactiontime']))
|
||||
carousel = Carousel(direction='right')
|
||||
if platform == 'android':
|
||||
carousel.height = 150
|
||||
|
@ -1571,6 +1599,17 @@ class Draft(Screen):
|
|||
valign='top')
|
||||
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):
|
||||
"""Method used to delete draft message permanently."""
|
||||
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
|
||||
|
@ -1694,8 +1733,8 @@ class Allmails(Screen):
|
|||
inbox WHERE folder = 'inbox' and toaddress = '{}';".format(
|
||||
account))
|
||||
sent_and_draft = sqlQuery(
|
||||
"SELECT toaddress, fromaddress, subject, message, folder from\
|
||||
sent WHERE folder != 'trash' and fromaddress = '{}';".format(
|
||||
"SELECT toaddress, fromaddress, subject, message, folder from sent \
|
||||
WHERE folder = 'sent' and fromaddress = '{}';".format(
|
||||
account))
|
||||
|
||||
all_mails = inbox + sent_and_draft
|
||||
|
|
|
@ -103,3 +103,5 @@ all_count = 0
|
|||
searcing_text = ''
|
||||
|
||||
search_screen = ''
|
||||
|
||||
send_draft_mail = None
|
Reference in New Issue
Block a user