Merge branch 'UiChanges' of https://github.com/surbhicis/PyBitmessage into UiChanges

This commit is contained in:
jai.s 2019-10-18 19:36:56 +05:30
commit 5a0686f9ac
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
4 changed files with 104 additions and 136 deletions

View File

@ -1,42 +1,18 @@
#:import Toolbar kivymd.toolbar.Toolbar #:import Toolbar kivymd.toolbar.Toolbar
#:import ThemeManager kivymd.theming.ThemeManager
#:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer
#:import NavigationLayout kivymd.navigationdrawer.NavigationLayout #:import NavigationLayout kivymd.navigationdrawer.NavigationLayout
#:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider #:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider
#:import NavigationDrawerToolbar kivymd.navigationdrawer.NavigationDrawerToolbar
#:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader #:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader
#:import MDCheckbox kivymd.selectioncontrols.MDCheckbox #:import MDCheckbox kivymd.selectioncontrols.MDCheckbox
#:import MDSwitch kivymd.selectioncontrols.MDSwitch
#:import MDList kivymd.list.MDList #:import MDList kivymd.list.MDList
#:import OneLineListItem kivymd.list.OneLineListItem #:import OneLineListItem kivymd.list.OneLineListItem
#:import TwoLineListItem kivymd.list.TwoLineListItem
#:import ThreeLineListItem kivymd.list.ThreeLineListItem
#:import OneLineAvatarListItem kivymd.list.OneLineAvatarListItem
#:import OneLineIconListItem kivymd.list.OneLineIconListItem
#:import OneLineAvatarIconListItem kivymd.list.OneLineAvatarIconListItem
#:import MDTextField kivymd.textfields.MDTextField #:import MDTextField kivymd.textfields.MDTextField
#:import MDSpinner kivymd.spinner.MDSpinner
#:import MDCard kivymd.card.MDCard
#:import MDSeparator kivymd.card.MDSeparator
#:import MDDropdownMenu kivymd.menu.MDDropdownMenu
#:import get_color_from_hex kivy.utils.get_color_from_hex #:import get_color_from_hex kivy.utils.get_color_from_hex
#:import colors kivymd.color_definitions.colors #:import colors kivymd.color_definitions.colors
#:import SmartTile kivymd.grid.SmartTile
#:import MDSlider kivymd.slider.MDSlider
#:import MDTabbedPanel kivymd.tabs.MDTabbedPanel #:import MDTabbedPanel kivymd.tabs.MDTabbedPanel
#:import MDTab kivymd.tabs.MDTab #:import MDTab kivymd.tabs.MDTab
#:import MDProgressBar kivymd.progressbar.MDProgressBar
#:import MDAccordion kivymd.accordion.MDAccordion
#:import MDAccordionItem kivymd.accordion.MDAccordionItem
#:import MDAccordionSubItem kivymd.accordion.MDAccordionSubItem
#:import MDThemePicker kivymd.theme_picker.MDThemePicker
#:import MDBottomNavigation kivymd.tabs.MDBottomNavigation
#:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem
#:import MDFloatingActionButton kivymd.button.MDFloatingActionButton #:import MDFloatingActionButton kivymd.button.MDFloatingActionButton
#:import Factory kivy.factory.Factory #:import Factory kivy.factory.Factory
#:import MDTextButton kivymd.button.MDTextButton
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
#:import MDScrollViewRefreshLayout kivymd.refreshlayout.MDScrollViewRefreshLayout #:import MDScrollViewRefreshLayout kivymd.refreshlayout.MDScrollViewRefreshLayout
#:set color_button (0.784, 0.443, 0.216, 1) # brown #:set color_button (0.784, 0.443, 0.216, 1) # brown
@ -55,8 +31,7 @@
<ContentNavigationDrawer@Navigatorss>: <ContentNavigationDrawer@Navigatorss>:
drawer_logo: app.address_identicon() drawer_logo: app.address_identicon()
NavigationDrawerDivider: NavigationDrawerDivider:
NavigationDrawerSubheader:
NavigationDrawerTwoLineListItem:
text: "Accounts" text: "Accounts"
NavigationDrawerIconButton: NavigationDrawerIconButton:
CustomSpinner: CustomSpinner:
@ -143,7 +118,7 @@
on_press: app.refreshScreen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Subscriptions/Payment" text: "Subscriptions/Payment"
icon:'wallet' icon:'bell'
on_release: app.root.ids.scr_mngr.current = 'payment' on_release: app.root.ids.scr_mngr.current = 'payment'
on_press: app.refreshScreen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
@ -417,17 +392,6 @@ NavigationLayout:
helper_text_mode: "on_error" helper_text_mode: "on_error"
BoxLayout: BoxLayout:
spacing:50 spacing:50
AnchorLayout:
MDRaisedButton:
size_hint: 1, None
height: dp(40)
on_press: root.reset_composer()
MDLabel:
font_style: 'Title'
text: 'reset'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<MyTextInput>: <MyTextInput>:
readonly: False readonly: False

View File

@ -19,7 +19,8 @@ from kivy.properties import (
ListProperty, ListProperty,
NumericProperty, NumericProperty,
ObjectProperty, ObjectProperty,
StringProperty) StringProperty
)
from kivy.uix.behaviors import FocusBehavior from kivy.uix.behaviors import FocusBehavior
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button from kivy.uix.button import Button
@ -44,10 +45,12 @@ from kivymd.list import (
ILeftBodyTouch, ILeftBodyTouch,
IRightBodyTouch, IRightBodyTouch,
TwoLineAvatarIconListItem, TwoLineAvatarIconListItem,
TwoLineListItem) TwoLineListItem
)
from kivymd.navigationdrawer import ( from kivymd.navigationdrawer import (
MDNavigationDrawer, MDNavigationDrawer,
NavigationDrawerHeaderBase) NavigationDrawerHeaderBase
)
from kivymd.selectioncontrols import MDCheckbox from kivymd.selectioncontrols import MDCheckbox
from kivymd.theming import ThemeManager from kivymd.theming import ThemeManager
import queues import queues
@ -61,8 +64,8 @@ import identiconGeneration
def toast(text): def toast(text):
"""Method will display the toast message.""" """Method will display the toast message."""
if platform == 'linux': # pylint: disable=redefined-outer-name
from kivymd.toast.kivytoast import toast # pylint: disable=redefined-outer-name from kivymd.toast.kivytoast import toast
toast(text) toast(text)
return return
@ -181,11 +184,9 @@ class Inbox(Screen):
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str(
data_index)) data_index))
try: try:
msg_count_objs = \ msg_count_objs = self.parent.parent.parent.parent.children[2].children[0].ids
self.parent.parent.parent.parent.children[2].children[0].ids except Exception:
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.inbox_count) > 0: if int(state.inbox_count) > 0:
msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.badge_text = str(
int(state.inbox_count) - 1) int(state.inbox_count) - 1)
@ -379,8 +380,9 @@ class AddressBook(Screen):
@staticmethod @staticmethod
def refreshs(*args): def refreshs(*args):
"""Refresh the Widget.""" """Refresh the Widget."""
state.navinstance.ids.sc11.ids.ml.clear_widgets() # state.navinstance.ids.sc11.ids.ml.clear_widgets()
state.navinstance.ids.sc11.loadAddresslist(None, 'All', '') # state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
pass
@staticmethod @staticmethod
def addBook_detail(address, label, *args): def addBook_detail(address, label, *args):
@ -436,20 +438,21 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
class RV(RecycleView): class RV(RecycleView):
"""Recycling View.""" """Recycling View."""
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation def __init__(self, **kwargs):
"""Recycling Method.""" """Recycling Method."""
# pylint: disable=useless-super-delegation
super(RV, self).__init__(**kwargs) super(RV, self).__init__(**kwargs)
class DropDownWidget(BoxLayout): class DropDownWidget(BoxLayout):
"""Adding Dropdown Widget.""" """Adding Dropdown Widget."""
# pylint: disable=too-many-statements, inconsistent-return-statements, too-many-locals
txt_input = ObjectProperty() txt_input = ObjectProperty()
rv = ObjectProperty() rv = ObjectProperty()
def send(self, navApp): # pylint: disable=too-many-statements, inconsistent-return-statements def send(self, navApp):
"""Send message from one address to another.""" """Send message from one address to another."""
# pylint: disable=too-many-locals
fromAddress = str(self.ids.ti.text) fromAddress = str(self.ids.ti.text)
toAddress = str(self.ids.txt_input.text) toAddress = str(self.ids.txt_input.text)
subject = self.ids.subject.text.encode('utf-8').strip() subject = self.ids.subject.text.encode('utf-8').strip()
@ -460,15 +463,14 @@ 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 = \ status, addressVersionNumber, streamNumber, ripe = decodeAddress(toAddress)
decodeAddress(toAddress)
if status == 'success': if status == 'success':
if state.detailPageType == 'draft' and state.send_draft_mail: if state.detailPageType == 'draft' and state.send_draft_mail:
sqlExecute( sqlExecute(
"UPDATE sent SET toaddress = ? \ "UPDATE sent SET toaddress = ?"
, fromaddress = ? , subject = ?\ ", fromaddress = ? , subject = ?"
, message = ?, folder = 'sent'\ ", message = ?, folder = 'sent'"
WHERE ackdata = ?;", " WHERE ackdata = ?;",
toAddress, toAddress,
fromAddress, fromAddress,
subject, subject,
@ -558,6 +560,7 @@ class DropDownWidget(BoxLayout):
self.ids.txt_input.text = '' self.ids.txt_input.text = ''
self.ids.subject.text = '' self.ids.subject.text = ''
self.ids.body.text = '' self.ids.body.text = ''
toast("Reset message")
def auto_fill_fromaddr(self): def auto_fill_fromaddr(self):
"""Mehtod used to fill the text automatically From Address.""" """Mehtod used to fill the text automatically From Address."""
@ -574,8 +577,9 @@ class MyTextInput(TextInput):
starting_no = NumericProperty(3) starting_no = NumericProperty(3)
suggestion_text = '' suggestion_text = ''
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation def __init__(self, **kwargs):
"""Getting Text Input.""" """Getting Text Input."""
# pylint: disable=useless-super-delegation
super(MyTextInput, self).__init__(**kwargs) super(MyTextInput, self).__init__(**kwargs)
def on_text(self, instance, value): def on_text(self, instance, value):
@ -605,8 +609,9 @@ class MyTextInput(TextInput):
class Payment(Screen): class Payment(Screen):
"""Payment Method.""" """Payment Method."""
def get_available_credits(self, instance): # pylint: disable=no-self-use def get_available_credits(self, instance):
"""Method helps to get the available credits""" """Method helps to get the available credits"""
# pylint: disable=no-self-use
state.availabe_credit = instance.parent.children[1].text state.availabe_credit = instance.parent.children[1].text
existing_credits = state.kivyapp.root.ids.sc18.ids.ml.children[0].children[0].children[0].children[0].text existing_credits = state.kivyapp.root.ids.sc18.ids.ml.children[0].children[0].children[0].children[0].text
if len(existing_credits.split(' ')) > 1: if len(existing_credits.split(' ')) > 1:
@ -694,6 +699,7 @@ class Random(Screen):
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
self.parent.parent.parent.parent.ids.sc10.ids.ml.clear_widgets() self.parent.parent.parent.parent.ids.sc10.ids.ml.clear_widgets()
self.manager.current = 'myaddress'
self.parent.parent.parent.parent.ids.sc10.init_ui() self.parent.parent.parent.parent.ids.sc10.init_ui()
self.manager.current = 'myaddress' self.manager.current = 'myaddress'
toast('New address created') toast('New address created')
@ -734,8 +740,7 @@ class Sent(Screen):
data = [] data = []
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 == \ if state.msg_counter_objs and state.association == state.check_sent_acc:
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.all_count = str(int(state.all_count) + 1) state.all_count = str(int(state.all_count) + 1)
@ -827,8 +832,8 @@ class Sent(Screen):
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash' \ "UPDATE sent SET folder = 'trash'"
WHERE ackdata = ?;", str(data_index)) " WHERE ackdata = ?;", str(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
toast('Deleted') toast('Deleted')
self.update_trash() self.update_trash()
@ -836,8 +841,8 @@ class Sent(Screen):
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( sqlExecute(
"UPDATE sent SET folder = 'trash' \ "UPDATE sent SET folder = 'trash'"
WHERE ackdata = ?;", str(data_index)) " WHERE ackdata = ?;", str(data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
@ -868,14 +873,13 @@ class Trash(Screen):
if state.association == '': if state.association == '':
if BMConfigParser().addresses(): if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0] state.association = BMConfigParser().addresses()[0]
inbox = sqlQuery( inbox = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder, received from \ "SELECT toaddress, fromaddress, subject, message, folder, received from"
inbox WHERE folder = 'trash' and toaddress = '{}';".format( " inbox WHERE folder = 'trash' and toaddress = '{}';".format(
state.association)) state.association))
sent = sqlQuery( sent = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder, lastactiontime from \ "SELECT toaddress, fromaddress, subject, message, folder, lastactiontime from"
sent WHERE folder = 'trash' and fromaddress = '{}';".format( " sent WHERE folder = 'trash' and fromaddress = '{}';".format(
state.association)) state.association))
trash_data = inbox + sent trash_data = inbox + sent
@ -952,8 +956,9 @@ class Setting(Screen):
pass pass
class NavigateApp(App): # pylint: disable=too-many-public-methods class NavigateApp(App):
"""Navigation Layout of class.""" """Navigation Layout of class."""
# pylint: disable=too-many-public-methods
theme_cls = ThemeManager() theme_cls = ThemeManager()
previous_date = ObjectProperty() previous_date = ObjectProperty()
@ -1024,25 +1029,24 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.sc1.ids.ml.clear_widgets() self.root.ids.sc1.ids.ml.clear_widgets()
self.root.ids.sc1.loadMessagelist(state.association) self.root.ids.sc1.loadMessagelist(state.association)
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 = \
self.root_window.children[1].children[2].children[0].ids
state.sent_count = str( state.sent_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \ "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
folder = 'sent' ;".format(state.association))[0][0]) " folder = 'sent' ;".format(state.association))[0][0])
state.inbox_count = str( state.inbox_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and \ "SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
folder = 'inbox' ;".format(state.association))[0][0]) " folder = 'inbox' ;".format(state.association))[0][0])
state.trash_count = str(sqlQuery("SELECT (SELECT count(*) FROM sent \ state.trash_count = str(sqlQuery(
where fromaddress = '{0}' and folder = 'trash' ) \ "SELECT (SELECT count(*) FROM sent"
+(SELECT count(*) FROM inbox where toaddress = '{0}' and \ " where fromaddress = '{0}' and folder = 'trash' )"
folder = 'trash') AS SumCount".format(state.association))[0][0]) "+(SELECT count(*) FROM inbox where toaddress = '{0}' and"
" folder = 'trash') AS SumCount".format(state.association))[0][0])
state.draft_count = str( state.draft_count = str(
sqlQuery( sqlQuery(
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and \ "SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
folder = 'draft' ;".format(state.association))[0][0]) " folder = 'draft' ;".format(state.association))[0][0])
state.all_count = str(int(state.sent_count) + int(state.inbox_count)) state.all_count = str(int(state.sent_count) + int(state.inbox_count))
if msg_counter_objs: if msg_counter_objs:
@ -1094,7 +1098,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
"""Getting default image on address""" """Getting default image on address"""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0]) return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0])
return '' return './images/no_identicons.png'
@staticmethod @staticmethod
def addressexist(): def addressexist():
@ -1158,16 +1162,17 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.toolbar.left_action_items = [ self.root.ids.toolbar.left_action_items = [
['arrow-left', lambda x: self.back_press()]] ['arrow-left', lambda x: self.back_press()]]
self.root.ids.toolbar.right_action_items = [ self.root.ids.toolbar.right_action_items = [
['refresh', lambda x: self.root.ids.sc3.children[0].reset_composer()],
['send', lambda x: self.root.ids.sc3.children[0].send(self)]] ['send', lambda x: self.root.ids.sc3.children[0].send(self)]]
def back_press(self): def back_press(self):
"""Method used for going back from composer to previous page.""" """Method used for going back from composer to previous page."""
self.root.ids.toolbar.right_action_items = \ self.root.ids.toolbar.right_action_items = [['account-plus', lambda x: self.addingtoaddressbook()]]
[['account-plus', lambda x: self.addingtoaddressbook()]] 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.scr_mngr.current = 'inbox' \ self.root.ids.scr_mngr.current = 'inbox' \
if state.in_composer else 'allmails' if state.is_allmail else state.detailPageType if state.in_composer else 'allmails'\
if state.is_allmail else state.detailPageType\
if state.detailPageType else 'inbox'
self.root.ids.scr_mngr.transition.direction = 'right' self.root.ids.scr_mngr.transition.direction = 'right'
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset) self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
if state.is_allmail or state.detailPageType == 'draft': if state.is_allmail or state.detailPageType == 'draft':
@ -1227,7 +1232,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.sc1.ids.ml.clear_widgets() self.root.ids.sc1.ids.ml.clear_widgets()
try: try:
self.root.ids.sc1.children[2].children[1].ids.search_field.text = '' self.root.ids.sc1.children[2].children[1].ids.search_field.text = ''
except Exception as e: except Exception:
self.root.ids.sc1.children[1].children[1].ids.search_field.text = '' self.root.ids.sc1.children[1].children[1].ids.search_field.text = ''
self.root.ids.sc1.loadMessagelist(state.association) self.root.ids.sc1.loadMessagelist(state.association)
elif instance.text == 'Draft': elif instance.text == 'Draft':
@ -1247,7 +1252,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.sc10.ids.ml.clear_widgets() self.root.ids.sc10.ids.ml.clear_widgets()
try: try:
self.root.ids.sc10.children[1].children[1].ids.search_field.text = '' self.root.ids.sc10.children[1].children[1].ids.search_field.text = ''
except Exception as e: except Exception:
self.root.ids.sc10.children[2].children[1].ids.search_field.text = '' self.root.ids.sc10.children[2].children[1].ids.search_field.text = ''
self.root.ids.sc10.init_ui() self.root.ids.sc10.init_ui()
return return
@ -1280,8 +1285,9 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
class GrashofPopup(Popup): class GrashofPopup(Popup):
"""Methods for saving contacts, error messages.""" """Methods for saving contacts, error messages."""
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation def __init__(self, **kwargs):
"""Grash of pop screen settings.""" """Grash of pop screen settings."""
# pylint: disable=useless-super-delegation
super(GrashofPopup, self).__init__(**kwargs) super(GrashofPopup, self).__init__(**kwargs)
def savecontact(self): def savecontact(self):
@ -1299,10 +1305,12 @@ class GrashofPopup(Popup):
stored_address = [addr[1] for addr in kivy_helper_search.search_sql( stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
folder="addressbook")] folder="addressbook")]
if label and address and address not in stored_address: if label and address and address not in stored_address:
state.navinstance = self.parent.children[1] # state.navinstance = self.parent.children[1]
queues.UISignalQueue.put(('rerenderAddressBook', '')) queues.UISignalQueue.put(('rerenderAddressBook', ''))
self.dismiss() self.dismiss()
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address) sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
state.kivyapp.root.ids.sc11.ids.ml.clear_widgets()
state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '')
self.parent.children[1].ids.scr_mngr.current = 'addressbook' self.parent.children[1].ids.scr_mngr.current = 'addressbook'
toast('Saved') toast('Saved')
@ -1421,16 +1429,16 @@ class MailDetail(Screen):
self.page_type = state.detailPageType if state.detailPageType else '' self.page_type = state.detailPageType if state.detailPageType else ''
if state.detailPageType == 'sent' or state.detailPageType == 'draft': if state.detailPageType == 'sent' or state.detailPageType == 'draft':
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message, status, \ "select toaddress, fromaddress, subject, message, status,"
ackdata from sent where ackdata = ?;", state.mail_id) " ackdata from sent where ackdata = ?;", state.mail_id)
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)
state.kivyapp.set_mail_detail_header() state.kivyapp.set_mail_detail_header()
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox \ "select toaddress, fromaddress, subject, message from inbox"
where msgid = ?;", str(state.mail_id)) " where msgid = ?;", str(state.mail_id))
self.assign_mail_details(data) self.assign_mail_details(data)
state.kivyapp.set_mail_detail_header() state.kivyapp.set_mail_detail_header()
@ -1453,16 +1461,18 @@ class MailDetail(Screen):
msg_count_objs = state.kivyapp.root.children[2].children[0].ids msg_count_objs = state.kivyapp.root.children[2].children[0].ids
if state.detailPageType == 'sent': if state.detailPageType == 'sent':
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash' WHERE \ "UPDATE sent SET folder = 'trash' WHERE"
ackdata = ?;", str(state.mail_id)) " ackdata = ?;", str(state.mail_id))
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.screens[3].ids.ml.clear_widgets() self.parent.screens[3].ids.ml.clear_widgets()
self.parent.screens[3].loadSent(state.association) self.parent.screens[3].loadSent(state.association)
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE \ "UPDATE inbox SET folder = 'trash' WHERE"
msgid = ?;", str(state.mail_id)) " msgid = ?;", str(state.mail_id))
msg_count_objs.inbox_cnt.badge_text = str(int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1)
self.parent.screens[0].ids.ml.clear_widgets() self.parent.screens[0].ids.ml.clear_widgets()
self.parent.screens[0].loadMessagelist(state.association) self.parent.screens[0].loadMessagelist(state.association)
elif state.detailPageType == 'draft': elif state.detailPageType == 'draft':
@ -1489,8 +1499,8 @@ class MailDetail(Screen):
def inbox_reply(self): def inbox_reply(self):
"""Method used for replying inbox messages.""" """Method used for replying inbox messages."""
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox where \ "select toaddress, fromaddress, subject, message from inbox where"
msgid = ?;", str(state.mail_id)) " msgid = ?;", str(state.mail_id))
composer_obj = self.parent.screens[2].children[0].ids composer_obj = self.parent.screens[2].children[0].ids
composer_obj.ti.text = data[0][0] composer_obj.ti.text = data[0][0]
composer_obj.btn.text = data[0][0] composer_obj.btn.text = data[0][0]
@ -1508,8 +1518,7 @@ class MailDetail(Screen):
def write_msg(self, navApp): def write_msg(self, navApp):
"""Method used to write on draft mail.""" """Method used to write on draft mail."""
state.send_draft_mail = state.mail_id state.send_draft_mail = state.mail_id
composer_ids = \ composer_ids = self.parent.parent.parent.parent.ids.sc3.children[0].ids
self.parent.parent.parent.parent.ids.sc3.children[0].ids
composer_ids.ti.text = state.write_msg['from_addr'] composer_ids.ti.text = state.write_msg['from_addr']
composer_ids.btn.text = state.write_msg['from_addr'] composer_ids.btn.text = state.write_msg['from_addr']
composer_ids.txt_input.text = state.write_msg['to_addr'] composer_ids.txt_input.text = state.write_msg['to_addr']
@ -1535,8 +1544,9 @@ class MyaddDetailPopup(Popup):
address_label = StringProperty() address_label = StringProperty()
address = StringProperty() address = StringProperty()
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation def __init__(self, **kwargs):
"""My Address Details screen setting.""" """My Address Details screen setting."""
# pylint: disable=useless-super-delegation
super(MyaddDetailPopup, self).__init__(**kwargs) super(MyaddDetailPopup, self).__init__(**kwargs)
def set_address(self, address, label): def set_address(self, address, label):
@ -1567,8 +1577,9 @@ class AddbookDetailPopup(Popup):
address_label = StringProperty() address_label = StringProperty()
address = StringProperty() address = StringProperty()
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation def __init__(self, **kwargs):
"""Method used set screen of address detail page.""" """Method used set screen of address detail page."""
# pylint: disable=useless-super-delegation
super(AddbookDetailPopup, self).__init__(**kwargs) super(AddbookDetailPopup, self).__init__(**kwargs)
def set_addbook_data(self, address, label): def set_addbook_data(self, address, label):
@ -1579,8 +1590,9 @@ class AddbookDetailPopup(Popup):
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 \ sqlExecute(
address = '{}';".format(str(self.ids.add_label.text), address)) "UPDATE addressbook SET label = '{}' WHERE"
" address = '{}';".format(str(self.ids.add_label.text), address))
self.parent.children[1].ids.sc11.ids.ml.clear_widgets() self.parent.children[1].ids.sc11.ids.ml.clear_widgets()
self.parent.children[1].ids.sc11.loadAddresslist(None, 'All', '') self.parent.children[1].ids.sc11.loadAddresslist(None, 'All', '')
self.dismiss() self.dismiss()
@ -1591,7 +1603,7 @@ class AddbookDetailPopup(Popup):
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 = ''
window_obj.sc3.children[0].ids.btn.text = '' window_obj.sc3.children[0].ids.btn.text = 'Select'
window_obj.sc3.children[0].ids.subject.text = '' window_obj.sc3.children[0].ids.subject.text = ''
window_obj.sc3.children[0].ids.body.text = '' window_obj.sc3.children[0].ids.body.text = ''
window_obj.scr_mngr.current = 'create' window_obj.scr_mngr.current = 'create'
@ -1712,8 +1724,7 @@ class Draft(Screen):
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str( sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str(
data_index)) data_index))
try: try:
msg_count_objs = \ msg_count_objs = self.parent.parent.parent.parent.children[2].children[0].ids
self.parent.parent.parent.parent.children[2].children[0].ids
except Exception: except Exception:
msg_count_objs = self.parent.parent.parent.parent.parent.children[ msg_count_objs = self.parent.parent.parent.parent.parent.children[
2].children[0].ids 2].children[0].ids
@ -1738,8 +1749,7 @@ class Draft(Screen):
sendMessageToPeople = True sendMessageToPeople = True
if sendMessageToPeople: if sendMessageToPeople:
from addresses import decodeAddress from addresses import decodeAddress
status, addressVersionNumber, streamNumber, ripe = \ status, addressVersionNumber, streamNumber, ripe = decodeAddress(toAddress)
decodeAddress(toAddress)
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red' statusIconColor = 'red'
@ -1809,16 +1819,11 @@ class Allmails(Screen):
def loadMessagelist(self, account, where="", what=""): def loadMessagelist(self, account, where="", what=""):
"""Load Inbox, Sent anf Draft list of messages.""" """Load Inbox, Sent anf Draft list of messages."""
inbox = sqlQuery( all_mails = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder, msgid from\ "SELECT toaddress, fromaddress, subject, message, folder, ackdata As id, DATE(lastactiontime)"
inbox WHERE folder = 'inbox' and toaddress = '{}';".format( " As actionTime FROM sent WHERE folder = 'sent' UNION"
account)) " SELECT toaddress, fromaddress, subject, message, folder, msgid As id, DATE(received) As"
sent_and_draft = sqlQuery( " actionTime FROM inbox WHERE folder = 'inbox' ORDER BY actionTime DESC")
"SELECT toaddress, fromaddress, subject, message, folder, ackdata from sent \
WHERE folder = 'sent' and fromaddress = '{}';".format(
account))
all_mails = inbox + sent_and_draft
if all_mails: if all_mails:
state.kivyapp.root.children[2].children[0].ids.allmail_cnt.badge_text = str(len(all_mails)) state.kivyapp.root.children[2].children[0].ids.allmail_cnt.badge_text = str(len(all_mails))
state.all_count = str(len(all_mails)) state.all_count = str(len(all_mails))

View File

@ -16,8 +16,9 @@ class UIkivySignaler(Thread):
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
label, address, streamNumber = data label, address, streamNumber = data
state.kivyapp.variable_1.append(address) state.kivyapp.variable_1.append(address)
elif command == 'rerenderAddressBook': # elif command == 'rerenderAddressBook':
state.kivyapp.obj_1.refreshs() # state.kivyapp.obj_1.refreshs()
# Need to discuss this
elif command == 'updateSentItemStatusByAckdata': elif command == 'updateSentItemStatusByAckdata':
state.kivyapp.status_dispatching(data) state.kivyapp.status_dispatching(data)

View File

@ -3,7 +3,6 @@ src/paths.py
============ ============
""" """
# pylint: disable=import-error # pylint: disable=import-error
import logging import logging
import os import os
import re import re
@ -12,7 +11,6 @@ from datetime import datetime
from shutil import move from shutil import move
from kivy.utils import platform from kivy.utils import platform
logger = logging.getLogger('default') logger = logging.getLogger('default')
# When using py2exe or py2app, the variable frozen is added to the sys # When using py2exe or py2app, the variable frozen is added to the sys
@ -48,14 +46,13 @@ def lookupAppdataFolder():
dataFolder = os.path.join( dataFolder = os.path.join(
os.environ['HOME'], os.environ['HOME'],
'Library/Application Support/', APPNAME 'Library/Application Support/', APPNAME
) + '/' # FIXME: should also be os.path.sep ) + '/' # ..fixme:: should also be os.path.sep
except KeyError: except KeyError:
sys.exit( sys.exit(
'Could not find home folder, please report this message' 'Could not find home folder, please report this message'
' and your OS X version to the BitMessage Github.') ' and your OS X version to the BitMessage Github.')
elif platform == 'android': elif platform == 'android':
dataFolder = os.path.join( dataFolder = os.path.join(os.environ['ANDROID_PRIVATE'] + '/', APPNAME) + '/'
os.environ['ANDROID_PRIVATE'] + '/', APPNAME) + '/'
elif 'win32' in sys.platform or 'win64' in sys.platform: elif 'win32' in sys.platform or 'win64' in sys.platform:
dataFolder = os.path.join( dataFolder = os.path.join(
os.environ['APPDATA'].decode( os.environ['APPDATA'].decode(
@ -81,6 +78,7 @@ def lookupAppdataFolder():
def codePath(): def codePath():
"""Returns path to the program sources""" """Returns path to the program sources"""
# pylint: disable=protected-access
if not frozen: if not frozen:
return os.path.dirname(__file__) return os.path.dirname(__file__)
return ( return (
@ -97,9 +95,9 @@ def tail(f, lines=20):
block_end_byte = f.tell() block_end_byte = f.tell()
lines_to_go = total_lines_wanted lines_to_go = total_lines_wanted
block_number = -1 block_number = -1
blocks = []
# blocks of size BLOCK_SIZE, in reverse order starting # blocks of size BLOCK_SIZE, in reverse order starting
# from the end of the file # from the end of the file
blocks = []
while lines_to_go > 0 and block_end_byte > 0: while lines_to_go > 0 and block_end_byte > 0:
if block_end_byte - BLOCK_SIZE > 0: if block_end_byte - BLOCK_SIZE > 0:
# read the last block we haven't yet read # read the last block we haven't yet read