Implement sent item message loading feature for current account logged with dynamic dispatching of accounts
This commit is contained in:
parent
c163001ee8
commit
d8a5b9356f
|
@ -7,9 +7,13 @@ def search_sql(xAddress = "toaddress", account = None, folder = "inbox", where =
|
||||||
else:
|
else:
|
||||||
what = None
|
what = None
|
||||||
|
|
||||||
|
if folder == "sent":
|
||||||
|
sqlStatementBase = '''
|
||||||
|
SELECT toaddress, fromaddress, subject, status, ackdata, lastactiontime
|
||||||
|
FROM sent '''
|
||||||
|
else:
|
||||||
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
|
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
|
||||||
FROM inbox '''
|
FROM inbox '''
|
||||||
|
|
||||||
sqlStatementParts = []
|
sqlStatementParts = []
|
||||||
sqlArguments = []
|
sqlArguments = []
|
||||||
if account is not None:
|
if account is not None:
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
background_color: app.theme_cls.primary_dark
|
background_color: app.theme_cls.primary_dark
|
||||||
text: app.showmeaddresses(name='text')
|
text: app.showmeaddresses(name='text')
|
||||||
values: app.showmeaddresses(name='values')
|
values: app.showmeaddresses(name='values')
|
||||||
|
on_text:app.getCurrentAccountData(self.text)
|
||||||
|
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'email-open'
|
icon: 'email-open'
|
||||||
|
@ -99,6 +100,7 @@ BoxLayout:
|
||||||
<Inbox>:
|
<Inbox>:
|
||||||
name: 'inbox'
|
name: 'inbox'
|
||||||
ScrollView:
|
ScrollView:
|
||||||
|
id:scrollid
|
||||||
GridLayout:
|
GridLayout:
|
||||||
id: box_share
|
id: box_share
|
||||||
cols: 1
|
cols: 1
|
||||||
|
@ -115,6 +117,21 @@ BoxLayout:
|
||||||
|
|
||||||
<Sent>:
|
<Sent>:
|
||||||
name: 'sent'
|
name: 'sent'
|
||||||
|
ScrollView:
|
||||||
|
id:scrollid
|
||||||
|
GridLayout:
|
||||||
|
id: box_share
|
||||||
|
cols: 1
|
||||||
|
size_hint_y: None
|
||||||
|
spacing: 10
|
||||||
|
padding: 10
|
||||||
|
height: self.minimum_height
|
||||||
|
canvas:
|
||||||
|
Color:
|
||||||
|
rgb: 30,144,255
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
|
||||||
<Trash>:
|
<Trash>:
|
||||||
name: 'trash'
|
name: 'trash'
|
||||||
|
|
|
@ -28,6 +28,8 @@ from addresses import decodeAddress, addBMIfNotPresent
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
statusIconColor = 'red'
|
statusIconColor = 'red'
|
||||||
avatarlist = os.listdir("images/ngletteravatar")
|
avatarlist = os.listdir("images/ngletteravatar")
|
||||||
|
global belonging
|
||||||
|
belonging = ''
|
||||||
|
|
||||||
|
|
||||||
class NavigateApp(App, TextInput):
|
class NavigateApp(App, TextInput):
|
||||||
|
@ -35,13 +37,21 @@ class NavigateApp(App, TextInput):
|
||||||
nav_drawer = ObjectProperty()
|
nav_drawer = ObjectProperty()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
|
global main_widget
|
||||||
main_widget = Builder.load_file(
|
main_widget = Builder.load_file(
|
||||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||||
self.nav_drawer = Navigator()
|
self.nav_drawer = Navigator()
|
||||||
return main_widget
|
return main_widget
|
||||||
|
|
||||||
# def setCurrentAccount(self, text):
|
def getCurrentAccountData(self, text):
|
||||||
# self.ids.btn.text = text
|
global belonging
|
||||||
|
belonging = text
|
||||||
|
main_widget.ids.sc1.clear_widgets()
|
||||||
|
main_widget.ids.sc2.clear_widgets()
|
||||||
|
main_widget.ids.sc1.add_widget(Inbox())
|
||||||
|
main_widget.ids.sc2.add_widget(Sent())
|
||||||
|
Inbox()
|
||||||
|
Sent()
|
||||||
|
|
||||||
def say_exit(self):
|
def say_exit(self):
|
||||||
print("**************************EXITING FROM APPLICATION*****************************")
|
print("**************************EXITING FROM APPLICATION*****************************")
|
||||||
|
@ -61,21 +71,24 @@ class Navigator(NavigationDrawer):
|
||||||
|
|
||||||
|
|
||||||
class Inbox(Screen):
|
class Inbox(Screen):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Inbox, self).__init__(*args, **kwargs)
|
super(Inbox, self).__init__(*args, **kwargs)
|
||||||
|
global belonging
|
||||||
|
if belonging == '':
|
||||||
|
belonging = Navigator().ids.btn.text
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
|
global belonging
|
||||||
self.orientation = "vertical"
|
self.orientation = "vertical"
|
||||||
self.create_button(self.ids.box_share)
|
self.inboxaccounts(self.ids.box_share)
|
||||||
|
|
||||||
def create_button(self, box_share):
|
def inboxaccounts(self, box_share):
|
||||||
account = Navigator().ids.btn.text
|
account = belonging
|
||||||
folder = 'inbox'
|
folder = 'inbox'
|
||||||
self.loadMessagelist(account, folder, box_share, 'All', '')
|
self.loadinboxlist(account, folder, box_share, 'All', '')
|
||||||
|
|
||||||
def loadMessagelist(self, account, folder, box_share, where="", what="", unreadOnly=False):
|
def loadinboxlist(self, account, folder, box_share, where="", what="", unreadOnly=False):
|
||||||
top_logo_share = 1.01
|
top_logo_share = 1.01
|
||||||
top_button_share = 1.1
|
top_button_share = 1.1
|
||||||
top_label_share = 1.4
|
top_label_share = 1.4
|
||||||
|
@ -89,13 +102,13 @@ class Inbox(Screen):
|
||||||
top_button_share -= .4
|
top_button_share -= .4
|
||||||
top_label_share -= .4
|
top_label_share -= .4
|
||||||
logo_share = \
|
logo_share = \
|
||||||
Image(source='images/ngletteravatar/{}'.format(self.list_random(avatarlist, subject)),
|
Image(source='images/ngletteravatar/{}'.format(self.getletterimage(avatarlist, subject)),
|
||||||
pos_hint={"center_x": .05, "top": top_logo_share},
|
pos_hint={"center_x": .05, "top": top_logo_share},
|
||||||
size_hint_y=None, height=25)
|
size_hint_y=None, height=25)
|
||||||
button_share = \
|
button_share = \
|
||||||
Button(pos_hint={"x": 0, "top": top_button_share},
|
Button(pos_hint={"x": 0, "top": top_button_share},
|
||||||
size_hint_y=None, height=40, text=subject, multiline=True, background_color=NavigateApp.theme_cls.primary_dark)
|
size_hint_y=None, height=40, text=subject, multiline=True, background_color=NavigateApp.theme_cls.primary_dark)
|
||||||
button_share.bind(on_press=self.change_screen)
|
button_share.bind(on_press=self.getInboxMessageDetail)
|
||||||
fl = FloatLayout(size_hint_y=None, height=25)
|
fl = FloatLayout(size_hint_y=None, height=25)
|
||||||
fl.add_widget(button_share)
|
fl.add_widget(button_share)
|
||||||
fl.add_widget(logo_share)
|
fl.add_widget(logo_share)
|
||||||
|
@ -106,7 +119,7 @@ class Inbox(Screen):
|
||||||
size_hint_y=None)
|
size_hint_y=None)
|
||||||
box_share.add_widget(label_share)
|
box_share.add_widget(label_share)
|
||||||
|
|
||||||
def list_random(self, ran, subject):
|
def getletterimage(self, ran, subject):
|
||||||
limit = 5
|
limit = 5
|
||||||
for x in subject[:limit]:
|
for x in subject[:limit]:
|
||||||
if '{}.png'.format(x.lower()) in ran:
|
if '{}.png'.format(x.lower()) in ran:
|
||||||
|
@ -118,8 +131,11 @@ class Inbox(Screen):
|
||||||
return ran[0]
|
return ran[0]
|
||||||
break
|
break
|
||||||
|
|
||||||
def change_screen(self, instance):
|
def getInboxMessageDetail(self, instance):
|
||||||
|
try:
|
||||||
self.manager.current = 'page'
|
self.manager.current = 'page'
|
||||||
|
except AttributeError:
|
||||||
|
self.parent.manager.current = 'page'
|
||||||
print('I am {}'.format(instance.text))
|
print('I am {}'.format(instance.text))
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,16 +148,71 @@ class AddressSuccessful(Screen):
|
||||||
|
|
||||||
|
|
||||||
class Sent(Screen):
|
class Sent(Screen):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Sent, self).__init__(**kwargs)
|
super(Sent, self).__init__(*args, **kwargs)
|
||||||
val_y = .1
|
global belonging
|
||||||
val_z = 0
|
if belonging == '':
|
||||||
my_box1 = BoxLayout(orientation='vertical')
|
belonging = Navigator().ids.btn.text
|
||||||
for i in range(1, 5):
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
my_box1.add_widget(Label(text="I am in sent", size_hint=(.3, .1), pos_hint={
|
|
||||||
'x': val_z, 'top': val_y}, color=(0, 0, 0, 1), background_color=(0, 0, 0, 0)))
|
def init_ui(self, dt=0):
|
||||||
val_y += .1
|
global belonging
|
||||||
self.add_widget(my_box1)
|
self.orientation = "vertical"
|
||||||
|
self.sentaccounts(self.ids.box_share)
|
||||||
|
|
||||||
|
def sentaccounts(self, box_share):
|
||||||
|
account = belonging
|
||||||
|
folder = 'inbox'
|
||||||
|
self.loadSent(account, box_share, 'All', '')
|
||||||
|
|
||||||
|
def loadSent(self, account, box_share, where="", what=""):
|
||||||
|
top_logo_share = 1.01
|
||||||
|
top_button_share = 1.1
|
||||||
|
top_label_share = 1.4
|
||||||
|
xAddress = 'fromaddress'
|
||||||
|
queryreturn = kivy_helper_search.search_sql(xAddress, account, "sent", where, what, False)
|
||||||
|
if queryreturn:
|
||||||
|
for row in queryreturn:
|
||||||
|
toAddress, fromAddress, subject, status, ackdata, lastactiontime = row
|
||||||
|
top_logo_share -= .4
|
||||||
|
top_button_share -= .4
|
||||||
|
top_label_share -= .4
|
||||||
|
logo_share = \
|
||||||
|
Image(source='images/ngletteravatar/{}'.format(self.getletterimage(avatarlist, subject)),
|
||||||
|
pos_hint={"center_x": .05, "top": top_logo_share},
|
||||||
|
size_hint_y=None, height=25)
|
||||||
|
button_share = \
|
||||||
|
Button(pos_hint={"x": 0, "top": top_button_share},
|
||||||
|
size_hint_y=None, height=40, text=subject, multiline=True, background_color=NavigateApp.theme_cls.primary_dark)
|
||||||
|
button_share.bind(on_press=self.getSentMessageDetail)
|
||||||
|
fl = FloatLayout(size_hint_y=None, height=25)
|
||||||
|
fl.add_widget(button_share)
|
||||||
|
fl.add_widget(logo_share)
|
||||||
|
box_share.add_widget(fl)
|
||||||
|
else:
|
||||||
|
label_share = \
|
||||||
|
Label(text="yet you dont have any emails received", pos_hint={"x": 0, "top": top_label_share},
|
||||||
|
size_hint_y=None)
|
||||||
|
box_share.add_widget(label_share)
|
||||||
|
|
||||||
|
def getletterimage(self, ran, subject):
|
||||||
|
limit = 5
|
||||||
|
for x in subject[:limit]:
|
||||||
|
if '{}.png'.format(x.lower()) in ran:
|
||||||
|
return '{}.png'.format(x.lower())
|
||||||
|
elif '{}.jpg'.format(x.lower()) in ran:
|
||||||
|
return '{}.jpg'.format(x.lower())
|
||||||
|
if x == limit:
|
||||||
|
random.shuffle(ran)
|
||||||
|
return ran[0]
|
||||||
|
break
|
||||||
|
|
||||||
|
def getSentMessageDetail(self, instance):
|
||||||
|
try:
|
||||||
|
self.manager.current = 'page'
|
||||||
|
except AttributeError:
|
||||||
|
self.parent.manager.current = 'page'
|
||||||
|
print('I am {}'.format(instance.text))
|
||||||
|
|
||||||
|
|
||||||
class Trash(Screen):
|
class Trash(Screen):
|
||||||
|
|
Reference in New Issue
Block a user