This commit is contained in:
surbhi 2025-02-21 18:05:55 +00:00
parent f53d4aa7d0
commit 4d42308924
Signed by untrusted user: surbhi
GPG Key ID: BD938EA4D030869A
4 changed files with 36 additions and 27 deletions

View File

@ -55,13 +55,13 @@ class Random(Screen):
toast('Creating New Address ...')
self.parent.parent.ids.toolbar.opacity = 1
self.parent.parent.ids.toolbar.disabled = False
App.get_running_app().loadMyAddressScreen(True)
App.get_running_app().load_my_address_screen(True)
self.manager.current = 'myaddress'
Clock.schedule_once(self.address_created_callback, 6)
def address_created_callback(self, dt=0):
"""New address created"""
App.get_running_app().loadMyAddressScreen(False)
App.get_running_app().load_my_address_screen(False)
App.get_running_app().root.ids.id_myaddress.ids.ml.clear_widgets()
App.get_running_app().root.ids.id_myaddress.is_add_created = True
App.get_running_app().root.ids.id_myaddress.init_ui()

View File

@ -26,7 +26,7 @@ class ShowQRCode(Screen):
def qrdisplay(self, instance, address):
"""Method used for showing QR Code"""
self.ids.qr.clear_widgets()
self.kivy_running_app.set_toolbar_for_QrCode()
self.kivy_running_app.set_toolbar_for_qr_code()
self.address = address # used for label
self.ids.qr.add_widget(QRCodeWidget(data=self.address))
self.ids.qr.children[0].show_border = False

View File

@ -115,11 +115,11 @@
name: "identity_dropdown"
option_cls: Factory.get("MySpinnerOption")
font_size: '12.5sp'
text: app.getDefaultAccData(self)
text: app.get_default_account_data(self)
color: color_font
background_normal: ''
background_color: app.theme_cls.primary_color
on_text: app.getCurrentAccountData(self.text)
on_text: app.get_current_account_data(self.text)
ArrowImg:
NavigationItem:
id: inbox_cnt

View File

@ -1,6 +1,7 @@
# pylint: disable=too-many-public-methods, unused-variable, too-many-ancestors
# pylint: disable=no-name-in-module, too-few-public-methods, unused-argument
# pylint: disable=too-few-public-methods, unused-argument
# pylint: disable=attribute-defined-outside-init, too-many-instance-attributes
# pylint: disable=broad-exception-caught, no-self-use
"""
Bitmessage android(mobile) interface
@ -43,7 +44,6 @@ from pybitmessage.bitmessagekivy.load_kivy_screens_data import load_screen_json
from pybitmessage.bitmessagekivy.baseclass.popup import (
AddAddressPopup, AppClosingPopup, AddressChangingLoader
)
from pybitmessage.bitmessagekivy.baseclass.login import * # noqa: F401, F403
from pybitmessage.bitmessagekivy.uikivysignaler import UIkivySignaler
from pybitmessage.mockbm.helper_startup import loadConfig, total_encrypted_messages_per_month
@ -167,7 +167,9 @@ class NavigateApp(MDApp):
self.root.ids.scr_mngr.current = 'scanscreen'
else:
alert_text = (
'Currently this feature is not avaialbe!' if platform == 'android' else 'Camera is not available!')
'Currently this feature is not avaialbe!'
if platform == 'android'
else 'Camera is not available!')
self.add_popup.dismiss()
toast(alert_text)
@ -191,8 +193,8 @@ class NavigateApp(MDApp):
self.add_popup.dismiss()
toast('Canceled')
def loadMyAddressScreen(self, action):
"""loadMyAddressScreen method spin the loader"""
def load_my_address_screen(self, action):
"""load_my_address_screen method spin the loader"""
if len(self.root.ids.id_myaddress.children) <= 2:
self.root.ids.id_myaddress.children[0].active = action
else:
@ -262,20 +264,20 @@ class NavigateApp(MDApp):
NavigateApp.format_address(address)
)
def getDefaultAccData(self, instance):
def get_default_account_data(self, instance):
"""Getting Default Account Data"""
if self.identity_list:
self.kivy_state_obj.selected_address = first_addr = self.identity_list[0]
return first_addr
return 'Select Address'
def getCurrentAccountData(self, text):
def get_current_account_data(self, text):
"""Get Current Address Account Data"""
if text != '':
if os.path.exists(os.path.join(
self.image_dir, 'default_identicon', '{}.png'.format(text))
):
self.load_selected_Image(text)
self.load_selected_image(text)
else:
self.set_identicon(text)
self.root.ids.content_drawer.ids.reset_image.opacity = 0
@ -287,10 +289,10 @@ class NavigateApp(MDApp):
for nav_obj in self.root.ids.content_drawer.children[
0].children[0].children[0].children:
nav_obj.active = True if nav_obj.text == 'Inbox' else False
self.fileManagerSetting()
Clock.schedule_once(self.setCurrentAccountData, 0.5)
self.file_manager_setting()
Clock.schedule_once(self.set_current_account_data, 0.5)
def setCurrentAccountData(self, dt=0):
def set_current_account_data(self, dt=0):
"""This method set the current accout data on all the screens"""
self.root.ids.id_inbox.ids.ml.clear_widgets()
self.root.ids.id_inbox.loadMessagelist(self.kivy_state_obj.selected_address)
@ -299,7 +301,7 @@ class NavigateApp(MDApp):
self.root.ids.id_sent.children[2].children[2].ids.search_field.text = ''
self.root.ids.id_sent.loadSent(self.kivy_state_obj.selected_address)
def fileManagerSetting(self):
def file_manager_setting(self):
"""This method is for file manager setting"""
if not self.root.ids.content_drawer.ids.file_manager.opacity and \
self.root.ids.content_drawer.ids.file_manager.disabled:
@ -336,7 +338,7 @@ class NavigateApp(MDApp):
def set_identicon(self, text):
"""Show identicon in address spinner"""
img = identiconGeneration.generate(text)
self.root.ids.content_drawer.ids.top_box.children[0].texture = (img.texture)
self.root.ids.content_drawer.ids.top_box.children[0].texture = img.texture
# pylint: disable=import-outside-toplevel
def file_manager_open(self):
@ -357,7 +359,9 @@ class NavigateApp(MDApp):
self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
self.kivy_state_obj.manager_open = True
else:
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
request_permissions(
[Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE]
)
else:
self.file_manager.show(os.environ["HOME"])
self.kivy_state_obj.manager_open = True
@ -365,23 +369,23 @@ class NavigateApp(MDApp):
def select_path(self, path):
"""This method is used to set the select image"""
try:
newImg = PilImage.open(path).resize((300, 300))
new_image = PilImage.open(path).resize((300, 300))
if platform == 'android':
android_path = os.path.join(
os.path.join(os.environ['ANDROID_PRIVATE'], 'app', 'images', 'kivy')
)
if not os.path.exists(os.path.join(android_path, 'default_identicon')):
os.makedirs(os.path.join(android_path, 'default_identicon'))
newImg.save(os.path.join(android_path, 'default_identicon', '{}.png'.format(
new_image.save(os.path.join(android_path, 'default_identicon', '{}.png'.format(
self.kivy_state_obj.selected_address))
)
else:
if not os.path.exists(os.path.join(self.image_dir, 'default_identicon')):
os.makedirs(os.path.join(self.image_dir, 'default_identicon'))
newImg.save(os.path.join(self.image_dir, 'default_identicon', '{0}.png'.format(
new_image.save(os.path.join(self.image_dir, 'default_identicon', '{0}.png'.format(
self.kivy_state_obj.selected_address))
)
self.load_selected_Image(self.kivy_state_obj.selected_address)
self.load_selected_image(self.kivy_state_obj.selected_address)
toast('Image changed')
except Exception:
toast('Exit')
@ -392,10 +396,14 @@ class NavigateApp(MDApp):
self.kivy_state_obj.manager_open = False
self.file_manager.close()
def load_selected_Image(self, curerentAddr):
def load_selected_image(self, curerent_addr):
"""This method load the selected image on screen"""
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
top_box_obj.source = os.path.join(self.image_dir, 'default_identicon', '{0}.png'.format(curerentAddr))
top_box_obj.source = os.path.join(
self.image_dir,
'default_identicon',
'{0}.png'.format(curerent_addr)
)
self.root.ids.content_drawer.ids.reset_image.opacity = 1
self.root.ids.content_drawer.ids.reset_image.disabled = False
top_box_obj.reload()
@ -404,7 +412,8 @@ class NavigateApp(MDApp):
"""set default avatar generated image"""
self.set_identicon(self.kivy_state_obj.selected_address)
img_path = os.path.join(
self.image_dir, 'default_identicon', '{}.png'.format(self.kivy_state_obj.selected_address)
self.image_dir, 'default_identicon',
'{}.png'.format(self.kivy_state_obj.selected_address)
)
if os.path.exists(img_path):
os.remove(img_path)
@ -456,7 +465,7 @@ class NavigateApp(MDApp):
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
self.kivy_state.in_composer = False
def set_toolbar_for_QrCode(self):
def set_toolbar_for_qr_code(self):
"""This method is use for setting Qr code toolbar."""
self.root.ids.toolbar.left_action_items = [
['arrow-left', lambda x: self.back_press()]]