1- # pylint: disable=unused-import, too-many-public-methods, unused-variable, too-many-ancestors
2- # pylint: disable=no-name-in-module, too-few-public-methods, import-error, unused-argument
3- # pylint: disable=attribute-defined-outside-init, global-variable-not-assigned, too-many-instance-attributes
1+ # pylint: disable=too-many-public-methods, unused-variable, too-many-ancestors
2+ # pylint: disable=no-name-in-module, too-few-public-methods, unused-argument
3+ # pylint: disable=attribute-defined-outside-init, too-many-instance-attributes
44
55"""
66Bitmessage android(mobile) interface
1010import logging
1111import sys
1212from functools import partial
13+ from PIL import Image as PilImage
1314
1415from kivy .clock import Clock
1516from kivy .lang import Builder
3940from pybitmessage .bitmessagekivy .load_kivy_screens_data import load_screen_json
4041
4142from pybitmessage .bitmessagekivy .baseclass .popup import AddAddressPopup
43+ from pybitmessage .bitmessagekivy .baseclass .login import * # noqa: F401, F403
4244
4345logger = logging .getLogger ('default' )
4446
@@ -90,8 +92,13 @@ class NavigateApp(MDApp):
9092 window_size = kivy_state .screen_density
9193 tr = Lang ("en" ) # for changing in franch replace en with fr
9294
95+ if os .environ .get ('INSTALL_TESTS' , False ):
96+ # Set kivy app resolution while running kivy tests
97+ window_size = (720 , 1280 )
98+
9399 def __init__ (self ):
94100 super (NavigateApp , self ).__init__ ()
101+ # workaround for relative imports
95102 sys .path .append (os .path .join (os .path .dirname (os .path .abspath (__file__ )), '..' ))
96103 self .data_screens , self .all_data , self .data_screen_dict , response = load_screen_json ()
97104 self .kivy_state_obj = KivyStateVariables ()
@@ -164,18 +171,12 @@ def is_camara_attached(self):
164171
165172 def savecontact (self , instance ):
166173 """Method is used for saving contacts"""
167- pupup_obj = self .add_popup .content_cls
168- label = pupup_obj .ids .label .text .strip ()
169- address = pupup_obj .ids .address .text .strip ()
170- if label == '' and address == '' :
171- pupup_obj .ids .label .focus = True
172- pupup_obj .ids .address .focus = True
173- elif address == '' :
174- pupup_obj .ids .address .focus = True
175- elif label == '' :
176- pupup_obj .ids .label .focus = True
177- else :
178- pupup_obj .ids .address .focus = True
174+ popup_obj = self .add_popup .content_cls
175+ label = popup_obj .ids .label .text .strip ()
176+ address = popup_obj .ids .address .text .strip ()
177+ popup_obj .ids .label .focus = not label
178+ # default focus on address field
179+ popup_obj .ids .address .focus = label or not address
179180
180181 def close_pop (self , instance ):
181182 """Close the popup"""
@@ -233,6 +234,7 @@ def file_manager_open(self):
233234 self .file_manager .previous = False
234235 self .file_manager .current_path = '/'
235236 if platform == 'android' :
237+ # pylint: disable=import-error
236238 from android .permissions import request_permissions , Permission , check_permission
237239 if check_permission (Permission .WRITE_EXTERNAL_STORAGE ) and \
238240 check_permission (Permission .READ_EXTERNAL_STORAGE ):
@@ -247,21 +249,21 @@ def file_manager_open(self):
247249 def select_path (self , path ):
248250 """This method is used to set the select image"""
249251 try :
250- from PIL import Image as PilImage
251252 newImg = PilImage .open (path ).resize ((300 , 300 ))
252253 if platform == 'android' :
253254 android_path = os .path .join (
254- os .environ ['ANDROID_PRIVATE' ] + '/app' + '/images' + '/kivy/' )
255- if not os .path .exists (android_path + '/default_identicon/' ):
256- os .makedirs (android_path + '/default_identicon/' )
257- newImg .save ('{1}/default_identicon/{0}.png' .format (
258- self .kivy_state_obj .association , android_path )
255+ os .path .join (os .environ ['ANDROID_PRIVATE' ], 'app' , 'images' , 'kivy' )
256+ )
257+ if not os .path .exists (os .path .join (android_path , 'default_identicon' )):
258+ os .makedirs (os .path .join (android_path , 'default_identicon' ))
259+ newImg .save (os .path .join (android_path , 'default_identicon' , '{}.png' .format (
260+ self .kivy_state_obj .association ))
259261 )
260262 else :
261- if not os .path .exists (self .image_dir + '/ default_identicon/' ):
262- os .makedirs (self .image_dir + '/ default_identicon/' )
263- newImg .save (self .image_dir + '/ default_identicon/ {0}.png' .format (
264- self .kivy_state_obj .association )
263+ if not os .path .exists (os . path . join ( self .image_dir , ' default_identicon' ) ):
264+ os .makedirs (os . path . join ( self .image_dir , ' default_identicon' ) )
265+ newImg .save (os . path . join ( self .image_dir , ' default_identicon' , ' {0}.png' .format (
266+ self .kivy_state_obj .association ))
265267 )
266268 self .load_selected_Image (self .kivy_state_obj .association )
267269 toast ('Image changed' )
@@ -277,16 +279,16 @@ def exit_manager(self, *args):
277279 def load_selected_Image (self , curerentAddr ):
278280 """This method load the selected image on screen"""
279281 top_box_obj = self .root .ids .content_drawer .ids .top_box .children [0 ]
280- top_box_obj .source = self .image_dir + '/ default_identicon/ {0}.png' .format (curerentAddr )
282+ top_box_obj .source = os . path . join ( self .image_dir , ' default_identicon' , ' {0}.png' .format (curerentAddr ) )
281283 self .root .ids .content_drawer .ids .reset_image .opacity = 1
282284 self .root .ids .content_drawer .ids .reset_image .disabled = False
283285 top_box_obj .reload ()
284286
285287 def rest_default_avatar_img (self ):
286288 """set default avatar generated image"""
287289 self .set_identicon (self .kivy_state_obj .association )
288- img_path = self . image_dir + '/default_identicon/{}.png' . format (
289- self .kivy_state_obj .association
290+ img_path = os . path . join (
291+ self .image_dir , 'default_identicon' , '{}.png' . format ( self . kivy_state_obj .association )
290292 )
291293 try :
292294 if os .path .exists (img_path ):
@@ -303,14 +305,18 @@ def get_default_logo(self, instance):
303305 first_addr = self .identity_list [0 ]
304306 if config .getboolean (str (first_addr ), 'enabled' ):
305307 if os .path .exists (
306- self .image_dir + '/default_identicon/{}.png' .format (first_addr )
308+ os .path .join (
309+ self .image_dir , 'default_identicon' , '{}.png' .format (first_addr )
310+ )
307311 ):
308- return self .image_dir + '/default_identicon/{}.png' .format (first_addr )
312+ return os .path .join (
313+ self .image_dir , 'default_identicon' , '{}.png' .format (first_addr )
314+ )
309315 else :
310316 img = identiconGeneration .generate (first_addr )
311317 instance .texture = img .texture
312318 return
313- return self .image_dir + '/ drawer_logo1.png'
319+ return os . path . join ( self .image_dir , ' drawer_logo1.png')
314320
315321 def reset_login_screen (self ):
316322 """This method is used for clearing the widgets of random screen"""
@@ -334,5 +340,4 @@ class PaymentMethodLayout(BoxLayout):
334340
335341
336342if __name__ == '__main__' :
337- # workaround for relative imports
338343 NavigateApp ().run ()
0 commit comments