2019-08-03 13:49:28 +02:00
|
|
|
"""Coding: utf-8."""
|
2019-08-17 14:43:10 +02:00
|
|
|
import time
|
|
|
|
from functools import partial
|
|
|
|
|
|
|
|
from bmconfigparser import BMConfigParser
|
|
|
|
|
|
|
|
from helper_sql import sqlExecute, sqlQuery
|
|
|
|
|
2018-07-09 13:17:59 +02:00
|
|
|
from kivy.app import App
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.clock import Clock
|
|
|
|
from kivy.core.window import Window
|
2018-07-18 14:49:39 +02:00
|
|
|
from kivy.lang import Builder
|
2019-05-09 14:48:29 +02:00
|
|
|
from kivy.metrics import dp
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivy.properties import (
|
|
|
|
BooleanProperty,
|
|
|
|
ListProperty,
|
|
|
|
NumericProperty,
|
|
|
|
ObjectProperty,
|
|
|
|
StringProperty)
|
|
|
|
from kivy.uix.behaviors import FocusBehavior
|
|
|
|
from kivy.uix.boxlayout import BoxLayout
|
|
|
|
from kivy.uix.button import Button
|
|
|
|
from kivy.uix.carousel import Carousel
|
|
|
|
from kivy.uix.floatlayout import FloatLayout
|
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
|
|
|
|
|
|
|
|
import kivy_helper_search
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
from kivymd.button import MDIconButton
|
|
|
|
from kivymd.dialog import MDDialog
|
|
|
|
from kivymd.label import MDLabel
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivymd.list import (
|
|
|
|
ILeftBody,
|
|
|
|
ILeftBodyTouch,
|
|
|
|
IRightBodyTouch,
|
|
|
|
ThreeLineAvatarIconListItem,
|
|
|
|
TwoLineAvatarIconListItem,
|
|
|
|
TwoLineListItem)
|
2019-08-05 12:19:19 +02:00
|
|
|
from kivymd.navigationdrawer import (
|
|
|
|
MDNavigationDrawer,
|
|
|
|
NavigationDrawerHeaderBase)
|
2019-05-09 14:48:29 +02:00
|
|
|
from kivymd.selectioncontrols import MDCheckbox
|
2019-08-17 14:43:10 +02:00
|
|
|
from kivymd.textfields import MDTextField
|
2018-07-25 12:25:47 +02:00
|
|
|
from kivymd.theming import ThemeManager
|
2019-08-17 14:43:10 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
import queues
|
2019-08-17 14:43:10 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
from semaphores import kivyuisignaler
|
2019-08-17 14:43:10 +02:00
|
|
|
|
|
|
|
import state
|
|
|
|
|
|
|
|
from uikivysignaler import UIkivySignaler
|
2019-05-13 13:31:33 +02:00
|
|
|
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-08-13 09:28:15 +02:00
|
|
|
def toast(text):
|
2019-08-13 13:54:04 +02:00
|
|
|
"""Method will display the toast message."""
|
2019-08-13 09:28:15 +02:00
|
|
|
if platform == 'linux':
|
|
|
|
from kivymd.toast.kivytoast import toast
|
|
|
|
toast(text)
|
|
|
|
return
|
|
|
|
|
2019-08-13 13:54:04 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Navigatorss(MDNavigationDrawer):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Navigators class contains image, title and logo."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-05-09 14:48:29 +02:00
|
|
|
image_source = StringProperty('images/qidenticon_two.png')
|
|
|
|
title = StringProperty('Navigation')
|
|
|
|
drawer_logo = StringProperty()
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2018-07-03 11:08:02 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class Inbox(Screen):
|
|
|
|
"""Inbox Screen uses screen to show widgets of screens."""
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
data = ListProperty()
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Method Parsing the address."""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(Inbox, self).__init__(*args, **kwargs)
|
2019-05-13 13:31:33 +02:00
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
2019-05-09 14:48:29 +02:00
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def init_ui(self, dt=0):
|
2019-06-06 15:48:20 +02:00
|
|
|
"""Clock Schdule for method inbox accounts."""
|
2019-05-13 13:31:33 +02:00
|
|
|
self.inboxaccounts()
|
2019-08-13 14:46:19 +02:00
|
|
|
print dt
|
2019-05-13 13:31:33 +02:00
|
|
|
|
|
|
|
def inboxaccounts(self):
|
|
|
|
"""Load inbox accounts."""
|
|
|
|
account = state.association
|
|
|
|
self.loadMessagelist(account, 'All', '')
|
|
|
|
|
|
|
|
def loadMessagelist(self, account, where="", what=""):
|
2019-06-06 15:48:20 +02:00
|
|
|
"""Load Inbox list for Inbox messages."""
|
2019-08-16 16:49:55 +02:00
|
|
|
# pylint: disable=too-many-locals
|
2019-08-02 11:11:33 +02:00
|
|
|
if state.searcing_text:
|
|
|
|
where = ['subject', 'message']
|
|
|
|
what = state.searcing_text
|
2019-05-13 13:31:33 +02:00
|
|
|
xAddress = 'toaddress'
|
|
|
|
data = []
|
|
|
|
queryreturn = kivy_helper_search.search_sql(
|
|
|
|
xAddress, account, "inbox", where, what, False)
|
|
|
|
if queryreturn:
|
|
|
|
for mail in queryreturn:
|
|
|
|
third_text = mail[3].replace('\n', ' ')
|
2019-08-03 13:49:28 +02:00
|
|
|
data.append({
|
|
|
|
'text': mail[4].strip(),
|
|
|
|
'secondary_text': mail[5][:10] + '...........' if len(
|
|
|
|
mail[3]) > 10 else mail[3] + '\n' + " " + (
|
2019-08-13 14:46:19 +02:00
|
|
|
third_text[:25] + '...!') if len(
|
|
|
|
third_text) > 25 else third_text,
|
2019-08-03 13:49:28 +02:00
|
|
|
'receivedTime': mail[6]})
|
2019-05-09 14:48:29 +02:00
|
|
|
for item in data:
|
2019-08-03 13:49:28 +02:00
|
|
|
meny = ThreeLineAvatarIconListItem(
|
|
|
|
text=item['text'],
|
|
|
|
secondary_text=item['secondary_text'],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-08 09:33:17 +02:00
|
|
|
img_latter = item['secondary_text'][0].upper() if (
|
|
|
|
item['secondary_text'][0].upper() >= 'A' and item[
|
|
|
|
'secondary_text'][0].upper() <= 'Z') else '!'
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
2019-08-08 09:33:17 +02:00
|
|
|
source='./images/text_images/{}.png'.format(img_latter)))
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.inbox_detail, item['receivedTime']))
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel = Carousel(direction='right')
|
2019-06-28 16:54:47 +02:00
|
|
|
if platform == 'android':
|
2019-08-02 11:11:33 +02:00
|
|
|
carousel.height = 150
|
|
|
|
elif platform == 'linux':
|
2019-08-03 13:49:28 +02:00
|
|
|
carousel.height = meny.height - 10
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
2019-07-17 10:50:27 +02:00
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1, 0, 0, 1)
|
2019-08-05 12:19:19 +02:00
|
|
|
del_btn.bind(on_press=partial(
|
|
|
|
self.delete, item['receivedTime']))
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
ach_btn = Button(text='Achieve')
|
2019-08-03 13:49:28 +02:00
|
|
|
ach_btn.background_color = (0, 1, 0, 1)
|
2019-08-05 12:19:19 +02:00
|
|
|
ach_btn.bind(on_press=partial(
|
|
|
|
self.archive, item['receivedTime']))
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel.add_widget(ach_btn)
|
2019-08-02 11:11:33 +02:00
|
|
|
carousel.index = 1
|
2019-06-06 15:48:20 +02:00
|
|
|
self.ids.ml.add_widget(carousel)
|
2019-05-09 14:48:29 +02:00
|
|
|
else:
|
2019-08-05 12:19:19 +02:00
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
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',
|
|
|
|
bold=True,
|
|
|
|
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
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
def inbox_detail(self, receivedTime, *args):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Load inbox page details."""
|
2019-08-06 18:13:34 +02:00
|
|
|
remove_search_bar(self)
|
2019-06-06 15:48:20 +02:00
|
|
|
state.detailPageType = 'inbox'
|
|
|
|
state.sentMailTime = receivedTime
|
|
|
|
if self.manager:
|
|
|
|
src_mng_obj = self.manager
|
|
|
|
else:
|
|
|
|
src_mng_obj = self.parent.parent
|
2019-08-02 11:11:33 +02:00
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
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-08-03 13:49:28 +02:00
|
|
|
"""Delete inbox mail from inbox listing."""
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
|
|
|
"UPDATE inbox SET folder = 'trash' WHERE received = {};".format(
|
|
|
|
data_index))
|
|
|
|
msg_count_objs = \
|
2019-08-13 09:28:15 +02:00
|
|
|
self.parent.parent.parent.parent.parent.children[2].children[0].ids
|
2019-07-17 10:50:27 +02:00
|
|
|
if int(state.inbox_count) > 0:
|
2019-08-05 12:19:19 +02:00
|
|
|
msg_count_objs.inbox_cnt.badge_text = str(
|
|
|
|
int(state.inbox_count) - 1)
|
|
|
|
msg_count_objs.trash_cnt.badge_text = str(
|
|
|
|
int(state.trash_count) + 1)
|
2019-07-17 10:50:27 +02:00
|
|
|
state.inbox_count = str(int(state.inbox_count) - 1)
|
|
|
|
state.trash_count = str(int(state.trash_count) + 1)
|
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-08-03 13:49:28 +02:00
|
|
|
"""Archive inbox mail from inbox listing."""
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE \
|
|
|
|
received = {};".format(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-08-03 13:49:28 +02: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-08-17 14:43:10 +02: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-08-03 13:49:28 +02:00
|
|
|
"""Method used for loading the inbox screen data."""
|
2019-08-02 11:11:33 +02:00
|
|
|
self.ids.ml.clear_widgets()
|
|
|
|
self.remove_widget(self.children[1])
|
|
|
|
try:
|
|
|
|
screens_obj = self.parent.screens[0]
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-08-02 11:11:33 +02:00
|
|
|
screens_obj = self.parent.parent.screens[0]
|
|
|
|
screens_obj.add_widget(Inbox())
|
|
|
|
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
|
|
|
|
|
|
|
class MyAddress(Screen):
|
|
|
|
"""MyAddress Screen uses screen to show widgets of screens."""
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Clock Schdule for method inbox 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):
|
|
|
|
"""Clock Schdule for method inbox accounts."""
|
2019-08-13 09:28:15 +02:00
|
|
|
addresses_list = state.kivyapp.variable_1
|
|
|
|
if state.searcing_text:
|
2019-08-17 14:43:10 +02:00
|
|
|
filtered_list = filter(
|
|
|
|
lambda addr: self.filter_address(
|
|
|
|
addr), BMConfigParser().addresses())
|
2019-08-13 09:28:15 +02:00
|
|
|
addresses_list = filtered_list
|
|
|
|
if addresses_list:
|
2019-05-13 13:31:33 +02:00
|
|
|
data = []
|
2019-08-08 18:20:58 +02:00
|
|
|
for address in addresses_list:
|
2019-08-05 12:19:19 +02:00
|
|
|
data.append({
|
|
|
|
'text': BMConfigParser().get(address, 'label'),
|
|
|
|
'secondary_text': address})
|
2019-05-13 13:31:33 +02:00
|
|
|
for item in data:
|
2019-08-03 13:49:28 +02:00
|
|
|
meny = TwoLineAvatarIconListItem(
|
|
|
|
text=item['text'],
|
|
|
|
secondary_text=item['secondary_text'],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-08 09:33:17 +02:00
|
|
|
img_latter = item['text'][0].upper() if (
|
|
|
|
item['text'][0].upper() >= 'A' and item['text'][
|
|
|
|
0].upper() <= 'Z') else '!'
|
2019-08-03 13:49:28 +02:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
2019-08-08 09:33:17 +02:00
|
|
|
source='./images/text_images/{}.png'.format(img_latter)))
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.myadd_detail, item['secondary_text'], item['text']))
|
2019-05-13 13:31:33 +02:00
|
|
|
self.ids.ml.add_widget(meny)
|
|
|
|
else:
|
2019-08-05 12:19:19 +02:00
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
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',
|
|
|
|
bold=True,
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-13 13:31:33 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
2019-05-28 13:12:51 +02:00
|
|
|
try:
|
2019-08-13 13:54:04 +02:00
|
|
|
self.manager.parent.parent\
|
|
|
|
.parent.ids.search_bar.clear_widgets()
|
2019-05-28 13:12:51 +02:00
|
|
|
self.manager.current = 'login'
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-05-28 13:12:51 +02:00
|
|
|
pass
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def myadd_detail(fromaddress, label, *args):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Myaddress Details."""
|
2019-06-06 15:48:20 +02:00
|
|
|
p = MyaddDetailPopup()
|
|
|
|
p.open()
|
2019-06-28 16:54:47 +02:00
|
|
|
p.set_address(fromaddress, label)
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-08-02 11:11:33 +02:00
|
|
|
def refresh_callback(self, *args):
|
2019-08-17 14:43:10 +02: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-08-03 13:49:28 +02:00
|
|
|
"""Method used for loading the myaddress screen data."""
|
2019-08-02 11:11:33 +02:00
|
|
|
self.ids.ml.clear_widgets()
|
|
|
|
self.remove_widget(self.children[1])
|
|
|
|
try:
|
|
|
|
screens_obj = self.parent.screens[9]
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-08-02 11:11:33 +02:00
|
|
|
screens_obj = self.parent.parent.screens[9]
|
|
|
|
screens_obj.add_widget(MyAddress())
|
|
|
|
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-08-13 13:54:04 +02:00
|
|
|
"""Method will filter the my address list data."""
|
|
|
|
if filter(lambda x: (
|
|
|
|
state.searcing_text).lower() in x, [
|
|
|
|
BMConfigParser().get(
|
2019-08-17 14:43:10 +02:00
|
|
|
address, 'label').lower(), address.lower()]):
|
2019-08-08 18:20:58 +02:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
class AddressBook(Screen):
|
|
|
|
"""AddressBook Screen uses screen to show widgets of screens."""
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-03 13:49:28 +02: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-08-08 09:33:17 +02:00
|
|
|
"""Clock Schdule for method AddressBook."""
|
2019-08-07 17:39:46 +02:00
|
|
|
self.loadAddresslist(None, 'All', '')
|
2019-08-13 14:46:19 +02:00
|
|
|
print dt
|
2019-08-07 17:39:46 +02:00
|
|
|
|
|
|
|
def loadAddresslist(self, account, where="", what=""):
|
2019-08-08 09:33:17 +02:00
|
|
|
"""Clock Schdule for method AddressBook."""
|
2019-08-07 17:39:46 +02:00
|
|
|
if state.searcing_text:
|
|
|
|
where = ['label', 'address']
|
|
|
|
what = state.searcing_text
|
|
|
|
xAddress = ''
|
|
|
|
queryreturn = kivy_helper_search.search_sql(
|
|
|
|
xAddress, account, "addressbook", where, what, False)
|
|
|
|
if queryreturn:
|
|
|
|
for item in queryreturn:
|
2019-08-03 13:49:28 +02:00
|
|
|
meny = TwoLineAvatarIconListItem(
|
|
|
|
text=item[0],
|
|
|
|
secondary_text=item[1],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-08 09:33:17 +02:00
|
|
|
img_latter = item[0][0].upper() if (
|
|
|
|
item[0][0].upper() >= 'A' and item[0][
|
|
|
|
0].upper() <= 'Z') else '!'
|
2019-08-03 13:49:28 +02:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
2019-08-08 09:33:17 +02:00
|
|
|
source='./images/text_images/{}.png'.format(img_latter)))
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.addBook_detail, item[1], item[0]))
|
2019-07-17 10:50:27 +02:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
if platform == 'android':
|
2019-08-02 11:11:33 +02:00
|
|
|
carousel.height = 140
|
|
|
|
elif platform == 'linux':
|
|
|
|
carousel.height = meny.height - 10
|
2019-07-17 10:50:27 +02:00
|
|
|
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)
|
2019-08-03 13:49:28 +02:00
|
|
|
carousel.index = 1
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.add_widget(carousel)
|
2019-05-09 14:48:29 +02:00
|
|
|
else:
|
2019-08-13 13:54:04 +02:00
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
theme_text_color='Primary',
|
|
|
|
text="No contact found!" if state.searcing_text
|
|
|
|
else "No contact found yet...... ",
|
|
|
|
halign='center',
|
|
|
|
bold=True,
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-09 14:48:29 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def refreshs(*args):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Refresh the Widget."""
|
2019-05-09 14:48:29 +02:00
|
|
|
state.navinstance.ids.sc11.clear_widgets()
|
|
|
|
state.navinstance.ids.sc11.add_widget(AddressBook())
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def addBook_detail(address, label, *args):
|
2019-08-03 13:49:28 +02: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-08-03 13:49:28 +02:00
|
|
|
"""Delete inbox mail from inbox listing."""
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.remove_widget(instance.parent.parent)
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
|
|
|
"DELETE FROM addressbook WHERE address = '{}';".format(address))
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior,
|
|
|
|
RecycleBoxLayout):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Adds selection and focus behaviour to the view."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-05-13 13:31:33 +02:00
|
|
|
pass
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SelectableLabel(RecycleDataViewBehavior, Label):
|
2019-08-03 13:49:28 +02:00
|
|
|
"""Add selection support to the Label."""
|
|
|
|
|
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-08-03 13:49:28 +02: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)
|
|
|
|
|
|
|
|
def on_touch_down(self, touch):
|
2019-08-03 13:49:28 +02: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-08-03 13:49:28 +02: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-08-13 14:46:19 +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-08-03 13:49:28 +02:00
|
|
|
"""Recycling View."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, **kwargs):
|
2019-08-03 13:49:28 +02: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-08-03 13:49:28 +02:00
|
|
|
"""Adding Dropdown Widget."""
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
txt_input = ObjectProperty()
|
|
|
|
rv = ObjectProperty()
|
2018-08-21 14:48:16 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def send(self):
|
|
|
|
"""Send message from one address to another."""
|
2019-08-16 16:49:55 +02:00
|
|
|
# pylint: disable=too-many-locals
|
2019-05-09 14:48:29 +02:00
|
|
|
fromAddress = str(self.ids.ti.text)
|
|
|
|
toAddress = str(self.ids.txt_input.text)
|
|
|
|
subject = str(self.ids.subject.text)
|
|
|
|
message = str(self.ids.body.text)
|
|
|
|
encoding = 3
|
2019-08-13 14:46:19 +02: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-05-09 14:48:29 +02:00
|
|
|
from addresses import decodeAddress
|
2019-08-05 12:19:19 +02:00
|
|
|
status, addressVersionNumber, streamNumber, ripe = \
|
|
|
|
decodeAddress(toAddress)
|
2019-05-09 14:48:29 +02:00
|
|
|
if status == 'success':
|
2019-08-19 13:06:24 +02:00
|
|
|
if state.detailPageType == 'draft' and state.send_draft_mail:
|
|
|
|
sqlExecute(
|
|
|
|
"UPDATE sent SET toaddress = '{0}', fromaddress ='{1}' , subject = '{2}', message = '{3}', folder = 'sent' \
|
|
|
|
WHERE lastactiontime = '{4}';".format(toAddress, fromAddress, subject, message, state.send_draft_mail))
|
|
|
|
self.parent.parent.screens[15].clear_widgets()
|
|
|
|
self.parent.parent.screens[15].add_widget(Draft())
|
|
|
|
state.detailPageType = 'draft'
|
|
|
|
else:
|
|
|
|
from addresses import addBMIfNotPresent
|
|
|
|
toAddress = addBMIfNotPresent(toAddress)
|
|
|
|
statusIconColor = 'red'
|
|
|
|
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
|
|
|
print "addressVersionNumber > 4 \
|
|
|
|
or addressVersionNumber <= 1"
|
|
|
|
if streamNumber > 1 or streamNumber == 0:
|
|
|
|
print "streamNumber > 1 or streamNumber == 0"
|
|
|
|
if statusIconColor == 'red':
|
|
|
|
print "shared.statusIconColor == 'red'"
|
|
|
|
stealthLevel = BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ackstealthlevel')
|
|
|
|
from helper_ackPayload import genAckPayload
|
|
|
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
|
|
|
t = ()
|
|
|
|
sqlExecute(
|
|
|
|
'''INSERT INTO sent VALUES
|
|
|
|
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
|
|
|
'',
|
|
|
|
toAddress,
|
|
|
|
ripe,
|
|
|
|
fromAddress,
|
|
|
|
subject,
|
|
|
|
message,
|
|
|
|
ackdata,
|
|
|
|
int(time.time()),
|
|
|
|
int(time.time()),
|
|
|
|
0,
|
|
|
|
'msgqueued',
|
|
|
|
0,
|
|
|
|
'sent',
|
|
|
|
encoding,
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
2019-06-28 16:54:47 +02:00
|
|
|
state.check_sent_acc = fromAddress
|
2019-08-05 12:19:19 +02:00
|
|
|
state.msg_counter_objs = self.parent.parent.parent.parent\
|
|
|
|
.parent.parent.children[0].children[2].children[0].ids
|
2019-05-09 14:48:29 +02:00
|
|
|
self.parent.parent.screens[3].clear_widgets()
|
|
|
|
self.parent.parent.screens[3].add_widget(Sent())
|
2019-08-19 13:06:24 +02:00
|
|
|
self.parent.parent.screens[16].clear_widgets()
|
|
|
|
self.parent.parent.screens[16].add_widget(Allmails())
|
2019-05-09 14:48:29 +02:00
|
|
|
toLabel = ''
|
|
|
|
queues.workerQueue.put(('sendmessage', toAddress))
|
2019-08-13 14:46:19 +02:00
|
|
|
print "sqlExecute successfully #######################"
|
2019-05-09 14:48:29 +02:00
|
|
|
self.ids.body.text = ''
|
|
|
|
self.ids.ti.text = ''
|
|
|
|
self.ids.subject.text = ''
|
|
|
|
self.ids.txt_input.text = ''
|
2019-08-08 18:20:58 +02:00
|
|
|
self.parent.parent.current = 'inbox'
|
2019-05-09 14:48:29 +02:00
|
|
|
self.ids.btn.text = 'select'
|
|
|
|
self.ids.ti.text = ''
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('send')
|
2019-05-09 14:48:29 +02:00
|
|
|
return None
|
2019-05-13 13:31:33 +02:00
|
|
|
else:
|
|
|
|
msg = 'Enter a valid recipients address'
|
|
|
|
elif not toAddress:
|
2019-05-28 13:12:51 +02:00
|
|
|
msg = 'Please fill the form'
|
|
|
|
else:
|
|
|
|
msg = 'Please fill the form'
|
|
|
|
self.address_error_message(msg)
|
2019-05-13 13:31:33 +02:00
|
|
|
|
|
|
|
def address_error_message(self, msg):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Show Error Message."""
|
2019-05-13 13:31:33 +02:00
|
|
|
self.box = FloatLayout()
|
2019-08-05 12:19:19 +02:00
|
|
|
self.lab = (Label(
|
|
|
|
text=msg,
|
|
|
|
font_size=25,
|
|
|
|
size_hint=(None, None),
|
|
|
|
pos_hint={'x': .25, 'y': .6}))
|
2019-05-13 13:31:33 +02:00
|
|
|
self.box.add_widget(self.lab)
|
2019-08-05 12:19:19 +02:00
|
|
|
self.but = (Button(
|
|
|
|
text="dismiss",
|
|
|
|
size_hint=(None, None),
|
|
|
|
width=200,
|
|
|
|
height=50,
|
|
|
|
pos_hint={'x': .3, 'y': 0}))
|
2019-05-13 13:31:33 +02:00
|
|
|
self.box.add_widget(self.but)
|
2019-08-05 12:19:19 +02:00
|
|
|
self.main_pop = Popup(
|
|
|
|
title="Error",
|
|
|
|
content=self.box,
|
|
|
|
size_hint=(None, None),
|
|
|
|
size=(550, 400),
|
|
|
|
auto_dismiss=False,
|
|
|
|
title_size=30)
|
2019-05-13 13:31:33 +02:00
|
|
|
self.but.bind(on_press=self.main_pop.dismiss)
|
|
|
|
self.main_pop.open()
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-08-13 09:28:15 +02:00
|
|
|
def reset_composer(self):
|
2019-08-13 13:54:04 +02: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 = ''
|
|
|
|
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class MyTextInput(TextInput):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Takes the text input in the field."""
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
txt_input = ObjectProperty()
|
|
|
|
flt_list = ObjectProperty()
|
|
|
|
word_list = ListProperty()
|
|
|
|
starting_no = NumericProperty(3)
|
|
|
|
suggestion_text = ''
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
def on_text(self, instance, value):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Find all the occurrence of the word."""
|
2019-05-09 14:48:29 +02:00
|
|
|
self.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})
|
|
|
|
self.parent.parent.parent.parent.ids.rv.data = display_data
|
|
|
|
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-08-05 09:24:32 +02:00
|
|
|
"""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-08-05 09:24:32 +02:00
|
|
|
"""Payment Method."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
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-08-05 09:24:32 +02:00
|
|
|
"""Login Screeen."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
2018-07-03 12:06:20 +02:00
|
|
|
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class NetworkStat(Screen):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used to show network stat."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
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'))
|
2019-05-09 14:48:29 +02: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-08-05 09:24:32 +02: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):
|
2018-09-01 13:45:39 +02:00
|
|
|
"""Clock Schdule for method inbox accounts."""
|
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
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class ContentNavigationDrawer(Navigatorss):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Navigate Content Drawer."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
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-08-05 09:24:32 +02:00
|
|
|
"""Generates Random Address."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-05-09 14:48:29 +02:00
|
|
|
is_active = BooleanProperty(False)
|
|
|
|
checked = StringProperty("")
|
|
|
|
|
|
|
|
def generateaddress(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method for Address Generator."""
|
2019-05-09 14:48:29 +02:00
|
|
|
streamNumberForAddress = 1
|
|
|
|
label = self.ids.label.text
|
|
|
|
eighteenByteRipe = False
|
|
|
|
nonceTrialsPerByte = 1000
|
|
|
|
payloadLengthExtraBytes = 1000
|
2019-05-13 13:31:33 +02:00
|
|
|
if self.ids.label.text:
|
|
|
|
queues.addressGeneratorQueue.put((
|
|
|
|
'createRandomAddress',
|
|
|
|
4, streamNumberForAddress,
|
|
|
|
label, 1, "", eighteenByteRipe,
|
|
|
|
nonceTrialsPerByte,
|
2019-08-13 14:46:19 +02:00
|
|
|
payloadLengthExtraBytes))
|
2019-06-06 15:48:20 +02:00
|
|
|
self.manager.current = 'myaddress'
|
2019-05-13 13:31:33 +02:00
|
|
|
self.ids.label.text = ''
|
2019-05-28 13:12:51 +02:00
|
|
|
self.parent.parent.parent.parent.ids.toolbar.opacity = 1
|
|
|
|
self.parent.parent.parent.parent.ids.toolbar.disabled = False
|
2019-06-28 16:54:47 +02:00
|
|
|
self.parent.parent.parent.parent.ids.sc10.clear_widgets()
|
|
|
|
self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress())
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('New address created')
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2018-08-04 10:30:12 +02:00
|
|
|
|
|
|
|
class AddressSuccessful(Screen):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Getting Address Detail."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2018-08-04 10:30:12 +02:00
|
|
|
pass
|
2018-07-03 11:08:02 +02:00
|
|
|
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2018-07-18 14:49:39 +02:00
|
|
|
class Sent(Screen):
|
2018-08-31 13:19:57 +02:00
|
|
|
"""Sent Screen uses screen to show widgets of screens."""
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2018-08-21 14:48:16 +02:00
|
|
|
data = ListProperty()
|
|
|
|
|
2018-08-09 12:20:20 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-05 09:24:32 +02: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):
|
2018-09-01 13:45:39 +02:00
|
|
|
"""Clock Schdule for method sent accounts."""
|
2018-08-21 14:48:16 +02:00
|
|
|
self.sentaccounts()
|
2019-08-13 14:46:19 +02:00
|
|
|
print dt
|
2018-08-09 12:20:20 +02:00
|
|
|
|
2018-08-21 14:48:16 +02:00
|
|
|
def sentaccounts(self):
|
2018-09-01 13:45:39 +02:00
|
|
|
"""Load sent accounts."""
|
2018-09-04 14:44:28 +02:00
|
|
|
account = state.association
|
2018-08-21 14:48:16 +02:00
|
|
|
self.loadSent(account, 'All', '')
|
2018-08-09 12:20:20 +02:00
|
|
|
|
2018-08-21 14:48:16 +02:00
|
|
|
def loadSent(self, account, where="", what=""):
|
2018-09-01 13:45:39 +02:00
|
|
|
"""Load Sent list for Sent messages."""
|
2019-08-02 11:11:33 +02:00
|
|
|
if state.searcing_text:
|
|
|
|
where = ['subject', 'message']
|
|
|
|
what = state.searcing_text
|
2018-08-09 12:20:20 +02:00
|
|
|
xAddress = 'fromaddress'
|
2018-08-31 13:19:57 +02:00
|
|
|
queryreturn = kivy_helper_search.search_sql(
|
|
|
|
xAddress, account, "sent", where, what, False)
|
2019-08-05 12:19:19 +02:00
|
|
|
if state.msg_counter_objs and state.association == \
|
|
|
|
state.check_sent_acc:
|
2019-06-28 16:54:47 +02:00
|
|
|
state.msg_counter_objs.send_cnt.badge_text = str(len(queryreturn))
|
|
|
|
state.sent_count = str(int(state.sent_count) + 1)
|
2019-08-14 16:55:34 +02:00
|
|
|
state.all_count = str(int(state.all_count) + 1)
|
|
|
|
state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
2019-06-28 16:54:47 +02:00
|
|
|
state.check_sent_acc = None
|
|
|
|
|
2018-08-09 12:20:20 +02:00
|
|
|
if queryreturn:
|
2019-05-09 14:48:29 +02:00
|
|
|
for mail in queryreturn:
|
|
|
|
third_text = mail[3].replace('\n', ' ')
|
2019-08-05 09:24:32 +02:00
|
|
|
self.data.append({
|
|
|
|
'text': mail[1].strip(),
|
|
|
|
'secondary_text': mail[2][:10] + '...........' if len(
|
2019-08-05 12:19:19 +02:00
|
|
|
mail[2]) > 10 else mail[2] + '\n' + " " + (
|
2019-08-13 14:46:19 +02:00
|
|
|
third_text[:25] + '...!') if len(
|
|
|
|
third_text) > 25 else third_text,
|
2019-08-05 09:24:32 +02:00
|
|
|
'lastactiontime': mail[6]})
|
2019-06-06 15:48:20 +02:00
|
|
|
for item in self.data:
|
2019-08-05 09:24:32 +02:00
|
|
|
meny = ThreeLineAvatarIconListItem(
|
|
|
|
text=item['text'],
|
|
|
|
secondary_text=item['secondary_text'],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-08 09:33:17 +02:00
|
|
|
img_latter = item['secondary_text'][0].upper() if (
|
|
|
|
item['secondary_text'][0].upper() >= 'A' and item[
|
|
|
|
'secondary_text'][0].upper() <= 'Z') else '!'
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
2019-08-08 09:33:17 +02:00
|
|
|
source='./images/text_images/{}.png'.format(img_latter)))
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.sent_detail, item['lastactiontime']))
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel = Carousel(direction='right')
|
2019-06-28 16:54:47 +02:00
|
|
|
if platform == 'android':
|
2019-08-02 11:11:33 +02:00
|
|
|
carousel.height = 150
|
|
|
|
elif platform == 'linux':
|
2019-08-05 09:24:32 +02:00
|
|
|
carousel.height = meny.height - 10
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel.size_hint_y = None
|
|
|
|
carousel.ignore_perpendicular_swipes = True
|
|
|
|
carousel.data_index = 0
|
|
|
|
carousel.min_move = 0.2
|
|
|
|
del_btn = Button(text='Delete')
|
2019-07-17 10:50:27 +02:00
|
|
|
del_btn.background_normal = ''
|
|
|
|
del_btn.background_color = (1.0, 0.0, 0.0, 1.0)
|
2019-08-05 12:19:19 +02:00
|
|
|
del_btn.bind(on_press=partial(
|
|
|
|
self.delete, item['lastactiontime']))
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
ach_btn = Button(text='Achieve')
|
2019-08-05 09:24:32 +02:00
|
|
|
ach_btn.background_color = (0, 1, 0, 1)
|
2019-08-05 12:19:19 +02:00
|
|
|
ach_btn.bind(on_press=partial(
|
|
|
|
self.archive, item['lastactiontime']))
|
2019-06-06 15:48:20 +02:00
|
|
|
carousel.add_widget(ach_btn)
|
2019-08-05 09:24:32 +02:00
|
|
|
carousel.index = 1
|
2019-06-06 15:48:20 +02:00
|
|
|
self.ids.ml.add_widget(carousel)
|
2018-08-09 12:20:20 +02:00
|
|
|
else:
|
2019-08-05 12:19:19 +02:00
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
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',
|
|
|
|
bold=True,
|
|
|
|
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-05-28 13:12:51 +02:00
|
|
|
def sent_detail(self, lastsenttime, *args):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Load sent mail details."""
|
2019-08-06 18:13:34 +02:00
|
|
|
remove_search_bar(self)
|
2019-06-06 15:48:20 +02:00
|
|
|
state.detailPageType = 'sent'
|
2019-05-28 13:12:51 +02:00
|
|
|
state.sentMailTime = lastsenttime
|
|
|
|
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-08-05 09:24:32 +02:00
|
|
|
"""Delete sent mail from sent mail listing."""
|
2019-06-28 16:54:47 +02:00
|
|
|
try:
|
2019-08-05 12:19:19 +02:00
|
|
|
msg_count_objs = self.parent.parent.parent.parent.children[
|
|
|
|
2].children[0].ids
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-08-05 12:19:19 +02:00
|
|
|
msg_count_objs = self.parent.parent.parent.parent.parent.children[
|
|
|
|
2].children[0].ids
|
2019-06-28 16:54:47 +02:00
|
|
|
if int(state.sent_count) > 0:
|
2019-08-05 12:19:19 +02:00
|
|
|
msg_count_objs.send_cnt.badge_text = str(
|
|
|
|
int(state.sent_count) - 1)
|
|
|
|
msg_count_objs.trash_cnt.badge_text = str(
|
|
|
|
int(state.trash_count) + 1)
|
2019-08-14 16:55:34 +02:00
|
|
|
msg_count_objs.allmail_cnt.badge_text = str(
|
|
|
|
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-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
|
|
|
"UPDATE sent SET folder = 'trash' \
|
|
|
|
WHERE lastactiontime = {};".format(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-08-05 09:24:32 +02:00
|
|
|
"""Archive sent mail from sent mail listing."""
|
2019-08-05 12:19:19 +02:00
|
|
|
sqlExecute(
|
|
|
|
"UPDATE sent SET folder = 'trash' \
|
|
|
|
WHERE lastactiontime = {};".format(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-08-05 09:24:32 +02: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-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):
|
2018-08-31 13:19:57 +02:00
|
|
|
"""Trash Screen uses screen to show widgets of screens."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2018-08-21 14:48:16 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-05 09:24:32 +02: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):
|
2018-09-01 13:45:39 +02:00
|
|
|
"""Clock Schdule for method inbox accounts."""
|
2019-06-28 16:54:47 +02:00
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
|
|
|
|
2019-08-05 09:24:32 +02:00
|
|
|
inbox = sqlQuery(
|
2019-08-17 14:43:10 +02:00
|
|
|
"SELECT toaddress, fromaddress, subject, message, folder from \
|
|
|
|
inbox WHERE folder = 'trash' and toaddress = '{}';".format(
|
2019-08-05 12:19:19 +02:00
|
|
|
state.association))
|
2019-08-05 09:24:32 +02:00
|
|
|
sent = sqlQuery(
|
2019-08-17 14:43:10 +02:00
|
|
|
"SELECT toaddress, fromaddress, subject, message, folder from \
|
|
|
|
sent WHERE folder = 'trash' and fromaddress = '{}';".format(
|
2019-08-05 12:19:19 +02:00
|
|
|
state.association))
|
2019-06-06 15:48:20 +02:00
|
|
|
trash_data = inbox + sent
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
for item in trash_data:
|
2019-08-05 09:24:32 +02:00
|
|
|
meny = ThreeLineAvatarIconListItem(
|
2019-08-16 16:49:55 +02:00
|
|
|
text='Draft' if item[4] == 'draft' else item[1],
|
2019-08-14 16:55:34 +02:00
|
|
|
secondary_text=item[2] if item[2] else item[1],
|
2019-08-05 09:24:32 +02:00
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-16 16:49:55 +02:00
|
|
|
img_latter = './images/avatar.png' if item[
|
|
|
|
4] == 'draft' else './images/text_images/{}.png'.format(
|
2019-08-05 12:19:19 +02:00
|
|
|
item[2][0].upper() if (item[2][0].upper() >= 'A' and item[
|
2019-08-14 16:55:34 +02:00
|
|
|
2][0].upper() <= 'Z') else '!')
|
|
|
|
meny.add_widget(AvatarSampleWidget(source=img_latter))
|
2019-05-09 14:48:29 +02:00
|
|
|
self.ids.ml.add_widget(meny)
|
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-08-05 09:24:32 +02:00
|
|
|
"""Page Screen show widgets of page."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
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-08-05 09:24:32 +02:00
|
|
|
"""Creates the screen widgets."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, **kwargs):
|
2019-08-05 09:24:32 +02: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-08-05 09:24:32 +02:00
|
|
|
"""Setting the Screen components."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2018-07-18 14:49:39 +02:00
|
|
|
pass
|
2018-07-03 11:08:02 +02:00
|
|
|
|
2018-07-07 14:11:58 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class NavigateApp(App):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Navigation Layout of class."""
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
theme_cls = ThemeManager()
|
|
|
|
previous_date = ObjectProperty()
|
|
|
|
obj_1 = ObjectProperty()
|
|
|
|
variable_1 = ListProperty(BMConfigParser().addresses())
|
|
|
|
nav_drawer = ObjectProperty()
|
2019-06-28 16:54:47 +02:00
|
|
|
state.screen_density = Window.size
|
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
|
|
|
|
menu_items = [
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
{'viewclass': 'MDMenuItem',
|
|
|
|
'text': 'Example item'},
|
|
|
|
]
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def build(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method builds the widget."""
|
|
|
|
import os
|
2019-05-09 14:48:29 +02:00
|
|
|
main_widget = Builder.load_file(
|
|
|
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
|
|
|
self.nav_drawer = Navigatorss()
|
|
|
|
self.obj_1 = AddressBook()
|
|
|
|
kivysignalthread = UIkivySignaler()
|
|
|
|
kivysignalthread.daemon = True
|
|
|
|
kivysignalthread.start()
|
2019-06-06 15:48:20 +02:00
|
|
|
Window.bind(on_keyboard=self.on_key)
|
2019-05-09 14:48:29 +02:00
|
|
|
return main_widget
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def run(self):
|
2019-08-05 09:24:32 +02: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"):
|
|
|
|
"""Show the addresses in spinner to make as dropdown."""
|
|
|
|
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] + '..'
|
|
|
|
else:
|
|
|
|
return "textdemo"
|
|
|
|
elif name == "values":
|
|
|
|
if BMConfigParser().addresses():
|
2019-08-06 12:05:03 +02:00
|
|
|
return [address[:16] + '..'
|
|
|
|
for address in BMConfigParser().addresses()]
|
2019-05-09 14:48:29 +02:00
|
|
|
else:
|
|
|
|
return "valuesdemo"
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def getCurrentAccountData(self, text):
|
|
|
|
"""Get Current Address Account Data."""
|
2019-08-05 12:19:19 +02:00
|
|
|
address_label = self.current_address_label(
|
|
|
|
BMConfigParser().get(text, 'label'))
|
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
|
|
|
|
self.root.ids.sc1.clear_widgets()
|
|
|
|
self.root.ids.sc4.clear_widgets()
|
|
|
|
self.root.ids.sc5.clear_widgets()
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.sc16.clear_widgets()
|
2019-08-19 13:06:24 +02:00
|
|
|
self.root.ids.sc17.clear_widgets()
|
2019-05-09 14:48:29 +02:00
|
|
|
self.root.ids.sc1.add_widget(Inbox())
|
|
|
|
self.root.ids.sc4.add_widget(Sent())
|
|
|
|
self.root.ids.sc5.add_widget(Trash())
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.sc16.add_widget(Draft())
|
2019-08-19 13:06:24 +02:00
|
|
|
self.root.ids.sc17.add_widget(Allmails())
|
2019-06-06 15:48:20 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
2018-08-31 13:19:57 +02:00
|
|
|
|
2019-08-06 12:05:03 +02:00
|
|
|
msg_counter_objs = \
|
|
|
|
self.root_window.children[1].children[2].children[0].ids
|
2019-08-05 09:24:32 +02:00
|
|
|
state.sent_count = str(
|
|
|
|
sqlQuery(
|
2019-08-06 12:05:03 +02:00
|
|
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
|
|
|
|
folder = 'sent' ;".format(state.association))[0][0])
|
2019-08-05 09:24:32 +02:00
|
|
|
state.inbox_count = str(
|
|
|
|
sqlQuery(
|
2019-08-08 18:20:58 +02:00
|
|
|
"SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and \
|
2019-08-06 12:05:03 +02:00
|
|
|
folder = 'inbox' ;".format(state.association))[0][0])
|
|
|
|
state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \
|
|
|
|
where fromaddress = '{0}' and folder = 'trash' ) \
|
2019-08-08 18:20:58 +02:00
|
|
|
+(SELECT count(*) FROM inbox where toaddress = '{0}' and \
|
2019-08-06 12:05:03 +02:00
|
|
|
folder = 'trash') AS SumCount".format(state.association))[0][0])
|
2019-08-05 09:24:32 +02:00
|
|
|
state.draft_count = str(
|
|
|
|
sqlQuery(
|
2019-08-06 12:05:03 +02:00
|
|
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
|
|
|
|
folder = 'draft' ;".format(state.association))[0][0])
|
2019-08-19 13:06:24 +02:00
|
|
|
state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
2019-06-28 16:54:47 +02:00
|
|
|
|
|
|
|
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
|
2019-07-17 10:50:27 +02:00
|
|
|
msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
2019-08-19 13:06:24 +02:00
|
|
|
msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
@staticmethod
|
|
|
|
def getCurrentAccount():
|
|
|
|
"""It uses to get current account label."""
|
|
|
|
if state.association:
|
|
|
|
return state.association
|
|
|
|
else:
|
|
|
|
return "Bitmessage Login"
|
2018-09-05 16:18:57 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def addingtoaddressbook():
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Adding to address Book."""
|
2019-05-09 14:48:29 +02:00
|
|
|
p = GrashofPopup()
|
|
|
|
p.open()
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def getDefaultAccData():
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Getting Default Account Data."""
|
2019-05-09 14:48:29 +02:00
|
|
|
if BMConfigParser().addresses():
|
|
|
|
return BMConfigParser().addresses()[0]
|
|
|
|
return 'Select Address'
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def addressexist():
|
2019-08-05 09:24:32 +02: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):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method is used for going on previous screen."""
|
2019-08-05 12:19:19 +02:00
|
|
|
if key == 27:
|
2019-07-17 10:50:27 +02:00
|
|
|
if self.root.ids.scr_mngr.current == "mailDetail":
|
2019-08-06 12:05:03 +02:00
|
|
|
self.root.ids.scr_mngr.current = \
|
2019-08-19 13:06:24 +02:00
|
|
|
'sent' if state.detailPageType == 'sent' else 'inbox' if state.detailPageType == 'inbox' else 'draft'
|
|
|
|
if state.detailPageType in ['sent', 'inbox']:
|
|
|
|
self.add_search_bar()
|
2019-07-17 10:50:27 +02:00
|
|
|
elif self.root.ids.scr_mngr.current == "create":
|
|
|
|
composer_objs = self.root
|
2019-08-06 12:05:03 +02:00
|
|
|
from_addr = str(self.root.children[1].children[0].children[
|
|
|
|
0].children[0].children[0].ids.ti.text)
|
|
|
|
to_addr = str(self.root.children[1].children[0].children[
|
|
|
|
0].children[0].children[0].ids.txt_input.text)
|
2019-08-19 13:06:24 +02:00
|
|
|
if from_addr and to_addr and state.detailPageType != 'draft':
|
2019-07-17 10:50:27 +02:00
|
|
|
Draft().draft_msg(composer_objs)
|
2019-06-06 15:48:20 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
2019-08-06 18:13:34 +02:00
|
|
|
self.add_search_bar()
|
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'
|
2019-06-06 15:48:20 +02:00
|
|
|
else:
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.scr_mngr.current = 'inbox'
|
2019-08-06 18:13:34 +02:00
|
|
|
self.add_search_bar()
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.scr_mngr.transition.direction = 'right'
|
|
|
|
self.root.ids.scr_mngr.transition.bind(on_complete=self.restart)
|
|
|
|
return True
|
|
|
|
|
2019-08-02 11:11:33 +02:00
|
|
|
def restart(self, *args):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used to set transition direction."""
|
2019-07-17 10:50:27 +02:00
|
|
|
self.root.ids.scr_mngr.transition.direction = 'left'
|
|
|
|
self.root.ids.scr_mngr.transition.unbind(on_complete=self.restart)
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def status_dispatching(data):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used for status dispatching 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-08-05 09:24:32 +02:00
|
|
|
"""If slow down the nwe will make new composer edit screen."""
|
2019-08-06 18:13:34 +02:00
|
|
|
self.root.ids.search_bar.clear_widgets()
|
2019-06-28 16:54:47 +02:00
|
|
|
composer_obj = self.root.ids.sc3.children[0].ids
|
|
|
|
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-16 16:49:55 +02:00
|
|
|
@staticmethod
|
2019-08-17 14:43:10 +02:00
|
|
|
def on_stop():
|
2019-08-05 09:24:32 +02:00
|
|
|
"""On stop methos is used for stoping the runing script."""
|
2019-08-13 14:46:19 +02:00
|
|
|
print "*******************EXITING FROM APPLICATION*******************"
|
2019-06-28 16:54:47 +02:00
|
|
|
import shutdown
|
|
|
|
shutdown.doCleanShutdown()
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def mail_count(text):
|
2019-08-07 10:12:41 +02:00
|
|
|
"""Counting Mail numbers."""
|
2019-06-28 16:54:47 +02:00
|
|
|
if state.association == '':
|
|
|
|
if BMConfigParser().addresses():
|
|
|
|
state.association = BMConfigParser().addresses()[0]
|
|
|
|
if text == 'Sent':
|
2019-08-06 12:05:03 +02:00
|
|
|
state.sent_count = str(sqlQuery(
|
|
|
|
"SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \
|
|
|
|
folder = '{0}' ;".format(
|
2019-08-05 09:24:32 +02:00
|
|
|
text.lower(), state.association))[0][0])
|
2019-06-28 16:54:47 +02:00
|
|
|
return state.sent_count
|
|
|
|
elif text == 'Inbox':
|
2019-08-06 12:05:03 +02:00
|
|
|
state.inbox_count = str(sqlQuery(
|
2019-08-08 18:20:58 +02:00
|
|
|
"SELECT COUNT(*) FROM {0} WHERE toaddress = '{1}' and \
|
2019-08-06 12:05:03 +02:00
|
|
|
folder = '{0}' ;".format(
|
|
|
|
text.lower(), state.association))[0][0])
|
2019-06-28 16:54:47 +02:00
|
|
|
return state.inbox_count
|
|
|
|
elif text == 'Trash':
|
2019-08-06 12:05:03 +02:00
|
|
|
state.trash_count = str(sqlQuery(
|
|
|
|
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' \
|
|
|
|
and folder = 'trash' )+(SELECT count(*) FROM inbox where \
|
2019-08-08 18:20:58 +02:00
|
|
|
toaddress = '{0}' and folder = 'trash') AS SumCount".format(
|
2019-08-06 12:05:03 +02:00
|
|
|
state.association))[0][0])
|
2019-06-28 16:54:47 +02:00
|
|
|
return state.trash_count
|
2019-07-17 10:50:27 +02:00
|
|
|
elif text == 'Draft':
|
2019-08-06 12:05:03 +02:00
|
|
|
state.draft_count = str(sqlQuery(
|
|
|
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{1}' and \
|
|
|
|
folder = '{0}' ;".format(
|
|
|
|
text.lower(), state.association))[0][0])
|
2019-07-17 10:50:27 +02:00
|
|
|
return state.draft_count
|
2019-08-14 16:55:34 +02:00
|
|
|
elif text == 'All Mails':
|
|
|
|
state.all_count = str(sqlQuery(
|
2019-08-19 13:06:24 +02:00
|
|
|
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and \
|
|
|
|
folder = 'sent' )+(SELECT count(*) FROM inbox where \
|
|
|
|
toaddress = '{0}' and folder != 'trash') AS SumCount".format(
|
2019-08-14 16:55:34 +02:00
|
|
|
state.association))[0][0])
|
|
|
|
return state.all_count
|
2019-07-17 10:50:27 +02:00
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def current_address_label(current_address=None):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Getting current address labels."""
|
2019-07-17 10:50:27 +02:00
|
|
|
if BMConfigParser().addresses() or current_address:
|
|
|
|
if current_address:
|
|
|
|
first_name = current_address
|
2019-08-02 11:11:33 +02:00
|
|
|
else:
|
2019-08-05 12:19:19 +02:00
|
|
|
first_name = BMConfigParser().get(
|
|
|
|
BMConfigParser().addresses()[0], 'label')
|
2019-07-17 10:50:27 +02:00
|
|
|
f_name = first_name.split()
|
2019-08-05 09:24:32 +02:00
|
|
|
return f_name[0][:14] + '...' if len(f_name[0]) > 15 else f_name[0]
|
2019-07-17 10:50:27 +02:00
|
|
|
return ''
|
2019-06-28 16:54:47 +02:00
|
|
|
|
2019-08-06 18:13:34 +02:00
|
|
|
def searchQuery(self, instance, *args):
|
2019-08-07 10:12:41 +02:00
|
|
|
"""Method used for 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()
|
|
|
|
if state.search_screen == 'inbox':
|
|
|
|
self.root.ids.sc1.clear_widgets()
|
|
|
|
self.root.ids.sc1.add_widget(Inbox())
|
2019-08-07 17:39:46 +02:00
|
|
|
elif state.search_screen == 'addressbook':
|
|
|
|
self.root.ids.sc11.clear_widgets()
|
|
|
|
self.root.ids.sc11.add_widget(AddressBook())
|
2019-08-08 18:20:58 +02:00
|
|
|
elif state.search_screen == 'myaddress':
|
|
|
|
self.root.ids.sc10.clear_widgets()
|
|
|
|
self.root.ids.sc10.add_widget(MyAddress())
|
2019-08-06 12:35:07 +02:00
|
|
|
else:
|
|
|
|
self.root.ids.sc4.clear_widgets()
|
|
|
|
self.root.ids.sc4.add_widget(Sent())
|
|
|
|
self.root.ids.scr_mngr.current = state.search_screen
|
2019-08-02 11:11:33 +02:00
|
|
|
|
|
|
|
def check_search_screen(self, instance):
|
2019-08-07 10:12:41 +02:00
|
|
|
"""Method show search button only on inbox or sent screen."""
|
2019-08-13 13:54:04 +02:00
|
|
|
if instance.text in ['Inbox', 'Sent', 'Address Book', 'My Addresses']:
|
2019-08-05 09:41:56 +02:00
|
|
|
if not self.root.ids.search_bar.children:
|
2019-08-07 10:12:41 +02:00
|
|
|
self.root.ids.search_bar.add_widget(
|
|
|
|
MDIconButton(icon='magnify'))
|
|
|
|
text_field = MDTextField(
|
2019-08-13 09:28:15 +02:00
|
|
|
id='search_field', hint_text='Search')
|
2019-08-07 10:12:41 +02:00
|
|
|
text_field.bind(text=self.searchQuery)
|
2019-08-06 18:13:34 +02:00
|
|
|
self.root.ids.search_bar.add_widget(text_field)
|
2019-08-07 17:39:46 +02:00
|
|
|
self.root.ids.search_bar.children[0].text = ''
|
2019-08-02 11:11:33 +02:00
|
|
|
else:
|
2019-08-05 09:41:56 +02:00
|
|
|
self.root.ids.search_bar.clear_widgets()
|
2019-08-07 17:39:46 +02:00
|
|
|
state.searcing_text = ''
|
2019-08-02 11:11:33 +02:00
|
|
|
return
|
|
|
|
|
2019-08-06 18:13:34 +02:00
|
|
|
def add_search_bar(self):
|
2019-08-07 10:12:41 +02:00
|
|
|
"""Method used for adding search function on screen."""
|
2019-08-06 18:13:34 +02:00
|
|
|
if not self.root.ids.search_bar.children:
|
2019-08-07 10:12:41 +02:00
|
|
|
self.root.ids.search_bar.add_widget(MDIconButton(icon='magnify'))
|
|
|
|
text_field = MDTextField(
|
2019-08-13 09:28:15 +02:00
|
|
|
id='search_field', hint_text='Search')
|
2019-08-07 10:12:41 +02:00
|
|
|
text_field.bind(text=self.searchQuery)
|
2019-08-06 18:13:34 +02:00
|
|
|
self.root.ids.search_bar.add_widget(text_field)
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2019-08-07 10:12:41 +02:00
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
class GrashofPopup(Popup):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Methods for saving contacts, error messages."""
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
def __init__(self, **kwargs):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Grash of pop screen settings."""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(GrashofPopup, self).__init__(**kwargs)
|
2019-06-28 16:54:47 +02:00
|
|
|
if state.screen_density[0] <= 720:
|
|
|
|
self.size_hint_y = 0.4
|
|
|
|
self.size_hint_x = 0.9
|
|
|
|
else:
|
|
|
|
self.size_hint_y = 0.42
|
|
|
|
self.size_hint_x = 0.7
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
def savecontact(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method is used for Saving Contacts."""
|
2019-08-06 12:05:03 +02:00
|
|
|
my_addresses = \
|
|
|
|
self.parent.children[1].children[2].children[0].ids.btn.values
|
2019-07-17 10:50:27 +02:00
|
|
|
entered_text = str(self.ids.label.text)
|
|
|
|
if entered_text in my_addresses:
|
|
|
|
self.ids.label.focus = True
|
|
|
|
self.ids.label.helper_text = 'Please Enter corrent address'
|
|
|
|
elif entered_text == '':
|
|
|
|
self.ids.label.focus = True
|
|
|
|
self.ids.label.helper_text = 'This field is required'
|
|
|
|
|
2019-05-09 14:48:29 +02:00
|
|
|
label = self.ids.label.text
|
|
|
|
address = self.ids.address.text
|
2019-08-13 13:54:04 +02:00
|
|
|
stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
|
|
|
folder="addressbook")]
|
2019-08-13 09:28:15 +02:00
|
|
|
if label and address and address not in stored_address:
|
2019-05-09 14:48:29 +02:00
|
|
|
state.navinstance = self.parent.children[1]
|
|
|
|
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
|
|
|
self.dismiss()
|
|
|
|
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
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
|
|
|
|
|
|
|
def show_error_message(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Showing error message."""
|
2019-08-06 12:05:03 +02:00
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
theme_text_color='Secondary',
|
|
|
|
text="Hey you are not allowed to save blank address contact. "
|
|
|
|
"That's wrong!",
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-05-09 14:48:29 +02:00
|
|
|
content.bind(texture_size=content.setter('size'))
|
|
|
|
self.dialog = MDDialog(content=content,
|
|
|
|
size_hint=(.8, None),
|
|
|
|
height=dp(200),
|
|
|
|
auto_dismiss=False)
|
|
|
|
|
|
|
|
self.dialog.add_action_button("ok",
|
|
|
|
action=lambda *x: self.dialog.dismiss())
|
|
|
|
self.dialog.open()
|
|
|
|
|
2019-08-17 14:43:10 +02:00
|
|
|
@staticmethod
|
|
|
|
def close_pop():
|
2019-08-13 13:54:04 +02:00
|
|
|
"""Pop is Canceled."""
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Canceled')
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class AvatarSampleWidget(ILeftBody, Image):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Avatar Sample Widget."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
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-08-05 09:24:32 +02:00
|
|
|
"""Left icon sample widget."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
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 IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Right icon sample widget."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class NavigationDrawerTwoLineListItem(
|
|
|
|
TwoLineListItem, NavigationDrawerHeaderBase):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Navigation Drawer in Listitems."""
|
2019-05-09 14:48:29 +02:00
|
|
|
|
|
|
|
address_property = StringProperty()
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method for Navigation Drawer."""
|
2019-05-09 14:48:29 +02:00
|
|
|
super(NavigationDrawerTwoLineListItem, self).__init__(**kwargs)
|
|
|
|
Clock.schedule_once(lambda dt: self.setup())
|
|
|
|
|
|
|
|
def setup(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Bind Controller.current_account property."""
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
def on_current_account(self, account):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Account detail."""
|
2019-05-09 14:48:29 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
def _update_specific_text_color(self, instance, value):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def _set_active(self, active, list):
|
2019-05-28 13:12:51 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
class MailDetail(Screen):
|
|
|
|
"""MailDetail Screen uses to show the detail of mails."""
|
2019-08-05 09:24:32 +02: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()
|
2019-05-28 13:12:51 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-05 09:24:32 +02: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-06-06 15:48:20 +02: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-08-06 12:05:03 +02:00
|
|
|
"select toaddress, fromaddress, subject, message, status, \
|
|
|
|
ackdata from sent where lastactiontime = {};".format(
|
|
|
|
state.sentMailTime))
|
2019-06-06 15:48:20 +02:00
|
|
|
state.status = self
|
|
|
|
state.ackdata = data[0][5]
|
|
|
|
self.assign_mail_details(data)
|
|
|
|
elif state.detailPageType == 'inbox':
|
2019-08-05 09:24:32 +02:00
|
|
|
data = sqlQuery(
|
2019-08-06 12:05:03 +02:00
|
|
|
"select toaddress, fromaddress, subject, message from inbox \
|
|
|
|
where received = {};".format(state.sentMailTime))
|
2019-06-06 15:48:20 +02:00
|
|
|
self.assign_mail_details(data)
|
|
|
|
|
2019-08-05 09:24:32 +02:00
|
|
|
def assign_mail_details(self, data):
|
|
|
|
"""Assigning mail details."""
|
2019-06-06 15:48:20 +02:00
|
|
|
self.to_addr = data[0][0]
|
|
|
|
self.from_addr = data[0][1]
|
2019-08-19 13:06:24 +02:00
|
|
|
self.subject = data[0][2].upper() if data[0][2].upper() else '(no subject)'
|
2019-06-06 15:48:20 +02:00
|
|
|
self.message = data[0][3]
|
|
|
|
if len(data[0]) == 6:
|
|
|
|
self.status = data[0][4]
|
|
|
|
|
|
|
|
def delete_mail(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method for mail delete."""
|
2019-08-06 12:05:03 +02:00
|
|
|
msg_count_objs = \
|
|
|
|
self.parent.parent.parent.parent.parent.children[2].children[0].ids
|
2019-06-06 15:48:20 +02:00
|
|
|
if state.detailPageType == 'sent':
|
2019-08-06 12:05:03 +02:00
|
|
|
sqlExecute(
|
|
|
|
"UPDATE sent SET folder = 'trash' WHERE \
|
|
|
|
lastactiontime = {};".format(state.sentMailTime))
|
2019-07-17 10:50:27 +02:00
|
|
|
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
|
|
|
|
state.sent_count = str(int(state.sent_count) - 1)
|
2019-06-06 15:48:20 +02:00
|
|
|
self.parent.parent.screens[3].clear_widgets()
|
|
|
|
self.parent.parent.screens[3].add_widget(Sent())
|
|
|
|
self.parent.parent.current = 'sent'
|
2019-06-28 16:54:47 +02:00
|
|
|
elif state.detailPageType == 'inbox':
|
2019-08-06 12:05:03 +02:00
|
|
|
sqlExecute(
|
|
|
|
"UPDATE inbox SET folder = 'trash' WHERE \
|
|
|
|
received = {};".format(state.sentMailTime))
|
2019-08-05 12:19:19 +02:00
|
|
|
msg_count_objs.inbox_cnt.badge_text = str(
|
|
|
|
int(state.inbox_count) - 1)
|
2019-07-17 10:50:27 +02:00
|
|
|
state.inbox_count = str(int(state.inbox_count) - 1)
|
2019-06-28 16:54:47 +02:00
|
|
|
self.parent.parent.screens[0].clear_widgets()
|
|
|
|
self.parent.parent.screens[0].add_widget(Inbox())
|
|
|
|
self.parent.parent.current = 'inbox'
|
2019-07-17 10:50:27 +02:00
|
|
|
msg_count_objs.trash_cnt.badge_text = str(int(state.trash_count) + 1)
|
2019-08-14 16:55:34 +02:00
|
|
|
msg_count_objs.allmail_cnt.badge_text = str(int(state.all_count) - 1)
|
2019-07-17 10:50:27 +02:00
|
|
|
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-06-06 15:48:20 +02:00
|
|
|
self.parent.parent.screens[4].clear_widgets()
|
|
|
|
self.parent.parent.screens[4].add_widget(Trash())
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Deleted')
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
def inbox_reply(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used for replying inbox messages."""
|
|
|
|
data = sqlQuery(
|
2019-08-06 12:05:03 +02:00
|
|
|
"select toaddress, fromaddress, subject, message from inbox where \
|
|
|
|
received = {};".format(state.sentMailTime))
|
2019-06-28 16:54:47 +02:00
|
|
|
composer_obj = self.parent.parent.screens[2].children[0].ids
|
|
|
|
composer_obj.ti.text = data[0][1]
|
|
|
|
composer_obj.btn.text = data[0][1]
|
|
|
|
composer_obj.txt_input.text = data[0][0]
|
|
|
|
composer_obj.subject.text = data[0][2]
|
|
|
|
self.parent.parent.current = 'create'
|
|
|
|
|
|
|
|
def copy_sent_mail(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used for copying sent mail to the composer."""
|
2019-06-28 16:54:47 +02:00
|
|
|
pass
|
|
|
|
|
2019-08-19 13:06:24 +02:00
|
|
|
def write_msg(self):
|
|
|
|
"""This method is used to write on draft mail."""
|
|
|
|
state.send_draft_mail = state.sentMailTime
|
|
|
|
composer_ids = self.parent.parent.parent.parent.parent.ids.sc3.children[0].ids
|
|
|
|
composer_ids.ti.text = self.from_addr
|
|
|
|
composer_ids.btn.text = self.from_addr
|
|
|
|
composer_ids.txt_input.text = self.to_addr
|
|
|
|
composer_ids.subject.text = '' if self.subject == '(no subject)' else self.subject.lower()
|
|
|
|
composer_ids.body.text = self.message
|
|
|
|
self.parent.parent.current = 'create'
|
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
|
|
|
|
class MyaddDetailPopup(Popup):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""MyaddDetailPopup pop is used for showing my address detail."""
|
|
|
|
|
2019-06-06 15:48:20 +02:00
|
|
|
address_label = StringProperty()
|
|
|
|
address = StringProperty()
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
2019-08-05 09:24:32 +02: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
|
|
|
if state.screen_density[0] <= 720:
|
|
|
|
self.size_hint_y = 0.32
|
|
|
|
self.size_hint_x = 0.9
|
|
|
|
else:
|
|
|
|
self.size_hint_y = 0.32
|
|
|
|
self.size_hint_x = 0.7
|
2019-06-06 15:48:20 +02:00
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
def set_address(self, address, label):
|
2019-08-05 09:24:32 +02: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-08-05 09:24:32 +02:00
|
|
|
"""Method used to fill from address of composer autofield."""
|
2019-06-28 16:54:47 +02:00
|
|
|
window_obj = self.parent.children[1].ids
|
|
|
|
window_obj.sc3.children[0].ids.ti.text = self.address
|
|
|
|
window_obj.sc3.children[0].ids.btn.text = self.address
|
|
|
|
window_obj.sc3.children[0].ids.txt_input.text = ''
|
|
|
|
window_obj.sc3.children[0].ids.subject.text = ''
|
|
|
|
window_obj.sc3.children[0].ids.body.text = ''
|
|
|
|
window_obj.scr_mngr.current = 'create'
|
|
|
|
self.dismiss()
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def close_pop():
|
2019-08-13 13:54:04 +02: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-08-05 09:24:32 +02:00
|
|
|
"""AddbookDetailPopup pop is used for showing my address detail."""
|
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
address_label = StringProperty()
|
|
|
|
address = StringProperty()
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used set screen of address detail page."""
|
2019-06-28 16:54:47 +02:00
|
|
|
super(AddbookDetailPopup, self).__init__(**kwargs)
|
|
|
|
if state.screen_density[0] <= 720:
|
|
|
|
self.size_hint_y = 0.35
|
|
|
|
self.size_hint_x = 0.95
|
|
|
|
else:
|
|
|
|
self.size_hint_y = 0.35
|
|
|
|
self.size_hint_x = 0.7
|
|
|
|
|
|
|
|
def set_addbook_data(self, address, label):
|
2019-08-05 09:24:32 +02: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-08-05 09:24:32 +02:00
|
|
|
"""Updating the label of address book address."""
|
2019-06-28 16:54:47 +02:00
|
|
|
if str(self.ids.add_label.text):
|
2019-08-06 12:05:03 +02:00
|
|
|
sqlExecute("UPDATE addressbook SET label = '{}' WHERE \
|
|
|
|
address = '{}';".format(str(self.ids.add_label.text), address))
|
2019-06-28 16:54:47 +02:00
|
|
|
self.parent.children[1].ids.sc11.clear_widgets()
|
|
|
|
self.parent.children[1].ids.sc11.add_widget(AddressBook())
|
|
|
|
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-08-05 09:24:32 +02:00
|
|
|
"""Method used to fill to_address of composer autofield."""
|
2019-06-28 16:54:47 +02:00
|
|
|
window_obj = self.parent.children[1].ids
|
|
|
|
window_obj.sc3.children[0].ids.txt_input.text = self.address
|
|
|
|
window_obj.sc3.children[0].ids.ti.text = ''
|
|
|
|
window_obj.sc3.children[0].ids.btn.text = ''
|
|
|
|
window_obj.sc3.children[0].ids.subject.text = ''
|
|
|
|
window_obj.sc3.children[0].ids.body.text = ''
|
|
|
|
window_obj.scr_mngr.current = 'create'
|
|
|
|
self.dismiss()
|
|
|
|
|
2019-08-16 16:49:55 +02:00
|
|
|
@staticmethod
|
|
|
|
def close_pop():
|
2019-08-13 13:54:04 +02:00
|
|
|
"""Pop is Canceled."""
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Canceled')
|
|
|
|
|
2019-06-28 16:54:47 +02:00
|
|
|
|
|
|
|
class ShowQRCode(Screen):
|
|
|
|
"""ShowQRCode Screen uses to show the detail of mails."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-06-28 16:54:47 +02:00
|
|
|
|
|
|
|
def qrdisplay(self):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used for showing QR Code."""
|
2019-08-13 09:28:15 +02:00
|
|
|
self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
|
2019-06-28 16:54:47 +02:00
|
|
|
self.ids.qr.clear_widgets()
|
2019-08-05 09:41:56 +02:00
|
|
|
from kivy.garden.qrcode import QRCodeWidget
|
2019-08-06 13:01:05 +02:00
|
|
|
self.ids.qr.add_widget(QRCodeWidget(
|
|
|
|
data=self.manager.get_parent_window().children[0].address))
|
2019-08-13 09:28:15 +02:00
|
|
|
toast('Show QR code')
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Draft(Screen):
|
|
|
|
"""Draft screen is used to show the list of draft messages."""
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2019-07-17 10:50:27 +02:00
|
|
|
data = ListProperty()
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-05 09:24:32 +02: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):
|
|
|
|
"""Clock Schdule for method draft accounts."""
|
|
|
|
self.sentaccounts()
|
2019-08-13 14:46:19 +02:00
|
|
|
print dt
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
def sentaccounts(self):
|
|
|
|
"""Load draft accounts."""
|
|
|
|
account = state.association
|
|
|
|
self.loadSent(account, 'All', '')
|
|
|
|
|
|
|
|
def loadSent(self, account, where="", what=""):
|
|
|
|
"""Load draft list for Draft messages."""
|
|
|
|
xAddress = 'fromaddress'
|
|
|
|
queryreturn = kivy_helper_search.search_sql(
|
|
|
|
xAddress, account, "draft", where, what, False)
|
|
|
|
if state.msg_counter_objs:
|
|
|
|
state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn))
|
2019-08-19 13:06:24 +02:00
|
|
|
# state.all_count = str(int(state.all_count) + 1)
|
|
|
|
# state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
|
|
|
# state.msg_counter_objs = None
|
2019-07-17 10:50:27 +02:00
|
|
|
|
|
|
|
if queryreturn:
|
|
|
|
for mail in queryreturn:
|
|
|
|
third_text = mail[3].replace('\n', ' ')
|
2019-08-05 09:24:32 +02:00
|
|
|
self.data.append({
|
|
|
|
'text': mail[1].strip(),
|
|
|
|
'secondary_text': mail[2][:10] + '...........' if len(
|
|
|
|
mail[2]) > 10 else mail[2] + '\n' + " " + (
|
2019-08-13 14:46:19 +02:00
|
|
|
third_text[:25] + '...!') if len(
|
|
|
|
third_text) > 25 else third_text,
|
2019-08-05 09:24:32 +02:00
|
|
|
'lastactiontime': mail[6]})
|
2019-07-17 10:50:27 +02:00
|
|
|
for item in self.data:
|
2019-08-05 09:24:32 +02:00
|
|
|
meny = TwoLineAvatarIconListItem(
|
|
|
|
text='Draft',
|
|
|
|
secondary_text=item['text'],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-05 12:19:19 +02:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source='./images/avatar.png'))
|
2019-08-19 13:06:24 +02:00
|
|
|
meny.bind(on_press=partial(
|
|
|
|
self.draft_detail, item['lastactiontime']))
|
2019-07-17 10:50:27 +02:00
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
if platform == 'android':
|
2019-08-02 11:11:33 +02:00
|
|
|
carousel.height = 150
|
|
|
|
elif platform == 'linux':
|
|
|
|
carousel.height = meny.height - 10
|
2019-07-17 10:50:27 +02:00
|
|
|
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.0, 0.0, 1.0)
|
2019-08-05 12:19:19 +02:00
|
|
|
del_btn.bind(on_press=partial(
|
|
|
|
self.delete_draft, item['lastactiontime']))
|
2019-07-17 10:50:27 +02:00
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
2019-08-05 09:24:32 +02:00
|
|
|
carousel.index = 1
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
else:
|
2019-08-06 12:05:03 +02:00
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
theme_text_color='Primary',
|
|
|
|
text="yet no message for this account!!!!!!!!!!!!!",
|
|
|
|
halign='center',
|
|
|
|
bold=True,
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
2019-07-17 10:50:27 +02:00
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
2019-08-19 13:06:24 +02:00
|
|
|
def draft_detail(self, lastsenttime, *args):
|
|
|
|
state.detailPageType = 'draft'
|
|
|
|
state.sentMailTime = lastsenttime
|
|
|
|
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-08-05 09:24:32 +02:00
|
|
|
"""Method used to delete draft message permanently."""
|
2019-08-16 16:56:19 +02:00
|
|
|
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
|
|
|
|
data_index))
|
2019-07-17 10:50:27 +02:00
|
|
|
try:
|
2019-08-06 12:05:03 +02:00
|
|
|
msg_count_objs = \
|
|
|
|
self.parent.parent.parent.parent.children[2].children[0].ids
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-08-06 12:05:03 +02: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:
|
2019-08-05 12:19:19 +02:00
|
|
|
msg_count_objs.draft_cnt.badge_text = str(
|
|
|
|
int(state.draft_count) - 1)
|
2019-08-14 16:55:34 +02:00
|
|
|
msg_count_objs.allmail_cnt.badge_text = str(
|
|
|
|
int(state.all_count) - 1)
|
|
|
|
msg_count_objs.trash_cnt.badge_text = str(
|
|
|
|
int(state.trash_count) + 1)
|
2019-07-17 10:50:27 +02:00
|
|
|
state.draft_count = str(int(state.draft_count) - 1)
|
2019-08-14 16:55:34 +02:00
|
|
|
state.all_count = str(int(state.all_count) - 1)
|
|
|
|
state.trash_count = str(int(state.trash_count) + 1)
|
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
|
|
|
|
def draft_msg(src_object):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used for saving draft mails."""
|
2019-08-16 16:49:55 +02:00
|
|
|
# pylint: disable=too-many-locals
|
2019-08-06 12:05:03 +02:00
|
|
|
composer_object = src_object.children[1].children[0].children[
|
|
|
|
0].children[0].children[0].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:
|
|
|
|
from addresses import decodeAddress
|
2019-08-06 12:05:03 +02:00
|
|
|
status, addressVersionNumber, streamNumber, ripe = \
|
|
|
|
decodeAddress(toAddress)
|
2019-08-05 09:24:32 +02:00
|
|
|
from addresses import addBMIfNotPresent
|
2019-07-17 10:50:27 +02:00
|
|
|
toAddress = addBMIfNotPresent(toAddress)
|
|
|
|
statusIconColor = 'red'
|
|
|
|
stealthLevel = BMConfigParser().safeGetInt(
|
|
|
|
'bitmessagesettings', 'ackstealthlevel')
|
|
|
|
from helper_ackPayload import genAckPayload
|
|
|
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
|
|
|
t = ()
|
|
|
|
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,
|
|
|
|
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
|
|
|
|
|
|
|
state.msg_counter_objs = src_object.children[2].children[0].ids
|
|
|
|
state.draft_count = str(int(state.draft_count) + 1)
|
|
|
|
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-08-05 09:24:32 +02:00
|
|
|
"""This class is used for setting spinner size."""
|
2019-08-17 14:43:10 +02:00
|
|
|
# pylint: disable=too-few-public-methods
|
2019-08-05 09:24:32 +02:00
|
|
|
|
2019-08-02 11:11:33 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-08-05 09:24:32 +02:00
|
|
|
"""Method used for setting size of spinner."""
|
2019-08-02 11:11:33 +02:00
|
|
|
super(CustomSpinner, self).__init__(*args, **kwargs)
|
2019-08-08 09:33:17 +02:00
|
|
|
max_value = 2.8
|
|
|
|
self.dropdown_cls.max_height = self.height * max_value + max_value * 4
|
2019-08-06 18:13:34 +02:00
|
|
|
|
|
|
|
|
2019-08-08 09:33:17 +02:00
|
|
|
def remove_search_bar(obj):
|
2019-08-07 10:12:41 +02:00
|
|
|
"""Remove search bar."""
|
2019-08-13 09:28:15 +02:00
|
|
|
try:
|
2019-08-13 13:54:04 +02:00
|
|
|
obj.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets()
|
2019-08-13 14:46:19 +02:00
|
|
|
except Exception:
|
2019-08-13 13:54:04 +02:00
|
|
|
obj.parent.parent.parent.parent.ids.search_bar.clear_widgets()
|
2019-08-14 16:55:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Allmails(Screen):
|
|
|
|
"""all mails Screen uses screen to show widgets of screens."""
|
|
|
|
|
|
|
|
data = ListProperty()
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
"""Method Parsing the address."""
|
|
|
|
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):
|
|
|
|
"""Clock Schdule for method all mails."""
|
|
|
|
self.mailaccounts()
|
2019-08-16 16:49:55 +02:00
|
|
|
print dt
|
2019-08-14 16:55:34 +02:00
|
|
|
|
|
|
|
def mailaccounts(self):
|
|
|
|
"""Load all mails for account."""
|
|
|
|
account = state.association
|
|
|
|
self.loadMessagelist(account, 'All', '')
|
|
|
|
|
|
|
|
def loadMessagelist(self, account, where="", what=""):
|
|
|
|
"""Load Inbox, Sent anf Draft list of messages."""
|
|
|
|
inbox = sqlQuery(
|
2019-08-17 14:43:10 +02:00
|
|
|
"SELECT toaddress, fromaddress, subject, message, folder from\
|
|
|
|
inbox WHERE folder = 'inbox' and toaddress = '{}';".format(
|
2019-08-14 16:55:34 +02:00
|
|
|
account))
|
|
|
|
sent_and_draft = sqlQuery(
|
2019-08-19 13:06:24 +02:00
|
|
|
"SELECT toaddress, fromaddress, subject, message, folder from sent \
|
|
|
|
WHERE folder = 'sent' and fromaddress = '{}';".format(
|
2019-08-14 16:55:34 +02:00
|
|
|
account))
|
|
|
|
|
|
|
|
all_mails = inbox + sent_and_draft
|
|
|
|
if all_mails:
|
|
|
|
for item in all_mails:
|
|
|
|
meny = ThreeLineAvatarIconListItem(
|
|
|
|
text='Draft' if item[4] == 'draft' else item[1],
|
|
|
|
secondary_text=item[1] if item[4] == 'draft' else item[2],
|
|
|
|
theme_text_color='Custom',
|
|
|
|
text_color=NavigateApp().theme_cls.primary_color)
|
2019-08-16 16:49:55 +02:00
|
|
|
img_latter = './images/avatar.png' if item[
|
|
|
|
4] == 'draft' else './images/text_images/{}.png'.format(
|
|
|
|
item[2][0].upper() if (
|
|
|
|
item[2][0].upper() >= 'A' and item[
|
|
|
|
2][0].upper() <= 'Z') else '!')
|
2019-08-14 16:55:34 +02:00
|
|
|
meny.add_widget(AvatarSampleWidget(
|
|
|
|
source=img_latter))
|
|
|
|
carousel = Carousel(direction='right')
|
|
|
|
if platform == 'android':
|
|
|
|
carousel.height = 150
|
|
|
|
elif platform == 'linux':
|
|
|
|
carousel.height = meny.height - 10
|
|
|
|
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.0, 0.0, 1.0)
|
|
|
|
carousel.add_widget(del_btn)
|
|
|
|
carousel.add_widget(meny)
|
|
|
|
carousel.index = 1
|
|
|
|
self.ids.ml.add_widget(carousel)
|
|
|
|
else:
|
|
|
|
content = MDLabel(
|
|
|
|
font_style='Body1',
|
|
|
|
theme_text_color='Primary',
|
|
|
|
text="yet no message for this account!!!!!!!!!!!!!",
|
|
|
|
halign='center',
|
|
|
|
bold=True,
|
|
|
|
size_hint_y=None,
|
|
|
|
valign='top')
|
|
|
|
self.ids.ml.add_widget(content)
|
|
|
|
|
|
|
|
def refresh_callback(self, *args):
|
2019-08-17 14:43:10 +02: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):
|
|
|
|
"""Method used for loading the allmails screen data."""
|
|
|
|
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)
|