Loadmessage list feature with current account get and ngletters images icon
41
src/bitmessagekivy/kivy_helper_search.py
Normal 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)
|
|
@ -10,8 +10,8 @@
|
|||
pos_hint:{"x":0,"y":.3}
|
||||
id: btn
|
||||
background_color: app.theme_cls.primary_dark
|
||||
text: '<address>'
|
||||
values: app.showmeaddresses()
|
||||
text: app.showmeaddresses(name='text')
|
||||
values: app.showmeaddresses(name='values')
|
||||
|
||||
NavigationDrawerIconButton:
|
||||
icon: 'email-open'
|
||||
|
@ -148,8 +148,8 @@ BoxLayout:
|
|||
pos_hint: {"x":0,"top":1.}
|
||||
pos: 10,10
|
||||
id: spinner_id
|
||||
text: '<select>'
|
||||
values: app.showmeaddresses()
|
||||
text: app.showmeaddresses(name='text')
|
||||
values: app.showmeaddresses(name='values')
|
||||
|
||||
BoxLayout:
|
||||
size_hint_y: None
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import kivy_helper_search
|
||||
import queues
|
||||
import random
|
||||
import shutdown
|
||||
|
@ -24,7 +25,7 @@ from kivy.uix.widget import Widget
|
|||
from bmconfigparser import BMConfigParser
|
||||
from helper_ackPayload import genAckPayload
|
||||
from addresses import decodeAddress, addBMIfNotPresent
|
||||
from helper_sql import sqlExecute
|
||||
from helper_sql import sqlExecute, sqlQuery
|
||||
statusIconColor = 'red'
|
||||
avatarlist = os.listdir("images/ngletteravatar")
|
||||
|
||||
|
@ -39,12 +40,18 @@ class NavigateApp(App, TextInput):
|
|||
self.nav_drawer = Navigator()
|
||||
return main_widget
|
||||
|
||||
# def setCurrentAccount(self, text):
|
||||
# self.ids.btn.text = text
|
||||
|
||||
def say_exit(self):
|
||||
print("**************************EXITING FROM APPLICATION*****************************")
|
||||
App.get_running_app().stop()
|
||||
shutdown.doCleanShutdown()
|
||||
|
||||
def showmeaddresses(self):
|
||||
def showmeaddresses(self, name="text"):
|
||||
if name == "text":
|
||||
return BMConfigParser().addresses()[0]
|
||||
elif name == "values":
|
||||
return BMConfigParser().addresses()
|
||||
|
||||
|
||||
|
@ -64,33 +71,52 @@ class Inbox(Screen):
|
|||
self.create_button(self.ids.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_button_share = 1.1
|
||||
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_button_share -= .4
|
||||
top_label_share -= .4
|
||||
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},
|
||||
size_hint_y=None, height=25)
|
||||
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)
|
||||
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.add_widget(button_share)
|
||||
fl.add_widget(logo_share)
|
||||
fl.add_widget(label_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 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)
|
||||
return ran[0]
|
||||
break
|
||||
|
||||
def change_screen(self, instance):
|
||||
self.manager.current = 'page'
|
||||
|
|
Before Width: | Height: | Size: 483 B |
BIN
src/images/ngletteravatar/Galleryr_rcirclelogo_Small.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 449 B |
BIN
src/images/ngletteravatar/x.jpg
Normal file
After Width: | Height: | Size: 8.9 KiB |