Update resolution and fix format

This commit is contained in:
shekhar-cis 2022-09-12 15:28:53 +05:30
parent ff89064b6c
commit 09cc100424
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
8 changed files with 44 additions and 65 deletions

View File

@ -1,3 +1,4 @@
#!/bin/bash #!/bin/bash
export INSTALL_TESTS=True
xvfb-run --server-args="-screen 0, 720x1280x24" python3 tests-kivy.py xvfb-run --server-args="-screen 0, 720x1280x24" python3 tests-kivy.py

View File

@ -84,7 +84,7 @@ if __name__ == "__main__":
) )
if os.environ.get('INSTALL_TESTS', False): if os.environ.get('INSTALL_TESTS', False):
packages.extend(['pybitmessage.mock', 'pybitmessage.backend']) packages.extend(['pybitmessage.mock', 'pybitmessage.backend', 'pybitmessage.bitmessagekivy.tests'])
# this will silently accept alternative providers of msgpack # this will silently accept alternative providers of msgpack
# if they are already installed # if they are already installed

View File

@ -2,9 +2,9 @@
Common methods and functions for kivy and qt. Common methods and functions for kivy and qt.
""" """
import queues from pybitmessage import queues
from bmconfigparser import config from pybitmessage.bmconfigparser import config
from defaults import ( from pybitmessage.defaults import (
networkDefaultProofOfWorkNonceTrialsPerByte, networkDefaultProofOfWorkNonceTrialsPerByte,
networkDefaultPayloadLengthExtraBytes networkDefaultPayloadLengthExtraBytes
) )

View File

@ -212,12 +212,6 @@ MDNavigationLayout:
id:sc6 id:sc6
Random: Random:
id:id_newidentity id:id_newidentity
Payment:
id:id_payment
MailDetail:
id:sc14
ShowQRCode:
id:id_showqrcode
MDNavigationDrawer: MDNavigationDrawer:
id: nav_drawer id: nav_drawer

View File

@ -1,6 +1,6 @@
# pylint: disable=unused-import, too-many-public-methods, unused-variable, too-many-ancestors # pylint: disable=too-many-public-methods, unused-variable, too-many-ancestors
# pylint: disable=no-name-in-module, too-few-public-methods, import-error, unused-argument # pylint: disable=no-name-in-module, too-few-public-methods, unused-argument
# pylint: disable=attribute-defined-outside-init, global-variable-not-assigned, too-many-instance-attributes # pylint: disable=attribute-defined-outside-init, too-many-instance-attributes
""" """
Bitmessage android(mobile) interface Bitmessage android(mobile) interface
@ -10,6 +10,7 @@ import os
import logging import logging
import sys import sys
from functools import partial from functools import partial
from PIL import Image as PilImage
from kivy.clock import Clock from kivy.clock import Clock
from kivy.lang import Builder from kivy.lang import Builder
@ -39,6 +40,7 @@ from pybitmessage.bitmessagekivy.baseclass.common import toast, load_image_path,
from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json
from pybitmessage.bitmessagekivy.baseclass.popup import AddAddressPopup from pybitmessage.bitmessagekivy.baseclass.popup import AddAddressPopup
from pybitmessage.bitmessagekivy.baseclass.login import * # noqa: F401, F403
logger = logging.getLogger('default') logger = logging.getLogger('default')
@ -90,8 +92,13 @@ class NavigateApp(MDApp):
window_size = kivy_state.screen_density window_size = kivy_state.screen_density
tr = Lang("en") # for changing in franch replace en with fr tr = Lang("en") # for changing in franch replace en with fr
if os.environ.get('INSTALL_TESTS', False):
# Set kivy app resolution while running kivy tests
window_size = (720, 1280)
def __init__(self): def __init__(self):
super(NavigateApp, self).__init__() super(NavigateApp, self).__init__()
# workaround for relative imports
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
self.data_screens, self.all_data, self.data_screen_dict, response = load_screen_json() self.data_screens, self.all_data, self.data_screen_dict, response = load_screen_json()
self.kivy_state_obj = KivyStateVariables() self.kivy_state_obj = KivyStateVariables()
@ -164,18 +171,12 @@ class NavigateApp(MDApp):
def savecontact(self, instance): def savecontact(self, instance):
"""Method is used for saving contacts""" """Method is used for saving contacts"""
pupup_obj = self.add_popup.content_cls popup_obj = self.add_popup.content_cls
label = pupup_obj.ids.label.text.strip() label = popup_obj.ids.label.text.strip()
address = pupup_obj.ids.address.text.strip() address = popup_obj.ids.address.text.strip()
if label == '' and address == '': popup_obj.ids.label.focus = not label
pupup_obj.ids.label.focus = True # default focus on address field
pupup_obj.ids.address.focus = True popup_obj.ids.address.focus = label or not address
elif address == '':
pupup_obj.ids.address.focus = True
elif label == '':
pupup_obj.ids.label.focus = True
else:
pupup_obj.ids.address.focus = True
def close_pop(self, instance): def close_pop(self, instance):
"""Close the popup""" """Close the popup"""
@ -233,6 +234,7 @@ class NavigateApp(MDApp):
self.file_manager.previous = False self.file_manager.previous = False
self.file_manager.current_path = '/' self.file_manager.current_path = '/'
if platform == 'android': if platform == 'android':
# pylint: disable=import-error
from android.permissions import request_permissions, Permission, check_permission from android.permissions import request_permissions, Permission, check_permission
if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \ if check_permission(Permission.WRITE_EXTERNAL_STORAGE) and \
check_permission(Permission.READ_EXTERNAL_STORAGE): check_permission(Permission.READ_EXTERNAL_STORAGE):
@ -247,21 +249,21 @@ class NavigateApp(MDApp):
def select_path(self, path): def select_path(self, path):
"""This method is used to set the select image""" """This method is used to set the select image"""
try: try:
from PIL import Image as PilImage
newImg = PilImage.open(path).resize((300, 300)) newImg = PilImage.open(path).resize((300, 300))
if platform == 'android': if platform == 'android':
android_path = os.path.join( android_path = os.path.join(
os.environ['ANDROID_PRIVATE'] + '/app' + '/images' + '/kivy/') os.path.join(os.environ['ANDROID_PRIVATE'], 'app', 'images', 'kivy')
if not os.path.exists(android_path + '/default_identicon/'): )
os.makedirs(android_path + '/default_identicon/') if not os.path.exists(os.path.join(android_path, 'default_identicon')):
newImg.save('{1}/default_identicon/{0}.png'.format( os.makedirs(os.path.join(android_path, 'default_identicon'))
self.kivy_state_obj.association, android_path) newImg.save(os.path.join(android_path, 'default_identicon', '{}.png'.format(
self.kivy_state_obj.association))
) )
else: else:
if not os.path.exists(self.image_dir + '/default_identicon/'): if not os.path.exists(os.path.join(self.image_dir, 'default_identicon')):
os.makedirs(self.image_dir + '/default_identicon/') os.makedirs(os.path.join(self.image_dir, 'default_identicon'))
newImg.save(self.image_dir + '/default_identicon/{0}.png'.format( newImg.save(os.path.join(self.image_dir, 'default_identicon', '{0}.png'.format(
self.kivy_state_obj.association) self.kivy_state_obj.association))
) )
self.load_selected_Image(self.kivy_state_obj.association) self.load_selected_Image(self.kivy_state_obj.association)
toast('Image changed') toast('Image changed')
@ -277,7 +279,7 @@ class NavigateApp(MDApp):
def load_selected_Image(self, curerentAddr): def load_selected_Image(self, curerentAddr):
"""This method load the selected image on screen""" """This method load the selected image on screen"""
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0] top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
top_box_obj.source = self.image_dir + '/default_identicon/{0}.png'.format(curerentAddr) top_box_obj.source = os.path.join(self.image_dir, 'default_identicon', '{0}.png'.format(curerentAddr))
self.root.ids.content_drawer.ids.reset_image.opacity = 1 self.root.ids.content_drawer.ids.reset_image.opacity = 1
self.root.ids.content_drawer.ids.reset_image.disabled = False self.root.ids.content_drawer.ids.reset_image.disabled = False
top_box_obj.reload() top_box_obj.reload()
@ -285,8 +287,8 @@ class NavigateApp(MDApp):
def rest_default_avatar_img(self): def rest_default_avatar_img(self):
"""set default avatar generated image""" """set default avatar generated image"""
self.set_identicon(self.kivy_state_obj.association) self.set_identicon(self.kivy_state_obj.association)
img_path = self.image_dir + '/default_identicon/{}.png'.format( img_path = os.path.join(
self.kivy_state_obj.association self.image_dir, 'default_identicon', '{}.png'.format(self.kivy_state_obj.association)
) )
try: try:
if os.path.exists(img_path): if os.path.exists(img_path):
@ -303,14 +305,18 @@ class NavigateApp(MDApp):
first_addr = self.identity_list[0] first_addr = self.identity_list[0]
if config.getboolean(str(first_addr), 'enabled'): if config.getboolean(str(first_addr), 'enabled'):
if os.path.exists( if os.path.exists(
self.image_dir + '/default_identicon/{}.png'.format(first_addr) os.path.join(
self.image_dir, 'default_identicon', '{}.png'.format(first_addr)
)
): ):
return self.image_dir + '/default_identicon/{}.png'.format(first_addr) return os.path.join(
self.image_dir, 'default_identicon', '{}.png'.format(first_addr)
)
else: else:
img = identiconGeneration.generate(first_addr) img = identiconGeneration.generate(first_addr)
instance.texture = img.texture instance.texture = img.texture
return return
return self.image_dir + '/drawer_logo1.png' return os.path.join(self.image_dir, 'drawer_logo1.png')
def reset_login_screen(self): def reset_login_screen(self):
"""This method is used for clearing the widgets of random screen""" """This method is used for clearing the widgets of random screen"""
@ -334,5 +340,4 @@ class PaymentMethodLayout(BoxLayout):
if __name__ == '__main__': if __name__ == '__main__':
# workaround for relative imports
NavigateApp().run() NavigateApp().run()

View File

@ -1,25 +1,6 @@
{ {
"Address Book": {
"kv_string": "addressbook",
"name_screen": "addressbook",
"Import": "from pybitmessage.bitmessagekivy.baseclass.addressbook import AddressBook"
},
"Payment": {
"kv_string": "payment",
"name_screen": "payment",
"Import": "from pybitmessage.bitmessagekivy.baseclass.payment import Payment"
},
"MailDetail": {
"kv_string": "maildetail",
"name_screen": "mailDetail",
"Import": "from pybitmessage.bitmessagekivy.baseclass.maildetail import MailDetail"
},
"Login": { "Login": {
"kv_string": "login", "kv_string": "login",
"Import": "from pybitmessage.bitmessagekivy.baseclass.login import *" "Import": "from pybitmessage.bitmessagekivy.baseclass.login import *"
},
"Qrcode": {
"kv_string": "qrcode",
"Import": "from pybitmessage.bitmessagekivy.baseclass.qrcode import ShowQRCode"
} }
} }

View File

@ -1,21 +1,18 @@
import unittest import unittest
from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json
from .common import skip_screen_checks
from .common import ordered from .common import ordered
class TestLoadScreenData(unittest.TestCase): class TestLoadScreenData(unittest.TestCase):
"""Screen Data Json test""" """Screen Data Json test"""
@skip_screen_checks
@ordered @ordered
def test_load_json(self): def test_load_json(self):
"""Test to load a valid json""" """Test to load a valid json"""
loaded_screen_names = load_screen_json() loaded_screen_names = load_screen_json()
self.assertEqual(loaded_screen_names[2], 'success') self.assertEqual(loaded_screen_names[3], 'success')
@skip_screen_checks
@ordered @ordered
def test_load_invalid_file(self): def test_load_invalid_file(self):
"""Test to load an invalid json""" """Test to load an invalid json"""

View File

@ -35,6 +35,7 @@ if __name__ == "__main__":
]) ])
sleep(2) # let ffmpeg start sleep(2) # let ffmpeg start
result = unittest.TextTestRunner(verbosity=2).run(unittest_discover()) result = unittest.TextTestRunner(verbosity=2).run(unittest_discover())
sleep(1)
if in_docker: if in_docker:
ffmpeg.terminate() ffmpeg.terminate()
try: try: