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
|
2020-05-13 18:01:22 +02:00
|
|
|
# pylint: disable=protected-access
|
2020-07-16 14:23:35 +02:00
|
|
|
# pylint: disable=import-outside-toplevel,ungrouped-imports,wrong-import-order,unused-import,arguments-differ
|
|
|
|
# pylint: disable=invalid-name,unnecessary-comprehension,broad-except,simplifiable-if-expression,no-member
|
2020-07-14 13:23:31 +02:00
|
|
|
# pylint: disable=too-many-return-statements
|
2020-06-10 13:15:20 +02:00
|
|
|
|
2020-06-10 17:34:23 +02:00
|
|
|
"""
|
2020-07-14 13:23:31 +02:00
|
|
|
Bitmessage android(mobile) interface
|
2020-06-10 17:34:23 +02:00
|
|
|
"""
|
|
|
|
|
2020-07-14 13:23:31 +02:00
|
|
|
from bitmessagekivy.get_platform import platform
|
2019-09-12 11:11:33 +02:00
|
|
|
import os
|
2021-03-31 17:02:23 +02:00
|
|
|
# from bitmessagekivy import identiconGeneration
|
2020-01-04 15:17:44 +01:00
|
|
|
from bitmessagekivy import kivy_helper_search
|
|
|
|
from bitmessagekivy.uikivysignaler import UIkivySignaler
|
2019-08-17 14:43:10 +02:00
|
|
|
from bmconfigparser import BMConfigParser
|
2021-03-31 17:02:23 +02:00
|
|
|
# from debug import logger
|
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.boxlayout import BoxLayout
|
|
|
|
from kivy.uix.spinner import Spinner
|
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
|
2021-03-31 17:02:23 +02:00
|
|
|
from kivymd.uix.button import MDRaisedButton
|
2019-10-01 16:49:03 +02:00
|
|
|
from kivymd.uix.list import (
|
2019-08-17 14:43:10 +02:00
|
|
|
IRightBodyTouch,
|
2020-01-18 11:31:50 +01:00
|
|
|
OneLineAvatarIconListItem,
|
|
|
|
OneLineListItem
|
2019-12-12 15:38:07 +01:00
|
|
|
)
|
2020-06-10 17:34:23 +02:00
|
|
|
|
|
|
|
from kivy.uix.screenmanager import RiseInTransition, SlideTransition, FallOutTransition
|
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-06-10 13:15:20 +02:00
|
|
|
from kivymd.uix.bottomsheet import MDCustomBottomSheet
|
2020-05-12 13:04:12 +02:00
|
|
|
|
2020-07-24 19:59:49 +02:00
|
|
|
from kivy.lang import Observable
|
|
|
|
import gettext
|
2020-10-19 23:03:22 +02:00
|
|
|
import l10n
|
|
|
|
import locale
|
2021-03-31 17:02:23 +02:00
|
|
|
import ast
|
|
|
|
|
|
|
|
from bitmessagekivy.baseclass.common import toast
|
2020-05-12 13:04:12 +02:00
|
|
|
|
2020-06-10 17:34:23 +02:00
|
|
|
if platform != "android":
|
2020-05-12 13:04:12 +02:00
|
|
|
from kivy.config import Config
|
2020-07-24 19:59:49 +02:00
|
|
|
from kivy_garden.zbarcam import ZBarCam
|
|
|
|
from pyzbar.pyzbar import ZBarSymbol
|
2020-06-10 17:34:23 +02:00
|
|
|
|
|
|
|
Config.set("input", "mouse", "mouse, multitouch_on_demand")
|
2020-07-14 13:23:31 +02:00
|
|
|
elif platform == "android":
|
|
|
|
from jnius import autoclass, cast
|
|
|
|
from android.runnable import run_on_ui_thread
|
|
|
|
from android import python_act as PythonActivity
|
|
|
|
|
|
|
|
Toast = autoclass("android.widget.Toast")
|
|
|
|
String = autoclass("java.lang.String")
|
|
|
|
CharSequence = autoclass("java.lang.CharSequence")
|
|
|
|
context = PythonActivity.mActivity
|
|
|
|
|
|
|
|
@run_on_ui_thread
|
|
|
|
def show_toast(text, length):
|
2020-07-16 14:23:35 +02:00
|
|
|
"""Its showing toast on screen"""
|
2020-07-14 13:23:31 +02:00
|
|
|
t = Toast.makeText(context, text, length)
|
|
|
|
t.show()
|
|
|
|
|
2019-08-03 13:49:28 +02:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
with open(os.path.join(os.path.dirname(__file__), "screens_data.json")
|
|
|
|
) as read_file:
|
|
|
|
all_data = ast.literal_eval(read_file.read())
|
|
|
|
data_screens = list(all_data.keys())
|
|
|
|
|
|
|
|
for modules in data_screens:
|
|
|
|
exec(all_data[modules]['Import'])
|
|
|
|
|
|
|
|
# pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init
|
2020-02-19 16:46:13 +01:00
|
|
|
|
|
|
|
|
2020-07-24 19:59:49 +02:00
|
|
|
class Lang(Observable):
|
|
|
|
observers = []
|
|
|
|
lang = None
|
|
|
|
|
|
|
|
def __init__(self, defaultlang):
|
|
|
|
super(Lang, self).__init__()
|
|
|
|
self.ugettext = None
|
|
|
|
self.lang = defaultlang
|
|
|
|
self.switch_lang(self.lang)
|
|
|
|
|
|
|
|
def _(self, text):
|
2021-03-31 17:02:23 +02:00
|
|
|
# return self.ugettext(text)
|
|
|
|
return text
|
2020-07-24 19:59:49 +02:00
|
|
|
|
|
|
|
def fbind(self, name, func, args, **kwargs):
|
|
|
|
if name == "_":
|
|
|
|
self.observers.append((func, args, kwargs))
|
|
|
|
else:
|
|
|
|
return super(Lang, self).fbind(name, func, *largs, **kwargs)
|
|
|
|
|
|
|
|
def funbind(self, name, func, args, **kwargs):
|
|
|
|
if name == "_":
|
|
|
|
key = (func, args, kwargs)
|
|
|
|
if key in self.observers:
|
|
|
|
self.observers.remove(key)
|
|
|
|
else:
|
|
|
|
return super(Lang, self).funbind(name, func, *args, **kwargs)
|
|
|
|
|
|
|
|
def switch_lang(self, lang):
|
|
|
|
# get the right locales directory, and instanciate a gettext
|
2021-03-31 17:02:23 +02:00
|
|
|
# locale_dir = os.path.join(os.path.dirname(__file__), 'translations', 'mo', 'locales')
|
|
|
|
# locales = gettext.translation('langapp', locale_dir, languages=[lang])
|
|
|
|
# self.ugettext = locales.gettext
|
2020-07-24 19:59:49 +02:00
|
|
|
|
|
|
|
# update all the kv rules attached to this text
|
|
|
|
for func, largs, kwargs in self.observers:
|
|
|
|
func(largs, None, None)
|
|
|
|
|
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
class NavigationItem(OneLineAvatarIconListItem):
|
|
|
|
"""NavigationItem class for kivy Ui"""
|
|
|
|
badge_text = StringProperty()
|
|
|
|
icon = StringProperty()
|
|
|
|
active = BooleanProperty(False)
|
2020-07-09 13:28:54 +02:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
def currentlyActive(self):
|
|
|
|
"""Currenly active"""
|
|
|
|
for nav_obj in self.parent.children:
|
|
|
|
nav_obj.active = False
|
|
|
|
self.active = True
|
2020-07-09 13:28:54 +02:00
|
|
|
|
2018-07-24 12:05:39 +02:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
class NavigationDrawerDivider(OneLineListItem):
|
|
|
|
"""
|
|
|
|
A small full-width divider that can be placed
|
|
|
|
in the :class:`MDNavigationDrawer`
|
|
|
|
"""
|
2019-12-26 16:56:04 +01:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
disabled = True
|
|
|
|
divider = None
|
|
|
|
_txt_top_pad = NumericProperty(dp(8))
|
|
|
|
_txt_bot_pad = NumericProperty(dp(8))
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2020-01-04 15:17:44 +01:00
|
|
|
def __init__(self, **kwargs):
|
2021-03-31 17:02:23 +02:00
|
|
|
# pylint: disable=bad-super-call
|
|
|
|
super(OneLineListItem, self).__init__(**kwargs)
|
|
|
|
self.height = dp(16)
|
2020-03-17 12:42:16 +01:00
|
|
|
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
class NavigationDrawerSubheader(OneLineListItem):
|
|
|
|
"""
|
|
|
|
A subheader for separating content in :class:`MDNavigationDrawer`
|
2018-08-21 14:48:16 +02:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
Works well alongside :class:`NavigationDrawerDivider`
|
|
|
|
"""
|
2018-08-04 10:30:12 +02:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
disabled = True
|
|
|
|
divider = None
|
|
|
|
theme_text_color = 'Secondary'
|
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):
|
2020-07-16 14:23:35 +02:00
|
|
|
"""ContentNavigationDrawer class for kivy Uir"""
|
2020-01-07 12:28:29 +01:00
|
|
|
|
2020-04-24 18:46:30 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
"""Method used for contentNavigationDrawer"""
|
|
|
|
super(ContentNavigationDrawer, self).__init__(*args, **kwargs)
|
|
|
|
Clock.schedule_once(self.init_ui, 0)
|
|
|
|
|
|
|
|
def init_ui(self, dt=0):
|
|
|
|
"""Clock Schdule for class contentNavigationDrawer"""
|
|
|
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
|
|
|
|
|
|
|
def check_scroll_y(self, instance, somethingelse):
|
|
|
|
"""show data on scroll down"""
|
|
|
|
if self.ids.btn.is_open:
|
|
|
|
self.ids.btn.is_open = False
|
2018-08-04 10:30:12 +02:00
|
|
|
|
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
class BadgeText(IRightBodyTouch, MDLabel):
|
|
|
|
"""BadgeText class for kivy Ui"""
|
2019-08-20 15:11:18 +02:00
|
|
|
|
2020-04-24 18:46:30 +02:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
class CustomSpinner(Spinner):
|
|
|
|
"""CustomSpinner class for kivy Ui"""
|
2020-10-19 23:03:22 +02:00
|
|
|
|
2020-07-14 14:00:01 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
2021-03-31 17:02:23 +02:00
|
|
|
"""Method used for setting size of spinner"""
|
|
|
|
super(CustomSpinner, self).__init__(*args, **kwargs)
|
|
|
|
self.dropdown_cls.max_height = Window.size[1] / 3
|
|
|
|
self.values = list(addr for addr in BMConfigParser().addresses()
|
|
|
|
if BMConfigParser().get(str(addr), 'enabled') == 'true')
|
2020-10-19 23:03:22 +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
|
2020-06-11 12:15:32 +02:00
|
|
|
file_manager = None
|
|
|
|
state.imageDir = os.path.join('./images', 'kivy')
|
|
|
|
image_path = state.imageDir
|
2020-11-26 15:23:27 +01:00
|
|
|
tr = Lang("en") # for changing in franch replace en with fr
|
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"""
|
2021-03-31 17:02:23 +02:00
|
|
|
print('data_screens: ', data_screens)
|
|
|
|
for kv in data_screens:
|
|
|
|
Builder.load_file(
|
|
|
|
os.path.join(
|
|
|
|
os.path.dirname(__file__),
|
|
|
|
"kv",
|
|
|
|
f"{all_data[kv]['kv_string']}.kv",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# self.obj_1 = AddressBook()
|
2019-05-09 14:48:29 +02:00
|
|
|
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
|
|
|
|
2021-03-16 10:43:11 +01:00
|
|
|
@staticmethod
|
|
|
|
def clickNavDrawer():
|
2021-02-22 19:17:23 +01:00
|
|
|
state.kivyapp.root.ids.nav_drawer.set_state('toggle')
|
|
|
|
|
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"""
|
2021-02-09 20:18:36 +01:00
|
|
|
if text != '':
|
|
|
|
if os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(text)):
|
|
|
|
self.load_selected_Image(text)
|
|
|
|
else:
|
2021-03-31 17:02:23 +02:00
|
|
|
# self.set_identicon(text)
|
2021-02-09 20:18:36 +01:00
|
|
|
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
|
|
|
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
|
|
|
address_label = self.current_address_label(
|
|
|
|
BMConfigParser().get(text, 'label'), text)
|
2021-02-26 11:33:29 +01:00
|
|
|
|
2021-02-09 20:18:36 +01:00
|
|
|
self.root_window.children[1].ids.toolbar.title = address_label
|
|
|
|
state.association = text
|
|
|
|
state.searcing_text = ''
|
|
|
|
LoadingPopup().open()
|
|
|
|
self.set_message_count()
|
|
|
|
for nav_obj in self.root.ids.content_drawer.children[
|
|
|
|
0].children[0].children[0].children:
|
|
|
|
nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
|
|
|
self.fileManagerSetting()
|
|
|
|
Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
2019-12-12 15:38:07 +01:00
|
|
|
|
2020-06-11 12:15:32 +02:00
|
|
|
def fileManagerSetting(self):
|
|
|
|
"""This method is for file manager setting"""
|
|
|
|
if not self.root.ids.content_drawer.ids.file_manager.opacity and \
|
|
|
|
self.root.ids.content_drawer.ids.file_manager.disabled:
|
2021-03-31 17:02:23 +02:00
|
|
|
self.root.ids.content_drawer.ids.file_manager.opacity = 0
|
|
|
|
self.root.ids.content_drawer.ids.file_manager.disabled = True
|
2020-06-11 12:15:32 +02:00
|
|
|
|
2019-12-12 15:38:07 +01:00
|
|
|
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
|
|
|
|
2020-07-14 14:00:01 +02:00
|
|
|
# @staticmethod
|
|
|
|
def addingtoaddressbook(self):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Adding to address Book"""
|
2020-07-14 14:00:01 +02:00
|
|
|
width = .85 if platform == 'android' else .8
|
|
|
|
self.add_popup = MDDialog(
|
|
|
|
title='add contact\'s',
|
|
|
|
type="custom",
|
2021-03-16 10:43:11 +01:00
|
|
|
size_hint=(width, .23),
|
2020-07-14 14:00:01 +02:00
|
|
|
content_cls=GrashofPopup(),
|
|
|
|
buttons=[
|
|
|
|
MDRaisedButton(
|
|
|
|
text="Save",
|
|
|
|
on_release=self.savecontact,
|
|
|
|
),
|
|
|
|
MDRaisedButton(
|
2021-03-16 10:43:11 +01:00
|
|
|
text="Cancel",
|
2020-07-14 14:00:01 +02:00
|
|
|
on_release=self.close_pop,
|
|
|
|
),
|
|
|
|
MDRaisedButton(
|
2021-03-16 10:43:11 +01:00
|
|
|
text="Scan QR code",
|
2020-07-24 19:59:49 +02:00
|
|
|
on_release=self.scan_qr_code,
|
2020-07-14 14:00:01 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2021-03-31 17:02:23 +02:00
|
|
|
# self.add_popup.set_normal_height()
|
2020-07-14 14:00:01 +02:00
|
|
|
self.add_popup.auto_dismiss = False
|
|
|
|
self.add_popup.open()
|
|
|
|
# p = GrashofPopup()
|
|
|
|
# p.open()
|
|
|
|
|
2020-07-24 19:59:49 +02:00
|
|
|
def scan_qr_code(self, instance):
|
|
|
|
"""this method is used for showing QR code scanner"""
|
|
|
|
if self.is_camara_attached():
|
|
|
|
self.add_popup.dismiss()
|
|
|
|
self.root.ids.sc23.get_screen(self.root.ids.scr_mngr.current, self.add_popup)
|
|
|
|
self.root.ids.scr_mngr.current = 'scanscreen'
|
|
|
|
else:
|
2020-12-03 09:41:13 +01:00
|
|
|
altet_txt = (
|
|
|
|
'Currently this feature is not avaialbe!' if platform == 'android' else 'Camera is not available!')
|
2020-07-24 19:59:49 +02:00
|
|
|
self.add_popup.dismiss()
|
|
|
|
toast(altet_txt)
|
|
|
|
|
|
|
|
def is_camara_attached(self):
|
|
|
|
"""This method is for checking is camera available or not"""
|
|
|
|
self.root.ids.sc23.check_camera()
|
|
|
|
is_available = self.root.ids.sc23.camera_avaialbe
|
|
|
|
return is_available
|
|
|
|
|
2020-07-14 14:00:01 +02:00
|
|
|
def savecontact(self, instance):
|
|
|
|
"""Method is used for saving contacts"""
|
|
|
|
pupup_obj = self.add_popup.content_cls
|
|
|
|
label = pupup_obj.ids.label.text.strip()
|
|
|
|
address = pupup_obj.ids.address.text.strip()
|
|
|
|
if label == '' and address == '':
|
|
|
|
pupup_obj.ids.label.focus = True
|
|
|
|
pupup_obj.ids.address.focus = True
|
|
|
|
elif address == '':
|
|
|
|
pupup_obj.ids.address.focus = True
|
|
|
|
elif label == '':
|
|
|
|
pupup_obj.ids.label.focus = True
|
2020-07-24 19:59:49 +02:00
|
|
|
else:
|
|
|
|
pupup_obj.ids.address.focus = True
|
|
|
|
# pupup_obj.ids.label.focus = True
|
2020-07-14 14:00:01 +02:00
|
|
|
|
|
|
|
stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
|
|
|
folder="addressbook")]
|
|
|
|
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 pupup_obj.valid:
|
|
|
|
# state.navinstance = self.parent.children[1]
|
|
|
|
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
|
|
|
self.add_popup.dismiss()
|
|
|
|
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
2021-02-26 11:33:29 +01:00
|
|
|
try:
|
|
|
|
rootIds = self.root.ids
|
|
|
|
except Exception as e:
|
|
|
|
rootIds = state.kivyapp.root.ids
|
|
|
|
rootIds.sc11.ids.ml.clear_widgets()
|
|
|
|
rootIds.sc11.loadAddresslist(None, 'All', '')
|
|
|
|
rootIds.scr_mngr.current = 'addressbook'
|
2020-07-14 14:00:01 +02:00
|
|
|
toast('Saved')
|
|
|
|
|
|
|
|
def close_pop(self, instance):
|
|
|
|
"""Pop is Canceled"""
|
|
|
|
self.add_popup.dismiss()
|
|
|
|
toast('Canceled')
|
2019-05-09 14:48:29 +02:00
|
|
|
|
2021-01-28 09:22:04 +01:00
|
|
|
def getDefaultAccData(self, instance):
|
2019-12-12 15:38:07 +01:00
|
|
|
"""Getting Default Account Data"""
|
2019-05-09 14:48:29 +02:00
|
|
|
if BMConfigParser().addresses():
|
2021-01-28 17:33:46 +01:00
|
|
|
first_addr = BMConfigParser().addresses()[0]
|
|
|
|
if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
2021-03-31 17:02:23 +02:00
|
|
|
# img = identiconGeneration.generate(first_addr)
|
2021-01-28 17:33:46 +01:00
|
|
|
# self.createFolder(state.imageDir + '/default_identicon/')
|
|
|
|
# if platform == 'android':
|
|
|
|
# # android_path = os.path.expanduser
|
|
|
|
# # ("~/user/0/org.test.bitapp/files/app/")
|
|
|
|
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
|
|
|
# BMConfigParser().addresses()[0])):
|
|
|
|
# android_path = os.path.join(
|
|
|
|
# os.environ['ANDROID_PRIVATE'] + '/app/')
|
|
|
|
# img.texture.save('{1}/images/kivy/default_identicon/{0}.png'.format(
|
|
|
|
# BMConfigParser().addresses()[0], android_path))
|
|
|
|
# else:
|
|
|
|
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
|
|
|
# BMConfigParser().addresses()[0])):
|
|
|
|
# img.texture.save(state.imageDir + '/default_identicon/{}.png'.format(
|
|
|
|
# BMConfigParser().addresses()[0]))
|
2021-03-31 17:02:23 +02:00
|
|
|
# instance.parent.parent.parent.parent.parent.ids.top_box.children[0].texture = (
|
|
|
|
# img.texture)
|
2021-01-28 17:33:46 +01:00
|
|
|
return first_addr
|
2021-03-31 17:02:23 +02:00
|
|
|
# instance.parent.parent.parent.parent.parent.ids.top_box.children[0].source = (
|
|
|
|
# state.imageDir + '/drawer_logo1.png')
|
2019-05-09 14:48:29 +02:00
|
|
|
return 'Select Address'
|
|
|
|
|
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:
|
2020-04-24 18:46:30 +02:00
|
|
|
if state.in_search_mode and self.root.ids.scr_mngr.current not in [
|
|
|
|
"mailDetail", "create"]:
|
2019-12-12 15:38:07 +01:00
|
|
|
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()
|
2020-04-24 18:46:30 +02:00
|
|
|
if state.in_search_mode 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 = ''
|
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":
|
2021-04-08 14:09:05 +02:00
|
|
|
self.set_common_header()
|
2019-07-17 10:50:27 +02:00
|
|
|
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'
|
2020-04-22 18:58:16 +02:00
|
|
|
elif self.root.ids.scr_mngr.current == 'chroom':
|
|
|
|
if state.association:
|
|
|
|
address_label = self.current_address_label(
|
|
|
|
BMConfigParser().get(
|
|
|
|
state.association, 'label'), state.association)
|
|
|
|
self.root.ids.toolbar.title = address_label
|
|
|
|
self.set_common_header()
|
|
|
|
self.root.ids.scr_mngr.transition = FallOutTransition()
|
|
|
|
self.root.ids.scr_mngr.current = 'chlist'
|
|
|
|
self.root.ids.scr_mngr.transition = SlideTransition()
|
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
|
2020-04-24 18:46:30 +02:00
|
|
|
elif key == 13 and state.searcing_text and not state.in_composer:
|
2019-12-18 17:17:07 +01:00
|
|
|
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()
|
2020-04-22 18:58:16 +02:00
|
|
|
if self.root.ids.scr_mngr.current == 'chroom' and state.association:
|
|
|
|
self.root.ids.scr_mngr.transition = FallOutTransition()
|
|
|
|
address_label = self.current_address_label(
|
|
|
|
BMConfigParser().get(
|
|
|
|
state.association, 'label'), state.association)
|
|
|
|
self.root.ids.toolbar.title = address_label
|
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'\
|
2020-04-22 18:58:16 +02:00
|
|
|
if self.root.ids.scr_mngr.current == 'pay-options' else 'chlist'\
|
|
|
|
if self.root.ids.scr_mngr.current == 'chroom' else 'inbox'
|
|
|
|
if self.root.ids.scr_mngr.current == 'chlist':
|
|
|
|
self.root.ids.scr_mngr.transition = SlideTransition()
|
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')
|
2021-01-28 17:33:46 +01:00
|
|
|
if BMConfigParser().get(addr, 'enabled') != 'true':
|
|
|
|
return ''
|
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':
|
2020-07-14 14:00:01 +02:00
|
|
|
self.root.ids.sc1.ids.inbox_search.ids.search_field.text = ''
|
|
|
|
# try:
|
|
|
|
# self.root.ids.sc1.children[
|
|
|
|
# 3].children[2].ids.search_field.text = ''
|
|
|
|
# except Exception:
|
|
|
|
# self.root.ids.sc1.children[
|
|
|
|
# 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':
|
2020-07-14 14:00:01 +02:00
|
|
|
self.root.ids.sc11.ids.address_search.ids.search_field.text = ''
|
|
|
|
# self.root.ids.sc11.children[
|
|
|
|
# 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':
|
2020-07-14 14:00:01 +02:00
|
|
|
self.root.ids.sc10.ids.search_bar.ids.search_field.text = ''
|
|
|
|
# try:
|
|
|
|
# self.root.ids.sc10.children[
|
|
|
|
# 1].children[2].ids.search_field.text = ''
|
|
|
|
# except Exception:
|
|
|
|
# self.root.ids.sc10.children[
|
|
|
|
# 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:
|
2020-07-14 14:00:01 +02:00
|
|
|
self.root.ids.sc4.ids.sent_search.ids.search_field.text = ''
|
|
|
|
# self.root.ids.sc4.children[
|
|
|
|
# 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"""
|
2021-03-31 17:02:23 +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
|
2021-03-31 17:02:23 +02: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"""
|
2020-04-24 18:46:30 +02:00
|
|
|
if state.association and state.in_search_mode:
|
|
|
|
address_label = self.current_address_label(
|
|
|
|
BMConfigParser().get(
|
|
|
|
state.association, 'label'), state.association)
|
|
|
|
self.root.ids.toolbar.title = address_label
|
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
|
|
|
|
|
2020-06-11 12:15:32 +02:00
|
|
|
if not self.file_manager:
|
|
|
|
self.file_manager = MDFileManager(
|
|
|
|
exit_manager=self.exit_manager,
|
|
|
|
select_path=self.select_path,
|
|
|
|
ext=['.png', '.jpg']
|
|
|
|
)
|
|
|
|
self.file_manager.previous = False
|
|
|
|
self.file_manager.current_path = '/'
|
2020-05-12 13:04:12 +02:00
|
|
|
if platform == 'android':
|
2020-06-11 12:15:32 +02:00
|
|
|
from android.permissions import request_permissions, Permission, check_permission
|
|
|
|
if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \
|
|
|
|
check_permission(Permission.READ_EXTERNAL_STORAGE):
|
|
|
|
self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
|
|
|
|
self.manager_open = True
|
|
|
|
else:
|
|
|
|
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
|
|
|
|
else:
|
|
|
|
self.file_manager.show(os.environ["HOME"])
|
|
|
|
self.manager_open = True
|
2020-02-19 16:46:13 +01:00
|
|
|
|
|
|
|
def select_path(self, path):
|
|
|
|
"""This method is used to save the select image"""
|
2020-06-11 12:15:32 +02:00
|
|
|
try:
|
|
|
|
from PIL import Image as PilImage
|
|
|
|
newImg = PilImage.open(path).resize((300, 300))
|
|
|
|
if platform == 'android':
|
|
|
|
android_path = os.path.join(
|
2021-03-16 10:43:11 +01:00
|
|
|
os.environ['ANDROID_PRIVATE'] + '/app' + '/images' + '/kivy/')
|
|
|
|
if not os.path.exists(android_path + '/default_identicon/'):
|
|
|
|
os.makedirs(android_path + '/default_identicon/')
|
|
|
|
newImg.save('{1}/default_identicon/{0}.png'.format(
|
2020-06-11 12:15:32 +02:00
|
|
|
state.association, android_path))
|
|
|
|
else:
|
|
|
|
if not os.path.exists(state.imageDir + '/default_identicon/'):
|
|
|
|
os.makedirs(state.imageDir + '/default_identicon/')
|
|
|
|
newImg.save(state.imageDir + '/default_identicon/{0}.png'.format(state.association))
|
|
|
|
self.load_selected_Image(state.association)
|
|
|
|
toast('Image changed')
|
|
|
|
except Exception:
|
|
|
|
toast('Exit')
|
2020-02-19 16:46:13 +01:00
|
|
|
self.exit_manager()
|
|
|
|
|
|
|
|
def exit_manager(self, *args):
|
|
|
|
"""Called when the user reaches the root of the directory tree."""
|
|
|
|
self.manager_open = False
|
2020-06-11 12:15:32 +02:00
|
|
|
self.file_manager.close()
|
2020-02-19 16:46:13 +01:00
|
|
|
|
|
|
|
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-06-11 12:15:32 +02:00
|
|
|
top_box_obj.source = state.imageDir + '/default_identicon/{0}.png'.format(curerentAddr)
|
2021-01-28 09:22:04 +01:00
|
|
|
self.root.ids.content_drawer.ids.reset_image.opacity = 1
|
|
|
|
self.root.ids.content_drawer.ids.reset_image.disabled = False
|
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
|
|
|
|
2021-01-28 09:22:04 +01:00
|
|
|
def rest_default_avatar_img(self):
|
|
|
|
"""set default avatar generated image"""
|
2021-03-31 17:02:23 +02:00
|
|
|
# self.set_identicon(state.association)
|
2021-01-28 09:22:04 +01:00
|
|
|
img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
|
|
|
|
try:
|
|
|
|
if os.path.exists(img_path):
|
|
|
|
os.remove(img_path)
|
|
|
|
self.root.ids.content_drawer.ids.reset_image.opacity = 0
|
|
|
|
self.root.ids.content_drawer.ids.reset_image.disabled = True
|
|
|
|
except Exception as e:
|
|
|
|
pass
|
|
|
|
toast('Avatar reset')
|
|
|
|
|
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')
|
|
|
|
|
2020-03-30 20:02:51 +02:00
|
|
|
def reset_login_screen(self):
|
2020-04-17 13:56:05 +02:00
|
|
|
"""This method is used for clearing random screen"""
|
2020-07-14 14:00:01 +02:00
|
|
|
if self.root.ids.sc7.ids.add_random_bx.children:
|
|
|
|
self.root.ids.sc7.ids.add_random_bx.clear_widgets()
|
2020-06-10 13:15:20 +02:00
|
|
|
|
|
|
|
def open_payment_layout(self, sku):
|
2020-07-16 14:23:35 +02:00
|
|
|
"""It basically open up a payment layout for kivy Ui"""
|
2020-07-09 14:02:19 +02:00
|
|
|
pml = PaymentMethodLayout()
|
|
|
|
self.product_id = sku
|
|
|
|
self.custom_sheet = MDCustomBottomSheet(screen=pml)
|
2020-06-10 13:15:20 +02:00
|
|
|
self.custom_sheet.open()
|
|
|
|
|
|
|
|
def initiate_purchase(self, method_name):
|
2020-07-16 14:23:35 +02:00
|
|
|
"""initiate_purchase module"""
|
2020-06-10 13:15:20 +02:00
|
|
|
print("Purchasing {} through {}".format(self.product_id, method_name))
|
|
|
|
|
|
|
|
def _after_scan(self, text):
|
2020-07-09 14:02:19 +02:00
|
|
|
if platform == 'android':
|
|
|
|
text = cast(CharSequence, String(text))
|
|
|
|
show_toast(text, Toast.LENGTH_SHORT)
|
2020-07-24 19:59:49 +02:00
|
|
|
elif self.root.ids.sc23.previous_open_screen == 'composer':
|
2020-06-10 13:15:20 +02:00
|
|
|
self.root.ids.sc3.children[1].ids.txt_input.text = text
|
|
|
|
self.root.ids.scr_mngr.current = 'create'
|
2020-07-24 19:59:49 +02:00
|
|
|
elif self.root.ids.sc23.previous_open_screen:
|
|
|
|
back_screen = self.root.ids.sc23.previous_open_screen
|
|
|
|
self.root.ids.scr_mngr.current = 'inbox' if back_screen == 'scanscreen' else back_screen
|
|
|
|
add_obj = self.root.ids.sc23.pop_up_instance
|
|
|
|
add_obj.content_cls.ids.address.text = text
|
|
|
|
Clock.schedule_once(partial(self.open_popup, add_obj), .5)
|
2019-08-07 10:12:41 +02:00
|
|
|
|
2020-07-24 19:59:49 +02:00
|
|
|
def open_popup(self, instance, dt):
|
|
|
|
"""This method is used for opening popup"""
|
|
|
|
instance.open()
|
2020-07-09 14:02:19 +02:00
|
|
|
|
2020-11-26 15:23:27 +01:00
|
|
|
|
2021-03-31 17:02:23 +02:00
|
|
|
class PaymentMethodLayout(BoxLayout):
|
|
|
|
"""PaymentMethodLayout class for kivy Ui"""
|