resolve merge conflict

This commit is contained in:
cis 2019-08-06 16:05:07 +05:30
commit 4916c94db5
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C

View File

@ -1,39 +1,35 @@
# -*- coding: utf-8 -*- """Coding: utf-8."""
from kivy.app import App from kivy.app import App
from kivy.lang import Builder from kivy.lang import Builder
from kivy.metrics import dp from kivy.metrics import dp
from kivy.properties import ObjectProperty from kivy.properties import ObjectProperty
from kivy.uix.image import Image from kivy.uix.image import Image
from kivy.uix.screenmanager import Screen, NoTransition from kivy.uix.screenmanager import Screen
from kivymd.bottomsheet import MDListBottomSheet, MDGridBottomSheet
from kivymd.button import MDIconButton from kivymd.button import MDIconButton
from kivymd.date_picker import MDDatePicker
from kivymd.dialog import MDDialog from kivymd.dialog import MDDialog
from kivymd.label import MDLabel from kivymd.label import MDLabel
from kivymd.list import ILeftBody, ILeftBodyTouch, IRightBodyTouch, BaseListItem from kivymd.list import ILeftBody, ILeftBodyTouch, IRightBodyTouch
from kivymd.material_resources import DEVICE_TYPE from kivymd.navigationdrawer import (
from kivymd.navigationdrawer import MDNavigationDrawer, NavigationDrawerHeaderBase MDNavigationDrawer,
NavigationDrawerHeaderBase)
from kivymd.selectioncontrols import MDCheckbox from kivymd.selectioncontrols import MDCheckbox
from kivymd.snackbar import Snackbar
from kivymd.theming import ThemeManager from kivymd.theming import ThemeManager
from kivymd.time_picker import MDTimePicker from kivymd.list import (
from kivymd.list import ThreeLineAvatarIconListItem, TwoLineAvatarIconListItem, TwoLineListItem ThreeLineAvatarIconListItem,
TwoLineAvatarIconListItem,
TwoLineListItem)
from kivy.properties import ListProperty, StringProperty, BooleanProperty from kivy.properties import ListProperty, StringProperty, BooleanProperty
from kivy.clock import Clock from kivy.clock import Clock
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
import state import state
import queues import queues
from kivy.uix.popup import Popup from kivy.uix.popup import Popup
from helper_sql import * from helper_sql import sqlQuery, sqlExecute
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.uix.textinput import TextInput from kivy.uix.textinput import TextInput
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout from kivy.uix.floatlayout import FloatLayout
from kivy.properties import NumericProperty, ListProperty, BooleanProperty, ObjectProperty from kivy.properties import NumericProperty
from kivy.uix.recycleview import RecycleView from kivy.uix.recycleview import RecycleView
from kivy.uix.recyclegridlayout import RecycleGridLayout
from kivy.uix.recycleview.views import RecycleDataViewBehavior from kivy.uix.recycleview.views import RecycleDataViewBehavior
from kivy.uix.label import Label from kivy.uix.label import Label
from kivy.uix.recycleboxlayout import RecycleBoxLayout from kivy.uix.recycleboxlayout import RecycleBoxLayout
@ -51,7 +47,10 @@ from kivy.utils import platform
from kivy.uix.spinner import Spinner from kivy.uix.spinner import Spinner
from kivymd.textfields import MDTextField from kivymd.textfields import MDTextField
class Navigatorss(MDNavigationDrawer): class Navigatorss(MDNavigationDrawer):
"""Navigators class contains image, title and logo."""
image_source = StringProperty('images/qidenticon_two.png') image_source = StringProperty('images/qidenticon_two.png')
title = StringProperty('Navigation') title = StringProperty('Navigation')
drawer_logo = StringProperty() drawer_logo = StringProperty()
@ -59,9 +58,11 @@ class Navigatorss(MDNavigationDrawer):
class Inbox(Screen): class Inbox(Screen):
"""Inbox Screen uses screen to show widgets of screens.""" """Inbox Screen uses screen to show widgets of screens."""
data = ListProperty() data = ListProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method Parsing the address."""
super(Inbox, self).__init__(*args, **kwargs) super(Inbox, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -90,11 +91,27 @@ class Inbox(Screen):
if queryreturn: if queryreturn:
for mail in queryreturn: for mail in queryreturn:
third_text = mail[3].replace('\n', ' ') third_text = mail[3].replace('\n', ' ')
data.append({'text': mail[4].strip(), 'secondary_text': mail[5][:10] + '...........' if len(mail[3]) > 10 else mail[3] + '\n' + " " + (third_text[:25] + '...!') if len(third_text) > 25 else third_text, 'receivedTime': mail[6] }) data.append({
'text': mail[4].strip(),
'secondary_text': mail[5][:10] + '...........' if len(
mail[3]) > 10 else mail[3] + '\n' + " " + (
third_text[:25] + '...!') if len(
third_text) > 25 else third_text,
'receivedTime': mail[6]})
for item in data: for item in data:
meny = ThreeLineAvatarIconListItem(text=item['text'], secondary_text=item['secondary_text'], theme_text_color= 'Custom', text_color=NavigateApp().theme_cls.primary_color) meny = ThreeLineAvatarIconListItem(
meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item['secondary_text'][0].upper() if (item['secondary_text'][0].upper() >= 'A' and item['secondary_text'][0].upper() <= 'Z') else '!'))) text=item['text'],
meny.bind(on_press = partial(self.inbox_detail, item['receivedTime'])) secondary_text=item['secondary_text'],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
item['secondary_text'][0].upper() if (
item['secondary_text'][0].upper() >= 'A' and item[
'secondary_text'][0].upper() <= 'Z')
else '!')))
meny.bind(on_press=partial(
self.inbox_detail, item['receivedTime']))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
if platform == 'android': if platform == 'android':
carousel.height = 150 carousel.height = 150
@ -107,17 +124,20 @@ class Inbox(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1, 0, 0, 1) del_btn.background_color = (1, 0, 0, 1)
del_btn.bind(on_press=partial(self.delete, item['receivedTime'])) del_btn.bind(on_press=partial(
self.delete, item['receivedTime']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
ach_btn = Button(text='Achieve') ach_btn = Button(text='Achieve')
ach_btn.background_color = (0,1,0,1) ach_btn.background_color = (0, 1, 0, 1)
ach_btn.bind(on_press=partial(self.archive, item['receivedTime'])) ach_btn.bind(on_press=partial(
self.archive, item['receivedTime']))
carousel.add_widget(ach_btn) carousel.add_widget(ach_btn)
carousel.index = 1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!", text="yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center',
@ -127,7 +147,7 @@ class Inbox(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def inbox_detail(self, receivedTime, *args): def inbox_detail(self, receivedTime, *args):
"""Load inbox page details""" """Load inbox page details."""
state.detailPageType = 'inbox' state.detailPageType = 'inbox'
state.sentMailTime = receivedTime state.sentMailTime = receivedTime
if self.manager: if self.manager:
@ -141,25 +161,31 @@ class Inbox(Screen):
src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete inbox mail from inbox listing""" """Delete inbox mail from inbox listing."""
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(data_index)) sqlExecute(
msg_count_objs = self.parent.parent.parent.parent.children[2].children[0].ids "UPDATE inbox SET folder = 'trash' WHERE received = {};".format(
data_index))
msg_count_objs = \
self.parent.parent.parent.parent.children[2].children[0].ids
if int(state.inbox_count) > 0: if int(state.inbox_count) > 0:
msg_count_objs.inbox_cnt.badge_text = str(int(state.inbox_count) - 1) msg_count_objs.inbox_cnt.badge_text = str(
msg_count_objs.trash_cnt.badge_text = str(int(state.trash_count) + 1) int(state.inbox_count) - 1)
msg_count_objs.trash_cnt.badge_text = str(
int(state.trash_count) + 1)
state.inbox_count = str(int(state.inbox_count) - 1) state.inbox_count = str(int(state.inbox_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""Archive inbox mail from inbox listing""" """Archive inbox mail from inbox listing."""
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(data_index)) sqlExecute("UPDATE inbox SET folder = 'trash' WHERE \
received = {};".format(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
def update_trash(self): def update_trash(self):
"""Update trash screen mails which is deleted from inbox""" """Update trash screen mails which is deleted from inbox."""
try: try:
self.parent.screens[4].clear_widgets() self.parent.screens[4].clear_widgets()
self.parent.screens[4].add_widget(Trash()) self.parent.screens[4].add_widget(Trash())
@ -168,11 +194,10 @@ class Inbox(Screen):
self.parent.parent.screens[4].add_widget(Trash()) self.parent.parent.screens[4].add_widget(Trash())
def refresh_callback(self, *args): def refresh_callback(self, *args):
"""A method that updates the state of your application """A method that updates the state of your application."""
while the spinner remains on the screen.""" """While the spinner remains on the screen."""
def refresh_callback(interval): def refresh_callback(interval):
"""This methods is used for loading the inbox screen data""" """Method used for loading the inbox screen data."""
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
self.remove_widget(self.children[1]) self.remove_widget(self.children[1])
try: try:
@ -188,7 +213,9 @@ class Inbox(Screen):
class MyAddress(Screen): class MyAddress(Screen):
"""MyAddress Screen uses screen to show widgets of screens.""" """MyAddress Screen uses screen to show widgets of screens."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Clock Schdule for method inbox accounts."""
super(MyAddress, self).__init__(*args, **kwargs) super(MyAddress, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
@ -197,14 +224,27 @@ class MyAddress(Screen):
if BMConfigParser().addresses() or state.kivyapp.variable_1: if BMConfigParser().addresses() or state.kivyapp.variable_1:
data = [] data = []
for address in state.kivyapp.variable_1: for address in state.kivyapp.variable_1:
data.append({'text': BMConfigParser().get(address, 'label'), 'secondary_text': address}) data.append({
'text': BMConfigParser().get(address, 'label'),
'secondary_text': address})
for item in data: for item in data:
meny = TwoLineAvatarIconListItem(text=item['text'], secondary_text=item['secondary_text'], theme_text_color= 'Custom',text_color=NavigateApp().theme_cls.primary_color) meny = TwoLineAvatarIconListItem(
meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item['text'][0].upper() if (item['text'][0].upper() >= 'A' and item['text'][0].upper() <= 'Z') else '!'))) text=item['text'],
meny.bind(on_press=partial(self.myadd_detail, item['secondary_text'], item['text'])) secondary_text=item['secondary_text'],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
item['text'][0].upper() if (
item['text'][0].upper() >= 'A' and item['text'][
0].upper() <= 'Z')
else '!')))
meny.bind(on_press=partial(
self.myadd_detail, item['secondary_text'], item['text']))
self.ids.ml.add_widget(meny) self.ids.ml.add_widget(meny)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="yet no address is created by user!!!!!!!!!!!!!", text="yet no address is created by user!!!!!!!!!!!!!",
halign='center', halign='center',
@ -218,16 +258,16 @@ class MyAddress(Screen):
pass pass
def myadd_detail(self, fromaddress, label, *args): def myadd_detail(self, fromaddress, label, *args):
"""Myaddress Details."""
p = MyaddDetailPopup() p = MyaddDetailPopup()
p.open() p.open()
p.set_address(fromaddress, label) p.set_address(fromaddress, label)
def refresh_callback(self, *args): def refresh_callback(self, *args):
"""A method that updates the state of your application """A method that updates the state of your application."""
while the spinner remains on the screen.""" """While the spinner remains on the screen."""
def refresh_callback(interval): def refresh_callback(interval):
"""This methods is used for loading the myaddress screen data""" """Method used for loading the myaddress screen data."""
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
self.remove_widget(self.children[1]) self.remove_widget(self.children[1])
try: try:
@ -243,7 +283,9 @@ class MyAddress(Screen):
class AddressBook(Screen): class AddressBook(Screen):
"""AddressBook Screen uses screen to show widgets of screens.""" """AddressBook Screen uses screen to show widgets of screens."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Getting AddressBook Details."""
super(AddressBook, self).__init__(*args, **kwargs) super(AddressBook, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
@ -252,9 +294,18 @@ class AddressBook(Screen):
data = sqlQuery("SELECT label, address from addressbook") data = sqlQuery("SELECT label, address from addressbook")
if data: if data:
for item in data: for item in data:
meny = TwoLineAvatarIconListItem(text=item[0], secondary_text=item[1], theme_text_color='Custom',text_color=NavigateApp().theme_cls.primary_color) meny = TwoLineAvatarIconListItem(
meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item[0][0].upper() if (item[0][0].upper() >= 'A' and item[0][0].upper() <= 'Z') else '!'))) text=item[0],
meny.bind(on_press = partial(self.addBook_detail, item[1], item[0])) secondary_text=item[1],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
item[0][0].upper() if (
item[0][0].upper() >= 'A' and item[0][
0].upper() <= 'Z') else '!')))
meny.bind(on_press=partial(
self.addBook_detail, item[1], item[0]))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
if platform == 'android': if platform == 'android':
carousel.height = 140 carousel.height = 140
@ -270,7 +321,7 @@ class AddressBook(Screen):
del_btn.bind(on_press=partial(self.delete_address, item[1])) del_btn.bind(on_press=partial(self.delete_address, item[1]))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
carousel.index=1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(font_style='Body1',
@ -283,59 +334,70 @@ class AddressBook(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def refreshs(self, *args): def refreshs(self, *args):
"""Refresh the Widget."""
state.navinstance.ids.sc11.clear_widgets() state.navinstance.ids.sc11.clear_widgets()
state.navinstance.ids.sc11.add_widget(AddressBook()) state.navinstance.ids.sc11.add_widget(AddressBook())
def addBook_detail(self, address, label, *args): def addBook_detail(self, address, label, *args):
"""Addressbook Details."""
p = AddbookDetailPopup() p = AddbookDetailPopup()
p.open() p.open()
p.set_addbook_data(address, label) p.set_addbook_data(address, label)
def delete_address(self, address, instance, *args): def delete_address(self, address, instance, *args):
"""Delete inbox mail from inbox listing""" """Delete inbox mail from inbox listing."""
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
sqlExecute("DELETE FROM addressbook WHERE address = '{}';".format(address)) sqlExecute(
"DELETE FROM addressbook WHERE address = '{}';".format(address))
class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior, class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior,
RecycleBoxLayout): RecycleBoxLayout):
''' Adds selection and focus behaviour to the view. ''' """Adds selection and focus behaviour to the view."""
pass pass
class SelectableLabel(RecycleDataViewBehavior, Label): class SelectableLabel(RecycleDataViewBehavior, Label):
''' Add selection support to the Label ''' """Add selection support to the Label."""
index = None index = None
selected = BooleanProperty(False) selected = BooleanProperty(False)
selectable = BooleanProperty(True) selectable = BooleanProperty(True)
def refresh_view_attrs(self, rv, index, data): def refresh_view_attrs(self, rv, index, data):
''' Catch and handle the view changes ''' """Catch and handle the view changes."""
self.index = index self.index = index
return super(SelectableLabel, self).refresh_view_attrs( return super(SelectableLabel, self).refresh_view_attrs(
rv, index, data) rv, index, data)
def on_touch_down(self, touch): def on_touch_down(self, touch):
''' Add selection on touch down ''' """Add selection on touch down."""
if super(SelectableLabel, self).on_touch_down(touch): if super(SelectableLabel, self).on_touch_down(touch):
return True return True
if self.collide_point(*touch.pos) and self.selectable: if self.collide_point(*touch.pos) and self.selectable:
return self.parent.select_with_touch(self.index, touch) return self.parent.select_with_touch(self.index, touch)
def apply_selection(self, rv, index, is_selected): def apply_selection(self, rv, index, is_selected):
''' Respond to the selection of items in the view. ''' """Respond to the selection of items in the view."""
self.selected = is_selected self.selected = is_selected
if is_selected: if is_selected:
print("selection changed to {0}".format(rv.data[index])) print("selection changed to {0}".format(rv.data[index]))
rv.parent.txt_input.text = rv.parent.txt_input.text.replace(rv.parent.txt_input.text, rv.data[index]['text']) rv.parent.txt_input.text = rv.parent.txt_input.text.replace(
rv.parent.txt_input.text, rv.data[index]['text'])
class RV(RecycleView): class RV(RecycleView):
"""Recycling View."""
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Recycling Method."""
super(RV, self).__init__(**kwargs) super(RV, self).__init__(**kwargs)
class DropDownWidget(BoxLayout): class DropDownWidget(BoxLayout):
"""Adding Dropdown Widget."""
txt_input = ObjectProperty() txt_input = ObjectProperty()
rv = ObjectProperty() rv = ObjectProperty()
@ -351,14 +413,15 @@ class DropDownWidget(BoxLayout):
if sendMessageToPeople: if sendMessageToPeople:
if toAddress != '' and subject and message: if toAddress != '' and subject and message:
from addresses import decodeAddress from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = decodeAddress( status, addressVersionNumber, streamNumber, ripe = \
toAddress) decodeAddress(toAddress)
if status == 'success': if status == 'success':
from addresses import * from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' statusIconColor = 'red'
if addressVersionNumber > 4 or addressVersionNumber <= 1: if addressVersionNumber > 4 or addressVersionNumber <= 1:
print("addressVersionNumber > 4 or addressVersionNumber <= 1") print("addressVersionNumber > 4 \
or addressVersionNumber <= 1")
if streamNumber > 1 or streamNumber == 0: if streamNumber > 1 or streamNumber == 0:
print("streamNumber > 1 or streamNumber == 0") print("streamNumber > 1 or streamNumber == 0")
if statusIconColor == 'red': if statusIconColor == 'red':
@ -369,7 +432,8 @@ class DropDownWidget(BoxLayout):
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () t = ()
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'', '',
toAddress, toAddress,
ripe, ripe,
@ -386,9 +450,8 @@ class DropDownWidget(BoxLayout):
encoding, encoding,
BMConfigParser().getint('bitmessagesettings', 'ttl')) BMConfigParser().getint('bitmessagesettings', 'ttl'))
state.check_sent_acc = fromAddress state.check_sent_acc = fromAddress
state.msg_counter_objs = self.parent.parent.parent.parent.parent.parent.children[0].children[2].children[0].ids state.msg_counter_objs = self.parent.parent.parent.parent\
# state.msg_counter_objs.send_cnt.badge_text = str(int(state.sent_count) + 1) .parent.parent.children[0].children[2].children[0].ids
# state.sent_count = str(int(state.sent_count) + 1)
self.parent.parent.screens[3].clear_widgets() self.parent.parent.screens[3].clear_widgets()
self.parent.parent.screens[3].add_widget(Sent()) self.parent.parent.screens[3].add_widget(Sent())
toLabel = '' toLabel = ''
@ -401,8 +464,10 @@ class DropDownWidget(BoxLayout):
self.parent.parent.current = 'sent' self.parent.parent.current = 'sent'
self.ids.btn.text = 'select' self.ids.btn.text = 'select'
self.ids.ti.text = '' self.ids.ti.text = ''
self.parent.parent.parent.parent.parent.ids.serch_btn.opacity = 1 self.parent.parent.parent.parent.parent\
self.parent.parent.parent.parent.parent.ids.serch_btn.disabled = False .ids.serch_btn.opacity = 1
self.parent.parent.parent.parent.parent\
.ids.serch_btn.disabled = False
return None return None
else: else:
@ -414,69 +479,96 @@ class DropDownWidget(BoxLayout):
self.address_error_message(msg) self.address_error_message(msg)
def address_error_message(self, msg): def address_error_message(self, msg):
"""Show Error Message."""
self.box = FloatLayout() self.box = FloatLayout()
self.lab = (Label(text=msg, font_size=25, self.lab = (Label(
size_hint=(None, None), pos_hint={'x': .25, 'y': .6})) text=msg,
font_size=25,
size_hint=(None, None),
pos_hint={'x': .25, 'y': .6}))
self.box.add_widget(self.lab) self.box.add_widget(self.lab)
self.but = (Button(text="dismiss", size_hint=(None, None), self.but = (Button(
width=200, height=50, pos_hint={'x': .3, 'y': 0})) text="dismiss",
size_hint=(None, None),
width=200,
height=50,
pos_hint={'x': .3, 'y': 0}))
self.box.add_widget(self.but) self.box.add_widget(self.but)
self.main_pop = Popup(title="Error", content=self.box, self.main_pop = Popup(
size_hint=(None, None), size=(550, 400), auto_dismiss=False, title_size=30) title="Error",
content=self.box,
size_hint=(None, None),
size=(550, 400),
auto_dismiss=False,
title_size=30)
self.but.bind(on_press=self.main_pop.dismiss) self.but.bind(on_press=self.main_pop.dismiss)
# self.main_pop.background = './images/popup.jpeg'
self.main_pop.open() self.main_pop.open()
class MyTextInput(TextInput): class MyTextInput(TextInput):
"""Takes the text input in the field."""
txt_input = ObjectProperty() txt_input = ObjectProperty()
flt_list = ObjectProperty() flt_list = ObjectProperty()
word_list = ListProperty() word_list = ListProperty()
# this is the variable storing the number to which the look-up will start
starting_no = NumericProperty(3) starting_no = NumericProperty(3)
suggestion_text = '' suggestion_text = ''
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Getting Text Input."""
super(MyTextInput, self).__init__(**kwargs) super(MyTextInput, self).__init__(**kwargs)
def on_text(self, instance, value): def on_text(self, instance, value):
# find all the occurrence of the word """Find all the occurrence of the word."""
self.parent.parent.parent.parent.ids.rv.data = [] self.parent.parent.parent.parent.ids.rv.data = []
matches = [self.word_list[i] for i in range(len(self.word_list)) if self.word_list[i][:self.starting_no] == value[:self.starting_no]] matches = [self.word_list[i] for i in range(
# display the data in the recycleview len(self.word_list)) if self.word_list[
i][:self.starting_no] == value[:self.starting_no]]
display_data = [] display_data = []
for i in matches: for i in matches:
display_data.append({'text': i}) display_data.append({'text': i})
self.parent.parent.parent.parent.ids.rv.data = display_data self.parent.parent.parent.parent.ids.rv.data = display_data
# ensure the size is okay
if len(matches) <= 10: if len(matches) <= 10:
self.parent.height = (250 + (len(matches) * 20)) self.parent.height = (250 + (len(matches) * 20))
else: else:
self.parent.height = 400 self.parent.height = 400
def keyboard_on_key_down(self, window, keycode, text, modifiers): def keyboard_on_key_down(self, window, keycode, text, modifiers):
"""Key Down."""
if self.suggestion_text and keycode[1] == 'tab': if self.suggestion_text and keycode[1] == 'tab':
self.insert_text(self.suggestion_text + ' ') self.insert_text(self.suggestion_text + ' ')
return True return True
return super(MyTextInput, self).keyboard_on_key_down(window, keycode, text, modifiers) return super(MyTextInput, self).keyboard_on_key_down(
window, keycode, text, modifiers)
class Payment(Screen): class Payment(Screen):
"""Payment Method."""
pass pass
class Login(Screen): class Login(Screen):
"""Login Screeen."""
pass pass
class NetworkStat(Screen): class NetworkStat(Screen):
text_variable_1 = StringProperty('{0}::{1}'.format('Total Connections', '0')) """Method used to show network stat."""
text_variable_2 = StringProperty('Processed {0} per-to-per messages'.format('0'))
text_variable_3 = StringProperty('Processed {0} brodcast messages'.format('0')) 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'))
text_variable_4 = StringProperty('Processed {0} public keys'.format('0')) text_variable_4 = StringProperty('Processed {0} public keys'.format('0'))
text_variable_5 = StringProperty('Processed {0} object to be synced'.format('0')) text_variable_5 = StringProperty(
'Processed {0} object to be synced'.format('0'))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Init method for network stat."""
super(NetworkStat, self).__init__(*args, **kwargs) super(NetworkStat, self).__init__(*args, **kwargs)
Clock.schedule_interval(self.init_ui, 1) Clock.schedule_interval(self.init_ui, 1)
@ -485,25 +577,33 @@ class NetworkStat(Screen):
import network.stats import network.stats
import shared import shared
from network import objectracker from network import objectracker
self.text_variable_1 = '{0} :: {1}'.format('Total Connections', str(len(network.stats.connectedHostsList()))) self.text_variable_1 = '{0} :: {1}'.format(
self.text_variable_2 = 'Processed {0} per-to-per messages'.format(str(shared.numberOfMessagesProcessed)) 'Total Connections', str(len(network.stats.connectedHostsList())))
self.text_variable_3 = 'Processed {0} brodcast messages'.format(str(shared.numberOfBroadcastsProcessed)) self.text_variable_2 = 'Processed {0} per-to-per messages'.format(
self.text_variable_4 = 'Processed {0} public keys'.format(str(shared.numberOfPubkeysProcessed)) str(shared.numberOfMessagesProcessed))
self.text_variable_5 = '{0} object to be synced'.format(len(objectracker.missingObjects)) 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))
class ContentNavigationDrawer(Navigatorss): class ContentNavigationDrawer(Navigatorss):
"""Navigate Content Drawer."""
pass pass
class Random(Screen): class Random(Screen):
"""Generates Random Address."""
is_active = BooleanProperty(False) is_active = BooleanProperty(False)
checked = StringProperty("") checked = StringProperty("")
# self.manager.parent.ids.create.children[0].source = 'images/plus-4-xxl.png'
def generateaddress(self): def generateaddress(self):
"""Method for Address Generator."""
import queues import queues
# queues.apiAddressGeneratorReturnQueue.queue.clear()
streamNumberForAddress = 1 streamNumberForAddress = 1
label = self.ids.label.text label = self.ids.label.text
eighteenByteRipe = False eighteenByteRipe = False
@ -517,26 +617,27 @@ class Random(Screen):
nonceTrialsPerByte, nonceTrialsPerByte,
payloadLengthExtraBytes) payloadLengthExtraBytes)
) )
# self.manager.current = 'add_sucess'
self.manager.current = 'myaddress' self.manager.current = 'myaddress'
self.ids.label.text = '' self.ids.label.text = ''
self.parent.parent.parent.parent.ids.toolbar.opacity = 1 self.parent.parent.parent.parent.ids.toolbar.opacity = 1
self.parent.parent.parent.parent.ids.toolbar.disabled = False self.parent.parent.parent.parent.ids.toolbar.disabled = False
# state.myAddressObj = self.parent.parent.parent.parent.ids.sc10
self.parent.parent.parent.parent.ids.sc10.clear_widgets() self.parent.parent.parent.parent.ids.sc10.clear_widgets()
self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress()) self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress())
class AddressSuccessful(Screen): class AddressSuccessful(Screen):
"""Getting Address Detail."""
pass pass
class Sent(Screen): class Sent(Screen):
"""Sent Screen uses screen to show widgets of screens.""" """Sent Screen uses screen to show widgets of screens."""
data = ListProperty() data = ListProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Association with the screen."""
super(Sent, self).__init__(*args, **kwargs) super(Sent, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -561,7 +662,8 @@ class Sent(Screen):
xAddress = 'fromaddress' xAddress = 'fromaddress'
queryreturn = kivy_helper_search.search_sql( queryreturn = kivy_helper_search.search_sql(
xAddress, account, "sent", where, what, False) xAddress, account, "sent", where, what, False)
if state.msg_counter_objs and state.association == state.check_sent_acc: if state.msg_counter_objs and state.association == \
state.check_sent_acc:
state.msg_counter_objs.send_cnt.badge_text = str(len(queryreturn)) state.msg_counter_objs.send_cnt.badge_text = str(len(queryreturn))
state.sent_count = str(int(state.sent_count) + 1) state.sent_count = str(int(state.sent_count) + 1)
state.check_sent_acc = None state.check_sent_acc = None
@ -569,11 +671,27 @@ class Sent(Screen):
if queryreturn: if queryreturn:
for mail in queryreturn: for mail in queryreturn:
third_text = mail[3].replace('\n', ' ') third_text = mail[3].replace('\n', ' ')
self.data.append({'text': mail[1].strip(), 'secondary_text': mail[2][:10] + '...........' if len(mail[2]) > 10 else mail[2] + '\n' + " " + (third_text[:25] + '...!') if len(third_text) > 25 else third_text, 'lastactiontime': mail[6]}) self.data.append({
'text': mail[1].strip(),
'secondary_text': mail[2][:10] + '...........' if len(
mail[2]) > 10 else mail[2] + '\n' + " " + (
third_text[:25] + '...!') if len(
third_text) > 25 else third_text,
'lastactiontime': mail[6]})
for item in self.data: for item in self.data:
meny = ThreeLineAvatarIconListItem(text=item['text'], secondary_text=item['secondary_text'], theme_text_color= 'Custom', text_color=NavigateApp().theme_cls.primary_color) meny = ThreeLineAvatarIconListItem(
meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item['secondary_text'][0].upper() if (item['secondary_text'][0].upper() >= 'A' and item['secondary_text'][0].upper() <= 'Z') else '!'))) text=item['text'],
meny.bind(on_press = partial(self.sent_detail, item['lastactiontime'])) secondary_text=item['secondary_text'],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
item['secondary_text'][0].upper() if (
item['secondary_text'][0].upper() >= 'A' and item[
'secondary_text'][0].upper() <= 'Z')
else '!')))
meny.bind(on_press=partial(
self.sent_detail, item['lastactiontime']))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
if platform == 'android': if platform == 'android':
carousel.height = 150 carousel.height = 150
@ -586,17 +704,20 @@ class Sent(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1.0, 0.0, 0.0, 1.0) del_btn.background_color = (1.0, 0.0, 0.0, 1.0)
del_btn.bind(on_press=partial(self.delete, item['lastactiontime'])) del_btn.bind(on_press=partial(
self.delete, item['lastactiontime']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
ach_btn = Button(text='Achieve') ach_btn = Button(text='Achieve')
ach_btn.background_color = (0,1,0,1) ach_btn.background_color = (0, 1, 0, 1)
ach_btn.bind(on_press=partial(self.archive, item['lastactiontime'])) ach_btn.bind(on_press=partial(
self.archive, item['lastactiontime']))
carousel.add_widget(ach_btn) carousel.add_widget(ach_btn)
carousel.index=1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!", text="yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center',
@ -606,7 +727,7 @@ class Sent(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def sent_detail(self, lastsenttime, *args): def sent_detail(self, lastsenttime, *args):
"""Load sent mail details""" """Load sent mail details."""
state.detailPageType = 'sent' state.detailPageType = 'sent'
state.sentMailTime = lastsenttime state.sentMailTime = lastsenttime
if self.manager: if self.manager:
@ -619,29 +740,36 @@ class Sent(Screen):
src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""delete sent mail from sent mail listing""" """Delete sent mail from sent mail listing."""
try: try:
msg_count_objs = self.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = self.parent.parent.parent.parent.children[
2].children[0].ids
except Exception as e: except Exception as e:
msg_count_objs = self.parent.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = self.parent.parent.parent.parent.parent.children[
2].children[0].ids
if int(state.sent_count) > 0: if int(state.sent_count) > 0:
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.badge_text = str(
msg_count_objs.trash_cnt.badge_text = str(int(state.trash_count) + 1) int(state.sent_count) - 1)
msg_count_objs.trash_cnt.badge_text = str(
int(state.trash_count) + 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
sqlExecute(
sqlExecute("UPDATE sent SET folder = 'trash' WHERE lastactiontime = {};".format(data_index)) "UPDATE sent SET folder = 'trash' \
WHERE lastactiontime = {};".format(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""archive sent mail from sent mail listing""" """Archive sent mail from sent mail listing."""
sqlExecute("UPDATE sent SET folder = 'trash' WHERE lastactiontime = {};".format(data_index)) sqlExecute(
"UPDATE sent SET folder = 'trash' \
WHERE lastactiontime = {};".format(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
def update_trash(self): def update_trash(self):
"""Update trash screen mails which is deleted from inbox""" """Update trash screen mails which is deleted from inbox."""
try: try:
self.parent.screens[4].clear_widgets() self.parent.screens[4].clear_widgets()
self.parent.screens[4].add_widget(Trash()) self.parent.screens[4].add_widget(Trash())
@ -652,7 +780,9 @@ class Sent(Screen):
class Trash(Screen): class Trash(Screen):
"""Trash Screen uses screen to show widgets of screens.""" """Trash Screen uses screen to show widgets of screens."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Trash method, delete sent message and add in Trash."""
super(Trash, self).__init__(*args, **kwargs) super(Trash, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
@ -662,38 +792,58 @@ class Trash(Screen):
if BMConfigParser().addresses(): if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0] state.association = BMConfigParser().addresses()[0]
inbox = sqlQuery("SELECT toaddress, fromaddress, subject, message from inbox WHERE folder = 'trash' and fromaddress = '{}';".format(state.association)) inbox = sqlQuery(
sent = sqlQuery("SELECT toaddress, fromaddress, subject, message from sent WHERE folder = 'trash' and fromaddress = '{}';".format(state.association)) "SELECT toaddress, fromaddress, subject, message from inbox \
WHERE folder = 'trash' and fromaddress = '{}';".format(
state.association))
sent = sqlQuery(
"SELECT toaddress, fromaddress, subject, message from sent \
WHERE folder = 'trash' and fromaddress = '{}';".format(
state.association))
trash_data = inbox + sent trash_data = inbox + sent
for item in trash_data: for item in trash_data:
meny = ThreeLineAvatarIconListItem(text=item[1], secondary_text=item[2], theme_text_color= 'Custom',text_color=NavigateApp().theme_cls.primary_color) meny = ThreeLineAvatarIconListItem(
meny.add_widget(AvatarSampleWidget(source='./images/text_images/{}.png'.format(item[2][0].upper() if (item[2][0].upper() >= 'A' and item[2][0].upper() <= 'Z') else '!'))) text=item[1],
secondary_text=item[2],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
item[2][0].upper() if (item[2][0].upper() >= 'A' and item[
2][0].upper() <= 'Z') else '!')))
self.ids.ml.add_widget(meny) self.ids.ml.add_widget(meny)
class Page(Screen): class Page(Screen):
"""Page Screen show widgets of page."""
pass pass
class Create(Screen): class Create(Screen):
"""Creates the screen widgets."""
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Getting Labels and address from addressbook."""
super(Create, self).__init__(**kwargs) super(Create, self).__init__(**kwargs)
widget_1 = DropDownWidget() widget_1 = DropDownWidget()
from helper_sql import * widget_1.ids.txt_input.word_list = [
widget_1.ids.txt_input.word_list = [addr[1] for addr in sqlQuery("SELECT label, address from addressbook")] addr[1] for addr in sqlQuery(
"SELECT label, address from addressbook")]
widget_1.ids.txt_input.starting_no = 2 widget_1.ids.txt_input.starting_no = 2
self.add_widget(widget_1) self.add_widget(widget_1)
class AddressSuccessful(Screen):
pass
class Setting(Screen): class Setting(Screen):
"""Setting the Screen components."""
pass pass
class NavigateApp(App): class NavigateApp(App):
"""Navigation Layout of class."""
theme_cls = ThemeManager() theme_cls = ThemeManager()
previous_date = ObjectProperty() previous_date = ObjectProperty()
obj_1 = ObjectProperty() obj_1 = ObjectProperty()
@ -721,6 +871,7 @@ class NavigateApp(App):
] ]
def build(self): def build(self):
"""Method builds the widget."""
import os import os
main_widget = Builder.load_file( main_widget = Builder.load_file(
os.path.join(os.path.dirname(__file__), 'main.kv')) os.path.join(os.path.dirname(__file__), 'main.kv'))
@ -733,10 +884,12 @@ class NavigateApp(App):
return main_widget return main_widget
def run(self): def run(self):
"""Running the widgets."""
kivyuisignaler.release() kivyuisignaler.release()
super(NavigateApp, self).run() super(NavigateApp, self).run()
def show_address_success(self): def show_address_success(self):
"""Showing the succesfull address."""
content = MDLabel(font_style='Body1', content = MDLabel(font_style='Body1',
theme_text_color='Secondary', theme_text_color='Secondary',
text="Successfully Saved your contact address. " text="Successfully Saved your contact address. "
@ -750,19 +903,21 @@ class NavigateApp(App):
def showmeaddresses(name="text"): def showmeaddresses(name="text"):
"""Show the addresses in spinner to make as dropdown.""" """Show the addresses in spinner to make as dropdown."""
if name == "text": if name == "text":
if bmconfigparserigParser().addresses(): if BMConfigParser().addresses():
return BMConfigParser().addresses()[0][:16] + '..' return BMConfigParser().addresses()[0][:16] + '..'
else: else:
return "textdemo" return "textdemo"
elif name == "values": elif name == "values":
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return [address[:16] + '..' for address in BMConfigParser().addresses()] return [address[:16] + '..'
for address in BMConfigParser().addresses()]
else: else:
return "valuesdemo" return "valuesdemo"
def getCurrentAccountData(self, text): def getCurrentAccountData(self, text):
"""Get Current Address Account Data.""" """Get Current Address Account Data."""
address_label = self.current_address_label(BMConfigParser().get(text, 'label')) address_label = self.current_address_label(
BMConfigParser().get(text, 'label'))
self.root_window.children[1].ids.toolbar.title = address_label self.root_window.children[1].ids.toolbar.title = address_label
state.association = text state.association = text
self.root.ids.sc1.clear_widgets() self.root.ids.sc1.clear_widgets()
@ -775,11 +930,24 @@ class NavigateApp(App):
self.root.ids.sc16.add_widget(Draft()) self.root.ids.sc16.add_widget(Draft())
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
msg_counter_objs = self.root_window.children[1].children[2].children[0].ids msg_counter_objs = \
state.sent_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'sent' ;".format(state.association))[0][0]) self.root_window.children[1].children[2].children[0].ids
state.inbox_count = str(sqlQuery("SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and folder = 'inbox' ;".format(state.association))[0][0]) state.sent_count = str(
state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and folder = 'trash' )+(SELECT count(*) FROM inbox where fromaddress = '{0}' and folder = 'trash') AS SumCount".format(state.association))[0][0]) sqlQuery(
state.draft_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and folder = 'draft' ;".format(state.association))[0][0]) "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
folder = 'sent' ;".format(state.association))[0][0])
state.inbox_count = str(
sqlQuery(
"SELECT COUNT(*) FROM inbox WHERE fromaddress = '{}' and \
folder = 'inbox' ;".format(state.association))[0][0])
state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \
where fromaddress = '{0}' and folder = 'trash' ) \
+(SELECT count(*) FROM inbox where fromaddress = '{0}' and \
folder = 'trash') AS SumCount".format(state.association))[0][0])
state.draft_count = str(
sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \
folder = 'draft' ;".format(state.association))[0][0])
if msg_counter_objs: if msg_counter_objs:
msg_counter_objs.send_cnt.badge_text = state.sent_count msg_counter_objs.send_cnt.badge_text = state.sent_count
@ -787,9 +955,8 @@ class NavigateApp(App):
msg_counter_objs.trash_cnt.badge_text = state.trash_count msg_counter_objs.trash_cnt.badge_text = state.trash_count
msg_counter_objs.draft_cnt.badge_text = state.draft_count msg_counter_objs.draft_cnt.badge_text = state.draft_count
def getInboxMessageDetail(self, instance): def getInboxMessageDetail(self, instance):
"""It will get message detail after make selected message description.""" """Getting message detail after selected message description."""
try: try:
self.root.ids._mngr.current = 'page' self.root.ids._mngr.current = 'page'
except AttributeError: except AttributeError:
@ -805,30 +972,35 @@ class NavigateApp(App):
return "Bitmessage Login" return "Bitmessage Login"
def addingtoaddressbook(self): def addingtoaddressbook(self):
"""Adding to address Book."""
p = GrashofPopup() p = GrashofPopup()
p.open() p.open()
def getDefaultAccData(self): def getDefaultAccData(self):
"""Getting Default Account Data."""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return BMConfigParser().addresses()[0] return BMConfigParser().addresses()[0]
return 'Select Address' return 'Select Address'
def addressexist(self): def addressexist(self):
"""Checking address existence."""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return True return True
return False return False
def on_key(self, window, key, *args): def on_key(self, window, key, *args):
"""This method is used for going on previous screen""" """Method is used for going on previous screen."""
if key == 27: # the esc key if key == 27:
if self.root.ids.scr_mngr.current == "mailDetail": if self.root.ids.scr_mngr.current == "mailDetail":
self.root.ids.scr_mngr.current = 'sent' if state.detailPageType == 'sent' else 'inbox' self.root.ids.scr_mngr.current = \
'sent' if state.detailPageType == 'sent' else 'inbox'
show_search_btn(self) show_search_btn(self)
# this is for direction of the screen comesup
elif self.root.ids.scr_mngr.current == "create": elif self.root.ids.scr_mngr.current == "create":
composer_objs = self.root composer_objs = self.root
from_addr = str(self.root.children[1].children[0].children[0].children[0].children[0].ids.ti.text) from_addr = str(self.root.children[1].children[0].children[
to_addr = str(self.root.children[1].children[0].children[0].children[0].children[0].ids.txt_input.text) 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)
if from_addr and to_addr: if from_addr and to_addr:
Draft().draft_msg(composer_objs) Draft().draft_msg(composer_objs)
self.root.ids.serch_btn.opacity = 1 self.root.ids.serch_btn.opacity = 1
@ -846,17 +1018,18 @@ class NavigateApp(App):
return True return True
def restart(self, *args): def restart(self, *args):
"""this method is used to set transition direction""" """Method used to set transition direction."""
self.root.ids.scr_mngr.transition.direction = 'left' self.root.ids.scr_mngr.transition.direction = 'left'
self.root.ids.scr_mngr.transition.unbind(on_complete=self.restart) self.root.ids.scr_mngr.transition.unbind(on_complete=self.restart)
def status_dispatching(self, data): def status_dispatching(self, data):
"""Method used for status dispatching acknowledgment."""
ackData, message = data ackData, message = data
if state.ackdata == ackData: if state.ackdata == ackData:
state.status.status = message state.status.status = message
def clear_composer(self): def clear_composer(self):
"""if slow down the nwe will make new composer edit screen""" """If slow down the nwe will make new composer edit screen."""
self.root.ids.serch_btn.opacity = 0 self.root.ids.serch_btn.opacity = 0
self.root.ids.serch_btn.disabled = True self.root.ids.serch_btn.disabled = True
composer_obj = self.root.ids.sc3.children[0].ids composer_obj = self.root.ids.sc3.children[0].ids
@ -866,8 +1039,8 @@ class NavigateApp(App):
composer_obj.subject.text = '' composer_obj.subject.text = ''
def on_stop(self): def on_stop(self):
"""On stop methos is used for stoping the runing script""" """On stop methos is used for stoping the runing script."""
print("**************************EXITING FROM APPLICATION*****************************") print("*******************EXITING FROM APPLICATION*******************")
import shutdown import shutdown
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
@ -876,32 +1049,45 @@ class NavigateApp(App):
if BMConfigParser().addresses(): if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0] state.association = BMConfigParser().addresses()[0]
if text == 'Sent': if text == 'Sent':
state.sent_count = str(sqlQuery("SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and folder = '{0}' ;".format(text.lower(), state.association))[0][0]) state.sent_count = str(sqlQuery(
"SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \
folder = '{0}' ;".format(
text.lower(), state.association))[0][0])
return state.sent_count return state.sent_count
elif text == 'Inbox': elif text == 'Inbox':
state.inbox_count = str(sqlQuery("SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and folder = '{0}' ;".format(text.lower(), state.association))[0][0]) state.inbox_count = str(sqlQuery(
"SELECT COUNT(*) FROM {0} WHERE fromaddress = '{1}' and \
folder = '{0}' ;".format(
text.lower(), state.association))[0][0])
return state.inbox_count return state.inbox_count
elif text == 'Trash': elif text == 'Trash':
state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' and folder = 'trash' )+(SELECT count(*) FROM inbox where fromaddress = '{0}' and folder = 'trash') AS SumCount".format(state.association))[0][0]) state.trash_count = str(sqlQuery(
"SELECT (SELECT count(*) FROM sent where fromaddress = '{0}' \
and folder = 'trash' )+(SELECT count(*) FROM inbox where \
fromaddress = '{0}' and folder = 'trash') AS SumCount".format(
state.association))[0][0])
return state.trash_count return state.trash_count
elif text == 'Draft': elif text == 'Draft':
state.draft_count = str(sqlQuery("SELECT COUNT(*) FROM sent WHERE fromaddress = '{1}' and folder = '{0}' ;".format(text.lower(), state.association))[0][0]) state.draft_count = str(sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{1}' and \
folder = '{0}' ;".format(
text.lower(), state.association))[0][0])
return state.draft_count return state.draft_count
def current_address_label(self, current_address=None): def current_address_label(self, current_address=None):
"""Getting current address labels."""
if BMConfigParser().addresses() or current_address: if BMConfigParser().addresses() or current_address:
if current_address: if current_address:
first_name = current_address first_name = current_address
else: else:
first_name = BMConfigParser().get(BMConfigParser().addresses()[0], 'label') first_name = BMConfigParser().get(
BMConfigParser().addresses()[0], 'label')
f_name = first_name.split() f_name = first_name.split()
return f_name[0][:14]+ '...' if len(f_name[0])>15 else f_name[0] return f_name[0][:14] + '...' if len(f_name[0]) > 15 else f_name[0]
return '' return ''
def searchQuery(self, instance): def searchQuery(self, instance):
'''This method is used for showing searched mails''' '''This method is used for showing searched mails'''
# import pdb;pdb.set_trace()
if str(instance.text):
state.search_screen = self.root.ids.scr_mngr.current state.search_screen = self.root.ids.scr_mngr.current
state.searcing_text = str(instance.text).strip() state.searcing_text = str(instance.text).strip()
if state.search_screen == 'inbox': if state.search_screen == 'inbox':
@ -936,12 +1122,13 @@ class NavigateApp(App):
# self.root.ids.scr_mngr.current = state.search_screen # self.root.ids.scr_mngr.current = state.search_screen
def reset_navdrawer(self, instance): def reset_navdrawer(self, instance):
'''This methos is used for reseting navigation drawer''' """Method used for reseting navigation drawer."""
self.root.ids.search_input.text = '' self.root.ids.search_input.text = ''
self.root.ids.search_input.opacity = 0 self.root.ids.search_input.opacity = 0
self.root.ids.search_input.size_hint = 1,None self.root.ids.search_input.size_hint = 1, None
self.root.ids.search_input.disabled = True self.root.ids.search_input.disabled = True
self.root.ids.toolbar.left_action_items = [['menu', lambda x: self.root.toggle_nav_drawer()]] self.root.ids.toolbar.left_action_items = [
['menu', lambda x: self.root.toggle_nav_drawer()]]
self.root.ids.toolbar.title = self.current_address_label() self.root.ids.toolbar.title = self.current_address_label()
self.root.ids.myButton.opacity = 1 self.root.ids.myButton.opacity = 1
self.root.ids.myButton.disabled = False self.root.ids.myButton.disabled = False
@ -956,7 +1143,7 @@ class NavigateApp(App):
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.add_widget(Sent())
def check_search_screen(self, instance): def check_search_screen(self, instance):
'''This method is used for showing search button only on inbox or sent screen''' """Method shows search button on inbox and sent screen only."""
if instance.text == 'Inbox' or instance.text == 'Sent': if instance.text == 'Inbox' or instance.text == 'Sent':
if not self.root.ids.search_bar.children: if not self.root.ids.search_bar.children:
self.root.ids.search_bar.add_widget(MDIconButton(icon = 'magnify')) self.root.ids.search_bar.add_widget(MDIconButton(icon = 'magnify'))
@ -976,7 +1163,10 @@ class NavigateApp(App):
class GrashofPopup(Popup): class GrashofPopup(Popup):
"""Methods for saving contacts, error messages."""
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Grash of pop screen settings."""
super(GrashofPopup, self).__init__(**kwargs) super(GrashofPopup, self).__init__(**kwargs)
if state.screen_density[0] <= 720: if state.screen_density[0] <= 720:
self.size_hint_y = 0.4 self.size_hint_y = 0.4
@ -986,7 +1176,9 @@ class GrashofPopup(Popup):
self.size_hint_x = 0.7 self.size_hint_x = 0.7
def savecontact(self): def savecontact(self):
my_addresses = self.parent.children[1].children[2].children[0].ids.btn.values """Method is used for Saving Contacts."""
my_addresses = \
self.parent.children[1].children[2].children[0].ids.btn.values
entered_text = str(self.ids.label.text) entered_text = str(self.ids.label.text)
if entered_text in my_addresses: if entered_text in my_addresses:
self.ids.label.focus = True self.ids.label.focus = True
@ -1007,7 +1199,9 @@ class GrashofPopup(Popup):
self.parent.children[1].ids.scr_mngr.current = 'addressbook' self.parent.children[1].ids.scr_mngr.current = 'addressbook'
def show_error_message(self): def show_error_message(self):
content = MDLabel(font_style='Body1', """Showing error message."""
content = MDLabel(
font_style='Body1',
theme_text_color='Secondary', theme_text_color='Secondary',
text="Hey you are not allowed to save blank address contact. " text="Hey you are not allowed to save blank address contact. "
"That's wrong!", "That's wrong!",
@ -1025,34 +1219,40 @@ class GrashofPopup(Popup):
class AvatarSampleWidget(ILeftBody, Image): class AvatarSampleWidget(ILeftBody, Image):
"""Avatar Sample Widget."""
pass pass
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton): class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
"""Left icon sample widget."""
pass pass
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox): class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
"""Right icon sample widget."""
pass pass
class NavigationDrawerTwoLineListItem( class NavigationDrawerTwoLineListItem(
TwoLineListItem, NavigationDrawerHeaderBase): TwoLineListItem, NavigationDrawerHeaderBase):
"""Navigation Drawer in Listitems."""
address_property = StringProperty() address_property = StringProperty()
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Method for Navigation Drawer."""
super(NavigationDrawerTwoLineListItem, self).__init__(**kwargs) super(NavigationDrawerTwoLineListItem, self).__init__(**kwargs)
Clock.schedule_once(lambda dt: self.setup()) Clock.schedule_once(lambda dt: self.setup())
def setup(self): def setup(self):
""" """Bind Controller.current_account property."""
Binds Controller.current_account property.
"""
pass pass
def on_current_account(self, account): def on_current_account(self, account):
"""Account detail."""
pass pass
def _update_specific_text_color(self, instance, value): def _update_specific_text_color(self, instance, value):
@ -1064,6 +1264,7 @@ class NavigationDrawerTwoLineListItem(
class MailDetail(Screen): class MailDetail(Screen):
"""MailDetail Screen uses to show the detail of mails.""" """MailDetail Screen uses to show the detail of mails."""
to_addr = StringProperty() to_addr = StringProperty()
from_addr = StringProperty() from_addr = StringProperty()
subject = StringProperty() subject = StringProperty()
@ -1072,6 +1273,7 @@ class MailDetail(Screen):
page_type = StringProperty() page_type = StringProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Mail Details method."""
super(MailDetail, self).__init__(*args, **kwargs) super(MailDetail, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
@ -1079,15 +1281,21 @@ class MailDetail(Screen):
"""Clock Schdule for method MailDetail mails.""" """Clock Schdule for method MailDetail mails."""
self.page_type = state.detailPageType if state.detailPageType else '' self.page_type = state.detailPageType if state.detailPageType else ''
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
data = sqlQuery("select toaddress, fromaddress, subject, message , status, ackdata from sent where lastactiontime = {};".format(state.sentMailTime)) data = sqlQuery(
"select toaddress, fromaddress, subject, message, status, \
ackdata from sent where lastactiontime = {};".format(
state.sentMailTime))
state.status = self state.status = self
state.ackdata = data[0][5] state.ackdata = data[0][5]
self.assign_mail_details(data) self.assign_mail_details(data)
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
data = sqlQuery("select toaddress, fromaddress, subject, message from inbox where received = {};".format(state.sentMailTime)) data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox \
where received = {};".format(state.sentMailTime))
self.assign_mail_details(data) self.assign_mail_details(data)
def assign_mail_details(self, data): def assign_mail_details(self, data):
"""Assigning mail details."""
self.to_addr = data[0][0] self.to_addr = data[0][0]
self.from_addr = data[0][1] self.from_addr = data[0][1]
self.subject = data[0][2].upper() self.subject = data[0][2].upper()
@ -1096,17 +1304,24 @@ class MailDetail(Screen):
self.status = data[0][4] self.status = data[0][4]
def delete_mail(self): def delete_mail(self):
msg_count_objs =self.parent.parent.parent.parent.parent.children[2].children[0].ids """Method for mail delete."""
msg_count_objs = \
self.parent.parent.parent.parent.parent.children[2].children[0].ids
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
sqlExecute("UPDATE sent SET folder = 'trash' WHERE lastactiontime = {};".format(state.sentMailTime)) sqlExecute(
"UPDATE sent SET folder = 'trash' WHERE \
lastactiontime = {};".format(state.sentMailTime))
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
self.parent.parent.screens[3].clear_widgets() self.parent.parent.screens[3].clear_widgets()
self.parent.parent.screens[3].add_widget(Sent()) self.parent.parent.screens[3].add_widget(Sent())
self.parent.parent.current = 'sent' self.parent.parent.current = 'sent'
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
sqlExecute("UPDATE inbox SET folder = 'trash' WHERE received = {};".format(state.sentMailTime)) sqlExecute(
msg_count_objs.inbox_cnt.badge_text = str(int(state.inbox_count) - 1) "UPDATE inbox SET folder = 'trash' WHERE \
received = {};".format(state.sentMailTime))
msg_count_objs.inbox_cnt.badge_text = str(
int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1) state.inbox_count = str(int(state.inbox_count) - 1)
self.parent.parent.screens[0].clear_widgets() self.parent.parent.screens[0].clear_widgets()
self.parent.parent.screens[0].add_widget(Inbox()) self.parent.parent.screens[0].add_widget(Inbox())
@ -1119,8 +1334,10 @@ class MailDetail(Screen):
self.parent.parent.parent.parent.parent.ids.serch_btn.disabled = False self.parent.parent.parent.parent.parent.ids.serch_btn.disabled = False
def inbox_reply(self): def inbox_reply(self):
"""This method is used for replying inbox messages""" """Method used for replying inbox messages."""
data = sqlQuery("select toaddress, fromaddress, subject, message from inbox where received = {};".format(state.sentMailTime)) data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox where \
received = {};".format(state.sentMailTime))
composer_obj = self.parent.parent.screens[2].children[0].ids composer_obj = self.parent.parent.screens[2].children[0].ids
composer_obj.ti.text = data[0][1] composer_obj.ti.text = data[0][1]
composer_obj.btn.text = data[0][1] composer_obj.btn.text = data[0][1]
@ -1129,16 +1346,18 @@ class MailDetail(Screen):
self.parent.parent.current = 'create' self.parent.parent.current = 'create'
def copy_sent_mail(self): def copy_sent_mail(self):
"""This method is used for copying sent mail to the composer""" """Method used for copying sent mail to the composer."""
pass pass
class MyaddDetailPopup(Popup): class MyaddDetailPopup(Popup):
"""MyaddDetailPopup pop is used for showing my address detail""" """MyaddDetailPopup pop is used for showing my address detail."""
address_label = StringProperty() address_label = StringProperty()
address = StringProperty() address = StringProperty()
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""My Address Details screen setting."""
super(MyaddDetailPopup, self).__init__(**kwargs) super(MyaddDetailPopup, self).__init__(**kwargs)
if state.screen_density[0] <= 720: if state.screen_density[0] <= 720:
self.size_hint_y = 0.32 self.size_hint_y = 0.32
@ -1148,12 +1367,12 @@ class MyaddDetailPopup(Popup):
self.size_hint_x = 0.7 self.size_hint_x = 0.7
def set_address(self, address, label): def set_address(self, address, label):
"""Getting address for displaying details on popup""" """Getting address for displaying details on popup."""
self.address_label = label self.address_label = label
self.address = address self.address = address
def send_message_from(self): def send_message_from(self):
"""This method used to fill from address of composer autofield""" """Method used to fill from address of composer autofield."""
window_obj = self.parent.children[1].ids window_obj = self.parent.children[1].ids
window_obj.sc3.children[0].ids.ti.text = self.address 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.btn.text = self.address
@ -1163,12 +1382,15 @@ class MyaddDetailPopup(Popup):
window_obj.scr_mngr.current = 'create' window_obj.scr_mngr.current = 'create'
self.dismiss() self.dismiss()
class AddbookDetailPopup(Popup): class AddbookDetailPopup(Popup):
"""AddbookDetailPopup pop is used for showing my address detail""" """AddbookDetailPopup pop is used for showing my address detail."""
address_label = StringProperty() address_label = StringProperty()
address = StringProperty() address = StringProperty()
def __init__(self, **kwargs): def __init__(self, **kwargs):
"""Method used set screen of address detail page."""
super(AddbookDetailPopup, self).__init__(**kwargs) super(AddbookDetailPopup, self).__init__(**kwargs)
if state.screen_density[0] <= 720: if state.screen_density[0] <= 720:
self.size_hint_y = 0.35 self.size_hint_y = 0.35
@ -1178,20 +1400,21 @@ class AddbookDetailPopup(Popup):
self.size_hint_x = 0.7 self.size_hint_x = 0.7
def set_addbook_data(self, address, label): def set_addbook_data(self, address, label):
"""Getting address book data for detial dipaly""" """Getting address book data for detial dipaly."""
self.address_label = label self.address_label = label
self.address = address self.address = address
def update_addbook_label(self, address): def update_addbook_label(self, address):
"""Updating the label of address book address""" """Updating the label of address book address."""
if str(self.ids.add_label.text): if str(self.ids.add_label.text):
sqlExecute("UPDATE addressbook SET label = '{}' WHERE address = '{}';".format(str(self.ids.add_label.text), address)) sqlExecute("UPDATE addressbook SET label = '{}' WHERE \
address = '{}';".format(str(self.ids.add_label.text), address))
self.parent.children[1].ids.sc11.clear_widgets() self.parent.children[1].ids.sc11.clear_widgets()
self.parent.children[1].ids.sc11.add_widget(AddressBook()) self.parent.children[1].ids.sc11.add_widget(AddressBook())
self.dismiss() self.dismiss()
def send_message_to(self): def send_message_to(self):
"""This method used to fill to_address of composer autofield""" """Method used to fill to_address of composer autofield."""
window_obj = self.parent.children[1].ids window_obj = self.parent.children[1].ids
window_obj.sc3.children[0].ids.txt_input.text = self.address 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.ti.text = ''
@ -1206,6 +1429,7 @@ class ShowQRCode(Screen):
"""ShowQRCode Screen uses to show the detail of mails.""" """ShowQRCode Screen uses to show the detail of mails."""
def qrdisplay(self): def qrdisplay(self):
"""Method used for showing QR Code."""
self.ids.qr.clear_widgets() self.ids.qr.clear_widgets()
from kivy.garden.qrcode import QRCodeWidget from kivy.garden.qrcode import QRCodeWidget
self.ids.qr.add_widget(QRCodeWidget(data=self.manager.get_parent_window().children[0].address)) self.ids.qr.add_widget(QRCodeWidget(data=self.manager.get_parent_window().children[0].address))
@ -1213,9 +1437,11 @@ class ShowQRCode(Screen):
class Draft(Screen): class Draft(Screen):
"""Draft screen is used to show the list of draft messages.""" """Draft screen is used to show the list of draft messages."""
data = ListProperty() data = ListProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Method used for storing draft messages."""
super(Draft, self).__init__(*args, **kwargs) super(Draft, self).__init__(*args, **kwargs)
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
@ -1243,10 +1469,21 @@ class Draft(Screen):
if queryreturn: if queryreturn:
for mail in queryreturn: for mail in queryreturn:
third_text = mail[3].replace('\n', ' ') third_text = mail[3].replace('\n', ' ')
self.data.append({'text': mail[1].strip(), 'secondary_text': mail[2][:10] + '...........' if len(mail[2]) > 10 else mail[2] + '\n' + " " + (third_text[:25] + '...!') if len(third_text) > 25 else third_text, 'lastactiontime': mail[6]}) self.data.append({
'text': mail[1].strip(),
'secondary_text': mail[2][:10] + '...........' if len(
mail[2]) > 10 else mail[2] + '\n' + " " + (
third_text[:25] + '...!') if len(
third_text) > 25 else third_text,
'lastactiontime': mail[6]})
for item in self.data: for item in self.data:
meny = TwoLineAvatarIconListItem(text='Draft', secondary_text=item['text'], theme_text_color= 'Custom',text_color=NavigateApp().theme_cls.primary_color) meny = TwoLineAvatarIconListItem(
meny.add_widget(AvatarSampleWidget(source='./images/avatar.png')) text='Draft',
secondary_text=item['text'],
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/avatar.png'))
carousel = Carousel(direction='right') carousel = Carousel(direction='right')
if platform == 'android': if platform == 'android':
carousel.height = 150 carousel.height = 150
@ -1259,13 +1496,15 @@ class Draft(Screen):
del_btn = Button(text='Delete') del_btn = Button(text='Delete')
del_btn.background_normal = '' del_btn.background_normal = ''
del_btn.background_color = (1.0, 0.0, 0.0, 1.0) del_btn.background_color = (1.0, 0.0, 0.0, 1.0)
del_btn.bind(on_press=partial(self.delete_draft, item['lastactiontime'])) del_btn.bind(on_press=partial(
self.delete_draft, item['lastactiontime']))
carousel.add_widget(del_btn) carousel.add_widget(del_btn)
carousel.add_widget(meny) carousel.add_widget(meny)
carousel.index=1 carousel.index = 1
self.ids.ml.add_widget(carousel) self.ids.ml.add_widget(carousel)
else: else:
content = MDLabel(font_style='Body1', content = MDLabel(
font_style='Body1',
theme_text_color='Primary', theme_text_color='Primary',
text="yet no message for this account!!!!!!!!!!!!!", text="yet no message for this account!!!!!!!!!!!!!",
halign='center', halign='center',
@ -1275,20 +1514,25 @@ class Draft(Screen):
self.ids.ml.add_widget(content) self.ids.ml.add_widget(content)
def delete_draft(self, data_index, instance, *args): def delete_draft(self, data_index, instance, *args):
"""This method is used to delete draft message permanently""" """Method used to delete draft message permanently."""
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(data_index)) sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
data_index))
try: try:
msg_count_objs = self.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = \
self.parent.parent.parent.parent.children[2].children[0].ids
except Exception as e: except Exception as e:
msg_count_objs = self.parent.parent.parent.parent.parent.children[2].children[0].ids msg_count_objs = self.parent.parent.parent.parent.parent.children[
2].children[0].ids
if int(state.draft_count) > 0: if int(state.draft_count) > 0:
msg_count_objs.draft_cnt.badge_text = str(int(state.draft_count) - 1) msg_count_objs.draft_cnt.badge_text = str(
int(state.draft_count) - 1)
state.draft_count = str(int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
def draft_msg(self, src_object): def draft_msg(self, src_object):
"""This method is used for saving draft mails""" """Method used for saving draft mails."""
composer_object = src_object.children[1].children[0].children[0].children[0].children[0].ids composer_object = src_object.children[1].children[0].children[
0].children[0].children[0].ids
fromAddress = str(composer_object.ti.text) fromAddress = str(composer_object.ti.text)
toAddress = str(composer_object.txt_input.text) toAddress = str(composer_object.txt_input.text)
subject = str(composer_object.subject.text) subject = str(composer_object.subject.text)
@ -1297,9 +1541,9 @@ class Draft(Screen):
sendMessageToPeople = True sendMessageToPeople = True
if sendMessageToPeople: if sendMessageToPeople:
from addresses import decodeAddress from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = decodeAddress( status, addressVersionNumber, streamNumber, ripe = \
toAddress) decodeAddress(toAddress)
from addresses import * from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' statusIconColor = 'red'
stealthLevel = BMConfigParser().safeGetInt( stealthLevel = BMConfigParser().safeGetInt(
@ -1308,7 +1552,8 @@ class Draft(Screen):
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () t = ()
sqlExecute( sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'', '',
toAddress, toAddress,
ripe, ripe,
@ -1333,20 +1578,23 @@ class Draft(Screen):
def show_search_btn(self): def show_search_btn(self):
'''This method is used to show search button''' """Method used to show search button."""
self.root.ids.serch_btn.opacity = 1 self.root.ids.serch_btn.opacity = 1
self.root.ids.serch_btn.disabled = False self.root.ids.serch_btn.disabled = False
def hide_search_btn(mgr_objs): def hide_search_btn(mgr_objs):
'''This method is used to hide search button and search box''' """Method used to hide search button and search box."""
mgr_objs.parent.parent.parent.ids.serch_btn.opacity = 0 mgr_objs.parent.parent.parent.ids.serch_btn.opacity = 0
mgr_objs.parent.parent.parent.ids.serch_btn.disabled = True mgr_objs.parent.parent.parent.ids.serch_btn.disabled = True
mgr_objs.parent.parent.parent.ids.search_input.size_hint = 1,None mgr_objs.parent.parent.parent.ids.search_input.size_hint = 1, None
mgr_objs.parent.parent.parent.ids.search_input.disabled = True mgr_objs.parent.parent.parent.ids.search_input.disabled = True
mgr_objs.parent.parent.parent.ids.search_input.opacity = 0 mgr_objs.parent.parent.parent.ids.search_input.opacity = 0
mgr_objs.parent.parent.parent.ids.toolbar.left_action_items = [['menu', lambda x: mgr_objs.parent.parent.parent.toggle_nav_drawer()]] mgr_objs.parent.parent.parent.ids.toolbar.left_action_items = \
mgr_objs.parent.parent.parent.ids.toolbar.title = NavigateApp().current_address_label() [['menu', lambda x: mgr_objs.parent.parent.parent.toggle_nav_drawer()]]
mgr_objs.parent.parent.parent.ids.toolbar.title = \
NavigateApp().current_address_label()
mgr_objs.parent.parent.parent.ids.myButton.opacity = 1 mgr_objs.parent.parent.parent.ids.myButton.opacity = 1
mgr_objs.parent.parent.parent.ids.myButton.disabled = False mgr_objs.parent.parent.parent.ids.myButton.disabled = False
mgr_objs.parent.parent.parent.ids.reset_navbar.opacity = 0 mgr_objs.parent.parent.parent.ids.reset_navbar.opacity = 0
@ -1354,9 +1602,11 @@ def hide_search_btn(mgr_objs):
class CustomSpinner(Spinner): class CustomSpinner(Spinner):
'''This class is used for setting spinner size''' """This class is used for setting spinner size."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
'''This methods is used for setting size of spinner''' """Method used for setting size of spinner."""
super(CustomSpinner, self).__init__(*args, **kwargs) super(CustomSpinner, self).__init__(*args, **kwargs)
max = 2.8 max = 2.8
self.dropdown_cls.max_height = self.height * max + max * 4 self.dropdown_cls.max_height = self.height * max + max * 4
print(args)