Loadmessage list feature with current account get and ngletters images icon

This commit is contained in:
surbhi 2018-08-07 11:44:14 +05:30
parent b1f7489b09
commit c163001ee8
No known key found for this signature in database
GPG Key ID: 88928762974D3618
9 changed files with 97 additions and 30 deletions

View File

@ -0,0 +1,41 @@
from helper_sql import *
def search_sql(xAddress = "toaddress", account = None, folder = "inbox", where = None, what = None, unreadOnly = False):
if what is not None and what != "":
what = "%" + what + "%"
else:
what = None
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
FROM inbox '''
sqlStatementParts = []
sqlArguments = []
if account is not None:
if xAddress == 'both':
sqlStatementParts.append("(fromaddress = ? OR toaddress = ?)")
sqlArguments.append(account)
sqlArguments.append(account)
else:
sqlStatementParts.append(xAddress + " = ? ")
sqlArguments.append(account)
if folder is not None:
if folder == "new":
folder = "inbox"
unreadOnly = True
sqlStatementParts.append("folder = ? ")
sqlArguments.append(folder)
else:
sqlStatementParts.append("folder != ?")
sqlArguments.append("trash")
if what is not None:
sqlStatementParts.append("%s LIKE ?" % (where))
sqlArguments.append(what)
if unreadOnly:
sqlStatementParts.append("read = 0")
if len(sqlStatementParts) > 0:
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
if folder == "sent":
sqlStatementBase += " ORDER BY lastactiontime"
return sqlQuery(sqlStatementBase, sqlArguments)

View File

@ -10,8 +10,8 @@
pos_hint:{"x":0,"y":.3} pos_hint:{"x":0,"y":.3}
id: btn id: btn
background_color: app.theme_cls.primary_dark background_color: app.theme_cls.primary_dark
text: '<address>' text: app.showmeaddresses(name='text')
values: app.showmeaddresses() values: app.showmeaddresses(name='values')
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email-open' icon: 'email-open'
@ -148,8 +148,8 @@ BoxLayout:
pos_hint: {"x":0,"top":1.} pos_hint: {"x":0,"top":1.}
pos: 10,10 pos: 10,10
id: spinner_id id: spinner_id
text: '<select>' text: app.showmeaddresses(name='text')
values: app.showmeaddresses() values: app.showmeaddresses(name='values')
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None

View File

@ -1,4 +1,5 @@
import os import os
import kivy_helper_search
import queues import queues
import random import random
import shutdown import shutdown
@ -24,7 +25,7 @@ from kivy.uix.widget import Widget
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
from addresses import decodeAddress, addBMIfNotPresent from addresses import decodeAddress, addBMIfNotPresent
from helper_sql import sqlExecute from helper_sql import sqlExecute, sqlQuery
statusIconColor = 'red' statusIconColor = 'red'
avatarlist = os.listdir("images/ngletteravatar") avatarlist = os.listdir("images/ngletteravatar")
@ -39,12 +40,18 @@ class NavigateApp(App, TextInput):
self.nav_drawer = Navigator() self.nav_drawer = Navigator()
return main_widget return main_widget
# def setCurrentAccount(self, text):
# self.ids.btn.text = text
def say_exit(self): def say_exit(self):
print("**************************EXITING FROM APPLICATION*****************************") print("**************************EXITING FROM APPLICATION*****************************")
App.get_running_app().stop() App.get_running_app().stop()
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
def showmeaddresses(self): def showmeaddresses(self, name="text"):
if name == "text":
return BMConfigParser().addresses()[0]
elif name == "values":
return BMConfigParser().addresses() return BMConfigParser().addresses()
@ -64,33 +71,52 @@ class Inbox(Screen):
self.create_button(self.ids.box_share) self.create_button(self.ids.box_share)
def create_button(self, box_share): def create_button(self, box_share):
account = Navigator().ids.btn.text
folder = 'inbox'
self.loadMessagelist(account, folder, box_share, 'All', '')
def loadMessagelist(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
for i in range(50): xAddress = "toaddress"
queryreturn = kivy_helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
if queryreturn:
for row in queryreturn:
msgfolder, msgid, toAddress, fromAddress, subject, received, read = row
top_logo_share -= .4 top_logo_share -= .4
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)), Image(source='images/ngletteravatar/{}'.format(self.list_random(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='email_{}'.format(i), 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.change_screen)
label_share = \
Label(text=str(i), pos_hint={"x": 0, "top": top_label_share},
size_hint_y=None)
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)
fl.add_widget(label_share)
box_share.add_widget(fl) 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 list_random(self, ran): def list_random(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) random.shuffle(ran)
return ran[0] return ran[0]
break
def change_screen(self, instance): def change_screen(self, instance):
self.manager.current = 'page' self.manager.current = 'page'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 483 B

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB