2019-09-17 16:44:26 +02:00
|
|
|
"""
|
2020-01-04 15:17:44 +01:00
|
|
|
Bitmessage android(mobile) interface
|
2019-09-17 16:44:26 +02:00
|
|
|
"""
|
2020-01-21 09:09:56 +01:00
|
|
|
# pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument
|
|
|
|
# pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation
|
2019-09-12 11:11:33 +02:00
|
|
|
import os
|
2019-08-17 14:43:10 +02:00
|
|
|
import time
|
2020-01-04 15:17:44 +01:00
|
|
|
from bitmessagekivy import identiconGeneration
|
|
|
|
from bitmessagekivy import kivy_helper_search
|
|
|
|
from bitmessagekivy.uikivysignaler import UIkivySignaler
|
2019-08-17 14:43:10 +02:00
|
|
|
from bmconfigparser import BMConfigParser
|
2019-12-12 15:38:07 +01:00
|
|
|
from functools import partial
|
2019-08-17 14:43:10 +02:00
|
|
|
from helper_sql import sqlExecute, sqlQuery
|
2020-01-09 16:09:01 +01:00
|
|
|
from kivymd.app import MDApp
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.clock import Clock
|
2019-09-12 11:11:33 +02:00
|
|
|
from kivy.core.clipboard import Clipboard
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.core.window import Window
|
2018-07-18 14:49:39 +02:00
|
|
|
from kivy.lang import Builder
|
2020-01-18 11:31:50 +01:00
|
|
|
from kivy.metrics import dp
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.properties import (
|
|
|
|
BooleanProperty,
|
|
|
|
ListProperty,
|
|
|
|
NumericProperty,
|
|
|
|
ObjectProperty,
|
2019-12-12 15:38:07 +01:00
|
|
|
StringProperty
|
|
|
|
)
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.uix.behaviors import FocusBehavior
|
|
|
|
from kivy.uix.boxlayout import BoxLayout
|
|
|
|
from kivy.uix.button import Button
|
|
|
|
from kivy.uix.carousel import Carousel
|
2019-05-09 14:48:29 +02:00
|
|
|
from kivy.uix.image import Image
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.uix.label import Label
|
|
|
|
from kivy.uix.popup import Popup
|
|
|
|
from kivy.uix.recycleboxlayout import RecycleBoxLayout
|
|
|
|
from kivy.uix.recycleview import RecycleView
|
|
|
|
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
|
|
|
|
from kivy.uix.recycleview.views import RecycleDataViewBehavior
|
2019-08-03 13:49:28 +02:00
|
|
|
from kivy.uix.screenmanager import Screen
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.uix.spinner import Spinner
|
|
|
|
from kivy.uix.textinput import TextInput
|
|
|
|
from kivy.utils import platform
|
2019-10-01 16:49:03 +02:00
|
|
|
from kivymd.uix.button import MDIconButton
|
2019-12-23 12:18:37 +01:00
|
|
|
from kivymd.uix.dialog import MDDialog
|
2019-10-01 16:49:03 +02:00
|
|
|
from kivymd.uix.label import MDLabel
|
|
|
|
from kivymd.uix.list import (
|
2019-08-17 14:43:10 +02:00
|
|
|
ILeftBody,
|
|
|
|
ILeftBodyTouch,
|
|
|
|
IRightBodyTouch,
|
|
|
|
TwoLineAvatarIconListItem,
|
2019-12-26 16:56:04 +01:00
|
|
|
OneLineIconListItem,
|
2020-01-18 11:31:50 +01:00
|
|
|
OneLineAvatarIconListItem,
|
|
|
|
OneLineListItem
|
2019-12-12 15:38:07 +01:00
|
|
|
)
|
2020-01-09 16:09:01 +01:00
|
|
|
# from kivymd.uix.navigationdrawer import (
|
|
|
|
# MDNavigationDrawer,
|
|
|
|
# NavigationDrawerHeaderBase
|
|
|
|
# )
|
2020-01-29 17:14:39 +01:00
|
|
|
from kivymd.uix.selectioncontrol import MDCheckbox, MDSwitch
|
2020-02-19 16:46:13 +01:00
|
|
|
from kivymd.uix.chip import MDChip
|
2019-10-21 11:15:31 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
import queues
|
|
|
|
from semaphores import kivyuisignaler
|
2019-10-21 11:15:31 +02:00
|
|
|
|
2019-08-17 14:43:10 +02:00
|
|
|
import state
|
2020-01-04 15:17:44 +01:00
|
|
|
from addresses import decodeAddress
|
2020-02-19 16:46:13 +01:00
|
|
|
from kivy.uix.modalview import ModalView
|
|
|
|
from datetime import datetime
|
2020-01-28 11:19:11 +01:00
|
|
|
from kivy.config import Config
|
|
|
|
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
|
2020-01-21 09:09:56 +01:00
|
|
|
# pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
KVFILES = [
|
|
|
|
'settings', 'popup', 'allmails', 'draft',
|
|
|
|
'maildetail', 'common_widgets', 'addressbook',
|
|
|
|
'myaddress', 'composer', 'payment', 'sent',
|
2020-03-18 14:00:45 +01:00
|
|
|
'network', 'login', 'credits', 'trash', 'inbox'
|
2020-01-20 13:59:02 +01:00
|
|
|
]
|
2020-01-10 15:07:43 +01:00
|
|
|
|
|
|
|
|
2019-08-13 09:28:15 +02:00
|
|
|
def toast(text):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Method will display the toast message"""
|
2020-01-04 15:17:44 +01:00
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
from kivymd.toast.kivytoast import toast
|
2019-10-18 16:00:43 +02:00
|
|
|
toast(text)
|
2019-08-13 09:28:15 +02:00
|
|
|
return
|
|
|
|
|
2019-08-13 13:54:04 +02:00
|
|
|
|
2020-01-18 11:31:50 +01:00
|
|
|
def showLimitedCnt(total_msg):
|
|
|
|
"""This method set the total count limit in badge_text"""
|
|
|
|
return "99+" if total_msg > 99 else str(total_msg)
|
|
|
|
|
|
|
|
|
2020-01-28 11:19:11 +01:00
|
|
|
def ShowTimeHistoy(act_time):
|
|
|
|
"""This method is used to return the message sent or receive time"""
|
|
|
|
action_time = datetime.fromtimestamp(int(act_time))
|
|
|
|
crnt_date = datetime.now()
|
|
|
|
duration = crnt_date - action_time
|
2020-03-18 11:37:02 +01:00
|
|
|
display_data = (
|
|
|
|
action_time.strftime('%d/%m/%Y')
|
2020-01-28 11:19:11 +01:00
|
|
|
if duration.days >= 365 else action_time.strftime('%I:%M %p').lstrip('0')
|
|
|
|
if duration.days == 0 and crnt_date.strftime('%d/%m/%Y') == action_time.strftime('%d/%m/%Y')
|
2020-03-18 11:37:02 +01:00
|
|
|
else action_time.strftime("%d %b")
|
|
|
|
)
|
2020-01-28 11:19:11 +01:00
|
|
|
return display_data
|
|
|
|
|
|
|
|
|
2020-03-18 11:37:02 +01:00
|
|
|
def AddTimeWidget(time): # pylint: disable=redefined-outer-name
|
2020-01-28 11:19:11 +01:00
|
|
|
"""This method is used to create TimeWidget"""
|
|
|
|
action_time = BadgeText(
|
2020-03-18 11:37:02 +01:00
|
|
|
size_hint=(None, None),
|
|
|
|
text=str(ShowTimeHistoy(time)),
|
2020-01-28 11:19:11 +01:00
|
|
|
halign='right',
|
|
|
|
font_style='Caption',
|
2020-03-18 11:37:02 +01:00
|
|
|
size=[65, 70])
|
2020-01-28 11:19:11 +01:00
|
|
|
return action_time
|
|
|
|
|
|
|
|
|
2020-02-19 16:46:13 +01:00
|
|
|
def chipTag(text):
|
|
|
|
"""This method is used for showing chip tag"""
|
|
|
|
obj = MDChip()
|
2020-03-18 11:37:02 +01:00
|
|
|
obj.size_hint = (None, None)
|
|
|
|
obj.label = text
|
|
|
|
obj.icon = ''
|
|
|
|
obj.pos_hint = {'center_x': .96, 'center_y': .2}
|
|
|
|
obj.height = dp(18)
|
|
|
|
obj.radius = 8
|
2020-02-19 16:46:13 +01:00
|
|
|
return obj
|
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Inbox(Screen):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Inbox Screen uses screen to show widgets of screens"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
queryreturn = ListProperty()
|
|
|
|
has_refreshed = True
|
|
|
|
account = StringProperty()
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Method Parsing the address"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(Inbox, self).__init__(*args, **kwargs)
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def set_defaultAddress():
|
2019-12-20 15:07:31 +01:00
|
|
|
"""This method set's default address"""
|
2019-05-13 13:31:33 +02:00
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def init_ui(self, dt=0):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Clock schdule for method inbox accounts"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.loadMessagelist()
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def loadMessagelist(self, where="", what=""):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Load Inbox list for Inbox messages"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_defaultAddress()
|
|
|
|
self.account = state.association
|
2019-08-02 11:11:33 +02:00
|
|
|
if state.searcing_text:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.children[2].children[0].children[0].scroll_y = 1.0
|
2019-08-02 11:11:33 +02:00
|
|
|
where = ['subject', 'message']
|
|
|
|
what = state.searcing_text
|
2019-05-13 13:31:33 +02:00
|
|
|
xAddress = 'toaddress'
|
|
|
|
data = []
|
2020-01-28 11:19:11 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.inboxDataQuery(xAddress, where, what)
|
2019-12-23 15:48:03 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
if self.queryreturn:
|
2019-12-23 15:48:03 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'Inbox'
|
2019-12-12 15:38:07 +01:00
|
|
|
state.kivyapp.get_inbox_count()
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_inboxCount(state.inbox_count)
|
2019-12-12 15:38:07 +01:00
|
|
|
for mail in self.queryreturn:
|
|
|
|
# third_text = mail[3].replace('\n', ' ')
|
2020-03-18 11:37:02 +01:00
|
|
|
body = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
|
|
|
subject = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
2019-08-03 13:49:28 +02:00
|
|
|
data.append({
|
|
|
|
'text': mail[4].strip(),
|
2020-03-02 11:42:15 +01:00
|
|
|
'secondary_text': (subject[:50] + '........' if len(
|
2020-03-18 11:37:02 +01:00
|
|
|
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace(
|
|
|
|
'\t', '').replace(' ', ''),
|
2020-01-28 11:19:11 +01:00
|
|
|
'msgid': mail[1], 'received': mail[6]})
|
2020-03-02 11:42:15 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
self.has_refreshed = True
|
|
|
|
self.set_mdList(data)
|
|
|
|
self.children[2].children[0].children[0].bind(
|
|
|
|
scroll_y=self.check_scroll_y)
|
2019-05-09 14:48:29 +02:00
|
|
|
else:
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_inboxCount('0')
|
2019-08-05 12:19:19 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-08-05 12:19:19 +02:00
|
|
|
theme_text_color='Primary',
|
2019-08-13 13:54:04 +02:00
|
|
|
text="No message found!" if state.searcing_text
|
|
|
|
else "yet no message for this account!!!!!!!!!!!!!",
|
2019-08-05 12:19:19 +02:00
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-13 13:31:33 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
def set_inboxCount(self, msgCnt): # pylint: disable=no-self-use
|
2020-01-18 11:31:50 +01:00
|
|
|
"""This method is used to sent inbox message count"""
|
|
|
|
src_mng_obj = state.kivyapp.root.ids.content_drawer.ids.inbox_cnt
|
|
|
|
src_mng_obj.children[0].children[0].text = showLimitedCnt(int(msgCnt))
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
2020-01-18 11:31:50 +01:00
|
|
|
"""This method is used for retrieving inbox data"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.queryreturn = kivy_helper_search.search_sql(
|
2019-12-20 15:07:31 +01:00
|
|
|
xAddress, self.account, "inbox", where, what,
|
|
|
|
False, start_indx, end_indx)
|
2019-12-12 15:38:07 +01:00
|
|
|
|
|
|
|
def set_mdList(self, data):
|
|
|
|
"""This method is used to create the mdList"""
|
|
|
|
total_message = len(self.ids.ml.children)
|
|
|
|
for item in data:
|
|
|
|
meny = TwoLineAvatarIconListItem(
|
2019-12-20 15:07:31 +01:00
|
|
|
text=item['text'], secondary_text=item['secondary_text'],
|
2019-12-12 15:38:07 +01:00
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-12-20 15:07:31 +01:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/text_images/{}.png'.format(
|
|
|
|
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
|
|
|
meny.bind(on_press=partial(self.inbox_detail, item['msgid']))
|
2020-01-28 11:19:11 +01:00
|
|
|
meny.add_widget(AddTimeWidget(item['received']))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
carousel.height = meny.height
|
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
2019-12-20 15:07:31 +01:00
|
|
|
del_btn.bind(on_press=partial(self.delete, item['msgid']))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
2020-01-28 11:19:11 +01:00
|
|
|
# ach_btn = Button(text='Achieve')
|
|
|
|
# ach_btn.background_color = (0, 1, 0, 1)
|
|
|
|
# ach_btn.bind(on_press=partial(self.archive, item['msgid']))
|
|
|
|
# carousel.add_widget(ach_btn)
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
update_message = len(self.ids.ml.children)
|
|
|
|
self.has_refreshed = True if total_message != update_message else False
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
2019-12-20 15:07:31 +01:00
|
|
|
"""Loads data on scroll"""
|
2019-12-12 15:38:07 +01:00
|
|
|
if self.children[2].children[0].children[
|
|
|
|
0].scroll_y <= -0.0 and self.has_refreshed:
|
|
|
|
self.children[2].children[0].children[0].scroll_y = 0.06
|
|
|
|
total_message = len(self.ids.ml.children)
|
|
|
|
self.update_inbox_screen_on_scroll(total_message)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_inbox_screen_on_scroll(self, total_message, where="", what=""):
|
|
|
|
"""This method is used to load more data on scroll down"""
|
|
|
|
data = []
|
|
|
|
if state.searcing_text:
|
|
|
|
where = ['subject', 'message']
|
|
|
|
what = state.searcing_text
|
|
|
|
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
|
|
|
for mail in self.queryreturn:
|
|
|
|
# third_text = mail[3].replace('\n', ' ')
|
2020-03-18 11:37:02 +01:00
|
|
|
subject = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
|
|
|
body = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
2019-12-12 15:38:07 +01:00
|
|
|
data.append({
|
|
|
|
'text': mail[4].strip(),
|
2020-02-05 14:34:54 +01:00
|
|
|
'secondary_text': body[:50] + '........' if len(
|
2020-03-18 11:37:02 +01:00
|
|
|
body) >= 50 else (body + ',' + subject.replace(
|
2019-12-12 15:38:07 +01:00
|
|
|
'\n', ''))[0:50] + '........',
|
|
|
|
'msgid': mail[1]})
|
|
|
|
self.set_mdList(data)
|
|
|
|
|
2019-10-03 18:27:54 +02:00
|
|
|
def inbox_detail(self, msg_id, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Load inbox page details"""
|
2019-06-06 15:48:20 +02:00
|
|
|
state.detailPageType = 'inbox'
|
2019-10-03 18:27:54 +02:00
|
|
|
state.mail_id = msg_id
|
2019-06-06 15:48:20 +02:00
|
|
|
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(self, data_index, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Delete inbox mail from inbox listing"""
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
2019-12-13 17:20:27 +01:00
|
|
|
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index)
|
2020-01-29 17:14:39 +01:00
|
|
|
msg_count_objs = self.parent.parent.ids.content_drawer.ids
|
2019-07-17 10:50:27 +02:00
|
|
|
if int(state.inbox_count) > 0:
|
2020-01-29 17:14:39 +01:00
|
|
|
msg_count_objs.inbox_cnt.children[0].children[0].text = showLimitedCnt(int(state.inbox_count) - 1)
|
|
|
|
msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt(int(state.trash_count) + 1)
|
|
|
|
msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt(int(state.all_count) - 1)
|
2019-08-20 15:11:18 +02:00
|
|
|
state.inbox_count = str(
|
|
|
|
int(state.inbox_count) - 1)
|
|
|
|
state.trash_count = str(
|
|
|
|
int(state.trash_count) + 1)
|
2019-09-19 18:30:26 +02:00
|
|
|
state.all_count = str(
|
|
|
|
int(state.all_count) - 1)
|
2019-12-30 09:05:07 +01:00
|
|
|
if int(state.inbox_count) <= 0:
|
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-08-20 15:11:18 +02:00
|
|
|
self.ids.ml.remove_widget(
|
|
|
|
instance.parent.parent)
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Deleted')
|
2019-06-06 15:48:20 +02:00
|
|
|
self.update_trash()
|
|
|
|
|
|
|
|
def archive(self, data_index, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Archive inbox mail from inbox listing"""
|
2019-08-20 15:11:18 +02:00
|
|
|
sqlExecute(
|
2019-12-13 17:20:27 +01:00
|
|
|
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index)
|
2019-06-06 15:48:20 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
|
|
|
self.update_trash()
|
|
|
|
|
|
|
|
def update_trash(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Update trash screen mails which is deleted from inbox"""
|
2019-06-06 15:48:20 +02:00
|
|
|
try:
|
|
|
|
self.parent.screens[4].clear_widgets()
|
|
|
|
self.parent.screens[4].add_widget(Trash())
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-06-06 15:48:20 +02:00
|
|
|
self.parent.parent.screens[4].clear_widgets()
|
|
|
|
self.parent.parent.screens[4].add_widget(Trash())
|
|
|
|
|
2019-08-02 11:11:33 +02:00
|
|
|
def refresh_callback(self, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method updates the state of application,
|
|
|
|
While the spinner remains on the screen"""
|
2019-08-02 11:11:33 +02:00
|
|
|
def refresh_callback(interval):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method used for loading the inbox screen data"""
|
2019-09-27 18:31:37 +02:00
|
|
|
state.searcing_text = ''
|
|
|
|
self.children[2].children[1].ids.search_field.text = ''
|
2019-08-02 11:11:33 +02:00
|
|
|
self.ids.ml.clear_widgets()
|
2019-09-27 18:31:37 +02:00
|
|
|
self.loadMessagelist(state.association)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.has_refreshed = True
|
2019-08-02 11:11:33 +02:00
|
|
|
self.ids.refresh_layout.refresh_done()
|
|
|
|
self.tick = 0
|
|
|
|
Clock.schedule_once(refresh_callback, 1)
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2020-03-02 11:42:15 +01:00
|
|
|
class CustomTwoLineAvatarIconListItem(TwoLineAvatarIconListItem):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""Custom Two Line Avatar Icon List"""
|
2020-03-02 11:42:15 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class MyAddress(Screen):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""MyAddress screen uses screen to show widgets of screens"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
addresses_list = ListProperty()
|
|
|
|
has_refreshed = True
|
|
|
|
is_add_created = False
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Clock schdule for method Myaddress accounts"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(MyAddress, self).__init__(*args, **kwargs)
|
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock schdule for method Myaddress accounts"""
|
2020-01-28 11:19:11 +01:00
|
|
|
# pylint: disable=unnecessary-lambda, deprecated-lambda
|
|
|
|
# self.addresses_list = state.kivyapp.variable_1
|
|
|
|
self.addresses_list = BMConfigParser().addresses()
|
2019-08-13 09:28:15 +02:00
|
|
|
if state.searcing_text:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.ids.refresh_layout.scroll_y = 1.0
|
2020-01-07 12:28:29 +01:00
|
|
|
filtered_list = [
|
|
|
|
x for x in BMConfigParser().addresses()
|
|
|
|
if self.filter_address(x)
|
|
|
|
]
|
2019-12-12 15:38:07 +01:00
|
|
|
self.addresses_list = filtered_list
|
|
|
|
self.addresses_list = [obj for obj in reversed(self.addresses_list)]
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
if self.addresses_list:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'My Addresses'
|
2019-12-12 15:38:07 +01:00
|
|
|
self.has_refreshed = True
|
|
|
|
self.set_mdList(0, 15)
|
|
|
|
self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y)
|
2019-05-13 13:31:33 +02:00
|
|
|
else:
|
2019-08-05 12:19:19 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-08-05 12:19:19 +02:00
|
|
|
theme_text_color='Primary',
|
2019-08-13 13:54:04 +02:00
|
|
|
text="No address found!" if state.searcing_text
|
|
|
|
else "yet no address is created by user!!!!!!!!!!!!!",
|
2019-08-05 12:19:19 +02:00
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-13 13:31:33 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
2019-12-12 15:38:07 +01:00
|
|
|
if not state.searcing_text and not self.is_add_created:
|
2019-09-27 18:31:37 +02:00
|
|
|
try:
|
|
|
|
self.manager.current = 'login'
|
|
|
|
except Exception:
|
|
|
|
pass
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def set_mdList(self, first_index, last_index):
|
|
|
|
"""Creating the mdlist"""
|
|
|
|
data = []
|
|
|
|
for address in self.addresses_list[first_index:last_index]:
|
|
|
|
data.append({
|
|
|
|
'text': BMConfigParser().get(address, 'label'),
|
|
|
|
'secondary_text': address})
|
|
|
|
for item in data:
|
2020-01-28 11:19:11 +01:00
|
|
|
is_enable = BMConfigParser().get(item['secondary_text'], 'enabled')
|
2020-03-02 11:42:15 +01:00
|
|
|
meny = CustomTwoLineAvatarIconListItem(
|
2019-12-20 15:07:31 +01:00
|
|
|
text=item['text'], secondary_text=item['secondary_text'],
|
2020-01-28 11:19:11 +01:00
|
|
|
theme_text_color='Custom' if is_enable == 'true' else 'Primary',
|
2020-03-18 11:51:18 +01:00
|
|
|
text_color=NavigateApp().theme_cls.primary_color,)
|
2020-03-17 12:42:16 +01:00
|
|
|
try:
|
|
|
|
meny.canvas.children[6].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
|
2020-03-18 11:51:18 +01:00
|
|
|
except Exception:
|
2020-03-17 12:42:16 +01:00
|
|
|
meny.canvas.children[9].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
|
2019-12-12 15:38:07 +01:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/text_images/{}.png'.format(
|
|
|
|
avatarImageFirstLetter(item['text'].strip()))))
|
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.myadd_detail, item['secondary_text'], item['text']))
|
2020-01-29 17:14:39 +01:00
|
|
|
if state.association == item['secondary_text']:
|
2020-03-18 11:37:02 +01:00
|
|
|
meny.add_widget(
|
|
|
|
BadgeText(
|
|
|
|
size_hint=(None, None),
|
|
|
|
text='Active', halign='right',
|
|
|
|
font_style='Body1', size=[50, 60],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color))
|
2020-01-29 17:14:39 +01:00
|
|
|
else:
|
2020-03-18 11:37:02 +01:00
|
|
|
meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False))
|
2020-01-29 17:14:39 +01:00
|
|
|
# carousel = Carousel(direction='right')
|
|
|
|
# carousel.height = meny.height
|
|
|
|
# carousel.size_hint_y = None
|
|
|
|
# carousel.ignore_perpendicular_swipes = True
|
|
|
|
# carousel.data_index = 0
|
|
|
|
# carousel.min_move = 0.2
|
|
|
|
# del_btn = Button(text='Disable' if is_enable == 'true' else 'Enable')
|
|
|
|
# if is_enable == 'true':
|
|
|
|
# del_btn.background_normal = ''
|
|
|
|
# del_btn.background_color = (1, 0, 0, 1) if is_enable == 'true' else (0, 1, 0, 1)
|
|
|
|
# del_btn.bind(
|
|
|
|
# on_press=partial(
|
|
|
|
# self.disableAddress if is_enable == 'true' else self.enableAddress , item['secondary_text']))
|
|
|
|
# carousel.add_widget(del_btn)
|
|
|
|
# carousel.add_widget(meny)
|
|
|
|
# carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(meny)
|
2019-12-12 15:38:07 +01:00
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""Load data on scroll down"""
|
|
|
|
if self.ids.refresh_layout.scroll_y <= -0.0 and self.has_refreshed:
|
|
|
|
self.ids.refresh_layout.scroll_y = 0.06
|
|
|
|
my_addresses = len(self.ids.ml.children)
|
|
|
|
if my_addresses != len(self.addresses_list):
|
|
|
|
self.update_addressBook_on_scroll(my_addresses)
|
|
|
|
self.has_refreshed = True if my_addresses != len(
|
|
|
|
self.addresses_list) else False
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_addressBook_on_scroll(self, my_addresses):
|
|
|
|
"""Loads more data on scroll down"""
|
|
|
|
self.set_mdList(my_addresses, my_addresses + 20)
|
|
|
|
|
2020-03-02 11:42:15 +01:00
|
|
|
# @staticmethod
|
|
|
|
def myadd_detail(self, fromaddress, label, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Load myaddresses details"""
|
2020-01-29 17:14:39 +01:00
|
|
|
if BMConfigParser().get(fromaddress, 'enabled') == 'true':
|
|
|
|
p = MyaddDetailPopup()
|
|
|
|
p.open()
|
|
|
|
p.set_address(fromaddress, label)
|
2020-03-02 11:42:15 +01:00
|
|
|
else:
|
|
|
|
width = .8 if platform == 'android' else .55
|
|
|
|
msg_dialog = MDDialog(
|
|
|
|
text='Address is not currently active. Please click on Toggle button to active it.',
|
|
|
|
title='', size_hint=(width, .25), text_button_ok='Ok',
|
|
|
|
events_callback=self.callback_for_menu_items)
|
|
|
|
msg_dialog.open()
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def callback_for_menu_items(text_item, *arg):
|
|
|
|
"""Callback of alert box"""
|
|
|
|
toast(text_item)
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-08-02 11:11:33 +02:00
|
|
|
def refresh_callback(self, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method updates the state of application,
|
|
|
|
While the spinner remains on the screen"""
|
2019-08-02 11:11:33 +02:00
|
|
|
def refresh_callback(interval):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method used for loading the myaddress screen data"""
|
2019-09-27 18:31:37 +02:00
|
|
|
state.searcing_text = ''
|
2020-01-20 13:59:02 +01:00
|
|
|
# state.kivyapp.root.ids.sc10.children[2].active = False
|
2020-01-29 17:14:39 +01:00
|
|
|
self.children[2].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.has_refreshed = True
|
2019-08-02 11:11:33 +02:00
|
|
|
self.ids.ml.clear_widgets()
|
2019-09-27 18:31:37 +02:00
|
|
|
self.init_ui()
|
2019-08-02 11:11:33 +02:00
|
|
|
self.ids.refresh_layout.refresh_done()
|
|
|
|
self.tick = 0
|
|
|
|
Clock.schedule_once(refresh_callback, 1)
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def filter_address(address):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method will filter the my address list data"""
|
2020-01-04 15:17:44 +01:00
|
|
|
if [
|
|
|
|
x for x in [
|
|
|
|
BMConfigParser().get(address, 'label').lower(),
|
|
|
|
address.lower()
|
|
|
|
]
|
|
|
|
if (state.searcing_text).lower() in x
|
|
|
|
]:
|
2019-08-08 18:20:58 +02:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2020-01-29 17:14:39 +01:00
|
|
|
def disableAddress(self, address, instance):
|
2020-01-28 11:19:11 +01:00
|
|
|
"""This method is use for disabling address"""
|
|
|
|
BMConfigParser().set(str(address), 'enabled', 'false')
|
|
|
|
BMConfigParser().save()
|
2020-01-29 17:14:39 +01:00
|
|
|
instance.parent.parent.theme_text_color = 'Primary'
|
2020-03-17 12:42:16 +01:00
|
|
|
try:
|
|
|
|
instance.parent.parent.canvas.children[6].rgba = [0.5, 0.5, 0.5, 0.5]
|
2020-03-18 11:51:18 +01:00
|
|
|
except Exception:
|
2020-03-17 12:42:16 +01:00
|
|
|
instance.parent.parent.canvas.children[9].rgba = [0.5, 0.5, 0.5, 0.5]
|
2020-01-29 17:14:39 +01:00
|
|
|
toast('Address disabled')
|
2020-01-28 11:19:11 +01:00
|
|
|
Clock.schedule_once(self.address_permision_callback, 0)
|
|
|
|
|
2020-01-29 17:14:39 +01:00
|
|
|
def enableAddress(self, address, instance):
|
2020-01-28 11:19:11 +01:00
|
|
|
"""This method is use for enabling address"""
|
|
|
|
BMConfigParser().set(address, 'enabled', 'true')
|
|
|
|
BMConfigParser().save()
|
2020-01-29 17:14:39 +01:00
|
|
|
instance.parent.parent.theme_text_color = 'Custom'
|
2020-03-17 12:42:16 +01:00
|
|
|
try:
|
|
|
|
instance.parent.parent.canvas.children[6].rgba = [0, 0, 0, 0]
|
2020-03-18 11:51:18 +01:00
|
|
|
except Exception:
|
2020-03-17 12:42:16 +01:00
|
|
|
instance.parent.parent.canvas.children[9].rgba = [0, 0, 0, 0]
|
2020-01-29 17:14:39 +01:00
|
|
|
toast('Address Enabled')
|
2020-01-28 11:19:11 +01:00
|
|
|
Clock.schedule_once(self.address_permision_callback, 0)
|
|
|
|
|
|
|
|
def address_permision_callback(self, dt=0):
|
2020-01-29 17:14:39 +01:00
|
|
|
"""callback for enable or disable addresses"""
|
2020-01-28 11:19:11 +01:00
|
|
|
addresses = [addr for addr in BMConfigParser().addresses()
|
|
|
|
if BMConfigParser().get(str(addr), 'enabled') == 'true']
|
|
|
|
self.parent.parent.ids.content_drawer.ids.btn.values = addresses
|
|
|
|
self.parent.parent.ids.sc3.children[1].ids.btn.values = addresses
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2020-01-29 17:14:39 +01:00
|
|
|
def toggleAction(self, instance):
|
|
|
|
"""This method is used for enable or disable address"""
|
|
|
|
addr = instance.parent.parent.secondary_text
|
|
|
|
if instance.active:
|
|
|
|
self.enableAddress(addr, instance)
|
2020-03-02 11:42:15 +01:00
|
|
|
else:
|
|
|
|
self.disableAddress(addr, instance)
|
2020-01-29 17:14:39 +01:00
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class AddressBook(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""AddressBook Screen uses screen to show widgets of screens"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
queryreturn = ListProperty()
|
|
|
|
has_refreshed = True
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting AddressBook Details"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(AddressBook, self).__init__(*args, **kwargs)
|
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
2018-07-03 12:06:20 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method AddressBook"""
|
2019-08-07 17:39:46 +02:00
|
|
|
self.loadAddresslist(None, 'All', '')
|
2019-12-12 15:38:07 +01:00
|
|
|
print(dt)
|
2019-08-07 17:39:46 +02:00
|
|
|
|
|
|
|
def loadAddresslist(self, account, where="", what=""):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method AddressBook"""
|
2019-08-07 17:39:46 +02:00
|
|
|
if state.searcing_text:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.ids.scroll_y.scroll_y = 1.0
|
2019-08-07 17:39:46 +02:00
|
|
|
where = ['label', 'address']
|
|
|
|
what = state.searcing_text
|
|
|
|
xAddress = ''
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.queryreturn = kivy_helper_search.search_sql(
|
2019-08-07 17:39:46 +02:00
|
|
|
xAddress, account, "addressbook", where, what, False)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.queryreturn = [obj for obj in reversed(self.queryreturn)]
|
|
|
|
if self.queryreturn:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'Address Book'
|
2019-12-12 15:38:07 +01:00
|
|
|
self.has_refreshed = True
|
|
|
|
self.set_mdList(0, 20)
|
|
|
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
2019-05-09 14:48:29 +02:00
|
|
|
else:
|
2019-08-13 13:54:04 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-08-13 13:54:04 +02:00
|
|
|
theme_text_color='Primary',
|
|
|
|
text="No contact found!" if state.searcing_text
|
|
|
|
else "No contact found yet...... ",
|
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-09 14:48:29 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def set_mdList(self, start_index, end_index):
|
|
|
|
"""Creating the mdList"""
|
|
|
|
for item in self.queryreturn[start_index:end_index]:
|
|
|
|
meny = TwoLineAvatarIconListItem(
|
2019-12-20 15:07:31 +01:00
|
|
|
text=item[0], secondary_text=item[1], theme_text_color='Custom',
|
2019-12-12 15:38:07 +01:00
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/text_images/{}.png'.format(
|
|
|
|
avatarImageFirstLetter(item[0].strip()))))
|
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.addBook_detail, item[1], item[0]))
|
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
carousel.height = meny.height
|
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
|
|
|
del_btn.bind(on_press=partial(self.delete_address, item[1]))
|
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""Load data on scroll"""
|
|
|
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
|
|
|
self.ids.scroll_y.scroll_y = 0.06
|
|
|
|
exist_addresses = len(self.ids.ml.children)
|
|
|
|
if exist_addresses != len(self.queryreturn):
|
|
|
|
self.update_addressBook_on_scroll(exist_addresses)
|
|
|
|
self.has_refreshed = True if exist_addresses != len(
|
|
|
|
self.queryreturn) else False
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_addressBook_on_scroll(self, exist_addresses):
|
|
|
|
"""Load more data on scroll down"""
|
|
|
|
self.set_mdList(exist_addresses, exist_addresses + 5)
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def refreshs(*args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Refresh the Widget"""
|
2019-10-18 16:00:43 +02:00
|
|
|
# state.navinstance.ids.sc11.ids.ml.clear_widgets()
|
|
|
|
# state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
|
|
|
|
pass
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def addBook_detail(address, label, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Addressbook details"""
|
2019-06-28 16:54:47 +02:00
|
|
|
p = AddbookDetailPopup()
|
|
|
|
p.open()
|
|
|
|
p.set_addbook_data(address, label)
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2019-07-17 10:50:27 +02:00
|
|
|
def delete_address(self, address, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Delete inbox mail from inbox listing"""
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
2020-01-21 09:09:56 +01:00
|
|
|
# if len(self.ids.ml.children) == 0:
|
|
|
|
if self.ids.ml.children is not None:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
|
|
|
"DELETE FROM addressbook WHERE address = '{}';".format(address))
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
class SelectableRecycleBoxLayout(
|
|
|
|
FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Adds selection and focus behaviour to the view"""
|
2019-12-23 15:17:23 +01:00
|
|
|
# pylint: disable = duplicate-bases
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-05-13 13:31:33 +02:00
|
|
|
pass
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SelectableLabel(RecycleDataViewBehavior, Label):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Add selection support to the Label"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
index = None
|
|
|
|
selected = BooleanProperty(False)
|
|
|
|
selectable = BooleanProperty(True)
|
|
|
|
|
|
|
|
def refresh_view_attrs(self, rv, index, data):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Catch and handle the view changes"""
|
2019-05-09 14:48:29 +02:00
|
|
|
self.index = index
|
|
|
|
return super(SelectableLabel, self).refresh_view_attrs(
|
|
|
|
rv, index, data)
|
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
def on_touch_down(self, touch): # pylint: disable=inconsistent-return-statements
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Add selection on touch down"""
|
2019-05-09 14:48:29 +02:00
|
|
|
if super(SelectableLabel, self).on_touch_down(touch):
|
2018-09-05 12:12:41 +02:00
|
|
|
return True
|
2019-05-09 14:48:29 +02:00
|
|
|
if self.collide_point(*touch.pos) and self.selectable:
|
|
|
|
return self.parent.select_with_touch(self.index, touch)
|
2018-09-05 12:12:41 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def apply_selection(self, rv, index, is_selected):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Respond to the selection of items in the view"""
|
2019-05-09 14:48:29 +02:00
|
|
|
self.selected = is_selected
|
|
|
|
if is_selected:
|
2019-10-01 16:49:03 +02:00
|
|
|
print("selection changed to {0}".format(rv.data[index]))
|
2019-08-03 13:49:28 +02:00
|
|
|
rv.parent.txt_input.text = rv.parent.txt_input.text.replace(
|
|
|
|
rv.parent.txt_input.text, rv.data[index]['text'])
|
2018-09-05 12:12:41 +02:00
|
|
|
|
2018-08-07 08:14:14 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class RV(RecycleView):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Recycling View"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
def __init__(self, **kwargs):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Recycling Method"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(RV, self).__init__(**kwargs)
|
2018-07-03 12:06:20 +02:00
|
|
|
|
2018-08-21 14:48:16 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class DropDownWidget(BoxLayout):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Adding Dropdown Widget"""
|
2020-01-04 15:17:44 +01:00
|
|
|
# pylint: disable=too-many-statements
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
txt_input = ObjectProperty()
|
|
|
|
rv = ObjectProperty()
|
2018-08-21 14:48:16 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def send(self, navApp):
|
|
|
|
"""Send message from one address to another"""
|
2020-01-28 11:19:11 +01:00
|
|
|
fromAddress = self.ids.ti.text.strip()
|
|
|
|
toAddress = self.ids.txt_input.text.strip()
|
2019-11-14 16:09:26 +01:00
|
|
|
subject = self.ids.subject.text.strip()
|
2020-01-18 11:31:50 +01:00
|
|
|
message = self.ids.body.text.strip()
|
2019-05-09 14:48:29 +02:00
|
|
|
encoding = 3
|
2019-12-23 15:17:23 +01:00
|
|
|
print("message: ", self.ids.body.text)
|
2019-05-09 14:48:29 +02:00
|
|
|
sendMessageToPeople = True
|
|
|
|
if sendMessageToPeople:
|
2019-05-13 13:31:33 +02:00
|
|
|
if toAddress != '' and subject and message:
|
2019-12-12 15:38:07 +01:00
|
|
|
status, addressVersionNumber, streamNumber, ripe = (
|
|
|
|
decodeAddress(toAddress))
|
2019-05-09 14:48:29 +02:00
|
|
|
if status == 'success':
|
2019-12-12 15:38:07 +01:00
|
|
|
navApp.root.ids.sc3.children[0].active = True
|
|
|
|
if state.detailPageType == 'draft' \
|
|
|
|
and state.send_draft_mail:
|
2019-08-19 13:06:24 +02:00
|
|
|
sqlExecute(
|
2019-12-12 15:38:07 +01:00
|
|
|
"UPDATE sent SET toaddress = ?"
|
|
|
|
", fromaddress = ? , subject = ?"
|
|
|
|
", message = ?, folder = 'sent'"
|
2020-02-05 09:53:04 +01:00
|
|
|
", senttime = ?, lastactiontime = ?"
|
2019-12-12 15:38:07 +01:00
|
|
|
" WHERE ackdata = ?;",
|
2019-10-04 15:54:58 +02:00
|
|
|
toAddress,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
2020-02-05 09:53:04 +01:00
|
|
|
int(time.time()),
|
|
|
|
int(time.time()),
|
2019-12-13 17:20:27 +01:00
|
|
|
state.send_draft_mail)
|
2019-08-19 13:06:24 +02:00
|
|
|
self.parent.parent.screens[15].clear_widgets()
|
|
|
|
self.parent.parent.screens[15].add_widget(Draft())
|
2019-12-26 16:56:04 +01:00
|
|
|
# state.detailPageType = ''
|
|
|
|
# state.send_draft_mail = None
|
2019-08-19 13:06:24 +02:00
|
|
|
else:
|
2019-12-26 16:56:04 +01:00
|
|
|
from addresses import addBMIfNotPresent
|
2019-08-19 13:06:24 +02:00
|
|
|
toAddress = addBMIfNotPresent(toAddress)
|
|
|
|
statusIconColor = 'red'
|
2019-12-12 15:38:07 +01:00
|
|
|
if (addressVersionNumber > 4) or (
|
|
|
|
addressVersionNumber <= 1):
|
2020-01-07 12:28:29 +01:00
|
|
|
print(
|
|
|
|
"addressVersionNumber > 4"
|
|
|
|
" or addressVersionNumber <= 1")
|
2019-08-19 13:06:24 +02:00
|
|
|
if streamNumber > 1 or streamNumber == 0:
|
2019-12-23 15:17:23 +01:00
|
|
|
print("streamNumber > 1 or streamNumber == 0")
|
2019-08-19 13:06:24 +02:00
|
|
|
if statusIconColor == 'red':
|
2019-12-23 15:17:23 +01:00
|
|
|
print("shared.statusIconColor == 'red'")
|
2019-08-19 13:06:24 +02:00
|
|
|
stealthLevel = BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ackstealthlevel')
|
|
|
|
from helper_ackPayload import genAckPayload
|
|
|
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
2019-12-12 15:38:07 +01:00
|
|
|
# t = ()
|
2019-08-19 13:06:24 +02:00
|
|
|
sqlExecute(
|
|
|
|
'''INSERT INTO sent VALUES
|
|
|
|
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
|
|
|
'',
|
|
|
|
toAddress,
|
|
|
|
ripe,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
ackdata,
|
|
|
|
int(time.time()),
|
|
|
|
int(time.time()),
|
|
|
|
0,
|
|
|
|
'msgqueued',
|
|
|
|
0,
|
|
|
|
'sent',
|
|
|
|
encoding,
|
2020-01-18 12:43:06 +01:00
|
|
|
BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ttl'))
|
2019-06-28 16:54:47 +02:00
|
|
|
state.check_sent_acc = fromAddress
|
2020-01-09 16:09:01 +01:00
|
|
|
# state.msg_counter_objs = self.parent.parent.parent.parent\
|
|
|
|
# .parent.parent.children[2].children[0].ids
|
2019-12-13 17:20:27 +01:00
|
|
|
if state.detailPageType == 'draft' \
|
|
|
|
and state.send_draft_mail:
|
|
|
|
state.draft_count = str(int(state.draft_count) - 1)
|
2020-01-09 16:09:01 +01:00
|
|
|
# state.msg_counter_objs.draft_cnt.badge_text = (
|
|
|
|
# state.draft_count)
|
2019-12-13 17:20:27 +01:00
|
|
|
state.detailPageType = ''
|
|
|
|
state.send_draft_mail = None
|
2020-02-19 16:46:13 +01:00
|
|
|
self.parent.parent.parent.ids.sc4.update_sent_messagelist()
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.callback_for_msgsend, 3)
|
2019-05-09 14:48:29 +02:00
|
|
|
queues.workerQueue.put(('sendmessage', toAddress))
|
2019-12-23 15:17:23 +01:00
|
|
|
print("sqlExecute successfully #######################")
|
2019-09-11 17:03:51 +02:00
|
|
|
state.in_composer = True
|
2019-12-12 15:38:07 +01:00
|
|
|
return
|
2019-05-13 13:31:33 +02:00
|
|
|
else:
|
|
|
|
msg = 'Enter a valid recipients address'
|
|
|
|
elif not toAddress:
|
2020-03-02 11:42:15 +01:00
|
|
|
msg = 'Please fill the form completely'
|
2019-05-28 13:12:51 +02:00
|
|
|
else:
|
2020-03-02 11:42:15 +01:00
|
|
|
msg = 'Please fill the form completely'
|
2019-05-28 13:12:51 +02:00
|
|
|
self.address_error_message(msg)
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
@staticmethod
|
|
|
|
def callback_for_msgsend(dt=0):
|
|
|
|
"""Callback method for messagesend"""
|
|
|
|
state.kivyapp.root.ids.sc3.children[0].active = False
|
|
|
|
state.in_sent_method = True
|
|
|
|
state.kivyapp.back_press()
|
|
|
|
toast('sent')
|
|
|
|
|
2019-05-13 13:31:33 +02:00
|
|
|
def address_error_message(self, msg):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Generates error message"""
|
2019-12-30 09:05:07 +01:00
|
|
|
width = .8 if platform == 'android' else .55
|
2019-09-11 17:03:51 +02:00
|
|
|
msg_dialog = MDDialog(
|
2019-08-05 12:19:19 +02:00
|
|
|
text=msg,
|
2019-12-30 09:05:07 +01:00
|
|
|
title='', size_hint=(width, .25), text_button_ok='Ok',
|
2019-09-11 17:03:51 +02:00
|
|
|
events_callback=self.callback_for_menu_items)
|
|
|
|
msg_dialog.open()
|
|
|
|
|
2019-09-12 11:43:11 +02:00
|
|
|
@staticmethod
|
2019-12-13 17:20:27 +01:00
|
|
|
def callback_for_menu_items(text_item, *arg):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Callback of alert box"""
|
2019-09-11 17:03:51 +02:00
|
|
|
toast(text_item)
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-08-13 09:28:15 +02:00
|
|
|
def reset_composer(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method will reset composer"""
|
2019-08-13 09:28:15 +02:00
|
|
|
self.ids.ti.text = ''
|
|
|
|
self.ids.btn.text = 'Select'
|
|
|
|
self.ids.txt_input.text = ''
|
|
|
|
self.ids.subject.text = ''
|
|
|
|
self.ids.body.text = ''
|
2019-10-18 16:00:43 +02:00
|
|
|
toast("Reset message")
|
2019-08-13 09:28:15 +02:00
|
|
|
|
2019-08-21 10:07:47 +02:00
|
|
|
def auto_fill_fromaddr(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Fill the text automatically From Address"""
|
2019-08-21 10:07:47 +02:00
|
|
|
self.ids.ti.text = self.ids.btn.text
|
|
|
|
self.ids.ti.focus = True
|
|
|
|
|
2020-03-09 08:54:10 +01:00
|
|
|
def qrScanner(self):
|
|
|
|
"""This method is used for scanning Qr code"""
|
|
|
|
pass
|
|
|
|
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class MyTextInput(TextInput):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Takes the text input in the field"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
txt_input = ObjectProperty()
|
|
|
|
flt_list = ObjectProperty()
|
|
|
|
word_list = ListProperty()
|
|
|
|
starting_no = NumericProperty(3)
|
|
|
|
suggestion_text = ''
|
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
def __init__(self, **kwargs):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Getting Text Input."""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(MyTextInput, self).__init__(**kwargs)
|
2020-03-18 11:37:02 +01:00
|
|
|
self.__lineBreak__ = 0
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
def on_text(self, instance, value):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Find all the occurrence of the word"""
|
2020-03-09 08:54:10 +01:00
|
|
|
self.parent.parent.parent.parent.parent.ids.rv.data = []
|
2019-08-05 09:24:32 +02:00
|
|
|
matches = [self.word_list[i] for i in range(
|
2019-08-05 12:19:19 +02:00
|
|
|
len(self.word_list)) if self.word_list[
|
2019-08-13 14:46:19 +02:00
|
|
|
i][:self.starting_no] == value[:self.starting_no]]
|
2019-05-09 14:48:29 +02:00
|
|
|
display_data = []
|
|
|
|
for i in matches:
|
|
|
|
display_data.append({'text': i})
|
2020-03-09 08:54:10 +01:00
|
|
|
self.parent.parent.parent.parent.parent.ids.rv.data = display_data
|
2019-05-09 14:48:29 +02:00
|
|
|
if len(matches) <= 10:
|
2019-05-13 13:31:33 +02:00
|
|
|
self.parent.height = (250 + (len(matches) * 20))
|
|
|
|
else:
|
2019-05-09 14:48:29 +02:00
|
|
|
self.parent.height = 400
|
|
|
|
|
|
|
|
def keyboard_on_key_down(self, window, keycode, text, modifiers):
|
2019-12-20 15:07:31 +01:00
|
|
|
"""Keyboard on key Down"""
|
2019-05-09 14:48:29 +02:00
|
|
|
if self.suggestion_text and keycode[1] == 'tab':
|
|
|
|
self.insert_text(self.suggestion_text + ' ')
|
|
|
|
return True
|
2019-08-05 12:19:19 +02:00
|
|
|
return super(MyTextInput, self).keyboard_on_key_down(
|
|
|
|
window, keycode, text, modifiers)
|
2018-08-31 13:19:57 +02:00
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Payment(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Payment module"""
|
2019-08-20 15:11:18 +02:00
|
|
|
|
2020-03-18 14:00:45 +01:00
|
|
|
def get_free_credits(self, instance):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Get the available credits"""
|
2020-01-04 15:17:44 +01:00
|
|
|
# pylint: disable=no-self-use
|
2019-09-16 12:21:05 +02:00
|
|
|
state.availabe_credit = instance.parent.children[1].text
|
2020-03-02 11:42:15 +01:00
|
|
|
existing_credits = state.kivyapp.root.ids.sc18.ids.cred.text
|
|
|
|
if float(existing_credits.split()[1]) > 0:
|
2019-12-12 15:38:07 +01:00
|
|
|
toast(
|
|
|
|
'We already have added free coins'
|
|
|
|
' for the subscription to your account!')
|
2019-09-16 12:21:05 +02:00
|
|
|
else:
|
|
|
|
toast('Coins added to your account!')
|
2020-03-02 11:42:15 +01:00
|
|
|
state.kivyapp.root.ids.sc18.ids.cred.text = '{0}'.format(
|
|
|
|
state.availabe_credit)
|
2019-09-16 12:21:05 +02:00
|
|
|
|
2020-03-20 09:18:17 +01:00
|
|
|
def create_hidden_payment_address(self, instance):
|
|
|
|
if BMConfigParser().paymentaddress():
|
|
|
|
toast('hidden payment address already exist for buying subscription...')
|
|
|
|
else:
|
|
|
|
streamNumberForAddress = 1
|
|
|
|
eighteenByteRipe = False
|
|
|
|
nonceTrialsPerByte = 1000
|
|
|
|
payloadLengthExtraBytes = 1000
|
|
|
|
queues.addressGeneratorQueue.put((
|
|
|
|
'createPaymentAddress', 4, streamNumberForAddress, '', 1,
|
|
|
|
"", eighteenByteRipe, nonceTrialsPerByte,
|
|
|
|
payloadLengthExtraBytes))
|
|
|
|
toast('hidden payment address Creating for buying subscription....')
|
2020-03-09 08:54:10 +01:00
|
|
|
|
2019-09-16 12:21:05 +02:00
|
|
|
|
|
|
|
class Credits(Screen):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Credits Method"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2020-03-18 11:37:02 +01:00
|
|
|
available_credits = StringProperty('{0}'.format('€ 0'))
|
2018-07-03 12:06:20 +02:00
|
|
|
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Login(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Login Screeen"""
|
2020-03-18 11:37:02 +01:00
|
|
|
log_text1 = (
|
|
|
|
'You may generate addresses by using either random numbers'
|
|
|
|
' or by using a passphrase If you use a passphrase, the address'
|
|
|
|
' is called a deterministic; address The Random Number option is'
|
|
|
|
' selected by default but deterministic addresses have several pros'
|
|
|
|
' and cons:')
|
2020-03-02 11:42:15 +01:00
|
|
|
log_text2 = ('If talk about pros You can recreate your addresses on any computer'
|
|
|
|
' from memory, You need-not worry about backing up your keys.dat file'
|
|
|
|
' as long as you can remember your passphrase and aside talk about cons'
|
|
|
|
' You must remember (or write down) your You must remember the address'
|
|
|
|
' version number and the stream number along with your passphrase If you'
|
|
|
|
' choose a weak passphrase and someone on the Internet can brute-force it,'
|
|
|
|
' they can read your messages and send messages as you')
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2020-03-17 12:42:16 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class NetworkStat(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method used to show network stat"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-08-05 12:19:19 +02:00
|
|
|
text_variable_1 = StringProperty(
|
|
|
|
'{0}::{1}'.format('Total Connections', '0'))
|
|
|
|
text_variable_2 = StringProperty(
|
|
|
|
'Processed {0} per-to-per messages'.format('0'))
|
|
|
|
text_variable_3 = StringProperty(
|
|
|
|
'Processed {0} brodcast messages'.format('0'))
|
2020-01-07 12:28:29 +01:00
|
|
|
text_variable_4 = StringProperty(
|
|
|
|
'Processed {0} public keys'.format('0'))
|
2019-08-05 12:19:19 +02:00
|
|
|
text_variable_5 = StringProperty(
|
|
|
|
'Processed {0} object to be synced'.format('0'))
|
2018-08-21 14:48:16 +02:00
|
|
|
|
2018-08-04 10:30:12 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Init method for network stat"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(NetworkStat, self).__init__(*args, **kwargs)
|
|
|
|
Clock.schedule_interval(self.init_ui, 1)
|
2018-08-04 10:30:12 +02:00
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method networkstat screen"""
|
2019-05-09 14:48:29 +02:00
|
|
|
import network.stats
|
|
|
|
import shared
|
2019-05-13 13:31:33 +02:00
|
|
|
from network import objectracker
|
2019-08-05 12:19:19 +02:00
|
|
|
self.text_variable_1 = '{0} :: {1}'.format(
|
|
|
|
'Total Connections', str(len(network.stats.connectedHostsList())))
|
|
|
|
self.text_variable_2 = 'Processed {0} per-to-per messages'.format(
|
|
|
|
str(shared.numberOfMessagesProcessed))
|
|
|
|
self.text_variable_3 = 'Processed {0} brodcast messages'.format(
|
|
|
|
str(shared.numberOfBroadcastsProcessed))
|
|
|
|
self.text_variable_4 = 'Processed {0} public keys'.format(
|
|
|
|
str(shared.numberOfPubkeysProcessed))
|
|
|
|
self.text_variable_5 = '{0} object to be synced'.format(
|
|
|
|
len(objectracker.missingObjects))
|
2018-08-04 10:30:12 +02:00
|
|
|
|
2018-08-07 08:14:14 +02:00
|
|
|
|
2020-01-09 16:09:01 +01:00
|
|
|
class ContentNavigationDrawer(BoxLayout):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Navigate Content Drawer"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
2018-08-04 10:30:12 +02:00
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Random(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Generates Random Address"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
is_active = BooleanProperty(False)
|
|
|
|
checked = StringProperty("")
|
|
|
|
|
2019-08-21 10:07:47 +02:00
|
|
|
def generateaddress(self, navApp):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method for Address Generator"""
|
|
|
|
entered_label = str(self.ids.label.text).strip()
|
2020-03-02 11:42:15 +01:00
|
|
|
if not entered_label:
|
|
|
|
self.ids.label.focus = True
|
|
|
|
# self.ids.label.error = True
|
|
|
|
# self.ids.label.helper_text = 'This field is required'
|
2019-05-09 14:48:29 +02:00
|
|
|
streamNumberForAddress = 1
|
|
|
|
label = self.ids.label.text
|
|
|
|
eighteenByteRipe = False
|
|
|
|
nonceTrialsPerByte = 1000
|
|
|
|
payloadLengthExtraBytes = 1000
|
2019-12-12 15:38:07 +01:00
|
|
|
lables = [BMConfigParser().get(obj, 'label')
|
|
|
|
for obj in BMConfigParser().addresses()]
|
|
|
|
if entered_label and entered_label not in lables:
|
|
|
|
toast('Address Creating...')
|
2019-05-13 13:31:33 +02:00
|
|
|
queues.addressGeneratorQueue.put((
|
2019-12-20 15:07:31 +01:00
|
|
|
'createRandomAddress', 4, streamNumberForAddress, label, 1,
|
|
|
|
"", eighteenByteRipe, nonceTrialsPerByte,
|
2019-08-13 14:46:19 +02:00
|
|
|
payloadLengthExtraBytes))
|
2019-05-13 13:31:33 +02:00
|
|
|
self.ids.label.text = ''
|
2020-01-10 15:07:43 +01:00
|
|
|
self.parent.parent.ids.toolbar.opacity = 1
|
|
|
|
self.parent.parent.ids.toolbar.disabled = False
|
2020-01-09 16:09:01 +01:00
|
|
|
state.kivyapp.loadMyAddressScreen(True)
|
2019-10-03 18:27:54 +02:00
|
|
|
self.manager.current = 'myaddress'
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.address_created_callback, 6)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def address_created_callback(dt=0):
|
|
|
|
"""New address created"""
|
2020-01-09 16:09:01 +01:00
|
|
|
state.kivyapp.loadMyAddressScreen(False)
|
2019-12-12 15:38:07 +01:00
|
|
|
state.kivyapp.root.ids.sc10.ids.ml.clear_widgets()
|
|
|
|
state.kivyapp.root.ids.sc10.is_add_created = True
|
|
|
|
state.kivyapp.root.ids.sc10.init_ui()
|
|
|
|
toast('New address created')
|
|
|
|
|
|
|
|
def add_validation(self, instance):
|
|
|
|
"""Checking validation at address creation time"""
|
|
|
|
entered_label = str(instance.text.strip())
|
|
|
|
lables = [BMConfigParser().get(obj, 'label')
|
|
|
|
for obj in BMConfigParser().addresses()]
|
|
|
|
if entered_label in lables:
|
|
|
|
self.ids.label.error = True
|
|
|
|
self.ids.label.helper_text = 'Label name is already exist you'\
|
|
|
|
' can try this Ex. ( {0}_1, {0}_2 )'.format(
|
|
|
|
entered_label)
|
|
|
|
elif entered_label:
|
|
|
|
self.ids.label.error = False
|
|
|
|
else:
|
|
|
|
self.ids.label.error = False
|
|
|
|
self.ids.label.helper_text = 'This field is required'
|
|
|
|
|
|
|
|
def reset_address_label(self):
|
|
|
|
"""Resetting address labels"""
|
|
|
|
self.ids.label.text = ''
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2018-08-04 10:30:12 +02:00
|
|
|
|
2018-07-18 14:49:39 +02:00
|
|
|
class Sent(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Sent Screen uses screen to show widgets of screens"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
queryreturn = ListProperty()
|
|
|
|
has_refreshed = True
|
|
|
|
account = StringProperty()
|
|
|
|
|
2018-08-09 12:20:20 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Association with the screen"""
|
2018-08-09 12:20:20 +02:00
|
|
|
super(Sent, self).__init__(*args, **kwargs)
|
2018-09-04 14:44:28 +02:00
|
|
|
if state.association == '':
|
2019-05-09 14:48:29 +02:00
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
2018-08-09 12:20:20 +02:00
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method sent accounts"""
|
|
|
|
self.loadSent()
|
2019-10-01 16:49:03 +02:00
|
|
|
print(dt)
|
2018-08-09 12:20:20 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def loadSent(self, where="", what=""):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Load Sent list for Sent messages"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.account = state.association
|
2019-08-02 11:11:33 +02:00
|
|
|
if state.searcing_text:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.ids.scroll_y.scroll_y = 1.0
|
2019-08-02 11:11:33 +02:00
|
|
|
where = ['subject', 'message']
|
|
|
|
what = state.searcing_text
|
2018-08-09 12:20:20 +02:00
|
|
|
xAddress = 'fromaddress'
|
2019-09-27 18:31:37 +02:00
|
|
|
data = []
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.sentDataQuery(xAddress, where, what)
|
|
|
|
if self.queryreturn:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'Sent'
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_sentCount(state.sent_count)
|
|
|
|
for mail in self.queryreturn:
|
2019-09-27 18:31:37 +02:00
|
|
|
data.append({
|
2019-08-05 09:24:32 +02:00
|
|
|
'text': mail[1].strip(),
|
2020-03-02 11:42:15 +01:00
|
|
|
'secondary_text': (mail[2][:50] + '........' if len(
|
2020-03-18 11:37:02 +01:00
|
|
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace(
|
|
|
|
'\t', '').replace(' ', ''),
|
2020-01-28 11:19:11 +01:00
|
|
|
'ackdata': mail[5], 'senttime': mail[6]},)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_mdlist(data, 0)
|
|
|
|
self.has_refreshed = True
|
|
|
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
2018-08-09 12:20:20 +02:00
|
|
|
else:
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_sentCount('0')
|
2019-08-05 12:19:19 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-08-05 12:19:19 +02:00
|
|
|
theme_text_color='Primary',
|
2019-08-13 13:54:04 +02:00
|
|
|
text="No message found!" if state.searcing_text
|
|
|
|
else "yet no message for this account!!!!!!!!!!!!!",
|
2019-08-05 12:19:19 +02:00
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-09 14:48:29 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def sentDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
|
|
|
"""This method is used to retrieving data from sent table"""
|
|
|
|
self.queryreturn = kivy_helper_search.search_sql(
|
|
|
|
xAddress,
|
|
|
|
self.account,
|
2019-12-26 16:56:04 +01:00
|
|
|
'sent',
|
2019-12-12 15:38:07 +01:00
|
|
|
where,
|
|
|
|
what,
|
|
|
|
False,
|
|
|
|
start_indx,
|
|
|
|
end_indx)
|
|
|
|
|
|
|
|
def set_mdlist(self, data, set_index=0):
|
|
|
|
"""This method is used to create the mdList"""
|
|
|
|
total_sent_msg = len(self.ids.ml.children)
|
|
|
|
for item in data:
|
|
|
|
meny = TwoLineAvatarIconListItem(
|
2019-12-20 15:07:31 +01:00
|
|
|
text=item['text'], secondary_text=item['secondary_text'],
|
2019-12-12 15:38:07 +01:00
|
|
|
theme_text_color='Custom',
|
2020-03-18 11:37:02 +01:00
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-12-12 15:38:07 +01:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/text_images/{}.png'.format(
|
|
|
|
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
2019-12-20 15:07:31 +01:00
|
|
|
meny.bind(on_press=partial(self.sent_detail, item['ackdata']))
|
2020-01-28 11:19:11 +01:00
|
|
|
meny.add_widget(AddTimeWidget(item['senttime']))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
carousel.height = meny.height
|
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
2019-12-20 15:07:31 +01:00
|
|
|
del_btn.bind(on_press=partial(self.delete, item['ackdata']))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
2020-01-28 11:19:11 +01:00
|
|
|
# ach_btn = Button(text='Achieve')
|
|
|
|
# ach_btn.background_color = (0, 1, 0, 1)
|
|
|
|
# ach_btn.bind(on_press=partial(self.archive, item['ackdata']))
|
|
|
|
# carousel.add_widget(ach_btn)
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel, index=set_index)
|
|
|
|
updated_msgs = len(self.ids.ml.children)
|
|
|
|
self.has_refreshed = True if total_sent_msg != updated_msgs else False
|
|
|
|
|
|
|
|
def update_sent_messagelist(self):
|
|
|
|
"""This method is used to update screen when new mail is sent"""
|
|
|
|
self.account = state.association
|
|
|
|
if len(self.ids.ml.children) < 3:
|
|
|
|
self.ids.ml.clear_widgets()
|
|
|
|
self.loadSent()
|
2020-03-17 12:42:16 +01:00
|
|
|
if state.association == state.check_sent_acc:
|
|
|
|
total_sent = int(state.sent_count) + 1
|
2020-03-18 11:51:18 +01:00
|
|
|
state.sent_count = str(int(state.sent_count) + 1)
|
2020-03-17 12:42:16 +01:00
|
|
|
self.set_sentCount(total_sent)
|
|
|
|
else:
|
|
|
|
total_sent = int(state.sent_count)
|
2019-12-12 15:38:07 +01:00
|
|
|
else:
|
|
|
|
data = []
|
|
|
|
self.sentDataQuery('fromaddress', '', '', 0, 1)
|
2020-03-17 12:42:16 +01:00
|
|
|
if state.association == state.check_sent_acc:
|
|
|
|
total_sent = int(state.sent_count) + 1
|
2020-03-18 11:51:18 +01:00
|
|
|
state.sent_count = str(int(state.sent_count) + 1)
|
2020-03-17 12:42:16 +01:00
|
|
|
self.set_sentCount(total_sent)
|
|
|
|
else:
|
|
|
|
total_sent = int(state.sent_count)
|
2019-12-12 15:38:07 +01:00
|
|
|
for mail in self.queryreturn:
|
|
|
|
data.append({
|
|
|
|
'text': mail[1].strip(),
|
2020-03-02 11:42:15 +01:00
|
|
|
'secondary_text': (mail[2][:50] + '........' if len(
|
2020-03-18 11:37:02 +01:00
|
|
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace(
|
|
|
|
'\t', '').replace(' ', ''),
|
2020-01-28 11:19:11 +01:00
|
|
|
'ackdata': mail[5], 'senttime': mail[6]})
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_mdlist(data, total_sent - 1)
|
|
|
|
if state.msg_counter_objs and state.association == (
|
|
|
|
state.check_sent_acc):
|
|
|
|
state.all_count = str(int(state.all_count) + 1)
|
|
|
|
state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
|
|
|
state.check_sent_acc = None
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""Load data on scroll down"""
|
|
|
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
|
|
|
self.ids.scroll_y.scroll_y = 0.06
|
|
|
|
total_sent_msg = len(self.ids.ml.children)
|
|
|
|
self.update_sent_screen_on_scroll(total_sent_msg)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_sent_screen_on_scroll(self, total_sent_msg, where="", what=""):
|
|
|
|
"""This method is used to load more data on scroll down"""
|
|
|
|
if state.searcing_text:
|
|
|
|
where = ['subject', 'message']
|
|
|
|
what = state.searcing_text
|
|
|
|
self.sentDataQuery('fromaddress', where, what, total_sent_msg, 5)
|
|
|
|
data = []
|
|
|
|
for mail in self.queryreturn:
|
|
|
|
data.append({
|
|
|
|
'text': mail[1].strip(),
|
|
|
|
'secondary_text': mail[2][:50] + '........' if len(
|
|
|
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3].replace(
|
|
|
|
'\n', ''))[0:50] + '........',
|
|
|
|
'ackdata': mail[5]})
|
|
|
|
self.set_mdlist(data, 0)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def set_sentCount(total_sent):
|
|
|
|
"""Set the total no. of sent message count"""
|
2020-01-18 11:31:50 +01:00
|
|
|
src_mng_obj = state.kivyapp.root.ids.content_drawer.ids.send_cnt
|
2020-01-28 11:19:11 +01:00
|
|
|
if state.association:
|
|
|
|
src_mng_obj.children[0].children[0].text = showLimitedCnt(int(total_sent))
|
2020-02-19 16:46:13 +01:00
|
|
|
# state.kivyapp.get_sent_count()
|
2020-01-28 11:19:11 +01:00
|
|
|
else:
|
|
|
|
src_mng_obj.children[0].children[0].text = '0'
|
2019-12-12 15:38:07 +01:00
|
|
|
|
2019-10-03 18:27:54 +02:00
|
|
|
def sent_detail(self, ackdata, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Load sent mail details"""
|
2019-06-06 15:48:20 +02:00
|
|
|
state.detailPageType = 'sent'
|
2019-10-03 18:27:54 +02:00
|
|
|
state.mail_id = ackdata
|
2019-05-28 13:12:51 +02:00
|
|
|
if self.manager:
|
|
|
|
src_mng_obj = self.manager
|
|
|
|
else:
|
|
|
|
src_mng_obj = self.parent.parent
|
|
|
|
src_mng_obj.screens[13].clear_widgets()
|
2019-06-06 15:48:20 +02:00
|
|
|
src_mng_obj.screens[13].add_widget(MailDetail())
|
|
|
|
src_mng_obj.current = 'mailDetail'
|
|
|
|
|
|
|
|
def delete(self, data_index, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Delete sent mail from sent mail listing"""
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs = self.parent.parent.ids.content_drawer.ids
|
2019-06-28 16:54:47 +02:00
|
|
|
if int(state.sent_count) > 0:
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.send_cnt.children[0].children[0].text = showLimitedCnt(int(state.sent_count) - 1)
|
|
|
|
msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt(int(state.trash_count) + 1)
|
|
|
|
msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt(int(state.all_count) - 1)
|
2019-06-28 16:54:47 +02:00
|
|
|
state.sent_count = str(int(state.sent_count) - 1)
|
|
|
|
state.trash_count = str(int(state.trash_count) + 1)
|
2019-08-14 16:55:34 +02:00
|
|
|
state.all_count = str(int(state.all_count) - 1)
|
2019-12-30 09:05:07 +01:00
|
|
|
if int(state.sent_count) <= 0:
|
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
2019-12-12 15:38:07 +01:00
|
|
|
"UPDATE sent SET folder = 'trash'"
|
2019-12-13 17:20:27 +01:00
|
|
|
" WHERE ackdata = ?;", data_index)
|
2019-06-06 15:48:20 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Deleted')
|
2019-06-06 15:48:20 +02:00
|
|
|
self.update_trash()
|
|
|
|
|
|
|
|
def archive(self, data_index, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Archive sent mail from sent mail listing"""
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
2019-12-12 15:38:07 +01:00
|
|
|
"UPDATE sent SET folder = 'trash'"
|
2019-12-13 17:20:27 +01:00
|
|
|
" WHERE ackdata = ?;", data_index)
|
2019-06-06 15:48:20 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
|
|
|
self.update_trash()
|
|
|
|
|
|
|
|
def update_trash(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Update trash screen mails which is deleted from inbox"""
|
2019-06-06 15:48:20 +02:00
|
|
|
try:
|
|
|
|
self.parent.screens[4].clear_widgets()
|
|
|
|
self.parent.screens[4].add_widget(Trash())
|
2019-09-06 17:20:58 +02:00
|
|
|
self.parent.screens[16].clear_widgets()
|
|
|
|
self.parent.screens[16].add_widget(Allmails())
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-06-06 15:48:20 +02:00
|
|
|
self.parent.parent.screens[4].clear_widgets()
|
|
|
|
self.parent.parent.screens[4].add_widget(Trash())
|
2019-09-06 17:20:58 +02:00
|
|
|
self.parent.parent.screens[16].clear_widgets()
|
|
|
|
self.parent.parent.screens[16].add_widget(Allmails())
|
2019-05-28 13:12:51 +02:00
|
|
|
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2018-07-18 14:49:39 +02:00
|
|
|
class Trash(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Trash Screen uses screen to show widgets of screens"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
trash_messages = ListProperty()
|
|
|
|
has_refreshed = True
|
2019-12-26 16:56:04 +01:00
|
|
|
# delete_index = StringProperty()
|
2019-12-12 15:38:07 +01:00
|
|
|
table_name = StringProperty()
|
2019-08-20 15:11:18 +02:00
|
|
|
|
2018-08-21 14:48:16 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Trash method, delete sent message and add in Trash"""
|
2018-08-21 14:48:16 +02:00
|
|
|
super(Trash, self).__init__(*args, **kwargs)
|
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Clock Schdule for method trash screen"""
|
2019-06-28 16:54:47 +02:00
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.trashDataQuery(0, 20)
|
|
|
|
if self.trash_messages:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'Trash'
|
2020-01-09 16:09:01 +01:00
|
|
|
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
|
|
|
# src_mng_obj.trash_cnt.badge_text = state.trash_count
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_TrashCnt(state.trash_count)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_mdList()
|
|
|
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
2019-09-06 17:20:58 +02:00
|
|
|
else:
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_TrashCnt('0')
|
2019-09-06 17:20:58 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-09-06 17:20:58 +02:00
|
|
|
theme_text_color='Primary',
|
|
|
|
text="yet no trashed message for this account!!!!!!!!!!!!!",
|
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def trashDataQuery(self, start_indx, end_indx):
|
|
|
|
"""Trash message query"""
|
|
|
|
self.trash_messages = sqlQuery(
|
|
|
|
"SELECT toaddress, fromaddress, subject, message,"
|
|
|
|
" folder ||',' || 'sent' as folder, ackdata As"
|
2020-02-05 09:53:04 +01:00
|
|
|
" id, DATE(senttime) As actionTime, senttime as msgtime FROM sent"
|
2019-12-12 15:38:07 +01:00
|
|
|
" WHERE folder = 'trash' and fromaddress = '{0}' UNION"
|
|
|
|
" SELECT toaddress, fromaddress, subject, message,"
|
|
|
|
" folder ||',' || 'inbox' as folder, msgid As id,"
|
2020-02-05 09:53:04 +01:00
|
|
|
" DATE(received) As actionTime, received as msgtime FROM inbox"
|
2019-12-12 15:38:07 +01:00
|
|
|
" WHERE folder = 'trash' and toaddress = '{0}'"
|
|
|
|
" ORDER BY actionTime DESC limit {1}, {2}".format(
|
|
|
|
state.association, start_indx, end_indx))
|
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
def set_TrashCnt(self, Count): # pylint: disable=no-self-use
|
2020-01-18 11:31:50 +01:00
|
|
|
"""This method is used to set trash message count"""
|
|
|
|
trashCnt_obj = state.kivyapp.root.ids.content_drawer.ids.trash_cnt
|
|
|
|
trashCnt_obj.children[0].children[0].text = showLimitedCnt(int(Count))
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def set_mdList(self):
|
|
|
|
"""This method is used to create the mdlist"""
|
|
|
|
total_trash_msg = len(self.ids.ml.children)
|
|
|
|
for item in self.trash_messages:
|
2020-03-18 11:37:02 +01:00
|
|
|
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
|
|
|
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
2019-12-12 15:38:07 +01:00
|
|
|
meny = TwoLineAvatarIconListItem(
|
|
|
|
text=item[1],
|
2020-03-02 11:42:15 +01:00
|
|
|
secondary_text=(item[2][:50] + '........' if len(
|
|
|
|
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
2019-12-12 15:38:07 +01:00
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
|
|
|
img_latter = './images/text_images/{}.png'.format(
|
2020-02-05 14:34:54 +01:00
|
|
|
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
|
2019-12-12 15:38:07 +01:00
|
|
|
meny.add_widget(AvatarSampleWidget(source=img_latter))
|
2020-02-05 09:53:04 +01:00
|
|
|
meny.add_widget(AddTimeWidget(item[7]))
|
2020-02-19 16:46:13 +01:00
|
|
|
meny.add_widget(chipTag('inbox 'if 'inbox' in item[4] else 'sent'))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
carousel.height = meny.height
|
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
|
|
|
del_btn.bind(on_press=partial(
|
|
|
|
self.delete_permanently, item[5], item[4]))
|
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
self.has_refreshed = True if total_trash_msg != len(
|
|
|
|
self.ids.ml.children) else False
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""Load data on scroll"""
|
|
|
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
|
|
|
self.ids.scroll_y.scroll_y = 0.06
|
|
|
|
total_trash_msg = len(self.ids.ml.children)
|
|
|
|
self.update_trash_screen_on_scroll(total_trash_msg)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_trash_screen_on_scroll(self, total_trash_msg):
|
|
|
|
"""Load more data on scroll down"""
|
|
|
|
self.trashDataQuery(total_trash_msg, 5)
|
|
|
|
self.set_mdList()
|
|
|
|
|
|
|
|
def delete_permanently(self, data_index, folder, instance, *args):
|
|
|
|
"""Deleting trash mail permanently"""
|
|
|
|
self.table_name = folder.split(',')[1]
|
|
|
|
self.delete_index = data_index
|
|
|
|
self.delete_confirmation()
|
|
|
|
|
|
|
|
def callback_for_screen_load(self, dt=0):
|
|
|
|
"""This methos is for loading screen"""
|
|
|
|
self.ids.ml.clear_widgets()
|
|
|
|
self.init_ui(0)
|
|
|
|
self.children[1].active = False
|
|
|
|
toast('Message is permanently deleted')
|
|
|
|
|
|
|
|
def delete_confirmation(self):
|
|
|
|
"""Show confirmation delete popup"""
|
2019-12-30 09:05:07 +01:00
|
|
|
width = .8 if platform == 'android' else .55
|
2019-12-12 15:38:07 +01:00
|
|
|
delete_msg_dialog = MDDialog(
|
|
|
|
text='Are you sure you want to delete this'
|
|
|
|
' message permanently from trash?',
|
|
|
|
title='',
|
2019-12-30 09:05:07 +01:00
|
|
|
size_hint=(width, .25),
|
2019-12-12 15:38:07 +01:00
|
|
|
text_button_ok='Yes',
|
|
|
|
text_button_cancel='No',
|
|
|
|
events_callback=self.callback_for_delete_msg)
|
|
|
|
delete_msg_dialog.open()
|
|
|
|
|
2019-12-26 16:56:04 +01:00
|
|
|
def callback_for_delete_msg(self, text_item, *arg):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting the callback of alert box"""
|
|
|
|
if text_item == 'Yes':
|
|
|
|
self.delete_message_from_trash()
|
|
|
|
else:
|
|
|
|
toast(text_item)
|
|
|
|
|
|
|
|
def delete_message_from_trash(self):
|
|
|
|
"""Deleting message from trash"""
|
|
|
|
self.children[1].active = True
|
|
|
|
if self.table_name == 'inbox':
|
2020-01-07 12:28:29 +01:00
|
|
|
sqlExecute(
|
|
|
|
"DELETE FROM inbox WHERE msgid = ?;", self.delete_index)
|
2019-12-12 15:38:07 +01:00
|
|
|
elif self.table_name == 'sent':
|
2020-01-07 12:28:29 +01:00
|
|
|
sqlExecute(
|
|
|
|
"DELETE FROM sent WHERE ackdata = ?;", self.delete_index)
|
2019-12-12 15:38:07 +01:00
|
|
|
if int(state.trash_count) > 0:
|
2020-01-09 16:09:01 +01:00
|
|
|
# msg_count_objs.trash_cnt.badge_text = str(
|
|
|
|
# int(state.trash_count) - 1)
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_TrashCnt(int(state.trash_count) - 1)
|
2019-12-12 15:38:07 +01:00
|
|
|
state.trash_count = str(int(state.trash_count) - 1)
|
|
|
|
Clock.schedule_once(self.callback_for_screen_load, 1)
|
2018-08-21 14:48:16 +02:00
|
|
|
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Page(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Page Screen show widgets of page"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
2018-07-03 11:08:02 +02:00
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Create(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Creates the screen widgets"""
|
2019-08-20 15:11:18 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, **kwargs):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Getting Labels and address from addressbook"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(Create, self).__init__(**kwargs)
|
|
|
|
widget_1 = DropDownWidget()
|
2019-08-05 12:19:19 +02:00
|
|
|
widget_1.ids.txt_input.word_list = [
|
|
|
|
addr[1] for addr in sqlQuery(
|
|
|
|
"SELECT label, address from addressbook")]
|
2019-05-09 14:48:29 +02:00
|
|
|
widget_1.ids.txt_input.starting_no = 2
|
|
|
|
self.add_widget(widget_1)
|
2018-08-31 14:34:20 +02:00
|
|
|
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Setting(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Setting the Screen components"""
|
2020-02-19 16:46:13 +01:00
|
|
|
exp_text = "By default, if you send a message to someone and he is offline for more than two days, Bitmessage will\
|
|
|
|
send the message again after an additional two days. This will be continued with exponential backoff\
|
2020-03-18 11:37:02 +01:00
|
|
|
forever; messages will be resent after 5, 10, 20 days ect. until the receiver acknowledges them.\
|
|
|
|
Here you may change that behavior by having Bitmessage give up after a certain number of days \
|
|
|
|
or months."
|
2018-07-03 11:08:02 +02:00
|
|
|
|
2018-07-07 14:11:58 +02:00
|
|
|
|
2020-01-09 16:09:01 +01:00
|
|
|
class NavigateApp(MDApp):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Navigation Layout of class"""
|
2020-01-21 09:09:56 +01:00
|
|
|
# pylint: disable=too-many-public-methods,inconsistent-return-statements
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2020-01-09 16:09:01 +01:00
|
|
|
# theme_cls = ThemeManager()
|
2019-05-09 14:48:29 +02:00
|
|
|
previous_date = ObjectProperty()
|
|
|
|
obj_1 = ObjectProperty()
|
2020-01-28 11:19:11 +01:00
|
|
|
variable_1 = ListProperty(addr for addr in BMConfigParser().addresses()
|
|
|
|
if BMConfigParser().get(str(addr), 'enabled') == 'true')
|
2019-05-09 14:48:29 +02:00
|
|
|
nav_drawer = ObjectProperty()
|
2019-06-28 16:54:47 +02:00
|
|
|
state.screen_density = Window.size
|
2019-09-11 17:03:51 +02:00
|
|
|
window_size = state.screen_density
|
2019-12-30 09:05:07 +01:00
|
|
|
app_platform = platform
|
2019-05-13 13:31:33 +02:00
|
|
|
title = "PyBitmessage"
|
2019-07-17 10:50:27 +02:00
|
|
|
imgstatus = False
|
2019-05-09 14:48:29 +02:00
|
|
|
count = 0
|
2020-02-19 16:46:13 +01:00
|
|
|
manager_open = False
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def build(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method builds the widget"""
|
2020-01-10 15:07:43 +01:00
|
|
|
for kv_file in KVFILES:
|
2020-01-21 09:09:56 +01:00
|
|
|
Builder.load_file(os.path.join(os.path.dirname(__file__), "kv/{}.kv").format(kv_file))
|
2019-05-09 14:48:29 +02:00
|
|
|
self.obj_1 = AddressBook()
|
|
|
|
kivysignalthread = UIkivySignaler()
|
|
|
|
kivysignalthread.daemon = True
|
|
|
|
kivysignalthread.start()
|
2020-01-20 09:45:54 +01:00
|
|
|
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
|
2020-01-10 15:07:43 +01:00
|
|
|
return Builder.load_file(
|
|
|
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def run(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Running the widgets"""
|
2019-05-09 14:48:29 +02:00
|
|
|
kivyuisignaler.release()
|
|
|
|
super(NavigateApp, self).run()
|
2018-07-24 14:42:53 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
@staticmethod
|
|
|
|
def showmeaddresses(name="text"):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Show the addresses in spinner to make as dropdown"""
|
2019-05-09 14:48:29 +02:00
|
|
|
if name == "text":
|
2019-08-05 09:24:32 +02:00
|
|
|
if BMConfigParser().addresses():
|
2019-05-09 14:48:29 +02:00
|
|
|
return BMConfigParser().addresses()[0][:16] + '..'
|
2019-08-20 15:11:18 +02:00
|
|
|
return "textdemo"
|
2019-05-09 14:48:29 +02:00
|
|
|
elif name == "values":
|
|
|
|
if BMConfigParser().addresses():
|
2019-08-06 12:05:03 +02:00
|
|
|
return [address[:16] + '..'
|
|
|
|
for address in BMConfigParser().addresses()]
|
2019-08-20 15:11:18 +02:00
|
|
|
return "valuesdemo"
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def getCurrentAccountData(self, text):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Get Current Address Account Data"""
|
2020-02-19 16:46:13 +01:00
|
|
|
if os.path.exists('./images/default_identicon/{}.png'.format(text)):
|
|
|
|
self.load_selected_Image(text)
|
|
|
|
else:
|
|
|
|
self.set_identicon(text)
|
2019-08-05 12:19:19 +02:00
|
|
|
address_label = self.current_address_label(
|
2019-08-22 17:37:50 +02:00
|
|
|
BMConfigParser().get(text, 'label'), text)
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root_window.children[1].ids.toolbar.title = address_label
|
2019-05-09 14:48:29 +02:00
|
|
|
state.association = text
|
2019-09-27 18:31:37 +02:00
|
|
|
state.searcing_text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
LoadingPopup().open()
|
|
|
|
self.set_message_count()
|
2020-02-05 09:53:04 +01:00
|
|
|
for nav_obj in self.root.ids.content_drawer.children[
|
2020-03-18 11:37:02 +01:00
|
|
|
0].children[0].children[0].children:
|
2020-02-05 09:53:04 +01:00
|
|
|
nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
|
|
|
|
|
|
|
def setCurrentAccountData(self, dt=0):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""This method set the current accout data on all the screens"""
|
2019-09-27 18:31:37 +02:00
|
|
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc1.loadMessagelist(state.association)
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
2019-12-30 09:05:07 +01:00
|
|
|
self.root.ids.sc4.children[2].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc4.loadSent(state.association)
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc16.clear_widgets()
|
|
|
|
self.root.ids.sc16.add_widget(Draft())
|
|
|
|
|
|
|
|
self.root.ids.sc5.clear_widgets()
|
|
|
|
self.root.ids.sc5.add_widget(Trash())
|
|
|
|
|
|
|
|
self.root.ids.sc17.clear_widgets()
|
|
|
|
self.root.ids.sc17.add_widget(Allmails())
|
|
|
|
|
2020-01-29 17:14:39 +01:00
|
|
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc10.init_ui()
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
@staticmethod
|
|
|
|
def getCurrentAccount():
|
2019-12-12 15:38:07 +01:00
|
|
|
"""It uses to get current account label"""
|
2019-05-09 14:48:29 +02:00
|
|
|
if state.association:
|
|
|
|
return state.association
|
2019-08-20 15:11:18 +02:00
|
|
|
return "Bitmessage Login"
|
2018-09-05 16:18:57 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def addingtoaddressbook():
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Adding to address Book"""
|
2019-05-09 14:48:29 +02:00
|
|
|
p = GrashofPopup()
|
|
|
|
p.open()
|
|
|
|
|
2019-09-06 17:20:58 +02:00
|
|
|
def getDefaultAccData(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting Default Account Data"""
|
2019-05-09 14:48:29 +02:00
|
|
|
if BMConfigParser().addresses():
|
2019-09-18 09:44:00 +02:00
|
|
|
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
|
|
|
|
self.createFolder('./images/default_identicon/')
|
2019-09-24 17:21:34 +02:00
|
|
|
if platform == 'android':
|
2019-12-12 15:38:07 +01:00
|
|
|
# android_path = os.path.expanduser
|
|
|
|
# ("~/user/0/org.test.bitapp/files/app/")
|
|
|
|
android_path = os.path.join(
|
|
|
|
os.environ['ANDROID_PRIVATE'] + '/app/')
|
2019-09-25 13:45:45 +02:00
|
|
|
img.texture.save('{1}/images/default_identicon/{0}.png'.format(
|
|
|
|
BMConfigParser().addresses()[0], android_path))
|
2019-09-24 17:21:34 +02:00
|
|
|
else:
|
2020-02-19 16:46:13 +01:00
|
|
|
if not os.path.exists('./images/default_identicon/{}.png'.format(
|
2020-03-18 11:37:02 +01:00
|
|
|
BMConfigParser().addresses()[0])):
|
2020-02-19 16:46:13 +01:00
|
|
|
img.texture.save('./images/default_identicon/{}.png'.format(
|
|
|
|
BMConfigParser().addresses()[0]))
|
2019-05-09 14:48:29 +02:00
|
|
|
return BMConfigParser().addresses()[0]
|
|
|
|
return 'Select Address'
|
|
|
|
|
2019-09-09 16:17:07 +02:00
|
|
|
@staticmethod
|
|
|
|
def createFolder(directory):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Create directory when app starts"""
|
2019-09-06 17:20:58 +02:00
|
|
|
try:
|
|
|
|
if not os.path.exists(directory):
|
|
|
|
os.makedirs(directory)
|
|
|
|
except OSError:
|
2019-12-23 15:17:23 +01:00
|
|
|
print('Error: Creating directory. ' + directory)
|
2019-09-06 17:20:58 +02:00
|
|
|
|
2019-09-09 16:17:07 +02:00
|
|
|
@staticmethod
|
|
|
|
def get_default_image():
|
|
|
|
"""Getting default image on address"""
|
2019-09-06 17:20:58 +02:00
|
|
|
if BMConfigParser().addresses():
|
2019-12-12 15:38:07 +01:00
|
|
|
return './images/default_identicon/{}.png'.format(
|
|
|
|
BMConfigParser().addresses()[0])
|
2019-10-18 16:00:43 +02:00
|
|
|
return './images/no_identicons.png'
|
2019-09-06 17:20:58 +02:00
|
|
|
|
2020-01-18 11:31:50 +01:00
|
|
|
@staticmethod
|
|
|
|
def get_default_logo():
|
|
|
|
"""Getting default logo image"""
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
return './images/default_identicon/{}.png'.format(
|
|
|
|
BMConfigParser().addresses()[0])
|
|
|
|
return './images/drawer_logo1.png'
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def addressexist():
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Checking address existence"""
|
2019-05-28 13:12:51 +02:00
|
|
|
if BMConfigParser().addresses():
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
def on_key(self, window, key, *args):
|
2020-03-18 11:37:02 +01:00
|
|
|
# pylint: disable=inconsistent-return-statements, too-many-branches
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method is used for going on previous screen"""
|
2019-08-05 12:19:19 +02:00
|
|
|
if key == 27:
|
2019-12-12 15:38:07 +01:00
|
|
|
if state.in_search_mode and self.root.ids.scr_mngr.current != (
|
|
|
|
"mailDetail"):
|
|
|
|
self.closeSearchScreen()
|
|
|
|
elif self.root.ids.scr_mngr.current == "mailDetail":
|
2019-08-21 16:24:56 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'sent'\
|
|
|
|
if state.detailPageType == 'sent' else 'inbox' \
|
|
|
|
if state.detailPageType == 'inbox' else 'draft'
|
2019-09-11 17:03:51 +02:00
|
|
|
self.back_press()
|
2019-07-17 10:50:27 +02:00
|
|
|
elif self.root.ids.scr_mngr.current == "create":
|
2019-12-12 15:38:07 +01:00
|
|
|
self.save_draft()
|
|
|
|
self.set_common_header()
|
|
|
|
state.in_composer = False
|
2019-06-06 15:48:20 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
2019-07-17 10:50:27 +02:00
|
|
|
elif self.root.ids.scr_mngr.current == "showqrcode":
|
|
|
|
self.root.ids.scr_mngr.current = 'myaddress'
|
|
|
|
elif self.root.ids.scr_mngr.current == "random":
|
2019-08-02 11:11:33 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'login'
|
2020-03-09 08:54:10 +01:00
|
|
|
elif self.root.ids.scr_mngr.current == 'pay-options':
|
|
|
|
self.set_common_header()
|
|
|
|
self.root.ids.scr_mngr.current = 'payment'
|
2019-06-06 15:48:20 +02:00
|
|
|
else:
|
2019-12-23 15:48:03 +01:00
|
|
|
if state.kivyapp.variable_1:
|
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.scr_mngr.transition.direction = 'right'
|
2019-08-21 10:07:47 +02:00
|
|
|
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
2019-07-17 10:50:27 +02:00
|
|
|
return True
|
2019-12-18 17:17:07 +01:00
|
|
|
elif key == 13 and state.searcing_text:
|
|
|
|
if state.search_screen == 'inbox':
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc1.children[1].active = True
|
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
elif state.search_screen == 'addressbook':
|
|
|
|
self.root.ids.sc11.children[1].active = True
|
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
elif state.search_screen == 'myaddress':
|
2020-01-09 16:09:01 +01:00
|
|
|
self.loadMyAddressScreen(True)
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
elif state.search_screen == 'sent':
|
|
|
|
self.root.ids.sc4.children[1].active = True
|
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
|
|
|
|
def search_callback(self, dt=0):
|
|
|
|
"""Show data after loader is loaded"""
|
|
|
|
if state.search_screen == 'inbox':
|
|
|
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc1.loadMessagelist(state.association)
|
|
|
|
self.root.ids.sc1.children[1].active = False
|
|
|
|
elif state.search_screen == 'addressbook':
|
|
|
|
self.root.ids.sc11.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
|
|
|
self.root.ids.sc11.children[1].active = False
|
|
|
|
elif state.search_screen == 'myaddress':
|
|
|
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc10.init_ui()
|
2020-01-09 16:09:01 +01:00
|
|
|
self.loadMyAddressScreen(False)
|
2019-12-12 15:38:07 +01:00
|
|
|
else:
|
|
|
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc4.loadSent(state.association)
|
|
|
|
self.root.ids.sc4.children[1].active = False
|
|
|
|
self.root.ids.scr_mngr.current = state.search_screen
|
|
|
|
|
2020-01-09 16:09:01 +01:00
|
|
|
def loadMyAddressScreen(self, action):
|
|
|
|
"""loadMyAddressScreen method spin the loader"""
|
2020-01-29 17:14:39 +01:00
|
|
|
if len(self.root.ids.sc10.children) <= 2:
|
|
|
|
self.root.ids.sc10.children[0].active = action
|
2020-01-09 16:09:01 +01:00
|
|
|
else:
|
2020-01-29 17:14:39 +01:00
|
|
|
self.root.ids.sc10.children[1].active = action
|
2020-01-09 16:09:01 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def save_draft(self):
|
|
|
|
"""Saving drafts messages"""
|
|
|
|
composer_objs = self.root
|
|
|
|
from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
|
2020-03-02 11:42:15 +01:00
|
|
|
# to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
|
|
|
|
if from_addr and state.detailPageType != 'draft' \
|
2019-12-12 15:38:07 +01:00
|
|
|
and not state.in_sent_method:
|
|
|
|
Draft().draft_msg(composer_objs)
|
|
|
|
return
|
2019-07-17 10:50:27 +02:00
|
|
|
|
2019-08-21 10:07:47 +02:00
|
|
|
def reset(self, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Set transition direction"""
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.scr_mngr.transition.direction = 'left'
|
2019-08-21 10:07:47 +02:00
|
|
|
self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def status_dispatching(data):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Dispatching Status acknowledgment"""
|
2019-06-06 15:48:20 +02:00
|
|
|
ackData, message = data
|
|
|
|
if state.ackdata == ackData:
|
|
|
|
state.status.status = message
|
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
def clear_composer(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""If slow down, the new composer edit screen"""
|
2019-08-26 17:28:12 +02:00
|
|
|
self.set_navbar_for_composer()
|
2019-12-12 15:38:07 +01:00
|
|
|
composer_obj = self.root.ids.sc3.children[1].ids
|
2019-06-28 16:54:47 +02:00
|
|
|
composer_obj.ti.text = ''
|
2019-07-17 10:50:27 +02:00
|
|
|
composer_obj.btn.text = 'Select'
|
2019-06-28 16:54:47 +02:00
|
|
|
composer_obj.txt_input.text = ''
|
|
|
|
composer_obj.subject.text = ''
|
2019-08-23 12:26:35 +02:00
|
|
|
composer_obj.body.text = ''
|
2019-09-11 17:03:51 +02:00
|
|
|
state.in_composer = True
|
2019-12-12 15:38:07 +01:00
|
|
|
state.in_sent_method = False
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-08-26 17:28:12 +02:00
|
|
|
def set_navbar_for_composer(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clearing toolbar data when composer open"""
|
2019-08-26 17:28:12 +02:00
|
|
|
self.root.ids.toolbar.left_action_items = [
|
|
|
|
['arrow-left', lambda x: self.back_press()]]
|
2019-09-11 17:03:51 +02:00
|
|
|
self.root.ids.toolbar.right_action_items = [
|
2019-12-12 15:38:07 +01:00
|
|
|
['refresh',
|
|
|
|
lambda x: self.root.ids.sc3.children[1].reset_composer()],
|
|
|
|
['send',
|
|
|
|
lambda x: self.root.ids.sc3.children[1].send(self)]]
|
|
|
|
|
2020-01-28 11:19:11 +01:00
|
|
|
def set_toolbar_for_QrCode(self):
|
|
|
|
"""This method is use for setting Qr code toolbar."""
|
|
|
|
self.root.ids.toolbar.left_action_items = [
|
|
|
|
['arrow-left', lambda x: self.back_press()]]
|
|
|
|
self.root.ids.toolbar.right_action_items = []
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def set_common_header(self):
|
|
|
|
"""Common header for all window"""
|
|
|
|
self.root.ids.toolbar.right_action_items = [
|
|
|
|
['account-plus', lambda x: self.addingtoaddressbook()]]
|
2020-01-09 16:09:01 +01:00
|
|
|
# self.root.ids.toolbar.left_action_items = [
|
|
|
|
# ['menu', lambda x: self.root.toggle_nav_drawer()]]
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.toolbar.left_action_items = [
|
2020-01-28 11:19:11 +01:00
|
|
|
['menu', lambda x: self.root.ids.nav_drawer.set_state("toggle")]]
|
2019-12-12 15:38:07 +01:00
|
|
|
return
|
2019-08-26 17:28:12 +02:00
|
|
|
|
2019-08-21 10:07:47 +02:00
|
|
|
def back_press(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method for, reverting composer to previous page"""
|
2020-03-02 11:42:15 +01:00
|
|
|
if self.root.ids.scr_mngr.current == 'create':
|
|
|
|
self.save_draft()
|
2019-12-12 15:38:07 +01:00
|
|
|
if self.root.ids.scr_mngr.current == \
|
|
|
|
'mailDetail' and state.in_search_mode:
|
|
|
|
toolbar_obj = self.root.ids.toolbar
|
|
|
|
toolbar_obj.left_action_items = [
|
|
|
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
|
|
|
toolbar_obj.right_action_items = []
|
|
|
|
self.root.ids.toolbar.title = ''
|
|
|
|
else:
|
|
|
|
self.set_common_header()
|
2019-09-12 11:11:33 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'inbox' \
|
2019-10-18 16:00:43 +02:00
|
|
|
if state.in_composer else 'allmails'\
|
|
|
|
if state.is_allmail else state.detailPageType\
|
2020-01-28 11:19:11 +01:00
|
|
|
if state.detailPageType else 'myaddress'\
|
2020-03-09 08:54:10 +01:00
|
|
|
if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\
|
|
|
|
if self.root.ids.scr_mngr.current == 'pay-options' else 'inbox'
|
2019-08-21 10:07:47 +02:00
|
|
|
self.root.ids.scr_mngr.transition.direction = 'right'
|
|
|
|
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
2019-09-11 17:03:51 +02:00
|
|
|
if state.is_allmail or state.detailPageType == 'draft':
|
|
|
|
state.is_allmail = False
|
2019-08-23 12:26:35 +02:00
|
|
|
state.detailPageType = ''
|
2019-09-11 17:03:51 +02:00
|
|
|
state.in_composer = False
|
2019-08-21 10:07:47 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
@staticmethod
|
|
|
|
def get_inbox_count():
|
|
|
|
"""Getting inbox count"""
|
2019-12-20 15:07:31 +01:00
|
|
|
state.inbox_count = str(sqlQuery(
|
|
|
|
"SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
|
|
|
|
" folder = 'inbox' ;".format(state.association))[0][0])
|
2019-12-12 15:38:07 +01:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_sent_count():
|
|
|
|
"""Getting sent count"""
|
2019-12-20 15:07:31 +01:00
|
|
|
state.sent_count = str(sqlQuery(
|
|
|
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
|
|
|
" folder = 'sent' ;".format(state.association))[0][0])
|
2019-12-12 15:38:07 +01:00
|
|
|
|
|
|
|
def set_message_count(self):
|
|
|
|
"""Setting message count"""
|
2020-03-17 12:42:16 +01:00
|
|
|
msg_counter_objs = state.kivyapp.root.children[0].children[0].ids
|
|
|
|
# try:
|
|
|
|
# msg_counter_objs = (
|
|
|
|
# self.root_window.children[0].children[2].children[0].ids)
|
|
|
|
# except Exception:
|
|
|
|
# msg_counter_objs = (
|
|
|
|
# self.root_window.children[2].children[2].children[0].ids)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.get_inbox_count()
|
|
|
|
self.get_sent_count()
|
|
|
|
state.trash_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(state.association))[0][0])
|
2019-12-20 15:07:31 +01:00
|
|
|
state.draft_count = str(sqlQuery(
|
|
|
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
|
|
|
" folder = 'draft' ;".format(state.association))[0][0])
|
2019-12-12 15:38:07 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
def on_start(self):
|
2020-01-21 09:09:56 +01:00
|
|
|
"""Setting message count"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_message_count()
|
|
|
|
|
2020-01-20 09:45:54 +01:00
|
|
|
# @staticmethod
|
|
|
|
# def on_stop():
|
|
|
|
# """On stop methos is used for stoping the runing script"""
|
|
|
|
# print("*******************EXITING FROM APPLICATION*******************")
|
|
|
|
# import shutdown
|
|
|
|
# shutdown.doCleanShutdown()
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
2019-09-06 17:20:58 +02:00
|
|
|
def current_address_label(current_add_label=None, current_addr=None):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting current address labels"""
|
2019-08-22 17:37:50 +02:00
|
|
|
if BMConfigParser().addresses():
|
|
|
|
if current_add_label:
|
|
|
|
first_name = current_add_label
|
|
|
|
addr = current_addr
|
2019-08-02 11:11:33 +02:00
|
|
|
else:
|
2019-08-22 17:37:50 +02:00
|
|
|
addr = BMConfigParser().addresses()[0]
|
|
|
|
first_name = BMConfigParser().get(addr, 'label')
|
2019-07-17 10:50:27 +02:00
|
|
|
f_name = first_name.split()
|
2019-12-12 15:38:07 +01:00
|
|
|
label = f_name[0][:14].capitalize() + '...' if len(
|
|
|
|
f_name[0]) > 15 else f_name[0].capitalize()
|
2020-02-05 09:53:04 +01:00
|
|
|
address = ' (' + addr + ')'
|
2019-08-22 17:37:50 +02:00
|
|
|
return label + address
|
2019-07-17 10:50:27 +02:00
|
|
|
return ''
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-09-27 18:31:37 +02:00
|
|
|
def searchQuery(self, instance):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Showing searched mails"""
|
2019-08-06 12:35:07 +02:00
|
|
|
state.search_screen = self.root.ids.scr_mngr.current
|
|
|
|
state.searcing_text = str(instance.text).strip()
|
2019-12-12 15:38:07 +01:00
|
|
|
if instance.focus and state.searcing_text:
|
|
|
|
toolbar_obj = self.root.ids.toolbar
|
|
|
|
toolbar_obj.left_action_items = [
|
|
|
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
|
|
|
toolbar_obj.right_action_items = []
|
|
|
|
self.root.ids.toolbar.title = ''
|
|
|
|
state.in_search_mode = True
|
|
|
|
|
|
|
|
def closeSearchScreen(self):
|
|
|
|
"""Function for close search screen"""
|
|
|
|
self.set_common_header()
|
2020-01-10 15:07:43 +01:00
|
|
|
if state.association:
|
|
|
|
address_label = self.current_address_label(
|
|
|
|
BMConfigParser().get(
|
|
|
|
state.association, 'label'), state.association)
|
|
|
|
self.root.ids.toolbar.title = address_label
|
2019-12-12 15:38:07 +01:00
|
|
|
state.searcing_text = ''
|
|
|
|
self.refreshScreen()
|
|
|
|
state.in_search_mode = False
|
2019-08-02 11:11:33 +02:00
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
def refreshScreen(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method show search button only on inbox or sent screen"""
|
2020-01-04 15:17:44 +01:00
|
|
|
# pylint: disable=unused-variable
|
2019-09-27 18:31:37 +02:00
|
|
|
state.searcing_text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
if state.search_screen == 'inbox':
|
2019-09-27 18:31:37 +02:00
|
|
|
try:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc1.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
3].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
except Exception:
|
|
|
|
self.root.ids.sc1.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc1.children[1].active = True
|
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
elif state.search_screen == 'addressbook':
|
|
|
|
self.root.ids.sc11.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc11.children[
|
|
|
|
1].active = True
|
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
elif state.search_screen == 'myaddress':
|
2019-09-27 18:31:37 +02:00
|
|
|
try:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc10.children[
|
2020-01-29 17:14:39 +01:00
|
|
|
1].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
except Exception:
|
|
|
|
self.root.ids.sc10.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].children[2].ids.search_field.text = ''
|
2020-01-09 16:09:01 +01:00
|
|
|
self.loadMyAddressScreen(True)
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
|
|
|
else:
|
|
|
|
self.root.ids.sc4.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc4.children[1].active = True
|
|
|
|
Clock.schedule_once(self.search_callback, 0.5)
|
2019-08-02 11:11:33 +02:00
|
|
|
return
|
|
|
|
|
2019-09-06 17:20:58 +02:00
|
|
|
def set_identicon(self, text):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Show identicon in address spinner"""
|
2019-09-06 17:20:58 +02:00
|
|
|
img = identiconGeneration.generate(text)
|
2020-03-09 08:54:10 +01:00
|
|
|
# self.root.children[0].children[0].ids.btn.children[1].texture = (img.texture)
|
2020-01-20 13:59:02 +01:00
|
|
|
# below line is for displaing logo
|
2020-01-18 11:31:50 +01:00
|
|
|
self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
|
2019-09-06 17:20:58 +02:00
|
|
|
|
2019-09-11 17:03:51 +02:00
|
|
|
def set_mail_detail_header(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Setting the details of the page"""
|
2019-09-11 17:03:51 +02:00
|
|
|
toolbar_obj = self.root.ids.toolbar
|
2019-12-12 15:38:07 +01:00
|
|
|
toolbar_obj.left_action_items = [
|
|
|
|
['arrow-left', lambda x: self.back_press()]]
|
|
|
|
delete_btn = ['delete-forever',
|
|
|
|
lambda x: self.root.ids.sc14.delete_mail()]
|
2019-09-11 17:03:51 +02:00
|
|
|
dynamic_list = []
|
|
|
|
if state.detailPageType == 'inbox':
|
2019-12-12 15:38:07 +01:00
|
|
|
dynamic_list = [
|
|
|
|
['reply', lambda x: self.root.ids.sc14.inbox_reply()],
|
|
|
|
delete_btn]
|
2019-09-11 17:03:51 +02:00
|
|
|
elif state.detailPageType == 'sent':
|
|
|
|
dynamic_list = [delete_btn]
|
|
|
|
elif state.detailPageType == 'draft':
|
2019-12-12 15:38:07 +01:00
|
|
|
dynamic_list = [
|
|
|
|
['pencil', lambda x: self.root.ids.sc14.write_msg(self)],
|
|
|
|
delete_btn]
|
2019-09-11 17:03:51 +02:00
|
|
|
toolbar_obj.right_action_items = dynamic_list
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def load_screen(self, instance):
|
|
|
|
"""This method is used for loading screen on every click"""
|
|
|
|
if instance.text == 'Inbox':
|
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
|
|
|
self.root.ids.sc1.children[1].active = True
|
|
|
|
elif instance.text == 'All Mails':
|
|
|
|
self.root.ids.scr_mngr.current = 'allmails'
|
|
|
|
try:
|
|
|
|
self.root.ids.sc17.children[1].active = True
|
2019-12-23 15:17:23 +01:00
|
|
|
except Exception:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc17.children[0].children[1].active = True
|
|
|
|
Clock.schedule_once(partial(self.load_screen_callback, instance), 1)
|
|
|
|
|
|
|
|
def load_screen_callback(self, instance, dt=0):
|
|
|
|
"""This method is rotating loader for few seconds"""
|
|
|
|
if instance.text == 'Inbox':
|
|
|
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
|
|
|
self.root.ids.sc1.loadMessagelist(state.association)
|
|
|
|
self.root.ids.sc1.children[1].active = False
|
|
|
|
elif instance.text == 'All Mails':
|
2020-01-29 17:14:39 +01:00
|
|
|
# if len(self.root.ids.sc17.ids.ml.children) <= 2:
|
|
|
|
# self.root.ids.sc17.clear_widgets()
|
|
|
|
# self.root.ids.sc17.add_widget(Allmails())
|
|
|
|
# else:
|
|
|
|
# self.root.ids.sc17.ids.ml.clear_widgets()
|
|
|
|
# self.root.ids.sc17.loadMessagelist()
|
|
|
|
self.root.ids.sc17.clear_widgets()
|
|
|
|
self.root.ids.sc17.add_widget(Allmails())
|
2019-12-12 15:38:07 +01:00
|
|
|
try:
|
|
|
|
self.root.ids.sc17.children[1].active = False
|
2019-12-23 15:17:23 +01:00
|
|
|
except Exception:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.root.ids.sc17.children[0].children[1].active = False
|
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
def on_request_close(self, *args): # pylint: disable=no-self-use
|
2020-01-20 09:45:54 +01:00
|
|
|
"""This method is for app closing request"""
|
|
|
|
AppClosingPopup().open()
|
2020-01-17 15:09:26 +01:00
|
|
|
return True
|
2020-01-20 13:59:02 +01:00
|
|
|
|
2020-02-19 16:46:13 +01:00
|
|
|
def file_manager_open(self):
|
|
|
|
"""This method open the file manager of local system"""
|
|
|
|
from kivymd.uix.filemanager import MDFileManager
|
|
|
|
|
|
|
|
self.manager = ModalView(size_hint=(1, 1), auto_dismiss=False)
|
|
|
|
self.file_manager = MDFileManager(
|
|
|
|
exit_manager=self.exit_manager,
|
|
|
|
select_path=self.select_path,
|
|
|
|
previous=False,
|
|
|
|
ext=['.png', '.jpg']
|
|
|
|
)
|
|
|
|
self.manager.add_widget(self.file_manager)
|
|
|
|
self.file_manager.show(os.environ["HOME"])
|
|
|
|
self.manager_open = True
|
|
|
|
self.manager.open()
|
|
|
|
|
|
|
|
def select_path(self, path):
|
|
|
|
"""This method is used to save the select image"""
|
|
|
|
from PIL import Image as PilImage
|
|
|
|
if not os.path.exists('./images/default_identicon/'):
|
|
|
|
os.makedirs('./images/default_identicon/')
|
2020-03-18 11:37:02 +01:00
|
|
|
newImg = PilImage.open(path).resize((300, 300))
|
2020-02-19 16:46:13 +01:00
|
|
|
newImg.save('./images/default_identicon/{0}.png'.format(state.association))
|
|
|
|
self.load_selected_Image(state.association)
|
|
|
|
self.exit_manager()
|
|
|
|
toast('Image changed')
|
|
|
|
|
|
|
|
def exit_manager(self, *args):
|
|
|
|
"""Called when the user reaches the root of the directory tree."""
|
|
|
|
|
|
|
|
self.manager.dismiss()
|
|
|
|
self.manager_open = False
|
|
|
|
|
|
|
|
def load_selected_Image(self, curerentAddr):
|
|
|
|
"""This method load the selected image on screen"""
|
|
|
|
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
2020-03-09 08:54:10 +01:00
|
|
|
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
|
|
|
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
2020-03-18 11:37:02 +01:00
|
|
|
top_box_obj.source = './images/default_identicon/{0}.png'.format(curerentAddr)
|
2020-02-19 16:46:13 +01:00
|
|
|
top_box_obj.reload()
|
2020-03-09 08:54:10 +01:00
|
|
|
# spinner_img_obj.reload()
|
2020-02-19 16:46:13 +01:00
|
|
|
|
2020-03-18 11:37:02 +01:00
|
|
|
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
2020-03-02 11:42:15 +01:00
|
|
|
"""Copy the data from mail detail page"""
|
|
|
|
Clipboard.copy(text)
|
|
|
|
toast('Copied')
|
|
|
|
|
2019-08-07 10:12:41 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class GrashofPopup(Popup):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Moule for save contacts and error messages"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
valid = False
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
def __init__(self, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Grash of pop screen settings"""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(GrashofPopup, self).__init__(**kwargs)
|
|
|
|
|
|
|
|
def savecontact(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method is used for saving contacts"""
|
2019-09-06 17:20:58 +02:00
|
|
|
label = self.ids.label.text.strip()
|
|
|
|
address = self.ids.address.text.strip()
|
|
|
|
if label == '' and address == '':
|
|
|
|
self.ids.label.focus = True
|
|
|
|
self.ids.address.focus = True
|
|
|
|
elif address == '':
|
|
|
|
self.ids.address.focus = True
|
|
|
|
elif label == '':
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.label.focus = True
|
|
|
|
|
2019-08-13 13:54:04 +02:00
|
|
|
stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
|
|
|
folder="addressbook")]
|
2019-12-12 15:38:07 +01:00
|
|
|
stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
|
|
|
folder="addressbook")]
|
|
|
|
if label and address and address not in stored_address \
|
|
|
|
and label not in stored_labels and self.valid:
|
2019-10-18 16:00:43 +02:00
|
|
|
# state.navinstance = self.parent.children[1]
|
2019-05-09 14:48:29 +02:00
|
|
|
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
|
|
|
self.dismiss()
|
|
|
|
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.parent.children[1].ids.sc11.ids.ml.clear_widgets()
|
|
|
|
self.parent.children[1].ids.sc11.loadAddresslist(None, 'All', '')
|
2019-06-28 16:54:47 +02:00
|
|
|
self.parent.children[1].ids.scr_mngr.current = 'addressbook'
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Saved')
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2019-08-17 14:43:10 +02:00
|
|
|
@staticmethod
|
|
|
|
def close_pop():
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Pop is Canceled"""
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Canceled')
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2019-09-06 17:20:58 +02:00
|
|
|
def checkAddress_valid(self, instance):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Checking address is valid or not"""
|
2020-01-09 16:09:01 +01:00
|
|
|
# my_addresses = (
|
|
|
|
# self.parent.children[1].children[2].children[0].ids.btn.values)
|
2019-12-12 15:38:07 +01:00
|
|
|
my_addresses = (
|
2020-01-09 16:09:01 +01:00
|
|
|
self.parent.children[1].children[0].children[0].ids.btn.values)
|
2019-09-06 17:20:58 +02:00
|
|
|
add_book = [addr[1] for addr in kivy_helper_search.search_sql(
|
|
|
|
folder="addressbook")]
|
|
|
|
entered_text = str(instance.text).strip()
|
|
|
|
if entered_text in add_book:
|
|
|
|
text = 'Address is already in the addressbook.'
|
|
|
|
elif entered_text in my_addresses:
|
|
|
|
text = 'You can not save your own address.'
|
2019-12-12 15:38:07 +01:00
|
|
|
elif entered_text:
|
|
|
|
text = self.addressChanged(entered_text)
|
2019-09-06 17:20:58 +02:00
|
|
|
|
|
|
|
if entered_text in my_addresses or entered_text in add_book:
|
2019-12-12 15:38:07 +01:00
|
|
|
self.ids.address.error = True
|
|
|
|
self.ids.address.helper_text = text
|
|
|
|
elif entered_text and self.valid:
|
|
|
|
self.ids.address.error = False
|
|
|
|
elif entered_text:
|
|
|
|
self.ids.address.error = True
|
|
|
|
self.ids.address.helper_text = text
|
|
|
|
else:
|
|
|
|
self.ids.address.error = False
|
|
|
|
self.ids.address.helper_text = 'This field is required'
|
|
|
|
|
|
|
|
def checkLabel_valid(self, instance):
|
|
|
|
"""Checking address label is unique or not"""
|
|
|
|
entered_label = instance.text.strip()
|
|
|
|
addr_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
|
|
|
folder="addressbook")]
|
|
|
|
if entered_label in addr_labels:
|
|
|
|
self.ids.label.error = True
|
|
|
|
self.ids.label.helper_text = 'label name already exists.'
|
|
|
|
elif entered_label:
|
|
|
|
self.ids.label.error = False
|
|
|
|
else:
|
|
|
|
self.ids.label.error = False
|
|
|
|
self.ids.label.helper_text = 'This field is required'
|
|
|
|
|
|
|
|
def _onSuccess(self, addressVersion, streamNumber, ripe):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def addressChanged(self, addr):
|
|
|
|
"""Address validation callback, performs validation and gives feedback"""
|
|
|
|
status, addressVersion, streamNumber, ripe = decodeAddress(
|
|
|
|
str(addr))
|
|
|
|
self.valid = status == 'success'
|
|
|
|
if self.valid:
|
|
|
|
text = "Address is valid."
|
|
|
|
self._onSuccess(addressVersion, streamNumber, ripe)
|
|
|
|
elif status == 'missingbm':
|
|
|
|
text = "The address should start with ''BM-''"
|
|
|
|
elif status == 'checksumfailed':
|
2020-01-07 12:28:29 +01:00
|
|
|
text = (
|
|
|
|
"The address is not typed or copied correctly"
|
|
|
|
" (the checksum failed).")
|
2019-12-12 15:38:07 +01:00
|
|
|
elif status == 'versiontoohigh':
|
2020-01-04 15:17:44 +01:00
|
|
|
text = (
|
|
|
|
"The version number of this address is higher than this"
|
|
|
|
" software can support. Please upgrade Bitmessage.")
|
2019-12-12 15:38:07 +01:00
|
|
|
elif status == 'invalidcharacters':
|
|
|
|
text = "The address contains invalid characters."
|
|
|
|
elif status == 'ripetooshort':
|
|
|
|
text = "Some data encoded in the address is too short."
|
|
|
|
elif status == 'ripetoolong':
|
|
|
|
text = "Some data encoded in the address is too long."
|
|
|
|
elif status == 'varintmalformed':
|
|
|
|
text = "Some data encoded in the address is malformed."
|
|
|
|
return text
|
2019-09-06 17:20:58 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
class AvatarSampleWidget(ILeftBody, Image):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Avatar Sample Widget"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
2018-09-05 16:12:55 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Left icon sample widget"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
2018-09-05 16:12:55 +02:00
|
|
|
|
|
|
|
|
2020-03-02 11:42:15 +01:00
|
|
|
class IconRightSampleWidget(IRightBodyTouch, MDIconButton):
|
2020-02-19 16:46:13 +01:00
|
|
|
"""Right icon sample widget"""
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-01-29 17:14:39 +01:00
|
|
|
class ToggleBtn(IRightBodyTouch, MDSwitch):
|
|
|
|
"""Right toggle button widget"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-03-09 08:54:10 +01:00
|
|
|
class CheckboxLeftSampleWidget(ILeftBodyTouch, MDCheckbox):
|
|
|
|
"""Left icon sample widget"""
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-03-18 11:37:02 +01:00
|
|
|
class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
|
2019-12-12 15:38:07 +01:00
|
|
|
"""MailDetail Screen uses to show the detail of mails"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-05-28 13:12:51 +02:00
|
|
|
to_addr = StringProperty()
|
|
|
|
from_addr = StringProperty()
|
|
|
|
subject = StringProperty()
|
|
|
|
message = StringProperty()
|
2019-06-06 15:48:20 +02:00
|
|
|
status = StringProperty()
|
2019-08-05 09:24:32 +02:00
|
|
|
page_type = StringProperty()
|
2020-02-05 09:53:04 +01:00
|
|
|
time_tag = StringProperty()
|
|
|
|
avatarImg = StringProperty()
|
2019-05-28 13:12:51 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Mail Details method"""
|
2019-06-06 15:48:20 +02:00
|
|
|
super(MailDetail, self).__init__(*args, **kwargs)
|
2019-05-28 13:12:51 +02:00
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method MailDetail mails"""
|
2019-06-28 16:54:47 +02:00
|
|
|
self.page_type = state.detailPageType if state.detailPageType else ''
|
2019-08-19 13:06:24 +02:00
|
|
|
if state.detailPageType == 'sent' or state.detailPageType == 'draft':
|
2019-08-05 09:24:32 +02:00
|
|
|
data = sqlQuery(
|
2019-12-12 15:38:07 +01:00
|
|
|
"select toaddress, fromaddress, subject, message, status,"
|
2020-02-05 09:53:04 +01:00
|
|
|
" ackdata, senttime from sent where ackdata = ?;", state.mail_id)
|
2019-06-06 15:48:20 +02:00
|
|
|
state.status = self
|
|
|
|
state.ackdata = data[0][5]
|
|
|
|
self.assign_mail_details(data)
|
2019-09-11 17:03:51 +02:00
|
|
|
state.kivyapp.set_mail_detail_header()
|
2019-06-06 15:48:20 +02:00
|
|
|
elif state.detailPageType == 'inbox':
|
2019-08-05 09:24:32 +02:00
|
|
|
data = sqlQuery(
|
2020-02-05 09:53:04 +01:00
|
|
|
"select toaddress, fromaddress, subject, message, received from inbox"
|
2019-12-18 17:17:07 +01:00
|
|
|
" where msgid = ?;", state.mail_id)
|
2019-06-06 15:48:20 +02:00
|
|
|
self.assign_mail_details(data)
|
2019-09-11 17:03:51 +02:00
|
|
|
state.kivyapp.set_mail_detail_header()
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-08-05 09:24:32 +02:00
|
|
|
def assign_mail_details(self, data):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Assigning mail details"""
|
2020-03-18 11:37:02 +01:00
|
|
|
subject = data[0][2].decode() if isinstance(data[0][2], bytes) else data[0][2]
|
|
|
|
body = data[0][3].decode() if isinstance(data[0][2], bytes) else data[0][3]
|
2020-03-02 11:42:15 +01:00
|
|
|
self.to_addr = data[0][0] if len(data[0][0]) > 4 else ' '
|
2019-06-06 15:48:20 +02:00
|
|
|
self.from_addr = data[0][1]
|
2020-02-05 14:34:54 +01:00
|
|
|
|
2020-02-19 16:46:13 +01:00
|
|
|
self.subject = subject.capitalize(
|
|
|
|
) if subject.capitalize() else '(no subject)'
|
2020-02-05 14:34:54 +01:00
|
|
|
self.message = body
|
2020-02-05 09:53:04 +01:00
|
|
|
if len(data[0]) == 7:
|
2019-06-06 15:48:20 +02:00
|
|
|
self.status = data[0][4]
|
2020-02-05 09:53:04 +01:00
|
|
|
self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6])
|
2020-03-18 11:37:02 +01:00
|
|
|
self.avatarImg = './images/avatar.png' if state.detailPageType == 'draft' else (
|
2020-02-19 16:46:13 +01:00
|
|
|
'./images/text_images/{0}.png'.format(avatarImageFirstLetter(self.subject.strip())))
|
|
|
|
self.timeinseconds = data[0][4] if state.detailPageType == 'inbox' else data[0][6]
|
2019-06-06 15:48:20 +02:00
|
|
|
|
|
|
|
def delete_mail(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method for mail delete"""
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs = state.kivyapp.root.ids.content_drawer.ids
|
2019-12-12 15:38:07 +01:00
|
|
|
state.searcing_text = ''
|
|
|
|
self.children[0].children[0].active = True
|
2019-06-06 15:48:20 +02:00
|
|
|
if state.detailPageType == 'sent':
|
2019-12-12 15:38:07 +01:00
|
|
|
state.kivyapp.root.ids.sc4.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].children[2].ids.search_field.text = ''
|
2019-08-06 12:05:03 +02:00
|
|
|
sqlExecute(
|
2019-12-12 15:38:07 +01:00
|
|
|
"UPDATE sent SET folder = 'trash' WHERE"
|
2019-12-13 17:20:27 +01:00
|
|
|
" ackdata = ?;", state.mail_id)
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.send_cnt.children[0].children[0].text = str(int(state.sent_count) - 1)
|
2019-07-17 10:50:27 +02:00
|
|
|
state.sent_count = str(int(state.sent_count) - 1)
|
2019-09-27 18:31:37 +02:00
|
|
|
self.parent.screens[3].ids.ml.clear_widgets()
|
|
|
|
self.parent.screens[3].loadSent(state.association)
|
2019-06-28 16:54:47 +02:00
|
|
|
elif state.detailPageType == 'inbox':
|
2019-12-12 15:38:07 +01:00
|
|
|
state.kivyapp.root.ids.sc1.children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].children[2].ids.search_field.text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.parent.screens[0].children[2].children[
|
2019-12-30 09:05:07 +01:00
|
|
|
2].ids.search_field.text = ''
|
2019-08-06 12:05:03 +02:00
|
|
|
sqlExecute(
|
2019-12-12 15:38:07 +01:00
|
|
|
"UPDATE inbox SET folder = 'trash' WHERE"
|
2019-12-26 16:56:04 +01:00
|
|
|
" msgid = ?;", state.mail_id)
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.inbox_cnt.children[0].children[0].text = str(
|
|
|
|
int(state.inbox_count) - 1)
|
2019-10-18 16:00:43 +02:00
|
|
|
state.inbox_count = str(int(state.inbox_count) - 1)
|
2019-09-27 18:31:37 +02:00
|
|
|
self.parent.screens[0].ids.ml.clear_widgets()
|
|
|
|
self.parent.screens[0].loadMessagelist(state.association)
|
2019-12-12 15:38:07 +01:00
|
|
|
|
2019-09-11 17:03:51 +02:00
|
|
|
elif state.detailPageType == 'draft':
|
2019-12-26 16:56:04 +01:00
|
|
|
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", state.mail_id)
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.draft_cnt.children[0].children[0].text = str(
|
|
|
|
int(state.draft_count) - 1)
|
2019-09-11 17:03:51 +02:00
|
|
|
state.draft_count = str(int(state.draft_count) - 1)
|
|
|
|
self.parent.screens[15].clear_widgets()
|
|
|
|
self.parent.screens[15].add_widget(Draft())
|
|
|
|
|
|
|
|
if state.detailPageType != 'draft':
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.trash_cnt.children[0].children[0].text = str(
|
|
|
|
int(state.trash_count) + 1)
|
|
|
|
msg_count_objs.allmail_cnt.children[0].children[0].text = str(
|
|
|
|
int(state.all_count) - 1)
|
2019-09-11 17:03:51 +02:00
|
|
|
state.trash_count = str(int(state.trash_count) + 1)
|
2019-12-23 15:48:03 +01:00
|
|
|
state.all_count = str(int(state.all_count) - 1) if int(state.all_count) else '0'
|
2019-12-13 17:20:27 +01:00
|
|
|
self.parent.screens[4].clear_widgets()
|
|
|
|
self.parent.screens[4].add_widget(Trash())
|
2019-12-30 09:05:07 +01:00
|
|
|
self.parent.screens[16].clear_widgets()
|
|
|
|
self.parent.screens[16].add_widget(Allmails())
|
2019-12-12 15:38:07 +01:00
|
|
|
Clock.schedule_once(self.callback_for_delete, 4)
|
|
|
|
|
|
|
|
def callback_for_delete(self, dt=0):
|
|
|
|
"""Delete method from allmails"""
|
2020-03-02 11:42:15 +01:00
|
|
|
if state.detailPageType:
|
2020-02-19 16:46:13 +01:00
|
|
|
self.children[0].children[0].active = False
|
|
|
|
state.kivyapp.set_common_header()
|
|
|
|
self.parent.current = 'allmails' \
|
|
|
|
if state.is_allmail else state.detailPageType
|
|
|
|
state.detailPageType = ''
|
|
|
|
toast('Deleted')
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
def inbox_reply(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Reply inbox messages"""
|
2019-08-05 09:24:32 +02:00
|
|
|
data = sqlQuery(
|
2020-03-17 12:42:16 +01:00
|
|
|
"select toaddress, fromaddress, subject, message, received from inbox where"
|
2019-12-26 16:56:04 +01:00
|
|
|
" msgid = ?;", state.mail_id)
|
2019-12-12 15:38:07 +01:00
|
|
|
composer_obj = self.parent.screens[2].children[1].ids
|
2019-09-11 17:03:51 +02:00
|
|
|
composer_obj.ti.text = data[0][0]
|
|
|
|
composer_obj.btn.text = data[0][0]
|
|
|
|
composer_obj.txt_input.text = data[0][1]
|
2020-03-17 12:42:16 +01:00
|
|
|
split_subject = data[0][2].split('Re:', 1)
|
2020-03-18 11:51:18 +01:00
|
|
|
composer_obj.subject.text = 'Re: ' + (split_subject[1] if len(split_subject) > 1 else split_subject[0])
|
2020-03-17 12:42:16 +01:00
|
|
|
time_obj = datetime.fromtimestamp(int(data[0][4]))
|
|
|
|
time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
|
|
|
|
sender_name = BMConfigParser().get(data[0][1], 'label')
|
2020-03-18 11:51:18 +01:00
|
|
|
composer_obj.body.text = (
|
|
|
|
'\n\n ------------------------On ' + time_tag + ', '
|
|
|
|
+ sender_name + ' wrote:-----------------------\n' + data[0][3])
|
2020-03-17 12:42:16 +01:00
|
|
|
composer_obj.body.focus = True
|
|
|
|
composer_obj.body.cursor = (0, 0)
|
2019-12-12 15:38:07 +01:00
|
|
|
state.kivyapp.root.ids.sc3.children[1].ids.rv.data = ''
|
2019-09-11 17:03:51 +02:00
|
|
|
self.parent.current = 'create'
|
|
|
|
state.kivyapp.set_navbar_for_composer()
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-08-23 12:26:35 +02:00
|
|
|
def write_msg(self, navApp):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Write on draft mail"""
|
2019-10-03 18:27:54 +02:00
|
|
|
state.send_draft_mail = state.mail_id
|
2020-01-18 11:31:50 +01:00
|
|
|
data = sqlQuery(
|
|
|
|
"select toaddress, fromaddress, subject, message from sent where"
|
|
|
|
" ackdata = ?;", state.mail_id)
|
2019-12-12 15:38:07 +01:00
|
|
|
composer_ids = (
|
2020-01-09 16:09:01 +01:00
|
|
|
self.parent.parent.ids.sc3.children[1].ids)
|
2020-01-18 11:31:50 +01:00
|
|
|
composer_ids.ti.text = data[0][1]
|
|
|
|
composer_ids.btn.text = data[0][1]
|
|
|
|
composer_ids.txt_input.text = data[0][0]
|
|
|
|
composer_ids.subject.text = data[0][2] if data[0][2] != '(no subject)' else ''
|
|
|
|
composer_ids.body.text = data[0][3]
|
2019-09-11 17:03:51 +02:00
|
|
|
self.parent.current = 'create'
|
2019-08-26 17:28:12 +02:00
|
|
|
navApp.set_navbar_for_composer()
|
2019-08-19 13:06:24 +02:00
|
|
|
|
2020-02-19 16:46:13 +01:00
|
|
|
def detailedPopup(self):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""Detailed popup"""
|
2020-02-19 16:46:13 +01:00
|
|
|
obj = SenderDetailPopup()
|
|
|
|
obj.open()
|
|
|
|
arg = (self.to_addr, self.from_addr, self.timeinseconds)
|
|
|
|
obj.assignDetail(*arg)
|
|
|
|
|
2019-09-09 16:17:07 +02:00
|
|
|
@staticmethod
|
2020-02-19 16:46:13 +01:00
|
|
|
def callback_for_menu_items(text_item, *arg):
|
|
|
|
"""Callback of alert box"""
|
|
|
|
toast(text_item)
|
2019-09-06 17:20:58 +02:00
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
|
|
|
|
class MyaddDetailPopup(Popup):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""MyaddDetailPopup pop is used for showing my address detail"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
address_label = StringProperty()
|
|
|
|
address = StringProperty()
|
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
def __init__(self, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""My Address Details screen setting"""
|
2019-06-06 15:48:20 +02:00
|
|
|
super(MyaddDetailPopup, self).__init__(**kwargs)
|
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
def set_address(self, address, label):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting address for displaying details on popup"""
|
2019-06-28 16:54:47 +02:00
|
|
|
self.address_label = label
|
|
|
|
self.address = address
|
|
|
|
|
|
|
|
def send_message_from(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method used to fill from address of composer autofield"""
|
|
|
|
state.kivyapp.set_navbar_for_composer()
|
2020-03-02 11:42:15 +01:00
|
|
|
try:
|
|
|
|
window_obj = self.parent.children[2].ids
|
2020-03-18 11:37:02 +01:00
|
|
|
except Exception:
|
2020-03-02 11:42:15 +01:00
|
|
|
window_obj = self.parent.children[1].ids
|
2019-12-12 15:38:07 +01:00
|
|
|
window_obj.sc3.children[1].ids.ti.text = self.address
|
|
|
|
window_obj.sc3.children[1].ids.btn.text = self.address
|
|
|
|
window_obj.sc3.children[1].ids.txt_input.text = ''
|
|
|
|
window_obj.sc3.children[1].ids.subject.text = ''
|
|
|
|
window_obj.sc3.children[1].ids.body.text = ''
|
2019-06-28 16:54:47 +02:00
|
|
|
window_obj.scr_mngr.current = 'create'
|
|
|
|
self.dismiss()
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def close_pop():
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Pop is Canceled"""
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Canceled')
|
|
|
|
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
class AddbookDetailPopup(Popup):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""AddbookDetailPopup pop is used for showing my address detail"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
address_label = StringProperty()
|
|
|
|
address = StringProperty()
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
"""Set screen of address detail page"""
|
2019-06-28 16:54:47 +02:00
|
|
|
super(AddbookDetailPopup, self).__init__(**kwargs)
|
|
|
|
|
|
|
|
def set_addbook_data(self, address, label):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting address book data for detial dipaly"""
|
2019-06-28 16:54:47 +02:00
|
|
|
self.address_label = label
|
|
|
|
self.address = address
|
|
|
|
|
|
|
|
def update_addbook_label(self, address):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Updating the label of address book address"""
|
|
|
|
address_list = kivy_helper_search.search_sql(folder="addressbook")
|
|
|
|
stored_labels = [labels[0] for labels in address_list]
|
|
|
|
add_dict = dict(address_list)
|
|
|
|
label = str(self.ids.add_label.text)
|
|
|
|
if label in stored_labels and self.address == add_dict[label]:
|
|
|
|
stored_labels.remove(label)
|
|
|
|
if label and label not in stored_labels:
|
|
|
|
sqlExecute(
|
|
|
|
"UPDATE addressbook SET label = '{}' WHERE"
|
|
|
|
" address = '{}';".format(
|
|
|
|
str(self.ids.add_label.text), address))
|
2020-03-17 12:42:16 +01:00
|
|
|
state.kivyapp.root.ids.sc11.ids.ml.clear_widgets()
|
|
|
|
state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '')
|
2019-06-28 16:54:47 +02:00
|
|
|
self.dismiss()
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Saved')
|
2019-06-28 16:54:47 +02:00
|
|
|
|
|
|
|
def send_message_to(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method used to fill to_address of composer autofield"""
|
|
|
|
state.kivyapp.set_navbar_for_composer()
|
2020-03-02 11:42:15 +01:00
|
|
|
try:
|
|
|
|
window_obj = self.parent.children[2].ids
|
2020-03-18 11:37:02 +01:00
|
|
|
except Exception:
|
2020-03-02 11:42:15 +01:00
|
|
|
window_obj = self.parent.children[1].ids
|
2019-12-12 15:38:07 +01:00
|
|
|
window_obj.sc3.children[1].ids.txt_input.text = self.address
|
|
|
|
window_obj.sc3.children[1].ids.ti.text = ''
|
|
|
|
window_obj.sc3.children[1].ids.btn.text = 'Select'
|
|
|
|
window_obj.sc3.children[1].ids.subject.text = ''
|
|
|
|
window_obj.sc3.children[1].ids.body.text = ''
|
2019-06-28 16:54:47 +02:00
|
|
|
window_obj.scr_mngr.current = 'create'
|
|
|
|
self.dismiss()
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def close_pop():
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Pop is Canceled"""
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Canceled')
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def checkLabel_valid(self, instance):
|
|
|
|
"""Checking address label is unique of not"""
|
|
|
|
entered_label = str(instance.text.strip())
|
|
|
|
address_list = kivy_helper_search.search_sql(folder="addressbook")
|
|
|
|
addr_labels = [labels[0] for labels in address_list]
|
|
|
|
add_dict = dict(address_list)
|
|
|
|
if self.address and entered_label in addr_labels \
|
|
|
|
and self.address != add_dict[entered_label]:
|
|
|
|
self.ids.add_label.error = True
|
|
|
|
self.ids.add_label.helper_text = 'label name already exists.'
|
|
|
|
elif entered_label:
|
|
|
|
self.ids.add_label.error = False
|
|
|
|
else:
|
|
|
|
self.ids.add_label.error = False
|
|
|
|
self.ids.add_label.helper_text = 'This field is required'
|
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
|
|
|
|
class ShowQRCode(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""ShowQRCode Screen uses to show the detail of mails"""
|
2020-03-02 11:42:15 +01:00
|
|
|
address = StringProperty()
|
2019-08-20 15:11:18 +02:00
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
def qrdisplay(self):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Method used for showing QR Code"""
|
2019-06-28 16:54:47 +02:00
|
|
|
self.ids.qr.clear_widgets()
|
2020-01-28 11:19:11 +01:00
|
|
|
state.kivyapp.set_toolbar_for_QrCode()
|
2019-08-05 09:41:56 +02:00
|
|
|
from kivy.garden.qrcode import QRCodeWidget
|
2020-01-10 15:07:43 +01:00
|
|
|
try:
|
|
|
|
address = self.manager.get_parent_window().children[0].address
|
2020-01-20 13:59:02 +01:00
|
|
|
except Exception:
|
|
|
|
address = self.manager.get_parent_window().children[1].address
|
2020-03-02 11:42:15 +01:00
|
|
|
self.address = address
|
2020-01-10 15:07:43 +01:00
|
|
|
self.ids.qr.add_widget(QRCodeWidget(data=address))
|
2020-03-02 11:42:15 +01:00
|
|
|
self.ids.qr.children[0].show_border = False
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Show QR code')
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Draft(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Draft screen is used to show the list of draft messages"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-07-17 10:50:27 +02:00
|
|
|
data = ListProperty()
|
2019-12-12 15:38:07 +01:00
|
|
|
account = StringProperty()
|
|
|
|
queryreturn = ListProperty()
|
|
|
|
has_refreshed = True
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method used for storing draft messages"""
|
2019-07-17 10:50:27 +02:00
|
|
|
super(Draft, self).__init__(*args, **kwargs)
|
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method draft accounts"""
|
2019-07-17 10:50:27 +02:00
|
|
|
self.sentaccounts()
|
2019-12-12 15:38:07 +01:00
|
|
|
print(dt)
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
def sentaccounts(self):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Load draft accounts"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.account = state.association
|
|
|
|
self.loadDraft()
|
2019-07-17 10:50:27 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def loadDraft(self, where="", what=""):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Load draft list for Draft messages"""
|
2019-07-17 10:50:27 +02:00
|
|
|
xAddress = 'fromaddress'
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.draftDataQuery(xAddress, where, what)
|
2020-02-05 09:53:04 +01:00
|
|
|
# if state.msg_counter_objs:
|
|
|
|
# state.msg_counter_objs.draft_cnt.children[0].children[0].text = showLimitedCnt(len(self.queryreturn))
|
2019-12-12 15:38:07 +01:00
|
|
|
if self.queryreturn:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'Draft'
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_draftCnt(state.draft_count)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_mdList()
|
|
|
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
2019-07-17 10:50:27 +02:00
|
|
|
else:
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_draftCnt('0')
|
2019-08-06 12:05:03 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-08-06 12:05:03 +02:00
|
|
|
theme_text_color='Primary',
|
|
|
|
text="yet no message for this account!!!!!!!!!!!!!",
|
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def draftDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
|
|
|
"""This methosd is for retrieving draft messages"""
|
|
|
|
self.queryreturn = kivy_helper_search.search_sql(
|
2019-12-20 15:07:31 +01:00
|
|
|
xAddress, self.account, "draft", where, what,
|
|
|
|
False, start_indx, end_indx)
|
2019-12-12 15:38:07 +01:00
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
def set_draftCnt(self, Count): # pylint: disable=no-self-use
|
2020-01-18 11:31:50 +01:00
|
|
|
"""This method set the count of draft mails"""
|
|
|
|
draftCnt_obj = state.kivyapp.root.ids.content_drawer.ids.draft_cnt
|
|
|
|
draftCnt_obj.children[0].children[0].text = showLimitedCnt(int(Count))
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def set_mdList(self):
|
|
|
|
"""This method is used to create mdlist"""
|
|
|
|
data = []
|
|
|
|
total_draft_msg = len(self.ids.ml.children)
|
|
|
|
for mail in self.queryreturn:
|
|
|
|
third_text = mail[3].replace('\n', ' ')
|
|
|
|
data.append({
|
|
|
|
'text': mail[1].strip(),
|
|
|
|
'secondary_text': mail[2][:10] + '...........' if len(
|
|
|
|
mail[2]) > 10 else mail[2] + '\n' + " " + (
|
|
|
|
third_text[:25] + '...!') if len(
|
|
|
|
third_text) > 25 else third_text,
|
2020-02-05 09:53:04 +01:00
|
|
|
'ackdata': mail[5], 'senttime': mail[6]})
|
2019-12-12 15:38:07 +01:00
|
|
|
for item in data:
|
|
|
|
meny = TwoLineAvatarIconListItem(
|
2020-01-04 15:17:44 +01:00
|
|
|
text='Draft', secondary_text=item['text'],
|
2019-12-12 15:38:07 +01:00
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/avatar.png'))
|
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.draft_detail, item['ackdata']))
|
2020-02-05 09:53:04 +01:00
|
|
|
meny.add_widget(AddTimeWidget(item['senttime']))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
carousel.height = meny.height
|
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
2019-12-20 15:07:31 +01:00
|
|
|
del_btn.bind(on_press=partial(self.delete_draft, item['ackdata']))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
updated_msg = len(self.ids.ml.children)
|
|
|
|
self.has_refreshed = True if total_draft_msg != updated_msg else False
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""Load data on scroll"""
|
|
|
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
|
|
|
self.ids.scroll_y.scroll_y = 0.06
|
|
|
|
total_draft_msg = len(self.ids.ml.children)
|
|
|
|
self.update_draft_screen_on_scroll(total_draft_msg)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_draft_screen_on_scroll(self, total_draft_msg, where='', what=''):
|
|
|
|
"""Load more data on scroll down"""
|
|
|
|
self.draftDataQuery('fromaddress', where, what, total_draft_msg, 5)
|
|
|
|
self.set_mdList()
|
|
|
|
|
2019-10-03 18:27:54 +02:00
|
|
|
def draft_detail(self, ackdata, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Show draft Details"""
|
2019-08-19 13:06:24 +02:00
|
|
|
state.detailPageType = 'draft'
|
2019-10-03 18:27:54 +02:00
|
|
|
state.mail_id = ackdata
|
2019-08-19 13:06:24 +02:00
|
|
|
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'
|
|
|
|
|
2019-07-17 10:50:27 +02:00
|
|
|
def delete_draft(self, data_index, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Delete draft message permanently"""
|
2019-12-30 09:05:07 +01:00
|
|
|
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", data_index)
|
2020-01-10 15:07:43 +01:00
|
|
|
# try:
|
|
|
|
# msg_count_objs = (
|
|
|
|
# self.parent.parent.parent.parent.parent.children[
|
|
|
|
# 2].children[0].ids)
|
|
|
|
# except Exception:
|
|
|
|
# msg_count_objs = (
|
|
|
|
# self.parent.parent.parent.parent.parent.parent.children[
|
|
|
|
# 2].children[0].ids)
|
2020-01-20 13:59:02 +01:00
|
|
|
# msg_count_objs = self.parent.parent.parent.parent.parent.children[
|
|
|
|
# 2].children[0].ids
|
2019-07-17 10:50:27 +02:00
|
|
|
if int(state.draft_count) > 0:
|
2020-01-10 15:07:43 +01:00
|
|
|
# msg_count_objs.draft_cnt.badge_text = str(
|
|
|
|
# int(state.draft_count) - 1)
|
2019-07-17 10:50:27 +02:00
|
|
|
state.draft_count = str(int(state.draft_count) - 1)
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_draftCnt(state.draft_count)
|
2019-12-30 09:05:07 +01:00
|
|
|
if int(state.draft_count) <= 0:
|
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Deleted')
|
2019-07-17 10:50:27 +02:00
|
|
|
|
2019-08-17 14:43:10 +02:00
|
|
|
@staticmethod
|
2020-01-04 15:17:44 +01:00
|
|
|
def draft_msg(src_object):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Save draft mails"""
|
|
|
|
composer_object = state.kivyapp.root.ids.sc3.children[1].ids
|
2019-07-17 10:50:27 +02:00
|
|
|
fromAddress = str(composer_object.ti.text)
|
|
|
|
toAddress = str(composer_object.txt_input.text)
|
|
|
|
subject = str(composer_object.subject.text)
|
|
|
|
message = str(composer_object.body.text)
|
|
|
|
encoding = 3
|
|
|
|
sendMessageToPeople = True
|
|
|
|
if sendMessageToPeople:
|
2019-12-12 15:38:07 +01:00
|
|
|
streamNumber, ripe = decodeAddress(toAddress)[2:]
|
2019-12-26 16:56:04 +01:00
|
|
|
from addresses import addBMIfNotPresent
|
2019-07-17 10:50:27 +02:00
|
|
|
toAddress = addBMIfNotPresent(toAddress)
|
|
|
|
stealthLevel = BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ackstealthlevel')
|
|
|
|
from helper_ackPayload import genAckPayload
|
|
|
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
|
|
|
sqlExecute(
|
2019-08-06 12:05:03 +02:00
|
|
|
'''INSERT INTO sent VALUES
|
|
|
|
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
2019-07-17 10:50:27 +02:00
|
|
|
'',
|
|
|
|
toAddress,
|
|
|
|
ripe,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
ackdata,
|
|
|
|
int(time.time()),
|
|
|
|
int(time.time()),
|
|
|
|
0,
|
|
|
|
'msgqueued',
|
|
|
|
0,
|
|
|
|
'draft',
|
|
|
|
encoding,
|
2020-01-18 12:43:06 +01:00
|
|
|
BMConfigParser().safeGetInt('bitmessagesettings', 'ttl'))
|
2019-07-17 10:50:27 +02:00
|
|
|
state.msg_counter_objs = src_object.children[2].children[0].ids
|
2020-03-18 11:37:02 +01:00
|
|
|
state.draft_count = str(int(state.draft_count) + 1) \
|
|
|
|
if state.association == fromAddress else state.draft_count
|
2019-07-17 10:50:27 +02:00
|
|
|
src_object.ids.sc16.clear_widgets()
|
|
|
|
src_object.ids.sc16.add_widget(Draft())
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Save draft')
|
2019-08-02 11:11:33 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
class CustomSpinner(Spinner):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""This class is used for setting spinner size"""
|
2019-08-20 15:11:18 +02:00
|
|
|
|
2019-08-02 11:11:33 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Method used for setting size of spinner"""
|
2019-08-02 11:11:33 +02:00
|
|
|
super(CustomSpinner, self).__init__(*args, **kwargs)
|
2019-09-06 17:20:58 +02:00
|
|
|
self.dropdown_cls.max_height = Window.size[1] / 3
|
2019-08-06 18:13:34 +02:00
|
|
|
|
|
|
|
|
2019-08-14 16:55:34 +02:00
|
|
|
class Allmails(Screen):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""All mails Screen uses screen to show widgets of screens"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2019-08-14 16:55:34 +02:00
|
|
|
data = ListProperty()
|
2019-12-12 15:38:07 +01:00
|
|
|
has_refreshed = True
|
|
|
|
all_mails = ListProperty()
|
|
|
|
account = StringProperty()
|
2019-08-14 16:55:34 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Method Parsing the address"""
|
2019-08-14 16:55:34 +02:00
|
|
|
super(Allmails, self).__init__(*args, **kwargs)
|
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Clock Schdule for method all mails"""
|
|
|
|
self.loadMessagelist()
|
2019-12-23 15:17:23 +01:00
|
|
|
print(dt)
|
2019-08-14 16:55:34 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def loadMessagelist(self):
|
2019-12-26 16:56:04 +01:00
|
|
|
"""Load Inbox, Sent anf Draft list of messages"""
|
2019-12-12 15:38:07 +01:00
|
|
|
self.account = state.association
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-12-12 15:38:07 +01:00
|
|
|
self.allMessageQuery(0, 20)
|
|
|
|
if self.all_mails:
|
2019-12-30 09:05:07 +01:00
|
|
|
self.ids.identi_tag.children[0].text = 'All Mails'
|
2019-12-12 15:38:07 +01:00
|
|
|
state.kivyapp.get_inbox_count()
|
|
|
|
state.kivyapp.get_sent_count()
|
|
|
|
state.all_count = str(
|
|
|
|
int(state.sent_count) + int(state.inbox_count))
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_AllmailCnt(state.all_count)
|
2019-12-12 15:38:07 +01:00
|
|
|
self.set_mdlist()
|
|
|
|
# self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y)
|
|
|
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
2019-08-14 16:55:34 +02:00
|
|
|
else:
|
2020-01-18 11:31:50 +01:00
|
|
|
self.set_AllmailCnt('0')
|
2019-08-14 16:55:34 +02:00
|
|
|
content = MDLabel(
|
2019-10-18 16:00:43 +02:00
|
|
|
font_style='Caption',
|
2019-08-14 16:55:34 +02:00
|
|
|
theme_text_color='Primary',
|
|
|
|
text="yet no message for this account!!!!!!!!!!!!!",
|
|
|
|
halign='center',
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def allMessageQuery(self, start_indx, end_indx):
|
|
|
|
"""Retrieving data from inbox or sent both tables"""
|
|
|
|
self.all_mails = sqlQuery(
|
|
|
|
"SELECT toaddress, fromaddress, subject, message, folder, ackdata"
|
2020-02-05 09:53:04 +01:00
|
|
|
" As id, DATE(senttime) As actionTime, senttime as msgtime FROM sent WHERE"
|
2019-12-12 15:38:07 +01:00
|
|
|
" folder = 'sent' and fromaddress = '{0}'"
|
|
|
|
" UNION SELECT toaddress, fromaddress, subject, message, folder,"
|
2020-02-05 09:53:04 +01:00
|
|
|
" msgid As id, DATE(received) As actionTime, received as msgtime FROM inbox"
|
2019-12-12 15:38:07 +01:00
|
|
|
" WHERE folder = 'inbox' and toaddress = '{0}'"
|
|
|
|
" ORDER BY actionTime DESC limit {1}, {2}".format(
|
|
|
|
self.account, start_indx, end_indx))
|
|
|
|
|
2020-01-20 13:59:02 +01:00
|
|
|
def set_AllmailCnt(self, Count): # pylint: disable=no-self-use
|
2020-01-18 11:31:50 +01:00
|
|
|
"""This method is used to set allmails message count"""
|
|
|
|
allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt
|
|
|
|
allmailCnt_obj.children[0].children[0].text = showLimitedCnt(int(Count))
|
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
def set_mdlist(self):
|
|
|
|
"""This method is used to create mdList for allmaills"""
|
|
|
|
data_exist = len(self.ids.ml.children)
|
|
|
|
for item in self.all_mails:
|
2020-03-18 11:37:02 +01:00
|
|
|
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
|
|
|
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
2019-12-12 15:38:07 +01:00
|
|
|
meny = TwoLineAvatarIconListItem(
|
|
|
|
text=item[1],
|
2020-03-02 11:42:15 +01:00
|
|
|
secondary_text=(subject[:50] + '........' if len(
|
2020-03-18 11:37:02 +01:00
|
|
|
subject) >= 50 else (
|
2020-03-02 11:42:15 +01:00
|
|
|
subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
2019-12-12 15:38:07 +01:00
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/text_images/{}.png'.format(
|
2020-02-05 14:34:54 +01:00
|
|
|
avatarImageFirstLetter(body.strip()))))
|
2019-12-12 15:38:07 +01:00
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.mail_detail, item[5], item[4]))
|
2020-02-05 09:53:04 +01:00
|
|
|
meny.add_widget(AddTimeWidget(item[7]))
|
2020-02-19 16:46:13 +01:00
|
|
|
meny.add_widget(chipTag(item[4]))
|
2019-12-12 15:38:07 +01:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
carousel.height = meny.height
|
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
|
|
|
del_btn.bind(on_press=partial(
|
|
|
|
self.swipe_delete, item[5], item[4]))
|
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
updated_data = len(self.ids.ml.children)
|
|
|
|
self.has_refreshed = True if data_exist != updated_data else False
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""Scroll fixed length"""
|
|
|
|
if self.ids.scroll_y.scroll_y <= -0.00 and self.has_refreshed:
|
|
|
|
self.ids.scroll_y.scroll_y = .06
|
|
|
|
load_more = len(self.ids.ml.children)
|
|
|
|
self.updating_allmail(load_more)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def updating_allmail(self, load_more):
|
|
|
|
"""This method is used to update the all mail
|
|
|
|
listing value on the scroll of screen"""
|
|
|
|
self.allMessageQuery(load_more, 5)
|
|
|
|
self.set_mdlist()
|
|
|
|
|
2019-08-26 17:28:12 +02:00
|
|
|
def mail_detail(self, unique_id, folder, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Load sent and inbox mail details"""
|
2019-08-26 17:28:12 +02:00
|
|
|
state.detailPageType = folder
|
|
|
|
state.is_allmail = True
|
2019-10-03 18:27:54 +02:00
|
|
|
state.mail_id = unique_id
|
2019-08-26 17:28:12 +02:00
|
|
|
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 swipe_delete(self, unique_id, folder, instance, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Delete inbox mail from all mail listing"""
|
2019-08-26 17:28:12 +02:00
|
|
|
if folder == 'inbox':
|
|
|
|
sqlExecute(
|
2020-01-04 15:17:44 +01:00
|
|
|
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;",
|
|
|
|
unique_id)
|
2019-08-26 17:28:12 +02:00
|
|
|
else:
|
|
|
|
sqlExecute(
|
2020-01-04 15:17:44 +01:00
|
|
|
"UPDATE sent SET folder = 'trash' WHERE ackdata = ?;",
|
|
|
|
unique_id)
|
2019-08-26 17:28:12 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
|
|
|
try:
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs = self.parent.parent.ids.content_drawer.ids
|
|
|
|
nav_lay_obj = self.parent.parent.ids
|
2019-12-12 15:38:07 +01:00
|
|
|
except Exception:
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs = self.parent.parent.parent.ids.content_drawer.ids
|
|
|
|
nav_lay_obj = self.parent.parent.parent.ids
|
2019-08-26 17:28:12 +02:00
|
|
|
if folder == 'inbox':
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.inbox_cnt.children[0].children[0].text = showLimitedCnt(int(state.inbox_count) - 1)
|
2019-08-26 17:28:12 +02:00
|
|
|
state.inbox_count = str(int(state.inbox_count) - 1)
|
2019-09-27 18:31:37 +02:00
|
|
|
nav_lay_obj.sc1.ids.ml.clear_widgets()
|
|
|
|
nav_lay_obj.sc1.loadMessagelist(state.association)
|
2019-08-26 17:28:12 +02:00
|
|
|
else:
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.send_cnt.children[0].children[0].text = showLimitedCnt(int(state.sent_count) - 1)
|
2019-08-26 17:28:12 +02:00
|
|
|
state.sent_count = str(int(state.sent_count) - 1)
|
2019-09-27 18:31:37 +02:00
|
|
|
nav_lay_obj.sc4.ids.ml.clear_widgets()
|
|
|
|
nav_lay_obj.sc4.loadSent(state.association)
|
2020-01-18 11:31:50 +01:00
|
|
|
msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt(int(state.trash_count) + 1)
|
|
|
|
msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt(int(state.all_count) - 1)
|
2019-08-26 17:28:12 +02:00
|
|
|
state.trash_count = str(int(state.trash_count) + 1)
|
|
|
|
state.all_count = str(int(state.all_count) - 1)
|
2019-12-30 09:05:07 +01:00
|
|
|
if int(state.all_count) <= 0:
|
|
|
|
self.ids.identi_tag.children[0].text = ''
|
2019-08-26 17:28:12 +02:00
|
|
|
nav_lay_obj.sc5.clear_widgets()
|
|
|
|
nav_lay_obj.sc5.add_widget(Trash())
|
2019-12-12 15:38:07 +01:00
|
|
|
nav_lay_obj.sc17.remove_widget(instance.parent.parent)
|
2019-08-26 17:28:12 +02:00
|
|
|
|
2019-08-14 16:55:34 +02:00
|
|
|
def refresh_callback(self, *args):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Method updates the state of application,
|
|
|
|
While the spinner remains on the screen"""
|
2019-08-14 16:55:34 +02:00
|
|
|
def refresh_callback(interval):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Load the allmails screen data"""
|
2019-08-14 16:55:34 +02:00
|
|
|
self.ids.ml.clear_widgets()
|
|
|
|
self.remove_widget(self.children[1])
|
|
|
|
try:
|
|
|
|
screens_obj = self.parent.screens[16]
|
2019-08-16 16:49:55 +02:00
|
|
|
except Exception:
|
2019-08-14 16:55:34 +02:00
|
|
|
screens_obj = self.parent.parent.screens[16]
|
|
|
|
screens_obj.add_widget(Allmails())
|
|
|
|
self.ids.refresh_layout.refresh_done()
|
|
|
|
self.tick = 0
|
|
|
|
Clock.schedule_once(refresh_callback, 1)
|
2019-09-06 17:20:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
def avatarImageFirstLetter(letter_string):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""This function is used to the first letter for the avatar image"""
|
|
|
|
if letter_string:
|
|
|
|
if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z':
|
|
|
|
img_latter = letter_string[0].upper()
|
|
|
|
elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9:
|
|
|
|
img_latter = letter_string[0]
|
|
|
|
else:
|
|
|
|
img_latter = '!'
|
2019-09-06 17:20:58 +02:00
|
|
|
else:
|
|
|
|
img_latter = '!'
|
2019-09-07 16:41:42 +02:00
|
|
|
return img_latter
|
2019-09-19 18:30:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Starred(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Starred Screen show widgets of page"""
|
2019-09-19 18:30:26 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Archieve(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Archieve Screen show widgets of page"""
|
2019-09-19 18:30:26 +02:00
|
|
|
pass
|
|
|
|
|
2019-09-20 13:19:04 +02:00
|
|
|
|
2019-09-19 18:30:26 +02:00
|
|
|
class Spam(Screen):
|
2019-11-29 13:12:38 +01:00
|
|
|
"""Spam Screen show widgets of page"""
|
2019-10-21 11:15:31 +02:00
|
|
|
pass
|
2019-12-12 15:38:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
class LoadingPopup(Popup):
|
|
|
|
"""Class for loading Popup"""
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super(LoadingPopup, self).__init__(**kwargs)
|
|
|
|
# call dismiss_popup in 2 seconds
|
|
|
|
Clock.schedule_once(self.dismiss_popup, 0.5)
|
|
|
|
|
|
|
|
def dismiss_popup(self, dt):
|
|
|
|
"""Dismiss popups"""
|
|
|
|
self.dismiss()
|
2019-12-26 16:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
class AddressDropdown(OneLineIconListItem):
|
|
|
|
"""AddressDropdown showns all the addresses"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
pass
|
2020-01-09 16:09:01 +01:00
|
|
|
|
|
|
|
|
2020-01-18 11:31:50 +01:00
|
|
|
class BadgeText(IRightBodyTouch, MDLabel):
|
2020-01-20 13:59:02 +01:00
|
|
|
"""Class for badgetext"""
|
2020-01-18 11:31:50 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class NavigationItem(OneLineAvatarIconListItem):
|
2020-01-09 16:09:01 +01:00
|
|
|
"""NavigationItem class is for button behaviour"""
|
2020-01-18 11:31:50 +01:00
|
|
|
badge_text = StringProperty()
|
|
|
|
icon = StringProperty()
|
|
|
|
active = BooleanProperty(False)
|
|
|
|
|
2020-02-05 09:53:04 +01:00
|
|
|
def currentlyActive(self):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""Currenly active"""
|
2020-02-05 09:53:04 +01:00
|
|
|
for nav_obj in self.parent.children:
|
|
|
|
nav_obj.active = False
|
|
|
|
self.active = True
|
|
|
|
|
2020-01-18 11:31:50 +01:00
|
|
|
|
|
|
|
class NavigationDrawerDivider(OneLineListItem):
|
|
|
|
"""
|
|
|
|
A small full-width divider that can be placed
|
|
|
|
in the :class:`MDNavigationDrawer`
|
|
|
|
"""
|
|
|
|
|
|
|
|
disabled = True
|
|
|
|
divider = None
|
|
|
|
_txt_top_pad = NumericProperty(dp(8))
|
|
|
|
_txt_bot_pad = NumericProperty(dp(8))
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
2020-01-21 09:09:56 +01:00
|
|
|
# pylint: disable=bad-super-call
|
2020-01-18 11:31:50 +01:00
|
|
|
super(OneLineListItem, self).__init__(**kwargs)
|
|
|
|
self.height = dp(16)
|
|
|
|
|
|
|
|
|
|
|
|
class NavigationDrawerSubheader(OneLineListItem):
|
|
|
|
"""
|
|
|
|
A subheader for separating content in :class:`MDNavigationDrawer`
|
|
|
|
|
|
|
|
Works well alongside :class:`NavigationDrawerDivider`
|
|
|
|
"""
|
|
|
|
|
|
|
|
disabled = True
|
|
|
|
divider = None
|
2020-01-20 09:45:54 +01:00
|
|
|
theme_text_color = 'Secondary'
|
|
|
|
|
|
|
|
|
|
|
|
class AppClosingPopup(Popup):
|
|
|
|
"""Class for app closing popup"""
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super(AppClosingPopup, self).__init__(**kwargs)
|
|
|
|
|
|
|
|
def closingAction(self, text):
|
2020-01-20 13:59:02 +01:00
|
|
|
"""Action on closing window"""
|
2020-01-20 09:45:54 +01:00
|
|
|
if text == 'Yes':
|
|
|
|
print("*******************EXITING FROM APPLICATION*******************")
|
|
|
|
import shutdown
|
|
|
|
shutdown.doCleanShutdown()
|
|
|
|
else:
|
|
|
|
self.dismiss()
|
2020-01-20 13:59:02 +01:00
|
|
|
toast(text)
|
2020-02-19 16:46:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
class SenderDetailPopup(Popup):
|
|
|
|
"""SenderDetailPopup pop is used for showing my address detail"""
|
|
|
|
|
|
|
|
to_addr = StringProperty()
|
|
|
|
from_addr = StringProperty()
|
|
|
|
time_tag = StringProperty()
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
"""this metthod initialized the send message detial popup"""
|
|
|
|
super(SenderDetailPopup, self).__init__(**kwargs)
|
|
|
|
|
|
|
|
def assignDetail(self, to_addr, from_addr, timeinseconds):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""Detailes assigned"""
|
2020-02-19 16:46:13 +01:00
|
|
|
self.to_addr = to_addr
|
|
|
|
self.from_addr = from_addr
|
|
|
|
time_obj = datetime.fromtimestamp(int(timeinseconds))
|
|
|
|
self.time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
|
2020-03-18 11:37:02 +01:00
|
|
|
pop_height = 1.2 * (self.ids.sd_label.height + self.ids.sd_btn.children[0].height)
|
2020-03-02 11:42:15 +01:00
|
|
|
if len(to_addr) > 3:
|
|
|
|
self.height = 0
|
|
|
|
self.height = pop_height
|
|
|
|
self.ids.to_addId.size_hint_y = None
|
2020-03-18 11:37:02 +01:00
|
|
|
self.ids.to_addId.height = 50
|
2020-03-02 11:42:15 +01:00
|
|
|
frmaddbox = ToAddrBoxlayout()
|
|
|
|
frmaddbox.set_toAddress(to_addr)
|
|
|
|
self.ids.to_addId.add_widget(frmaddbox)
|
|
|
|
else:
|
|
|
|
self.height = 0
|
2020-03-18 11:37:02 +01:00
|
|
|
self.height = pop_height / 1.5
|
2020-02-19 16:46:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
class OneLineListTitle(OneLineListItem):
|
|
|
|
"""class for long press behaviour"""
|
|
|
|
__events__ = ('on_long_press', )
|
|
|
|
long_press_time = NumericProperty(1)
|
|
|
|
|
|
|
|
def on_state(self, instance, value):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""On state"""
|
2020-02-19 16:46:13 +01:00
|
|
|
if value == 'down':
|
|
|
|
lpt = self.long_press_time
|
|
|
|
self._clockev = Clock.schedule_once(self._do_long_press, lpt)
|
|
|
|
else:
|
|
|
|
self._clockev.cancel()
|
|
|
|
|
|
|
|
def _do_long_press(self, dt):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""Do long press"""
|
2020-02-19 16:46:13 +01:00
|
|
|
self.dispatch('on_long_press')
|
|
|
|
|
|
|
|
def on_long_press(self, *largs):
|
2020-03-18 11:37:02 +01:00
|
|
|
"""On long press"""
|
2020-02-19 16:46:13 +01:00
|
|
|
self.copymessageTitle(self.text)
|
|
|
|
|
|
|
|
def copymessageTitle(self, text):
|
|
|
|
"""this method is for displaying dialog box"""
|
|
|
|
width = .8 if platform == 'android' else .55
|
|
|
|
msg_dialog = MDDialog(
|
|
|
|
text=text,
|
|
|
|
title='', size_hint=(width, .25),
|
|
|
|
text_button_cancel='Cancel',
|
|
|
|
text_button_ok='Copy',
|
|
|
|
events_callback=self.callback_for_copy_title)
|
|
|
|
msg_dialog.open()
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def callback_for_copy_title(text_item, *arg):
|
|
|
|
"""Callback of alert box"""
|
|
|
|
if text_item == 'Copy':
|
|
|
|
Clipboard.copy(str(arg[0].text))
|
2020-03-02 11:42:15 +01:00
|
|
|
toast(text_item)
|
|
|
|
|
|
|
|
|
|
|
|
class ToAddrBoxlayout(BoxLayout):
|
|
|
|
"""class for BoxLayout behaviour"""
|
|
|
|
to_addr = StringProperty()
|
|
|
|
|
|
|
|
def set_toAddress(self, to_addr):
|
2020-03-09 08:54:10 +01:00
|
|
|
"""This method is use to set to address"""
|
2020-03-02 11:42:15 +01:00
|
|
|
self.to_addr = to_addr
|