Merge pull request #14 from navjotcis/UiChanges
code quality stuff fixes with enhancement in kivy app
This commit is contained in:
commit
137a10ddb3
|
@ -1,24 +1,28 @@
|
||||||
from os import environ
|
"""
|
||||||
from os.path import exists, join
|
src/bitmessagekivy/android/python-for-android/recipes/kivymd/__init__.py
|
||||||
|
=================================
|
||||||
|
"""
|
||||||
|
# pylint: disable=import-error
|
||||||
|
from os.path import join
|
||||||
|
|
||||||
import sh
|
|
||||||
from pythonforandroid.logger import shprint, info_main, info
|
|
||||||
from pythonforandroid.recipe import PythonRecipe
|
from pythonforandroid.recipe import PythonRecipe
|
||||||
# from pythonforandroid.util import ensure_dir
|
# from pythonforandroid.util import ensure_dir
|
||||||
|
|
||||||
|
|
||||||
class KivyMDRecipe(PythonRecipe):
|
class KivyMDRecipe(PythonRecipe):
|
||||||
# This recipe installs KivyMD into the android dist from source
|
"""This recipe installs KivyMD into the android dist from source"""
|
||||||
version = 'master'
|
version = 'master'
|
||||||
url = 'https://github.com/surbhicis/kivymd/archive/master.zip'
|
url = 'https://github.com/surbhicis/kivymd/archive/master.zip'
|
||||||
depends = ['kivy']
|
depends = ['kivy']
|
||||||
site_packages_name = 'kivymd'
|
site_packages_name = 'kivymd'
|
||||||
call_hostpython_via_targetpython = False
|
call_hostpython_via_targetpython = False
|
||||||
|
|
||||||
def should_build(self, arch):
|
def should_build(self, arch): # pylint: disable=no-self-use, unused-argument
|
||||||
|
"""Method helps to build the application"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_recipe_env(self, arch):
|
def get_recipe_env(self, arch):
|
||||||
|
"""Method is used for getting all the env paths"""
|
||||||
env = super(KivyMDRecipe, self).get_recipe_env(arch)
|
env = super(KivyMDRecipe, self).get_recipe_env(arch)
|
||||||
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
|
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
|
||||||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
|
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
|
||||||
|
@ -30,8 +34,7 @@ class KivyMDRecipe(PythonRecipe):
|
||||||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
|
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
|
||||||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
|
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
|
||||||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'),
|
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'),
|
||||||
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
|
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'), ])
|
||||||
])
|
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
src/identiconGeneration.py
|
src/identiconGeneration.py
|
||||||
=================================
|
=================================
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=import-error
|
||||||
import hashlib
|
import hashlib
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from kivy.core.image import Image as CoreImage
|
from kivy.core.image import Image as CoreImage
|
||||||
from kivy.uix.image import Image as kiImage
|
from kivy.uix.image import Image as kiImage
|
||||||
from io import BytesIO
|
|
||||||
""" Core classes for loading images and converting them to a Texture.
|
""" Core classes for loading images and converting them to a Texture.
|
||||||
The raw image data can be keep in memory for further access """
|
The raw image data can be keep in memory for further access """
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
from helper_sql import *
|
"""
|
||||||
|
src/bitmessagekivy/kivy_helper_search.py
|
||||||
|
=================================
|
||||||
|
"""
|
||||||
|
from helper_sql import sqlQuery
|
||||||
|
|
||||||
|
|
||||||
def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, what=None, unreadOnly=False):
|
def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, what=None, unreadOnly=False):
|
||||||
|
"""Method helping for searching mails"""
|
||||||
|
# pylint: disable=too-many-arguments, too-many-branches
|
||||||
if what is not None and what != "":
|
if what is not None and what != "":
|
||||||
what = "%" + what + "%"
|
what = "%" + what + "%"
|
||||||
else:
|
else:
|
||||||
|
@ -9,7 +15,7 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
|
||||||
|
|
||||||
if folder == "sent" or folder == "draft":
|
if folder == "sent" or folder == "draft":
|
||||||
sqlStatementBase = '''
|
sqlStatementBase = '''
|
||||||
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
|
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
|
||||||
FROM sent '''
|
FROM sent '''
|
||||||
elif folder == "addressbook":
|
elif folder == "addressbook":
|
||||||
sqlStatementBase = '''SELECT label, address From addressbook '''
|
sqlStatementBase = '''SELECT label, address From addressbook '''
|
||||||
|
@ -27,7 +33,7 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
|
||||||
else:
|
else:
|
||||||
sqlStatementParts.append(xAddress + " = ? ")
|
sqlStatementParts.append(xAddress + " = ? ")
|
||||||
sqlArguments.append(account)
|
sqlArguments.append(account)
|
||||||
if folder is not "addressbook":
|
if folder != "addressbook":
|
||||||
if folder is not None:
|
if folder is not None:
|
||||||
if folder == "new":
|
if folder == "new":
|
||||||
folder = "inbox"
|
folder = "inbox"
|
||||||
|
@ -50,10 +56,10 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
|
||||||
sqlStatementParts.append(filter_col)
|
sqlStatementParts.append(filter_col)
|
||||||
if unreadOnly:
|
if unreadOnly:
|
||||||
sqlStatementParts.append("read = 0")
|
sqlStatementParts.append("read = 0")
|
||||||
if len(sqlStatementParts) > 0:
|
if sqlStatementParts:
|
||||||
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
|
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
|
||||||
if folder == "sent":
|
if folder == "sent":
|
||||||
sqlStatementBase += " ORDER BY lastactiontime DESC"
|
sqlStatementBase += " ORDER BY lastactiontime DESC"
|
||||||
elif folder == "inbox":
|
elif folder == "inbox":
|
||||||
sqlStatementBase += " ORDER BY received DESC"
|
sqlStatementBase += " ORDER BY received DESC"
|
||||||
return sqlQuery(sqlStatementBase, sqlArguments)
|
return sqlQuery(sqlStatementBase, sqlArguments)
|
||||||
|
|
|
@ -72,9 +72,9 @@
|
||||||
on_text:app.getCurrentAccountData(self.text)
|
on_text:app.getCurrentAccountData(self.text)
|
||||||
Image:
|
Image:
|
||||||
source: app.get_default_image()
|
source: app.get_default_image()
|
||||||
x: self.width/4-2
|
x: self.width/6
|
||||||
y: self.parent.y + self.parent.height/2 - self.height + 14
|
y: self.parent.y + self.parent.height/4
|
||||||
size: 28, 28
|
size: self.parent.height/2, self.parent.height/2
|
||||||
ArrowImg:
|
ArrowImg:
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
id: inbox_cnt
|
id: inbox_cnt
|
||||||
|
@ -82,52 +82,52 @@
|
||||||
text: "Inbox"
|
text: "Inbox"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'inbox'
|
on_release: app.root.ids.scr_mngr.current = 'inbox'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
id: send_cnt
|
id: send_cnt
|
||||||
icon: 'send'
|
icon: 'send'
|
||||||
text: "Sent"
|
text: "Sent"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'sent'
|
on_release: app.root.ids.scr_mngr.current = 'sent'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
id: draft_cnt
|
id: draft_cnt
|
||||||
icon: 'message-draw'
|
icon: 'message-draw'
|
||||||
text: "Draft"
|
text: "Draft"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'draft'
|
on_release: app.root.ids.scr_mngr.current = 'draft'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "Starred"
|
text: "Starred"
|
||||||
icon:'star'
|
icon:'star'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'starred'
|
on_release: app.root.ids.scr_mngr.current = 'starred'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'archive'
|
icon: 'archive'
|
||||||
text: "Archieve"
|
text: "Archieve"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'archieve'
|
on_release: app.root.ids.scr_mngr.current = 'archieve'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'email-open-outline'
|
icon: 'email-open-outline'
|
||||||
text: "Spam"
|
text: "Spam"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'spam'
|
on_release: app.root.ids.scr_mngr.current = 'spam'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
id: trash_cnt
|
id: trash_cnt
|
||||||
icon: 'delete'
|
icon: 'delete'
|
||||||
text: "Trash"
|
text: "Trash"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'trash'
|
on_release: app.root.ids.scr_mngr.current = 'trash'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
id: allmail_cnt
|
id: allmail_cnt
|
||||||
text: "All Mails"
|
text: "All Mails"
|
||||||
icon:'contact-mail'
|
icon:'contact-mail'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'allmails'
|
on_release: app.root.ids.scr_mngr.current = 'allmails'
|
||||||
badge_text: "0"
|
badge_text: "0"
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerDivider:
|
NavigationDrawerDivider:
|
||||||
NavigationDrawerSubheader:
|
NavigationDrawerSubheader:
|
||||||
text: "All labels"
|
text: "All labels"
|
||||||
|
@ -135,37 +135,37 @@
|
||||||
text: "Address Book"
|
text: "Address Book"
|
||||||
icon:'book-multiple'
|
icon:'book-multiple'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'addressbook'
|
on_release: app.root.ids.scr_mngr.current = 'addressbook'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "Settings"
|
text: "Settings"
|
||||||
icon:'settings'
|
icon:'settings'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'set'
|
on_release: app.root.ids.scr_mngr.current = 'set'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "Subscriptions/Payment"
|
text: "Subscriptions/Payment"
|
||||||
icon:'wallet'
|
icon:'wallet'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'payment'
|
on_release: app.root.ids.scr_mngr.current = 'payment'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "Credits"
|
text: "Credits"
|
||||||
icon:'wallet'
|
icon:'wallet'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'credits'
|
on_release: app.root.ids.scr_mngr.current = 'credits'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "new address"
|
text: "new address"
|
||||||
icon:'account-plus'
|
icon:'account-plus'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'login'
|
on_release: app.root.ids.scr_mngr.current = 'login'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "Network Status"
|
text: "Network Status"
|
||||||
icon:'server-network'
|
icon:'server-network'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'networkstat'
|
on_release: app.root.ids.scr_mngr.current = 'networkstat'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "My Addresses"
|
text: "My Addresses"
|
||||||
icon:'account-multiple'
|
icon:'account-multiple'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'myaddress'
|
on_release: app.root.ids.scr_mngr.current = 'myaddress'
|
||||||
on_press: app.check_search_screen(self)
|
on_press: app.refreshScreen(self)
|
||||||
|
|
||||||
NavigationLayout:
|
NavigationLayout:
|
||||||
id: nav_layout
|
id: nav_layout
|
||||||
|
@ -186,18 +186,6 @@ NavigationLayout:
|
||||||
background_hue: '500'
|
background_hue: '500'
|
||||||
left_action_items: [['menu', lambda x: app.root.toggle_nav_drawer()]]
|
left_action_items: [['menu', lambda x: app.root.toggle_nav_drawer()]]
|
||||||
right_action_items: [['account-plus', lambda x: app.addingtoaddressbook()]]
|
right_action_items: [['account-plus', lambda x: app.addingtoaddressbook()]]
|
||||||
BoxLayout:
|
|
||||||
id: search_bar
|
|
||||||
size_hint_y: None
|
|
||||||
height: self.minimum_height
|
|
||||||
|
|
||||||
MDIconButton:
|
|
||||||
icon: 'magnify'
|
|
||||||
|
|
||||||
MDTextField:
|
|
||||||
id: search_field
|
|
||||||
hint_text: 'Search'
|
|
||||||
on_text: app.searchQuery(self)
|
|
||||||
|
|
||||||
ScreenManager:
|
ScreenManager:
|
||||||
id: scr_mngr
|
id: scr_mngr
|
||||||
|
@ -246,21 +234,30 @@ NavigationLayout:
|
||||||
|
|
||||||
<Inbox>:
|
<Inbox>:
|
||||||
name: 'inbox'
|
name: 'inbox'
|
||||||
FloatLayout:
|
BoxLayout:
|
||||||
MDScrollViewRefreshLayout:
|
orientation: 'vertical'
|
||||||
id: refresh_layout
|
spacing: dp(10)
|
||||||
refresh_callback: root.refresh_callback
|
SearchBar:
|
||||||
root_layout: root
|
FloatLayout:
|
||||||
MDList:
|
MDScrollViewRefreshLayout:
|
||||||
id: ml
|
id: refresh_layout
|
||||||
|
refresh_callback: root.refresh_callback
|
||||||
|
root_layout: root
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
ComposerButton:
|
ComposerButton:
|
||||||
|
|
||||||
<Sent>:
|
<Sent>:
|
||||||
name: 'sent'
|
name: 'sent'
|
||||||
ScrollView:
|
BoxLayout:
|
||||||
do_scroll_x: False
|
orientation: 'vertical'
|
||||||
MDList:
|
SearchBar:
|
||||||
id: ml
|
BoxLayout:
|
||||||
|
orientation:'vertical'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
ComposerButton:
|
ComposerButton:
|
||||||
|
|
||||||
<Trash>:
|
<Trash>:
|
||||||
|
@ -654,23 +651,29 @@ NavigationLayout:
|
||||||
|
|
||||||
<MyAddress>:
|
<MyAddress>:
|
||||||
name: 'myaddress'
|
name: 'myaddress'
|
||||||
FloatLayout:
|
BoxLayout:
|
||||||
MDScrollViewRefreshLayout:
|
orientation: 'vertical'
|
||||||
id: refresh_layout
|
SearchBar:
|
||||||
refresh_callback: root.refresh_callback
|
FloatLayout:
|
||||||
root_layout: root
|
MDScrollViewRefreshLayout:
|
||||||
MDList:
|
id: refresh_layout
|
||||||
id: ml
|
refresh_callback: root.refresh_callback
|
||||||
|
root_layout: root
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
ComposerButton:
|
ComposerButton:
|
||||||
|
|
||||||
<AddressBook>:
|
<AddressBook>:
|
||||||
name: 'addressbook'
|
name: 'addressbook'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation:'vertical'
|
orientation: 'vertical'
|
||||||
ScrollView:
|
SearchBar:
|
||||||
do_scroll_x: False
|
BoxLayout:
|
||||||
MDList:
|
orientation:'vertical'
|
||||||
id: ml
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
ComposerButton:
|
ComposerButton:
|
||||||
|
|
||||||
<Payment>:
|
<Payment>:
|
||||||
|
@ -821,11 +824,13 @@ NavigationLayout:
|
||||||
|
|
||||||
<GrashofPopup>:
|
<GrashofPopup>:
|
||||||
id: popup
|
id: popup
|
||||||
|
size_hint : (None,None)
|
||||||
|
height: 2*(label.height + address.height) + 10
|
||||||
|
width :app.window_size[0] - app.window_size[0]/10
|
||||||
title: 'add contact\'s'
|
title: 'add contact\'s'
|
||||||
background: './images/popup.jpeg'
|
background: './images/popup.jpeg'
|
||||||
title_size: sp(20)
|
title_size: sp(20)
|
||||||
title_color: 0.4, 0.3765, 0.3451, 1
|
title_color: 0.4, 0.3765, 0.3451, 1
|
||||||
size_hint: 1, 1
|
|
||||||
auto_dismiss: False
|
auto_dismiss: False
|
||||||
separator_color: 0.3529, 0.3922, 0.102, 0.7
|
separator_color: 0.3529, 0.3922, 0.102, 0.7
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
@ -1050,19 +1055,23 @@ NavigationLayout:
|
||||||
|
|
||||||
<MyaddDetailPopup>:
|
<MyaddDetailPopup>:
|
||||||
id: myadd_popup
|
id: myadd_popup
|
||||||
|
size_hint : (None,None)
|
||||||
|
height: 4.5*(myaddr_label.height+ my_add_btn.children[0].height)
|
||||||
|
width :app.window_size[0] - app.window_size[0]/10
|
||||||
background: './images/popup.jpeg'
|
background: './images/popup.jpeg'
|
||||||
separator_height: 0
|
|
||||||
auto_dismiss: False
|
auto_dismiss: False
|
||||||
|
separator_height: 0
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
id: myadd_popup_box
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
spacing:dp(70)
|
spacing:dp(70)
|
||||||
id: myadd_popup_box
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
spacing:dp(25)
|
spacing:dp(25)
|
||||||
MDLabel:
|
MDLabel:
|
||||||
|
id: myaddr_label
|
||||||
font_style: 'Title'
|
font_style: 'Title'
|
||||||
theme_text_color: 'Primary'
|
theme_text_color: 'Primary'
|
||||||
text: "Label"
|
text: "Label"
|
||||||
|
@ -1087,6 +1096,7 @@ NavigationLayout:
|
||||||
font_size: '15sp'
|
font_size: '15sp'
|
||||||
halign: 'left'
|
halign: 'left'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
id: my_add_btn
|
||||||
spacing:5
|
spacing:5
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
MDRaisedButton:
|
MDRaisedButton:
|
||||||
|
@ -1125,6 +1135,9 @@ NavigationLayout:
|
||||||
|
|
||||||
<AddbookDetailPopup>:
|
<AddbookDetailPopup>:
|
||||||
id: addbook_popup
|
id: addbook_popup
|
||||||
|
size_hint : (None,None)
|
||||||
|
height: 4*(add_label.height)
|
||||||
|
width :app.window_size[0] - app.window_size[0]/10
|
||||||
background: './images/popup.jpeg'
|
background: './images/popup.jpeg'
|
||||||
separator_height: 0
|
separator_height: 0
|
||||||
auto_dismiss: False
|
auto_dismiss: False
|
||||||
|
@ -1165,6 +1178,7 @@ NavigationLayout:
|
||||||
font_size: '15sp'
|
font_size: '15sp'
|
||||||
halign: 'left'
|
halign: 'left'
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
id: addbook_btn
|
||||||
spacing:5
|
spacing:5
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
MDRaisedButton:
|
MDRaisedButton:
|
||||||
|
@ -1211,4 +1225,18 @@ NavigationLayout:
|
||||||
source: './images/down-arrow.png' if self.parent.is_open == True else './images/right-arrow.png'
|
source: './images/down-arrow.png' if self.parent.is_open == True else './images/right-arrow.png'
|
||||||
size: 15, 15
|
size: 15, 15
|
||||||
x: self.parent.x + self.parent.width - self.width - 5
|
x: self.parent.x + self.parent.width - self.width - 5
|
||||||
y: self.parent.y + self.parent.height/2 - self.height + 5
|
y: self.parent.y + self.parent.height/2 - self.height + 5
|
||||||
|
|
||||||
|
|
||||||
|
<SearchBar@BoxLayout>:
|
||||||
|
id: search_bar
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
|
||||||
|
MDIconButton:
|
||||||
|
icon: 'magnify'
|
||||||
|
|
||||||
|
MDTextField:
|
||||||
|
id: search_field
|
||||||
|
hint_text: 'Search'
|
||||||
|
on_text: app.searchQuery(self)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
src/bitmessagekivy/mpybit.py
|
src/bitmessagekivy/mpybit.py
|
||||||
=================================
|
=================================
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=relative-import, unused-variable, import-error, no-name-in-module, too-many-lines
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
@ -42,24 +43,19 @@ from kivymd.list import (
|
||||||
ILeftBody,
|
ILeftBody,
|
||||||
ILeftBodyTouch,
|
ILeftBodyTouch,
|
||||||
IRightBodyTouch,
|
IRightBodyTouch,
|
||||||
ThreeLineAvatarIconListItem,
|
|
||||||
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.textfields import MDTextField
|
|
||||||
from kivymd.theming import ThemeManager
|
from kivymd.theming import ThemeManager
|
||||||
import queues
|
import queues
|
||||||
from semaphores import kivyuisignaler
|
from semaphores import kivyuisignaler
|
||||||
import state
|
import state
|
||||||
from uikivysignaler import UIkivySignaler
|
from uikivysignaler import UIkivySignaler
|
||||||
# pylint: disable=unused-argument, too-few-public-methods, import-error
|
|
||||||
|
|
||||||
import identiconGeneration
|
import identiconGeneration
|
||||||
import os
|
|
||||||
from kivy.core.clipboard import Clipboard
|
|
||||||
# pylint: disable=unused-argument, too-few-public-methods
|
# pylint: disable=unused-argument, too-few-public-methods
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,8 +78,6 @@ 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()
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Method Parsing the address."""
|
"""Method Parsing the address."""
|
||||||
super(Inbox, self).__init__(*args, **kwargs)
|
super(Inbox, self).__init__(*args, **kwargs)
|
||||||
|
@ -171,7 +165,6 @@ class Inbox(Screen):
|
||||||
|
|
||||||
def inbox_detail(self, receivedTime, *args):
|
def inbox_detail(self, receivedTime, *args):
|
||||||
"""Load inbox page details."""
|
"""Load inbox page details."""
|
||||||
remove_search_bar(self)
|
|
||||||
state.detailPageType = 'inbox'
|
state.detailPageType = 'inbox'
|
||||||
state.sentMailTime = receivedTime
|
state.sentMailTime = receivedTime
|
||||||
if self.manager:
|
if self.manager:
|
||||||
|
@ -187,8 +180,12 @@ class Inbox(Screen):
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
"UPDATE inbox SET folder = 'trash' WHERE received = {};".format(
|
"UPDATE inbox SET folder = 'trash' WHERE received = {};".format(
|
||||||
data_index))
|
data_index))
|
||||||
msg_count_objs = \
|
try:
|
||||||
self.parent.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:
|
||||||
|
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)
|
||||||
|
@ -229,13 +226,10 @@ class Inbox(Screen):
|
||||||
"""Method updates the state of application, While the spinner remains on the screen."""
|
"""Method updates the state of application, While the spinner remains on the screen."""
|
||||||
def refresh_callback(interval):
|
def refresh_callback(interval):
|
||||||
"""Method used for loading the inbox screen data."""
|
"""Method used for loading the inbox screen data."""
|
||||||
|
state.searcing_text = ''
|
||||||
|
self.children[2].children[1].ids.search_field.text = ''
|
||||||
self.ids.ml.clear_widgets()
|
self.ids.ml.clear_widgets()
|
||||||
self.remove_widget(self.children[1])
|
self.loadMessagelist(state.association)
|
||||||
try:
|
|
||||||
screens_obj = self.parent.screens[0]
|
|
||||||
except Exception:
|
|
||||||
screens_obj = self.parent.parent.screens[0]
|
|
||||||
screens_obj.add_widget(Inbox())
|
|
||||||
self.ids.refresh_layout.refresh_done()
|
self.ids.refresh_layout.refresh_done()
|
||||||
self.tick = 0
|
self.tick = 0
|
||||||
|
|
||||||
|
@ -287,12 +281,11 @@ class MyAddress(Screen):
|
||||||
size_hint_y=None,
|
size_hint_y=None,
|
||||||
valign='top')
|
valign='top')
|
||||||
self.ids.ml.add_widget(content)
|
self.ids.ml.add_widget(content)
|
||||||
try:
|
if not state.searcing_text:
|
||||||
self.manager.parent.parent\
|
try:
|
||||||
.parent.ids.search_bar.clear_widgets()
|
self.manager.current = 'login'
|
||||||
self.manager.current = 'login'
|
except Exception:
|
||||||
except Exception:
|
pass
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def myadd_detail(fromaddress, label, *args):
|
def myadd_detail(fromaddress, label, *args):
|
||||||
|
@ -306,13 +299,10 @@ class MyAddress(Screen):
|
||||||
"""Method updates the state of application, While the spinner remains on the screen."""
|
"""Method updates the state of application, While the spinner remains on the screen."""
|
||||||
def refresh_callback(interval):
|
def refresh_callback(interval):
|
||||||
"""Method used for loading the myaddress screen data."""
|
"""Method used for loading the myaddress screen data."""
|
||||||
|
state.searcing_text = ''
|
||||||
|
self.children[2].children[1].ids.search_field.text = ''
|
||||||
self.ids.ml.clear_widgets()
|
self.ids.ml.clear_widgets()
|
||||||
self.remove_widget(self.children[1])
|
self.init_ui()
|
||||||
try:
|
|
||||||
screens_obj = self.parent.screens[9]
|
|
||||||
except Exception:
|
|
||||||
screens_obj = self.parent.parent.screens[9]
|
|
||||||
screens_obj.add_widget(MyAddress())
|
|
||||||
self.ids.refresh_layout.refresh_done()
|
self.ids.refresh_layout.refresh_done()
|
||||||
self.tick = 0
|
self.tick = 0
|
||||||
Clock.schedule_once(refresh_callback, 1)
|
Clock.schedule_once(refresh_callback, 1)
|
||||||
|
@ -389,8 +379,8 @@ class AddressBook(Screen):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def refreshs(*args):
|
def refreshs(*args):
|
||||||
"""Refresh the Widget."""
|
"""Refresh the Widget."""
|
||||||
state.navinstance.ids.sc11.clear_widgets()
|
state.navinstance.ids.sc11.ids.ml.clear_widgets()
|
||||||
state.navinstance.ids.sc11.add_widget(AddressBook())
|
state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addBook_detail(address, label, *args):
|
def addBook_detail(address, label, *args):
|
||||||
|
@ -526,8 +516,8 @@ class DropDownWidget(BoxLayout):
|
||||||
state.check_sent_acc = fromAddress
|
state.check_sent_acc = fromAddress
|
||||||
state.msg_counter_objs = self.parent.parent.parent.parent\
|
state.msg_counter_objs = self.parent.parent.parent.parent\
|
||||||
.parent.parent.children[0].children[2].children[0].ids
|
.parent.parent.children[0].children[2].children[0].ids
|
||||||
self.parent.parent.screens[3].clear_widgets()
|
self.parent.parent.screens[3].ids.ml.clear_widgets()
|
||||||
self.parent.parent.screens[3].add_widget(Sent())
|
self.parent.parent.screens[3].loadSent(state.association)
|
||||||
self.parent.parent.screens[16].clear_widgets()
|
self.parent.parent.screens[16].clear_widgets()
|
||||||
self.parent.parent.screens[16].add_widget(Allmails())
|
self.parent.parent.screens[16].add_widget(Allmails())
|
||||||
toLabel = ''
|
toLabel = ''
|
||||||
|
@ -704,9 +694,8 @@ class Random(Screen):
|
||||||
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
|
||||||
self.parent.parent.parent.parent.ids.sc10.clear_widgets()
|
self.parent.parent.parent.parent.ids.sc10.ids.ml.clear_widgets()
|
||||||
self.parent.parent.parent.parent.ids.sc10.add_widget(MyAddress())
|
self.parent.parent.parent.parent.ids.sc10.init_ui()
|
||||||
navApp.add_search_bar()
|
|
||||||
toast('New address created')
|
toast('New address created')
|
||||||
|
|
||||||
|
|
||||||
|
@ -718,9 +707,6 @@ class AddressSuccessful(Screen):
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Association with the screen."""
|
"""Association with the screen."""
|
||||||
super(Sent, self).__init__(*args, **kwargs)
|
super(Sent, self).__init__(*args, **kwargs)
|
||||||
|
@ -745,6 +731,7 @@ class Sent(Screen):
|
||||||
where = ['subject', 'message']
|
where = ['subject', 'message']
|
||||||
what = state.searcing_text
|
what = state.searcing_text
|
||||||
xAddress = 'fromaddress'
|
xAddress = 'fromaddress'
|
||||||
|
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 == \
|
||||||
|
@ -760,13 +747,13 @@ class Sent(Screen):
|
||||||
src_mng_obj.send_cnt.badge_text = str(len(queryreturn))
|
src_mng_obj.send_cnt.badge_text = str(len(queryreturn))
|
||||||
state.sent_count = str(len(queryreturn))
|
state.sent_count = str(len(queryreturn))
|
||||||
for mail in queryreturn:
|
for mail in queryreturn:
|
||||||
self.data.append({
|
data.append({
|
||||||
'text': mail[1].strip(),
|
'text': mail[1].strip(),
|
||||||
'secondary_text': mail[2][:50] + '........' if len(
|
'secondary_text': mail[2][:50] + '........' if len(
|
||||||
mail[2]) >= 50 else (
|
mail[2]) >= 50 else (
|
||||||
mail[2] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
|
mail[2] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
|
||||||
'lastactiontime': mail[6]})
|
'lastactiontime': mail[6]})
|
||||||
for item in self.data:
|
for item in data:
|
||||||
meny = TwoLineAvatarIconListItem(
|
meny = TwoLineAvatarIconListItem(
|
||||||
text=item['text'],
|
text=item['text'],
|
||||||
secondary_text=item['secondary_text'],
|
secondary_text=item['secondary_text'],
|
||||||
|
@ -811,7 +798,6 @@ class Sent(Screen):
|
||||||
|
|
||||||
def sent_detail(self, lastsenttime, *args):
|
def sent_detail(self, lastsenttime, *args):
|
||||||
"""Load sent mail details."""
|
"""Load sent mail details."""
|
||||||
remove_search_bar(self)
|
|
||||||
state.detailPageType = 'sent'
|
state.detailPageType = 'sent'
|
||||||
state.sentMailTime = lastsenttime
|
state.sentMailTime = lastsenttime
|
||||||
if self.manager:
|
if self.manager:
|
||||||
|
@ -1034,16 +1020,9 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
BMConfigParser().get(text, 'label'), text)
|
BMConfigParser().get(text, 'label'), text)
|
||||||
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()
|
state.searcing_text = ''
|
||||||
self.root.ids.sc1.add_widget(Inbox())
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
# self.root.ids.sc4.clear_widgets()
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
# self.root.ids.sc5.clear_widgets()
|
|
||||||
# self.root.ids.sc16.clear_widgets()
|
|
||||||
# self.root.ids.sc17.clear_widgets()
|
|
||||||
# self.root.ids.sc4.add_widget(Sent())
|
|
||||||
# self.root.ids.sc5.add_widget(Trash())
|
|
||||||
# self.root.ids.sc16.add_widget(Draft())
|
|
||||||
# self.root.ids.sc17.add_widget(Allmails())
|
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
|
|
||||||
msg_counter_objs = \
|
msg_counter_objs = \
|
||||||
|
@ -1091,7 +1070,13 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
|
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
|
||||||
self.createFolder('./images/default_identicon/')
|
self.createFolder('./images/default_identicon/')
|
||||||
img.texture.save('./images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0]))
|
if platform == 'android':
|
||||||
|
# android_path = os.path.expanduser("~/user/0/org.test.bitapp/files/app/")
|
||||||
|
android_path = os.path.join(os.environ['ANDROID_PRIVATE'] + '/app/')
|
||||||
|
img.texture.save('{1}/images/default_identicon/{0}.png'.format(
|
||||||
|
BMConfigParser().addresses()[0], android_path))
|
||||||
|
else:
|
||||||
|
img.texture.save('./images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0]))
|
||||||
return BMConfigParser().addresses()[0]
|
return BMConfigParser().addresses()[0]
|
||||||
return 'Select Address'
|
return 'Select Address'
|
||||||
|
|
||||||
|
@ -1125,8 +1110,6 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
self.root.ids.scr_mngr.current = 'sent'\
|
self.root.ids.scr_mngr.current = 'sent'\
|
||||||
if state.detailPageType == 'sent' else 'inbox' \
|
if state.detailPageType == 'sent' else 'inbox' \
|
||||||
if state.detailPageType == 'inbox' else 'draft'
|
if state.detailPageType == 'inbox' else 'draft'
|
||||||
# if state.detailPageType in ['sent', 'inbox']:
|
|
||||||
# self.add_search_bar()
|
|
||||||
self.back_press()
|
self.back_press()
|
||||||
elif self.root.ids.scr_mngr.current == "create":
|
elif self.root.ids.scr_mngr.current == "create":
|
||||||
composer_objs = self.root
|
composer_objs = self.root
|
||||||
|
@ -1142,7 +1125,6 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
self.root.ids.scr_mngr.current = 'login'
|
self.root.ids.scr_mngr.current = 'login'
|
||||||
else:
|
else:
|
||||||
self.root.ids.scr_mngr.current = 'inbox'
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
self.add_search_bar()
|
|
||||||
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)
|
||||||
return True
|
return True
|
||||||
|
@ -1162,7 +1144,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
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.set_navbar_for_composer()
|
self.set_navbar_for_composer()
|
||||||
self.root.ids.search_bar.clear_widgets()
|
# self.root.ids.search_bar.clear_widgets()
|
||||||
composer_obj = self.root.ids.sc3.children[0].ids
|
composer_obj = self.root.ids.sc3.children[0].ids
|
||||||
composer_obj.ti.text = ''
|
composer_obj.ti.text = ''
|
||||||
composer_obj.btn.text = 'Select'
|
composer_obj.btn.text = 'Select'
|
||||||
|
@ -1190,8 +1172,6 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
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':
|
||||||
state.is_allmail = False
|
state.is_allmail = False
|
||||||
else:
|
|
||||||
self.add_search_bar()
|
|
||||||
state.detailPageType = ''
|
state.detailPageType = ''
|
||||||
state.in_composer = False
|
state.in_composer = False
|
||||||
|
|
||||||
|
@ -1218,66 +1198,60 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
return label + address
|
return label + address
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def searchQuery(self, instance, *args):
|
def searchQuery(self, instance):
|
||||||
"""Method used for showing searched mails."""
|
"""Method used for showing searched mails."""
|
||||||
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':
|
||||||
self.root.ids.sc1.clear_widgets()
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc1.add_widget(Inbox())
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
elif state.search_screen == 'addressbook':
|
elif state.search_screen == 'addressbook':
|
||||||
self.root.ids.sc11.clear_widgets()
|
self.root.ids.sc11.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc11.add_widget(AddressBook())
|
self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
elif state.search_screen == 'myaddress':
|
elif state.search_screen == 'myaddress':
|
||||||
self.root.ids.sc10.clear_widgets()
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc10.add_widget(MyAddress())
|
self.root.ids.sc10.init_ui()
|
||||||
else:
|
else:
|
||||||
self.root.ids.sc4.clear_widgets()
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
self.root.ids.sc4.add_widget(Sent())
|
self.root.ids.sc4.loadSent(state.association)
|
||||||
self.root.ids.scr_mngr.current = state.search_screen
|
self.root.ids.scr_mngr.current = state.search_screen
|
||||||
|
|
||||||
def clearSreeen(self, text):
|
def refreshScreen(self, instance):
|
||||||
"""Method is used for clear screen"""
|
"""Method show search button only on inbox or sent screen."""
|
||||||
if text == 'Sent':
|
state.searcing_text = ''
|
||||||
self.root.ids.sc4.clear_widgets()
|
if instance.text == 'Sent':
|
||||||
self.root.ids.sc4.add_widget(Sent())
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
elif text == 'Draft':
|
self.root.ids.sc4.children[1].children[1].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc4.loadSent(state.association)
|
||||||
|
elif instance.text == 'Inbox':
|
||||||
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
|
try:
|
||||||
|
self.root.ids.sc1.children[2].children[1].ids.search_field.text = ''
|
||||||
|
except Exception as e:
|
||||||
|
self.root.ids.sc1.children[1].children[1].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
|
elif instance.text == 'Draft':
|
||||||
self.root.ids.sc16.clear_widgets()
|
self.root.ids.sc16.clear_widgets()
|
||||||
self.root.ids.sc16.add_widget(Draft())
|
self.root.ids.sc16.add_widget(Draft())
|
||||||
elif text == 'Trash':
|
elif instance.text == 'Trash':
|
||||||
self.root.ids.sc5.clear_widgets()
|
self.root.ids.sc5.clear_widgets()
|
||||||
self.root.ids.sc5.add_widget(Trash())
|
self.root.ids.sc5.add_widget(Trash())
|
||||||
elif text == 'All Mails':
|
elif instance.text == 'All Mails':
|
||||||
self.root.ids.sc17.clear_widgets()
|
self.root.ids.sc17.clear_widgets()
|
||||||
self.root.ids.sc17.add_widget(Allmails())
|
self.root.ids.sc17.add_widget(Allmails())
|
||||||
|
elif instance.text == 'Address Book':
|
||||||
def check_search_screen(self, instance):
|
self.root.ids.sc11.ids.ml.clear_widgets()
|
||||||
"""Method show search button only on inbox or sent screen."""
|
self.root.ids.sc11.children[1].children[1].ids.search_field.text = ''
|
||||||
if instance.text in ['Sent', 'Draft', 'Trash', 'All Mails']:
|
self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
self.clearSreeen(instance.text)
|
elif instance.text == 'My Addresses':
|
||||||
if instance.text in ['Inbox', 'Sent', 'Address Book', 'My Addresses']:
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
if not self.root.ids.search_bar.children:
|
try:
|
||||||
self.root.ids.search_bar.add_widget(
|
self.root.ids.sc10.children[1].children[1].ids.search_field.text = ''
|
||||||
MDIconButton(icon='magnify'))
|
except Exception as e:
|
||||||
text_field = MDTextField(
|
self.root.ids.sc10.children[2].children[1].ids.search_field.text = ''
|
||||||
id='search_field', hint_text='Search')
|
self.root.ids.sc10.init_ui()
|
||||||
text_field.bind(text=self.searchQuery)
|
|
||||||
self.root.ids.search_bar.add_widget(text_field)
|
|
||||||
self.root.ids.search_bar.children[0].text = ''
|
|
||||||
else:
|
|
||||||
self.root.ids.search_bar.clear_widgets()
|
|
||||||
state.searcing_text = ''
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_search_bar(self):
|
|
||||||
"""Method used for adding search function on screen"""
|
|
||||||
if not self.root.ids.search_bar.children:
|
|
||||||
self.root.ids.search_bar.add_widget(MDIconButton(icon='magnify'))
|
|
||||||
text_field = MDTextField(
|
|
||||||
id='search_field', hint_text='Search')
|
|
||||||
text_field.bind(text=self.searchQuery)
|
|
||||||
self.root.ids.search_bar.add_widget(text_field)
|
|
||||||
|
|
||||||
def set_identicon(self, text):
|
def set_identicon(self, text):
|
||||||
"""This method is use for showing identicon in address spinner"""
|
"""This method is use for showing identicon in address spinner"""
|
||||||
img = identiconGeneration.generate(text)
|
img = identiconGeneration.generate(text)
|
||||||
|
@ -1306,16 +1280,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):
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
"""Grash of pop screen settings."""
|
"""Grash of pop screen settings."""
|
||||||
super(GrashofPopup, self).__init__(**kwargs)
|
super(GrashofPopup, self).__init__(**kwargs)
|
||||||
print("sssssssssssssssssssiiiiiiiiiiiiiiizzzzzzzzzzeeeeee...............", state.screen_density)
|
|
||||||
if state.screen_density[0] <= 720:
|
|
||||||
self.size_hint_y = 0.4
|
|
||||||
self.size_hint_x = 0.9
|
|
||||||
else:
|
|
||||||
self.size_hint_y = 0.42
|
|
||||||
self.size_hint_x = 0.7
|
|
||||||
|
|
||||||
def savecontact(self):
|
def savecontact(self):
|
||||||
"""Method is used for Saving Contacts."""
|
"""Method is used for Saving Contacts."""
|
||||||
|
@ -1430,7 +1397,7 @@ class NavigationDrawerTwoLineListItem(
|
||||||
def _update_specific_text_color(self, instance, value):
|
def _update_specific_text_color(self, instance, value):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _set_active(self, active, list): # pylint: disable=redefined-builtin
|
def _set_active(self, active, list_):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -1491,17 +1458,17 @@ class MailDetail(Screen):
|
||||||
lastactiontime = {};".format(state.sentMailTime))
|
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.screens[3].clear_widgets()
|
self.parent.screens[3].ids.ml.clear_widgets()
|
||||||
self.parent.screens[3].add_widget(Sent())
|
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 \
|
||||||
received = {};".format(state.sentMailTime))
|
received = {};".format(state.sentMailTime))
|
||||||
# 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)
|
||||||
# state.inbox_count = str(int(state.inbox_count) - 1)
|
# state.inbox_count = str(int(state.inbox_count) - 1)
|
||||||
self.parent.screens[0].clear_widgets()
|
self.parent.screens[0].ids.ml.clear_widgets()
|
||||||
self.parent.screens[0].add_widget(Inbox())
|
self.parent.screens[0].loadMessagelist(state.association)
|
||||||
elif state.detailPageType == 'draft':
|
elif state.detailPageType == 'draft':
|
||||||
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
|
sqlExecute("DELETE FROM sent WHERE lastactiontime = '{}';".format(
|
||||||
state.sentMailTime))
|
state.sentMailTime))
|
||||||
|
@ -1533,6 +1500,7 @@ class MailDetail(Screen):
|
||||||
composer_obj.btn.text = data[0][0]
|
composer_obj.btn.text = data[0][0]
|
||||||
composer_obj.txt_input.text = data[0][1]
|
composer_obj.txt_input.text = data[0][1]
|
||||||
composer_obj.subject.text = data[0][2]
|
composer_obj.subject.text = data[0][2]
|
||||||
|
composer_obj.body.text = ''
|
||||||
state.kivyapp.root.ids.sc3.children[0].ids.rv.data = ''
|
state.kivyapp.root.ids.sc3.children[0].ids.rv.data = ''
|
||||||
self.parent.current = 'create'
|
self.parent.current = 'create'
|
||||||
state.kivyapp.set_navbar_for_composer()
|
state.kivyapp.set_navbar_for_composer()
|
||||||
|
@ -1571,15 +1539,9 @@ class MyaddDetailPopup(Popup):
|
||||||
address_label = StringProperty()
|
address_label = StringProperty()
|
||||||
address = StringProperty()
|
address = StringProperty()
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
"""My Address Details screen setting."""
|
"""My Address Details screen setting."""
|
||||||
super(MyaddDetailPopup, self).__init__(**kwargs)
|
super(MyaddDetailPopup, self).__init__(**kwargs)
|
||||||
if state.screen_density[0] <= 720:
|
|
||||||
self.size_hint_y = 0.32
|
|
||||||
self.size_hint_x = 0.9
|
|
||||||
else:
|
|
||||||
self.size_hint_y = 0.32
|
|
||||||
self.size_hint_x = 0.7
|
|
||||||
|
|
||||||
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."""
|
||||||
|
@ -1609,15 +1571,9 @@ class AddbookDetailPopup(Popup):
|
||||||
address_label = StringProperty()
|
address_label = StringProperty()
|
||||||
address = StringProperty()
|
address = StringProperty()
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
"""Method used set screen of address detail page."""
|
"""Method used set screen of address detail page."""
|
||||||
super(AddbookDetailPopup, self).__init__(**kwargs)
|
super(AddbookDetailPopup, self).__init__(**kwargs)
|
||||||
if state.screen_density[0] <= 720:
|
|
||||||
self.size_hint_y = 0.35
|
|
||||||
self.size_hint_x = 0.95
|
|
||||||
else:
|
|
||||||
self.size_hint_y = 0.35
|
|
||||||
self.size_hint_x = 0.7
|
|
||||||
|
|
||||||
def set_addbook_data(self, address, label):
|
def set_addbook_data(self, address, label):
|
||||||
"""Getting address book data for detial dipaly."""
|
"""Getting address book data for detial dipaly."""
|
||||||
|
@ -1629,8 +1585,8 @@ class AddbookDetailPopup(Popup):
|
||||||
if str(self.ids.add_label.text):
|
if str(self.ids.add_label.text):
|
||||||
sqlExecute("UPDATE addressbook SET label = '{}' WHERE \
|
sqlExecute("UPDATE addressbook SET label = '{}' WHERE \
|
||||||
address = '{}';".format(str(self.ids.add_label.text), address))
|
address = '{}';".format(str(self.ids.add_label.text), address))
|
||||||
self.parent.children[1].ids.sc11.clear_widgets()
|
self.parent.children[1].ids.sc11.ids.ml.clear_widgets()
|
||||||
self.parent.children[1].ids.sc11.add_widget(AddressBook())
|
self.parent.children[1].ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
self.dismiss()
|
self.dismiss()
|
||||||
toast('Saved')
|
toast('Saved')
|
||||||
|
|
||||||
|
@ -1656,7 +1612,7 @@ class ShowQRCode(Screen):
|
||||||
|
|
||||||
def qrdisplay(self):
|
def qrdisplay(self):
|
||||||
"""Method used for showing QR Code."""
|
"""Method used for showing QR Code."""
|
||||||
self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
|
# self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
|
||||||
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(
|
self.ids.qr.add_widget(QRCodeWidget(
|
||||||
|
@ -1685,19 +1641,15 @@ class Draft(Screen):
|
||||||
def sentaccounts(self):
|
def sentaccounts(self):
|
||||||
"""Load draft accounts."""
|
"""Load draft accounts."""
|
||||||
account = state.association
|
account = state.association
|
||||||
self.loadSent(account, 'All', '')
|
self.loadDraft(account, 'All', '')
|
||||||
|
|
||||||
def loadSent(self, account, where="", what=""):
|
def loadDraft(self, account, where="", what=""):
|
||||||
"""Load draft list for Draft messages."""
|
"""Load draft list for Draft messages."""
|
||||||
xAddress = 'fromaddress'
|
xAddress = 'fromaddress'
|
||||||
queryreturn = kivy_helper_search.search_sql(
|
queryreturn = kivy_helper_search.search_sql(
|
||||||
xAddress, account, "draft", where, what, False)
|
xAddress, account, "draft", where, what, False)
|
||||||
if state.msg_counter_objs:
|
if state.msg_counter_objs:
|
||||||
state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn))
|
state.msg_counter_objs.draft_cnt.badge_text = str(len(queryreturn))
|
||||||
# state.all_count = str(int(state.all_count) + 1)
|
|
||||||
# state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
|
||||||
# state.msg_counter_objs = None
|
|
||||||
|
|
||||||
if queryreturn:
|
if queryreturn:
|
||||||
src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
||||||
src_mng_obj.draft_cnt.badge_text = str(len(queryreturn))
|
src_mng_obj.draft_cnt.badge_text = str(len(queryreturn))
|
||||||
|
@ -1772,13 +1724,7 @@ class Draft(Screen):
|
||||||
if int(state.draft_count) > 0:
|
if int(state.draft_count) > 0:
|
||||||
msg_count_objs.draft_cnt.badge_text = str(
|
msg_count_objs.draft_cnt.badge_text = str(
|
||||||
int(state.draft_count) - 1)
|
int(state.draft_count) - 1)
|
||||||
# msg_count_objs.allmail_cnt.badge_text = str(
|
|
||||||
# int(state.all_count) - 1)
|
|
||||||
# msg_count_objs.trash_cnt.badge_text = str(
|
|
||||||
# int(state.trash_count) + 1)
|
|
||||||
state.draft_count = str(int(state.draft_count) - 1)
|
state.draft_count = str(int(state.draft_count) - 1)
|
||||||
# state.all_count = str(int(state.all_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)
|
||||||
toast('Deleted')
|
toast('Deleted')
|
||||||
|
|
||||||
|
@ -1840,19 +1786,9 @@ class CustomSpinner(Spinner):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Method 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_value = 2.8
|
|
||||||
# self.dropdown_cls.max_height = self.height / 2 * max_value + max_value * 4
|
|
||||||
self.dropdown_cls.max_height = Window.size[1] / 3
|
self.dropdown_cls.max_height = Window.size[1] / 3
|
||||||
|
|
||||||
|
|
||||||
def remove_search_bar(obj):
|
|
||||||
"""Remove search bar."""
|
|
||||||
try:
|
|
||||||
obj.parent.parent.parent.parent.parent.ids.search_bar.clear_widgets()
|
|
||||||
except Exception:
|
|
||||||
obj.parent.parent.parent.parent.ids.search_bar.clear_widgets()
|
|
||||||
|
|
||||||
|
|
||||||
class Allmails(Screen):
|
class Allmails(Screen):
|
||||||
"""all mails Screen uses screen to show widgets of screens."""
|
"""all mails Screen uses screen to show widgets of screens."""
|
||||||
|
|
||||||
|
@ -1932,7 +1868,6 @@ class Allmails(Screen):
|
||||||
|
|
||||||
def mail_detail(self, unique_id, folder, *args):
|
def mail_detail(self, unique_id, folder, *args):
|
||||||
"""Load sent and inbox mail details."""
|
"""Load sent and inbox mail details."""
|
||||||
remove_search_bar(self)
|
|
||||||
state.detailPageType = folder
|
state.detailPageType = folder
|
||||||
state.is_allmail = True
|
state.is_allmail = True
|
||||||
state.sentMailTime = unique_id
|
state.sentMailTime = unique_id
|
||||||
|
@ -1967,14 +1902,14 @@ class Allmails(Screen):
|
||||||
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)
|
||||||
state.inbox_count = str(int(state.inbox_count) - 1)
|
state.inbox_count = str(int(state.inbox_count) - 1)
|
||||||
nav_lay_obj.sc1.clear_widgets()
|
nav_lay_obj.sc1.ids.ml.clear_widgets()
|
||||||
nav_lay_obj.sc1.add_widget(Inbox())
|
nav_lay_obj.sc1.loadMessagelist(state.association)
|
||||||
else:
|
else:
|
||||||
msg_count_objs.send_cnt.badge_text = str(
|
msg_count_objs.send_cnt.badge_text = str(
|
||||||
int(state.sent_count) - 1)
|
int(state.sent_count) - 1)
|
||||||
state.sent_count = str(int(state.sent_count) - 1)
|
state.sent_count = str(int(state.sent_count) - 1)
|
||||||
nav_lay_obj.sc4.clear_widgets()
|
nav_lay_obj.sc4.ids.ml.clear_widgets()
|
||||||
nav_lay_obj.sc4.add_widget(Sent())
|
nav_lay_obj.sc4.loadSent(state.association)
|
||||||
msg_count_objs.trash_cnt.badge_text = str(
|
msg_count_objs.trash_cnt.badge_text = str(
|
||||||
int(state.trash_count) + 1)
|
int(state.trash_count) + 1)
|
||||||
msg_count_objs.allmail_cnt.badge_text = str(
|
msg_count_objs.allmail_cnt.badge_text = str(
|
||||||
|
@ -2026,7 +1961,8 @@ class Archieve(Screen):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Spam(Screen):
|
class Spam(Screen):
|
||||||
"""Spam Screen show widgets of page."""
|
"""Spam Screen show widgets of page."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -17,11 +17,11 @@ resends getpubkey messages in 5 days (then 10 days, then 20 days, etc...)
|
||||||
resends msg messages in 5 days (then 10 days, then 20 days, etc...)
|
resends msg messages in 5 days (then 10 days, then 20 days, etc...)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=relative-import, protected-access
|
||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
import shared
|
|
||||||
import time
|
import time
|
||||||
|
import shared
|
||||||
|
|
||||||
import tr
|
import tr
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
|
@ -36,11 +36,12 @@ import state
|
||||||
|
|
||||||
|
|
||||||
class singleCleaner(StoppableThread):
|
class singleCleaner(StoppableThread):
|
||||||
|
"""Base method that Cleanup knownnodes and handle possible severe exception"""
|
||||||
name = "singleCleaner"
|
name = "singleCleaner"
|
||||||
cycleLength = 300
|
cycleLength = 300
|
||||||
expireDiscoveredPeers = 300
|
expireDiscoveredPeers = 300
|
||||||
|
|
||||||
def run(self):
|
def run(self): # pylint: disable=too-many-branches
|
||||||
gc.disable()
|
gc.disable()
|
||||||
timeWeLastClearedInventoryAndPubkeysTables = 0
|
timeWeLastClearedInventoryAndPubkeysTables = 0
|
||||||
try:
|
try:
|
||||||
|
@ -73,7 +74,7 @@ class singleCleaner(StoppableThread):
|
||||||
# If we are running as a daemon then we are going to fill up the UI
|
# If we are running as a daemon then we are going to fill up the UI
|
||||||
# queue which will never be handled by a UI. We should clear it to
|
# queue which will never be handled by a UI. We should clear it to
|
||||||
# save memory.
|
# save memory.
|
||||||
# FIXME redundant?
|
# ..FIXME redundant?
|
||||||
if shared.thisapp.daemon or not state.enableGUI:
|
if shared.thisapp.daemon or not state.enableGUI:
|
||||||
queues.UISignalQueue.queue.clear()
|
queues.UISignalQueue.queue.clear()
|
||||||
if timeWeLastClearedInventoryAndPubkeysTables < \
|
if timeWeLastClearedInventoryAndPubkeysTables < \
|
||||||
|
@ -128,9 +129,10 @@ class singleCleaner(StoppableThread):
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
'Alert: Your disk or data storage volume'
|
'Alert: Your disk or data storage volume'
|
||||||
' is full. Bitmessage will now exit.'),
|
' is full. Bitmessage will now exit.'),
|
||||||
True)
|
True)
|
||||||
))
|
))
|
||||||
# FIXME redundant?
|
# ..FIXME redundant?
|
||||||
|
# pylint: disable=no-member
|
||||||
if shared.daemon or not state.enableGUI:
|
if shared.daemon or not state.enableGUI:
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
|
@ -153,7 +155,7 @@ class singleCleaner(StoppableThread):
|
||||||
del state.discoveredPeers[k]
|
del state.discoveredPeers[k]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# TODO: cleanup pending upload / download
|
# ..TODO: cleanup pending upload / download
|
||||||
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
@ -162,6 +164,7 @@ class singleCleaner(StoppableThread):
|
||||||
|
|
||||||
|
|
||||||
def resendPubkeyRequest(address):
|
def resendPubkeyRequest(address):
|
||||||
|
"""After a long time, method send getpubkey request"""
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'It has been a long time and we haven\'t heard a response to our'
|
'It has been a long time and we haven\'t heard a response to our'
|
||||||
' getpubkey request. Sending again.'
|
' getpubkey request. Sending again.'
|
||||||
|
@ -186,6 +189,7 @@ def resendPubkeyRequest(address):
|
||||||
|
|
||||||
|
|
||||||
def resendMsg(ackdata):
|
def resendMsg(ackdata):
|
||||||
|
"""After a long time, method send acknowledgement msg"""
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'It has been a long time and we haven\'t heard an acknowledgement'
|
'It has been a long time and we haven\'t heard an acknowledgement'
|
||||||
' to our msg. Sending again.'
|
' to our msg. Sending again.'
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
src/class_singleWorker.py
|
src/class_singleWorker.py
|
||||||
=========================
|
=========================
|
||||||
"""
|
"""
|
||||||
# pylint: disable=protected-access,too-many-branches,too-many-statements,no-self-use,too-many-lines,too-many-locals
|
# pylint: disable=protected-access,too-many-branches,too-many-statements
|
||||||
|
# pylint: disable=no-self-use,too-many-lines,too-many-locals,relative-import
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -34,6 +34,7 @@ from inventory import Inventory
|
||||||
# This thread, of which there is only one, does the heavy lifting:
|
# This thread, of which there is only one, does the heavy lifting:
|
||||||
# calculating POWs.
|
# calculating POWs.
|
||||||
|
|
||||||
|
|
||||||
def sizeof_fmt(num, suffix='h/s'):
|
def sizeof_fmt(num, suffix='h/s'):
|
||||||
"""Format hashes per seconds nicely (SI prefix)"""
|
"""Format hashes per seconds nicely (SI prefix)"""
|
||||||
|
|
||||||
|
@ -469,7 +470,7 @@ class singleWorker(StoppableThread):
|
||||||
def sendOnionPeerObj(self, peer=None):
|
def sendOnionPeerObj(self, peer=None):
|
||||||
"""Send onionpeer object representing peer"""
|
"""Send onionpeer object representing peer"""
|
||||||
if not peer: # find own onionhostname
|
if not peer: # find own onionhostname
|
||||||
for peer in state.ownAddresses:
|
for peer in state.ownAddresses: # pylint: disable=redefined-argument-from-local
|
||||||
if peer.host.endswith('.onion'):
|
if peer.host.endswith('.onion'):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -478,7 +479,7 @@ class singleWorker(StoppableThread):
|
||||||
embeddedTime = int(time.time() + TTL)
|
embeddedTime = int(time.time() + TTL)
|
||||||
streamNumber = 1 # Don't know yet what should be here
|
streamNumber = 1 # Don't know yet what should be here
|
||||||
objectType = protocol.OBJECT_ONIONPEER
|
objectType = protocol.OBJECT_ONIONPEER
|
||||||
# FIXME: ideally the objectPayload should be signed
|
# ..FIXME: ideally the objectPayload should be signed
|
||||||
objectPayload = encodeVarint(peer.port) + protocol.encodeHost(peer.host)
|
objectPayload = encodeVarint(peer.port) + protocol.encodeHost(peer.host)
|
||||||
tag = calculateInventoryHash(objectPayload)
|
tag = calculateInventoryHash(objectPayload)
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 461 B |
Binary file not shown.
Before Width: | Height: | Size: 475 B |
|
@ -42,6 +42,7 @@ def constructObject(data):
|
||||||
else:
|
else:
|
||||||
return returnObj
|
return returnObj
|
||||||
|
|
||||||
|
|
||||||
if paths.frozen is not None or platform == "android":
|
if paths.frozen is not None or platform == "android":
|
||||||
import messagetypes.message
|
import messagetypes.message
|
||||||
import messagetypes.vote
|
import messagetypes.vote
|
||||||
|
|
|
@ -4,6 +4,7 @@ src/messagetypes/message.py
|
||||||
"""
|
"""
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from messagetypes import MsgBase
|
from messagetypes import MsgBase
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
|
||||||
|
|
||||||
class Message(MsgBase):
|
class Message(MsgBase):
|
||||||
|
|
|
@ -4,6 +4,7 @@ src/messagetypes/vote.py
|
||||||
"""
|
"""
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from messagetypes import MsgBase
|
from messagetypes import MsgBase
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
|
||||||
|
|
||||||
class Vote(MsgBase):
|
class Vote(MsgBase):
|
||||||
|
|
47
src/paths.py
47
src/paths.py
|
@ -1,3 +1,8 @@
|
||||||
|
"""
|
||||||
|
src/paths.py
|
||||||
|
============
|
||||||
|
"""
|
||||||
|
# pylint: disable=import-error
|
||||||
from os import environ, path
|
from os import environ, path
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
@ -7,9 +12,14 @@ from kivy.utils import platform
|
||||||
# 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
|
||||||
# namespace. This can be used to setup a different code path for
|
# namespace. This can be used to setup a different code path for
|
||||||
# binary distributions vs source distributions.
|
# binary distributions vs source distributions.
|
||||||
frozen = getattr(sys,'frozen', None)
|
frozen = getattr(sys, 'frozen', None)
|
||||||
|
|
||||||
|
|
||||||
def lookupExeFolder():
|
def lookupExeFolder():
|
||||||
|
"""
|
||||||
|
Folder with PyBitmessage binary (.exe, .app, ...). If it is run from source, it returns the source root
|
||||||
|
directory
|
||||||
|
"""
|
||||||
if frozen:
|
if frozen:
|
||||||
if frozen == "macosx_app":
|
if frozen == "macosx_app":
|
||||||
# targetdir/Bitmessage.app/Contents/MacOS/Bitmessage
|
# targetdir/Bitmessage.app/Contents/MacOS/Bitmessage
|
||||||
|
@ -22,10 +32,12 @@ def lookupExeFolder():
|
||||||
exeFolder = ''
|
exeFolder = ''
|
||||||
return exeFolder
|
return exeFolder
|
||||||
|
|
||||||
def lookupAppdataFolder():
|
|
||||||
|
|
||||||
|
def lookupAppdataFolder(): # pylint: disable=too-many-branches
|
||||||
|
"""Folder with runtime data (like configuration, database, ...)"""
|
||||||
|
# flake8: noqa=F821
|
||||||
import traceback
|
import traceback
|
||||||
print(traceback.print_tb)
|
print traceback.print_tb
|
||||||
APPNAME = "PyBitmessage"
|
APPNAME = "PyBitmessage"
|
||||||
if "BITMESSAGE_HOME" in environ:
|
if "BITMESSAGE_HOME" in environ:
|
||||||
dataFolder = environ["BITMESSAGE_HOME"]
|
dataFolder = environ["BITMESSAGE_HOME"]
|
||||||
|
@ -35,9 +47,11 @@ def lookupAppdataFolder():
|
||||||
if "HOME" in environ:
|
if "HOME" in environ:
|
||||||
dataFolder = path.join(environ["HOME"], "Library/Application Support/", APPNAME) + '/'
|
dataFolder = path.join(environ["HOME"], "Library/Application Support/", APPNAME) + '/'
|
||||||
else:
|
else:
|
||||||
stringToLog = 'Could not find home folder, please report this message and your OS X version to the BitMessage Github.'
|
stringToLog = (
|
||||||
|
'Could not find home folder, please report this message'
|
||||||
|
' and your OS X version to the BitMessage Github.')
|
||||||
if 'logger' in globals():
|
if 'logger' in globals():
|
||||||
logger.critical(stringToLog)
|
logger.critical(stringToLog) # pylint: disable=undefined-variable
|
||||||
else:
|
else:
|
||||||
print stringToLog
|
print stringToLog
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
@ -58,7 +72,7 @@ def lookupAppdataFolder():
|
||||||
move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder)
|
move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder)
|
||||||
stringToLog = "Moving data folder to %s" % (dataFolder)
|
stringToLog = "Moving data folder to %s" % (dataFolder)
|
||||||
if 'logger' in globals():
|
if 'logger' in globals():
|
||||||
logger.info(stringToLog)
|
logger.info(stringToLog) # pylint: disable=undefined-variable
|
||||||
else:
|
else:
|
||||||
print stringToLog
|
print stringToLog
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -67,16 +81,21 @@ def lookupAppdataFolder():
|
||||||
dataFolder = dataFolder + '/'
|
dataFolder = dataFolder + '/'
|
||||||
return dataFolder
|
return dataFolder
|
||||||
|
|
||||||
|
|
||||||
def codePath():
|
def codePath():
|
||||||
|
"""Return the code path of the running instance"""
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
if frozen == "macosx_app":
|
if frozen == "macosx_app":
|
||||||
codePath = environ.get("RESOURCEPATH")
|
codePath = environ.get("RESOURCEPATH")
|
||||||
elif frozen: # windows
|
elif frozen: # windows
|
||||||
codePath = sys._MEIPASS
|
codePath = sys._MEIPASS # pylint: disable=no-member,protected-access
|
||||||
else:
|
else:
|
||||||
codePath = path.dirname(__file__)
|
codePath = path.dirname(__file__)
|
||||||
return codePath
|
return codePath
|
||||||
|
|
||||||
|
|
||||||
def tail(f, lines=20):
|
def tail(f, lines=20):
|
||||||
|
"""Read last lines of a file. Like tail(1)"""
|
||||||
total_lines_wanted = lines
|
total_lines_wanted = lines
|
||||||
|
|
||||||
BLOCK_SIZE = 1024
|
BLOCK_SIZE = 1024
|
||||||
|
@ -84,12 +103,13 @@ 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 = []
|
||||||
# from the end of the file
|
# blocks of size BLOCK_SIZE, in reverse order starting
|
||||||
|
# from the end of the file
|
||||||
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
|
||||||
f.seek(block_number*BLOCK_SIZE, 2)
|
f.seek(block_number * BLOCK_SIZE, 2)
|
||||||
blocks.append(f.read(BLOCK_SIZE))
|
blocks.append(f.read(BLOCK_SIZE))
|
||||||
else:
|
else:
|
||||||
# file too small, start from begining
|
# file too small, start from begining
|
||||||
|
@ -105,6 +125,7 @@ def tail(f, lines=20):
|
||||||
|
|
||||||
|
|
||||||
def lastCommit():
|
def lastCommit():
|
||||||
|
"""Git commitish of the currently checked out repository"""
|
||||||
githeadfile = path.join(codePath(), '..', '.git', 'logs', 'HEAD')
|
githeadfile = path.join(codePath(), '..', '.git', 'logs', 'HEAD')
|
||||||
result = {}
|
result = {}
|
||||||
if path.isfile(githeadfile):
|
if path.isfile(githeadfile):
|
||||||
|
@ -117,4 +138,4 @@ def lastCommit():
|
||||||
)
|
)
|
||||||
except (IOError, AttributeError, TypeError):
|
except (IOError, AttributeError, TypeError):
|
||||||
pass
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
src/pyelliptic/openssl.py
|
src/pyelliptic/openssl.py
|
||||||
=================================
|
=================================
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=import-error
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform
|
||||||
|
@ -21,8 +22,6 @@ src/pyelliptic/openssl.py
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CipherName:
|
class CipherName:
|
||||||
"""Class returns cipher name, pointer and blocksize"""
|
"""Class returns cipher name, pointer and blocksize"""
|
||||||
|
|
||||||
|
|
28
src/state.py
28
src/state.py
|
@ -1,20 +1,21 @@
|
||||||
|
"""
|
||||||
|
src/state.py
|
||||||
|
=================================
|
||||||
|
"""
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
neededPubkeys = {}
|
neededPubkeys = {}
|
||||||
streamsInWhichIAmParticipating = []
|
streamsInWhichIAmParticipating = []
|
||||||
|
|
||||||
# For UPnP
|
# For UPnP
|
||||||
extPort = None
|
extPort = None
|
||||||
|
|
||||||
# for Tor hidden service
|
# for Tor hidden service
|
||||||
socksIP = None
|
socksIP = None
|
||||||
|
# Network protocols availability, initialised below
|
||||||
|
networkProtocolAvailability = None
|
||||||
appdata = '' # holds the location of the application data storage directory
|
appdata = '' # holds the location of the application data storage directory
|
||||||
|
|
||||||
# Set to 1 by the doCleanShutdown function.
|
# Set to 1 by the doCleanShutdown function.
|
||||||
# Used to tell the proof of work worker threads to exit.
|
# Used to tell the proof of work worker threads to exit.
|
||||||
shutdown = 0
|
shutdown = 0
|
||||||
|
|
||||||
# Component control flags - set on startup, do not change during runtime
|
# Component control flags - set on startup, do not change during runtime
|
||||||
# The defaults are for standalone GUI (default operating mode)
|
# The defaults are for standalone GUI (default operating mode)
|
||||||
enableNetwork = True # enable network threads
|
enableNetwork = True # enable network threads
|
||||||
|
@ -23,18 +24,13 @@ enableAPI = True # enable API (if configured)
|
||||||
enableGUI = True # enable GUI (QT or ncurses)
|
enableGUI = True # enable GUI (QT or ncurses)
|
||||||
enableSTDIO = False # enable STDIO threads
|
enableSTDIO = False # enable STDIO threads
|
||||||
curses = False
|
curses = False
|
||||||
|
|
||||||
sqlReady = False # set to true by sqlTread when ready for processing
|
sqlReady = False # set to true by sqlTread when ready for processing
|
||||||
|
|
||||||
maximumNumberOfHalfOpenConnections = 0
|
maximumNumberOfHalfOpenConnections = 0
|
||||||
|
|
||||||
invThread = None
|
invThread = None
|
||||||
addrThread = None
|
addrThread = None
|
||||||
downloadThread = None
|
downloadThread = None
|
||||||
uploadThread = None
|
uploadThread = None
|
||||||
|
|
||||||
ownAddresses = {}
|
ownAddresses = {}
|
||||||
|
|
||||||
# If the trustedpeer option is specified in keys.dat then this will
|
# If the trustedpeer option is specified in keys.dat then this will
|
||||||
# contain a Peer which will be connected to instead of using the
|
# contain a Peer which will be connected to instead of using the
|
||||||
# addresses advertised by other peers. The client will only connect to
|
# addresses advertised by other peers. The client will only connect to
|
||||||
|
@ -46,11 +42,19 @@ ownAddresses = {}
|
||||||
# it will sync with the network a lot faster without compromising
|
# it will sync with the network a lot faster without compromising
|
||||||
# security.
|
# security.
|
||||||
trustedPeer = None
|
trustedPeer = None
|
||||||
|
|
||||||
discoveredPeers = {}
|
discoveredPeers = {}
|
||||||
|
|
||||||
Peer = collections.namedtuple('Peer', ['host', 'port'])
|
Peer = collections.namedtuple('Peer', ['host', 'port'])
|
||||||
|
|
||||||
|
|
||||||
|
def resetNetworkProtocolAvailability():
|
||||||
|
"""This method helps to reset the availability of network protocol"""
|
||||||
|
# pylint: disable=global-statement
|
||||||
|
global networkProtocolAvailability
|
||||||
|
networkProtocolAvailability = {'IPv4': None, 'IPv6': None, 'onion': None}
|
||||||
|
|
||||||
|
|
||||||
|
resetNetworkProtocolAvailability()
|
||||||
|
|
||||||
dandelion = 0
|
dandelion = 0
|
||||||
|
|
||||||
testmode = False
|
testmode = False
|
||||||
|
|
51
src/tr.py
51
src/tr.py
|
@ -1,25 +1,43 @@
|
||||||
|
"""
|
||||||
|
src/tr.py
|
||||||
|
=================================
|
||||||
|
"""
|
||||||
|
# pylint: disable=relative-import
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import state
|
import state
|
||||||
|
|
||||||
# This is used so that the translateText function can be used when we are in daemon mode and not using any QT functions.
|
"""This is used so that the translateText function can be used """
|
||||||
class translateClass:
|
"""when we are in daemon mode and not using any QT functions."""
|
||||||
|
|
||||||
|
|
||||||
|
class translateClass: # pylint: disable=old-style-class, too-few-public-methods
|
||||||
|
"""
|
||||||
|
This is used so that the translateText function can be used when we are
|
||||||
|
in daemon mode and not using any QT functions.
|
||||||
|
"""
|
||||||
def __init__(self, context, text):
|
def __init__(self, context, text):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.text = text
|
self.text = text
|
||||||
def arg(self,argument):
|
|
||||||
if '%' in self.text:
|
|
||||||
return translateClass(self.context, self.text.replace('%','',1)) # This doesn't actually do anything with the arguments because we don't have a UI in which to display this information anyway.
|
|
||||||
else:
|
|
||||||
return self.text
|
|
||||||
|
|
||||||
def _translate(context, text, disambiguation = None, encoding = None, n = None):
|
def arg(self, argument): # pylint: disable=unused-argument
|
||||||
|
"""Replace argument placeholders"""
|
||||||
|
if '%' in self.text:
|
||||||
|
return translateClass(self.context, self.text.replace('%', '', 1))
|
||||||
|
# This doesn't actually do anything with the arguments
|
||||||
|
# because we don't have a UI in which to display this information anyway.
|
||||||
|
return self.text
|
||||||
|
|
||||||
|
|
||||||
|
def _translate(context, text, disambiguation=None, encoding=None, n=None): # pylint: disable=unused-argument
|
||||||
return translateText(context, text, n)
|
return translateText(context, text, n)
|
||||||
|
|
||||||
# def _translate(context, text, disambiguation = None, encoding = None, n = None):
|
# def _translate(context, text, disambiguation = None, encoding = None, n = None):
|
||||||
# return translateClass(context, text.replace('%','',1))
|
# return translateClass(context, text.replace('%','',1))
|
||||||
|
|
||||||
def translateText(context, text, n = None):
|
|
||||||
|
def translateText(context, text, n=None):
|
||||||
|
"""Translate text in context"""
|
||||||
try:
|
try:
|
||||||
enableGUI = state.enableGUI
|
enableGUI = state.enableGUI
|
||||||
except AttributeError: # inside the plugin
|
except AttributeError: # inside the plugin
|
||||||
|
@ -28,15 +46,16 @@ def translateText(context, text, n = None):
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
|
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API\
|
||||||
|
.You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download\
|
||||||
|
or by searching Google for \'PyQt Download\'.\
|
||||||
|
If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
|
||||||
print 'Error message:', err
|
print 'Error message:', err
|
||||||
os._exit(0)
|
os._exit(0) # pylint: disable=protected-access
|
||||||
if n is None:
|
if n is None:
|
||||||
return QtGui.QApplication.translate(context, text)
|
return QtGui.QApplication.translate(context, text)
|
||||||
else:
|
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n)
|
||||||
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n)
|
|
||||||
else:
|
else:
|
||||||
if '%' in text:
|
if '%' in text:
|
||||||
return translateClass(context, text.replace('%','',1))
|
return translateClass(context, text.replace('%', '', 1))
|
||||||
else:
|
return text
|
||||||
return text
|
|
||||||
|
|
Reference in New Issue
Block a user