resloved conflicts
3
.gitignore
vendored
|
@ -19,3 +19,6 @@ docs/_*/*
|
||||||
docs/autodoc/
|
docs/autodoc/
|
||||||
build/sphinx/
|
build/sphinx/
|
||||||
pyan/
|
pyan/
|
||||||
|
.buildozer/
|
||||||
|
bin/
|
||||||
|
src/images/default_identicon/
|
|
@ -1,2 +0,0 @@
|
||||||
This directory contains scripts that are helpful for developers when building
|
|
||||||
or maintaining PyBitmessage.
|
|
|
@ -1,16 +0,0 @@
|
||||||
export LANG=de_DE.UTF-8
|
|
||||||
export LANGUAGE=de_DE
|
|
||||||
export LC_CTYPE="de_DE.UTF-8"
|
|
||||||
export LC_NUMERIC=de_DE.UTF-8
|
|
||||||
export LC_TIME=de_DE.UTF-8
|
|
||||||
export LC_COLLATE="de_DE.UTF-8"
|
|
||||||
export LC_MONETARY=de_DE.UTF-8
|
|
||||||
export LC_MESSAGES="de_DE.UTF-8"
|
|
||||||
export LC_PAPER=de_DE.UTF-8
|
|
||||||
export LC_NAME=de_DE.UTF-8
|
|
||||||
export LC_ADDRESS=de_DE.UTF-8
|
|
||||||
export LC_TELEPHONE=de_DE.UTF-8
|
|
||||||
export LC_MEASUREMENT=de_DE.UTF-8
|
|
||||||
export LC_IDENTIFICATION=de_DE.UTF-8
|
|
||||||
export LC_ALL=
|
|
||||||
python2.7 src/bitmessagemain.py
|
|
|
@ -1,23 +0,0 @@
|
||||||
#!/usr/bin/python2.7
|
|
||||||
|
|
||||||
import ctypes
|
|
||||||
import fnmatch
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
matches = []
|
|
||||||
for root, dirnames, filenames in os.walk('src'):
|
|
||||||
for filename in fnmatch.filter(filenames, '*.py'):
|
|
||||||
matches.append(os.path.join(root, filename))
|
|
||||||
|
|
||||||
for filename in matches:
|
|
||||||
source = open(filename, 'r').read() + '\n'
|
|
||||||
try:
|
|
||||||
compile(source, filename, 'exec')
|
|
||||||
except Exception as e:
|
|
||||||
if 'win' in sys.platform:
|
|
||||||
ctypes.windll.user32.MessageBoxA(0, traceback.format_exc(), "Exception in " + filename, 1)
|
|
||||||
else:
|
|
||||||
print "Exception in %s: %s" % (filename, traceback.format_exc())
|
|
||||||
sys.exit(1)
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "You must specify pull request number"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull
|
|
||||||
git checkout v0.6
|
|
||||||
git fetch origin pull/"$1"/head:"$1"
|
|
||||||
git merge --ff-only "$1"
|
|
26
build/osx.sh
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# OS X Build script wrapper around the py2app script.
|
|
||||||
# This build can only be generated on OS X.
|
|
||||||
# Requires all build dependencies for Bitmessage
|
|
||||||
# Especially important is OpenSSL installed through brew
|
|
||||||
|
|
||||||
export ARCHFLAGS="-arch i386 -arch x86_64"
|
|
||||||
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo "Please supply a version number for this release as the first argument."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Creating OS X packages for Bitmessage."
|
|
||||||
|
|
||||||
export PYBITMESSAGEVERSION=$1
|
|
||||||
|
|
||||||
cd src && python2.7 build_osx.py py2app
|
|
||||||
|
|
||||||
if [[ $? = "0" ]]; then
|
|
||||||
hdiutil create -fs HFS+ -volname "Bitmessage" -srcfolder dist/Bitmessage.app dist/bitmessage-v$1.dmg
|
|
||||||
else
|
|
||||||
echo "Problem creating Bitmessage.app, stopping."
|
|
||||||
exit
|
|
||||||
fi
|
|
|
@ -1,22 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ ! -f "$1" ]; then
|
|
||||||
echo "$1 not found, please specify the file name for source"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
srcdir=`mktemp -d`
|
|
||||||
|
|
||||||
unzip "$1" -d $srcdir
|
|
||||||
|
|
||||||
for i in $srcdir/*ts; do
|
|
||||||
o=`basename $i|cut -b3-`
|
|
||||||
o="${o,,}"
|
|
||||||
o="${o//@/_}"
|
|
||||||
echo "$i -> $o"
|
|
||||||
mv "$i" "$HOME/src/PyBitmessage/src/translations/$o"
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -rf -- $srcdir
|
|
||||||
|
|
||||||
lrelease-qt4 "$HOME/src/PyBitmessage/src/translations/bitmessage.pro"
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5aa322da9179dae305fde5af1db516c1ad9baea4
|
BIN
src/alice.png
Normal file
After Width: | Height: | Size: 669 B |
|
@ -0,0 +1,50 @@
|
||||||
|
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
|
||||||
|
from os.path import exists, join
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from multiprocessing import cpu_count
|
||||||
|
import sh
|
||||||
|
|
||||||
|
|
||||||
|
class BitmsghashRecipe(Recipe):
|
||||||
|
# This could also inherit from PythonRecipe etc. if you want to
|
||||||
|
# use their pre-written build processes
|
||||||
|
|
||||||
|
url = 'https://github.com/surbhicis/bitmsghash/archive/master.zip'
|
||||||
|
# {version} will be replaced with self.version when downloading
|
||||||
|
|
||||||
|
depends = ['openssl']
|
||||||
|
|
||||||
|
conflicts = []
|
||||||
|
|
||||||
|
def get_recipe_env(self, arch=None):
|
||||||
|
env = super(BitmsghashRecipe, self).get_recipe_env(arch)
|
||||||
|
r = Recipe.get_recipe('openssl', self.ctx)
|
||||||
|
b = r.get_build_dir(arch.arch)
|
||||||
|
env['CCFLAGS'] = env['CFLAGS'] = \
|
||||||
|
env['CFLAGS'] + ' -I{openssl_build_path}/include ' \
|
||||||
|
'-I{openssl_build_path}/include/openssl'.format(
|
||||||
|
openssl_build_path=b)
|
||||||
|
env['LDFLAGS'] = \
|
||||||
|
env['LDFLAGS'] + ' -L{openssl_build_path} ' \
|
||||||
|
'-lcrypto{openssl_version} ' \
|
||||||
|
'-lssl{openssl_version}'.format(
|
||||||
|
openssl_build_path=b,
|
||||||
|
openssl_version=r.version)
|
||||||
|
return env
|
||||||
|
|
||||||
|
def should_build(self, arch=None):
|
||||||
|
super(BitmsghashRecipe, self).should_build(arch)
|
||||||
|
return not exists(
|
||||||
|
join(self.ctx.get_libs_dir(arch.arch), 'libbitmsghash.so'))
|
||||||
|
|
||||||
|
def build_arch(self, arch=None):
|
||||||
|
super(BitmsghashRecipe, self).build_arch(arch)
|
||||||
|
env = self.get_recipe_env(arch)
|
||||||
|
with current_directory(join(self.get_build_dir(arch.arch))):
|
||||||
|
dst_dir = join(self.get_build_dir(arch.arch))
|
||||||
|
shprint(sh.make, '-j', str(cpu_count()), _env=env)
|
||||||
|
self.install_libs(arch, '{}/libbitmsghash.so'.format(dst_dir),
|
||||||
|
'libbitmsghash.so')
|
||||||
|
|
||||||
|
recipe = BitmsghashRecipe()
|
|
@ -0,0 +1,41 @@
|
||||||
|
"""
|
||||||
|
src/bitmessagekivy/android/python-for-android/recipes/kivymd/__init__.py
|
||||||
|
=================================
|
||||||
|
"""
|
||||||
|
# pylint: disable=import-error
|
||||||
|
from os.path import join
|
||||||
|
|
||||||
|
from pythonforandroid.recipe import PythonRecipe
|
||||||
|
# from pythonforandroid.util import ensure_dir
|
||||||
|
|
||||||
|
|
||||||
|
class KivyMDRecipe(PythonRecipe):
|
||||||
|
"""This recipe installs KivyMD into the android dist from source"""
|
||||||
|
version = 'master'
|
||||||
|
url = 'https://github.com/surbhicis/kivymd/archive/master.zip'
|
||||||
|
depends = ['kivy']
|
||||||
|
site_packages_name = 'kivymd'
|
||||||
|
call_hostpython_via_targetpython = False
|
||||||
|
|
||||||
|
def should_build(self, arch): # pylint: disable=no-self-use, unused-argument
|
||||||
|
"""Method helps to build the application"""
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_recipe_env(self, arch):
|
||||||
|
"""Method is used for getting all the env paths"""
|
||||||
|
env = super(KivyMDRecipe, self).get_recipe_env(arch)
|
||||||
|
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
|
||||||
|
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
|
||||||
|
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
|
||||||
|
' -lpython2.7'
|
||||||
|
if 'sdl2' in self.ctx.recipe_build_order:
|
||||||
|
env['USE_SDL2'] = '1'
|
||||||
|
env['KIVY_SDL2_PATH'] = ':'.join([
|
||||||
|
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_mixer'),
|
||||||
|
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'), ])
|
||||||
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
recipe = KivyMDRecipe()
|
|
@ -0,0 +1,36 @@
|
||||||
|
diff -Naurp KivyMD.orig/kivymd/button.py KivyMD/kivymd/button.py
|
||||||
|
--- KivyMD.orig/kivymd/button.py 2017-08-25 13:12:34.000000000 +0200
|
||||||
|
+++ KivyMD/kivymd/button.py 2018-07-10 10:37:55.719440354 +0200
|
||||||
|
@@ -175,7 +175,8 @@ class BaseButton(ThemableBehavior, Butto
|
||||||
|
self._current_button_color = self.md_bg_color_disabled
|
||||||
|
else:
|
||||||
|
self._current_button_color = self.md_bg_color
|
||||||
|
- super(BaseButton, self).on_disabled(instance, value)
|
||||||
|
+ # To add compatibility to last kivy (disabled is now an Alias property)
|
||||||
|
+ # super(BaseButton, self).on_disabled(instance, value)
|
||||||
|
|
||||||
|
|
||||||
|
class BasePressedButton(BaseButton):
|
||||||
|
diff -Naurp KivyMD.orig/kivymd/selectioncontrols.py KivyMD/kivymd/selectioncontrols.py
|
||||||
|
--- KivyMD.orig/kivymd/selectioncontrols.py 2017-08-25 13:12:34.000000000 +0200
|
||||||
|
+++ KivyMD/kivymd/selectioncontrols.py 2018-07-10 10:40:06.971439102 +0200
|
||||||
|
@@ -45,6 +45,7 @@ Builder.load_string('''
|
||||||
|
pos: self.pos
|
||||||
|
|
||||||
|
<MDSwitch>:
|
||||||
|
+ _thumb_pos: (self.right - dp(12), self.center_y - dp(12)) if self.active else (self.x - dp(12), self.center_y - dp(12))
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: self._track_color_disabled if self.disabled else \
|
||||||
|
diff -Naurp KivyMD.orig/kivymd/tabs.py KivyMD/kivymd/tabs.py
|
||||||
|
--- KivyMD.orig/kivymd/tabs.py 2017-08-25 13:12:34.000000000 +0200
|
||||||
|
+++ KivyMD/kivymd/tabs.py 2018-07-10 10:39:20.603439544 +0200
|
||||||
|
@@ -185,7 +185,7 @@ class MDBottomNavigationBar(ThemableBeha
|
||||||
|
|
||||||
|
class MDTabHeader(MDFlatButton):
|
||||||
|
""" Internal widget for headers based on MDFlatButton"""
|
||||||
|
-
|
||||||
|
+
|
||||||
|
width = BoundedNumericProperty(dp(0), min=dp(72), max=dp(264), errorhandler=lambda x: dp(72))
|
||||||
|
tab = ObjectProperty(None)
|
||||||
|
panel = ObjectProperty(None)
|
93
src/bitmessagekivy/identiconGeneration.py
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
"""
|
||||||
|
Core classes for loading images and converting them to a Texture.
|
||||||
|
The raw image data can be keep in memory for further access
|
||||||
|
"""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
from kivy.core.image import Image as CoreImage
|
||||||
|
from kivy.uix.image import Image as kiImage
|
||||||
|
# pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
|
# constants
|
||||||
|
RESOLUTION = 128, 128
|
||||||
|
V_RESOLUTION = 7, 7
|
||||||
|
BACKGROUND_COLOR = 255, 255, 255, 255
|
||||||
|
MODE = "RGB"
|
||||||
|
|
||||||
|
|
||||||
|
def generate(Generate_string=None):
|
||||||
|
"""Generating string"""
|
||||||
|
hash_string = generate_hash(Generate_string)
|
||||||
|
color = random_color(hash_string)
|
||||||
|
image = Image.new(MODE, V_RESOLUTION, BACKGROUND_COLOR)
|
||||||
|
image = generate_image(image, color, hash_string)
|
||||||
|
image = image.resize(RESOLUTION, 0)
|
||||||
|
|
||||||
|
data = BytesIO()
|
||||||
|
image.save(data, format='png')
|
||||||
|
data.seek(0)
|
||||||
|
# yes you actually need this
|
||||||
|
im = CoreImage(BytesIO(data.read()), ext='png')
|
||||||
|
beeld = kiImage()
|
||||||
|
# only use this line in first code instance
|
||||||
|
beeld.texture = im.texture
|
||||||
|
return beeld
|
||||||
|
# image.show()
|
||||||
|
|
||||||
|
|
||||||
|
def generate_hash(string):
|
||||||
|
"""Generating hash"""
|
||||||
|
try:
|
||||||
|
# make input case insensitive
|
||||||
|
string = str.lower(string)
|
||||||
|
hash_object = hashlib.md5(str.encode(string))
|
||||||
|
print hash_object.hexdigest()
|
||||||
|
|
||||||
|
# returned object is a hex string
|
||||||
|
return hash_object.hexdigest()
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
print "Error: Please enter a string as an argument."
|
||||||
|
|
||||||
|
|
||||||
|
def random_color(hash_string):
|
||||||
|
"""Getting random color"""
|
||||||
|
# remove first three digits from hex string
|
||||||
|
split = 6
|
||||||
|
rgb = hash_string[:split]
|
||||||
|
|
||||||
|
split = 2
|
||||||
|
r = rgb[:split]
|
||||||
|
g = rgb[split:2 * split]
|
||||||
|
b = rgb[2 * split:3 * split]
|
||||||
|
|
||||||
|
color = (int(r, 16), int(g, 16),
|
||||||
|
int(b, 16), 0xFF)
|
||||||
|
|
||||||
|
return color
|
||||||
|
|
||||||
|
|
||||||
|
def generate_image(image, color, hash_string):
|
||||||
|
"""Generating images"""
|
||||||
|
hash_string = hash_string[6:]
|
||||||
|
|
||||||
|
lower_x = 1
|
||||||
|
lower_y = 1
|
||||||
|
upper_x = int(V_RESOLUTION[0] / 2) + 1
|
||||||
|
upper_y = V_RESOLUTION[1] - 1
|
||||||
|
limit_x = V_RESOLUTION[0] - 1
|
||||||
|
index = 0
|
||||||
|
|
||||||
|
for x in range(lower_x, upper_x):
|
||||||
|
for y in range(lower_y, upper_y):
|
||||||
|
if int(hash_string[index], 16) % 2 == 0:
|
||||||
|
image.putpixel((x, y), color)
|
||||||
|
image.putpixel((limit_x - x, y), color)
|
||||||
|
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
return image
|
|
@ -1,19 +1,30 @@
|
||||||
from helper_sql import *
|
"""
|
||||||
|
Sql queries for bitmessagekivy
|
||||||
|
"""
|
||||||
|
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, start_indx=0, end_indx=20):
|
||||||
|
"""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:
|
||||||
what = None
|
what = None
|
||||||
|
|
||||||
if folder == "sent":
|
if folder == "sent" or folder == "draft":
|
||||||
sqlStatementBase = '''
|
sqlStatementBase = (
|
||||||
SELECT toaddress, fromaddress, subject, status, ackdata, lastactiontime
|
'''SELECT toaddress, fromaddress, subject, message, status,'''
|
||||||
FROM sent '''
|
''' ackdata, lastactiontime FROM sent ''')
|
||||||
|
elif folder == "addressbook":
|
||||||
|
sqlStatementBase = '''SELECT label, address From addressbook '''
|
||||||
else:
|
else:
|
||||||
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
|
sqlStatementBase = (
|
||||||
FROM inbox '''
|
'''SELECT folder, msgid, toaddress, message, fromaddress,'''
|
||||||
|
''' subject, received, read FROM inbox ''')
|
||||||
|
|
||||||
sqlStatementParts = []
|
sqlStatementParts = []
|
||||||
sqlArguments = []
|
sqlArguments = []
|
||||||
if account is not None:
|
if account is not None:
|
||||||
|
@ -24,6 +35,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 != "addressbook":
|
||||||
if folder is not None:
|
if folder is not None:
|
||||||
if folder == "new":
|
if folder == "new":
|
||||||
folder = "inbox"
|
folder = "inbox"
|
||||||
|
@ -34,12 +46,28 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
|
||||||
sqlStatementParts.append("folder != ?")
|
sqlStatementParts.append("folder != ?")
|
||||||
sqlArguments.append("trash")
|
sqlArguments.append("trash")
|
||||||
if what is not None:
|
if what is not None:
|
||||||
sqlStatementParts.append("%s LIKE ?" % (where))
|
for colmns in where:
|
||||||
|
if len(where) > 1:
|
||||||
|
if where[0] == colmns:
|
||||||
|
filter_col = "(%s LIKE ?" % (colmns)
|
||||||
|
else:
|
||||||
|
filter_col += " or %s LIKE ? )" % (colmns)
|
||||||
|
else:
|
||||||
|
filter_col = "%s LIKE ?" % (colmns)
|
||||||
sqlArguments.append(what)
|
sqlArguments.append(what)
|
||||||
|
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" or folder == "draft":
|
||||||
sqlStatementBase += " ORDER BY lastactiontime"
|
sqlStatementBase += \
|
||||||
|
" ORDER BY lastactiontime DESC limit {0}, {1}".format(
|
||||||
|
start_indx, end_indx)
|
||||||
|
elif folder == "inbox":
|
||||||
|
sqlStatementBase += \
|
||||||
|
" ORDER BY received DESC limit {0}, {1}".format(
|
||||||
|
start_indx, end_indx)
|
||||||
|
# elif folder == "addressbook":
|
||||||
|
# sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx)
|
||||||
return sqlQuery(sqlStatementBase, sqlArguments)
|
return sqlQuery(sqlStatementBase, sqlArguments)
|
||||||
|
|
|
@ -1,354 +1,1332 @@
|
||||||
#:import la kivy.adapters.listadapter
|
|
||||||
#:import factory kivy.factory
|
|
||||||
#:import mpybit bitmessagekivy.mpybit
|
|
||||||
#:import C kivy.utils.get_color_from_hex
|
|
||||||
|
|
||||||
<Navigator>:
|
#:import Toolbar kivymd.toolbar.Toolbar
|
||||||
id: nav_drawer
|
#:import NavigationLayout kivymd.navigationdrawer.NavigationLayout
|
||||||
|
#:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider
|
||||||
|
#:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader
|
||||||
|
#:import MDCheckbox kivymd.selectioncontrols.MDCheckbox
|
||||||
|
#:import MDList kivymd.list.MDList
|
||||||
|
#:import OneLineListItem kivymd.list.OneLineListItem
|
||||||
|
#:import MDTextField kivymd.textfields.MDTextField
|
||||||
|
#:import get_color_from_hex kivy.utils.get_color_from_hex
|
||||||
|
#:import colors kivymd.color_definitions.colors
|
||||||
|
#:import MDTabbedPanel kivymd.tabs.MDTabbedPanel
|
||||||
|
#:import MDTab kivymd.tabs.MDTab
|
||||||
|
#:import MDFloatingActionButton kivymd.button.MDFloatingActionButton
|
||||||
|
#:import Factory kivy.factory.Factory
|
||||||
|
#:import MDScrollViewRefreshLayout kivymd.refreshlayout.MDScrollViewRefreshLayout
|
||||||
|
#:import MDSpinner kivymd.spinner.MDSpinner
|
||||||
|
#:import NoTransition kivy.uix.screenmanager.NoTransition
|
||||||
|
#:import MDSeparator kivymd.card.MDSeparator
|
||||||
|
|
||||||
|
#:set color_button (0.784, 0.443, 0.216, 1) # brown
|
||||||
|
#:set color_button_pressed (0.659, 0.522, 0.431, 1) # darker brown
|
||||||
|
#:set color_font (0.957, 0.890, 0.843, 1) # off white
|
||||||
|
|
||||||
|
<MyNavigationDrawerIconButton@NavigationDrawerIconButton>:
|
||||||
|
icon: 'checkbox-blank-circle'
|
||||||
|
|
||||||
|
<MySpinnerOption@SpinnerOption>:
|
||||||
|
font_size: '12.5sp'
|
||||||
|
background_color: color_button if self.state == 'down' else color_button_pressed
|
||||||
|
background_down: 'atlas://data/images/defaulttheme/button'
|
||||||
|
color: color_font
|
||||||
|
|
||||||
|
<ContentNavigationDrawer@Navigatorss>:
|
||||||
|
drawer_logo: './images/drawer_logo1.png'
|
||||||
|
NavigationDrawerDivider:
|
||||||
|
NavigationDrawerSubheader:
|
||||||
|
text: "Accounts"
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
Spinner:
|
CustomSpinner:
|
||||||
pos_hint:{"x":0,"y":.3}
|
|
||||||
id: btn
|
id: btn
|
||||||
background_color: app.theme_cls.primary_dark
|
pos_hint:{"x":0,"y":.25}
|
||||||
text: app.showmeaddresses(name='text')
|
option_cls: Factory.get("MySpinnerOption")
|
||||||
values: app.showmeaddresses(name='values')
|
font_size: '11.9sp'
|
||||||
|
text: app.getDefaultAccData()
|
||||||
|
background_color: color_button if self.state == 'normal' else color_button_pressed
|
||||||
|
background_down: 'atlas://data/images/defaulttheme/spinner'
|
||||||
|
color: color_font
|
||||||
|
values: app.variable_1
|
||||||
on_text:app.getCurrentAccountData(self.text)
|
on_text:app.getCurrentAccountData(self.text)
|
||||||
|
Image:
|
||||||
|
source: app.get_default_image()
|
||||||
|
x: self.width/6
|
||||||
|
y: self.parent.y + self.parent.height/4
|
||||||
|
size: self.parent.height/2, self.parent.height/2
|
||||||
|
ArrowImg:
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
|
id: inbox_cnt
|
||||||
icon: 'email-open'
|
icon: 'email-open'
|
||||||
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"
|
||||||
|
on_press: app.load_screen(self)
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'mail-send'
|
id: send_cnt
|
||||||
text: "sent"
|
icon: 'send'
|
||||||
|
text: "Sent"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'sent'
|
on_release: app.root.ids.scr_mngr.current = 'sent'
|
||||||
|
badge_text: "0"
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'dropbox'
|
id: draft_cnt
|
||||||
text: "trash"
|
icon: 'message-draw'
|
||||||
|
text: "Draft"
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'draft'
|
||||||
|
badge_text: "0"
|
||||||
|
#NavigationDrawerIconButton:
|
||||||
|
#text: "Starred"
|
||||||
|
#icon:'star'
|
||||||
|
#on_release: app.root.ids.scr_mngr.current = 'starred'
|
||||||
|
#badge_text: "0"
|
||||||
|
#NavigationDrawerIconButton:
|
||||||
|
#icon: 'archive'
|
||||||
|
#text: "Archieve"
|
||||||
|
#on_release: app.root.ids.scr_mngr.current = 'archieve'
|
||||||
|
#badge_text: "0"
|
||||||
|
#NavigationDrawerIconButton:
|
||||||
|
#icon: 'email-open-outline'
|
||||||
|
#text: "Spam"
|
||||||
|
#on_release: app.root.ids.scr_mngr.current = 'spam'
|
||||||
|
#badge_text: "0"
|
||||||
|
NavigationDrawerIconButton:
|
||||||
|
id: trash_cnt
|
||||||
|
icon: 'delete'
|
||||||
|
text: "Trash"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'trash'
|
on_release: app.root.ids.scr_mngr.current = 'trash'
|
||||||
|
badge_text: "0"
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'email'
|
id: allmail_cnt
|
||||||
text: "drafts"
|
text: "All Mails"
|
||||||
on_release: app.root.ids.scr_mngr.current = 'dialog'
|
icon:'contact-mail'
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'allmails'
|
||||||
|
badge_text: "0"
|
||||||
|
on_press: app.load_screen(self)
|
||||||
|
NavigationDrawerDivider:
|
||||||
|
NavigationDrawerSubheader:
|
||||||
|
text: "All labels"
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
icon: 'markunread-mailbox'
|
text: "Address Book"
|
||||||
text: "test"
|
icon:'book-multiple'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'test'
|
on_release: app.root.ids.scr_mngr.current = 'addressbook'
|
||||||
NavigationDrawerIconButton:
|
NavigationDrawerIconButton:
|
||||||
text: "new identity"
|
text: "Settings"
|
||||||
icon:'accounts-add'
|
icon:'settings'
|
||||||
on_release: app.root.ids.scr_mngr.current = 'newidentity'
|
on_release: app.root.ids.scr_mngr.current = 'set'
|
||||||
|
NavigationDrawerIconButton:
|
||||||
|
text: "Subscriptions/Payment"
|
||||||
|
icon:'bell'
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'payment'
|
||||||
|
NavigationDrawerIconButton:
|
||||||
|
text: "Credits"
|
||||||
|
icon:'wallet'
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'credits'
|
||||||
|
NavigationDrawerIconButton:
|
||||||
|
text: "new address"
|
||||||
|
icon:'account-plus'
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'login'
|
||||||
|
NavigationDrawerIconButton:
|
||||||
|
text: "Network Status"
|
||||||
|
icon:'server-network'
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'networkstat'
|
||||||
|
NavigationDrawerIconButton:
|
||||||
|
text: "My Addresses"
|
||||||
|
icon:'account-multiple'
|
||||||
|
on_release: app.root.ids.scr_mngr.current = 'myaddress'
|
||||||
|
|
||||||
|
NavigationLayout:
|
||||||
|
id: nav_layout
|
||||||
|
|
||||||
|
ContentNavigationDrawer:
|
||||||
|
id: nav_drawer
|
||||||
|
|
||||||
|
FloatLayout:
|
||||||
|
id: float_box
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
id: box_layout
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
Toolbar:
|
Toolbar:
|
||||||
id: toolbar
|
id: toolbar
|
||||||
title: app.getCurrentAccount()
|
title: app.current_address_label()
|
||||||
background_color: app.theme_cls.primary_dark
|
opacity: 1 if app.addressexist() else 0
|
||||||
left_action_items: [['menu', lambda x: app.nav_drawer.toggle()]]
|
disabled: False if app.addressexist() else True
|
||||||
Button:
|
md_bg_color: app.theme_cls.primary_color
|
||||||
text:"EXIT"
|
background_palette: 'Primary'
|
||||||
color: 0,0,0,1
|
background_hue: '500'
|
||||||
background_color: (0,0,0,0)
|
left_action_items: [['menu', lambda x: app.root.toggle_nav_drawer()]]
|
||||||
size_hint_y: 0.4
|
right_action_items: [['account-plus', lambda x: app.addingtoaddressbook()]]
|
||||||
size_hint_x: 0.1
|
|
||||||
pos_hint: {'x': 0.8, 'y':0.4}
|
|
||||||
on_press: app.say_exit()
|
|
||||||
|
|
||||||
|
|
||||||
ScreenManager:
|
ScreenManager:
|
||||||
id: scr_mngr
|
id: scr_mngr
|
||||||
Inbox:
|
Inbox:
|
||||||
id:sc1
|
id:sc1
|
||||||
Sent:
|
|
||||||
id:sc2
|
|
||||||
Trash:
|
|
||||||
id:sc3
|
|
||||||
Dialog:
|
|
||||||
id:sc4
|
|
||||||
Test:
|
|
||||||
id:sc5
|
|
||||||
Create:
|
|
||||||
id:sc6
|
|
||||||
NewIdentity:
|
|
||||||
id:sc7
|
|
||||||
Page:
|
Page:
|
||||||
|
id:sc2
|
||||||
|
Create:
|
||||||
|
id:sc3
|
||||||
|
Sent:
|
||||||
|
id:sc4
|
||||||
|
Trash:
|
||||||
|
id:sc5
|
||||||
|
Login:
|
||||||
|
id:sc6
|
||||||
|
Random:
|
||||||
|
id:sc7
|
||||||
|
Spam:
|
||||||
id:sc8
|
id:sc8
|
||||||
AddressSuccessful:
|
Setting:
|
||||||
id:sc9
|
id:sc9
|
||||||
|
MyAddress:
|
||||||
Button:
|
id:sc10
|
||||||
id:create
|
AddressBook:
|
||||||
height:100
|
id:sc11
|
||||||
size_hint_y: 0.13
|
Payment:
|
||||||
size_hint_x: 0.1
|
id:sc12
|
||||||
pos_hint: {'x': 0.85, 'y': 0.5}
|
NetworkStat:
|
||||||
background_color: (0,0,0,0)
|
id:sc13
|
||||||
on_press: scr_mngr.current = 'create'
|
MailDetail:
|
||||||
Image:
|
id:sc14
|
||||||
source: 'images/plus.png'
|
ShowQRCode:
|
||||||
y: self.parent.y - 7.5
|
id:sc15
|
||||||
x: self.parent.x + self.parent.width - 50
|
Draft:
|
||||||
size: 70, 70
|
id:sc16
|
||||||
|
Allmails:
|
||||||
<SwipeButton@Carousel>:
|
id:sc17
|
||||||
text: ''
|
Credits:
|
||||||
size_hint_y: None
|
id:sc18
|
||||||
height: 48
|
Starred:
|
||||||
ignore_perpendicular_swipes: True
|
id:sc19
|
||||||
data_index: 0
|
Archieve:
|
||||||
min_move: 20 / self.width
|
id:sc20
|
||||||
|
|
||||||
on__offset: app.update_index(root.data_index, self.index)
|
|
||||||
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
rgba: C('FFFFFF33')
|
|
||||||
|
|
||||||
Rectangle:
|
|
||||||
pos: self.pos
|
|
||||||
size: self.size
|
|
||||||
|
|
||||||
Line:
|
|
||||||
rectangle: self.pos + self.size
|
|
||||||
|
|
||||||
Button:
|
|
||||||
text: 'delete ({}:{})'.format(root.text, root.data_index)
|
|
||||||
on_press: app.delete(root.data_index)
|
|
||||||
|
|
||||||
Button:
|
|
||||||
text: root.text
|
|
||||||
on_press: app.getInboxMessageDetail(self.text)
|
|
||||||
|
|
||||||
Button:
|
|
||||||
text: 'archive'
|
|
||||||
on_press: app.archive(root.data_index)
|
|
||||||
|
|
||||||
<Inbox>:
|
<Inbox>:
|
||||||
name: 'inbox'
|
name: 'inbox'
|
||||||
RecycleView:
|
transition: NoTransition()
|
||||||
data: root.data
|
BoxLayout:
|
||||||
viewclass: 'SwipeButton'
|
|
||||||
do_scroll_x: False
|
|
||||||
scroll_timeout: 100
|
|
||||||
|
|
||||||
RecycleBoxLayout:
|
|
||||||
id:rc
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
SearchBar:
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 0, 0, 5]
|
||||||
|
cols: 1
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
default_size_hint: 1, None
|
MDLabel:
|
||||||
canvas.before:
|
text: ''
|
||||||
Color:
|
font_style: 'Body1'
|
||||||
rgba: 0,0,0, 1
|
bold: True
|
||||||
Rectangle:
|
#FloatLayout:
|
||||||
pos: self.pos
|
# MDScrollViewRefreshLayout:
|
||||||
size: self.size
|
# id: refresh_layout
|
||||||
|
# refresh_callback: root.refresh_callback
|
||||||
|
# root_layout: root.set_root_layout()
|
||||||
|
# MDList:
|
||||||
|
# id: ml
|
||||||
|
BoxLayout:
|
||||||
|
orientation:'vertical'
|
||||||
|
ScrollView:
|
||||||
|
id: scroll_y
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
Loader:
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
<Sent>:
|
<Sent>:
|
||||||
name: 'sent'
|
name: 'sent'
|
||||||
RecycleView:
|
BoxLayout:
|
||||||
data: root.data
|
|
||||||
viewclass: 'SwipeButton'
|
|
||||||
do_scroll_x: False
|
|
||||||
scroll_timeout: 100
|
|
||||||
|
|
||||||
RecycleBoxLayout:
|
|
||||||
id:rc
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
SearchBar:
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 0, 0, 5]
|
||||||
|
cols: 1
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
default_size_hint: 1, None
|
MDLabel:
|
||||||
canvas.before:
|
text: ''
|
||||||
Color:
|
font_style: 'Body1'
|
||||||
rgba: 0,0,0, 1
|
bold: True
|
||||||
Rectangle:
|
BoxLayout:
|
||||||
pos: self.pos
|
orientation:'vertical'
|
||||||
size: self.size
|
ScrollView:
|
||||||
|
id: scroll_y
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
Loader:
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
<Trash>:
|
<Trash>:
|
||||||
name: 'trash'
|
name: 'trash'
|
||||||
RecycleView:
|
BoxLayout:
|
||||||
data: root.data
|
|
||||||
viewclass: 'SwipeButton'
|
|
||||||
do_scroll_x: False
|
|
||||||
scroll_timeout: 100
|
|
||||||
|
|
||||||
RecycleBoxLayout:
|
|
||||||
id:rc
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 20, 0, 5]
|
||||||
|
spacing: dp(5)
|
||||||
|
cols: 1
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
default_size_hint: 1, None
|
MDLabel:
|
||||||
canvas.before:
|
text: ''
|
||||||
Color:
|
font_style: 'Body1'
|
||||||
rgba: 0,0,0, 1
|
bold: True
|
||||||
Rectangle:
|
BoxLayout:
|
||||||
pos: self.pos
|
orientation:'vertical'
|
||||||
size: self.size
|
ScrollView:
|
||||||
|
id: scroll_y
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
Loader:
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<Draft>:
|
||||||
|
name: 'draft'
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 20, 0, 5]
|
||||||
|
cols: 1
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
MDLabel:
|
||||||
|
text: ''
|
||||||
|
font_style: 'Body1'
|
||||||
|
bold: True
|
||||||
|
BoxLayout:
|
||||||
|
orientation:'vertical'
|
||||||
|
ScrollView:
|
||||||
|
id: scroll_y
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<Starred>:
|
||||||
|
name: 'starred'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<Archieve>:
|
||||||
|
name: 'archieve'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<Spam>:
|
||||||
|
name: 'spam'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<Allmails>:
|
||||||
|
name: 'allmails'
|
||||||
|
#FloatLayout:
|
||||||
|
# MDScrollViewRefreshLayout:
|
||||||
|
# id: refresh_layout
|
||||||
|
# refresh_callback: root.refresh_callback
|
||||||
|
# root_layout: root.set_root_layout()
|
||||||
|
# MDList:
|
||||||
|
# id: ml
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 20, 0, 5]
|
||||||
|
spacing: dp(5)
|
||||||
|
cols: 1
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
MDLabel:
|
||||||
|
text: ''
|
||||||
|
font_style: 'Body1'
|
||||||
|
bold: True
|
||||||
|
BoxLayout:
|
||||||
|
orientation:'vertical'
|
||||||
|
ScrollView:
|
||||||
|
id: scroll_y
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
Loader:
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
<Dialog>:
|
|
||||||
name: 'dialog'
|
|
||||||
Label:
|
|
||||||
text:"I have a good dialox box"
|
|
||||||
color: 0,0,0,1
|
|
||||||
<Test>:
|
<Test>:
|
||||||
name: 'test'
|
name: 'test'
|
||||||
Label:
|
Label:
|
||||||
text:"I am in test"
|
text:"I am in test"
|
||||||
color: 0,0,0,1
|
color: 0,0,0,1
|
||||||
|
|
||||||
<Create>:
|
|
||||||
name: 'create'
|
|
||||||
GridLayout:
|
|
||||||
rows: 5
|
|
||||||
cols: 1
|
|
||||||
padding: 60,60,60,60
|
|
||||||
spacing: 50
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
height: '32dp'
|
|
||||||
Label:
|
|
||||||
text: 'FROM'
|
|
||||||
color: 0,0,0,1
|
|
||||||
Spinner:
|
|
||||||
size_hint: 1,1
|
|
||||||
pos_hint: {"x":0,"top":1.}
|
|
||||||
pos: 10,10
|
|
||||||
id: spinner_id
|
|
||||||
text: app.showmeaddresses(name='text')
|
|
||||||
values: app.showmeaddresses(name='values')
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
height: '32dp'
|
|
||||||
Label:
|
|
||||||
text: 'TO'
|
|
||||||
color: 0,0,0,1
|
|
||||||
TextInput:
|
|
||||||
id: recipent
|
|
||||||
hint_text: 'To'
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
height: '32dp'
|
|
||||||
Label:
|
|
||||||
text: 'SUBJECT'
|
|
||||||
color: 0,0,0,1
|
|
||||||
TextInput:
|
|
||||||
id: subject
|
|
||||||
hint_text: 'SUBJECT'
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
height: '32dp'
|
|
||||||
Label:
|
|
||||||
text: 'BODY'
|
|
||||||
color: 0,0,0,1
|
|
||||||
TextInput:
|
|
||||||
id: message
|
|
||||||
multiline:True
|
|
||||||
size_hint: 1,2
|
|
||||||
|
|
||||||
Button:
|
|
||||||
text: 'send'
|
|
||||||
size_hint_y: 0.1
|
|
||||||
size_hint_x: 0.2
|
|
||||||
height: '32dp'
|
|
||||||
pos_hint: {'x': .5, 'y': 0.1}
|
|
||||||
on_press: root.send()
|
|
||||||
Button:
|
|
||||||
text: 'cancel'
|
|
||||||
size_hint_y: 0.1
|
|
||||||
size_hint_x: 0.2
|
|
||||||
height: '32dp'
|
|
||||||
pos_hint: {'x': .72, 'y': 0.1}
|
|
||||||
on_press: root.cancel()
|
|
||||||
|
|
||||||
<NewIdentity>:
|
|
||||||
name: 'newidentity'
|
|
||||||
GridLayout:
|
|
||||||
padding: '120dp'
|
|
||||||
cols: 1
|
|
||||||
Label:
|
|
||||||
text:"""Here you may generate as many addresses as you like. Indeed, creating and abandoning addresses is encouraged."""
|
|
||||||
line_height:1.5
|
|
||||||
text_size:(700,None)
|
|
||||||
color: 0,0,0,1
|
|
||||||
BoxLayout:
|
|
||||||
CheckBox:
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
rgb: 1,0,0
|
|
||||||
Ellipse:
|
|
||||||
pos:self.center_x-8, self.center_y-8
|
|
||||||
size:[16,16]
|
|
||||||
group: "money"
|
|
||||||
id:chk
|
|
||||||
text:"use a random number generator to make an address"
|
|
||||||
on_active:
|
|
||||||
root.checked = self.text
|
|
||||||
active:root.is_active
|
|
||||||
|
|
||||||
Label:
|
|
||||||
text: "use a random number generator to make an address"
|
|
||||||
color: 0,0,0,1
|
|
||||||
BoxLayout:
|
|
||||||
CheckBox:
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
rgb: 1,0,0
|
|
||||||
Ellipse:
|
|
||||||
pos:self.center_x-8, self.center_y-8
|
|
||||||
size:[16,16]
|
|
||||||
group: "money"
|
|
||||||
id:chk
|
|
||||||
text:"use a pseudo number generator to make an address"
|
|
||||||
on_active:
|
|
||||||
root.checked = self.text
|
|
||||||
active:not root.is_active
|
|
||||||
Label:
|
|
||||||
text: "use a pseudo number generator to make an address"
|
|
||||||
color: 0,0,0,1
|
|
||||||
Label:
|
|
||||||
color: 0,0,0,1
|
|
||||||
size_hint_x: .35
|
|
||||||
markup: True
|
|
||||||
text: "[b]{}[/b]".format("Randomly generated addresses")
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
height: '32dp'
|
|
||||||
Label:
|
|
||||||
text: "Label (not shown to anyone except you)"
|
|
||||||
color: 0,0,0,1
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
height: '32dp'
|
|
||||||
TextInput:
|
|
||||||
id: label
|
|
||||||
|
|
||||||
Button:
|
|
||||||
text: 'Cancel'
|
|
||||||
size_hint_y: 0.1
|
|
||||||
size_hint_x: 0.3
|
|
||||||
height: '32dp'
|
|
||||||
pos_hint: {'x': .1, 'y': 0.1}
|
|
||||||
Button:
|
|
||||||
text: 'Ok'
|
|
||||||
size_hint_y: 0.1
|
|
||||||
size_hint_x: 0.3
|
|
||||||
height: '32dp'
|
|
||||||
pos_hint: {'x': .5, 'y': 0.1}
|
|
||||||
on_press: root.generateaddress()
|
|
||||||
|
|
||||||
<Page>:
|
<Page>:
|
||||||
name: 'page'
|
name: 'page'
|
||||||
Label:
|
Label:
|
||||||
text: 'I am on description of my email yooooo'
|
text:"I am on page"
|
||||||
color: 0,0,0,1
|
color: 0,0,0,1
|
||||||
|
|
||||||
<AddressSuccessful>:
|
<Create>:
|
||||||
name: 'add_sucess'
|
name: 'create'
|
||||||
Label:
|
Loader:
|
||||||
text: 'Successfully created a new bit address'
|
|
||||||
|
<Credits>:
|
||||||
|
name: 'credits'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(200)
|
||||||
|
OneLineListItem:
|
||||||
|
text: "Available Credits"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .6, .35
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: root.available_credits
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
<DropDownWidget>:
|
||||||
|
ScrollView:
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height + 2 * self.parent.height/4
|
||||||
|
padding: dp(32)
|
||||||
|
spacing: 15
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
MDTextField:
|
||||||
|
id: ti
|
||||||
|
hint_text: 'type or select sender address'
|
||||||
|
size_hint_y: None
|
||||||
|
height: 100
|
||||||
|
font_size: '13sp'
|
||||||
|
multiline: False
|
||||||
|
required: True
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(40)
|
||||||
|
CustomSpinner:
|
||||||
|
background_color: app.theme_cls.primary_dark
|
||||||
|
id: btn
|
||||||
|
values: app.variable_1
|
||||||
|
on_text: root.auto_fill_fromaddr() if self.text != 'Select' else ''
|
||||||
|
option_cls: Factory.get("MySpinnerOption")
|
||||||
|
background_color: color_button if self.state == 'normal' else color_button_pressed
|
||||||
|
background_down: 'atlas://data/images/defaulttheme/spinner'
|
||||||
|
color: color_font
|
||||||
|
font_size: '12.5sp'
|
||||||
|
ArrowImg:
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
txt_input: txt_input
|
||||||
|
rv: rv
|
||||||
|
size : (890, 60)
|
||||||
|
size_hint: 1,1
|
||||||
|
MyTextInput:
|
||||||
|
id: txt_input
|
||||||
|
size_hint_y: None
|
||||||
|
font_size: '13sp'
|
||||||
|
height: self.parent.height/2
|
||||||
|
#hint_text: 'type or search recipients address starting with BM-'
|
||||||
|
hint_text: 'type, select or scan QR code for recipients address'
|
||||||
|
RV:
|
||||||
|
id: rv
|
||||||
|
MDTextField:
|
||||||
|
id: subject
|
||||||
|
hint_text: 'subject'
|
||||||
|
required: True
|
||||||
|
height: 100
|
||||||
|
font_size: '13sp'
|
||||||
|
size_hint_y: None
|
||||||
|
multiline: False
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
|
||||||
|
MDTextField:
|
||||||
|
id: body
|
||||||
|
multiline: True
|
||||||
|
hint_text: 'body'
|
||||||
|
size_hint_y: None
|
||||||
|
font_size: '13sp'
|
||||||
|
required: True
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
BoxLayout:
|
||||||
|
spacing:50
|
||||||
|
|
||||||
|
<MyTextInput>:
|
||||||
|
readonly: False
|
||||||
|
multiline: False
|
||||||
|
|
||||||
|
<SelectableLabel>:
|
||||||
|
# Draw a background to indicate selection
|
||||||
color: 0,0,0,1
|
color: 0,0,0,1
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: app.theme_cls.primary_dark if self.selected else (1, 1, 1, 0)
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
|
||||||
|
<RV>:
|
||||||
|
canvas:
|
||||||
|
Color:
|
||||||
|
rgba: 0,0,0,.2
|
||||||
|
|
||||||
|
Line:
|
||||||
|
rectangle: self.x +1 , self.y, self.width - 2, self.height -2
|
||||||
|
bar_width: 10
|
||||||
|
scroll_type:['bars']
|
||||||
|
viewclass: 'SelectableLabel'
|
||||||
|
SelectableRecycleBoxLayout:
|
||||||
|
default_size: None, dp(20)
|
||||||
|
default_size_hint: 1, None
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
orientation: 'vertical'
|
||||||
|
multiselect: False
|
||||||
|
|
||||||
|
|
||||||
|
<Login>:
|
||||||
|
name: 'login'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(750)
|
||||||
|
padding: dp(10)
|
||||||
|
BoxLayout:
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Body1'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "You may generate addresses by using either random numbers or by using a passphrase If you use a passphrase, the address is called a deterministic; address The Random Number option is selected by default but deterministic addresses have several \n pros and cons:\n"
|
||||||
|
halign: 'center'
|
||||||
|
bold: True
|
||||||
|
color:app.theme_cls.primary_dark
|
||||||
|
BoxLayout:
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Caption'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "If talk about pros You can recreate your addresses on any computer from memory, You need-not worry about backing up your keys.dat file as long as you can remember your passphrase and aside talk about cons You must remember (or write down) your You must remember the address version number and the stream number along with your passphrase If you choose a weak passphrase and someone on the Internet can brute-force it, they can read your messages and send messages as you"
|
||||||
|
halign: 'center'
|
||||||
|
bold: True
|
||||||
|
color:app.theme_cls.primary_dark
|
||||||
|
MDCheckbox:
|
||||||
|
id: grp_chkbox_1
|
||||||
|
group: 'test'
|
||||||
|
active: True
|
||||||
|
allow_no_selection: False
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Caption'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "use a random number generator to make an address"
|
||||||
|
halign: 'center'
|
||||||
|
size_hint_y: None
|
||||||
|
bold: True
|
||||||
|
height: self.texture_size[1] + dp(4)
|
||||||
|
color: [0.941, 0, 0,1]
|
||||||
|
MDCheckbox:
|
||||||
|
id: grp_chkbox_1
|
||||||
|
group: 'test'
|
||||||
|
allow_no_selection: False
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Caption'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "use a pseudo number generator to make an address"
|
||||||
|
halign: 'center'
|
||||||
|
size_hint_y: None
|
||||||
|
bold: True
|
||||||
|
color: [0.941, 0, 0,1]
|
||||||
|
height: self.texture_size[1] + dp(4)
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
height: dp(40)
|
||||||
|
on_press: app.root.ids.scr_mngr.current = 'random'
|
||||||
|
on_press: app.root.ids.sc7.reset_address_label()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'proceed'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
<Random>:
|
||||||
|
name: 'random'
|
||||||
|
ScrollView:
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
padding: dp(20)
|
||||||
|
spacing: 100
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Body1'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "Random Addresses"
|
||||||
|
halign: 'center'
|
||||||
|
bold: True
|
||||||
|
color:app.theme_cls.primary_dark
|
||||||
|
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Body1'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "Here you may generate as many addresses as you like, Indeed creating and abandoning addresses is encouraged"
|
||||||
|
halign: 'center'
|
||||||
|
bold: True
|
||||||
|
color:app.theme_cls.primary_dark
|
||||||
|
|
||||||
|
MDTextField:
|
||||||
|
id: label
|
||||||
|
multiline: True
|
||||||
|
hint_text: "Label"
|
||||||
|
required: True
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
on_text: root.add_validation(self)
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
height: dp(40)
|
||||||
|
on_release: root.generateaddress(app)
|
||||||
|
opposite_colors: True
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'next'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
<Setting>:
|
||||||
|
name: 'set'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(500)
|
||||||
|
OneLineListItem:
|
||||||
|
text: "SERVER SETTINGS"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .6, .55
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Server'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
OneLineListItem:
|
||||||
|
text: "DATA SETTINGS"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .6, .55
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Import or export data'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
OneLineListItem:
|
||||||
|
text: "OTHER SETTINGS"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .6, .55
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Restart background service'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Body1'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "bitmessage is 11 seconds behind the network"
|
||||||
|
halign: 'center'
|
||||||
|
bold: True
|
||||||
|
color: [0.941, 0, 0,1]
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
MDCheckbox:
|
||||||
|
id: chkbox
|
||||||
|
size_hint: None, None
|
||||||
|
size: dp(48), dp(64)
|
||||||
|
active: True
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Body1'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "show settings (for advanced users only)"
|
||||||
|
halign: 'left'
|
||||||
|
bold: True
|
||||||
|
color: app.theme_cls.primary_dark
|
||||||
|
|
||||||
|
<MyAddress>:
|
||||||
|
name: 'myaddress'
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
SearchBar:
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 0, 0, 5]
|
||||||
|
cols: 1
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
MDLabel:
|
||||||
|
text: 'My Addresses'
|
||||||
|
font_style: 'Body1'
|
||||||
|
bold: True
|
||||||
|
FloatLayout:
|
||||||
|
MDScrollViewRefreshLayout:
|
||||||
|
id: refresh_layout
|
||||||
|
refresh_callback: root.refresh_callback
|
||||||
|
root_layout: root.set_root_layout()
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
Loader:
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<AddressBook>:
|
||||||
|
name: 'addressbook'
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing: dp(5)
|
||||||
|
SearchBar:
|
||||||
|
GridLayout:
|
||||||
|
id: identi_tag
|
||||||
|
padding: [20, 0, 0, 5]
|
||||||
|
cols: 1
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
MDLabel:
|
||||||
|
text: ''
|
||||||
|
font_style: 'Body1'
|
||||||
|
bold: True
|
||||||
|
BoxLayout:
|
||||||
|
orientation:'vertical'
|
||||||
|
ScrollView:
|
||||||
|
id: scroll_y
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
Loader:
|
||||||
|
ComposerButton:
|
||||||
|
|
||||||
|
<Payment>:
|
||||||
|
name: 'payment'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
padding: [dp(app.window_size[0]/16 if app.window_size[0] <= 720 else app.window_size[0]/6 if app.window_size[0] <= 800 else app.window_size[0]/18), dp(10)]
|
||||||
|
spacing: 12
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height + dp(app.window_size[1]) if app.window_size[1] > app.window_size[0] else dp(app.window_size[0])
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
padding: dp(5)
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: app.theme_cls.primary_dark
|
||||||
|
Rectangle:
|
||||||
|
# self here refers to the widget i.e FloatLayout
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
MDLabel:
|
||||||
|
size_hint_y: None
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: 'Platinum'
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: 'We provide subscriptions for proof of work calculation for first month. '
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDLabel:
|
||||||
|
id: free_pak
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: '€ 50.0'
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDRaisedButton:
|
||||||
|
canvas:
|
||||||
|
Color:
|
||||||
|
rgb: (0.93, 0.93, 0.93)
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
size_hint: 1, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.get_available_credits(self)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Get Free Credits'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (0,0,0,1)
|
||||||
|
halign: 'center'
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
padding: dp(5)
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: app.theme_cls.primary_dark
|
||||||
|
Rectangle:
|
||||||
|
# self here refers to the widget i.e FloatLayout
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
MDLabel:
|
||||||
|
size_hint_y: None
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: 'Silver'
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: 'We provide for proof of work calculation for six month. '
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: '€ 100.0'
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDRaisedButton:
|
||||||
|
canvas:
|
||||||
|
Color:
|
||||||
|
rgb: (0.93, 0.93, 0.93)
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
size_hint: 1, None
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Get Monthly Credits'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (0,0,0,1)
|
||||||
|
halign: 'center'
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
padding: dp(5)
|
||||||
|
canvas.before:
|
||||||
|
Color:
|
||||||
|
rgba: app.theme_cls.primary_dark
|
||||||
|
Rectangle:
|
||||||
|
# self here refers to the widget i.e FloatLayout
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
MDLabel:
|
||||||
|
size_hint_y: None
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: 'Gold'
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: 'We provide for proof of work calculation for 1years. '
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: '€ 500.0'
|
||||||
|
halign: 'center'
|
||||||
|
color: 1,1,1,1
|
||||||
|
MDRaisedButton:
|
||||||
|
canvas:
|
||||||
|
Color:
|
||||||
|
rgb: (0.93, 0.93, 0.93)
|
||||||
|
Rectangle:
|
||||||
|
pos: self.pos
|
||||||
|
size: self.size
|
||||||
|
size_hint: 1, None
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Get Yearly Credits'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (0,0,0,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
|
||||||
|
<GrashofPopup>:
|
||||||
|
id: popup
|
||||||
|
size_hint : (None,None)
|
||||||
|
height: 2*(label.height + address.height) + 10
|
||||||
|
width :app.window_size[0] - (app.window_size[0]/10 if app.app_platform == 'android' else app.window_size[0]/4)
|
||||||
|
title: 'add contact\'s'
|
||||||
|
background: './images/popup.jpeg'
|
||||||
|
title_size: sp(20)
|
||||||
|
title_color: 0.4, 0.3765, 0.3451, 1
|
||||||
|
auto_dismiss: False
|
||||||
|
separator_color: 0.3529, 0.3922, 0.102, 0.7
|
||||||
|
BoxLayout:
|
||||||
|
size_hint_y: 0.5
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing:dp(20)
|
||||||
|
id: popup_box
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
MDTextField:
|
||||||
|
id: label
|
||||||
|
multiline: False
|
||||||
|
hint_text: "Label"
|
||||||
|
required: True
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
on_text: root.checkLabel_valid(self)
|
||||||
|
MDTextField:
|
||||||
|
id: address
|
||||||
|
hint_text: "Address"
|
||||||
|
required: True
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
on_text: root.checkAddress_valid(self)
|
||||||
|
BoxLayout:
|
||||||
|
spacing:5
|
||||||
|
orientation: 'horizontal'
|
||||||
|
MDRaisedButton:
|
||||||
|
id: save_addr
|
||||||
|
size_hint: 1.5, None
|
||||||
|
height: dp(40)
|
||||||
|
on_release:
|
||||||
|
root.savecontact()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Save'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 1.5, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.dismiss()
|
||||||
|
on_press: root.close_pop()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Cancel'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 2, None
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Scan QR code'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
|
||||||
|
<NetworkStat>:
|
||||||
|
name: 'networkstat'
|
||||||
|
MDTabbedPanel:
|
||||||
|
id: tab_panel
|
||||||
|
tab_display_mode:'text'
|
||||||
|
|
||||||
|
MDTab:
|
||||||
|
name: 'connections'
|
||||||
|
text: "Total connections"
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(200)
|
||||||
|
OneLineListItem:
|
||||||
|
text: "Total Connections"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .6, .35
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: root.text_variable_1
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDTab:
|
||||||
|
name: 'processes'
|
||||||
|
text: 'Processes'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
MDList:
|
||||||
|
id: ml
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(500)
|
||||||
|
OneLineListItem:
|
||||||
|
text: "person-to-person"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .7, .6
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: root.text_variable_2
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
OneLineListItem:
|
||||||
|
text: "Brodcast"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .7, .6
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: root.text_variable_3
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
OneLineListItem:
|
||||||
|
text: "publickeys"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .7, .6
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: root.text_variable_4
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
OneLineListItem:
|
||||||
|
text: "objects"
|
||||||
|
BoxLayout:
|
||||||
|
AnchorLayout:
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: .7, .6
|
||||||
|
height: dp(40)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: root.text_variable_5
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
<MailDetail>:
|
||||||
|
name: 'mailDetail'
|
||||||
|
ScrollView:
|
||||||
|
do_scroll_x: False
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(500) + self.minimum_height
|
||||||
|
padding: dp(32)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Headline'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: root.subject
|
||||||
|
halign: 'left'
|
||||||
|
font_size: '20sp'
|
||||||
|
CopyTextBtn:
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "From: " + root.from_addr
|
||||||
|
halign: 'left'
|
||||||
|
CopyTextBtn:
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "To: " + root.to_addr
|
||||||
|
halign: 'left'
|
||||||
|
CopyTextBtn:
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: root.status
|
||||||
|
halign: 'left'
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: root.message
|
||||||
|
halign: 'left'
|
||||||
|
bold: True
|
||||||
|
CopyTextBtn:
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(100) + self.minimum_height
|
||||||
|
Loader:
|
||||||
|
|
||||||
|
<CopyTextBtn@Button>:
|
||||||
|
id: cpyButton
|
||||||
|
color: 0,0,0,1
|
||||||
|
background_color: (0,0,0,0)
|
||||||
|
center_x: self.parent.center_x * 2 - self.parent.parent.padding[0]/2
|
||||||
|
center_y: self.parent.center_y
|
||||||
|
on_press:app.root.ids.sc14.copy_composer_text(self)
|
||||||
|
Image:
|
||||||
|
source: './images/copy_text.png'
|
||||||
|
center_x: self.parent.center_x
|
||||||
|
center_y: self.parent.center_y
|
||||||
|
size: 20, 20
|
||||||
|
|
||||||
|
<ComposerButton@BoxLayout>:
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(56)
|
||||||
|
spacing: '10dp'
|
||||||
|
pos_hint: {'center_x':0.45, 'center_y': .1}
|
||||||
|
|
||||||
|
Widget:
|
||||||
|
|
||||||
|
MDFloatingActionButton:
|
||||||
|
icon: 'plus'
|
||||||
|
opposite_colors: True
|
||||||
|
elevation_normal: 8
|
||||||
|
md_bg_color: [0.941, 0, 0,1]
|
||||||
|
on_press: app.root.ids.scr_mngr.current = 'create'
|
||||||
|
on_press: app.clear_composer()
|
||||||
|
|
||||||
|
<MyaddDetailPopup>:
|
||||||
|
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 if app.app_platform == 'android' else app.window_size[0]/4)
|
||||||
|
background: './images/popup.jpeg'
|
||||||
|
auto_dismiss: False
|
||||||
|
separator_height: 0
|
||||||
|
BoxLayout:
|
||||||
|
id: myadd_popup_box
|
||||||
|
size_hint_y: None
|
||||||
|
spacing:dp(70)
|
||||||
|
orientation: 'vertical'
|
||||||
|
BoxLayout:
|
||||||
|
size_hint_y: None
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing:dp(25)
|
||||||
|
MDLabel:
|
||||||
|
id: myaddr_label
|
||||||
|
font_style: 'Title'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "Label"
|
||||||
|
font_size: '17sp'
|
||||||
|
halign: 'left'
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: root.address_label
|
||||||
|
font_size: '15sp'
|
||||||
|
halign: 'left'
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "Address"
|
||||||
|
font_size: '17sp'
|
||||||
|
halign: 'left'
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: root.address
|
||||||
|
font_size: '15sp'
|
||||||
|
halign: 'left'
|
||||||
|
BoxLayout:
|
||||||
|
id: my_add_btn
|
||||||
|
spacing:5
|
||||||
|
orientation: 'horizontal'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 2, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.send_message_from()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Send message from'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 1.5, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.dismiss()
|
||||||
|
on_press: app.root.ids.scr_mngr.current = 'showqrcode'
|
||||||
|
on_press: app.root.ids.sc15.qrdisplay()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Show QR code'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 1.5, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.dismiss()
|
||||||
|
on_press: root.close_pop()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Cancel'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
<AddbookDetailPopup>:
|
||||||
|
id: addbook_popup
|
||||||
|
size_hint : (None,None)
|
||||||
|
height: 4*(add_label.height)
|
||||||
|
width :app.window_size[0] - (app.window_size[0]/10 if app.app_platform == 'android' else app.window_size[0]/4)
|
||||||
|
background: './images/popup.jpeg'
|
||||||
|
separator_height: 0
|
||||||
|
auto_dismiss: False
|
||||||
|
BoxLayout:
|
||||||
|
size_hint_y: None
|
||||||
|
spacing:dp(70)
|
||||||
|
id: addbook_popup_box
|
||||||
|
orientation: 'vertical'
|
||||||
|
BoxLayout:
|
||||||
|
size_hint_y: None
|
||||||
|
orientation: 'vertical'
|
||||||
|
spacing:dp(20)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "Label"
|
||||||
|
font_size: '17sp'
|
||||||
|
halign: 'left'
|
||||||
|
MDTextField:
|
||||||
|
id: add_label
|
||||||
|
font_style: 'Subhead'
|
||||||
|
font_size: '15sp'
|
||||||
|
halign: 'left'
|
||||||
|
text: root.address_label
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
required: True
|
||||||
|
helper_text_mode: "on_error"
|
||||||
|
on_text: root.checkLabel_valid(self)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: "Address"
|
||||||
|
font_size: '17sp'
|
||||||
|
halign: 'left'
|
||||||
|
MDLabel:
|
||||||
|
id: address
|
||||||
|
font_style: 'Subhead'
|
||||||
|
theme_text_color: 'Primary'
|
||||||
|
text: root.address
|
||||||
|
font_size: '15sp'
|
||||||
|
halign: 'left'
|
||||||
|
BoxLayout:
|
||||||
|
id: addbook_btn
|
||||||
|
spacing:5
|
||||||
|
orientation: 'horizontal'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 2, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.send_message_to()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Send message to'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 1.5, None
|
||||||
|
height: dp(40)
|
||||||
|
font_size: '10sp'
|
||||||
|
on_press: root.update_addbook_label(root.address)
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Save'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
MDRaisedButton:
|
||||||
|
size_hint: 1.5, None
|
||||||
|
height: dp(40)
|
||||||
|
on_press: root.dismiss()
|
||||||
|
on_press: root.close_pop()
|
||||||
|
MDLabel:
|
||||||
|
font_style: 'Title'
|
||||||
|
text: 'Cancel'
|
||||||
|
font_size: '13sp'
|
||||||
|
color: (1,1,1,1)
|
||||||
|
halign: 'center'
|
||||||
|
|
||||||
|
<ShowQRCode>:
|
||||||
|
name: 'showqrcode'
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
id: qr
|
||||||
|
|
||||||
|
|
||||||
|
<ArrowImg@Image>:
|
||||||
|
source: './images/down-arrow.png' if self.parent.is_open == True else './images/right-arrow.png'
|
||||||
|
size: 15, 15
|
||||||
|
x: self.parent.x + self.parent.width - self.width - 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)
|
||||||
|
|
||||||
|
|
||||||
|
<LoadingPopup>:
|
||||||
|
separator_color: 1, 1, 1, 1
|
||||||
|
background: "White.png"
|
||||||
|
Button:
|
||||||
|
id: btn
|
||||||
|
disabled: True
|
||||||
|
background_disabled_normal: "White.png"
|
||||||
|
Image:
|
||||||
|
source: './images/loader.zip'
|
||||||
|
anim_delay: 0
|
||||||
|
#mipmap: True
|
||||||
|
size: root.size
|
||||||
|
|
||||||
|
|
||||||
|
<Loader@MDSpinner>:
|
||||||
|
id: spinner
|
||||||
|
size_hint: None, None
|
||||||
|
size: dp(46), dp(46)
|
||||||
|
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
|
||||||
|
active: False
|
|
@ -1,393 +1,2482 @@
|
||||||
import kivy_helper_search
|
"""
|
||||||
|
Bitmessage android(mobile) interface
|
||||||
|
"""
|
||||||
|
# pylint: disable=relative-import, import-error, no-name-in-module
|
||||||
|
# pylint: disable=too-few-public-methods, too-many-lines, unused-argument
|
||||||
import os
|
import os
|
||||||
import queues
|
|
||||||
import shutdown
|
|
||||||
import state
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from kivy.app import App
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.properties import BooleanProperty
|
|
||||||
from kivy.clock import Clock
|
|
||||||
from navigationdrawer import NavigationDrawer
|
|
||||||
from kivy.properties import ObjectProperty, StringProperty, ListProperty
|
|
||||||
from kivy.uix.screenmanager import Screen
|
|
||||||
from kivy.uix.textinput import TextInput
|
|
||||||
from kivymd.theming import ThemeManager
|
|
||||||
from kivymd.toolbar import Toolbar
|
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from helper_ackPayload import genAckPayload
|
from functools import partial
|
||||||
from addresses import decodeAddress, addBMIfNotPresent
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from helper_sql import sqlExecute
|
from kivy.app import App
|
||||||
|
from kivy.clock import Clock
|
||||||
|
from kivy.core.clipboard import Clipboard
|
||||||
|
from kivy.core.window import Window
|
||||||
|
from kivy.lang import Builder
|
||||||
|
from kivy.properties import (
|
||||||
|
BooleanProperty,
|
||||||
|
ListProperty,
|
||||||
|
NumericProperty,
|
||||||
|
ObjectProperty,
|
||||||
|
StringProperty
|
||||||
|
)
|
||||||
|
from kivy.uix.behaviors import FocusBehavior
|
||||||
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
|
from kivy.uix.button import Button
|
||||||
|
from kivy.uix.carousel import Carousel
|
||||||
|
from kivy.uix.image import Image
|
||||||
|
from kivy.uix.label import Label
|
||||||
|
from kivy.uix.popup import Popup
|
||||||
|
from kivy.uix.recycleboxlayout import RecycleBoxLayout
|
||||||
|
from kivy.uix.recycleview import RecycleView
|
||||||
|
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
|
||||||
|
from kivy.uix.recycleview.views import RecycleDataViewBehavior
|
||||||
|
from kivy.uix.screenmanager import Screen
|
||||||
|
from kivy.uix.spinner import Spinner
|
||||||
|
from kivy.uix.textinput import TextInput
|
||||||
|
from kivy.utils import platform
|
||||||
|
|
||||||
statusIconColor = 'red'
|
import kivy_helper_search
|
||||||
|
from kivymd.button import MDIconButton
|
||||||
|
from kivymd.dialog import MDDialog
|
||||||
|
from kivymd.label import MDLabel
|
||||||
|
from kivymd.list import (
|
||||||
|
ILeftBody,
|
||||||
|
ILeftBodyTouch,
|
||||||
|
IRightBodyTouch,
|
||||||
|
TwoLineAvatarIconListItem,
|
||||||
|
TwoLineListItem
|
||||||
|
)
|
||||||
|
from kivymd.navigationdrawer import (
|
||||||
|
MDNavigationDrawer,
|
||||||
|
NavigationDrawerHeaderBase
|
||||||
|
)
|
||||||
|
from kivymd.selectioncontrols import MDCheckbox
|
||||||
|
from kivymd.theming import ThemeManager
|
||||||
|
|
||||||
|
import queues
|
||||||
|
from semaphores import kivyuisignaler
|
||||||
|
|
||||||
|
import state
|
||||||
|
from uikivysignaler import UIkivySignaler
|
||||||
|
|
||||||
|
import identiconGeneration
|
||||||
|
from addresses import addBMIfNotPresent, decodeAddress
|
||||||
|
|
||||||
|
|
||||||
class NavigateApp(App, TextInput):
|
def toast(text):
|
||||||
"""Application uses kivy in which base Class of Navigate App inherits from the App class."""
|
"""Function displays toast message"""
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
theme_cls = ThemeManager()
|
from kivymd.toast.kivytoast import toast
|
||||||
nav_drawer = ObjectProperty()
|
toast(text)
|
||||||
|
return
|
||||||
def build(self):
|
|
||||||
"""Return a main_widget as a root widget.
|
|
||||||
|
|
||||||
An application can be built if you return a widget on build(), or if you set
|
|
||||||
self.root.
|
|
||||||
"""
|
|
||||||
main_widget = Builder.load_file(
|
|
||||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
|
||||||
self.nav_drawer = Navigator()
|
|
||||||
return main_widget
|
|
||||||
|
|
||||||
def getCurrentAccountData(self, text):
|
|
||||||
"""Get Current Address Account Data."""
|
|
||||||
state.association = text
|
|
||||||
self.root.ids.sc1.clear_widgets()
|
|
||||||
self.root.ids.sc2.clear_widgets()
|
|
||||||
self.root.ids.sc3.clear_widgets()
|
|
||||||
self.root.ids.sc1.add_widget(Inbox())
|
|
||||||
self.root.ids.sc2.add_widget(Sent())
|
|
||||||
self.root.ids.sc3.add_widget(Trash())
|
|
||||||
self.root.ids.toolbar.title = BMConfigParser().get(
|
|
||||||
state.association, 'label') + '({})'.format(state.association)
|
|
||||||
Inbox()
|
|
||||||
Sent()
|
|
||||||
Trash()
|
|
||||||
|
|
||||||
def say_exit(self):
|
|
||||||
"""Exit the application as uses shutdown PyBitmessage."""
|
|
||||||
print("**************************EXITING FROM APPLICATION*****************************")
|
|
||||||
App.get_running_app().stop()
|
|
||||||
shutdown.doCleanShutdown()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def showmeaddresses(name="text"):
|
|
||||||
"""Show the addresses in spinner to make as dropdown."""
|
|
||||||
if name == "text":
|
|
||||||
return BMConfigParser().addresses()[0]
|
|
||||||
elif name == "values":
|
|
||||||
return BMConfigParser().addresses()
|
|
||||||
|
|
||||||
def update_index(self, data_index, index):
|
|
||||||
"""Update index after archieve message to trash."""
|
|
||||||
if self.root.ids.scr_mngr.current == 'inbox':
|
|
||||||
self.root.ids.sc1.data[data_index]['index'] = index
|
|
||||||
elif self.root.ids.scr_mngr.current == 'sent':
|
|
||||||
self.root.ids.sc2.data[data_index]['index'] = index
|
|
||||||
elif self.root.ids.scr_mngr.current == 'trash':
|
|
||||||
self.root.ids.sc3.data[data_index]['index'] = index
|
|
||||||
|
|
||||||
def delete(self, data_index):
|
|
||||||
"""It will make delete using remove function."""
|
|
||||||
print("delete {}".format(data_index))
|
|
||||||
self._remove(data_index)
|
|
||||||
|
|
||||||
def archive(self, data_index):
|
|
||||||
"""It will make archieve using remove function."""
|
|
||||||
print("archive {}".format(data_index))
|
|
||||||
self._remove(data_index)
|
|
||||||
|
|
||||||
def _remove(self, data_index):
|
|
||||||
"""It will remove message by resetting the values in recycleview data."""
|
|
||||||
if self.root.ids.scr_mngr.current == 'inbox':
|
|
||||||
self.root.ids.sc1.data.pop(data_index)
|
|
||||||
self.root.ids.sc1.data = [{
|
|
||||||
'data_index': i,
|
|
||||||
'index': d['index'],
|
|
||||||
'height': d['height'],
|
|
||||||
'text': d['text']}
|
|
||||||
for i, d in enumerate(self.root.ids.sc1.data)
|
|
||||||
]
|
|
||||||
elif self.root.ids.scr_mngr.current == 'sent':
|
|
||||||
self.root.ids.sc2.data.pop(data_index)
|
|
||||||
self.root.ids.sc2.data = [{
|
|
||||||
'data_index': i,
|
|
||||||
'index': d['index'],
|
|
||||||
'height': d['height'],
|
|
||||||
'text': d['text']}
|
|
||||||
for i, d in enumerate(self.root.ids.sc2.data)
|
|
||||||
]
|
|
||||||
elif self.root.ids.scr_mngr.current == 'trash':
|
|
||||||
self.root.ids.sc3.data.pop(data_index)
|
|
||||||
self.root.ids.sc3.data = [{
|
|
||||||
'data_index': i,
|
|
||||||
'index': d['index'],
|
|
||||||
'height': d['height'],
|
|
||||||
'text': d['text']}
|
|
||||||
for i, d in enumerate(self.root.ids.sc3.data)
|
|
||||||
]
|
|
||||||
|
|
||||||
def getInboxMessageDetail(self, instance):
|
|
||||||
"""It will get message detail after make selected message description."""
|
|
||||||
try:
|
|
||||||
self.root.ids.scr_mngr.current = 'page'
|
|
||||||
except AttributeError:
|
|
||||||
self.parent.manager.current = 'page'
|
|
||||||
print('Message Clicked {}'.format(instance))
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getCurrentAccount():
|
|
||||||
"""It uses to get current account label."""
|
|
||||||
return BMConfigParser().get(state.association, 'label') + '({})'.format(state.association)
|
|
||||||
|
|
||||||
|
|
||||||
class Navigator(NavigationDrawer):
|
class Navigatorss(MDNavigationDrawer):
|
||||||
"""Navigator class uses NavigationDrawer.
|
"""Navigator class (image, title and logo)"""
|
||||||
|
|
||||||
It is an UI panel that shows our app's main navigation menu
|
|
||||||
It is hidden when not in use, but appears when the user swipes
|
|
||||||
a finger from the left edge of the screen or, when at the top
|
|
||||||
level of the app, the user touches the drawer icon in the app bar
|
|
||||||
"""
|
|
||||||
|
|
||||||
image_source = StringProperty('images/qidenticon_two.png')
|
image_source = StringProperty('images/qidenticon_two.png')
|
||||||
title = StringProperty('Navigation')
|
title = StringProperty('Navigation')
|
||||||
|
drawer_logo = StringProperty()
|
||||||
|
|
||||||
|
|
||||||
class Inbox(Screen):
|
class Inbox(Screen):
|
||||||
"""Inbox Screen uses screen to show widgets of screens."""
|
"""Inbox Screen uses screen to show widgets of screens."""
|
||||||
|
queryreturn = ListProperty()
|
||||||
data = ListProperty()
|
has_refreshed = True
|
||||||
|
account = StringProperty()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Method Parsing the address."""
|
||||||
super(Inbox, self).__init__(*args, **kwargs)
|
super(Inbox, self).__init__(*args, **kwargs)
|
||||||
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_defaultAddress():
|
||||||
|
"""This method set's default address"""
|
||||||
if state.association == '':
|
if state.association == '':
|
||||||
state.association = Navigator().ids.btn.text
|
if BMConfigParser().addresses():
|
||||||
|
state.association = BMConfigParser().addresses()[0]
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock schdule for method inbox accounts."""
|
||||||
|
self.loadMessagelist()
|
||||||
|
|
||||||
|
def loadMessagelist(self, where="", what=""):
|
||||||
|
"""Load Inbox list for Inbox messages."""
|
||||||
|
# pylint: disable=too-many-locals
|
||||||
|
self.set_defaultAddress()
|
||||||
|
self.account = state.association
|
||||||
|
if state.searcing_text:
|
||||||
|
self.children[2].children[0].children[0].scroll_y = 1.0
|
||||||
|
where = ['subject', 'message']
|
||||||
|
what = state.searcing_text
|
||||||
|
xAddress = 'toaddress'
|
||||||
|
data = []
|
||||||
|
self.inboxDataQuery(xAddress, where, what)
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
if self.queryreturn:
|
||||||
|
self.ids.identi_tag.children[0].text = 'Inbox'
|
||||||
|
state.kivyapp.get_inbox_count()
|
||||||
|
src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
||||||
|
src_mng_obj.inbox_cnt.badge_text = state.inbox_count
|
||||||
|
for mail in self.queryreturn:
|
||||||
|
# third_text = mail[3].replace('\n', ' ')
|
||||||
|
data.append({
|
||||||
|
'text': mail[4].strip(),
|
||||||
|
'secondary_text': mail[5][:50] + '........' if len(
|
||||||
|
mail[5]) >= 50 else (mail[5] + ',' + mail[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
'msgid': mail[1]})
|
||||||
|
self.has_refreshed = True
|
||||||
|
self.set_mdList(data)
|
||||||
|
self.children[2].children[0].children[0].bind(
|
||||||
|
scroll_y=self.check_scroll_y)
|
||||||
|
else:
|
||||||
|
content = MDLabel(
|
||||||
|
font_style='Body1', theme_text_color='Primary',
|
||||||
|
text="No message found!" if state.searcing_text
|
||||||
|
else "yet no message for this account!!!!!!!!!!!!!",
|
||||||
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
|
self.ids.ml.add_widget(content)
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
|
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
||||||
|
"""This method used for retrieving inbox data"""
|
||||||
|
self.queryreturn = kivy_helper_search.search_sql(
|
||||||
|
xAddress, self.account, "inbox", where, what,
|
||||||
|
False, start_indx, end_indx)
|
||||||
|
|
||||||
|
def set_mdList(self, data):
|
||||||
|
"""This method is used to create the mdList"""
|
||||||
|
total_message = len(self.ids.ml.children)
|
||||||
|
for item in data:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text=item['text'], secondary_text=item['secondary_text'],
|
||||||
|
theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
meny.add_widget(AvatarSampleWidget(
|
||||||
|
source='./images/text_images/{}.png'.format(
|
||||||
|
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
||||||
|
meny.bind(on_press=partial(self.inbox_detail, item['msgid']))
|
||||||
|
carousel = Carousel(direction='right')
|
||||||
|
carousel.height = meny.height
|
||||||
|
carousel.size_hint_y = None
|
||||||
|
carousel.ignore_perpendicular_swipes = True
|
||||||
|
carousel.data_index = 0
|
||||||
|
carousel.min_move = 0.2
|
||||||
|
del_btn = Button(text='Delete')
|
||||||
|
del_btn.background_normal = ''
|
||||||
|
del_btn.background_color = (1, 0, 0, 1)
|
||||||
|
del_btn.bind(on_press=partial(self.delete, item['msgid']))
|
||||||
|
carousel.add_widget(del_btn)
|
||||||
|
carousel.add_widget(meny)
|
||||||
|
ach_btn = Button(text='Achieve')
|
||||||
|
ach_btn.background_color = (0, 1, 0, 1)
|
||||||
|
ach_btn.bind(on_press=partial(self.archive, item['msgid']))
|
||||||
|
carousel.add_widget(ach_btn)
|
||||||
|
carousel.index = 1
|
||||||
|
self.ids.ml.add_widget(carousel)
|
||||||
|
update_message = len(self.ids.ml.children)
|
||||||
|
self.has_refreshed = True if total_message != update_message else False
|
||||||
|
|
||||||
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
|
"""Loads data on scroll"""
|
||||||
|
if self.children[2].children[0].children[
|
||||||
|
0].scroll_y <= -0.0 and self.has_refreshed:
|
||||||
|
self.children[2].children[0].children[0].scroll_y = 0.06
|
||||||
|
total_message = len(self.ids.ml.children)
|
||||||
|
self.update_inbox_screen_on_scroll(total_message)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def update_inbox_screen_on_scroll(self, total_message, where="", what=""):
|
||||||
|
"""This method is used to load more data on scroll down"""
|
||||||
|
data = []
|
||||||
|
if state.searcing_text:
|
||||||
|
where = ['subject', 'message']
|
||||||
|
what = state.searcing_text
|
||||||
|
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
||||||
|
for mail in self.queryreturn:
|
||||||
|
# third_text = mail[3].replace('\n', ' ')
|
||||||
|
data.append({
|
||||||
|
'text': mail[4].strip(),
|
||||||
|
'secondary_text': mail[5][:50] + '........' if len(
|
||||||
|
mail[5]) >= 50 else (mail[5] + ',' + mail[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
'msgid': mail[1]})
|
||||||
|
self.set_mdList(data)
|
||||||
|
|
||||||
|
def inbox_detail(self, msg_id, *args):
|
||||||
|
"""Load inbox page details"""
|
||||||
|
state.detailPageType = 'inbox'
|
||||||
|
state.mail_id = msg_id
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[13].clear_widgets()
|
||||||
|
src_mng_obj.screens[13].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
|
|
||||||
|
def delete(self, data_index, instance, *args):
|
||||||
|
"""Delete inbox mail from inbox listing"""
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str(
|
||||||
|
data_index))
|
||||||
|
try:
|
||||||
|
msg_count_objs = (
|
||||||
|
self.parent.parent.parent.parent.children[2].children[0].ids)
|
||||||
|
except Exception:
|
||||||
|
msg_count_objs = (
|
||||||
|
self.parent.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids)
|
||||||
|
if int(state.inbox_count) > 0:
|
||||||
|
msg_count_objs.inbox_cnt.badge_text = str(
|
||||||
|
int(state.inbox_count) - 1)
|
||||||
|
msg_count_objs.trash_cnt.badge_text = str(
|
||||||
|
int(state.trash_count) + 1)
|
||||||
|
msg_count_objs.allmail_cnt.badge_text = str(
|
||||||
|
int(state.all_count) - 1)
|
||||||
|
state.inbox_count = str(
|
||||||
|
int(state.inbox_count) - 1)
|
||||||
|
state.trash_count = str(
|
||||||
|
int(state.trash_count) + 1)
|
||||||
|
state.all_count = str(
|
||||||
|
int(state.all_count) - 1)
|
||||||
|
if int(state.inbox_count) <= 0:
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
self.ids.ml.remove_widget(
|
||||||
|
instance.parent.parent)
|
||||||
|
toast('Deleted')
|
||||||
|
self.update_trash()
|
||||||
|
|
||||||
|
def archive(self, data_index, instance, *args):
|
||||||
|
"""Archive inbox mail from inbox listing"""
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;",
|
||||||
|
str(data_index))
|
||||||
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
|
self.update_trash()
|
||||||
|
|
||||||
|
def update_trash(self):
|
||||||
|
"""Update trash screen mails which is deleted from inbox"""
|
||||||
|
try:
|
||||||
|
self.parent.screens[4].clear_widgets()
|
||||||
|
self.parent.screens[4].add_widget(Trash())
|
||||||
|
except Exception:
|
||||||
|
self.parent.parent.screens[4].clear_widgets()
|
||||||
|
self.parent.parent.screens[4].add_widget(Trash())
|
||||||
|
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
def refresh_callback(self, *args):
|
||||||
|
"""Method updates the state of application,
|
||||||
|
While the spinner remains on the screen"""
|
||||||
|
def refresh_callback(interval):
|
||||||
|
"""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.loadMessagelist(state.association)
|
||||||
|
self.has_refreshed = True
|
||||||
|
self.ids.refresh_layout.refresh_done()
|
||||||
|
self.tick = 0
|
||||||
|
Clock.schedule_once(refresh_callback, 1)
|
||||||
|
|
||||||
|
# def set_root_layout(self):
|
||||||
|
# """Setting root layout"""
|
||||||
|
# return self.parent.parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
class MyAddress(Screen):
|
||||||
|
"""MyAddress screen uses screen to show widgets of screens."""
|
||||||
|
addresses_list = ListProperty()
|
||||||
|
has_refreshed = True
|
||||||
|
is_add_created = False
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Clock schdule for method Myaddress accounts."""
|
||||||
|
super(MyAddress, self).__init__(*args, **kwargs)
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""Clock Schdule for method inbox accounts."""
|
"""Clock schdule for method Myaddress accounts"""
|
||||||
self.inboxaccounts()
|
self.addresses_list = state.kivyapp.variable_1
|
||||||
print(dt)
|
if state.searcing_text:
|
||||||
|
self.ids.refresh_layout.scroll_y = 1.0
|
||||||
def inboxaccounts(self):
|
# filtered_list = filter(
|
||||||
"""Load inbox accounts."""
|
# lambda addr: self.filter_address(
|
||||||
account = state.association
|
# addr), BMConfigParser().addresses())
|
||||||
self.loadMessagelist(account, 'All', '')
|
filtered_list = [
|
||||||
|
x
|
||||||
def loadMessagelist(self, account, where="", what=""):
|
for x in BMConfigParser().addresses()
|
||||||
"""Load Inbox list for inbox messages."""
|
if self.filter_address(x)]
|
||||||
xAddress = "toaddress"
|
self.addresses_list = filtered_list
|
||||||
queryreturn = kivy_helper_search.search_sql(
|
self.addresses_list = [obj for obj in reversed(self.addresses_list)]
|
||||||
xAddress, account, 'inbox', where, what, False)
|
self.ids.identi_tag.children[0].text = ''
|
||||||
if queryreturn:
|
if self.addresses_list:
|
||||||
self.data = [{
|
self.ids.identi_tag.children[0].text = 'My Addresses'
|
||||||
'data_index': i,
|
self.has_refreshed = True
|
||||||
'index': 1,
|
self.set_mdList(0, 15)
|
||||||
'height': 48,
|
self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y)
|
||||||
'text': row[4]}
|
|
||||||
for i, row in enumerate(queryreturn)
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
self.data = [{
|
content = MDLabel(
|
||||||
'data_index': 1,
|
font_style='Body1', theme_text_color='Primary',
|
||||||
'index': 1,
|
text="No address found!" if state.searcing_text
|
||||||
'height': 48,
|
else "yet no address is created by user!!!!!!!!!!!!!",
|
||||||
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
]
|
self.ids.ml.add_widget(content)
|
||||||
|
if not state.searcing_text and not self.is_add_created:
|
||||||
|
try:
|
||||||
class Page(Screen):
|
self.manager.current = 'login'
|
||||||
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def set_mdList(self, first_index, last_index):
|
||||||
|
"""Creating the mdlist"""
|
||||||
|
data = []
|
||||||
|
for address in self.addresses_list[first_index:last_index]:
|
||||||
|
data.append({
|
||||||
|
'text': BMConfigParser().get(address, 'label'),
|
||||||
|
'secondary_text': address})
|
||||||
|
for item in data:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text=item['text'], secondary_text=item['secondary_text'],
|
||||||
|
theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
meny.add_widget(AvatarSampleWidget(
|
||||||
|
source='./images/text_images/{}.png'.format(
|
||||||
|
avatarImageFirstLetter(item['text'].strip()))))
|
||||||
|
meny.bind(on_press=partial(
|
||||||
|
self.myadd_detail, item['secondary_text'], item['text']))
|
||||||
|
self.ids.ml.add_widget(meny)
|
||||||
|
|
||||||
class AddressSuccessful(Screen):
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
|
"""Load data on scroll down"""
|
||||||
|
if self.ids.refresh_layout.scroll_y <= -0.0 and self.has_refreshed:
|
||||||
|
self.ids.refresh_layout.scroll_y = 0.06
|
||||||
|
my_addresses = len(self.ids.ml.children)
|
||||||
|
if my_addresses != len(self.addresses_list):
|
||||||
|
self.update_addressBook_on_scroll(my_addresses)
|
||||||
|
self.has_refreshed = True if my_addresses != len(
|
||||||
|
self.addresses_list) else False
|
||||||
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def update_addressBook_on_scroll(self, my_addresses):
|
||||||
|
"""Loads more data on scroll down"""
|
||||||
|
self.set_mdList(my_addresses, my_addresses + 20)
|
||||||
|
|
||||||
class Sent(Screen):
|
@staticmethod
|
||||||
"""Sent Screen uses screen to show widgets of screens."""
|
def myadd_detail(fromaddress, label, *args):
|
||||||
|
"""Load myaddresses details"""
|
||||||
|
p = MyaddDetailPopup()
|
||||||
|
p.open()
|
||||||
|
p.set_address(fromaddress, label)
|
||||||
|
|
||||||
data = ListProperty()
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
def refresh_callback(self, *args):
|
||||||
|
"""Method updates the state of application,
|
||||||
|
While the spinner remains on the screen"""
|
||||||
|
def refresh_callback(interval):
|
||||||
|
"""Method used for loading the myaddress screen data"""
|
||||||
|
state.searcing_text = ''
|
||||||
|
state.kivyapp.root.ids.sc10.children[2].active = False
|
||||||
|
self.children[2].children[2].ids.search_field.text = ''
|
||||||
|
self.has_refreshed = True
|
||||||
|
self.ids.ml.clear_widgets()
|
||||||
|
self.init_ui()
|
||||||
|
self.ids.refresh_layout.refresh_done()
|
||||||
|
self.tick = 0
|
||||||
|
Clock.schedule_once(refresh_callback, 1)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def filter_address(address):
|
||||||
|
"""Method will filter the my address list data"""
|
||||||
|
# if filter(lambda x: (state.searcing_text).lower() in x, [
|
||||||
|
# BMConfigParser().get(
|
||||||
|
# address, 'label').lower(), address.lower()]):
|
||||||
|
if [x for x in [BMConfigParser().get(
|
||||||
|
address, 'label').lower(), address.lower()] if (
|
||||||
|
state.searcing_text).lower() in x]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def set_root_layout(self):
|
||||||
|
"""Setting root layout"""
|
||||||
|
return self.manager.parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
class AddressBook(Screen):
|
||||||
|
"""AddressBook Screen uses screen to show widgets of screens"""
|
||||||
|
queryreturn = ListProperty()
|
||||||
|
has_refreshed = True
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Sent, self).__init__(*args, **kwargs)
|
"""Getting AddressBook Details"""
|
||||||
if state.association == '':
|
super(AddressBook, self).__init__(*args, **kwargs)
|
||||||
state.association = Navigator().ids.btn.text
|
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""Clock Schdule for method sent accounts."""
|
"""Clock Schdule for method AddressBook"""
|
||||||
self.sentaccounts()
|
self.loadAddresslist(None, 'All', '')
|
||||||
print(dt)
|
print dt
|
||||||
|
|
||||||
def sentaccounts(self):
|
def loadAddresslist(self, account, where="", what=""):
|
||||||
"""Load sent accounts."""
|
"""Clock Schdule for method AddressBook"""
|
||||||
account = state.association
|
if state.searcing_text:
|
||||||
self.loadSent(account, 'All', '')
|
self.ids.scroll_y.scroll_y = 1.0
|
||||||
|
where = ['label', 'address']
|
||||||
def loadSent(self, account, where="", what=""):
|
what = state.searcing_text
|
||||||
"""Load Sent list for Sent messages."""
|
xAddress = ''
|
||||||
xAddress = 'fromaddress'
|
self.ids.identi_tag.children[0].text = ''
|
||||||
queryreturn = kivy_helper_search.search_sql(
|
self.queryreturn = kivy_helper_search.search_sql(
|
||||||
xAddress, account, "sent", where, what, False)
|
xAddress, account, "addressbook", where, what, False)
|
||||||
if queryreturn:
|
self.queryreturn = [obj for obj in reversed(self.queryreturn)]
|
||||||
self.data = [{
|
if self.queryreturn:
|
||||||
'data_index': i,
|
self.ids.identi_tag.children[0].text = 'Address Book'
|
||||||
'index': 1,
|
self.has_refreshed = True
|
||||||
'height': 48,
|
self.set_mdList(0, 20)
|
||||||
'text': row[2]}
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
for i, row in enumerate(queryreturn)
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
self.data = [{
|
content = MDLabel(
|
||||||
'data_index': 1,
|
font_style='Body1', theme_text_color='Primary',
|
||||||
'index': 1,
|
text="No contact found!" if state.searcing_text
|
||||||
'height': 48,
|
else "No contact found yet...... ",
|
||||||
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
]
|
self.ids.ml.add_widget(content)
|
||||||
|
|
||||||
|
def set_mdList(self, start_index, end_index):
|
||||||
|
"""Creating the mdList"""
|
||||||
|
for item in self.queryreturn[start_index:end_index]:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text=item[0], secondary_text=item[1], theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
meny.add_widget(AvatarSampleWidget(
|
||||||
|
source='./images/text_images/{}.png'.format(
|
||||||
|
avatarImageFirstLetter(item[0].strip()))))
|
||||||
|
meny.bind(on_press=partial(
|
||||||
|
self.addBook_detail, item[1], item[0]))
|
||||||
|
carousel = Carousel(direction='right')
|
||||||
|
carousel.height = meny.height
|
||||||
|
carousel.size_hint_y = None
|
||||||
|
carousel.ignore_perpendicular_swipes = True
|
||||||
|
carousel.data_index = 0
|
||||||
|
carousel.min_move = 0.2
|
||||||
|
del_btn = Button(text='Delete')
|
||||||
|
del_btn.background_normal = ''
|
||||||
|
del_btn.background_color = (1, 0, 0, 1)
|
||||||
|
del_btn.bind(on_press=partial(self.delete_address, item[1]))
|
||||||
|
carousel.add_widget(del_btn)
|
||||||
|
carousel.add_widget(meny)
|
||||||
|
carousel.index = 1
|
||||||
|
self.ids.ml.add_widget(carousel)
|
||||||
|
|
||||||
class Trash(Screen):
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
"""Trash Screen uses screen to show widgets of screens."""
|
"""Load data on scroll"""
|
||||||
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
||||||
data = ListProperty()
|
self.ids.scroll_y.scroll_y = 0.06
|
||||||
|
exist_addresses = len(self.ids.ml.children)
|
||||||
def __init__(self, *args, **kwargs):
|
if exist_addresses != len(self.queryreturn):
|
||||||
super(Trash, self).__init__(*args, **kwargs)
|
self.update_addressBook_on_scroll(exist_addresses)
|
||||||
if state.association == '':
|
self.has_refreshed = True if exist_addresses != len(
|
||||||
state.association = Navigator().ids.btn.text
|
self.queryreturn) else False
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
|
||||||
"""Clock Schdule for method inbox accounts."""
|
|
||||||
self.inboxaccounts()
|
|
||||||
print(dt)
|
|
||||||
|
|
||||||
def inboxaccounts(self):
|
|
||||||
"""Load inbox accounts."""
|
|
||||||
account = state.association
|
|
||||||
self.loadTrashlist(account, 'All', '')
|
|
||||||
|
|
||||||
def loadTrashlist(self, account, where="", what=""):
|
|
||||||
"""Load Trash list for trashed messages."""
|
|
||||||
xAddress = "toaddress"
|
|
||||||
queryreturn = kivy_helper_search.search_sql(
|
|
||||||
xAddress, account, 'trash', where, what, False)
|
|
||||||
if queryreturn:
|
|
||||||
self.data = [{
|
|
||||||
'data_index': i,
|
|
||||||
'index': 1,
|
|
||||||
'height': 48,
|
|
||||||
'text': row[4]}
|
|
||||||
for i, row in enumerate(queryreturn)
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
self.data = [{
|
pass
|
||||||
'data_index': 1,
|
|
||||||
'index': 1,
|
def update_addressBook_on_scroll(self, exist_addresses):
|
||||||
'height': 48,
|
"""Load more data on scroll down"""
|
||||||
'text': "yet no message for this account!!!!!!!!!!!!!"}
|
self.set_mdList(exist_addresses, exist_addresses + 5)
|
||||||
]
|
|
||||||
|
@staticmethod
|
||||||
|
def refreshs(*args):
|
||||||
|
"""Refresh the Widget"""
|
||||||
|
# state.navinstance.ids.sc11.ids.ml.clear_widgets()
|
||||||
|
# state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def addBook_detail(address, label, *args):
|
||||||
|
"""Addressbook details"""
|
||||||
|
p = AddbookDetailPopup()
|
||||||
|
p.open()
|
||||||
|
p.set_addbook_data(address, label)
|
||||||
|
|
||||||
|
def delete_address(self, address, instance, *args):
|
||||||
|
"""Delete inbox mail from inbox listing"""
|
||||||
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
|
if len(self.ids.ml.children) == 0:
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
sqlExecute(
|
||||||
|
"DELETE FROM addressbook WHERE address = '{}';".format(address))
|
||||||
|
|
||||||
|
|
||||||
class Dialog(Screen):
|
class SelectableRecycleBoxLayout(
|
||||||
"""Dialog Screen uses screen to show widgets of screens."""
|
FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout):
|
||||||
|
"""Adds selection and focus behaviour to the view"""
|
||||||
|
# pylint: disable = too-many-ancestors, duplicate-bases
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Test(Screen):
|
class SelectableLabel(RecycleDataViewBehavior, Label):
|
||||||
"""Test Screen uses screen to show widgets of screens."""
|
"""Add selection support to the Label"""
|
||||||
|
index = None
|
||||||
|
selected = BooleanProperty(False)
|
||||||
|
selectable = BooleanProperty(True)
|
||||||
|
|
||||||
pass
|
def refresh_view_attrs(self, rv, index, data):
|
||||||
|
"""Catch and handle the view changes"""
|
||||||
|
self.index = index
|
||||||
|
return super(SelectableLabel, self).refresh_view_attrs(
|
||||||
|
rv, index, data)
|
||||||
|
|
||||||
|
# pylint: disable=inconsistent-return-statements
|
||||||
|
def on_touch_down(self, touch):
|
||||||
|
"""Add selection on touch down"""
|
||||||
|
if super(SelectableLabel, self).on_touch_down(touch):
|
||||||
|
return True
|
||||||
|
if self.collide_point(*touch.pos) and self.selectable:
|
||||||
|
return self.parent.select_with_touch(self.index, touch)
|
||||||
|
|
||||||
|
def apply_selection(self, rv, index, is_selected):
|
||||||
|
"""Respond to the selection of items in the view"""
|
||||||
|
self.selected = is_selected
|
||||||
|
if is_selected:
|
||||||
|
print "selection changed to {0}".format(rv.data[index])
|
||||||
|
rv.parent.txt_input.text = rv.parent.txt_input.text.replace(
|
||||||
|
rv.parent.txt_input.text, rv.data[index]['text'])
|
||||||
|
|
||||||
|
|
||||||
class Create(Screen):
|
class RV(RecycleView):
|
||||||
"""Create Screen uses screen to show widgets of screens."""
|
"""Recycling View"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
super(Create, self).__init__(*args, **kwargs)
|
"""Recycling Method"""
|
||||||
|
super(RV, self).__init__(**kwargs)
|
||||||
|
|
||||||
def send(self):
|
|
||||||
"""Send message from one address to another."""
|
class DropDownWidget(BoxLayout):
|
||||||
fromAddress = self.ids.spinner_id.text
|
"""Adding Dropdown Widget"""
|
||||||
# For now we are using static address i.e we are not using recipent field value.
|
# pylint: disable=too-many-statements, too-many-locals
|
||||||
toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
|
# pylint: disable=inconsistent-return-statements
|
||||||
message = self.ids.message.text
|
txt_input = ObjectProperty()
|
||||||
subject = self.ids.subject.text
|
rv = ObjectProperty()
|
||||||
|
|
||||||
|
def send(self, navApp):
|
||||||
|
"""Send message from one address to another"""
|
||||||
|
fromAddress = str(self.ids.ti.text)
|
||||||
|
toAddress = str(self.ids.txt_input.text)
|
||||||
|
subject = self.ids.subject.text.encode('utf-8').strip()
|
||||||
|
message = self.ids.body.text.encode('utf-8').strip()
|
||||||
encoding = 3
|
encoding = 3
|
||||||
print("message: ", self.ids.message.text)
|
print "message: ", self.ids.body.text
|
||||||
sendMessageToPeople = True
|
sendMessageToPeople = True
|
||||||
if sendMessageToPeople:
|
if sendMessageToPeople:
|
||||||
if toAddress != '':
|
if toAddress != '' and subject and message:
|
||||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
status, addressVersionNumber, streamNumber, ripe = (
|
||||||
toAddress)
|
decodeAddress(toAddress))
|
||||||
if status == 'success':
|
if status == 'success':
|
||||||
|
navApp.root.ids.sc3.children[0].active = True
|
||||||
|
if state.detailPageType == 'draft' \
|
||||||
|
and state.send_draft_mail:
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE sent SET toaddress = ?, fromaddress = ? ,"
|
||||||
|
" subject = ?, message = ?, folder = 'sent' WHERE"
|
||||||
|
" ackdata = ?;", toAddress, fromAddress, subject,
|
||||||
|
message, str(state.send_draft_mail))
|
||||||
|
self.parent.parent.screens[15].clear_widgets()
|
||||||
|
self.parent.parent.screens[15].add_widget(Draft())
|
||||||
|
else:
|
||||||
toAddress = addBMIfNotPresent(toAddress)
|
toAddress = addBMIfNotPresent(toAddress)
|
||||||
|
statusIconColor = 'red'
|
||||||
if addressVersionNumber > 4 or addressVersionNumber <= 1:
|
if (addressVersionNumber > 4) or (
|
||||||
print("addressVersionNumber > 4 or addressVersionNumber <= 1")
|
addressVersionNumber <= 1):
|
||||||
|
print "addressVersionNumber > 4"\
|
||||||
|
" or addressVersionNumber <= 1"
|
||||||
if streamNumber > 1 or streamNumber == 0:
|
if streamNumber > 1 or streamNumber == 0:
|
||||||
print("streamNumber > 1 or streamNumber == 0")
|
print "streamNumber > 1 or streamNumber == 0"
|
||||||
if statusIconColor == 'red':
|
if statusIconColor == 'red':
|
||||||
print("shared.statusIconColor == 'red'")
|
print "shared.statusIconColor == 'red'"
|
||||||
stealthLevel = BMConfigParser().safeGetInt(
|
stealthLevel = BMConfigParser().safeGetInt(
|
||||||
'bitmessagesettings', 'ackstealthlevel')
|
'bitmessagesettings', 'ackstealthlevel')
|
||||||
|
from helper_ackPayload import genAckPayload
|
||||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
t = ()
|
# t = ()
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
'''INSERT INTO sent VALUES
|
||||||
'',
|
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
|
||||||
toAddress,
|
'', toAddress, ripe, fromAddress, subject, message,
|
||||||
ripe,
|
ackdata, int(time.time()), int(time.time()), 0,
|
||||||
fromAddress,
|
'msgqueued', 0, 'sent', encoding,
|
||||||
subject,
|
BMConfigParser().getint(
|
||||||
message,
|
'bitmessagesettings', 'ttl'))
|
||||||
ackdata,
|
state.check_sent_acc = fromAddress
|
||||||
int(time.time()),
|
state.msg_counter_objs = self.parent.parent.parent.parent\
|
||||||
int(time.time()),
|
.parent.parent.children[2].children[0].ids
|
||||||
0,
|
if state.detailPageType == 'draft' and state.send_draft_mail:
|
||||||
'msgqueued',
|
state.draft_count = str(int(state.draft_count) - 1)
|
||||||
0,
|
state.msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
||||||
'sent',
|
state.detailPageType = ''
|
||||||
encoding,
|
state.send_draft_mail = None
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
# self.parent.parent.screens[0].ids.ml.clear_widgets()
|
||||||
toLabel = ''
|
# self.parent.parent.screens[0].loadMessagelist(state.association)
|
||||||
|
self.parent.parent.screens[3].update_sent_messagelist()
|
||||||
|
# self.parent.parent.screens[16].clear_widgets()
|
||||||
|
# self.parent.parent.screens[16].add_widget(Allmails())
|
||||||
|
Clock.schedule_once(self.callback_for_msgsend, 3)
|
||||||
queues.workerQueue.put(('sendmessage', toAddress))
|
queues.workerQueue.put(('sendmessage', toAddress))
|
||||||
print("sqlExecute successfully ##### ##################")
|
print "sqlExecute successfully #######################"
|
||||||
self.ids.message.text = ''
|
state.in_composer = True
|
||||||
self.ids.spinner_id.text = '<select>'
|
return
|
||||||
|
else:
|
||||||
|
msg = 'Enter a valid recipients address'
|
||||||
|
elif not toAddress:
|
||||||
|
msg = 'Please fill the form'
|
||||||
|
else:
|
||||||
|
msg = 'Please fill the form'
|
||||||
|
self.address_error_message(msg)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def callback_for_msgsend(dt=0):
|
||||||
|
"""Callback method for messagesend"""
|
||||||
|
state.kivyapp.root.ids.sc3.children[0].active = False
|
||||||
|
state.in_sent_method = True
|
||||||
|
state.kivyapp.back_press()
|
||||||
|
toast('sent')
|
||||||
|
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
def address_error_message(self, msg):
|
||||||
|
"""Generates error message"""
|
||||||
|
width = .8 if platform == 'android' else .55
|
||||||
|
msg_dialog = MDDialog(
|
||||||
|
text=msg,
|
||||||
|
title='', size_hint=(width, .25), text_button_ok='Ok',
|
||||||
|
events_callback=self.callback_for_menu_items)
|
||||||
|
msg_dialog.open()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def callback_for_menu_items(text_item):
|
||||||
|
"""Callback of alert box"""
|
||||||
|
toast(text_item)
|
||||||
|
|
||||||
|
def reset_composer(self):
|
||||||
|
"""Method will reset composer"""
|
||||||
|
self.ids.ti.text = ''
|
||||||
|
self.ids.btn.text = 'Select'
|
||||||
|
self.ids.txt_input.text = ''
|
||||||
self.ids.subject.text = ''
|
self.ids.subject.text = ''
|
||||||
self.ids.recipent.text = ''
|
self.ids.body.text = ''
|
||||||
return None
|
toast("Reset message")
|
||||||
|
|
||||||
def cancel(self):
|
def auto_fill_fromaddr(self):
|
||||||
"""Reset values for send message."""
|
"""Fill the text automatically From Address"""
|
||||||
self.ids.message.text = ''
|
self.ids.ti.text = self.ids.btn.text
|
||||||
self.ids.spinner_id.text = '<select>'
|
self.ids.ti.focus = True
|
||||||
self.ids.subject.text = ''
|
|
||||||
self.ids.recipent.text = ''
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class NewIdentity(Screen):
|
class MyTextInput(TextInput):
|
||||||
"""Create new address for PyBitmessage."""
|
"""Takes the text input in the field"""
|
||||||
|
txt_input = ObjectProperty()
|
||||||
|
flt_list = ObjectProperty()
|
||||||
|
word_list = ListProperty()
|
||||||
|
starting_no = NumericProperty(3)
|
||||||
|
suggestion_text = ''
|
||||||
|
|
||||||
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
|
"""Getting Text Input"""
|
||||||
|
super(MyTextInput, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
def on_text(self, instance, value):
|
||||||
|
"""Find all the occurrence of the word"""
|
||||||
|
self.parent.parent.parent.parent.ids.rv.data = []
|
||||||
|
matches = [self.word_list[i] for i in range(
|
||||||
|
len(self.word_list)) if self.word_list[
|
||||||
|
i][:self.starting_no] == value[:self.starting_no]]
|
||||||
|
display_data = []
|
||||||
|
for i in matches:
|
||||||
|
display_data.append({'text': i})
|
||||||
|
self.parent.parent.parent.parent.ids.rv.data = display_data
|
||||||
|
if len(matches) <= 10:
|
||||||
|
self.parent.height = (250 + (len(matches) * 20))
|
||||||
|
else:
|
||||||
|
self.parent.height = 400
|
||||||
|
|
||||||
|
def keyboard_on_key_down(self, window, keycode, text, modifiers):
|
||||||
|
"""Keyboard on key Down"""
|
||||||
|
if self.suggestion_text and keycode[1] == 'tab':
|
||||||
|
self.insert_text(self.suggestion_text + ' ')
|
||||||
|
return True
|
||||||
|
return super(MyTextInput, self).keyboard_on_key_down(
|
||||||
|
window, keycode, text, modifiers)
|
||||||
|
|
||||||
|
|
||||||
|
class Payment(Screen):
|
||||||
|
"""Payment module"""
|
||||||
|
|
||||||
|
def get_available_credits(self, instance): # pylint: disable=no-self-use
|
||||||
|
"""Get the available credits"""
|
||||||
|
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)
|
||||||
|
if len(existing_credits.split(' ')) > 1:
|
||||||
|
toast(
|
||||||
|
'We already have added free coins'
|
||||||
|
' for the subscription to your account!')
|
||||||
|
else:
|
||||||
|
toast('Coins added to your account!')
|
||||||
|
state.kivyapp.root.ids.sc18.ids.ml.children[0].children[
|
||||||
|
0].children[0].children[0].text = '{0}'.format(
|
||||||
|
state.availabe_credit)
|
||||||
|
|
||||||
|
|
||||||
|
class Credits(Screen):
|
||||||
|
"""Module for screen screen"""
|
||||||
|
available_credits = StringProperty('{0}'.format('0'))
|
||||||
|
|
||||||
|
|
||||||
|
class Login(Screen):
|
||||||
|
"""Login Screeen"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkStat(Screen):
|
||||||
|
"""Method used to show network stat"""
|
||||||
|
text_variable_1 = StringProperty(
|
||||||
|
'{0}::{1}'.format('Total Connections', '0'))
|
||||||
|
text_variable_2 = StringProperty(
|
||||||
|
'Processed {0} per-to-per messages'.format('0'))
|
||||||
|
text_variable_3 = StringProperty(
|
||||||
|
'Processed {0} brodcast messages'.format('0'))
|
||||||
|
text_variable_4 = StringProperty(
|
||||||
|
'Processed {0} public keys'.format('0'))
|
||||||
|
text_variable_5 = StringProperty(
|
||||||
|
'Processed {0} object to be synced'.format('0'))
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Init method for network stat"""
|
||||||
|
super(NetworkStat, self).__init__(*args, **kwargs)
|
||||||
|
Clock.schedule_interval(self.init_ui, 1)
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock Schdule for method networkstat screen"""
|
||||||
|
import network.stats
|
||||||
|
import shared
|
||||||
|
from network import objectracker
|
||||||
|
self.text_variable_1 = '{0} :: {1}'.format(
|
||||||
|
'Total Connections', str(len(network.stats.connectedHostsList())))
|
||||||
|
self.text_variable_2 = 'Processed {0} per-to-per messages'.format(
|
||||||
|
str(shared.numberOfMessagesProcessed))
|
||||||
|
self.text_variable_3 = 'Processed {0} brodcast messages'.format(
|
||||||
|
str(shared.numberOfBroadcastsProcessed))
|
||||||
|
self.text_variable_4 = 'Processed {0} public keys'.format(
|
||||||
|
str(shared.numberOfPubkeysProcessed))
|
||||||
|
self.text_variable_5 = '{0} object to be synced'.format(
|
||||||
|
len(objectracker.missingObjects))
|
||||||
|
|
||||||
|
|
||||||
|
class ContentNavigationDrawer(Navigatorss):
|
||||||
|
"""Navigate Content Drawer"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Random(Screen):
|
||||||
|
"""Generates Random Address"""
|
||||||
is_active = BooleanProperty(False)
|
is_active = BooleanProperty(False)
|
||||||
checked = StringProperty("")
|
checked = StringProperty("")
|
||||||
# self.manager.parent.ids.create.children[0].source = 'images/plus-4-xxl.png'
|
|
||||||
|
|
||||||
def generateaddress(self):
|
def generateaddress(self, navApp):
|
||||||
"""Generate new address."""
|
"""Method for Address Generator"""
|
||||||
if self.checked == 'use a random number generator to make an address':
|
entered_label = str(self.ids.label.text).strip()
|
||||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
|
||||||
streamNumberForAddress = 1
|
streamNumberForAddress = 1
|
||||||
label = self.ids.label.text
|
label = self.ids.label.text
|
||||||
eighteenByteRipe = False
|
eighteenByteRipe = False
|
||||||
nonceTrialsPerByte = 1000
|
nonceTrialsPerByte = 1000
|
||||||
payloadLengthExtraBytes = 1000
|
payloadLengthExtraBytes = 1000
|
||||||
|
lables = [BMConfigParser().get(obj, 'label')
|
||||||
|
for obj in BMConfigParser().addresses()]
|
||||||
|
if entered_label and entered_label not in lables:
|
||||||
|
toast('Address Creating...')
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'createRandomAddress',
|
'createRandomAddress', 4, streamNumberForAddress, label, 1,
|
||||||
4, streamNumberForAddress,
|
"", eighteenByteRipe, nonceTrialsPerByte,
|
||||||
label, 1, "", eighteenByteRipe,
|
payloadLengthExtraBytes))
|
||||||
nonceTrialsPerByte,
|
self.ids.label.text = ''
|
||||||
payloadLengthExtraBytes)
|
self.parent.parent.children[1].opacity = 1
|
||||||
)
|
self.parent.parent.children[1].disabled = False
|
||||||
self.manager.current = 'add_sucess'
|
state.kivyapp.root.ids.sc10.children[1].active = True
|
||||||
|
self.manager.current = 'myaddress'
|
||||||
|
Clock.schedule_once(self.address_created_callback, 6)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def address_created_callback(dt=0):
|
||||||
|
"""New address created"""
|
||||||
|
state.kivyapp.root.ids.sc10.children[1].active = False
|
||||||
|
state.kivyapp.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
|
state.kivyapp.root.ids.sc10.is_add_created = True
|
||||||
|
state.kivyapp.root.ids.sc10.init_ui()
|
||||||
|
toast('New address created')
|
||||||
|
|
||||||
|
def add_validation(self, instance):
|
||||||
|
"""Checking validation at address creation time"""
|
||||||
|
entered_label = str(instance.text.strip())
|
||||||
|
lables = [BMConfigParser().get(obj, 'label')
|
||||||
|
for obj in BMConfigParser().addresses()]
|
||||||
|
if entered_label in lables:
|
||||||
|
self.ids.label.error = True
|
||||||
|
self.ids.label.helper_text = 'Label name is already exist you'\
|
||||||
|
' can try this Ex. ( {0}_1, {0}_2 )'.format(
|
||||||
|
entered_label)
|
||||||
|
elif entered_label:
|
||||||
|
self.ids.label.error = False
|
||||||
|
else:
|
||||||
|
self.ids.label.error = False
|
||||||
|
self.ids.label.helper_text = 'This field is required'
|
||||||
|
|
||||||
|
def reset_address_label(self):
|
||||||
|
"""Resetting address labels"""
|
||||||
|
self.ids.label.text = ''
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
class Sent(Screen):
|
||||||
NavigateApp().run()
|
"""Sent Screen uses screen to show widgets of screens"""
|
||||||
|
queryreturn = ListProperty()
|
||||||
|
has_refreshed = True
|
||||||
|
account = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Association with the screen."""
|
||||||
|
super(Sent, self).__init__(*args, **kwargs)
|
||||||
|
if state.association == '':
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
state.association = BMConfigParser().addresses()[0]
|
||||||
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock Schdule for method sent accounts"""
|
||||||
|
self.loadSent()
|
||||||
|
print dt
|
||||||
|
|
||||||
|
def loadSent(self, where="", what=""):
|
||||||
|
"""Load Sent list for Sent messages."""
|
||||||
|
self.account = state.association
|
||||||
|
if state.searcing_text:
|
||||||
|
self.ids.scroll_y.scroll_y = 1.0
|
||||||
|
where = ['subject', 'message']
|
||||||
|
what = state.searcing_text
|
||||||
|
xAddress = 'fromaddress'
|
||||||
|
data = []
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
self.sentDataQuery(xAddress, where, what)
|
||||||
|
if self.queryreturn:
|
||||||
|
self.ids.identi_tag.children[0].text = 'Sent'
|
||||||
|
self.set_sentCount(state.sent_count)
|
||||||
|
for mail in self.queryreturn:
|
||||||
|
data.append({
|
||||||
|
'text': mail[1].strip(),
|
||||||
|
'secondary_text': mail[2][:50] + '........' if len(
|
||||||
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
'ackdata': mail[5]})
|
||||||
|
self.set_mdlist(data, 0)
|
||||||
|
self.has_refreshed = True
|
||||||
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
|
else:
|
||||||
|
content = MDLabel(
|
||||||
|
font_style='Body1', theme_text_color='Primary',
|
||||||
|
text="No message found!" if state.searcing_text
|
||||||
|
else "yet no message for this account!!!!!!!!!!!!!",
|
||||||
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
|
self.ids.ml.add_widget(content)
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
|
def sentDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
||||||
|
"""This method is used to retrieving data from sent table"""
|
||||||
|
self.queryreturn = kivy_helper_search.search_sql(
|
||||||
|
xAddress, self.account, "sent", where, what,
|
||||||
|
False, start_indx, end_indx)
|
||||||
|
|
||||||
|
def set_mdlist(self, data, set_index=0):
|
||||||
|
"""This method is used to create the mdList"""
|
||||||
|
total_sent_msg = len(self.ids.ml.children)
|
||||||
|
for item in data:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text=item['text'], secondary_text=item['secondary_text'],
|
||||||
|
theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
meny.add_widget(AvatarSampleWidget(
|
||||||
|
source='./images/text_images/{}.png'.format(
|
||||||
|
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
||||||
|
meny.bind(on_press=partial(self.sent_detail, item['ackdata']))
|
||||||
|
carousel = Carousel(direction='right')
|
||||||
|
carousel.height = meny.height
|
||||||
|
carousel.size_hint_y = None
|
||||||
|
carousel.ignore_perpendicular_swipes = True
|
||||||
|
carousel.data_index = 0
|
||||||
|
carousel.min_move = 0.2
|
||||||
|
del_btn = Button(text='Delete')
|
||||||
|
del_btn.background_normal = ''
|
||||||
|
del_btn.background_color = (1, 0, 0, 1)
|
||||||
|
del_btn.bind(on_press=partial(self.delete, item['ackdata']))
|
||||||
|
carousel.add_widget(del_btn)
|
||||||
|
carousel.add_widget(meny)
|
||||||
|
ach_btn = Button(text='Achieve')
|
||||||
|
ach_btn.background_color = (0, 1, 0, 1)
|
||||||
|
ach_btn.bind(on_press=partial(self.archive, item['ackdata']))
|
||||||
|
carousel.add_widget(ach_btn)
|
||||||
|
carousel.index = 1
|
||||||
|
self.ids.ml.add_widget(carousel, index=set_index)
|
||||||
|
updated_msgs = len(self.ids.ml.children)
|
||||||
|
self.has_refreshed = True if total_sent_msg != updated_msgs else False
|
||||||
|
|
||||||
|
def update_sent_messagelist(self):
|
||||||
|
"""This method is used to update screen when new mail is sent"""
|
||||||
|
self.account = state.association
|
||||||
|
if len(self.ids.ml.children) < 3:
|
||||||
|
self.ids.ml.clear_widgets()
|
||||||
|
self.loadSent()
|
||||||
|
total_sent = int(state.sent_count) + 1
|
||||||
|
self.set_sentCount(total_sent)
|
||||||
|
else:
|
||||||
|
data = []
|
||||||
|
self.sentDataQuery('fromaddress', '', '', 0, 1)
|
||||||
|
total_sent = int(state.sent_count) + 1
|
||||||
|
self.set_sentCount(total_sent)
|
||||||
|
for mail in self.queryreturn:
|
||||||
|
data.append({
|
||||||
|
'text': mail[1].strip(),
|
||||||
|
'secondary_text': mail[2][:50] + '........' if len(
|
||||||
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
'ackdata': mail[5]})
|
||||||
|
self.set_mdlist(data, total_sent - 1)
|
||||||
|
if state.msg_counter_objs and state.association == (
|
||||||
|
state.check_sent_acc):
|
||||||
|
state.all_count = str(int(state.all_count) + 1)
|
||||||
|
state.msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||||
|
state.check_sent_acc = None
|
||||||
|
|
||||||
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
|
"""Load data on scroll down"""
|
||||||
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
||||||
|
self.ids.scroll_y.scroll_y = 0.06
|
||||||
|
total_sent_msg = len(self.ids.ml.children)
|
||||||
|
self.update_sent_screen_on_scroll(total_sent_msg)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def update_sent_screen_on_scroll(self, total_sent_msg, where="", what=""):
|
||||||
|
"""This method is used to load more data on scroll down"""
|
||||||
|
if state.searcing_text:
|
||||||
|
where = ['subject', 'message']
|
||||||
|
what = state.searcing_text
|
||||||
|
self.sentDataQuery('fromaddress', where, what, total_sent_msg, 5)
|
||||||
|
data = []
|
||||||
|
for mail in self.queryreturn:
|
||||||
|
data.append({
|
||||||
|
'text': mail[1].strip(),
|
||||||
|
'secondary_text': mail[2][:50] + '........' if len(
|
||||||
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
'ackdata': mail[5]})
|
||||||
|
self.set_mdlist(data, 0)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_sentCount(total_sent):
|
||||||
|
"""Set the total no. of sent message count"""
|
||||||
|
src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
||||||
|
src_mng_obj.send_cnt.badge_text = str(total_sent)
|
||||||
|
state.sent_count = str(total_sent)
|
||||||
|
|
||||||
|
def sent_detail(self, ackdata, *args):
|
||||||
|
"""Load sent mail details"""
|
||||||
|
state.detailPageType = 'sent'
|
||||||
|
state.mail_id = ackdata
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[13].clear_widgets()
|
||||||
|
src_mng_obj.screens[13].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
|
|
||||||
|
def delete(self, data_index, instance, *args):
|
||||||
|
"""Delete sent mail from sent mail listing"""
|
||||||
|
try:
|
||||||
|
msg_count_objs = self.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids
|
||||||
|
except Exception:
|
||||||
|
msg_count_objs = self.parent.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids
|
||||||
|
if int(state.sent_count) > 0:
|
||||||
|
msg_count_objs.send_cnt.badge_text = str(
|
||||||
|
int(state.sent_count) - 1)
|
||||||
|
msg_count_objs.trash_cnt.badge_text = str(
|
||||||
|
int(state.trash_count) + 1)
|
||||||
|
msg_count_objs.allmail_cnt.badge_text = str(
|
||||||
|
int(state.all_count) - 1)
|
||||||
|
state.sent_count = str(int(state.sent_count) - 1)
|
||||||
|
state.trash_count = str(int(state.trash_count) + 1)
|
||||||
|
state.all_count = str(int(state.all_count) - 1)
|
||||||
|
if int(state.sent_count) <= 0:
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE sent SET folder = 'trash'"
|
||||||
|
" WHERE ackdata = ?;", str(data_index))
|
||||||
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
|
toast('Deleted')
|
||||||
|
self.update_trash()
|
||||||
|
|
||||||
|
def archive(self, data_index, instance, *args):
|
||||||
|
"""Archive sent mail from sent mail listing"""
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE sent SET folder = 'trash' WHERE ackdata = ?;",
|
||||||
|
str(data_index))
|
||||||
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
|
self.update_trash()
|
||||||
|
|
||||||
|
def update_trash(self):
|
||||||
|
"""Update trash screen mails which is deleted from inbox"""
|
||||||
|
try:
|
||||||
|
self.parent.screens[4].clear_widgets()
|
||||||
|
self.parent.screens[4].add_widget(Trash())
|
||||||
|
self.parent.screens[16].clear_widgets()
|
||||||
|
self.parent.screens[16].add_widget(Allmails())
|
||||||
|
except Exception:
|
||||||
|
self.parent.parent.screens[4].clear_widgets()
|
||||||
|
self.parent.parent.screens[4].add_widget(Trash())
|
||||||
|
self.parent.parent.screens[16].clear_widgets()
|
||||||
|
self.parent.parent.screens[16].add_widget(Allmails())
|
||||||
|
|
||||||
|
|
||||||
|
class Trash(Screen):
|
||||||
|
"""Trash Screen uses screen to show widgets of screens"""
|
||||||
|
trash_messages = ListProperty()
|
||||||
|
has_refreshed = True
|
||||||
|
delete_index = StringProperty()
|
||||||
|
table_name = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Trash method, delete sent message and add in Trash"""
|
||||||
|
super(Trash, self).__init__(*args, **kwargs)
|
||||||
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock Schdule for method trash screen."""
|
||||||
|
if state.association == '':
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
state.association = BMConfigParser().addresses()[0]
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
self.trashDataQuery(0, 20)
|
||||||
|
if self.trash_messages:
|
||||||
|
self.ids.identi_tag.children[0].text = 'Trash'
|
||||||
|
src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
||||||
|
src_mng_obj.trash_cnt.badge_text = state.trash_count
|
||||||
|
self.set_mdList()
|
||||||
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
|
else:
|
||||||
|
content = MDLabel(
|
||||||
|
font_style='Body1', theme_text_color='Primary',
|
||||||
|
text="yet no trashed message for this account!!!!!!!!!!!!!",
|
||||||
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
|
self.ids.ml.add_widget(content)
|
||||||
|
|
||||||
|
def trashDataQuery(self, start_indx, end_indx):
|
||||||
|
"""Trash message query"""
|
||||||
|
self.trash_messages = sqlQuery(
|
||||||
|
"SELECT toaddress, fromaddress, subject, message,"
|
||||||
|
" folder ||',' || 'sent' as folder, ackdata As"
|
||||||
|
" id, DATE(lastactiontime) As actionTime FROM sent"
|
||||||
|
" WHERE folder = 'trash' and fromaddress = '{0}' UNION"
|
||||||
|
" SELECT toaddress, fromaddress, subject, message,"
|
||||||
|
" folder ||',' || 'inbox' as folder, msgid As id,"
|
||||||
|
" DATE(received) As actionTime FROM inbox"
|
||||||
|
" WHERE folder = 'trash' and toaddress = '{0}'"
|
||||||
|
" ORDER BY actionTime DESC limit {1}, {2}".format(
|
||||||
|
state.association, start_indx, end_indx))
|
||||||
|
|
||||||
|
def set_mdList(self):
|
||||||
|
"""This method is used to create the mdlist"""
|
||||||
|
total_trash_msg = len(self.ids.ml.children)
|
||||||
|
for item in self.trash_messages:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text=item[1],
|
||||||
|
secondary_text=item[2][:50] + '........' if len(
|
||||||
|
item[2]) >= 50 else (item[2] + ',' + item[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
img_latter = './images/text_images/{}.png'.format(
|
||||||
|
item[2][0].upper() if (item[2][0].upper() >= 'A' and item[
|
||||||
|
2][0].upper() <= 'Z') else '!')
|
||||||
|
meny.add_widget(AvatarSampleWidget(source=img_latter))
|
||||||
|
carousel = Carousel(direction='right')
|
||||||
|
carousel.height = meny.height
|
||||||
|
carousel.size_hint_y = None
|
||||||
|
carousel.ignore_perpendicular_swipes = True
|
||||||
|
carousel.data_index = 0
|
||||||
|
carousel.min_move = 0.2
|
||||||
|
del_btn = Button(text='Delete')
|
||||||
|
del_btn.background_normal = ''
|
||||||
|
del_btn.background_color = (1, 0, 0, 1)
|
||||||
|
del_btn.bind(on_press=partial(
|
||||||
|
self.delete_permanently, item[5], item[4]))
|
||||||
|
carousel.add_widget(del_btn)
|
||||||
|
carousel.add_widget(meny)
|
||||||
|
carousel.index = 1
|
||||||
|
self.ids.ml.add_widget(carousel)
|
||||||
|
self.has_refreshed = True if total_trash_msg != len(
|
||||||
|
self.ids.ml.children) else False
|
||||||
|
|
||||||
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
|
"""Load data on scroll"""
|
||||||
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
||||||
|
self.ids.scroll_y.scroll_y = 0.06
|
||||||
|
total_trash_msg = len(self.ids.ml.children)
|
||||||
|
self.update_trash_screen_on_scroll(total_trash_msg)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def update_trash_screen_on_scroll(self, total_trash_msg):
|
||||||
|
"""Load more data on scroll down"""
|
||||||
|
self.trashDataQuery(total_trash_msg, 5)
|
||||||
|
self.set_mdList()
|
||||||
|
|
||||||
|
def delete_permanently(self, data_index, folder, instance, *args):
|
||||||
|
"""Deleting trash mail permanently"""
|
||||||
|
self.table_name = folder.split(',')[1]
|
||||||
|
self.delete_index = data_index
|
||||||
|
self.delete_confirmation()
|
||||||
|
|
||||||
|
def callback_for_screen_load(self, dt=0):
|
||||||
|
"""This methos is for loading screen"""
|
||||||
|
self.ids.ml.clear_widgets()
|
||||||
|
self.init_ui(0)
|
||||||
|
self.children[1].active = False
|
||||||
|
toast('Message is permanently deleted')
|
||||||
|
|
||||||
|
def delete_confirmation(self):
|
||||||
|
"""Show confirmation delete popup"""
|
||||||
|
width = .8 if platform == 'android' else .55
|
||||||
|
delete_msg_dialog = MDDialog(
|
||||||
|
text='Are you sure you want to delete this'
|
||||||
|
' message permanently from trash?', title='',
|
||||||
|
size_hint=(width, .25), text_button_ok='Yes',
|
||||||
|
text_button_cancel='No',
|
||||||
|
events_callback=self.callback_for_delete_msg)
|
||||||
|
delete_msg_dialog.open()
|
||||||
|
|
||||||
|
def callback_for_delete_msg(self, text_item):
|
||||||
|
"""Getting the callback of alert box"""
|
||||||
|
if text_item == 'Yes':
|
||||||
|
self.delete_message_from_trash()
|
||||||
|
else:
|
||||||
|
toast(text_item)
|
||||||
|
|
||||||
|
def delete_message_from_trash(self):
|
||||||
|
"""Deleting message from trash"""
|
||||||
|
self.children[1].active = True
|
||||||
|
if self.table_name == 'inbox':
|
||||||
|
sqlExecute(
|
||||||
|
"DELETE FROM inbox WHERE msgid = ?;",
|
||||||
|
str(self.delete_index))
|
||||||
|
elif self.table_name == 'sent':
|
||||||
|
sqlExecute(
|
||||||
|
"DELETE FROM sent WHERE ackdata = ?;",
|
||||||
|
str(self.delete_index))
|
||||||
|
msg_count_objs = state.kivyapp.root.children[2].children[0].ids
|
||||||
|
if int(state.trash_count) > 0:
|
||||||
|
msg_count_objs.trash_cnt.badge_text = str(
|
||||||
|
int(state.trash_count) - 1)
|
||||||
|
state.trash_count = str(int(state.trash_count) - 1)
|
||||||
|
Clock.schedule_once(self.callback_for_screen_load, 1)
|
||||||
|
|
||||||
|
|
||||||
|
class Page(Screen):
|
||||||
|
"""Page Screen show widgets of page"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Create(Screen):
|
||||||
|
"""Creates the screen widgets"""
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
"""Getting Labels and address from addressbook"""
|
||||||
|
super(Create, self).__init__(**kwargs)
|
||||||
|
widget_1 = DropDownWidget()
|
||||||
|
widget_1.ids.txt_input.word_list = [
|
||||||
|
addr[1] for addr in sqlQuery(
|
||||||
|
"SELECT label, address from addressbook")]
|
||||||
|
widget_1.ids.txt_input.starting_no = 2
|
||||||
|
self.add_widget(widget_1)
|
||||||
|
|
||||||
|
|
||||||
|
class Setting(Screen):
|
||||||
|
"""Setting the Screen components"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NavigateApp(App): # pylint: disable=too-many-public-methods
|
||||||
|
"""Navigation Layout of class"""
|
||||||
|
theme_cls = ThemeManager()
|
||||||
|
previous_date = ObjectProperty()
|
||||||
|
obj_1 = ObjectProperty()
|
||||||
|
variable_1 = ListProperty(BMConfigParser().addresses())
|
||||||
|
nav_drawer = ObjectProperty()
|
||||||
|
state.screen_density = Window.size
|
||||||
|
window_size = state.screen_density
|
||||||
|
app_platform = platform
|
||||||
|
title = "PyBitmessage"
|
||||||
|
imgstatus = False
|
||||||
|
count = 0
|
||||||
|
menu_items = [
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
{'viewclass': 'MDMenuItem', 'text': 'Example item'},
|
||||||
|
]
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
"""Method builds the widget"""
|
||||||
|
main_widget = Builder.load_file(
|
||||||
|
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||||
|
self.nav_drawer = Navigatorss()
|
||||||
|
self.obj_1 = AddressBook()
|
||||||
|
kivysignalthread = UIkivySignaler()
|
||||||
|
kivysignalthread.daemon = True
|
||||||
|
kivysignalthread.start()
|
||||||
|
Window.bind(on_keyboard=self.on_key)
|
||||||
|
return main_widget
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Running the widgets"""
|
||||||
|
kivyuisignaler.release()
|
||||||
|
super(NavigateApp, self).run()
|
||||||
|
|
||||||
|
# pylint: disable=inconsistent-return-statements
|
||||||
|
@staticmethod
|
||||||
|
def showmeaddresses(name="text"):
|
||||||
|
"""Show the addresses in spinner to make as dropdown"""
|
||||||
|
if name == "text":
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
return BMConfigParser().addresses()[0][:16] + '..'
|
||||||
|
return "textdemo"
|
||||||
|
elif name == "values":
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
return [address[:16] + '..'
|
||||||
|
for address in BMConfigParser().addresses()]
|
||||||
|
return "valuesdemo"
|
||||||
|
|
||||||
|
def getCurrentAccountData(self, text):
|
||||||
|
"""Get Current Address Account Data"""
|
||||||
|
self.set_identicon(text)
|
||||||
|
address_label = self.current_address_label(
|
||||||
|
BMConfigParser().get(text, 'label'), text)
|
||||||
|
self.root_window.children[1].ids.toolbar.title = address_label
|
||||||
|
state.association = text
|
||||||
|
state.searcing_text = ''
|
||||||
|
LoadingPopup().open()
|
||||||
|
self.set_message_count()
|
||||||
|
Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
||||||
|
|
||||||
|
def setCurrentAccountData(self, dt=0):
|
||||||
|
"""This method set the current accout data on all the screens."""
|
||||||
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
|
|
||||||
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc4.children[2].children[2].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc4.loadSent(state.association)
|
||||||
|
|
||||||
|
self.root.ids.sc16.clear_widgets()
|
||||||
|
self.root.ids.sc16.add_widget(Draft())
|
||||||
|
|
||||||
|
self.root.ids.sc5.clear_widgets()
|
||||||
|
self.root.ids.sc5.add_widget(Trash())
|
||||||
|
|
||||||
|
self.root.ids.sc17.clear_widgets()
|
||||||
|
self.root.ids.sc17.add_widget(Allmails())
|
||||||
|
|
||||||
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getCurrentAccount():
|
||||||
|
"""It uses to get current account label"""
|
||||||
|
if state.association:
|
||||||
|
return state.association
|
||||||
|
return "Bitmessage Login"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def addingtoaddressbook():
|
||||||
|
"""Adding to address Book"""
|
||||||
|
p = GrashofPopup()
|
||||||
|
p.open()
|
||||||
|
|
||||||
|
def getDefaultAccData(self):
|
||||||
|
"""Getting Default Account Data"""
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
|
||||||
|
self.createFolder('./images/default_identicon/')
|
||||||
|
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 'Select Address'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def createFolder(directory):
|
||||||
|
"""Create directory when app starts"""
|
||||||
|
try:
|
||||||
|
if not os.path.exists(directory):
|
||||||
|
os.makedirs(directory)
|
||||||
|
except OSError:
|
||||||
|
print 'Error: Creating directory. ' + directory
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_default_image():
|
||||||
|
"""Getting default image on address"""
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
return './images/default_identicon/{}.png'.format(
|
||||||
|
BMConfigParser().addresses()[0])
|
||||||
|
return './images/no_identicons.png'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def addressexist():
|
||||||
|
"""Checking address existence"""
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def on_key(self, window, key, *args):
|
||||||
|
"""Method is used for going on previous screen"""
|
||||||
|
if key == 27:
|
||||||
|
if state.in_search_mode and self.root.ids.scr_mngr.current != (
|
||||||
|
"mailDetail"):
|
||||||
|
self.closeSearchScreen()
|
||||||
|
elif self.root.ids.scr_mngr.current == "mailDetail":
|
||||||
|
self.root.ids.scr_mngr.current = 'sent'\
|
||||||
|
if state.detailPageType == 'sent' else 'inbox' \
|
||||||
|
if state.detailPageType == 'inbox' else 'draft'
|
||||||
|
self.back_press()
|
||||||
|
elif self.root.ids.scr_mngr.current == "create":
|
||||||
|
self.save_draft()
|
||||||
|
self.set_common_header()
|
||||||
|
state.in_composer = False
|
||||||
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
|
elif self.root.ids.scr_mngr.current == "showqrcode":
|
||||||
|
self.root.ids.scr_mngr.current = 'myaddress'
|
||||||
|
elif self.root.ids.scr_mngr.current == "random":
|
||||||
|
self.root.ids.scr_mngr.current = 'login'
|
||||||
|
else:
|
||||||
|
if state.kivyapp.variable_1:
|
||||||
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
|
self.root.ids.scr_mngr.transition.direction = 'right'
|
||||||
|
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
|
||||||
|
return True
|
||||||
|
elif key == 13 and state.searcing_text:
|
||||||
|
if state.search_screen == 'inbox':
|
||||||
|
self.root.ids.sc1.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
elif state.search_screen == 'addressbook':
|
||||||
|
self.root.ids.sc11.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
elif state.search_screen == 'myaddress':
|
||||||
|
self.root.ids.sc10.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
elif state.search_screen == 'sent':
|
||||||
|
self.root.ids.sc4.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
|
||||||
|
def search_callback(self, dt=0):
|
||||||
|
"""Show data after loader is loaded"""
|
||||||
|
if state.search_screen == 'inbox':
|
||||||
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
|
self.root.ids.sc1.children[1].active = False
|
||||||
|
elif state.search_screen == 'addressbook':
|
||||||
|
self.root.ids.sc11.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
|
self.root.ids.sc11.children[1].active = False
|
||||||
|
elif state.search_screen == 'myaddress':
|
||||||
|
self.root.ids.sc10.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc10.init_ui()
|
||||||
|
self.root.ids.sc10.children[1].active = False
|
||||||
|
else:
|
||||||
|
self.root.ids.sc4.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc4.loadSent(state.association)
|
||||||
|
self.root.ids.sc4.children[1].active = False
|
||||||
|
self.root.ids.scr_mngr.current = state.search_screen
|
||||||
|
|
||||||
|
def save_draft(self):
|
||||||
|
"""Saving drafts messages"""
|
||||||
|
composer_objs = self.root
|
||||||
|
from_addr = str(self.root.ids.sc3.children[1].ids.ti.text)
|
||||||
|
to_addr = str(self.root.ids.sc3.children[1].ids.txt_input.text)
|
||||||
|
if from_addr and to_addr and state.detailPageType != 'draft' \
|
||||||
|
and not state.in_sent_method:
|
||||||
|
Draft().draft_msg(composer_objs)
|
||||||
|
return
|
||||||
|
|
||||||
|
def reset(self, *args):
|
||||||
|
"""Set transition direction"""
|
||||||
|
self.root.ids.scr_mngr.transition.direction = 'left'
|
||||||
|
self.root.ids.scr_mngr.transition.unbind(on_complete=self.reset)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def status_dispatching(data):
|
||||||
|
"""Dispatching Status acknowledgment"""
|
||||||
|
ackData, message = data
|
||||||
|
if state.ackdata == ackData:
|
||||||
|
state.status.status = message
|
||||||
|
|
||||||
|
def clear_composer(self):
|
||||||
|
"""If slow down, the new composer edit screen"""
|
||||||
|
self.set_navbar_for_composer()
|
||||||
|
composer_obj = self.root.ids.sc3.children[1].ids
|
||||||
|
composer_obj.ti.text = ''
|
||||||
|
composer_obj.btn.text = 'Select'
|
||||||
|
composer_obj.txt_input.text = ''
|
||||||
|
composer_obj.subject.text = ''
|
||||||
|
composer_obj.body.text = ''
|
||||||
|
state.in_composer = True
|
||||||
|
state.in_sent_method = False
|
||||||
|
|
||||||
|
def set_navbar_for_composer(self):
|
||||||
|
"""Clearing toolbar data when composer open"""
|
||||||
|
self.root.ids.toolbar.left_action_items = [
|
||||||
|
['arrow-left', lambda x: self.back_press()]]
|
||||||
|
self.root.ids.toolbar.right_action_items = [
|
||||||
|
['refresh',
|
||||||
|
lambda x: self.root.ids.sc3.children[1].reset_composer()],
|
||||||
|
['send',
|
||||||
|
lambda x: self.root.ids.sc3.children[1].send(self)]]
|
||||||
|
|
||||||
|
def set_common_header(self):
|
||||||
|
"""Common header for all window"""
|
||||||
|
self.root.ids.toolbar.right_action_items = [
|
||||||
|
['account-plus', lambda x: self.addingtoaddressbook()]]
|
||||||
|
self.root.ids.toolbar.left_action_items = [
|
||||||
|
['menu', lambda x: self.root.toggle_nav_drawer()]]
|
||||||
|
return
|
||||||
|
|
||||||
|
def back_press(self):
|
||||||
|
"""Method for, reverting composer to previous page"""
|
||||||
|
self.save_draft()
|
||||||
|
if self.root.ids.scr_mngr.current == \
|
||||||
|
'mailDetail' and state.in_search_mode:
|
||||||
|
toolbar_obj = self.root.ids.toolbar
|
||||||
|
toolbar_obj.left_action_items = [
|
||||||
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
|
toolbar_obj.right_action_items = []
|
||||||
|
self.root.ids.toolbar.title = ''
|
||||||
|
else:
|
||||||
|
self.set_common_header()
|
||||||
|
self.root.ids.scr_mngr.current = 'inbox' \
|
||||||
|
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.bind(on_complete=self.reset)
|
||||||
|
if state.is_allmail or state.detailPageType == 'draft':
|
||||||
|
state.is_allmail = False
|
||||||
|
state.detailPageType = ''
|
||||||
|
state.in_composer = False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_inbox_count():
|
||||||
|
"""Getting inbox count"""
|
||||||
|
state.inbox_count = str(sqlQuery(
|
||||||
|
"SELECT COUNT(*) FROM inbox WHERE toaddress = '{}' and"
|
||||||
|
" folder = 'inbox' ;".format(state.association))[0][0])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_sent_count():
|
||||||
|
"""Getting sent count"""
|
||||||
|
state.sent_count = str(sqlQuery(
|
||||||
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
||||||
|
" folder = 'sent' ;".format(state.association))[0][0])
|
||||||
|
|
||||||
|
def set_message_count(self):
|
||||||
|
"""Setting message count"""
|
||||||
|
try:
|
||||||
|
msg_counter_objs = (
|
||||||
|
self.root_window.children[0].children[2].children[0].ids)
|
||||||
|
except Exception:
|
||||||
|
msg_counter_objs = (
|
||||||
|
self.root_window.children[2].children[2].children[0].ids)
|
||||||
|
self.get_inbox_count()
|
||||||
|
self.get_sent_count()
|
||||||
|
state.trash_count = str(sqlQuery(
|
||||||
|
"SELECT (SELECT count(*) FROM sent"
|
||||||
|
" where fromaddress = '{0}' and folder = 'trash' )"
|
||||||
|
"+(SELECT count(*) FROM inbox where toaddress = '{0}' and"
|
||||||
|
" folder = 'trash') AS SumCount".format(state.association))[0][0])
|
||||||
|
state.draft_count = str(sqlQuery(
|
||||||
|
"SELECT COUNT(*) FROM sent WHERE fromaddress = '{}' and"
|
||||||
|
" folder = 'draft' ;".format(state.association))[0][0])
|
||||||
|
state.all_count = str(int(state.sent_count) + int(state.inbox_count))
|
||||||
|
if msg_counter_objs:
|
||||||
|
msg_counter_objs.send_cnt.badge_text = state.sent_count
|
||||||
|
msg_counter_objs.inbox_cnt.badge_text = state.inbox_count
|
||||||
|
msg_counter_objs.trash_cnt.badge_text = state.trash_count
|
||||||
|
msg_counter_objs.draft_cnt.badge_text = state.draft_count
|
||||||
|
msg_counter_objs.allmail_cnt.badge_text = state.all_count
|
||||||
|
|
||||||
|
def on_start(self):
|
||||||
|
"""Method activates on start"""
|
||||||
|
self.set_message_count()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def on_stop():
|
||||||
|
"""On stop methos is used for stoping the runing script"""
|
||||||
|
print "*******************EXITING FROM APPLICATION*******************"
|
||||||
|
import shutdown
|
||||||
|
shutdown.doCleanShutdown()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def current_address_label(current_add_label=None, current_addr=None):
|
||||||
|
"""Getting current address labels"""
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
if current_add_label:
|
||||||
|
first_name = current_add_label
|
||||||
|
addr = current_addr
|
||||||
|
else:
|
||||||
|
addr = BMConfigParser().addresses()[0]
|
||||||
|
first_name = BMConfigParser().get(addr, 'label')
|
||||||
|
f_name = first_name.split()
|
||||||
|
label = f_name[0][:14].capitalize() + '...' if len(
|
||||||
|
f_name[0]) > 15 else f_name[0].capitalize()
|
||||||
|
address = ' (' + addr + '...)'
|
||||||
|
return label + address
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def searchQuery(self, instance):
|
||||||
|
"""Showing searched mails"""
|
||||||
|
state.search_screen = self.root.ids.scr_mngr.current
|
||||||
|
state.searcing_text = str(instance.text).strip()
|
||||||
|
if instance.focus and state.searcing_text:
|
||||||
|
toolbar_obj = self.root.ids.toolbar
|
||||||
|
toolbar_obj.left_action_items = [
|
||||||
|
['arrow-left', lambda x: self.closeSearchScreen()]]
|
||||||
|
toolbar_obj.right_action_items = []
|
||||||
|
self.root.ids.toolbar.title = ''
|
||||||
|
state.in_search_mode = True
|
||||||
|
|
||||||
|
def closeSearchScreen(self):
|
||||||
|
"""Function for close search screen"""
|
||||||
|
self.set_common_header()
|
||||||
|
address_label = self.current_address_label(
|
||||||
|
BMConfigParser().get(
|
||||||
|
state.association, 'label'), state.association)
|
||||||
|
self.root.ids.toolbar.title = address_label
|
||||||
|
state.searcing_text = ''
|
||||||
|
self.refreshScreen()
|
||||||
|
state.in_search_mode = False
|
||||||
|
|
||||||
|
def refreshScreen(self): # pylint: disable=unused-variable
|
||||||
|
"""Method show search button only on inbox or sent screen"""
|
||||||
|
state.searcing_text = ''
|
||||||
|
if state.search_screen == 'inbox':
|
||||||
|
try:
|
||||||
|
self.root.ids.sc1.children[
|
||||||
|
3].children[2].ids.search_field.text = ''
|
||||||
|
except Exception:
|
||||||
|
self.root.ids.sc1.children[
|
||||||
|
2].children[2].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc1.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
elif state.search_screen == 'addressbook':
|
||||||
|
self.root.ids.sc11.children[
|
||||||
|
2].children[2].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc11.children[
|
||||||
|
1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
elif state.search_screen == 'myaddress':
|
||||||
|
try:
|
||||||
|
self.root.ids.sc10.children[
|
||||||
|
3].children[2].ids.search_field.text = ''
|
||||||
|
except Exception:
|
||||||
|
self.root.ids.sc10.children[
|
||||||
|
2].children[2].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc10.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
else:
|
||||||
|
self.root.ids.sc4.children[
|
||||||
|
2].children[2].ids.search_field.text = ''
|
||||||
|
self.root.ids.sc4.children[1].active = True
|
||||||
|
Clock.schedule_once(self.search_callback, 0.5)
|
||||||
|
return
|
||||||
|
|
||||||
|
def set_identicon(self, text):
|
||||||
|
"""Show identicon in address spinner"""
|
||||||
|
img = identiconGeneration.generate(text)
|
||||||
|
self.root.children[2].children[0].ids.btn.children[1].texture = (
|
||||||
|
img.texture)
|
||||||
|
|
||||||
|
def set_mail_detail_header(self):
|
||||||
|
"""Setting the details of the page"""
|
||||||
|
toolbar_obj = self.root.ids.toolbar
|
||||||
|
toolbar_obj.left_action_items = [
|
||||||
|
['arrow-left', lambda x: self.back_press()]]
|
||||||
|
delete_btn = ['delete-forever',
|
||||||
|
lambda x: self.root.ids.sc14.delete_mail()]
|
||||||
|
dynamic_list = []
|
||||||
|
if state.detailPageType == 'inbox':
|
||||||
|
dynamic_list = [
|
||||||
|
['reply', lambda x: self.root.ids.sc14.inbox_reply()],
|
||||||
|
delete_btn]
|
||||||
|
elif state.detailPageType == 'sent':
|
||||||
|
dynamic_list = [delete_btn]
|
||||||
|
elif state.detailPageType == 'draft':
|
||||||
|
dynamic_list = [
|
||||||
|
['pencil', lambda x: self.root.ids.sc14.write_msg(self)],
|
||||||
|
delete_btn]
|
||||||
|
toolbar_obj.right_action_items = dynamic_list
|
||||||
|
|
||||||
|
def load_screen(self, instance):
|
||||||
|
"""This method is used for loading screen on every click"""
|
||||||
|
if instance.text == 'Inbox':
|
||||||
|
self.root.ids.scr_mngr.current = 'inbox'
|
||||||
|
self.root.ids.sc1.children[1].active = True
|
||||||
|
elif instance.text == 'All Mails':
|
||||||
|
self.root.ids.scr_mngr.current = 'allmails'
|
||||||
|
try:
|
||||||
|
self.root.ids.sc17.children[1].active = True
|
||||||
|
except Exception:
|
||||||
|
self.root.ids.sc17.children[0].children[1].active = True
|
||||||
|
Clock.schedule_once(partial(self.load_screen_callback, instance), 1)
|
||||||
|
|
||||||
|
def load_screen_callback(self, instance, dt=0):
|
||||||
|
"""This method is rotating loader for few seconds"""
|
||||||
|
if instance.text == 'Inbox':
|
||||||
|
self.root.ids.sc1.ids.ml.clear_widgets()
|
||||||
|
self.root.ids.sc1.loadMessagelist(state.association)
|
||||||
|
self.root.ids.sc1.children[1].active = False
|
||||||
|
elif instance.text == 'All Mails':
|
||||||
|
self.root.ids.sc17.clear_widgets()
|
||||||
|
self.root.ids.sc17.add_widget(Allmails())
|
||||||
|
try:
|
||||||
|
self.root.ids.sc17.children[1].active = False
|
||||||
|
except Exception:
|
||||||
|
self.root.ids.sc17.children[0].children[1].active = False
|
||||||
|
|
||||||
|
|
||||||
|
class GrashofPopup(Popup):
|
||||||
|
"""Moule for save contacts and error messages"""
|
||||||
|
valid = False
|
||||||
|
|
||||||
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
|
"""Grash of pop screen settings"""
|
||||||
|
super(GrashofPopup, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
def savecontact(self):
|
||||||
|
"""Method is used for saving contacts"""
|
||||||
|
label = self.ids.label.text.strip()
|
||||||
|
address = self.ids.address.text.strip()
|
||||||
|
if label == '' and address == '':
|
||||||
|
self.ids.label.focus = True
|
||||||
|
self.ids.address.focus = True
|
||||||
|
elif address == '':
|
||||||
|
self.ids.address.focus = True
|
||||||
|
elif label == '':
|
||||||
|
self.ids.label.focus = True
|
||||||
|
|
||||||
|
stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
|
||||||
|
folder="addressbook")]
|
||||||
|
stored_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
||||||
|
folder="addressbook")]
|
||||||
|
if label and address and address not in stored_address \
|
||||||
|
and label not in stored_labels and self.valid:
|
||||||
|
# state.navinstance = self.parent.children[1]
|
||||||
|
queues.UISignalQueue.put(('rerenderAddressBook', ''))
|
||||||
|
self.dismiss()
|
||||||
|
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
|
||||||
|
self.parent.children[1].ids.sc11.ids.ml.clear_widgets()
|
||||||
|
self.parent.children[1].ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
|
self.parent.children[1].ids.scr_mngr.current = 'addressbook'
|
||||||
|
toast('Saved')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def close_pop():
|
||||||
|
"""Pop is Canceled"""
|
||||||
|
toast('Canceled')
|
||||||
|
|
||||||
|
def checkAddress_valid(self, instance):
|
||||||
|
"""Checking address is valid or not"""
|
||||||
|
my_addresses = (
|
||||||
|
self.parent.children[1].children[2].children[0].ids.btn.values)
|
||||||
|
add_book = [addr[1] for addr in kivy_helper_search.search_sql(
|
||||||
|
folder="addressbook")]
|
||||||
|
entered_text = str(instance.text).strip()
|
||||||
|
if entered_text in add_book:
|
||||||
|
text = 'Address is already in the addressbook.'
|
||||||
|
elif entered_text in my_addresses:
|
||||||
|
text = 'You can not save your own address.'
|
||||||
|
elif entered_text:
|
||||||
|
text = self.addressChanged(entered_text)
|
||||||
|
|
||||||
|
if entered_text in my_addresses or entered_text in add_book:
|
||||||
|
self.ids.address.error = True
|
||||||
|
self.ids.address.helper_text = text
|
||||||
|
elif entered_text and self.valid:
|
||||||
|
self.ids.address.error = False
|
||||||
|
elif entered_text:
|
||||||
|
self.ids.address.error = True
|
||||||
|
self.ids.address.helper_text = text
|
||||||
|
else:
|
||||||
|
self.ids.address.error = False
|
||||||
|
self.ids.address.helper_text = 'This field is required'
|
||||||
|
|
||||||
|
def checkLabel_valid(self, instance):
|
||||||
|
"""Checking address label is unique or not"""
|
||||||
|
entered_label = instance.text.strip()
|
||||||
|
addr_labels = [labels[0] for labels in kivy_helper_search.search_sql(
|
||||||
|
folder="addressbook")]
|
||||||
|
if entered_label in addr_labels:
|
||||||
|
self.ids.label.error = True
|
||||||
|
self.ids.label.helper_text = 'label name already exists.'
|
||||||
|
elif entered_label:
|
||||||
|
self.ids.label.error = False
|
||||||
|
else:
|
||||||
|
self.ids.label.error = False
|
||||||
|
self.ids.label.helper_text = 'This field is required'
|
||||||
|
|
||||||
|
def _onSuccess(self, addressVersion, streamNumber, ripe):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def addressChanged(self, addr):
|
||||||
|
"""Address validation callback, performs validation and gives feedback"""
|
||||||
|
status, addressVersion, streamNumber, ripe = decodeAddress(
|
||||||
|
str(addr))
|
||||||
|
self.valid = status == 'success'
|
||||||
|
if self.valid:
|
||||||
|
text = "Address is valid."
|
||||||
|
self._onSuccess(addressVersion, streamNumber, ripe)
|
||||||
|
elif status == 'missingbm':
|
||||||
|
text = "The address should start with ''BM-''"
|
||||||
|
elif status == 'checksumfailed':
|
||||||
|
text = "The address is not typed or copied correctly(the checksum failed)."
|
||||||
|
elif status == 'versiontoohigh':
|
||||||
|
text = "The version number of this address is higher"\
|
||||||
|
" than this software can support. Please upgrade Bitmessage."
|
||||||
|
elif status == 'invalidcharacters':
|
||||||
|
text = "The address contains invalid characters."
|
||||||
|
elif status == 'ripetooshort':
|
||||||
|
text = "Some data encoded in the address is too short."
|
||||||
|
elif status == 'ripetoolong':
|
||||||
|
text = "Some data encoded in the address is too long."
|
||||||
|
elif status == 'varintmalformed':
|
||||||
|
text = "Some data encoded in the address is malformed."
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
class AvatarSampleWidget(ILeftBody, Image):
|
||||||
|
"""Avatar Sample Widget"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
|
||||||
|
"""Left icon sample widget"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
|
||||||
|
"""Right icon sample widget"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NavigationDrawerTwoLineListItem(
|
||||||
|
TwoLineListItem, NavigationDrawerHeaderBase):
|
||||||
|
"""Navigation Drawer in Listitems"""
|
||||||
|
address_property = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
"""Method for Navigation Drawer"""
|
||||||
|
super(NavigationDrawerTwoLineListItem, self).__init__(**kwargs)
|
||||||
|
Clock.schedule_once(lambda dt: self.setup())
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
"""Bind Controller.current_account property"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_current_account(self, account):
|
||||||
|
"""Account detail"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _update_specific_text_color(self, instance, value):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _set_active(self, active, list_):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MailDetail(Screen):
|
||||||
|
"""MailDetail Screen uses to show the detail of mails"""
|
||||||
|
to_addr = StringProperty()
|
||||||
|
from_addr = StringProperty()
|
||||||
|
subject = StringProperty()
|
||||||
|
message = StringProperty()
|
||||||
|
status = StringProperty()
|
||||||
|
page_type = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Mail Details method"""
|
||||||
|
super(MailDetail, self).__init__(*args, **kwargs)
|
||||||
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock Schdule for method MailDetail mails"""
|
||||||
|
self.page_type = state.detailPageType if state.detailPageType else ''
|
||||||
|
if state.detailPageType == 'sent' or state.detailPageType == 'draft':
|
||||||
|
data = sqlQuery(
|
||||||
|
"select toaddress, fromaddress, subject, message, status,"
|
||||||
|
" ackdata from sent where ackdata = ?;", state.mail_id)
|
||||||
|
state.status = self
|
||||||
|
state.ackdata = data[0][5]
|
||||||
|
self.assign_mail_details(data)
|
||||||
|
state.kivyapp.set_mail_detail_header()
|
||||||
|
elif state.detailPageType == 'inbox':
|
||||||
|
data = sqlQuery(
|
||||||
|
"select toaddress, fromaddress, subject, message from inbox"
|
||||||
|
" where msgid = ?;", str(state.mail_id))
|
||||||
|
self.assign_mail_details(data)
|
||||||
|
state.kivyapp.set_mail_detail_header()
|
||||||
|
|
||||||
|
def assign_mail_details(self, data):
|
||||||
|
"""Assigning mail details"""
|
||||||
|
self.to_addr = data[0][0]
|
||||||
|
self.from_addr = data[0][1]
|
||||||
|
self.subject = data[0][2].upper(
|
||||||
|
) if data[0][2].upper() else '(no subject)'
|
||||||
|
self.message = data[0][3]
|
||||||
|
if len(data[0]) == 6:
|
||||||
|
self.status = data[0][4]
|
||||||
|
state.write_msg = {'to_addr': self.to_addr,
|
||||||
|
'from_addr': self.from_addr,
|
||||||
|
'subject': self.subject,
|
||||||
|
'message': self.message}
|
||||||
|
|
||||||
|
def delete_mail(self):
|
||||||
|
"""Method for mail delete"""
|
||||||
|
msg_count_objs = state.kivyapp.root.children[2].children[0].ids
|
||||||
|
state.searcing_text = ''
|
||||||
|
self.children[0].children[0].active = True
|
||||||
|
if state.detailPageType == 'sent':
|
||||||
|
state.kivyapp.root.ids.sc4.children[
|
||||||
|
2].children[2].ids.search_field.text = ''
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE sent SET folder = 'trash' WHERE"
|
||||||
|
" ackdata = ?;", str(state.mail_id))
|
||||||
|
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) if int(state.sent_count) else '0'
|
||||||
|
state.sent_count = str(int(state.sent_count) - 1) if int(state.sent_count) else '0'
|
||||||
|
self.parent.screens[3].ids.ml.clear_widgets()
|
||||||
|
self.parent.screens[3].loadSent(state.association)
|
||||||
|
elif state.detailPageType == 'inbox':
|
||||||
|
state.kivyapp.root.ids.sc1.children[
|
||||||
|
2].children[2].ids.search_field.text = ''
|
||||||
|
self.parent.screens[0].children[2].children[
|
||||||
|
2].ids.search_field.text = ''
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE inbox SET folder = 'trash' WHERE"
|
||||||
|
" msgid = ?;", str(state.mail_id))
|
||||||
|
msg_count_objs.inbox_cnt.badge_text = str(
|
||||||
|
int(state.inbox_count) - 1) if int(state.inbox_count) else '0'
|
||||||
|
state.inbox_count = str(int(state.inbox_count) - 1) if int(state.inbox_count) else '0'
|
||||||
|
self.parent.screens[0].ids.ml.clear_widgets()
|
||||||
|
self.parent.screens[0].loadMessagelist(state.association)
|
||||||
|
|
||||||
|
elif state.detailPageType == 'draft':
|
||||||
|
sqlExecute(
|
||||||
|
"DELETE FROM sent WHERE ackdata = ?;", str(state.mail_id))
|
||||||
|
msg_count_objs.draft_cnt.badge_text = str(
|
||||||
|
int(state.draft_count) - 1)
|
||||||
|
state.draft_count = str(int(state.draft_count) - 1)
|
||||||
|
self.parent.screens[15].clear_widgets()
|
||||||
|
self.parent.screens[15].add_widget(Draft())
|
||||||
|
|
||||||
|
# self.parent.current = 'allmails' \
|
||||||
|
# if state.is_allmail else state.detailPageType
|
||||||
|
if state.detailPageType != 'draft':
|
||||||
|
msg_count_objs.trash_cnt.badge_text = str(
|
||||||
|
int(state.trash_count) + 1)
|
||||||
|
msg_count_objs.allmail_cnt.badge_text = str(
|
||||||
|
int(state.all_count) - 1) if int(state.all_count) else '0'
|
||||||
|
state.trash_count = str(int(state.trash_count) + 1)
|
||||||
|
state.all_count = str(int(state.all_count) - 1) if int(state.all_count) else '0'
|
||||||
|
self.parent.screens[4].clear_widgets()
|
||||||
|
self.parent.screens[4].add_widget(Trash())
|
||||||
|
self.parent.screens[16].clear_widgets()
|
||||||
|
self.parent.screens[16].add_widget(Allmails())
|
||||||
|
Clock.schedule_once(self.callback_for_delete, 4)
|
||||||
|
|
||||||
|
def callback_for_delete(self, dt=0):
|
||||||
|
"""Delete method from allmails"""
|
||||||
|
self.children[0].children[0].active = False
|
||||||
|
state.kivyapp.set_common_header()
|
||||||
|
self.parent.current = 'allmails' \
|
||||||
|
if state.is_allmail else state.detailPageType
|
||||||
|
state.detailPageType = ''
|
||||||
|
toast('Deleted')
|
||||||
|
|
||||||
|
def inbox_reply(self):
|
||||||
|
"""Reply inbox messages"""
|
||||||
|
data = sqlQuery(
|
||||||
|
"select toaddress, fromaddress, subject, message from inbox where"
|
||||||
|
" msgid = ?;", str(state.mail_id))
|
||||||
|
composer_obj = self.parent.screens[2].children[1].ids
|
||||||
|
composer_obj.ti.text = data[0][0]
|
||||||
|
composer_obj.btn.text = data[0][0]
|
||||||
|
composer_obj.txt_input.text = data[0][1]
|
||||||
|
composer_obj.subject.text = data[0][2]
|
||||||
|
composer_obj.body.text = ''
|
||||||
|
state.kivyapp.root.ids.sc3.children[1].ids.rv.data = ''
|
||||||
|
self.parent.current = 'create'
|
||||||
|
state.kivyapp.set_navbar_for_composer()
|
||||||
|
|
||||||
|
def write_msg(self, navApp):
|
||||||
|
"""Write on draft mail"""
|
||||||
|
state.send_draft_mail = state.mail_id
|
||||||
|
composer_ids = (
|
||||||
|
self.parent.parent.parent.parent.parent.ids.sc3.children[1].ids)
|
||||||
|
composer_ids.ti.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.subject.text = state.write_msg[
|
||||||
|
'subject'] if state.write_msg['subject'] != '(no subject)' else ''
|
||||||
|
composer_ids.body.text = state.write_msg['message']
|
||||||
|
self.parent.current = 'create'
|
||||||
|
navApp.set_navbar_for_composer()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def copy_composer_text(instance, *args):
|
||||||
|
"""Copy the data from mail detail page"""
|
||||||
|
if len(instance.parent.text.split(':')) > 1:
|
||||||
|
cpy_text = instance.parent.text.split(':')[1].strip()
|
||||||
|
else:
|
||||||
|
cpy_text = instance.parent.text
|
||||||
|
Clipboard.copy(cpy_text)
|
||||||
|
toast('Copied')
|
||||||
|
|
||||||
|
|
||||||
|
class MyaddDetailPopup(Popup):
|
||||||
|
"""MyaddDetailPopup pop is used for showing my address detail"""
|
||||||
|
address_label = StringProperty()
|
||||||
|
address = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
|
||||||
|
"""My Address Details screen setting"""
|
||||||
|
super(MyaddDetailPopup, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
def set_address(self, address, label):
|
||||||
|
"""Getting address for displaying details on popup"""
|
||||||
|
self.address_label = label
|
||||||
|
self.address = address
|
||||||
|
|
||||||
|
def send_message_from(self):
|
||||||
|
"""Method used to fill from address of composer autofield"""
|
||||||
|
state.kivyapp.set_navbar_for_composer()
|
||||||
|
window_obj = self.parent.children[1].ids
|
||||||
|
window_obj.sc3.children[1].ids.ti.text = self.address
|
||||||
|
window_obj.sc3.children[1].ids.btn.text = self.address
|
||||||
|
window_obj.sc3.children[1].ids.txt_input.text = ''
|
||||||
|
window_obj.sc3.children[1].ids.subject.text = ''
|
||||||
|
window_obj.sc3.children[1].ids.body.text = ''
|
||||||
|
window_obj.scr_mngr.current = 'create'
|
||||||
|
self.dismiss()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def close_pop():
|
||||||
|
"""Pop is Canceled"""
|
||||||
|
toast('Canceled')
|
||||||
|
|
||||||
|
|
||||||
|
class AddbookDetailPopup(Popup):
|
||||||
|
"""AddbookDetailPopup pop is used for showing my address detail"""
|
||||||
|
address_label = StringProperty()
|
||||||
|
address = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
"""Set screen of address detail page"""
|
||||||
|
# pylint: disable=useless-super-delegation
|
||||||
|
super(AddbookDetailPopup, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
def set_addbook_data(self, address, label):
|
||||||
|
"""Getting address book data for detial dipaly"""
|
||||||
|
self.address_label = label
|
||||||
|
self.address = address
|
||||||
|
|
||||||
|
def update_addbook_label(self, address):
|
||||||
|
"""Updating the label of address book address"""
|
||||||
|
address_list = kivy_helper_search.search_sql(folder="addressbook")
|
||||||
|
stored_labels = [labels[0] for labels in address_list]
|
||||||
|
add_dict = dict(address_list)
|
||||||
|
label = str(self.ids.add_label.text)
|
||||||
|
if label in stored_labels and self.address == add_dict[label]:
|
||||||
|
stored_labels.remove(label)
|
||||||
|
if label and label not in stored_labels:
|
||||||
|
sqlExecute(
|
||||||
|
"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.loadAddresslist(None, 'All', '')
|
||||||
|
self.dismiss()
|
||||||
|
toast('Saved')
|
||||||
|
|
||||||
|
def send_message_to(self):
|
||||||
|
"""Method used to fill to_address of composer autofield"""
|
||||||
|
state.kivyapp.set_navbar_for_composer()
|
||||||
|
window_obj = self.parent.children[1].ids
|
||||||
|
window_obj.sc3.children[1].ids.txt_input.text = self.address
|
||||||
|
window_obj.sc3.children[1].ids.ti.text = ''
|
||||||
|
window_obj.sc3.children[1].ids.btn.text = 'Select'
|
||||||
|
window_obj.sc3.children[1].ids.subject.text = ''
|
||||||
|
window_obj.sc3.children[1].ids.body.text = ''
|
||||||
|
window_obj.scr_mngr.current = 'create'
|
||||||
|
self.dismiss()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def close_pop():
|
||||||
|
"""Pop is Canceled"""
|
||||||
|
toast('Canceled')
|
||||||
|
|
||||||
|
def checkLabel_valid(self, instance):
|
||||||
|
"""Checking address label is unique of not"""
|
||||||
|
entered_label = str(instance.text.strip())
|
||||||
|
address_list = kivy_helper_search.search_sql(folder="addressbook")
|
||||||
|
addr_labels = [labels[0] for labels in address_list]
|
||||||
|
add_dict = dict(address_list)
|
||||||
|
if self.address and entered_label in addr_labels \
|
||||||
|
and self.address != add_dict[entered_label]:
|
||||||
|
self.ids.add_label.error = True
|
||||||
|
self.ids.add_label.helper_text = 'label name already exists.'
|
||||||
|
elif entered_label:
|
||||||
|
self.ids.add_label.error = False
|
||||||
|
else:
|
||||||
|
self.ids.add_label.error = False
|
||||||
|
self.ids.add_label.helper_text = 'This field is required'
|
||||||
|
|
||||||
|
|
||||||
|
class ShowQRCode(Screen):
|
||||||
|
"""ShowQRCode Screen uses to show the detail of mails"""
|
||||||
|
|
||||||
|
def qrdisplay(self):
|
||||||
|
"""Showing QR Code"""
|
||||||
|
# self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
|
||||||
|
self.ids.qr.clear_widgets()
|
||||||
|
from kivy.garden.qrcode import QRCodeWidget
|
||||||
|
self.ids.qr.add_widget(QRCodeWidget(
|
||||||
|
data=self.manager.get_parent_window().children[0].address))
|
||||||
|
toast('Show QR code')
|
||||||
|
|
||||||
|
|
||||||
|
class Draft(Screen):
|
||||||
|
"""Draft screen is used to show the list of draft messages"""
|
||||||
|
data = ListProperty()
|
||||||
|
account = StringProperty()
|
||||||
|
queryreturn = ListProperty()
|
||||||
|
has_refreshed = True
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Method used for storing draft messages"""
|
||||||
|
super(Draft, self).__init__(*args, **kwargs)
|
||||||
|
if state.association == '':
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
state.association = BMConfigParser().addresses()[0]
|
||||||
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock Schdule for method draft accounts"""
|
||||||
|
self.sentaccounts()
|
||||||
|
print dt
|
||||||
|
|
||||||
|
def sentaccounts(self):
|
||||||
|
"""Load draft accounts."""
|
||||||
|
self.account = state.association
|
||||||
|
self.loadDraft()
|
||||||
|
|
||||||
|
def loadDraft(self, where="", what=""):
|
||||||
|
"""Load draft list for Draft messages."""
|
||||||
|
xAddress = 'fromaddress'
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
self.draftDataQuery(xAddress, where, what)
|
||||||
|
if state.msg_counter_objs:
|
||||||
|
state.msg_counter_objs.draft_cnt.badge_text = str(
|
||||||
|
len(self.queryreturn))
|
||||||
|
if self.queryreturn:
|
||||||
|
self.ids.identi_tag.children[0].text = 'Draft'
|
||||||
|
src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
||||||
|
src_mng_obj.draft_cnt.badge_text = state.draft_count
|
||||||
|
self.set_mdList()
|
||||||
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
|
else:
|
||||||
|
content = MDLabel(
|
||||||
|
font_style='Body1', theme_text_color='Primary',
|
||||||
|
text="yet no message for this account!!!!!!!!!!!!!",
|
||||||
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
|
self.ids.ml.add_widget(content)
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
|
def draftDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
|
||||||
|
"""This methosd is for retrieving draft messages"""
|
||||||
|
self.queryreturn = kivy_helper_search.search_sql(
|
||||||
|
xAddress, self.account, "draft", where, what,
|
||||||
|
False, start_indx, end_indx)
|
||||||
|
|
||||||
|
def set_mdList(self):
|
||||||
|
"""This method is used to create mdlist"""
|
||||||
|
data = []
|
||||||
|
total_draft_msg = len(self.ids.ml.children)
|
||||||
|
for mail in self.queryreturn:
|
||||||
|
third_text = mail[3].replace('\n', ' ')
|
||||||
|
data.append({
|
||||||
|
'text': mail[1].strip(),
|
||||||
|
'secondary_text': mail[2][:10] + '...........' if len(
|
||||||
|
mail[2]) > 10 else mail[2] + '\n' + " " + (
|
||||||
|
third_text[:25] + '...!') if len(
|
||||||
|
third_text) > 25 else third_text,
|
||||||
|
'ackdata': mail[5]})
|
||||||
|
for item in data:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text='Draft', secondary_text=item['text'],
|
||||||
|
theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
meny.add_widget(AvatarSampleWidget(
|
||||||
|
source='./images/avatar.png'))
|
||||||
|
meny.bind(on_press=partial(
|
||||||
|
self.draft_detail, item['ackdata']))
|
||||||
|
carousel = Carousel(direction='right')
|
||||||
|
carousel.height = meny.height
|
||||||
|
carousel.size_hint_y = None
|
||||||
|
carousel.ignore_perpendicular_swipes = True
|
||||||
|
carousel.data_index = 0
|
||||||
|
carousel.min_move = 0.2
|
||||||
|
del_btn = Button(text='Delete')
|
||||||
|
del_btn.background_normal = ''
|
||||||
|
del_btn.background_color = (1, 0, 0, 1)
|
||||||
|
del_btn.bind(on_press=partial(self.delete_draft, item['ackdata']))
|
||||||
|
carousel.add_widget(del_btn)
|
||||||
|
carousel.add_widget(meny)
|
||||||
|
carousel.index = 1
|
||||||
|
self.ids.ml.add_widget(carousel)
|
||||||
|
updated_msg = len(self.ids.ml.children)
|
||||||
|
self.has_refreshed = True if total_draft_msg != updated_msg else False
|
||||||
|
|
||||||
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
|
"""Load data on scroll"""
|
||||||
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
||||||
|
self.ids.scroll_y.scroll_y = 0.06
|
||||||
|
total_draft_msg = len(self.ids.ml.children)
|
||||||
|
self.update_draft_screen_on_scroll(total_draft_msg)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def update_draft_screen_on_scroll(self, total_draft_msg, where='', what=''):
|
||||||
|
"""Load more data on scroll down"""
|
||||||
|
self.draftDataQuery('fromaddress', where, what, total_draft_msg, 5)
|
||||||
|
self.set_mdList()
|
||||||
|
|
||||||
|
def draft_detail(self, ackdata, *args):
|
||||||
|
"""Show draft Details"""
|
||||||
|
state.detailPageType = 'draft'
|
||||||
|
state.mail_id = ackdata
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[13].clear_widgets()
|
||||||
|
src_mng_obj.screens[13].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
|
|
||||||
|
def delete_draft(self, data_index, instance, *args):
|
||||||
|
"""Delete draft message permanently"""
|
||||||
|
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str(
|
||||||
|
data_index))
|
||||||
|
try:
|
||||||
|
msg_count_objs = (
|
||||||
|
self.parent.parent.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids)
|
||||||
|
except Exception:
|
||||||
|
msg_count_objs = self.parent.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids
|
||||||
|
if int(state.draft_count) > 0:
|
||||||
|
msg_count_objs.draft_cnt.badge_text = str(
|
||||||
|
int(state.draft_count) - 1)
|
||||||
|
state.draft_count = str(int(state.draft_count) - 1)
|
||||||
|
if int(state.draft_count) <= 0:
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
|
toast('Deleted')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def draft_msg(src_object): # pylint: disable=too-many-locals
|
||||||
|
"""Save draft mails"""
|
||||||
|
composer_object = state.kivyapp.root.ids.sc3.children[1].ids
|
||||||
|
fromAddress = str(composer_object.ti.text)
|
||||||
|
toAddress = str(composer_object.txt_input.text)
|
||||||
|
subject = str(composer_object.subject.text)
|
||||||
|
message = str(composer_object.body.text)
|
||||||
|
encoding = 3
|
||||||
|
sendMessageToPeople = True
|
||||||
|
if sendMessageToPeople:
|
||||||
|
streamNumber, ripe = decodeAddress(toAddress)[2:]
|
||||||
|
toAddress = addBMIfNotPresent(toAddress)
|
||||||
|
stealthLevel = BMConfigParser().safeGetInt(
|
||||||
|
'bitmessagesettings', 'ackstealthlevel')
|
||||||
|
from helper_ackPayload import genAckPayload
|
||||||
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
|
sqlExecute(
|
||||||
|
'''INSERT INTO sent VALUES
|
||||||
|
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '', toAddress, ripe,
|
||||||
|
fromAddress, subject, message, ackdata, int(time.time()),
|
||||||
|
int(time.time()), 0, 'msgqueued', 0, 'draft', encoding,
|
||||||
|
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||||
|
state.msg_counter_objs = src_object.children[2].children[0].ids
|
||||||
|
state.draft_count = str(int(state.draft_count) + 1)
|
||||||
|
src_object.ids.sc16.clear_widgets()
|
||||||
|
src_object.ids.sc16.add_widget(Draft())
|
||||||
|
toast('Save draft')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class CustomSpinner(Spinner):
|
||||||
|
"""This class is used for setting spinner size"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Setting size of spinner"""
|
||||||
|
super(CustomSpinner, self).__init__(*args, **kwargs)
|
||||||
|
self.dropdown_cls.max_height = Window.size[1] / 3
|
||||||
|
|
||||||
|
|
||||||
|
class Allmails(Screen):
|
||||||
|
"""All mails Screen uses screen to show widgets of screens"""
|
||||||
|
data = ListProperty()
|
||||||
|
has_refreshed = True
|
||||||
|
all_mails = ListProperty()
|
||||||
|
account = StringProperty()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Method Parsing the address."""
|
||||||
|
super(Allmails, self).__init__(*args, **kwargs)
|
||||||
|
if state.association == '':
|
||||||
|
if BMConfigParser().addresses():
|
||||||
|
state.association = BMConfigParser().addresses()[0]
|
||||||
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
|
def init_ui(self, dt=0):
|
||||||
|
"""Clock Schdule for method all mails"""
|
||||||
|
self.loadMessagelist()
|
||||||
|
print dt
|
||||||
|
|
||||||
|
def loadMessagelist(self):
|
||||||
|
"""Load Inbox, Sent anf Draft list of messages."""
|
||||||
|
self.account = state.association
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
self.allMessageQuery(0, 20)
|
||||||
|
if self.all_mails:
|
||||||
|
self.ids.identi_tag.children[0].text = 'All Mails'
|
||||||
|
state.kivyapp.get_inbox_count()
|
||||||
|
state.kivyapp.get_sent_count()
|
||||||
|
state.all_count = str(
|
||||||
|
int(state.sent_count) + int(state.inbox_count))
|
||||||
|
state.kivyapp.root.children[2].children[
|
||||||
|
0].ids.allmail_cnt.badge_text = state.all_count
|
||||||
|
self.set_mdlist()
|
||||||
|
# self.ids.refresh_layout.bind(scroll_y=self.check_scroll_y)
|
||||||
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
|
else:
|
||||||
|
content = MDLabel(
|
||||||
|
font_style='Body1', theme_text_color='Primary',
|
||||||
|
text="yet no message for this account!!!!!!!!!!!!!",
|
||||||
|
halign='center', bold=True, size_hint_y=None, valign='top')
|
||||||
|
self.ids.ml.add_widget(content)
|
||||||
|
|
||||||
|
def allMessageQuery(self, start_indx, end_indx):
|
||||||
|
"""Retrieving data from inbox or sent both tables"""
|
||||||
|
self.all_mails = sqlQuery(
|
||||||
|
"SELECT toaddress, fromaddress, subject, message, folder, ackdata"
|
||||||
|
" As id, DATE(lastactiontime) As actionTime FROM sent WHERE"
|
||||||
|
" folder = 'sent' and fromaddress = '{0}'"
|
||||||
|
" UNION SELECT toaddress, fromaddress, subject, message, folder,"
|
||||||
|
" msgid As id, DATE(received) As actionTime FROM inbox"
|
||||||
|
" WHERE folder = 'inbox' and toaddress = '{0}'"
|
||||||
|
" ORDER BY actionTime DESC limit {1}, {2}".format(
|
||||||
|
self.account, start_indx, end_indx))
|
||||||
|
|
||||||
|
def set_mdlist(self):
|
||||||
|
"""This method is used to create mdList for allmaills"""
|
||||||
|
data_exist = len(self.ids.ml.children)
|
||||||
|
for item in self.all_mails:
|
||||||
|
meny = TwoLineAvatarIconListItem(
|
||||||
|
text=item[1],
|
||||||
|
secondary_text=item[2][:50] + '........' if len(
|
||||||
|
item[2]) >= 50 else (
|
||||||
|
item[2] + ',' + item[3].replace(
|
||||||
|
'\n', ''))[0:50] + '........',
|
||||||
|
theme_text_color='Custom',
|
||||||
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
|
meny.add_widget(AvatarSampleWidget(
|
||||||
|
source='./images/text_images/{}.png'.format(
|
||||||
|
avatarImageFirstLetter(item[2].strip()))))
|
||||||
|
meny.bind(on_press=partial(
|
||||||
|
self.mail_detail, item[5], item[4]))
|
||||||
|
carousel = Carousel(direction='right')
|
||||||
|
carousel.height = meny.height
|
||||||
|
carousel.size_hint_y = None
|
||||||
|
carousel.ignore_perpendicular_swipes = True
|
||||||
|
carousel.data_index = 0
|
||||||
|
carousel.min_move = 0.2
|
||||||
|
del_btn = Button(text='Delete')
|
||||||
|
del_btn.background_normal = ''
|
||||||
|
del_btn.background_color = (1, 0, 0, 1)
|
||||||
|
del_btn.bind(on_press=partial(
|
||||||
|
self.swipe_delete, item[5], item[4]))
|
||||||
|
carousel.add_widget(del_btn)
|
||||||
|
carousel.add_widget(meny)
|
||||||
|
carousel.index = 1
|
||||||
|
self.ids.ml.add_widget(carousel)
|
||||||
|
updated_data = len(self.ids.ml.children)
|
||||||
|
self.has_refreshed = True if data_exist != updated_data else False
|
||||||
|
|
||||||
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
|
"""Scroll fixed length"""
|
||||||
|
if self.ids.scroll_y.scroll_y <= -0.00 and self.has_refreshed:
|
||||||
|
self.ids.scroll_y.scroll_y = .06
|
||||||
|
load_more = len(self.ids.ml.children)
|
||||||
|
self.updating_allmail(load_more)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def updating_allmail(self, load_more):
|
||||||
|
"""This method is used to update the all mail
|
||||||
|
listing value on the scroll of screen"""
|
||||||
|
self.allMessageQuery(load_more, 5)
|
||||||
|
self.set_mdlist()
|
||||||
|
|
||||||
|
def mail_detail(self, unique_id, folder, *args):
|
||||||
|
"""Load sent and inbox mail details"""
|
||||||
|
state.detailPageType = folder
|
||||||
|
state.is_allmail = True
|
||||||
|
state.mail_id = unique_id
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[13].clear_widgets()
|
||||||
|
src_mng_obj.screens[13].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
|
|
||||||
|
def swipe_delete(self, unique_id, folder, instance, *args):
|
||||||
|
"""Delete inbox mail from all mail listing"""
|
||||||
|
if folder == 'inbox':
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;",
|
||||||
|
str(unique_id))
|
||||||
|
else:
|
||||||
|
sqlExecute(
|
||||||
|
"UPDATE sent SET folder = 'trash' WHERE ackdata = ?;",
|
||||||
|
str(unique_id))
|
||||||
|
self.ids.ml.remove_widget(instance.parent.parent)
|
||||||
|
try:
|
||||||
|
msg_count_objs = self.parent.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids
|
||||||
|
nav_lay_obj = self.parent.parent.parent.parent.parent.ids
|
||||||
|
except Exception:
|
||||||
|
msg_count_objs = self.parent.parent.parent.parent.parent.parent.children[
|
||||||
|
2].children[0].ids
|
||||||
|
nav_lay_obj = self.parent.parent.parent.parent.parent.parent.ids
|
||||||
|
if folder == 'inbox':
|
||||||
|
msg_count_objs.inbox_cnt.badge_text = str(
|
||||||
|
int(state.inbox_count) - 1)
|
||||||
|
state.inbox_count = str(int(state.inbox_count) - 1)
|
||||||
|
nav_lay_obj.sc1.ids.ml.clear_widgets()
|
||||||
|
nav_lay_obj.sc1.loadMessagelist(state.association)
|
||||||
|
else:
|
||||||
|
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
|
||||||
|
state.sent_count = str(int(state.sent_count) - 1)
|
||||||
|
nav_lay_obj.sc4.ids.ml.clear_widgets()
|
||||||
|
nav_lay_obj.sc4.loadSent(state.association)
|
||||||
|
msg_count_objs.trash_cnt.badge_text = str(int(state.trash_count) + 1)
|
||||||
|
msg_count_objs.allmail_cnt.badge_text = str(int(state.all_count) - 1)
|
||||||
|
state.trash_count = str(int(state.trash_count) + 1)
|
||||||
|
state.all_count = str(int(state.all_count) - 1)
|
||||||
|
if int(state.all_count) <= 0:
|
||||||
|
self.ids.identi_tag.children[0].text = ''
|
||||||
|
nav_lay_obj.sc5.clear_widgets()
|
||||||
|
nav_lay_obj.sc5.add_widget(Trash())
|
||||||
|
nav_lay_obj.sc17.remove_widget(instance.parent.parent)
|
||||||
|
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
def refresh_callback(self, *args):
|
||||||
|
"""Method updates the state of application,
|
||||||
|
While the spinner remains on the screen"""
|
||||||
|
def refresh_callback(interval):
|
||||||
|
"""Load the allmails screen data"""
|
||||||
|
self.ids.ml.clear_widgets()
|
||||||
|
self.remove_widget(self.children[1])
|
||||||
|
try:
|
||||||
|
screens_obj = self.parent.screens[16]
|
||||||
|
except Exception:
|
||||||
|
screens_obj = self.parent.parent.screens[16]
|
||||||
|
screens_obj.add_widget(Allmails())
|
||||||
|
self.ids.refresh_layout.refresh_done()
|
||||||
|
self.tick = 0
|
||||||
|
Clock.schedule_once(refresh_callback, 1)
|
||||||
|
|
||||||
|
def set_root_layout(self):
|
||||||
|
"""Setting root layout"""
|
||||||
|
try:
|
||||||
|
return self.manager.parent.parent
|
||||||
|
except Exception:
|
||||||
|
return state.kivyapp.root.ids.float_box
|
||||||
|
|
||||||
|
|
||||||
|
def avatarImageFirstLetter(letter_string):
|
||||||
|
"""This function is used to the first letter for the avatar image"""
|
||||||
|
if letter_string:
|
||||||
|
if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z':
|
||||||
|
img_latter = letter_string[0].upper()
|
||||||
|
elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9:
|
||||||
|
img_latter = letter_string[0]
|
||||||
|
else:
|
||||||
|
img_latter = '!'
|
||||||
|
else:
|
||||||
|
img_latter = '!'
|
||||||
|
return img_latter
|
||||||
|
|
||||||
|
|
||||||
|
class Starred(Screen):
|
||||||
|
"""Starred Screen show widgets of page"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Archieve(Screen):
|
||||||
|
"""Archieve Screen show widgets of page"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Spam(Screen):
|
||||||
|
"""Spam Screen show widgets of page"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class LoadingPopup(Popup):
|
||||||
|
"""Class for loading Popup"""
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(LoadingPopup, self).__init__(**kwargs)
|
||||||
|
# call dismiss_popup in 2 seconds
|
||||||
|
Clock.schedule_once(self.dismiss_popup, 0.5)
|
||||||
|
|
||||||
|
def dismiss_popup(self, dt):
|
||||||
|
"""Dismiss popups"""
|
||||||
|
self.dismiss()
|
||||||
|
|
28
src/bitmessagekivy/uikivysignaler.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
"""
|
||||||
|
Ui Singnaler for kivy interface
|
||||||
|
"""
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
|
import queues
|
||||||
|
import state
|
||||||
|
from semaphores import kivyuisignaler
|
||||||
|
|
||||||
|
|
||||||
|
class UIkivySignaler(Thread):
|
||||||
|
"""Kivy ui signaler"""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
kivyuisignaler.acquire()
|
||||||
|
while state.shutdown == 0:
|
||||||
|
try:
|
||||||
|
command, data = queues.UISignalQueue.get()
|
||||||
|
if command == 'writeNewAddressToTable':
|
||||||
|
address = data[1]
|
||||||
|
state.kivyapp.variable_1.append(address)
|
||||||
|
# elif command == 'rerenderAddressBook':
|
||||||
|
# state.kivyapp.obj_1.refreshs()
|
||||||
|
# Need to discuss this
|
||||||
|
elif command == 'updateSentItemStatusByAckdata':
|
||||||
|
state.kivyapp.status_dispatching(data)
|
||||||
|
except Exception as e:
|
||||||
|
print e
|
|
@ -12,15 +12,6 @@ The PyBitmessage startup script
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
app_dir = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
os.chdir(app_dir)
|
|
||||||
sys.path.insert(0, app_dir)
|
|
||||||
|
|
||||||
|
|
||||||
import depends
|
|
||||||
depends.check_dependencies()
|
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import getopt
|
import getopt
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
@ -33,6 +24,7 @@ import traceback
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
import defaults
|
import defaults
|
||||||
|
import depends
|
||||||
import shared
|
import shared
|
||||||
import state
|
import state
|
||||||
import shutdown
|
import shutdown
|
||||||
|
@ -55,6 +47,12 @@ from threads import (
|
||||||
set_thread_name,
|
set_thread_name,
|
||||||
addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread)
|
addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread)
|
||||||
|
|
||||||
|
app_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
os.chdir(app_dir)
|
||||||
|
sys.path.insert(0, app_dir)
|
||||||
|
|
||||||
|
depends.check_dependencies()
|
||||||
|
|
||||||
|
|
||||||
def connectToStream(streamNumber):
|
def connectToStream(streamNumber):
|
||||||
"""Connect to a stream"""
|
"""Connect to a stream"""
|
||||||
|
@ -158,13 +156,13 @@ def signal_handler(signum, frame):
|
||||||
if shared.thisapp.daemon or not state.enableGUI:
|
if shared.thisapp.daemon or not state.enableGUI:
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
else:
|
else:
|
||||||
print('# Thread: %s(%d)' % (thread.name, thread.ident))
|
print '# Thread: %s(%d)' % (thread.name, thread.ident)
|
||||||
for filename, lineno, name, line in traceback.extract_stack(frame):
|
for filename, lineno, name, line in traceback.extract_stack(frame):
|
||||||
print('File: "%s", line %d, in %s' % (filename, lineno, name))
|
print 'File: "%s", line %d, in %s' % (filename, lineno, name)
|
||||||
if line:
|
if line:
|
||||||
print(' %s' % line.strip())
|
print ' %s' % line.strip()
|
||||||
print('Unfortunately you cannot use Ctrl+C when running the UI'
|
print 'Unfortunately you cannot use Ctrl+C when running the UI \
|
||||||
' because the UI captures the signal.')
|
because the UI captures the signal.'
|
||||||
|
|
||||||
|
|
||||||
class Main(object):
|
class Main(object):
|
||||||
|
@ -217,7 +215,8 @@ class Main(object):
|
||||||
if daemon:
|
if daemon:
|
||||||
state.enableGUI = False # run without a UI
|
state.enableGUI = False # run without a UI
|
||||||
|
|
||||||
if state.enableGUI and not state.curses and not depends.check_pyqt():
|
# is the application already running? If yes then exit.
|
||||||
|
if state.enableGUI and not state.curses and not state.kivy and not depends.check_pyqt():
|
||||||
sys.exit(
|
sys.exit(
|
||||||
'PyBitmessage requires PyQt unless you want'
|
'PyBitmessage requires PyQt unless you want'
|
||||||
' to run it as a daemon and interact with it'
|
' to run it as a daemon and interact with it'
|
||||||
|
@ -231,11 +230,14 @@ class Main(object):
|
||||||
' \'-c\' as a commandline argument.'
|
' \'-c\' as a commandline argument.'
|
||||||
)
|
)
|
||||||
# is the application already running? If yes then exit.
|
# is the application already running? If yes then exit.
|
||||||
|
try:
|
||||||
shared.thisapp = singleinstance("", daemon)
|
shared.thisapp = singleinstance("", daemon)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
if daemon:
|
if daemon:
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print('Running as a daemon. Send TERM signal to end.')
|
print 'Running as a daemon. Send TERM signal to end.'
|
||||||
self.daemonize()
|
self.daemonize()
|
||||||
|
|
||||||
self.setSignalHandler()
|
self.setSignalHandler()
|
||||||
|
@ -258,6 +260,7 @@ class Main(object):
|
||||||
|
|
||||||
readKnownNodes()
|
readKnownNodes()
|
||||||
|
|
||||||
|
|
||||||
# Not needed if objproc is disabled
|
# Not needed if objproc is disabled
|
||||||
if state.enableObjProc:
|
if state.enableObjProc:
|
||||||
|
|
||||||
|
@ -279,14 +282,11 @@ class Main(object):
|
||||||
# The closeEvent should command this thread to exit gracefully.
|
# The closeEvent should command this thread to exit gracefully.
|
||||||
sqlLookup.daemon = False
|
sqlLookup.daemon = False
|
||||||
sqlLookup.start()
|
sqlLookup.start()
|
||||||
|
|
||||||
Inventory() # init
|
Inventory() # init
|
||||||
# init, needs to be early because other thread may access it early
|
# init, needs to be early because other thread may access it early
|
||||||
Dandelion()
|
Dandelion()
|
||||||
|
|
||||||
# Enable object processor and SMTP only if objproc enabled
|
# Enable object processor and SMTP only if objproc enabled
|
||||||
if state.enableObjProc:
|
if state.enableObjProc:
|
||||||
|
|
||||||
# SMTP delivery thread
|
# SMTP delivery thread
|
||||||
if daemon and config.safeGet(
|
if daemon and config.safeGet(
|
||||||
'bitmessagesettings', 'smtpdeliver', '') != '':
|
'bitmessagesettings', 'smtpdeliver', '') != '':
|
||||||
|
@ -308,18 +308,15 @@ class Main(object):
|
||||||
# each object.
|
# each object.
|
||||||
objectProcessorThread.daemon = False
|
objectProcessorThread.daemon = False
|
||||||
objectProcessorThread.start()
|
objectProcessorThread.start()
|
||||||
|
|
||||||
# Start the cleanerThread
|
# Start the cleanerThread
|
||||||
singleCleanerThread = singleCleaner()
|
singleCleanerThread = singleCleaner()
|
||||||
# close the main program even if there are threads left
|
# close the main program even if there are threads left
|
||||||
singleCleanerThread.daemon = True
|
singleCleanerThread.daemon = True
|
||||||
singleCleanerThread.start()
|
singleCleanerThread.start()
|
||||||
|
|
||||||
# Not needed if objproc disabled
|
# Not needed if objproc disabled
|
||||||
if state.enableObjProc:
|
if state.enableObjProc:
|
||||||
shared.reloadMyAddressHashes()
|
shared.reloadMyAddressHashes()
|
||||||
shared.reloadBroadcastSendersForWhichImWatching()
|
shared.reloadBroadcastSendersForWhichImWatching()
|
||||||
|
|
||||||
# API is also objproc dependent
|
# API is also objproc dependent
|
||||||
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
|
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
|
||||||
import api # pylint: disable=relative-import
|
import api # pylint: disable=relative-import
|
||||||
|
@ -327,7 +324,6 @@ class Main(object):
|
||||||
# close the main program even if there are threads left
|
# close the main program even if there are threads left
|
||||||
singleAPIThread.daemon = True
|
singleAPIThread.daemon = True
|
||||||
singleAPIThread.start()
|
singleAPIThread.start()
|
||||||
|
|
||||||
# start network components if networking is enabled
|
# start network components if networking is enabled
|
||||||
if state.enableNetwork:
|
if state.enableNetwork:
|
||||||
start_proxyconfig()
|
start_proxyconfig()
|
||||||
|
@ -356,7 +352,6 @@ class Main(object):
|
||||||
state.uploadThread.start()
|
state.uploadThread.start()
|
||||||
|
|
||||||
connectToStream(1)
|
connectToStream(1)
|
||||||
|
|
||||||
if config.safeGetBoolean('bitmessagesettings', 'upnp'):
|
if config.safeGetBoolean('bitmessagesettings', 'upnp'):
|
||||||
import upnp
|
import upnp
|
||||||
upnpThread = upnp.uPnPThread()
|
upnpThread = upnp.uPnPThread()
|
||||||
|
@ -364,18 +359,19 @@ class Main(object):
|
||||||
else:
|
else:
|
||||||
# Populate with hardcoded value (same as connectToStream above)
|
# Populate with hardcoded value (same as connectToStream above)
|
||||||
state.streamsInWhichIAmParticipating.append(1)
|
state.streamsInWhichIAmParticipating.append(1)
|
||||||
|
|
||||||
if not daemon and state.enableGUI:
|
if not daemon and state.enableGUI:
|
||||||
if state.curses:
|
if state.curses:
|
||||||
if not depends.check_curses():
|
if not depends.check_curses():
|
||||||
sys.exit()
|
sys.exit()
|
||||||
print('Running with curses')
|
print 'Running with curses'
|
||||||
import bitmessagecurses
|
import bitmessagecurses
|
||||||
bitmessagecurses.runwrapper()
|
bitmessagecurses.runwrapper()
|
||||||
|
|
||||||
elif state.kivy:
|
elif state.kivy:
|
||||||
config.remove_option('bitmessagesettings', 'dontconnect')
|
config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
from bitmessagekivy.mpybit import NavigateApp
|
from bitmessagekivy.mpybit import NavigateApp
|
||||||
NavigateApp().run()
|
state.kivyapp = NavigateApp()
|
||||||
|
state.kivyapp.run()
|
||||||
else:
|
else:
|
||||||
import bitmessageqt
|
import bitmessageqt
|
||||||
bitmessageqt.run()
|
bitmessageqt.run()
|
||||||
|
@ -385,8 +381,7 @@ class Main(object):
|
||||||
if daemon:
|
if daemon:
|
||||||
while state.shutdown == 0:
|
while state.shutdown == 0:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if (
|
if (state.testmode and time.time() - state.last_api_response >= 30):
|
||||||
state.testmode and time.time() - state.last_api_response >= 30):
|
|
||||||
self.stop()
|
self.stop()
|
||||||
elif not state.enableGUI:
|
elif not state.enableGUI:
|
||||||
from tests import core as test_core # pylint: disable=relative-import
|
from tests import core as test_core # pylint: disable=relative-import
|
||||||
|
@ -412,6 +407,7 @@ class Main(object):
|
||||||
# wait until grandchild ready
|
# wait until grandchild ready
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
os._exit(0) # pylint: disable=protected-access
|
os._exit(0) # pylint: disable=protected-access
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# fork not implemented
|
# fork not implemented
|
||||||
|
@ -433,6 +429,7 @@ class Main(object):
|
||||||
# wait until child ready
|
# wait until child ready
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
os._exit(0) # pylint: disable=protected-access
|
os._exit(0) # pylint: disable=protected-access
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# fork not implemented
|
# fork not implemented
|
||||||
|
@ -479,7 +476,7 @@ All parameters are optional.
|
||||||
def stop():
|
def stop():
|
||||||
"""Stop main application"""
|
"""Stop main application"""
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print('Stopping Bitmessage Deamon.')
|
print 'Stopping Bitmessage Deamon.'
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
|
|
||||||
# .. todo:: nice function but no one is using this
|
# .. todo:: nice function but no one is using this
|
||||||
|
|
BIN
src/bob.png
Normal file
After Width: | Height: | Size: 640 B |
|
@ -1,10 +1,10 @@
|
||||||
[app]
|
[app]
|
||||||
|
|
||||||
# (str) Title of your application
|
# (str) Title of your application
|
||||||
title = PyBitmessage
|
title = bitapp
|
||||||
|
|
||||||
# (str) Package name
|
# (str) Package name
|
||||||
package.name = PyBitmessage
|
package.name = bitapp
|
||||||
|
|
||||||
# (str) Package domain (needed for android/ios packaging)
|
# (str) Package domain (needed for android/ios packaging)
|
||||||
package.domain = org.test
|
package.domain = org.test
|
||||||
|
@ -13,7 +13,7 @@ package.domain = org.test
|
||||||
source.dir = .
|
source.dir = .
|
||||||
|
|
||||||
# (list) Source files to include (let empty to include all the files)
|
# (list) Source files to include (let empty to include all the files)
|
||||||
source.include_exts = py,png,jpg,kv,atlas
|
source.include_exts = py,png,jpg,kv,atlas,gif,zip
|
||||||
|
|
||||||
# (list) List of inclusions using pattern matching
|
# (list) List of inclusions using pattern matching
|
||||||
#source.include_patterns = assets/*,images/*.png
|
#source.include_patterns = assets/*,images/*.png
|
||||||
|
@ -35,16 +35,25 @@ version = 0.1
|
||||||
# version.filename = %(source.dir)s/main.py
|
# version.filename = %(source.dir)s/main.py
|
||||||
|
|
||||||
# (list) Application requirements
|
# (list) Application requirements
|
||||||
# comma seperated e.g. requirements = sqlite3,kivy
|
# comma separated e.g. requirements = sqlite3,kivy
|
||||||
requirements = python2, sqlite3, kivy, openssl
|
requirements =
|
||||||
|
openssl,
|
||||||
|
sqlite3,
|
||||||
|
python2,
|
||||||
|
kivy,
|
||||||
|
bitmsghash,
|
||||||
|
kivymd,
|
||||||
|
kivy-garden,
|
||||||
|
qrcode,
|
||||||
|
Pillow,
|
||||||
|
msgpack
|
||||||
|
|
||||||
# (str) Custom source folders for requirements
|
# (str) Custom source folders for requirements
|
||||||
# Sets custom source for any requirements with recipes
|
# Sets custom source for any requirements with recipes
|
||||||
# requirements.source.kivy = ../../kivy
|
# requirements.source.kivy = ../../kivy
|
||||||
#requirements.source.sqlite3 =
|
|
||||||
|
|
||||||
# (list) Garden requirements
|
# (list) Garden requirements
|
||||||
#garden_requirements =
|
garden_requirements = qrcode
|
||||||
|
|
||||||
# (str) Presplash of the application
|
# (str) Presplash of the application
|
||||||
#presplash.filename = %(source.dir)s/data/presplash.png
|
#presplash.filename = %(source.dir)s/data/presplash.png
|
||||||
|
@ -66,8 +75,7 @@ orientation = portrait
|
||||||
# author = © Copyright Info
|
# author = © Copyright Info
|
||||||
|
|
||||||
# change the major version of python used by the app
|
# change the major version of python used by the app
|
||||||
#osx.python_version = 2
|
osx.python_version = 3
|
||||||
|
|
||||||
|
|
||||||
# Kivy version to use
|
# Kivy version to use
|
||||||
osx.kivy_version = 1.9.1
|
osx.kivy_version = 1.9.1
|
||||||
|
@ -87,19 +95,19 @@ fullscreen = 0
|
||||||
#android.presplash_color = #FFFFFF
|
#android.presplash_color = #FFFFFF
|
||||||
|
|
||||||
# (list) Permissions
|
# (list) Permissions
|
||||||
android.permissions = INTERNET
|
android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE
|
||||||
|
|
||||||
# (int) Android API to use
|
# (int) Android API to use
|
||||||
#android.api = 19
|
android.api = 27
|
||||||
|
|
||||||
# (int) Minimum API required
|
# (int) Minimum API required
|
||||||
#android.minapi = 9
|
android.minapi = 21
|
||||||
|
|
||||||
# (int) Android SDK version to use
|
# (int) Android SDK version to use
|
||||||
#android.sdk = 20
|
android.sdk = 20
|
||||||
|
|
||||||
# (str) Android NDK version to use
|
# (str) Android NDK version to use
|
||||||
#android.ndk = 9c
|
android.ndk = 17c
|
||||||
|
|
||||||
# (bool) Use --private data storage (True) or --dir public storage (False)
|
# (bool) Use --private data storage (True) or --dir public storage (False)
|
||||||
# android.private_storage = True
|
# android.private_storage = True
|
||||||
|
@ -124,9 +132,6 @@ android.permissions = INTERNET
|
||||||
# (list) Pattern to whitelist for the whole project
|
# (list) Pattern to whitelist for the whole project
|
||||||
#android.whitelist =
|
#android.whitelist =
|
||||||
|
|
||||||
android.whitelist = /usr/lib/komodo-edit/python/lib/python2.7/lib-dynload/_sqlite3.so
|
|
||||||
|
|
||||||
|
|
||||||
# (str) Path to a custom whitelist file
|
# (str) Path to a custom whitelist file
|
||||||
#android.whitelist_src =
|
#android.whitelist_src =
|
||||||
|
|
||||||
|
@ -150,9 +155,12 @@ android.whitelist = /usr/lib/komodo-edit/python/lib/python2.7/lib-dynload/_sqlit
|
||||||
# (list) Gradle dependencies to add (currently works only with sdl2_gradle
|
# (list) Gradle dependencies to add (currently works only with sdl2_gradle
|
||||||
# bootstrap)
|
# bootstrap)
|
||||||
#android.gradle_dependencies =
|
#android.gradle_dependencies =
|
||||||
, /home/cis/Downloads/libssl1.0.2_1.0.2l-2+deb9u2_amd64
|
|
||||||
|
# (list) Java classes to add as activities to the manifest.
|
||||||
|
#android.add_activites = com.example.ExampleActivity
|
||||||
|
|
||||||
# (str) python-for-android branch to use, defaults to stable
|
# (str) python-for-android branch to use, defaults to stable
|
||||||
#p4a.branch = stable
|
p4a.branch = master
|
||||||
|
|
||||||
# (str) OUYA Console category. Should be one of GAME or APP
|
# (str) OUYA Console category. Should be one of GAME or APP
|
||||||
# If you leave this blank, OUYA support will not be enabled
|
# If you leave this blank, OUYA support will not be enabled
|
||||||
|
@ -164,7 +172,10 @@ android.whitelist = /usr/lib/komodo-edit/python/lib/python2.7/lib-dynload/_sqlit
|
||||||
# (str) XML file to include as an intent filters in <activity> tag
|
# (str) XML file to include as an intent filters in <activity> tag
|
||||||
#android.manifest.intent_filters =
|
#android.manifest.intent_filters =
|
||||||
|
|
||||||
# (list) Android additionnal libraries to copy into libs/armeabi
|
# (str) launchMode to set for the main activity
|
||||||
|
#android.manifest.launch_mode = standard
|
||||||
|
|
||||||
|
# (list) Android additional libraries to copy into libs/armeabi
|
||||||
#android.add_libs_armeabi = libs/android/*.so
|
#android.add_libs_armeabi = libs/android/*.so
|
||||||
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
|
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
|
||||||
#android.add_libs_x86 = libs/android-x86/*.so
|
#android.add_libs_x86 = libs/android-x86/*.so
|
||||||
|
@ -198,7 +209,7 @@ android.arch = armeabi-v7a
|
||||||
#p4a.source_dir =
|
#p4a.source_dir =
|
||||||
|
|
||||||
# (str) The directory in which python-for-android should look for your own build recipes (if any)
|
# (str) The directory in which python-for-android should look for your own build recipes (if any)
|
||||||
#p4a.local_recipes =
|
p4a.local_recipes = /home/cis/navjotrepo/PyBitmessage/src/bitmessagekivy/android/python-for-android/recipes/
|
||||||
|
|
||||||
# (str) Filename to the hook for p4a
|
# (str) Filename to the hook for p4a
|
||||||
#p4a.hook =
|
#p4a.hook =
|
||||||
|
@ -206,6 +217,9 @@ android.arch = armeabi-v7a
|
||||||
# (str) Bootstrap to use for android builds
|
# (str) Bootstrap to use for android builds
|
||||||
# p4a.bootstrap = sdl2
|
# p4a.bootstrap = sdl2
|
||||||
|
|
||||||
|
# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
|
||||||
|
#p4a.port =
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# iOS specific
|
# iOS specific
|
||||||
|
|
|
@ -6,7 +6,6 @@ import hashlib
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from pyelliptic import arithmetic
|
from pyelliptic import arithmetic
|
||||||
from pyelliptic.openssl import OpenSSL
|
from pyelliptic.openssl import OpenSSL
|
||||||
|
|
||||||
import tr
|
import tr
|
||||||
import queues
|
import queues
|
||||||
import state
|
import state
|
||||||
|
@ -118,9 +117,7 @@ class addressGenerator(StoppableThread):
|
||||||
defaults.networkDefaultPayloadLengthExtraBytes
|
defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
if command == 'createRandomAddress':
|
if command == 'createRandomAddress':
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateStatusBar',
|
'updateStatusBar'
|
||||||
tr._translate(
|
|
||||||
"MainWindow", "Generating one new address")
|
|
||||||
))
|
))
|
||||||
# This next section is a little bit strange. We're going
|
# This next section is a little bit strange. We're going
|
||||||
# to generate keys over and over until we find one
|
# to generate keys over and over until we find one
|
||||||
|
@ -177,7 +174,6 @@ class addressGenerator(StoppableThread):
|
||||||
privEncryptionKey).digest()).digest()[0:4]
|
privEncryptionKey).digest()).digest()[0:4]
|
||||||
privEncryptionKeyWIF = arithmetic.changebase(
|
privEncryptionKeyWIF = arithmetic.changebase(
|
||||||
privEncryptionKey + checksum, 256, 58)
|
privEncryptionKey + checksum, 256, 58)
|
||||||
|
|
||||||
BMConfigParser().add_section(address)
|
BMConfigParser().add_section(address)
|
||||||
BMConfigParser().set(address, 'label', label)
|
BMConfigParser().set(address, 'label', label)
|
||||||
BMConfigParser().set(address, 'enabled', 'true')
|
BMConfigParser().set(address, 'enabled', 'true')
|
||||||
|
@ -197,11 +193,7 @@ class addressGenerator(StoppableThread):
|
||||||
queues.apiAddressGeneratorReturnQueue.put(address)
|
queues.apiAddressGeneratorReturnQueue.put(address)
|
||||||
|
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateStatusBar',
|
'updateStatusBar'
|
||||||
tr._translate(
|
|
||||||
"MainWindow",
|
|
||||||
"Done generating address. Doing work necessary"
|
|
||||||
" to broadcast it...")
|
|
||||||
))
|
))
|
||||||
queues.UISignalQueue.put(('writeNewAddressToTable', (
|
queues.UISignalQueue.put(('writeNewAddressToTable', (
|
||||||
label, address, streamNumber)))
|
label, address, streamNumber)))
|
||||||
|
|
|
@ -18,14 +18,15 @@ It resends messages when there has been no response:
|
||||||
- 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
|
||||||
|
from datetime import datetime, timedelta
|
||||||
import time
|
import time
|
||||||
|
import shared
|
||||||
|
|
||||||
import knownnodes
|
import knownnodes
|
||||||
import queues
|
import queues
|
||||||
import shared
|
|
||||||
import state
|
import state
|
||||||
import tr
|
import tr
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
|
@ -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 < \
|
||||||
|
@ -110,7 +111,7 @@ class singleCleaner(StoppableThread):
|
||||||
self.resendPubkeyRequest(toAddress)
|
self.resendPubkeyRequest(toAddress)
|
||||||
elif status == 'msgsent':
|
elif status == 'msgsent':
|
||||||
self.resendMsg(ackData)
|
self.resendMsg(ackData)
|
||||||
|
deleteTrashMsgPermonantly()
|
||||||
try:
|
try:
|
||||||
# Cleanup knownnodes and handle possible severe exception
|
# Cleanup knownnodes and handle possible severe exception
|
||||||
# while writing it to disk
|
# while writing it to disk
|
||||||
|
@ -146,6 +147,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()
|
||||||
|
@ -191,3 +193,12 @@ class singleCleaner(StoppableThread):
|
||||||
'updateStatusBar',
|
'updateStatusBar',
|
||||||
'Doing work necessary to again attempt to deliver a message...'
|
'Doing work necessary to again attempt to deliver a message...'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
def deleteTrashMsgPermonantly():
|
||||||
|
"""This method is used to delete old messages"""
|
||||||
|
ndays_before_time = datetime.now() - timedelta(days=30)
|
||||||
|
old_messages = time.mktime(ndays_before_time.timetuple())
|
||||||
|
sqlExecute("delete from sent where folder = 'trash' and lastactiontime <= ?;", int(old_messages))
|
||||||
|
sqlExecute("delete from inbox where folder = 'trash' and received <= ?;", int(old_messages))
|
||||||
|
return
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""
|
"""
|
||||||
Thread for performing PoW
|
Thread for performing PoW
|
||||||
"""
|
"""
|
||||||
# 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
|
||||||
|
@ -29,6 +29,9 @@ from helper_sql import sqlExecute, sqlQuery
|
||||||
from inventory import Inventory
|
from inventory import Inventory
|
||||||
from network import StoppableThread
|
from network import StoppableThread
|
||||||
|
|
||||||
|
# This thread, of which there is only one, does the heavy lifting:
|
||||||
|
# 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)"""
|
||||||
|
@ -67,7 +70,7 @@ class singleWorker(StoppableThread):
|
||||||
# Initialize the neededPubkeys dictionary.
|
# Initialize the neededPubkeys dictionary.
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''SELECT DISTINCT toaddress FROM sent'''
|
'''SELECT DISTINCT toaddress FROM sent'''
|
||||||
''' WHERE (status='awaitingpubkey' AND folder='sent')''')
|
''' WHERE (status='awaitingpubkey' AND folder LIKE '%sent%')''')
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
toAddress, = row
|
toAddress, = row
|
||||||
# toStatus
|
# toStatus
|
||||||
|
@ -476,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)
|
||||||
|
|
||||||
|
@ -512,7 +515,7 @@ class singleWorker(StoppableThread):
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''SELECT fromaddress, subject, message, '''
|
'''SELECT fromaddress, subject, message, '''
|
||||||
''' ackdata, ttl, encodingtype FROM sent '''
|
''' ackdata, ttl, encodingtype FROM sent '''
|
||||||
''' WHERE status=? and folder='sent' ''', 'broadcastqueued')
|
''' WHERE status=? and folder LIKE '%sent%' ''', 'broadcastqueued')
|
||||||
|
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
fromaddress, subject, body, ackdata, TTL, encoding = row
|
fromaddress, subject, body, ackdata, TTL, encoding = row
|
||||||
|
@ -682,7 +685,7 @@ class singleWorker(StoppableThread):
|
||||||
'''SELECT toaddress, fromaddress, subject, message, '''
|
'''SELECT toaddress, fromaddress, subject, message, '''
|
||||||
''' ackdata, status, ttl, retrynumber, encodingtype FROM '''
|
''' ackdata, status, ttl, retrynumber, encodingtype FROM '''
|
||||||
''' sent WHERE (status='msgqueued' or status='forcepow') '''
|
''' sent WHERE (status='msgqueued' or status='forcepow') '''
|
||||||
''' and folder='sent' ''')
|
''' and folder LIKE '%sent%' ''')
|
||||||
# while we have a msg that needs some work
|
# while we have a msg that needs some work
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
toaddress, fromaddress, subject, message, \
|
toaddress, fromaddress, subject, message, \
|
||||||
|
@ -1212,6 +1215,7 @@ class singleWorker(StoppableThread):
|
||||||
powStartTime = time.time()
|
powStartTime = time.time()
|
||||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||||
|
print("nonce calculated value#############################", nonce)
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'(For msg message) Found proof of work %s Nonce: %s',
|
'(For msg message) Found proof of work %s Nonce: %s',
|
||||||
trialValue, nonce
|
trialValue, nonce
|
||||||
|
|
BIN
src/dave.png
Normal file
After Width: | Height: | Size: 650 B |
|
@ -45,7 +45,6 @@ import helper_startup
|
||||||
import state
|
import state
|
||||||
|
|
||||||
helper_startup.loadConfig()
|
helper_startup.loadConfig()
|
||||||
|
|
||||||
# Now can be overriden from a config file, which uses standard python
|
# Now can be overriden from a config file, which uses standard python
|
||||||
# logging.config.fileConfig interface
|
# logging.config.fileConfig interface
|
||||||
# examples are here:
|
# examples are here:
|
||||||
|
|
|
@ -17,7 +17,7 @@ if not hasattr(sys, 'hexversion') or sys.hexversion < 0x20300F0:
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
import state
|
||||||
# We can now use logging so set up a simple configuration
|
# We can now use logging so set up a simple configuration
|
||||||
formatter = logging.Formatter('%(levelname)s: %(message)s')
|
formatter = logging.Formatter('%(levelname)s: %(message)s')
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
|
@ -249,8 +249,11 @@ def check_openssl(): # pylint: disable=too-many-branches, too-many-return-sta
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
import os.path
|
import os.path
|
||||||
paths.insert(0, os.path.join(sys._MEIPASS, 'libeay32.dll'))
|
paths.insert(0, os.path.join(sys._MEIPASS, 'libeay32.dll'))
|
||||||
|
elif state.kivy:
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
paths = ['libcrypto.so', 'libcrypto.so.1.0.0']
|
paths = ['libcrypto.so', 'libcrypto.so.1.0.0']
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
paths.extend([
|
paths.extend([
|
||||||
'libcrypto.dylib',
|
'libcrypto.dylib',
|
||||||
|
@ -426,7 +429,6 @@ def check_dependencies(verbose=False, optional=False):
|
||||||
check_functions = [check_ripemd160, check_sqlite, check_openssl]
|
check_functions = [check_ripemd160, check_sqlite, check_openssl]
|
||||||
if optional:
|
if optional:
|
||||||
check_functions.extend([check_msgpack, check_pyqt, check_curses])
|
check_functions.extend([check_msgpack, check_pyqt, check_curses])
|
||||||
|
|
||||||
# Unexpected exceptions are handled here
|
# Unexpected exceptions are handled here
|
||||||
for check in check_functions:
|
for check in check_functions:
|
||||||
try:
|
try:
|
||||||
|
|
BIN
src/eve.png
Normal file
After Width: | Height: | Size: 651 B |
114
src/helper_generic.py
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
"""
|
||||||
|
Helper Generic perform generic operations for threading.
|
||||||
|
|
||||||
|
Also perform some conversion operations.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import traceback
|
||||||
|
try:
|
||||||
|
import multiprocessing
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
from binascii import hexlify, unhexlify
|
||||||
|
|
||||||
|
import shared
|
||||||
|
import state
|
||||||
|
import queues
|
||||||
|
import shutdown
|
||||||
|
from debug import logger
|
||||||
|
|
||||||
|
|
||||||
|
def powQueueSize():
|
||||||
|
curWorkerQueue = queues.workerQueue.qsize()
|
||||||
|
for thread in threading.enumerate():
|
||||||
|
try:
|
||||||
|
if thread.name == "singleWorker":
|
||||||
|
curWorkerQueue += thread.busy
|
||||||
|
except Exception as err:
|
||||||
|
logger.info('Thread error %s', err)
|
||||||
|
return curWorkerQueue
|
||||||
|
|
||||||
|
|
||||||
|
def convertIntToString(n):
|
||||||
|
a = __builtins__.hex(n)
|
||||||
|
if a[-1:] == 'L':
|
||||||
|
a = a[:-1]
|
||||||
|
if (len(a) % 2) == 0:
|
||||||
|
return unhexlify(a[2:])
|
||||||
|
else:
|
||||||
|
return unhexlify('0' + a[2:])
|
||||||
|
|
||||||
|
|
||||||
|
def convertStringToInt(s):
|
||||||
|
return int(hexlify(s), 16)
|
||||||
|
|
||||||
|
|
||||||
|
def allThreadTraceback(frame):
|
||||||
|
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
|
||||||
|
code = []
|
||||||
|
for threadId, stack in sys._current_frames().items():
|
||||||
|
code.append(
|
||||||
|
'\n# Thread: %s(%d)' % (id2name.get(threadId, ''), threadId))
|
||||||
|
for filename, lineno, name, line in traceback.extract_stack(stack):
|
||||||
|
code.append(
|
||||||
|
'File: "%s", line %d, in %s' % (filename, lineno, name))
|
||||||
|
if line:
|
||||||
|
code.append(' %s' % (line.strip()))
|
||||||
|
print('\n'.join(code))
|
||||||
|
|
||||||
|
|
||||||
|
def signal_handler(signal, frame):
|
||||||
|
try:
|
||||||
|
process = multiprocessing.current_process()
|
||||||
|
except Exception as e:
|
||||||
|
process = threading.current_thread()
|
||||||
|
logger.error(
|
||||||
|
'Got signal %i in %s/%s',
|
||||||
|
signal, process.name, threading.current_thread().name
|
||||||
|
)
|
||||||
|
if process.name == "RegExParser":
|
||||||
|
# on Windows this isn't triggered, but it's fine,
|
||||||
|
# it has its own process termination thing
|
||||||
|
raise SystemExit
|
||||||
|
if "PoolWorker" in process.name:
|
||||||
|
raise SystemExit
|
||||||
|
if threading.current_thread().name not in ("PyBitmessage", "MainThread"):
|
||||||
|
return
|
||||||
|
logger.error("Got signal %i", signal)
|
||||||
|
if shared.thisapp.daemon or not state.enableGUI: # FIXME redundant?
|
||||||
|
shutdown.doCleanShutdown()
|
||||||
|
else:
|
||||||
|
allThreadTraceback(frame)
|
||||||
|
print('Unfortunately you cannot use Ctrl+C when running the UI'
|
||||||
|
' because the UI captures the signal.')
|
||||||
|
|
||||||
|
|
||||||
|
def isHostInPrivateIPRange(host):
|
||||||
|
if ":" in host: # IPv6
|
||||||
|
hostAddr = socket.inet_pton(socket.AF_INET6, host)
|
||||||
|
if hostAddr == ('\x00' * 15) + '\x01':
|
||||||
|
return False
|
||||||
|
if hostAddr[0] == '\xFE' and (ord(hostAddr[1]) & 0xc0) == 0x80:
|
||||||
|
return False
|
||||||
|
if (ord(hostAddr[0]) & 0xfe) == 0xfc:
|
||||||
|
return False
|
||||||
|
elif ".onion" not in host:
|
||||||
|
if host[:3] == '10.':
|
||||||
|
return True
|
||||||
|
if host[:4] == '172.':
|
||||||
|
if host[6] == '.':
|
||||||
|
if int(host[4:6]) >= 16 and int(host[4:6]) <= 31:
|
||||||
|
return True
|
||||||
|
if host[:8] == '192.168.':
|
||||||
|
return True
|
||||||
|
# Multicast
|
||||||
|
if host[:3] >= 224 and host[:3] <= 239 and host[4] == '.':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def addDataPadding(data, desiredMsgLength=12, paddingChar='\x00'):
|
||||||
|
return data + paddingChar * (desiredMsgLength - len(data))
|
|
@ -32,6 +32,7 @@ StoreConfigFilesInSameDirectoryAsProgramByDefault = False
|
||||||
def loadConfig():
|
def loadConfig():
|
||||||
"""Load the config"""
|
"""Load the config"""
|
||||||
config = BMConfigParser()
|
config = BMConfigParser()
|
||||||
|
|
||||||
if state.appdata:
|
if state.appdata:
|
||||||
config.read(state.appdata + 'keys.dat')
|
config.read(state.appdata + 'keys.dat')
|
||||||
# state.appdata must have been specified as a startup option.
|
# state.appdata must have been specified as a startup option.
|
||||||
|
|
BIN
src/image.svg
Normal file
After Width: | Height: | Size: 704 B |
BIN
src/images/3.zip
Normal file
BIN
src/images/account_multiple.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/images/addressbookadd.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/images/avatar.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
src/images/back-button.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
src/images/black_cross.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
src/images/copy_text.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
src/images/down-arrow.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
src/images/drawer_logo1.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src/images/left_arrow.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
src/images/loader.gif
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/images/loader.zip
Normal file
BIN
src/images/red.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
src/images/right-arrow.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/images/search.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/images/search_mail.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/images/text_images/!.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/images/text_images/0.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/images/text_images/1.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/images/text_images/2.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
src/images/text_images/3.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/images/text_images/4.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
src/images/text_images/5.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
src/images/text_images/6.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
src/images/text_images/7.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
src/images/text_images/8.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/images/text_images/9.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/images/text_images/A.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
src/images/text_images/B.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/images/text_images/C.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
src/images/text_images/D.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
src/images/text_images/E.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/images/text_images/F.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/images/text_images/G.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
src/images/text_images/H.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/images/text_images/I.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/images/text_images/J.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
src/images/text_images/K.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/images/text_images/L.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
src/images/text_images/M.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/images/text_images/N.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/images/text_images/O.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
src/images/text_images/P.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
src/images/text_images/Q.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
src/images/text_images/R.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
src/images/text_images/S.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/images/text_images/T.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/images/text_images/U.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
src/images/text_images/V.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/images/text_images/W.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/images/text_images/X.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
src/images/text_images/Y.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
src/images/text_images/Z.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
src/images/transparent.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/images/white.png
Normal file
After Width: | Height: | Size: 80 KiB |
|
@ -1,21 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2015 Andrés Rodríguez and KivyMD contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
|
@ -1,6 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os
|
|
||||||
|
|
||||||
path = os.path.dirname(__file__)
|
|
||||||
fonts_path = os.path.join(path, "fonts/")
|
|
||||||
images_path = os.path.join(path, 'images/')
|
|
|
@ -1,254 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.properties import StringProperty, ListProperty, OptionProperty
|
|
||||||
from kivy.utils import get_color_from_hex
|
|
||||||
from kivymd.color_definitions import colors
|
|
||||||
from kivymd.theming import ThemableBehavior
|
|
||||||
from kivy.uix.accordion import Accordion, AccordionItem
|
|
||||||
from kivymd.backgroundcolorbehavior import BackgroundColorBehavior
|
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
|
||||||
|
|
||||||
|
|
||||||
class MDAccordionItemTitleLayout(ThemableBehavior, BackgroundColorBehavior, BoxLayout):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MDAccordion(ThemableBehavior, BackgroundColorBehavior, Accordion):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MDAccordionItem(ThemableBehavior, AccordionItem):
|
|
||||||
title_theme_color = OptionProperty(None, allownone=True,
|
|
||||||
options=['Primary', 'Secondary', 'Hint',
|
|
||||||
'Error', 'Custom'])
|
|
||||||
''' Color theme for title text and icon '''
|
|
||||||
|
|
||||||
title_color = ListProperty(None, allownone=True)
|
|
||||||
''' Color for title text and icon if `title_theme_color` is Custom '''
|
|
||||||
|
|
||||||
background_color = ListProperty(None, allownone=True)
|
|
||||||
''' Color for the background of the accordian item title in rgba format.
|
|
||||||
'''
|
|
||||||
|
|
||||||
divider_color = ListProperty(None, allownone=True)
|
|
||||||
''' Color for dividers between different titles in rgba format
|
|
||||||
To remove the divider set a color with an alpha of 0.
|
|
||||||
'''
|
|
||||||
|
|
||||||
indicator_color = ListProperty(None, allownone=True)
|
|
||||||
''' Color for the indicator on the side of the active item in rgba format
|
|
||||||
To remove the indicator set a color with an alpha of 0.
|
|
||||||
'''
|
|
||||||
|
|
||||||
font_style = OptionProperty(
|
|
||||||
'Subhead', options=['Body1', 'Body2', 'Caption', 'Subhead', 'Title',
|
|
||||||
'Headline', 'Display1', 'Display2', 'Display3',
|
|
||||||
'Display4', 'Button', 'Icon'])
|
|
||||||
''' Font style to use for the title text '''
|
|
||||||
|
|
||||||
title_template = StringProperty('MDAccordionItemTitle')
|
|
||||||
''' Template to use for the title '''
|
|
||||||
|
|
||||||
icon = StringProperty(None,allownone=True)
|
|
||||||
''' Icon name to use when this item is expanded '''
|
|
||||||
|
|
||||||
icon_expanded = StringProperty('chevron-up')
|
|
||||||
''' Icon name to use when this item is expanded '''
|
|
||||||
|
|
||||||
icon_collapsed = StringProperty('chevron-down')
|
|
||||||
''' Icon name to use when this item is collapsed '''
|
|
||||||
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
#:import MDLabel kivymd.label.MDLabel
|
|
||||||
#:import md_icons kivymd.icon_definitions.md_icons
|
|
||||||
|
|
||||||
|
|
||||||
<MDAccordionItem>:
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
rgba: self.background_color or self.theme_cls.primary_color
|
|
||||||
Rectangle:
|
|
||||||
size:self.size
|
|
||||||
pos:self.pos
|
|
||||||
|
|
||||||
PushMatrix
|
|
||||||
Translate:
|
|
||||||
xy: (dp(2),0) if self.orientation == 'vertical' else (0,dp(2))
|
|
||||||
canvas.after:
|
|
||||||
PopMatrix
|
|
||||||
Color:
|
|
||||||
rgba: self.divider_color or self.theme_cls.divider_color
|
|
||||||
Rectangle:
|
|
||||||
size:(dp(1),self.height) if self.orientation == 'horizontal' else (self.width,dp(1))
|
|
||||||
pos:self.pos
|
|
||||||
Color:
|
|
||||||
rgba: [0,0,0,0] if self.collapse else (self.indicator_color or self.theme_cls.accent_color)
|
|
||||||
Rectangle:
|
|
||||||
size:(dp(2),self.height) if self.orientation == 'vertical' else (self.width,dp(2))
|
|
||||||
pos:self.pos
|
|
||||||
|
|
||||||
[MDAccordionItemTitle@MDAccordionItemTitleLayout]:
|
|
||||||
padding: '12dp'
|
|
||||||
spacing: '12dp'
|
|
||||||
orientation: 'horizontal' if ctx.item.orientation=='vertical' else 'vertical'
|
|
||||||
canvas:
|
|
||||||
PushMatrix
|
|
||||||
Translate:
|
|
||||||
xy: (-dp(2),0) if ctx.item.orientation == 'vertical' else (0,-dp(2))
|
|
||||||
|
|
||||||
Color:
|
|
||||||
rgba: self.background_color or self.theme_cls.primary_color
|
|
||||||
Rectangle:
|
|
||||||
size:self.size
|
|
||||||
pos:self.pos
|
|
||||||
|
|
||||||
canvas.after:
|
|
||||||
Color:
|
|
||||||
rgba: [0,0,0,0] if ctx.item.collapse else (ctx.item.indicator_color or self.theme_cls.accent_color)
|
|
||||||
Rectangle:
|
|
||||||
size:(dp(2),self.height) if ctx.item.orientation == 'vertical' else (self.width,dp(2))
|
|
||||||
pos:self.pos
|
|
||||||
PopMatrix
|
|
||||||
MDLabel:
|
|
||||||
id:_icon
|
|
||||||
theme_text_color:ctx.item.title_theme_color if ctx.item.icon else 'Custom'
|
|
||||||
text_color:ctx.item.title_color if ctx.item.icon else [0,0,0,0]
|
|
||||||
text: md_icons[ctx.item.icon if ctx.item.icon else 'menu']
|
|
||||||
font_style:'Icon'
|
|
||||||
size_hint: (None,1) if ctx.item.orientation == 'vertical' else (1,None)
|
|
||||||
size: ((self.texture_size[0],1) if ctx.item.orientation == 'vertical' else (1,self.texture_size[1])) \
|
|
||||||
if ctx.item.icon else (0,0)
|
|
||||||
text_size: (self.width, None) if ctx.item.orientation=='vertical' else (None,self.width)
|
|
||||||
canvas.before:
|
|
||||||
PushMatrix
|
|
||||||
Rotate:
|
|
||||||
angle: 90 if ctx.item.orientation == 'horizontal' else 0
|
|
||||||
origin: self.center
|
|
||||||
canvas.after:
|
|
||||||
PopMatrix
|
|
||||||
MDLabel:
|
|
||||||
id:_label
|
|
||||||
theme_text_color:ctx.item.title_theme_color
|
|
||||||
text_color:ctx.item.title_color
|
|
||||||
text: ctx.item.title
|
|
||||||
font_style:ctx.item.font_style
|
|
||||||
text_size: (self.width, None) if ctx.item.orientation=='vertical' else (None,self.width)
|
|
||||||
canvas.before:
|
|
||||||
PushMatrix
|
|
||||||
Rotate:
|
|
||||||
angle: 90 if ctx.item.orientation == 'horizontal' else 0
|
|
||||||
origin: self.center
|
|
||||||
canvas.after:
|
|
||||||
PopMatrix
|
|
||||||
|
|
||||||
MDLabel:
|
|
||||||
id:_expand_icon
|
|
||||||
theme_text_color:ctx.item.title_theme_color
|
|
||||||
text_color:ctx.item.title_color
|
|
||||||
font_style:'Icon'
|
|
||||||
size_hint: (None,1) if ctx.item.orientation == 'vertical' else (1,None)
|
|
||||||
size: (self.texture_size[0],1) if ctx.item.orientation == 'vertical' else (1,self.texture_size[1])
|
|
||||||
text:md_icons[ctx.item.icon_collapsed if ctx.item.collapse else ctx.item.icon_expanded]
|
|
||||||
halign: 'right' if ctx.item.orientation=='vertical' else 'center'
|
|
||||||
#valign: 'middle' if ctx.item.orientation=='vertical' else 'bottom'
|
|
||||||
canvas.before:
|
|
||||||
PushMatrix
|
|
||||||
Rotate:
|
|
||||||
angle: 90 if ctx.item.orientation == 'horizontal' else 0
|
|
||||||
origin:self.center
|
|
||||||
canvas.after:
|
|
||||||
PopMatrix
|
|
||||||
|
|
||||||
''')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
from kivy.app import App
|
|
||||||
from kivymd.theming import ThemeManager
|
|
||||||
|
|
||||||
class AccordionApp(App):
|
|
||||||
theme_cls = ThemeManager()
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
# self.theme_cls.primary_palette = 'Indigo'
|
|
||||||
return Builder.load_string("""
|
|
||||||
#:import MDLabel kivymd.label.MDLabel
|
|
||||||
#:import MDList kivymd.list.MDList
|
|
||||||
#:import OneLineListItem kivymd.list.OneLineListItem
|
|
||||||
BoxLayout:
|
|
||||||
spacing: '64dp'
|
|
||||||
MDAccordion:
|
|
||||||
orientation:'vertical'
|
|
||||||
MDAccordionItem:
|
|
||||||
title:'Item 1'
|
|
||||||
icon: 'home'
|
|
||||||
ScrollView:
|
|
||||||
MDList:
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 1"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 2"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 3"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
MDAccordionItem:
|
|
||||||
title:'Item 2'
|
|
||||||
icon: 'globe'
|
|
||||||
ScrollView:
|
|
||||||
MDList:
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 4"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 5"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 6"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
MDAccordionItem:
|
|
||||||
title:'Item 3'
|
|
||||||
ScrollView:
|
|
||||||
MDList:
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 7"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 8"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
OneLineListItem:
|
|
||||||
text: "Subitem 9"
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: [1,1,1,1]
|
|
||||||
MDAccordion:
|
|
||||||
orientation:'horizontal'
|
|
||||||
MDAccordionItem:
|
|
||||||
title:'Item 1'
|
|
||||||
icon: 'home'
|
|
||||||
MDLabel:
|
|
||||||
text:'Content 1'
|
|
||||||
theme_text_color:'Primary'
|
|
||||||
MDAccordionItem:
|
|
||||||
title:'Item 2'
|
|
||||||
MDLabel:
|
|
||||||
text:'Content 2'
|
|
||||||
theme_text_color:'Primary'
|
|
||||||
MDAccordionItem:
|
|
||||||
title:'Item 3'
|
|
||||||
MDLabel:
|
|
||||||
text:'Content 3'
|
|
||||||
theme_text_color:'Primary'
|
|
||||||
""")
|
|
||||||
|
|
||||||
|
|
||||||
AccordionApp().run()
|
|
|
@ -1,23 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.properties import BoundedNumericProperty, ReferenceListProperty
|
|
||||||
from kivy.uix.widget import Widget
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
<BackgroundColorBehavior>
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
rgba: self.background_color
|
|
||||||
Rectangle:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class BackgroundColorBehavior(Widget):
|
|
||||||
r = BoundedNumericProperty(1., min=0., max=1.)
|
|
||||||
g = BoundedNumericProperty(1., min=0., max=1.)
|
|
||||||
b = BoundedNumericProperty(1., min=0., max=1.)
|
|
||||||
a = BoundedNumericProperty(0., min=0., max=1.)
|
|
||||||
|
|
||||||
background_color = ReferenceListProperty(r, g, b, a)
|
|
|
@ -1,211 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
'''
|
|
||||||
Bottom Sheets
|
|
||||||
=============
|
|
||||||
|
|
||||||
`Material Design spec Bottom Sheets page <http://www.google.com/design/spec/components/bottom-sheets.html>`_
|
|
||||||
|
|
||||||
In this module there's the :class:`MDBottomSheet` class which will let you implement your own Material Design Bottom Sheets, and there are two classes called :class:`MDListBottomSheet` and :class:`MDGridBottomSheet` implementing the ones mentioned in the spec.
|
|
||||||
|
|
||||||
Examples
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
These widgets are designed to be called from Python code only.
|
|
||||||
|
|
||||||
For :class:`MDListBottomSheet`:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
bs = MDListBottomSheet()
|
|
||||||
bs.add_item("Here's an item with text only", lambda x: x)
|
|
||||||
bs.add_item("Here's an item with an icon", lambda x: x, icon='md-cast')
|
|
||||||
bs.add_item("Here's another!", lambda x: x, icon='md-nfc')
|
|
||||||
bs.open()
|
|
||||||
|
|
||||||
For :class:`MDListBottomSheet`:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
bs = MDGridBottomSheet()
|
|
||||||
bs.add_item("Facebook", lambda x: x, icon_src='./assets/facebook-box.png')
|
|
||||||
bs.add_item("YouTube", lambda x: x, icon_src='./assets/youtube-play.png')
|
|
||||||
bs.add_item("Twitter", lambda x: x, icon_src='./assets/twitter.png')
|
|
||||||
bs.add_item("Da Cloud", lambda x: x, icon_src='./assets/cloud-upload.png')
|
|
||||||
bs.add_item("Camera", lambda x: x, icon_src='./assets/camera.png')
|
|
||||||
bs.open()
|
|
||||||
|
|
||||||
API
|
|
||||||
---
|
|
||||||
'''
|
|
||||||
from kivy.clock import Clock
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.metrics import dp
|
|
||||||
from kivy.properties import ObjectProperty, StringProperty
|
|
||||||
from kivy.uix.behaviors import ButtonBehavior
|
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
|
||||||
from kivy.uix.gridlayout import GridLayout
|
|
||||||
from kivy.uix.modalview import ModalView
|
|
||||||
from kivy.uix.scrollview import ScrollView
|
|
||||||
from kivymd.backgroundcolorbehavior import BackgroundColorBehavior
|
|
||||||
from kivymd.label import MDLabel
|
|
||||||
from kivymd.list import MDList, OneLineListItem, ILeftBody, \
|
|
||||||
OneLineIconListItem
|
|
||||||
from kivymd.theming import ThemableBehavior
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
<MDBottomSheet>
|
|
||||||
background: 'atlas://data/images/defaulttheme/action_group_disabled'
|
|
||||||
background_color: 0,0,0,.8
|
|
||||||
sv: sv
|
|
||||||
upper_padding: upper_padding
|
|
||||||
gl_content: gl_content
|
|
||||||
ScrollView:
|
|
||||||
id: sv
|
|
||||||
do_scroll_x: False
|
|
||||||
BoxLayout:
|
|
||||||
size_hint_y: None
|
|
||||||
orientation: 'vertical'
|
|
||||||
padding: 0,1,0,0
|
|
||||||
height: upper_padding.height + gl_content.height + 1 # +1 to allow overscroll
|
|
||||||
BsPadding:
|
|
||||||
id: upper_padding
|
|
||||||
size_hint_y: None
|
|
||||||
height: root.height - min(root.width * 9 / 16, gl_content.height)
|
|
||||||
on_release: root.dismiss()
|
|
||||||
BottomSheetContent:
|
|
||||||
id: gl_content
|
|
||||||
size_hint_y: None
|
|
||||||
background_color: root.theme_cls.bg_normal
|
|
||||||
cols: 1
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class BsPadding(ButtonBehavior, FloatLayout):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class BottomSheetContent(BackgroundColorBehavior, GridLayout):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MDBottomSheet(ThemableBehavior, ModalView):
|
|
||||||
sv = ObjectProperty()
|
|
||||||
upper_padding = ObjectProperty()
|
|
||||||
gl_content = ObjectProperty()
|
|
||||||
dismiss_zone_scroll = 1000 # Arbitrary high number
|
|
||||||
|
|
||||||
def open(self, *largs):
|
|
||||||
super(MDBottomSheet, self).open(*largs)
|
|
||||||
Clock.schedule_once(self.set_dismiss_zone, 0)
|
|
||||||
|
|
||||||
def set_dismiss_zone(self, *largs):
|
|
||||||
# Scroll to right below overscroll threshold:
|
|
||||||
self.sv.scroll_y = 1 - self.sv.convert_distance_to_scroll(0, 1)[1]
|
|
||||||
|
|
||||||
# This is a line where m (slope) is 1/6 and b (y-intercept) is 80:
|
|
||||||
self.dismiss_zone_scroll = self.sv.convert_distance_to_scroll(
|
|
||||||
0, (self.height - self.upper_padding.height) * (1 / 6.0) + 80)[
|
|
||||||
1]
|
|
||||||
# Uncomment next line if the limit should just be half of
|
|
||||||
# visible content on open (capped by specs to 16 units to width/9:
|
|
||||||
# self.dismiss_zone_scroll = (self.sv.convert_distance_to_scroll(
|
|
||||||
# 0, self.height - self.upper_padding.height)[1] * 0.50)
|
|
||||||
|
|
||||||
# Check if user has overscrolled enough to dismiss bottom sheet:
|
|
||||||
self.sv.bind(on_scroll_stop=self.check_if_scrolled_to_death)
|
|
||||||
|
|
||||||
def check_if_scrolled_to_death(self, *largs):
|
|
||||||
if self.sv.scroll_y >= 1 + self.dismiss_zone_scroll:
|
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
def add_widget(self, widget, index=0):
|
|
||||||
if type(widget) == ScrollView:
|
|
||||||
super(MDBottomSheet, self).add_widget(widget, index)
|
|
||||||
else:
|
|
||||||
self.gl_content.add_widget(widget,index)
|
|
||||||
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
#:import md_icons kivymd.icon_definitions.md_icons
|
|
||||||
<ListBSIconLeft>
|
|
||||||
font_style: 'Icon'
|
|
||||||
text: u"{}".format(md_icons[root.icon])
|
|
||||||
halign: 'center'
|
|
||||||
theme_text_color: 'Primary'
|
|
||||||
valign: 'middle'
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class ListBSIconLeft(ILeftBody, MDLabel):
|
|
||||||
icon = StringProperty()
|
|
||||||
|
|
||||||
|
|
||||||
class MDListBottomSheet(MDBottomSheet):
|
|
||||||
mlist = ObjectProperty()
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(MDListBottomSheet, self).__init__(**kwargs)
|
|
||||||
self.mlist = MDList()
|
|
||||||
self.gl_content.add_widget(self.mlist)
|
|
||||||
Clock.schedule_once(self.resize_content_layout, 0)
|
|
||||||
|
|
||||||
def resize_content_layout(self, *largs):
|
|
||||||
self.gl_content.height = self.mlist.height
|
|
||||||
|
|
||||||
def add_item(self, text, callback, icon=None):
|
|
||||||
if icon:
|
|
||||||
item = OneLineIconListItem(text=text, on_release=callback)
|
|
||||||
item.add_widget(ListBSIconLeft(icon=icon))
|
|
||||||
else:
|
|
||||||
item = OneLineListItem(text=text, on_release=callback)
|
|
||||||
|
|
||||||
item.bind(on_release=lambda x: self.dismiss())
|
|
||||||
self.mlist.add_widget(item)
|
|
||||||
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
<GridBSItem>
|
|
||||||
orientation: 'vertical'
|
|
||||||
padding: 0, dp(24), 0, 0
|
|
||||||
size_hint_y: None
|
|
||||||
size: dp(64), dp(96)
|
|
||||||
BoxLayout:
|
|
||||||
padding: dp(8), 0, dp(8), dp(8)
|
|
||||||
size_hint_y: None
|
|
||||||
height: dp(48)
|
|
||||||
Image:
|
|
||||||
source: root.source
|
|
||||||
MDLabel:
|
|
||||||
font_style: 'Caption'
|
|
||||||
theme_text_color: 'Secondary'
|
|
||||||
text: root.caption
|
|
||||||
halign: 'center'
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class GridBSItem(ButtonBehavior, BoxLayout):
|
|
||||||
source = StringProperty()
|
|
||||||
|
|
||||||
caption = StringProperty()
|
|
||||||
|
|
||||||
|
|
||||||
class MDGridBottomSheet(MDBottomSheet):
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(MDGridBottomSheet, self).__init__(**kwargs)
|
|
||||||
self.gl_content.padding = (dp(16), 0, dp(16), dp(24))
|
|
||||||
self.gl_content.height = dp(24)
|
|
||||||
self.gl_content.cols = 3
|
|
||||||
|
|
||||||
def add_item(self, text, callback, icon_src):
|
|
||||||
item = GridBSItem(
|
|
||||||
caption=text,
|
|
||||||
on_release=callback,
|
|
||||||
source=icon_src
|
|
||||||
)
|
|
||||||
item.bind(on_release=lambda x: self.dismiss())
|
|
||||||
if len(self.gl_content.children) % 3 == 0:
|
|
||||||
self.gl_content.height += dp(96)
|
|
||||||
self.gl_content.add_widget(item)
|
|
|
@ -1,453 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
'''
|
|
||||||
Buttons
|
|
||||||
=======
|
|
||||||
|
|
||||||
`Material Design spec, Buttons page <https://www.google.com/design/spec/components/buttons.html>`_
|
|
||||||
|
|
||||||
`Material Design spec, Buttons: Floating Action Button page <https://www.google.com/design/spec/components/buttons-floating-action-button.html>`_
|
|
||||||
|
|
||||||
TO-DO: DOCUMENT MODULE
|
|
||||||
'''
|
|
||||||
from kivy.clock import Clock
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.metrics import dp
|
|
||||||
from kivy.utils import get_color_from_hex
|
|
||||||
from kivy.properties import StringProperty, BoundedNumericProperty, \
|
|
||||||
ListProperty, AliasProperty, BooleanProperty, NumericProperty, \
|
|
||||||
OptionProperty
|
|
||||||
from kivy.uix.anchorlayout import AnchorLayout
|
|
||||||
from kivy.uix.behaviors import ButtonBehavior
|
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
|
||||||
from kivy.animation import Animation
|
|
||||||
from kivymd.backgroundcolorbehavior import BackgroundColorBehavior
|
|
||||||
from kivymd.ripplebehavior import CircularRippleBehavior, \
|
|
||||||
RectangularRippleBehavior
|
|
||||||
from kivymd.elevationbehavior import ElevationBehavior, \
|
|
||||||
RoundElevationBehavior
|
|
||||||
from kivymd.theming import ThemableBehavior
|
|
||||||
from kivymd.color_definitions import colors
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
#:import md_icons kivymd.icon_definitions.md_icons
|
|
||||||
#:import colors kivymd.color_definitions.colors
|
|
||||||
#:import MDLabel kivymd.label.MDLabel
|
|
||||||
<MDIconButton>
|
|
||||||
size_hint: (None, None)
|
|
||||||
size: (dp(48), dp(48))
|
|
||||||
padding: dp(12)
|
|
||||||
theme_text_color: 'Primary'
|
|
||||||
MDLabel:
|
|
||||||
id: _label
|
|
||||||
font_style: 'Icon'
|
|
||||||
text: u"{}".format(md_icons[root.icon])
|
|
||||||
halign: 'center'
|
|
||||||
theme_text_color: root.theme_text_color
|
|
||||||
text_color: root.text_color
|
|
||||||
opposite_colors: root.opposite_colors
|
|
||||||
valign: 'middle'
|
|
||||||
|
|
||||||
<MDFlatButton>
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
#rgba: self.background_color if self.state == 'normal' else self._bg_color_down
|
|
||||||
rgba: self._current_button_color
|
|
||||||
Rectangle:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
size_hint: (None, None)
|
|
||||||
height: dp(36)
|
|
||||||
width: _label.texture_size[0] + dp(16)
|
|
||||||
padding: (dp(8), 0)
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
text_color: root.theme_cls.primary_color
|
|
||||||
MDLabel:
|
|
||||||
id: _label
|
|
||||||
text: root._text
|
|
||||||
font_style: 'Button'
|
|
||||||
size_hint_x: None
|
|
||||||
text_size: (None, root.height)
|
|
||||||
height: self.texture_size[1]
|
|
||||||
theme_text_color: root.theme_text_color
|
|
||||||
text_color: root.text_color
|
|
||||||
valign: 'middle'
|
|
||||||
halign: 'center'
|
|
||||||
opposite_colors: root.opposite_colors
|
|
||||||
|
|
||||||
<MDRaisedButton>:
|
|
||||||
canvas:
|
|
||||||
Clear
|
|
||||||
Color:
|
|
||||||
rgba: self.background_color_disabled if self.disabled else \
|
|
||||||
(self.background_color if self.state == 'normal' else self.background_color_down)
|
|
||||||
Rectangle:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
|
|
||||||
anchor_x: 'center'
|
|
||||||
anchor_y: 'center'
|
|
||||||
background_color: root.theme_cls.primary_color
|
|
||||||
background_color_down: root.theme_cls.primary_dark
|
|
||||||
background_color_disabled: root.theme_cls.divider_color
|
|
||||||
theme_text_color: 'Primary'
|
|
||||||
MDLabel:
|
|
||||||
id: label
|
|
||||||
font_style: 'Button'
|
|
||||||
text: root._text
|
|
||||||
size_hint: None, None
|
|
||||||
width: root.width
|
|
||||||
text_size: self.width, None
|
|
||||||
height: self.texture_size[1]
|
|
||||||
theme_text_color: root.theme_text_color
|
|
||||||
text_color: root.text_color
|
|
||||||
opposite_colors: root.opposite_colors
|
|
||||||
disabled: root.disabled
|
|
||||||
halign: 'center'
|
|
||||||
valign: 'middle'
|
|
||||||
|
|
||||||
<MDFloatingActionButton>:
|
|
||||||
canvas:
|
|
||||||
Clear
|
|
||||||
Color:
|
|
||||||
rgba: self.background_color_disabled if self.disabled else \
|
|
||||||
(self.background_color if self.state == 'normal' else self.background_color_down)
|
|
||||||
Ellipse:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
|
|
||||||
anchor_x: 'center'
|
|
||||||
anchor_y: 'center'
|
|
||||||
background_color: root.theme_cls.accent_color
|
|
||||||
background_color_down: root.theme_cls.accent_dark
|
|
||||||
background_color_disabled: root.theme_cls.divider_color
|
|
||||||
theme_text_color: 'Primary'
|
|
||||||
MDLabel:
|
|
||||||
id: label
|
|
||||||
font_style: 'Icon'
|
|
||||||
text: u"{}".format(md_icons[root.icon])
|
|
||||||
size_hint: None, None
|
|
||||||
size: dp(24), dp(24)
|
|
||||||
text_size: self.size
|
|
||||||
theme_text_color: root.theme_text_color
|
|
||||||
text_color: root.text_color
|
|
||||||
opposite_colors: root.opposite_colors
|
|
||||||
disabled: root.disabled
|
|
||||||
halign: 'center'
|
|
||||||
valign: 'middle'
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class MDIconButton(CircularRippleBehavior, ButtonBehavior, BoxLayout):
|
|
||||||
icon = StringProperty('circle')
|
|
||||||
theme_text_color = OptionProperty(None, allownone=True,
|
|
||||||
options=['Primary', 'Secondary', 'Hint',
|
|
||||||
'Error', 'Custom'])
|
|
||||||
text_color = ListProperty(None, allownone=True)
|
|
||||||
opposite_colors = BooleanProperty(False)
|
|
||||||
|
|
||||||
|
|
||||||
class MDFlatButton(ThemableBehavior, RectangularRippleBehavior,
|
|
||||||
ButtonBehavior, BackgroundColorBehavior, AnchorLayout):
|
|
||||||
width = BoundedNumericProperty(dp(64), min=dp(64), max=None,
|
|
||||||
errorhandler=lambda x: dp(64))
|
|
||||||
|
|
||||||
text_color = ListProperty()
|
|
||||||
|
|
||||||
text = StringProperty('')
|
|
||||||
theme_text_color = OptionProperty(None, allownone=True,
|
|
||||||
options=['Primary', 'Secondary', 'Hint',
|
|
||||||
'Error', 'Custom'])
|
|
||||||
text_color = ListProperty(None, allownone=True)
|
|
||||||
|
|
||||||
_text = StringProperty('')
|
|
||||||
_bg_color_down = ListProperty([0, 0, 0, 0])
|
|
||||||
_current_button_color = ListProperty([0, 0, 0, 0])
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(MDFlatButton, self).__init__(**kwargs)
|
|
||||||
self._current_button_color = self.background_color
|
|
||||||
self._bg_color_down = get_color_from_hex(
|
|
||||||
colors[self.theme_cls.theme_style]['FlatButtonDown'])
|
|
||||||
|
|
||||||
Clock.schedule_once(lambda x: self.ids._label.bind(
|
|
||||||
texture_size=self.update_width_on_label_texture))
|
|
||||||
|
|
||||||
def update_width_on_label_texture(self, instance, value):
|
|
||||||
self.ids._label.width = value[0]
|
|
||||||
|
|
||||||
def on_text(self, instance, value):
|
|
||||||
self._text = value.upper()
|
|
||||||
|
|
||||||
def on_touch_down(self, touch):
|
|
||||||
if touch.is_mouse_scrolling:
|
|
||||||
return False
|
|
||||||
elif not self.collide_point(touch.x, touch.y):
|
|
||||||
return False
|
|
||||||
elif self in touch.ud:
|
|
||||||
return False
|
|
||||||
elif self.disabled:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
self.fade_bg = Animation(duration=.2, _current_button_color=get_color_from_hex(
|
|
||||||
colors[self.theme_cls.theme_style]['FlatButtonDown']))
|
|
||||||
self.fade_bg.start(self)
|
|
||||||
return super(MDFlatButton, self).on_touch_down(touch)
|
|
||||||
|
|
||||||
def on_touch_up(self, touch):
|
|
||||||
if touch.grab_current is self:
|
|
||||||
self.fade_bg.stop_property(self, '_current_button_color')
|
|
||||||
Animation(duration=.05, _current_button_color=self.background_color).start(self)
|
|
||||||
return super(MDFlatButton, self).on_touch_up(touch)
|
|
||||||
|
|
||||||
|
|
||||||
class MDRaisedButton(ThemableBehavior, RectangularRippleBehavior,
|
|
||||||
ElevationBehavior, ButtonBehavior,
|
|
||||||
AnchorLayout):
|
|
||||||
_bg_color_down = ListProperty([])
|
|
||||||
background_color = ListProperty()
|
|
||||||
background_color_down = ListProperty()
|
|
||||||
background_color_disabled = ListProperty()
|
|
||||||
theme_text_color = OptionProperty(None, allownone=True,
|
|
||||||
options=['Primary', 'Secondary', 'Hint',
|
|
||||||
'Error', 'Custom'])
|
|
||||||
text_color = ListProperty(None, allownone=True)
|
|
||||||
|
|
||||||
def _get_bg_color_down(self):
|
|
||||||
return self._bg_color_down
|
|
||||||
|
|
||||||
def _set_bg_color_down(self, color, alpha=None):
|
|
||||||
if len(color) == 2:
|
|
||||||
self._bg_color_down = get_color_from_hex(
|
|
||||||
colors[color[0]][color[1]])
|
|
||||||
if alpha:
|
|
||||||
self._bg_color_down[3] = alpha
|
|
||||||
elif len(color) == 4:
|
|
||||||
self._bg_color_down = color
|
|
||||||
|
|
||||||
background_color_down = AliasProperty(_get_bg_color_down,
|
|
||||||
_set_bg_color_down,
|
|
||||||
bind=('_bg_color_down',))
|
|
||||||
|
|
||||||
_bg_color_disabled = ListProperty([])
|
|
||||||
|
|
||||||
def _get_bg_color_disabled(self):
|
|
||||||
return self._bg_color_disabled
|
|
||||||
|
|
||||||
def _set_bg_color_disabled(self, color, alpha=None):
|
|
||||||
if len(color) == 2:
|
|
||||||
self._bg_color_disabled = get_color_from_hex(
|
|
||||||
colors[color[0]][color[1]])
|
|
||||||
if alpha:
|
|
||||||
self._bg_color_disabled[3] = alpha
|
|
||||||
elif len(color) == 4:
|
|
||||||
self._bg_color_disabled = color
|
|
||||||
|
|
||||||
background_color_disabled = AliasProperty(_get_bg_color_disabled,
|
|
||||||
_set_bg_color_disabled,
|
|
||||||
bind=('_bg_color_disabled',))
|
|
||||||
|
|
||||||
_elev_norm = NumericProperty(2)
|
|
||||||
|
|
||||||
def _get_elev_norm(self):
|
|
||||||
return self._elev_norm
|
|
||||||
|
|
||||||
def _set_elev_norm(self, value):
|
|
||||||
self._elev_norm = value if value <= 12 else 12
|
|
||||||
self._elev_raised = (value + 6) if value + 6 <= 12 else 12
|
|
||||||
self.elevation = self._elev_norm
|
|
||||||
|
|
||||||
elevation_normal = AliasProperty(_get_elev_norm, _set_elev_norm,
|
|
||||||
bind=('_elev_norm',))
|
|
||||||
|
|
||||||
_elev_raised = NumericProperty(8)
|
|
||||||
|
|
||||||
def _get_elev_raised(self):
|
|
||||||
return self._elev_raised
|
|
||||||
|
|
||||||
def _set_elev_raised(self, value):
|
|
||||||
self._elev_raised = value if value + self._elev_norm <= 12 else 12
|
|
||||||
|
|
||||||
elevation_raised = AliasProperty(_get_elev_raised, _set_elev_raised,
|
|
||||||
bind=('_elev_raised',))
|
|
||||||
|
|
||||||
text = StringProperty()
|
|
||||||
|
|
||||||
_text = StringProperty()
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(MDRaisedButton, self).__init__(**kwargs)
|
|
||||||
self.elevation_press_anim = Animation(elevation=self.elevation_raised,
|
|
||||||
duration=.2, t='out_quad')
|
|
||||||
self.elevation_release_anim = Animation(
|
|
||||||
elevation=self.elevation_normal, duration=.2, t='out_quad')
|
|
||||||
|
|
||||||
def on_disabled(self, instance, value):
|
|
||||||
if value:
|
|
||||||
self.elevation = 0
|
|
||||||
else:
|
|
||||||
self.elevation = self.elevation_normal
|
|
||||||
super(MDRaisedButton, self).on_disabled(instance, value)
|
|
||||||
|
|
||||||
def on_touch_down(self, touch):
|
|
||||||
if not self.disabled:
|
|
||||||
if touch.is_mouse_scrolling:
|
|
||||||
return False
|
|
||||||
if not self.collide_point(touch.x, touch.y):
|
|
||||||
return False
|
|
||||||
if self in touch.ud:
|
|
||||||
return False
|
|
||||||
Animation.cancel_all(self, 'elevation')
|
|
||||||
self.elevation_press_anim.start(self)
|
|
||||||
return super(MDRaisedButton, self).on_touch_down(touch)
|
|
||||||
|
|
||||||
def on_touch_up(self, touch):
|
|
||||||
if not self.disabled:
|
|
||||||
if touch.grab_current is not self:
|
|
||||||
return super(ButtonBehavior, self).on_touch_up(touch)
|
|
||||||
Animation.cancel_all(self, 'elevation')
|
|
||||||
self.elevation_release_anim.start(self)
|
|
||||||
else:
|
|
||||||
Animation.cancel_all(self, 'elevation')
|
|
||||||
self.elevation = 0
|
|
||||||
return super(MDRaisedButton, self).on_touch_up(touch)
|
|
||||||
|
|
||||||
def on_text(self, instance, text):
|
|
||||||
self._text = text.upper()
|
|
||||||
|
|
||||||
def on__elev_norm(self, instance, value):
|
|
||||||
self.elevation_release_anim = Animation(elevation=value,
|
|
||||||
duration=.2, t='out_quad')
|
|
||||||
|
|
||||||
def on__elev_raised(self, instance, value):
|
|
||||||
self.elevation_press_anim = Animation(elevation=value,
|
|
||||||
duration=.2, t='out_quad')
|
|
||||||
|
|
||||||
|
|
||||||
class MDFloatingActionButton(ThemableBehavior, CircularRippleBehavior,
|
|
||||||
RoundElevationBehavior, ButtonBehavior,
|
|
||||||
AnchorLayout):
|
|
||||||
_bg_color_down = ListProperty([])
|
|
||||||
background_color = ListProperty()
|
|
||||||
background_color_down = ListProperty()
|
|
||||||
background_color_disabled = ListProperty()
|
|
||||||
theme_text_color = OptionProperty(None, allownone=True,
|
|
||||||
options=['Primary', 'Secondary', 'Hint',
|
|
||||||
'Error', 'Custom'])
|
|
||||||
text_color = ListProperty(None, allownone=True)
|
|
||||||
|
|
||||||
def _get_bg_color_down(self):
|
|
||||||
return self._bg_color_down
|
|
||||||
|
|
||||||
def _set_bg_color_down(self, color, alpha=None):
|
|
||||||
if len(color) == 2:
|
|
||||||
self._bg_color_down = get_color_from_hex(
|
|
||||||
colors[color[0]][color[1]])
|
|
||||||
if alpha:
|
|
||||||
self._bg_color_down[3] = alpha
|
|
||||||
elif len(color) == 4:
|
|
||||||
self._bg_color_down = color
|
|
||||||
|
|
||||||
background_color_down = AliasProperty(_get_bg_color_down,
|
|
||||||
_set_bg_color_down,
|
|
||||||
bind=('_bg_color_down',))
|
|
||||||
|
|
||||||
_bg_color_disabled = ListProperty([])
|
|
||||||
|
|
||||||
def _get_bg_color_disabled(self):
|
|
||||||
return self._bg_color_disabled
|
|
||||||
|
|
||||||
def _set_bg_color_disabled(self, color, alpha=None):
|
|
||||||
if len(color) == 2:
|
|
||||||
self._bg_color_disabled = get_color_from_hex(
|
|
||||||
colors[color[0]][color[1]])
|
|
||||||
if alpha:
|
|
||||||
self._bg_color_disabled[3] = alpha
|
|
||||||
elif len(color) == 4:
|
|
||||||
self._bg_color_disabled = color
|
|
||||||
|
|
||||||
background_color_disabled = AliasProperty(_get_bg_color_disabled,
|
|
||||||
_set_bg_color_disabled,
|
|
||||||
bind=('_bg_color_disabled',))
|
|
||||||
icon = StringProperty('android')
|
|
||||||
|
|
||||||
_elev_norm = NumericProperty(6)
|
|
||||||
|
|
||||||
def _get_elev_norm(self):
|
|
||||||
return self._elev_norm
|
|
||||||
|
|
||||||
def _set_elev_norm(self, value):
|
|
||||||
self._elev_norm = value if value <= 12 else 12
|
|
||||||
self._elev_raised = (value + 6) if value + 6 <= 12 else 12
|
|
||||||
self.elevation = self._elev_norm
|
|
||||||
|
|
||||||
elevation_normal = AliasProperty(_get_elev_norm, _set_elev_norm,
|
|
||||||
bind=('_elev_norm',))
|
|
||||||
|
|
||||||
# _elev_raised = NumericProperty(12)
|
|
||||||
_elev_raised = NumericProperty(6)
|
|
||||||
|
|
||||||
def _get_elev_raised(self):
|
|
||||||
return self._elev_raised
|
|
||||||
|
|
||||||
def _set_elev_raised(self, value):
|
|
||||||
self._elev_raised = value if value + self._elev_norm <= 12 else 12
|
|
||||||
|
|
||||||
elevation_raised = AliasProperty(_get_elev_raised, _set_elev_raised,
|
|
||||||
bind=('_elev_raised',))
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
if self.elevation_raised == 0 and self.elevation_normal + 6 <= 12:
|
|
||||||
self.elevation_raised = self.elevation_normal + 6
|
|
||||||
elif self.elevation_raised == 0:
|
|
||||||
self.elevation_raised = 12
|
|
||||||
|
|
||||||
super(MDFloatingActionButton, self).__init__(**kwargs)
|
|
||||||
|
|
||||||
self.elevation_press_anim = Animation(elevation=self.elevation_raised,
|
|
||||||
duration=.2, t='out_quad')
|
|
||||||
self.elevation_release_anim = Animation(
|
|
||||||
elevation=self.elevation_normal, duration=.2, t='out_quad')
|
|
||||||
|
|
||||||
def _set_ellipse(self, instance, value):
|
|
||||||
ellipse = self.ellipse
|
|
||||||
ripple_rad = self.ripple_rad
|
|
||||||
|
|
||||||
ellipse.size = (ripple_rad, ripple_rad)
|
|
||||||
ellipse.pos = (self.center_x - ripple_rad / 2.,
|
|
||||||
self.center_y - ripple_rad / 2.)
|
|
||||||
|
|
||||||
def on_disabled(self, instance, value):
|
|
||||||
super(MDFloatingActionButton, self).on_disabled(instance, value)
|
|
||||||
if self.disabled:
|
|
||||||
self.elevation = 0
|
|
||||||
else:
|
|
||||||
self.elevation = self.elevation_normal
|
|
||||||
|
|
||||||
def on_touch_down(self, touch):
|
|
||||||
if not self.disabled:
|
|
||||||
if touch.is_mouse_scrolling:
|
|
||||||
return False
|
|
||||||
if not self.collide_point(touch.x, touch.y):
|
|
||||||
return False
|
|
||||||
if self in touch.ud:
|
|
||||||
return False
|
|
||||||
self.elevation_press_anim.stop(self)
|
|
||||||
self.elevation_press_anim.start(self)
|
|
||||||
return super(MDFloatingActionButton, self).on_touch_down(touch)
|
|
||||||
|
|
||||||
def on_touch_up(self, touch):
|
|
||||||
if not self.disabled:
|
|
||||||
if touch.grab_current is not self:
|
|
||||||
return super(ButtonBehavior, self).on_touch_up(touch)
|
|
||||||
self.elevation_release_anim.stop(self)
|
|
||||||
self.elevation_release_anim.start(self)
|
|
||||||
return super(MDFloatingActionButton, self).on_touch_up(touch)
|
|
||||||
|
|
||||||
def on_elevation_normal(self, instance, value):
|
|
||||||
self.elevation = value
|
|
||||||
|
|
||||||
def on_elevation_raised(self, instance, value):
|
|
||||||
if self.elevation_raised == 0 and self.elevation_normal + 6 <= 12:
|
|
||||||
self.elevation_raised = self.elevation_normal + 6
|
|
||||||
elif self.elevation_raised == 0:
|
|
||||||
self.elevation_raised = 12
|
|
|
@ -1,58 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.properties import BoundedNumericProperty, ReferenceListProperty, ListProperty,BooleanProperty
|
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
|
||||||
from kivymd.elevationbehavior import ElevationBehavior
|
|
||||||
from kivymd.theming import ThemableBehavior
|
|
||||||
from kivy.metrics import dp
|
|
||||||
from kivy.uix.widget import Widget
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
<MDCard>
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
rgba: self.background_color
|
|
||||||
RoundedRectangle:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
radius: [self.border_radius]
|
|
||||||
Color:
|
|
||||||
rgba: self.theme_cls.divider_color
|
|
||||||
a: self.border_color_a
|
|
||||||
Line:
|
|
||||||
rounded_rectangle: (self.pos[0],self.pos[1],self.size[0],self.size[1],self.border_radius)
|
|
||||||
background_color: self.theme_cls.bg_light
|
|
||||||
|
|
||||||
<MDSeparator>
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
rgba: self.theme_cls.divider_color
|
|
||||||
Rectangle:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class MDSeparator(ThemableBehavior, BoxLayout):
|
|
||||||
""" A separator line """
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(MDSeparator, self).__init__(*args, **kwargs)
|
|
||||||
self.on_orientation()
|
|
||||||
|
|
||||||
def on_orientation(self,*args):
|
|
||||||
self.size_hint = (1, None) if self.orientation == 'horizontal' else (None, 1)
|
|
||||||
if self.orientation == 'horizontal':
|
|
||||||
self.height = dp(1)
|
|
||||||
else:
|
|
||||||
self.width = dp(1)
|
|
||||||
|
|
||||||
|
|
||||||
class MDCard(ThemableBehavior, ElevationBehavior, BoxLayout):
|
|
||||||
r = BoundedNumericProperty(1., min=0., max=1.)
|
|
||||||
g = BoundedNumericProperty(1., min=0., max=1.)
|
|
||||||
b = BoundedNumericProperty(1., min=0., max=1.)
|
|
||||||
a = BoundedNumericProperty(0., min=0., max=1.)
|
|
||||||
|
|
||||||
border_radius = BoundedNumericProperty(dp(3),min=0)
|
|
||||||
border_color_a = BoundedNumericProperty(0, min=0., max=1.)
|
|
||||||
background_color = ReferenceListProperty(r, g, b, a)
|
|
|
@ -1,360 +0,0 @@
|
||||||
colors = {
|
|
||||||
'Pink': {
|
|
||||||
'50': 'fce4ec',
|
|
||||||
'100': 'f8bbd0',
|
|
||||||
'200': 'f48fb1',
|
|
||||||
'300': 'f06292',
|
|
||||||
'400': 'ec407a',
|
|
||||||
'500': 'e91e63',
|
|
||||||
'600': 'd81b60',
|
|
||||||
'700': 'C2185B',
|
|
||||||
'800': 'ad1457',
|
|
||||||
'900': '88e4ff',
|
|
||||||
'A100': 'ff80ab',
|
|
||||||
'A400': 'F50057',
|
|
||||||
'A700': 'c51162',
|
|
||||||
'A200': 'ff4081'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Blue': {
|
|
||||||
'200': '90caf9',
|
|
||||||
'900': '0D47A1',
|
|
||||||
'600': '1e88e5',
|
|
||||||
'A100': '82b1ff',
|
|
||||||
'300': '64b5f6',
|
|
||||||
'A400': '2979ff',
|
|
||||||
'700': '1976d2',
|
|
||||||
'50': 'e3f2fd',
|
|
||||||
'A700': '2962ff',
|
|
||||||
'400': '42a5f5',
|
|
||||||
'100': 'bbdefb',
|
|
||||||
'800': '1565c0',
|
|
||||||
'A200': '448aff',
|
|
||||||
'500': '2196f3'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Indigo': {
|
|
||||||
'200': '9fa8da',
|
|
||||||
'900': '1a237e',
|
|
||||||
'600': '3949ab',
|
|
||||||
'A100': '8c9eff',
|
|
||||||
'300': '7986cb',
|
|
||||||
'A400': '3d5afe',
|
|
||||||
'700': '303f9f',
|
|
||||||
'50': 'e8eaf6',
|
|
||||||
'A700': '304ffe',
|
|
||||||
'400': '5c6bc0',
|
|
||||||
'100': 'c5cae9',
|
|
||||||
'800': '283593',
|
|
||||||
'A200': '536dfe',
|
|
||||||
'500': '3f51b5'
|
|
||||||
},
|
|
||||||
|
|
||||||
'BlueGrey': {
|
|
||||||
'200': 'b0bec5',
|
|
||||||
'900': '263238',
|
|
||||||
'600': '546e7a',
|
|
||||||
'300': '90a4ae',
|
|
||||||
'700': '455a64',
|
|
||||||
'50': 'eceff1',
|
|
||||||
'400': '78909c',
|
|
||||||
'100': 'cfd8dc',
|
|
||||||
'800': '37474f',
|
|
||||||
'500': '607d8b'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Brown': {
|
|
||||||
'200': 'bcaaa4',
|
|
||||||
'900': '3e2723',
|
|
||||||
'600': '6d4c41',
|
|
||||||
'300': 'a1887f',
|
|
||||||
'700': '5d4037',
|
|
||||||
'50': 'efebe9',
|
|
||||||
'400': '8d6e63',
|
|
||||||
'100': 'd7ccc8',
|
|
||||||
'800': '4e342e',
|
|
||||||
'500': '795548'
|
|
||||||
},
|
|
||||||
|
|
||||||
'LightBlue': {
|
|
||||||
'200': '81d4fa',
|
|
||||||
'900': '01579B',
|
|
||||||
'600': '039BE5',
|
|
||||||
'A100': '80d8ff',
|
|
||||||
'300': '4fc3f7',
|
|
||||||
'A400': '00B0FF',
|
|
||||||
'700': '0288D1',
|
|
||||||
'50': 'e1f5fe',
|
|
||||||
'A700': '0091EA',
|
|
||||||
'400': '29b6f6',
|
|
||||||
'100': 'b3e5fc',
|
|
||||||
'800': '0277BD',
|
|
||||||
'A200': '40c4ff',
|
|
||||||
'500': '03A9F4'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Purple': {
|
|
||||||
'200': 'ce93d8',
|
|
||||||
'900': '4a148c',
|
|
||||||
'600': '8e24aa',
|
|
||||||
'A100': 'ea80fc',
|
|
||||||
'300': 'ba68c8',
|
|
||||||
'A400': 'D500F9',
|
|
||||||
'700': '7b1fa2',
|
|
||||||
'50': 'f3e5f5',
|
|
||||||
'A700': 'AA00FF',
|
|
||||||
'400': 'ab47bc',
|
|
||||||
'100': 'e1bee7',
|
|
||||||
'800': '6a1b9a',
|
|
||||||
'A200': 'e040fb',
|
|
||||||
'500': '9c27b0'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Grey': {
|
|
||||||
'200': 'eeeeee',
|
|
||||||
'900': '212121',
|
|
||||||
'600': '757575',
|
|
||||||
'300': 'e0e0e0',
|
|
||||||
'700': '616161',
|
|
||||||
'50': 'fafafa',
|
|
||||||
'400': 'bdbdbd',
|
|
||||||
'100': 'f5f5f5',
|
|
||||||
'800': '424242',
|
|
||||||
'500': '9e9e9e'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Yellow': {
|
|
||||||
'200': 'fff59d',
|
|
||||||
'900': 'f57f17',
|
|
||||||
'600': 'fdd835',
|
|
||||||
'A100': 'ffff8d',
|
|
||||||
'300': 'fff176',
|
|
||||||
'A400': 'FFEA00',
|
|
||||||
'700': 'fbc02d',
|
|
||||||
'50': 'fffde7',
|
|
||||||
'A700': 'FFD600',
|
|
||||||
'400': 'ffee58',
|
|
||||||
'100': 'fff9c4',
|
|
||||||
'800': 'f9a825',
|
|
||||||
'A200': 'FFFF00',
|
|
||||||
'500': 'ffeb3b'
|
|
||||||
},
|
|
||||||
|
|
||||||
'LightGreen': {
|
|
||||||
'200': 'c5e1a5',
|
|
||||||
'900': '33691e',
|
|
||||||
'600': '7cb342',
|
|
||||||
'A100': 'ccff90',
|
|
||||||
'300': 'aed581',
|
|
||||||
'A400': '76FF03',
|
|
||||||
'700': '689f38',
|
|
||||||
'50': 'f1f8e9',
|
|
||||||
'A700': '64dd17',
|
|
||||||
'400': '9ccc65',
|
|
||||||
'100': 'dcedc8',
|
|
||||||
'800': '558b2f',
|
|
||||||
'A200': 'b2ff59',
|
|
||||||
'500': '8bc34a'
|
|
||||||
},
|
|
||||||
|
|
||||||
'DeepOrange': {
|
|
||||||
'200': 'ffab91',
|
|
||||||
'900': 'bf36c',
|
|
||||||
'600': 'f4511e',
|
|
||||||
'A100': 'ff9e80',
|
|
||||||
'300': 'ff8a65',
|
|
||||||
'A400': 'FF3D00',
|
|
||||||
'700': 'e64a19',
|
|
||||||
'50': 'fbe9e7',
|
|
||||||
'A700': 'DD2C00',
|
|
||||||
'400': 'ff7043',
|
|
||||||
'100': 'ffccbc',
|
|
||||||
'800': 'd84315',
|
|
||||||
'A200': 'ff6e40',
|
|
||||||
'500': 'ff5722'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Green': {
|
|
||||||
'200': 'a5d6a7',
|
|
||||||
'900': '1b5e20',
|
|
||||||
'600': '43a047',
|
|
||||||
'A100': 'b9f6ca',
|
|
||||||
'300': '81c784',
|
|
||||||
'A400': '00E676',
|
|
||||||
'700': '388e3c',
|
|
||||||
'50': 'e8f5e9',
|
|
||||||
'A700': '00C853',
|
|
||||||
'400': '66bb6a',
|
|
||||||
'100': 'c8e6c9',
|
|
||||||
'800': '2e7d32',
|
|
||||||
'A200': '69f0ae',
|
|
||||||
'500': '4caf50'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Red': {
|
|
||||||
'200': 'ef9a9a',
|
|
||||||
'900': 'b71c1c',
|
|
||||||
'600': 'e53935',
|
|
||||||
'A100': 'ff8a80',
|
|
||||||
'300': 'e57373',
|
|
||||||
'A400': 'ff1744',
|
|
||||||
'700': 'd32f2f',
|
|
||||||
'50': 'ffebee',
|
|
||||||
'A700': 'd50000',
|
|
||||||
'400': 'ef5350',
|
|
||||||
'100': 'ffcdd2',
|
|
||||||
'800': 'c62828',
|
|
||||||
'A200': 'ff5252',
|
|
||||||
'500': 'f44336'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Teal': {
|
|
||||||
'200': '80cbc4',
|
|
||||||
'900': '004D40',
|
|
||||||
'600': '00897B',
|
|
||||||
'A100': 'a7ffeb',
|
|
||||||
'300': '4db6ac',
|
|
||||||
'A400': '1de9b6',
|
|
||||||
'700': '00796B',
|
|
||||||
'50': 'e0f2f1',
|
|
||||||
'A700': '00BFA5',
|
|
||||||
'400': '26a69a',
|
|
||||||
'100': 'b2dfdb',
|
|
||||||
'800': '00695C',
|
|
||||||
'A200': '64ffda',
|
|
||||||
'500': '009688'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Orange': {
|
|
||||||
'200': 'ffcc80',
|
|
||||||
'900': 'E65100',
|
|
||||||
'600': 'FB8C00',
|
|
||||||
'A100': 'ffd180',
|
|
||||||
'300': 'ffb74d',
|
|
||||||
'A400': 'FF9100',
|
|
||||||
'700': 'F57C00',
|
|
||||||
'50': 'fff3e0',
|
|
||||||
'A700': 'FF6D00',
|
|
||||||
'400': 'ffa726',
|
|
||||||
'100': 'ffe0b2',
|
|
||||||
'800': 'EF6C00',
|
|
||||||
'A200': 'ffab40',
|
|
||||||
'500': 'FF9800'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Cyan': {
|
|
||||||
'200': '80deea',
|
|
||||||
'900': '006064',
|
|
||||||
'600': '00ACC1',
|
|
||||||
'A100': '84ffff',
|
|
||||||
'300': '4dd0e1',
|
|
||||||
'A400': '00E5FF',
|
|
||||||
'700': '0097A7',
|
|
||||||
'50': 'e0f7fa',
|
|
||||||
'A700': '00B8D4',
|
|
||||||
'400': '26c6da',
|
|
||||||
'100': 'b2ebf2',
|
|
||||||
'800': '00838F',
|
|
||||||
'A200': '18ffff',
|
|
||||||
'500': '00BCD4'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Amber': {
|
|
||||||
'200': 'ffe082',
|
|
||||||
'900': 'FF6F00',
|
|
||||||
'600': 'FFB300',
|
|
||||||
'A100': 'ffe57f',
|
|
||||||
'300': 'ffd54f',
|
|
||||||
'A400': 'FFC400',
|
|
||||||
'700': 'FFA000',
|
|
||||||
'50': 'fff8e1',
|
|
||||||
'A700': 'FFAB00',
|
|
||||||
'400': 'ffca28',
|
|
||||||
'100': 'ffecb3',
|
|
||||||
'800': 'FF8F00',
|
|
||||||
'A200': 'ffd740',
|
|
||||||
'500': 'FFC107'
|
|
||||||
},
|
|
||||||
|
|
||||||
'DeepPurple': {
|
|
||||||
'200': 'b39ddb',
|
|
||||||
'900': '311b92',
|
|
||||||
'600': '5e35b1',
|
|
||||||
'A100': 'b388ff',
|
|
||||||
'300': '9575cd',
|
|
||||||
'A400': '651fff',
|
|
||||||
'700': '512da8',
|
|
||||||
'50': 'ede7f6',
|
|
||||||
'A700': '6200EA',
|
|
||||||
'400': '7e57c2',
|
|
||||||
'100': 'd1c4e9',
|
|
||||||
'800': '4527a0',
|
|
||||||
'A200': '7c4dff',
|
|
||||||
'500': '673ab7'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Lime': {
|
|
||||||
'200': 'e6ee9c',
|
|
||||||
'900': '827717',
|
|
||||||
'600': 'c0ca33',
|
|
||||||
'A100': 'f4ff81',
|
|
||||||
'300': 'dce775',
|
|
||||||
'A400': 'C6FF00',
|
|
||||||
'700': 'afb42b',
|
|
||||||
'50': 'f9fbe7',
|
|
||||||
'A700': 'AEEA00',
|
|
||||||
'400': 'd4e157',
|
|
||||||
'100': 'f0f4c3',
|
|
||||||
'800': '9e9d24',
|
|
||||||
'A200': 'eeff41',
|
|
||||||
'500': 'cddc39'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Light': {
|
|
||||||
'StatusBar': 'E0E0E0',
|
|
||||||
'AppBar': 'F5F5F5',
|
|
||||||
'Background': 'FAFAFA',
|
|
||||||
'CardsDialogs': 'FFFFFF',
|
|
||||||
'FlatButtonDown': 'cccccc'
|
|
||||||
},
|
|
||||||
|
|
||||||
'Dark': {
|
|
||||||
'StatusBar': '000000',
|
|
||||||
'AppBar': '212121',
|
|
||||||
'Background': '303030',
|
|
||||||
'CardsDialogs': '424242',
|
|
||||||
'FlatButtonDown': '999999'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
light_colors = {
|
|
||||||
'Pink': ['50' '100', '200', 'A100'],
|
|
||||||
'Blue': ['50' '100', '200', '300', '400', 'A100'],
|
|
||||||
'Indigo': ['50' '100', '200', 'A100'],
|
|
||||||
'BlueGrey': ['50' '100', '200', '300'],
|
|
||||||
'Brown': ['50' '100', '200'],
|
|
||||||
'LightBlue': ['50' '100', '200', '300', '400', '500', 'A100', 'A200',
|
|
||||||
'A400'],
|
|
||||||
'Purple': ['50' '100', '200', 'A100'],
|
|
||||||
'Grey': ['50' '100', '200', '300', '400', '500'],
|
|
||||||
'Yellow': ['50' '100', '200', '300', '400', '500', '600', '700', '800',
|
|
||||||
'900', 'A100', 'A200', 'A400', 'A700'],
|
|
||||||
'LightGreen': ['50' '100', '200', '300', '400', '500', '600', 'A100',
|
|
||||||
'A200', 'A400', 'A700'],
|
|
||||||
'DeepOrange': ['50' '100', '200', '300', '400', 'A100', 'A200'],
|
|
||||||
'Green': ['50' '100', '200', '300', '400', '500', 'A100', 'A200', 'A400',
|
|
||||||
'A700'],
|
|
||||||
'Red': ['50' '100', '200', '300', 'A100'],
|
|
||||||
'Teal': ['50' '100', '200', '300', '400', 'A100', 'A200', 'A400', 'A700'],
|
|
||||||
'Orange': ['50' '100', '200', '300', '400', '500', '600', '700', 'A100',
|
|
||||||
'A200', 'A400', 'A700'],
|
|
||||||
'Cyan': ['50' '100', '200', '300', '400', '500', '600', 'A100', 'A200',
|
|
||||||
'A400', 'A700'],
|
|
||||||
'Amber': ['50' '100', '200', '300', '400', '500', '600', '700', '800',
|
|
||||||
'900', 'A100', 'A200', 'A400', 'A700'],
|
|
||||||
'DeepPurple': ['50' '100', '200', 'A100'],
|
|
||||||
'Lime': ['50' '100', '200', '300', '400', '500', '600', '700', '800',
|
|
||||||
'A100', 'A200', 'A400', 'A700'],
|
|
||||||
'Dark': [],
|
|
||||||
'Light': ['White', 'MainBackground', 'DialogBackground']
|
|
||||||
}
|
|
|
@ -1,325 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.uix.modalview import ModalView
|
|
||||||
from kivymd.label import MDLabel
|
|
||||||
from kivymd.theming import ThemableBehavior
|
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
|
||||||
from kivymd.elevationbehavior import ElevationBehavior
|
|
||||||
import calendar
|
|
||||||
from datetime import date
|
|
||||||
import datetime
|
|
||||||
from kivy.properties import StringProperty, NumericProperty, ObjectProperty, \
|
|
||||||
BooleanProperty
|
|
||||||
from kivy.uix.anchorlayout import AnchorLayout
|
|
||||||
from kivy.uix.behaviors import ButtonBehavior
|
|
||||||
from kivymd.ripplebehavior import CircularRippleBehavior
|
|
||||||
from kivy.clock import Clock
|
|
||||||
from kivy.core.window import Window
|
|
||||||
|
|
||||||
Builder.load_string("""
|
|
||||||
#:import calendar calendar
|
|
||||||
<MDDatePicker>
|
|
||||||
cal_layout: cal_layout
|
|
||||||
|
|
||||||
size_hint: (None, None)
|
|
||||||
size: [dp(328), dp(484)] if self.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [dp(512), dp(304)]
|
|
||||||
pos_hint: {'center_x': .5, 'center_y': .5}
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
rgb: app.theme_cls.primary_color
|
|
||||||
Rectangle:
|
|
||||||
size: [dp(328), dp(96)] if self.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [dp(168), dp(304)]
|
|
||||||
pos: [root.pos[0], root.pos[1] + root.height-dp(96)] if self.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [root.pos[0], root.pos[1] + root.height-dp(304)]
|
|
||||||
Color:
|
|
||||||
rgb: app.theme_cls.bg_normal
|
|
||||||
Rectangle:
|
|
||||||
size: [dp(328), dp(484)-dp(96)] if self.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [dp(344), dp(304)]
|
|
||||||
pos: [root.pos[0], root.pos[1] + root.height-dp(96)-(dp(484)-dp(96))]\
|
|
||||||
if self.theme_cls.device_orientation == 'portrait' else [root.pos[0]+dp(168), root.pos[1]] #+dp(334)
|
|
||||||
MDLabel:
|
|
||||||
id: label_full_date
|
|
||||||
font_style: 'Display1'
|
|
||||||
text_color: 1, 1, 1, 1
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
size_hint: (None, None)
|
|
||||||
size: [root.width, dp(30)] if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [dp(168), dp(30)]
|
|
||||||
pos: [root.pos[0]+dp(23), root.pos[1] + root.height - dp(74)] \
|
|
||||||
if root.theme_cls.device_orientation == 'portrait' \
|
|
||||||
else [root.pos[0]+dp(3), root.pos[1] + dp(214)]
|
|
||||||
line_height: 0.84
|
|
||||||
valign: 'middle'
|
|
||||||
text_size: [root.width, None] if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [dp(149), None]
|
|
||||||
bold: True
|
|
||||||
text: root.fmt_lbl_date(root.sel_year, root.sel_month, root.sel_day, root.theme_cls.device_orientation)
|
|
||||||
MDLabel:
|
|
||||||
id: label_year
|
|
||||||
font_style: 'Subhead'
|
|
||||||
text_color: 1, 1, 1, 1
|
|
||||||
theme_text_color: 'Custom'
|
|
||||||
size_hint: (None, None)
|
|
||||||
size: root.width, dp(30)
|
|
||||||
pos: (root.pos[0]+dp(23), root.pos[1]+root.height-dp(40)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (root.pos[0]+dp(16), root.pos[1]+root.height-dp(41))
|
|
||||||
valign: 'middle'
|
|
||||||
text: str(root.sel_year)
|
|
||||||
GridLayout:
|
|
||||||
id: cal_layout
|
|
||||||
cols: 7
|
|
||||||
size: (dp(44*7), dp(40*7)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(46*7), dp(32*7))
|
|
||||||
col_default_width: dp(42) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else dp(39)
|
|
||||||
size_hint: (None, None)
|
|
||||||
padding: (dp(2), 0) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(7), 0)
|
|
||||||
spacing: (dp(2), 0) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(7), 0)
|
|
||||||
pos: (root.pos[0]+dp(10), root.pos[1]+dp(60)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (root.pos[0]+dp(168)+dp(8), root.pos[1]+dp(48))
|
|
||||||
MDLabel:
|
|
||||||
id: label_month_selector
|
|
||||||
font_style: 'Body2'
|
|
||||||
text: calendar.month_name[root.month].capitalize() + ' ' + str(root.year)
|
|
||||||
size_hint: (None, None)
|
|
||||||
size: root.width, dp(30)
|
|
||||||
pos: root.pos
|
|
||||||
theme_text_color: 'Primary'
|
|
||||||
pos_hint: {'center_x': 0.5, 'center_y': 0.75} if self.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else {'center_x': 0.67, 'center_y': 0.915}
|
|
||||||
valign: "middle"
|
|
||||||
halign: "center"
|
|
||||||
MDIconButton:
|
|
||||||
icon: 'chevron-left'
|
|
||||||
theme_text_color: 'Secondary'
|
|
||||||
pos_hint: {'center_x': 0.09, 'center_y': 0.745} if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else {'center_x': 0.39, 'center_y': 0.925}
|
|
||||||
on_release: root.change_month('prev')
|
|
||||||
MDIconButton:
|
|
||||||
icon: 'chevron-right'
|
|
||||||
theme_text_color: 'Secondary'
|
|
||||||
pos_hint: {'center_x': 0.92, 'center_y': 0.745} if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else {'center_x': 0.94, 'center_y': 0.925}
|
|
||||||
on_release: root.change_month('next')
|
|
||||||
MDFlatButton:
|
|
||||||
pos: root.pos[0]+root.size[0]-dp(72)*2, root.pos[1] + dp(7)
|
|
||||||
text: "Cancel"
|
|
||||||
on_release: root.dismiss()
|
|
||||||
MDFlatButton:
|
|
||||||
pos: root.pos[0]+root.size[0]-dp(72), root.pos[1] + dp(7)
|
|
||||||
text: "OK"
|
|
||||||
on_release: root.ok_click()
|
|
||||||
|
|
||||||
<DayButton>
|
|
||||||
size_hint: None, None
|
|
||||||
size: (dp(40), dp(40)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(32), dp(32))
|
|
||||||
MDLabel:
|
|
||||||
font_style: 'Caption'
|
|
||||||
theme_text_color: 'Custom' if root.is_today and not root.is_selected else 'Primary'
|
|
||||||
text_color: root.theme_cls.primary_color
|
|
||||||
opposite_colors: root.is_selected if root.owner.sel_month == root.owner.month \
|
|
||||||
and root.owner.sel_year == root.owner.year and str(self.text) == str(root.owner.sel_day) else False
|
|
||||||
size_hint_x: None
|
|
||||||
valign: 'middle'
|
|
||||||
halign: 'center'
|
|
||||||
text: root.text
|
|
||||||
|
|
||||||
<WeekdayLabel>
|
|
||||||
font_style: 'Caption'
|
|
||||||
theme_text_color: 'Secondary'
|
|
||||||
size: (dp(40), dp(40)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(32), dp(32))
|
|
||||||
size_hint: None, None
|
|
||||||
text_size: self.size
|
|
||||||
valign: 'middle' if root.theme_cls.device_orientation == 'portrait' else 'bottom'
|
|
||||||
halign: 'center'
|
|
||||||
|
|
||||||
<DaySelector>
|
|
||||||
size: (dp(40), dp(40)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(32), dp(32))
|
|
||||||
size_hint: (None, None)
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
rgba: self.theme_cls.primary_color if self.shown else [0, 0, 0, 0]
|
|
||||||
Ellipse:
|
|
||||||
size: (dp(40), dp(40)) if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else (dp(32), dp(32))
|
|
||||||
pos: self.pos if root.theme_cls.device_orientation == 'portrait'\
|
|
||||||
else [self.pos[0] + dp(3), self.pos[1]]
|
|
||||||
""")
|
|
||||||
|
|
||||||
|
|
||||||
class DaySelector(ThemableBehavior, AnchorLayout):
|
|
||||||
shown = BooleanProperty(False)
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
|
||||||
super(DaySelector, self).__init__()
|
|
||||||
self.parent_class = parent
|
|
||||||
self.parent_class.add_widget(self, index=7)
|
|
||||||
self.selected_widget = None
|
|
||||||
Window.bind(on_resize=self.move_resize)
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
parent = self.parent_class
|
|
||||||
if parent.sel_month == parent.month and parent.sel_year == parent.year:
|
|
||||||
self.shown = True
|
|
||||||
else:
|
|
||||||
self.shown = False
|
|
||||||
|
|
||||||
def set_widget(self, widget):
|
|
||||||
self.selected_widget = widget
|
|
||||||
self.pos = widget.pos
|
|
||||||
self.move_resize(do_again=True)
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def move_resize(self, window=None, width=None, height=None, do_again=True):
|
|
||||||
self.pos = self.selected_widget.pos
|
|
||||||
if do_again:
|
|
||||||
Clock.schedule_once(lambda x: self.move_resize(do_again=False), 0.01)
|
|
||||||
|
|
||||||
|
|
||||||
class DayButton(ThemableBehavior, CircularRippleBehavior, ButtonBehavior,
|
|
||||||
AnchorLayout):
|
|
||||||
text = StringProperty()
|
|
||||||
owner = ObjectProperty()
|
|
||||||
is_today = BooleanProperty(False)
|
|
||||||
is_selected = BooleanProperty(False)
|
|
||||||
|
|
||||||
def on_release(self):
|
|
||||||
self.owner.set_selected_widget(self)
|
|
||||||
|
|
||||||
|
|
||||||
class WeekdayLabel(MDLabel):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MDDatePicker(FloatLayout, ThemableBehavior, ElevationBehavior,
|
|
||||||
ModalView):
|
|
||||||
_sel_day_widget = ObjectProperty()
|
|
||||||
cal_list = None
|
|
||||||
cal_layout = ObjectProperty()
|
|
||||||
sel_year = NumericProperty()
|
|
||||||
sel_month = NumericProperty()
|
|
||||||
sel_day = NumericProperty()
|
|
||||||
day = NumericProperty()
|
|
||||||
month = NumericProperty()
|
|
||||||
year = NumericProperty()
|
|
||||||
today = date.today()
|
|
||||||
callback = ObjectProperty()
|
|
||||||
|
|
||||||
class SetDateError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __init__(self, callback, year=None, month=None, day=None,
|
|
||||||
firstweekday=0,
|
|
||||||
**kwargs):
|
|
||||||
self.callback = callback
|
|
||||||
self.cal = calendar.Calendar(firstweekday)
|
|
||||||
self.sel_year = year if year else self.today.year
|
|
||||||
self.sel_month = month if month else self.today.month
|
|
||||||
self.sel_day = day if day else self.today.day
|
|
||||||
self.month = self.sel_month
|
|
||||||
self.year = self.sel_year
|
|
||||||
self.day = self.sel_day
|
|
||||||
super(MDDatePicker, self).__init__(**kwargs)
|
|
||||||
self.selector = DaySelector(parent=self)
|
|
||||||
self.generate_cal_widgets()
|
|
||||||
self.update_cal_matrix(self.sel_year, self.sel_month)
|
|
||||||
self.set_month_day(self.sel_day)
|
|
||||||
self.selector.update()
|
|
||||||
|
|
||||||
def ok_click(self):
|
|
||||||
self.callback(date(self.sel_year, self.sel_month, self.sel_day))
|
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
def fmt_lbl_date(self, year, month, day, orientation):
|
|
||||||
d = datetime.date(int(year), int(month), int(day))
|
|
||||||
separator = '\n' if orientation == 'landscape' else ' '
|
|
||||||
return d.strftime('%a,').capitalize() + separator + d.strftime(
|
|
||||||
'%b').capitalize() + ' ' + str(day).lstrip('0')
|
|
||||||
|
|
||||||
def set_date(self, year, month, day):
|
|
||||||
try:
|
|
||||||
date(year, month, day)
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
if str(e) == "day is out of range for month":
|
|
||||||
raise self.SetDateError(" Day %s day is out of range for month %s" % (day, month))
|
|
||||||
elif str(e) == "month must be in 1..12":
|
|
||||||
raise self.SetDateError("Month must be between 1 and 12, got %s" % month)
|
|
||||||
elif str(e) == "year is out of range":
|
|
||||||
raise self.SetDateError("Year must be between %s and %s, got %s" %
|
|
||||||
(datetime.MINYEAR, datetime.MAXYEAR, year))
|
|
||||||
else:
|
|
||||||
self.sel_year = year
|
|
||||||
self.sel_month = month
|
|
||||||
self.sel_day = day
|
|
||||||
self.month = self.sel_month
|
|
||||||
self.year = self.sel_year
|
|
||||||
self.day = self.sel_day
|
|
||||||
self.update_cal_matrix(self.sel_year, self.sel_month)
|
|
||||||
self.set_month_day(self.sel_day)
|
|
||||||
self.selector.update()
|
|
||||||
|
|
||||||
def set_selected_widget(self, widget):
|
|
||||||
if self._sel_day_widget:
|
|
||||||
self._sel_day_widget.is_selected = False
|
|
||||||
widget.is_selected = True
|
|
||||||
self.sel_month = int(self.month)
|
|
||||||
self.sel_year = int(self.year)
|
|
||||||
self.sel_day = int(widget.text)
|
|
||||||
self._sel_day_widget = widget
|
|
||||||
self.selector.set_widget(widget)
|
|
||||||
|
|
||||||
def set_month_day(self, day):
|
|
||||||
for idx in range(len(self.cal_list)):
|
|
||||||
if str(day) == str(self.cal_list[idx].text):
|
|
||||||
self._sel_day_widget = self.cal_list[idx]
|
|
||||||
self.sel_day = int(self.cal_list[idx].text)
|
|
||||||
if self._sel_day_widget:
|
|
||||||
self._sel_day_widget.is_selected = False
|
|
||||||
self._sel_day_widget = self.cal_list[idx]
|
|
||||||
self.cal_list[idx].is_selected = True
|
|
||||||
self.selector.set_widget(self.cal_list[idx])
|
|
||||||
|
|
||||||
def update_cal_matrix(self, year, month):
|
|
||||||
try:
|
|
||||||
dates = [x for x in self.cal.itermonthdates(year, month)]
|
|
||||||
except ValueError as e:
|
|
||||||
if str(e) == "year is out of range":
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.year = year
|
|
||||||
self.month = month
|
|
||||||
for idx in range(len(self.cal_list)):
|
|
||||||
if idx >= len(dates) or dates[idx].month != month:
|
|
||||||
self.cal_list[idx].disabled = True
|
|
||||||
self.cal_list[idx].text = ''
|
|
||||||
else:
|
|
||||||
self.cal_list[idx].disabled = False
|
|
||||||
self.cal_list[idx].text = str(dates[idx].day)
|
|
||||||
self.cal_list[idx].is_today = dates[idx] == self.today
|
|
||||||
self.selector.update()
|
|
||||||
|
|
||||||
def generate_cal_widgets(self):
|
|
||||||
cal_list = []
|
|
||||||
for i in calendar.day_abbr:
|
|
||||||
self.cal_layout.add_widget(WeekdayLabel(text=i[0].upper()))
|
|
||||||
for i in range(6 * 7): # 6 weeks, 7 days a week
|
|
||||||
db = DayButton(owner=self)
|
|
||||||
cal_list.append(db)
|
|
||||||
self.cal_layout.add_widget(db)
|
|
||||||
self.cal_list = cal_list
|
|
||||||
|
|
||||||
def change_month(self, operation):
|
|
||||||
op = 1 if operation is 'next' else -1
|
|
||||||
sl, sy = self.month, self.year
|
|
||||||
m = 12 if sl + op == 0 else 1 if sl + op == 13 else sl + op
|
|
||||||
y = sy - 1 if sl + op == 0 else sy + 1 if sl + op == 13 else sy
|
|
||||||
self.update_cal_matrix(y, m)
|
|
|
@ -1,176 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.properties import StringProperty, ObjectProperty, ListProperty
|
|
||||||
from kivy.metrics import dp
|
|
||||||
from kivy.uix.modalview import ModalView
|
|
||||||
from kivy.animation import Animation
|
|
||||||
from kivymd.theming import ThemableBehavior
|
|
||||||
from kivymd.elevationbehavior import ElevationBehavior
|
|
||||||
from kivymd.button import MDFlatButton
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
<MDDialog>:
|
|
||||||
canvas:
|
|
||||||
Color:
|
|
||||||
rgba: self.theme_cls.bg_light
|
|
||||||
Rectangle:
|
|
||||||
size: self.size
|
|
||||||
pos: self.pos
|
|
||||||
|
|
||||||
_container: container
|
|
||||||
_action_area: action_area
|
|
||||||
elevation: 12
|
|
||||||
GridLayout:
|
|
||||||
cols: 1
|
|
||||||
|
|
||||||
GridLayout:
|
|
||||||
cols: 1
|
|
||||||
padding: dp(24), dp(24), dp(24), 0
|
|
||||||
spacing: dp(20)
|
|
||||||
MDLabel:
|
|
||||||
text: root.title
|
|
||||||
font_style: 'Title'
|
|
||||||
theme_text_color: 'Primary'
|
|
||||||
halign: 'left'
|
|
||||||
valign: 'middle'
|
|
||||||
size_hint_y: None
|
|
||||||
text_size: self.width, None
|
|
||||||
height: self.texture_size[1]
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
id: container
|
|
||||||
|
|
||||||
AnchorLayout:
|
|
||||||
anchor_x: 'right'
|
|
||||||
anchor_y: 'center'
|
|
||||||
size_hint: 1, None
|
|
||||||
height: dp(48)
|
|
||||||
padding: dp(8), dp(8)
|
|
||||||
spacing: dp(4)
|
|
||||||
|
|
||||||
GridLayout:
|
|
||||||
id: action_area
|
|
||||||
rows: 1
|
|
||||||
size_hint: None, None if len(root._action_buttons) > 0 else 1
|
|
||||||
height: dp(36) if len(root._action_buttons) > 0 else 0
|
|
||||||
width: self.minimum_width
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class MDDialog(ThemableBehavior, ElevationBehavior, ModalView):
|
|
||||||
title = StringProperty('')
|
|
||||||
|
|
||||||
content = ObjectProperty(None)
|
|
||||||
|
|
||||||
background_color = ListProperty([0, 0, 0, .2])
|
|
||||||
|
|
||||||
_container = ObjectProperty()
|
|
||||||
_action_buttons = ListProperty([])
|
|
||||||
_action_area = ObjectProperty()
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(MDDialog, self).__init__(**kwargs)
|
|
||||||
self.bind(_action_buttons=self._update_action_buttons,
|
|
||||||
auto_dismiss=lambda *x: setattr(self.shadow, 'on_release',
|
|
||||||
self.shadow.dismiss if self.auto_dismiss else None))
|
|
||||||
|
|
||||||
def add_action_button(self, text, action=None):
|
|
||||||
"""Add an :class:`FlatButton` to the right of the action area.
|
|
||||||
|
|
||||||
:param icon: Unicode character for the icon
|
|
||||||
:type icon: str or None
|
|
||||||
:param action: Function set to trigger when on_release fires
|
|
||||||
:type action: function or None
|
|
||||||
"""
|
|
||||||
button = MDFlatButton(text=text,
|
|
||||||
size_hint=(None, None),
|
|
||||||
height=dp(36))
|
|
||||||
if action:
|
|
||||||
button.bind(on_release=action)
|
|
||||||
button.text_color = self.theme_cls.primary_color
|
|
||||||
button.background_color = self.theme_cls.bg_light
|
|
||||||
self._action_buttons.append(button)
|
|
||||||
|
|
||||||
def add_widget(self, widget):
|
|
||||||
if self._container:
|
|
||||||
if self.content:
|
|
||||||
raise PopupException(
|
|
||||||
'Popup can have only one widget as content')
|
|
||||||
self.content = widget
|
|
||||||
else:
|
|
||||||
super(MDDialog, self).add_widget(widget)
|
|
||||||
|
|
||||||
def open(self, *largs):
|
|
||||||
'''Show the view window from the :attr:`attach_to` widget. If set, it
|
|
||||||
will attach to the nearest window. If the widget is not attached to any
|
|
||||||
window, the view will attach to the global
|
|
||||||
:class:`~kivy.core.window.Window`.
|
|
||||||
'''
|
|
||||||
if self._window is not None:
|
|
||||||
Logger.warning('ModalView: you can only open once.')
|
|
||||||
return self
|
|
||||||
# search window
|
|
||||||
self._window = self._search_window()
|
|
||||||
if not self._window:
|
|
||||||
Logger.warning('ModalView: cannot open view, no window found.')
|
|
||||||
return self
|
|
||||||
self._window.add_widget(self)
|
|
||||||
self._window.bind(on_resize=self._align_center,
|
|
||||||
on_keyboard=self._handle_keyboard)
|
|
||||||
self.center = self._window.center
|
|
||||||
self.bind(size=self._align_center)
|
|
||||||
a = Animation(_anim_alpha=1., d=self._anim_duration)
|
|
||||||
a.bind(on_complete=lambda *x: self.dispatch('on_open'))
|
|
||||||
a.start(self)
|
|
||||||
return self
|
|
||||||
|
|
||||||
def dismiss(self, *largs, **kwargs):
|
|
||||||
'''Close the view if it is open. If you really want to close the
|
|
||||||
view, whatever the on_dismiss event returns, you can use the *force*
|
|
||||||
argument:
|
|
||||||
::
|
|
||||||
|
|
||||||
view = ModalView(...)
|
|
||||||
view.dismiss(force=True)
|
|
||||||
|
|
||||||
When the view is dismissed, it will be faded out before being
|
|
||||||
removed from the parent. If you don't want animation, use::
|
|
||||||
|
|
||||||
view.dismiss(animation=False)
|
|
||||||
|
|
||||||
'''
|
|
||||||
if self._window is None:
|
|
||||||
return self
|
|
||||||
if self.dispatch('on_dismiss') is True:
|
|
||||||
if kwargs.get('force', False) is not True:
|
|
||||||
return self
|
|
||||||
if kwargs.get('animation', True):
|
|
||||||
Animation(_anim_alpha=0., d=self._anim_duration).start(self)
|
|
||||||
else:
|
|
||||||
self._anim_alpha = 0
|
|
||||||
self._real_remove_widget()
|
|
||||||
return self
|
|
||||||
|
|
||||||
def on_content(self, instance, value):
|
|
||||||
if self._container:
|
|
||||||
self._container.clear_widgets()
|
|
||||||
self._container.add_widget(value)
|
|
||||||
|
|
||||||
def on__container(self, instance, value):
|
|
||||||
if value is None or self.content is None:
|
|
||||||
return
|
|
||||||
self._container.clear_widgets()
|
|
||||||
self._container.add_widget(self.content)
|
|
||||||
|
|
||||||
def on_touch_down(self, touch):
|
|
||||||
if self.disabled and self.collide_point(*touch.pos):
|
|
||||||
return True
|
|
||||||
return super(MDDialog, self).on_touch_down(touch)
|
|
||||||
|
|
||||||
def _update_action_buttons(self, *args):
|
|
||||||
self._action_area.clear_widgets()
|
|
||||||
for btn in self._action_buttons:
|
|
||||||
btn.ids._label.texture_update()
|
|
||||||
btn.width = btn.ids._label.texture_size[0] + dp(16)
|
|
||||||
self._action_area.add_widget(btn)
|
|
|
@ -1,187 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from kivy.app import App
|
|
||||||
from kivy.lang import Builder
|
|
||||||
from kivy.properties import (ListProperty, ObjectProperty, NumericProperty)
|
|
||||||
from kivy.properties import AliasProperty
|
|
||||||
from kivy.metrics import dp
|
|
||||||
|
|
||||||
Builder.load_string('''
|
|
||||||
<ElevationBehavior>
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
a: self._soft_shadow_a
|
|
||||||
Rectangle:
|
|
||||||
texture: self._soft_shadow_texture
|
|
||||||
size: self._soft_shadow_size
|
|
||||||
pos: self._soft_shadow_pos
|
|
||||||
Color:
|
|
||||||
a: self._hard_shadow_a
|
|
||||||
Rectangle:
|
|
||||||
texture: self._hard_shadow_texture
|
|
||||||
size: self._hard_shadow_size
|
|
||||||
pos: self._hard_shadow_pos
|
|
||||||
Color:
|
|
||||||
a: 1
|
|
||||||
|
|
||||||
<RoundElevationBehavior>
|
|
||||||
canvas.before:
|
|
||||||
Color:
|
|
||||||
a: self._soft_shadow_a
|
|
||||||
Rectangle:
|
|
||||||
texture: self._soft_shadow_texture
|
|
||||||
size: self._soft_shadow_size
|
|
||||||
pos: self._soft_shadow_pos
|
|
||||||
Color:
|
|
||||||
a: self._hard_shadow_a
|
|
||||||
Rectangle:
|
|
||||||
texture: self._hard_shadow_texture
|
|
||||||
size: self._hard_shadow_size
|
|
||||||
pos: self._hard_shadow_pos
|
|
||||||
Color:
|
|
||||||
a: 1
|
|
||||||
''')
|
|
||||||
|
|
||||||
|
|
||||||
class ElevationBehavior(object):
|
|
||||||
_elevation = NumericProperty(1)
|
|
||||||
|
|
||||||
def _get_elevation(self):
|
|
||||||
return self._elevation
|
|
||||||
|
|
||||||
def _set_elevation(self, elevation):
|
|
||||||
try:
|
|
||||||
self._elevation = elevation
|
|
||||||
except:
|
|
||||||
self._elevation = 1
|
|
||||||
|
|
||||||
elevation = AliasProperty(_get_elevation, _set_elevation,
|
|
||||||
bind=('_elevation',))
|
|
||||||
|
|
||||||
_soft_shadow_texture = ObjectProperty()
|
|
||||||
_soft_shadow_size = ListProperty([0, 0])
|
|
||||||
_soft_shadow_pos = ListProperty([0, 0])
|
|
||||||
_soft_shadow_a = NumericProperty(0)
|
|
||||||
_hard_shadow_texture = ObjectProperty()
|
|
||||||
_hard_shadow_size = ListProperty([0, 0])
|
|
||||||
_hard_shadow_pos = ListProperty([0, 0])
|
|
||||||
_hard_shadow_a = NumericProperty(0)
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(ElevationBehavior, self).__init__(**kwargs)
|
|
||||||
self.bind(elevation=self._update_shadow,
|
|
||||||
pos=self._update_shadow,
|
|
||||||
size=self._update_shadow)
|
|
||||||
|
|
||||||
def _update_shadow(self, *args):
|
|
||||||
if self.elevation > 0:
|
|
||||||
ratio = self.width / (self.height if self.height != 0 else 1)
|
|
||||||
if ratio > -2 and ratio < 2:
|
|
||||||
self._shadow = App.get_running_app().theme_cls.quad_shadow
|
|
||||||
width = soft_width = self.width * 1.9
|
|
||||||
height = soft_height = self.height * 1.9
|
|
||||||
elif ratio <= -2:
|
|
||||||
self._shadow = App.get_running_app().theme_cls.rec_st_shadow
|
|
||||||
ratio = abs(ratio)
|
|
||||||
if ratio > 5:
|
|
||||||
ratio = ratio * 22
|
|
||||||
else:
|
|
||||||
ratio = ratio * 11.5
|
|
||||||
|
|
||||||
width = soft_width = self.width * 1.9
|
|
||||||
height = self.height + dp(ratio)
|
|
||||||
soft_height = self.height + dp(ratio) + dp(self.elevation) * .5
|
|
||||||
else:
|
|
||||||
self._shadow = App.get_running_app().theme_cls.quad_shadow
|
|
||||||
width = soft_width = self.width * 1.8
|
|
||||||
height = soft_height = self.height * 1.8
|
|
||||||
# self._shadow = App.get_running_app().theme_cls.rec_shadow
|
|
||||||
# ratio = abs(ratio)
|
|
||||||
# if ratio > 5:
|
|
||||||
# ratio = ratio * 22
|
|
||||||
# else:
|
|
||||||
# ratio = ratio * 11.5
|
|
||||||
#
|
|
||||||
# width = self.width + dp(ratio)
|
|
||||||
# soft_width = self.width + dp(ratio) + dp(self.elevation) * .9
|
|
||||||
# height = soft_height = self.height * 1.9
|
|
||||||
|
|
||||||
x = self.center_x - width / 2
|
|
||||||
soft_x = self.center_x - soft_width / 2
|
|
||||||
self._soft_shadow_size = (soft_width, soft_height)
|
|
||||||
self._hard_shadow_size = (width, height)
|
|
||||||
|
|
||||||
y = self.center_y - soft_height / 2 - dp(
|
|
||||||
.1 * 1.5 ** self.elevation)
|
|
||||||
self._soft_shadow_pos = (soft_x, y)
|
|
||||||
self._soft_shadow_a = 0.1 * 1.1 ** self.elevation
|
|
||||||
self._soft_shadow_texture = self._shadow.textures[
|
|
||||||
str(int(round(self.elevation - 1)))]
|
|
||||||
|
|
||||||
y = self.center_y - height / 2 - dp(.5 * 1.18 ** self.elevation)
|
|
||||||
self._hard_shadow_pos = (x, y)
|
|
||||||
self._hard_shadow_a = .4 * .9 ** self.elevation
|
|
||||||
self._hard_shadow_texture = self._shadow.textures[
|
|
||||||
str(int(round(self.elevation)))]
|
|
||||||
|
|
||||||
else:
|
|
||||||
self._soft_shadow_a = 0
|
|
||||||
self._hard_shadow_a = 0
|
|
||||||
|
|
||||||
|
|
||||||
class RoundElevationBehavior(object):
|
|
||||||
_elevation = NumericProperty(1)
|
|
||||||
|
|
||||||
def _get_elevation(self):
|
|
||||||
return self._elevation
|
|
||||||
|
|
||||||
def _set_elevation(self, elevation):
|
|
||||||
try:
|
|
||||||
self._elevation = elevation
|
|
||||||
except:
|
|
||||||
self._elevation = 1
|
|
||||||
|
|
||||||
elevation = AliasProperty(_get_elevation, _set_elevation,
|
|
||||||
bind=('_elevation',))
|
|
||||||
|
|
||||||
_soft_shadow_texture = ObjectProperty()
|
|
||||||
_soft_shadow_size = ListProperty([0, 0])
|
|
||||||
_soft_shadow_pos = ListProperty([0, 0])
|
|
||||||
_soft_shadow_a = NumericProperty(0)
|
|
||||||
_hard_shadow_texture = ObjectProperty()
|
|
||||||
_hard_shadow_size = ListProperty([0, 0])
|
|
||||||
_hard_shadow_pos = ListProperty([0, 0])
|
|
||||||
_hard_shadow_a = NumericProperty(0)
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(RoundElevationBehavior, self).__init__(**kwargs)
|
|
||||||
self._shadow = App.get_running_app().theme_cls.round_shadow
|
|
||||||
self.bind(elevation=self._update_shadow,
|
|
||||||
pos=self._update_shadow,
|
|
||||||
size=self._update_shadow)
|
|
||||||
|
|
||||||
def _update_shadow(self, *args):
|
|
||||||
if self.elevation > 0:
|
|
||||||
width = self.width * 2
|
|
||||||
height = self.height * 2
|
|
||||||
|
|
||||||
x = self.center_x - width / 2
|
|
||||||
self._soft_shadow_size = (width, height)
|
|
||||||
|
|
||||||
self._hard_shadow_size = (width, height)
|
|
||||||
|
|
||||||
y = self.center_y - height / 2 - dp(.1 * 1.5 ** self.elevation)
|
|
||||||
self._soft_shadow_pos = (x, y)
|
|
||||||
self._soft_shadow_a = 0.1 * 1.1 ** self.elevation
|
|
||||||
self._soft_shadow_texture = self._shadow.textures[
|
|
||||||
str(int(round(self.elevation)))]
|
|
||||||
|
|
||||||
y = self.center_y - height / 2 - dp(.5 * 1.18 ** self.elevation)
|
|
||||||
self._hard_shadow_pos = (x, y)
|
|
||||||
self._hard_shadow_a = .4 * .9 ** self.elevation
|
|
||||||
self._hard_shadow_texture = self._shadow.textures[
|
|
||||||
str(int(round(self.elevation - 1)))]
|
|
||||||
|
|
||||||
else:
|
|
||||||
self._soft_shadow_a = 0
|
|
||||||
self._hard_shadow_a = 0
|
|