Implementing swipe left to right delete feature for inbox, sent message to be archieved in Kivy
This commit is contained in:
parent
d8a5b9356f
commit
f98acd3ae0
|
@ -1,7 +1,7 @@
|
||||||
#:import la kivy.adapters.listadapter
|
#:import la kivy.adapters.listadapter
|
||||||
#:import factory kivy.factory
|
#:import factory kivy.factory
|
||||||
#:import mpybit bitmessagekivy.mpybit
|
#:import mpybit bitmessagekivy.mpybit
|
||||||
#:import ListItemButton kivy.uix.listview.ListItemButton
|
#:import C kivy.utils.get_color_from_hex
|
||||||
|
|
||||||
<Navigator>:
|
<Navigator>:
|
||||||
id: nav_drawer
|
id: nav_drawer
|
||||||
|
@ -78,63 +78,114 @@ BoxLayout:
|
||||||
id:sc9
|
id:sc9
|
||||||
|
|
||||||
Button:
|
Button:
|
||||||
|
id:create
|
||||||
height:100
|
height:100
|
||||||
size_hint_y: 0.2
|
size_hint_y: 0.13
|
||||||
size_hint_x: 0.1
|
size_hint_x: 0.1
|
||||||
pos_hint: {'x': 0.85, 'y': 0.5}
|
pos_hint: {'x': 0.85, 'y': 0.5}
|
||||||
background_color: (0,0,0,0)
|
background_color: (0,0,0,0)
|
||||||
on_press: scr_mngr.current = 'create'
|
on_press: scr_mngr.current = 'create'
|
||||||
Image:
|
Image:
|
||||||
source: 'images/plus.png'
|
source: 'images/plus.png'
|
||||||
y: self.parent.y
|
y: self.parent.y - 7.5
|
||||||
x: self.parent.x + self.parent.width - 50
|
x: self.parent.x + self.parent.width - 50
|
||||||
size: 70, 70
|
size: 70, 70
|
||||||
|
|
||||||
<ListItemButton>:
|
<SwipeButton@Carousel>:
|
||||||
height: dp(25)
|
text: ''
|
||||||
size_hint: (1,.1)
|
size_hint_y: None
|
||||||
selected_color: 0,0,0,0
|
height: 48
|
||||||
deselected_color: 0,0,0,0
|
ignore_perpendicular_swipes: True
|
||||||
color: 0, 0,0, 1
|
data_index: 0
|
||||||
|
min_move: 20 / self.width
|
||||||
|
|
||||||
|
on__offset: app.update_index(root.data_index, self.index)
|
||||||
|
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: C('FFFFFF33')
|
||||||
|
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
|
||||||
|
Line:
|
||||||
|
rectangle: self.pos + self.size
|
||||||
|
|
||||||
|
Button:
|
||||||
|
text: 'delete ({}:{})'.format(root.text, root.data_index)
|
||||||
|
on_press: app.delete(root.data_index)
|
||||||
|
|
||||||
|
Button:
|
||||||
|
text: root.text
|
||||||
|
on_press: app.getInboxMessageDetail(self.text)
|
||||||
|
|
||||||
|
Button:
|
||||||
|
text: 'archive'
|
||||||
|
on_press: app.archive(root.data_index)
|
||||||
|
|
||||||
<Inbox>:
|
<Inbox>:
|
||||||
name: 'inbox'
|
name: 'inbox'
|
||||||
ScrollView:
|
RecycleView:
|
||||||
id:scrollid
|
data: root.data
|
||||||
GridLayout:
|
viewclass: 'SwipeButton'
|
||||||
id: box_share
|
do_scroll_x: False
|
||||||
cols: 1
|
scroll_timeout: 100
|
||||||
|
|
||||||
|
RecycleBoxLayout:
|
||||||
|
id:rc
|
||||||
|
orientation: 'vertical'
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
spacing: 10
|
|
||||||
padding: 10
|
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
canvas:
|
default_size_hint: 1, None
|
||||||
|
canvas.before:
|
||||||
Color:
|
Color:
|
||||||
rgb: 30,144,255
|
rgba: 0,0,0, 1
|
||||||
Rectangle:
|
Rectangle:
|
||||||
pos: self.pos
|
pos: self.pos
|
||||||
size: self.size
|
size: self.size
|
||||||
|
|
||||||
<Sent>:
|
<Sent>:
|
||||||
name: 'sent'
|
name: 'sent'
|
||||||
ScrollView:
|
RecycleView:
|
||||||
id:scrollid
|
data: root.data
|
||||||
GridLayout:
|
viewclass: 'SwipeButton'
|
||||||
id: box_share
|
do_scroll_x: False
|
||||||
cols: 1
|
scroll_timeout: 100
|
||||||
|
|
||||||
|
RecycleBoxLayout:
|
||||||
|
id:rc
|
||||||
|
orientation: 'vertical'
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
spacing: 10
|
|
||||||
padding: 10
|
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
canvas:
|
default_size_hint: 1, None
|
||||||
|
canvas.before:
|
||||||
Color:
|
Color:
|
||||||
rgb: 30,144,255
|
rgba: 0,0,0, 1
|
||||||
Rectangle:
|
Rectangle:
|
||||||
pos: self.pos
|
pos: self.pos
|
||||||
size: self.size
|
size: self.size
|
||||||
|
|
||||||
<Trash>:
|
<Trash>:
|
||||||
name: 'trash'
|
name: 'trash'
|
||||||
|
RecycleView:
|
||||||
|
data: root.data
|
||||||
|
viewclass: 'SwipeButton'
|
||||||
|
do_scroll_x: False
|
||||||
|
scroll_timeout: 100
|
||||||
|
|
||||||
|
RecycleBoxLayout:
|
||||||
|
id:rc
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
default_size_hint: 1, None
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: 0,0,0, 1
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
|
||||||
<Dialog>:
|
<Dialog>:
|
||||||
name: 'dialog'
|
name: 'dialog'
|
||||||
|
|
|
@ -25,7 +25,8 @@ 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, sqlQuery
|
from helper_sql import sqlExecute
|
||||||
|
|
||||||
statusIconColor = 'red'
|
statusIconColor = 'red'
|
||||||
avatarlist = os.listdir("images/ngletteravatar")
|
avatarlist = os.listdir("images/ngletteravatar")
|
||||||
global belonging
|
global belonging
|
||||||
|
@ -48,10 +49,13 @@ class NavigateApp(App, TextInput):
|
||||||
belonging = text
|
belonging = text
|
||||||
main_widget.ids.sc1.clear_widgets()
|
main_widget.ids.sc1.clear_widgets()
|
||||||
main_widget.ids.sc2.clear_widgets()
|
main_widget.ids.sc2.clear_widgets()
|
||||||
|
main_widget.ids.sc3.clear_widgets()
|
||||||
main_widget.ids.sc1.add_widget(Inbox())
|
main_widget.ids.sc1.add_widget(Inbox())
|
||||||
main_widget.ids.sc2.add_widget(Sent())
|
main_widget.ids.sc2.add_widget(Sent())
|
||||||
|
main_widget.ids.sc3.add_widget(Trash())
|
||||||
Inbox()
|
Inbox()
|
||||||
Sent()
|
Sent()
|
||||||
|
Trash()
|
||||||
|
|
||||||
def say_exit(self):
|
def say_exit(self):
|
||||||
print("**************************EXITING FROM APPLICATION*****************************")
|
print("**************************EXITING FROM APPLICATION*****************************")
|
||||||
|
@ -64,6 +68,58 @@ class NavigateApp(App, TextInput):
|
||||||
elif name == "values":
|
elif name == "values":
|
||||||
return BMConfigParser().addresses()
|
return BMConfigParser().addresses()
|
||||||
|
|
||||||
|
def update_index(self, data_index, index):
|
||||||
|
if self.root.ids.scr_mngr.current == 'inbox':
|
||||||
|
self.root.ids.sc1.data[data_index]['index'] = index
|
||||||
|
elif self.root.ids.scr_mngr.current == 'sent':
|
||||||
|
self.root.ids.sc2.data[data_index]['index'] = index
|
||||||
|
elif self.root.ids.scr_mngr.current == 'trash':
|
||||||
|
self.root.ids.sc3.data[data_index]['index'] = index
|
||||||
|
|
||||||
|
def delete(self, data_index):
|
||||||
|
print("delete {}".format(data_index))
|
||||||
|
self._remove(data_index)
|
||||||
|
|
||||||
|
def archive(self, data_index):
|
||||||
|
print("archive {}".format(data_index))
|
||||||
|
self._remove(data_index)
|
||||||
|
|
||||||
|
def _remove(self, data_index):
|
||||||
|
if self.root.ids.scr_mngr.current == 'inbox':
|
||||||
|
self.root.ids.sc1.data.pop(data_index)
|
||||||
|
self.root.ids.sc1.data = [{
|
||||||
|
'data_index': i,
|
||||||
|
'index': d['index'],
|
||||||
|
'height': d['height'],
|
||||||
|
'text': d['text']}
|
||||||
|
for i, d in enumerate(self.root.ids.sc1.data)
|
||||||
|
]
|
||||||
|
elif self.root.ids.scr_mngr.current == 'sent':
|
||||||
|
self.root.ids.sc2.data.pop(data_index)
|
||||||
|
self.root.ids.sc2.data = [{
|
||||||
|
'data_index': i,
|
||||||
|
'index': d['index'],
|
||||||
|
'height': d['height'],
|
||||||
|
'text': d['text']}
|
||||||
|
for i, d in enumerate(self.root.ids.sc2.data)
|
||||||
|
]
|
||||||
|
elif self.root.ids.scr_mngr.current == 'trash':
|
||||||
|
self.root.ids.sc3.data.pop(data_index)
|
||||||
|
self.root.ids.sc3.data = [{
|
||||||
|
'data_index': i,
|
||||||
|
'index': d['index'],
|
||||||
|
'height': d['height'],
|
||||||
|
'text': d['text']}
|
||||||
|
for i, d in enumerate(self.root.ids.sc3.data)
|
||||||
|
]
|
||||||
|
|
||||||
|
def getInboxMessageDetail(self, instance):
|
||||||
|
try:
|
||||||
|
self.root.ids.scr_mngr.current = 'page'
|
||||||
|
except AttributeError:
|
||||||
|
self.parent.manager.current = 'page'
|
||||||
|
print('Message Clicked {}'.format(instance))
|
||||||
|
|
||||||
|
|
||||||
class Navigator(NavigationDrawer):
|
class Navigator(NavigationDrawer):
|
||||||
image_source = StringProperty('images/qidenticon_two.png')
|
image_source = StringProperty('images/qidenticon_two.png')
|
||||||
|
@ -71,6 +127,8 @@ class Navigator(NavigationDrawer):
|
||||||
|
|
||||||
|
|
||||||
class Inbox(Screen):
|
class Inbox(Screen):
|
||||||
|
data = ListProperty()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Inbox, self).__init__(*args, **kwargs)
|
super(Inbox, self).__init__(*args, **kwargs)
|
||||||
global belonging
|
global belonging
|
||||||
|
@ -81,62 +139,31 @@ class Inbox(Screen):
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
global belonging
|
global belonging
|
||||||
self.orientation = "vertical"
|
self.orientation = "vertical"
|
||||||
self.inboxaccounts(self.ids.box_share)
|
self.inboxaccounts()
|
||||||
|
|
||||||
def inboxaccounts(self, box_share):
|
def inboxaccounts(self):
|
||||||
account = belonging
|
account = belonging
|
||||||
folder = 'inbox'
|
folder = 'inbox'
|
||||||
self.loadinboxlist(account, folder, box_share, 'All', '')
|
self.loadMessagelist(account, folder, 'All', '')
|
||||||
|
|
||||||
def loadinboxlist(self, account, folder, box_share, where="", what="", unreadOnly=False):
|
def loadMessagelist(self, account, folder, where="", what="", unreadOnly=False):
|
||||||
top_logo_share = 1.01
|
|
||||||
top_button_share = 1.1
|
|
||||||
top_label_share = 1.4
|
|
||||||
xAddress = "toaddress"
|
xAddress = "toaddress"
|
||||||
|
|
||||||
queryreturn = kivy_helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
queryreturn = kivy_helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
||||||
if queryreturn:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
self.data = [{
|
||||||
msgfolder, msgid, toAddress, fromAddress, subject, received, read = row
|
'data_index': i,
|
||||||
top_logo_share -= .4
|
'index': 1,
|
||||||
top_button_share -= .4
|
'height': 48,
|
||||||
top_label_share -= .4
|
'text': row[4]}
|
||||||
logo_share = \
|
for i, row in enumerate(queryreturn)
|
||||||
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.getInboxMessageDetail)
|
|
||||||
fl = FloatLayout(size_hint_y=None, height=25)
|
|
||||||
fl.add_widget(button_share)
|
|
||||||
fl.add_widget(logo_share)
|
|
||||||
box_share.add_widget(fl)
|
|
||||||
else:
|
else:
|
||||||
label_share = \
|
self.data = [{
|
||||||
Label(text="yet you dont have any emails received", pos_hint={"x": 0, "top": top_label_share},
|
'data_index': 1,
|
||||||
size_hint_y=None)
|
'index': 1,
|
||||||
box_share.add_widget(label_share)
|
'height': 48,
|
||||||
|
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
||||||
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 getInboxMessageDetail(self, instance):
|
|
||||||
try:
|
|
||||||
self.manager.current = 'page'
|
|
||||||
except AttributeError:
|
|
||||||
self.parent.manager.current = 'page'
|
|
||||||
print('I am {}'.format(instance.text))
|
|
||||||
|
|
||||||
|
|
||||||
class Page(Screen):
|
class Page(Screen):
|
||||||
|
@ -148,6 +175,8 @@ class AddressSuccessful(Screen):
|
||||||
|
|
||||||
|
|
||||||
class Sent(Screen):
|
class Sent(Screen):
|
||||||
|
data = ListProperty()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Sent, self).__init__(*args, **kwargs)
|
super(Sent, self).__init__(*args, **kwargs)
|
||||||
global belonging
|
global belonging
|
||||||
|
@ -158,54 +187,31 @@ class Sent(Screen):
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
global belonging
|
global belonging
|
||||||
self.orientation = "vertical"
|
self.orientation = "vertical"
|
||||||
self.sentaccounts(self.ids.box_share)
|
self.sentaccounts()
|
||||||
|
|
||||||
def sentaccounts(self, box_share):
|
def sentaccounts(self):
|
||||||
account = belonging
|
account = belonging
|
||||||
folder = 'inbox'
|
folder = 'inbox'
|
||||||
self.loadSent(account, box_share, 'All', '')
|
self.loadSent(account, 'All', '')
|
||||||
|
|
||||||
def loadSent(self, account, box_share, where="", what=""):
|
def loadSent(self, account, where="", what=""):
|
||||||
top_logo_share = 1.01
|
|
||||||
top_button_share = 1.1
|
|
||||||
top_label_share = 1.4
|
|
||||||
xAddress = 'fromaddress'
|
xAddress = 'fromaddress'
|
||||||
queryreturn = kivy_helper_search.search_sql(xAddress, account, "sent", where, what, False)
|
queryreturn = kivy_helper_search.search_sql(xAddress, account, "sent", where, what, False)
|
||||||
if queryreturn:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
self.data = [{
|
||||||
toAddress, fromAddress, subject, status, ackdata, lastactiontime = row
|
'data_index': i,
|
||||||
top_logo_share -= .4
|
'index': 1,
|
||||||
top_button_share -= .4
|
'height': 48,
|
||||||
top_label_share -= .4
|
'text': row[2]}
|
||||||
logo_share = \
|
for i, row in enumerate(queryreturn)
|
||||||
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:
|
else:
|
||||||
label_share = \
|
self.data = [{
|
||||||
Label(text="yet you dont have any emails received", pos_hint={"x": 0, "top": top_label_share},
|
'data_index': 1,
|
||||||
size_hint_y=None)
|
'index': 1,
|
||||||
box_share.add_widget(label_share)
|
'height': 48,
|
||||||
|
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
||||||
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):
|
def getSentMessageDetail(self, instance):
|
||||||
try:
|
try:
|
||||||
|
@ -216,16 +222,43 @@ class Sent(Screen):
|
||||||
|
|
||||||
|
|
||||||
class Trash(Screen):
|
class Trash(Screen):
|
||||||
def __init__(self, **kwargs):
|
data = ListProperty()
|
||||||
super(Trash, self).__init__(**kwargs)
|
|
||||||
val_y = .1
|
def __init__(self, *args, **kwargs):
|
||||||
val_z = 0
|
super(Trash, self).__init__(*args, **kwargs)
|
||||||
my_box1 = BoxLayout(orientation='vertical')
|
global belonging
|
||||||
for i in range(1, 5):
|
if belonging == '':
|
||||||
my_box1.add_widget(Label(text="I am in trash", size_hint=(.3, .1), pos_hint={
|
belonging = Navigator().ids.btn.text
|
||||||
'x': val_z, 'top': val_y}, color=(0, 0, 0, 1), background_color=(0, 0, 0, 0)))
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
val_y += .1
|
|
||||||
self.add_widget(my_box1)
|
def init_ui(self, dt=0):
|
||||||
|
global belonging
|
||||||
|
self.orientation = "vertical"
|
||||||
|
self.inboxaccounts()
|
||||||
|
|
||||||
|
def inboxaccounts(self):
|
||||||
|
account = belonging
|
||||||
|
folder = 'trash'
|
||||||
|
self.loadTrashlist(account, folder, 'All', '')
|
||||||
|
|
||||||
|
def loadTrashlist(self, account, folder, where="", what="", unreadOnly=False):
|
||||||
|
xAddress = "toaddress"
|
||||||
|
queryreturn = kivy_helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
||||||
|
if queryreturn:
|
||||||
|
self.data = [{
|
||||||
|
'data_index': i,
|
||||||
|
'index': 1,
|
||||||
|
'height': 48,
|
||||||
|
'text': row[4]}
|
||||||
|
for i, row in enumerate(queryreturn)
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
self.data = [{
|
||||||
|
'data_index': 1,
|
||||||
|
'index': 1,
|
||||||
|
'height': 48,
|
||||||
|
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Dialog(Screen):
|
class Dialog(Screen):
|
||||||
|
@ -309,6 +342,7 @@ class Create(Screen):
|
||||||
class NewIdentity(Screen):
|
class NewIdentity(Screen):
|
||||||
is_active = BooleanProperty(False)
|
is_active = BooleanProperty(False)
|
||||||
checked = StringProperty("")
|
checked = StringProperty("")
|
||||||
|
# self.manager.parent.ids.create.children[0].source = 'images/plus-4-xxl.png'
|
||||||
|
|
||||||
def generateaddress(self):
|
def generateaddress(self):
|
||||||
if self.checked == 'use a random number generator to make an address':
|
if self.checked == 'use a random number generator to make an address':
|
||||||
|
|
Reference in New Issue
Block a user