Added lazy-loader for complex views

This commit is contained in:
Mark Qvist 2023-10-31 21:41:15 +01:00
parent d870585178
commit ef7dd1e2f2
3 changed files with 528 additions and 135 deletions

View File

@ -61,8 +61,8 @@ if args.daemon:
class DaemonApp():
pass
MDApp = DaemonApp; OneLineIconListItem = DaemonElement; Window = DaemonElement; Clipboard = DaemonElement
EventLoop = DaemonElement; Clock = DaemonElement; Builder = DaemonElement; ScrollEffect = DaemonElement;
MDApp = DaemonApp; OneLineIconListItem = DaemonElement; Window = DaemonElement; Clipboard = DaemonElement;
EventLoop = DaemonElement; Clock = DaemonElement; Builder = DaemonElement; ScrollEffect = DaemonElement; SlideTransition = DaemonElement;
ScreenManager = DaemonElement; FadeTransition = DaemonElement; NoTransition = DaemonElement; OneLineIconListItem = DaemonElement;
StringProperty = DaemonElement; BaseButton = DaemonElement; MDIconButton = DaemonElement; MDFileManager = DaemonElement;
toast = DaemonElement; dp = DaemonElement; sp = DaemonElement; MDRectangleFlatButton = DaemonElement; MDDialog = DaemonElement;
@ -82,7 +82,7 @@ else:
from kivy.lang.builder import Builder
from kivy.effects.scroll import ScrollEffect
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.screenmanager import FadeTransition, NoTransition
from kivy.uix.screenmanager import FadeTransition, NoTransition, SlideTransition
from kivymd.uix.list import OneLineIconListItem
from kivy.properties import StringProperty
from kivymd.uix.button import BaseButton, MDIconButton
@ -140,6 +140,14 @@ if RNS.vendor.platformutils.get_platform() == "android":
from jnius import autoclass
from android.runnable import run_on_ui_thread
TRANSITION_DURATION = 0.25
if RNS.vendor.platformutils.is_android():
ll_ot = 0.55
ll_ft = 0.275
else:
ll_ot = 0.4
ll_ft = 0.275
class SidebandApp(MDApp):
STARTING = 0x00
ACTIVE = 0x01
@ -161,6 +169,9 @@ class SidebandApp(MDApp):
self.app_dir = plyer.storagepath.get_application_dir()
self.shaders_disabled = __disable_shaders__
self.no_transition = NoTransition()
self.slide_transition = SlideTransition()
if RNS.vendor.platformutils.get_platform() == "android":
self.sideband = SidebandCore(self, is_client=True, android_app_dir=self.app_dir, verbose=__debug_build__)
else:
@ -260,12 +271,14 @@ class SidebandApp(MDApp):
# Pre-load announce stream widgets
self.update_loading_text()
self.init_announces_view()
self.announces_view.update()
# self.telemetry_init()
# self.settings_init()
self.connectivity_init()
self.object_details_screen = ObjectDetails(self)
self.loader_init()
if not RNS.vendor.platformutils.is_android():
self.telemetry_init()
self.settings_init()
self.information_init()
self.object_details_screen = None
# Wait a little extra for user to react to permissions prompt
# if RNS.vendor.platformutils.get_platform() == "android":
@ -743,7 +756,8 @@ class SidebandApp(MDApp):
def on_start(self):
self.last_exit_event = time.time()
self.root.ids.screen_manager.transition.duration = 0.25
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.duration = TRANSITION_DURATION
self.root.ids.screen_manager.transition.bind(on_complete=self.screen_transition_complete)
EventLoop.window.bind(on_keyboard=self.keyboard_event)
@ -906,6 +920,21 @@ class SidebandApp(MDApp):
except Exception as e:
RNS.log("An error occurred while handling clipboard action: "+str(e), RNS.LOG_ERROR)
def loader_init(self, sender=None):
if not self.root.ids.screen_manager.has_screen("loader_screen"):
self.loader_screen = Builder.load_string(layout_loader_screen)
self.root.ids.screen_manager.add_widget(self.loader_screen)
def loader_action(self, target=None, direction="left"):
if not self.root.ids.screen_manager.has_screen("loader_screen"):
self.loader_init()
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "loader_screen"
self.root.ids.nav_drawer.set_state("closed")
def quit_action(self, sender):
self.root.ids.nav_drawer.set_state("closed")
self.sideband.should_persist_data()
@ -1189,9 +1218,18 @@ class SidebandApp(MDApp):
### Conversations screen
######################################
def conversations_action(self, sender=None, direction="left"):
def conversations_action(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.open_conversations(direction=direction)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def open_conversations(self, direction="left"):
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.nav_drawer.set_state("closed")
@ -1442,7 +1480,19 @@ class SidebandApp(MDApp):
### Information/version screen
######################################
def information_action(self, sender=None):
def information_action(self, sender=None, direction="left"):
if self.root.ids.screen_manager.has_screen("information_screen"):
self.information_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.information_init()
def o(dt):
self.information_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def information_init(self):
if not self.root.ids.screen_manager.has_screen("information_screen"):
self.information_screen = Builder.load_string(layout_information_screen)
self.information_screen.app = self
@ -1459,6 +1509,8 @@ class SidebandApp(MDApp):
info = "This is Sideband v"+__version__+" "+__variant__+", on RNS v"+RNS.__version__+" and LXMF v"+LXMF.__version__+".\n\nHumbly build using the following open components:\n\n - [b]Reticulum[/b] (MIT License)\n - [b]LXMF[/b] (MIT License)\n - [b]KivyMD[/b] (MIT License)\n - [b]Kivy[/b] (MIT License)\n - [b]Python[/b] (PSF License)"+"\n\nGo to [u][ref=link]https://unsigned.io/donate[/ref][/u] to support the project.\n\nThe Sideband app is Copyright (c) 2022 Mark Qvist / unsigned.io\n\nPermission is granted to freely share and distribute binary copies of Sideband v"+__version__+" "+__variant__+", so long as no payment or compensation is charged for said distribution or sharing.\n\nIf you were charged or paid anything for this copy of Sideband, please report it to [b]license@unsigned.io[/b].\n\nTHIS IS EXPERIMENTAL SOFTWARE - SIDEBAND COMES WITH ABSOLUTELY NO WARRANTY - USE AT YOUR OWN RISK AND RESPONSIBILITY"
self.information_screen.ids.information_info.text = info
self.information_screen.ids.information_info.bind(on_ref_press=link_exec)
def information_open(self, sender=None, direction="left", no_transition=False):
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "information_screen"
self.root.ids.nav_drawer.set_state("closed")
@ -1470,15 +1522,34 @@ class SidebandApp(MDApp):
### Settings screen
######################################
def settings_action(self, sender=None):
self.settings_init()
self.root.ids.screen_manager.transition.direction = "left"
def settings_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.nav_drawer.set_state("closed")
if self.sideband.active_propagation_node != None:
self.settings_screen.ids.settings_propagation_node_address.text = RNS.hexrep(self.sideband.active_propagation_node, delimit=False)
self.root.ids.screen_manager.current = "settings_screen"
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def settings_action(self, sender=None, direction="left"):
if self.settings_ready:
self.settings_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.settings_init()
def o(dt):
self.settings_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def interval_to_slider_val(self, interval):
try:
mseg = 72; hseg = 84; sv = 0
@ -1736,13 +1807,34 @@ class SidebandApp(MDApp):
### Connectivity screen
######################################
def connectivity_action(self, sender=None):
def connectivity_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.nav_drawer.set_state("closed")
self.connectivity_init()
self.root.ids.screen_manager.current = "connectivity_screen"
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def connectivity_action(self, sender=None, direction="left"):
if self.root.ids.screen_manager.has_screen("connectivity_screen"):
self.connectivity_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.connectivity_init()
def o(dt):
self.connectivity_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def connectivity_init(self, sender=None):
if not self.connectivity_ready:
if not self.root.ids.screen_manager.has_screen("connectivity_screen"):
@ -2071,19 +2163,32 @@ class SidebandApp(MDApp):
### Repository screen
######################################
def repository_action(self, sender=None, direction="left"):
if self.repository_ready:
self.repository_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.repository_init()
def o(dt):
self.repository_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def repository_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.repository_screen.ids.repository_update.text = ""
self.root.ids.screen_manager.current = "repository_screen"
self.root.ids.nav_drawer.set_state("closed")
if not RNS.vendor.platformutils.is_android():
self.widget_hide(self.repository_screen.ids.repository_enable_button)
self.widget_hide(self.repository_screen.ids.repository_disable_button)
self.widget_hide(self.repository_screen.ids.repository_download_button)
self.repository_screen.ids.repository_info.text = "\nThe [b]Repository Webserver[/b] feature is currently only available on mobile devices."
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def repository_link_action(self, sender=None, event=None):
if self.reposository_url != None:
def lj():
@ -2211,7 +2316,12 @@ class SidebandApp(MDApp):
self.repository_update_info()
self.repository_screen.ids.repository_update.text = ""
if not RNS.vendor.platformutils.is_android():
self.widget_hide(self.repository_screen.ids.repository_enable_button)
self.widget_hide(self.repository_screen.ids.repository_disable_button)
self.widget_hide(self.repository_screen.ids.repository_download_button)
self.repository_screen.ids.repository_info.text = "\nThe [b]Repository Webserver[/b] feature is currently only available on mobile devices."
self.repository_ready = True
def close_repository_action(self, sender=None):
@ -2220,12 +2330,33 @@ class SidebandApp(MDApp):
### Hardware screen
######################################
def hardware_action(self, sender=None, direction="left"):
if self.hardware_ready:
self.hardware_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.hardware_init()
def o(dt):
self.hardware_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def hardware_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.hardware_init()
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "hardware_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def close_sub_hardware_action(self, sender=None):
self.hardware_action(direction="right")
@ -2243,14 +2374,6 @@ class SidebandApp(MDApp):
self.widget_hide(self.hardware_screen.ids.hardware_modem_button)
self.widget_hide(self.hardware_screen.ids.hardware_serial_button)
# def con_collapse_local(collapse=True):
# self.widget_hide(self.root.ids.connectivity_local_fields, collapse)
# def save_connectivity(sender=None, event=None):
# # self.sideband.config["connect_local"] = self.root.ids.connectivity_use_local.active
# con_collapse_local(collapse=not self.root.ids.connectivity_use_local.active)
# self.sideband.save_configuration()
if RNS.vendor.platformutils.get_platform() == "android":
if not self.sideband.getpersistent("service.is_controlling_connectivity"):
info = "Sideband is connected via a shared Reticulum instance running on this system.\n\n"
@ -2286,13 +2409,33 @@ class SidebandApp(MDApp):
self.open_conversations(direction="right")
## RNode hardware screen
def hardware_rnode_action(self, sender=None):
def hardware_rnode_action(self, sender=None, direction="left"):
if self.hardware_rnode_ready:
self.hardware_rnode_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.hardware_rnode_init()
def o(dt):
self.hardware_rnode_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def hardware_rnode_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "hardware_rnode_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def hardware_rnode_save(self):
try:
self.sideband.config["hw_rnode_frequency"] = int(float(self.hardware_rnode_screen.ids.hardware_rnode_frequency.text)*1000000)
@ -2400,7 +2543,6 @@ class SidebandApp(MDApp):
self.sideband.save_configuration()
def hardware_rnode_framebuffer_toggle_action(self, sender=None, event=None):
if sender.active:
self.sideband.config["hw_rnode_enable_framebuffer"] = True
@ -2409,7 +2551,6 @@ class SidebandApp(MDApp):
self.sideband.save_configuration()
def hardware_rnode_init(self, sender=None):
if not self.hardware_rnode_ready:
if not self.root.ids.screen_manager.has_screen("hardware_rnode_screen"):
@ -2500,6 +2641,7 @@ class SidebandApp(MDApp):
self.hardware_rnode_screen.ids.hardware_rnode_bluetooth.bind(active=self.hardware_rnode_bt_toggle_action)
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.bind(active=self.hardware_rnode_framebuffer_toggle_action)
self.hardware_rnode_ready = True
def hardware_rnode_validate(self, sender=None):
valid = True
@ -2691,13 +2833,35 @@ class SidebandApp(MDApp):
dialog.open()
## Modem hardware screen
def hardware_modem_action(self, sender=None):
def hardware_modem_action(self, sender=None, direction="left"):
if self.hardware_modem_ready:
self.hardware_modem_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.hardware_modem_init()
def o(dt):
self.hardware_modem_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def hardware_modem_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.hardware_modem_init()
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "hardware_modem_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def hardware_modem_init(self, sender=None):
if not self.hardware_modem_ready:
if not self.root.ids.screen_manager.has_screen("hardware_modem_screen"):
@ -2795,6 +2959,8 @@ class SidebandApp(MDApp):
self.hardware_modem_screen.ids.hardware_modem_persistence.bind(on_text_validate=save_connectivity)
self.hardware_modem_screen.ids.hardware_modem_slottime.bind(on_text_validate=save_connectivity)
self.hardware_modem_ready = True
def hardware_modem_save(self):
self.sideband.config["hw_modem_baudrate"] = int(self.hardware_modem_screen.ids.hardware_modem_baudrate.text)
self.sideband.config["hw_modem_databits"] = int(self.hardware_modem_screen.ids.hardware_modem_databits.text)
@ -2921,13 +3087,33 @@ class SidebandApp(MDApp):
return valid
## Serial hardware screen
def hardware_serial_action(self, sender=None):
def hardware_serial_action(self, sender=None, direction="left"):
if self.hardware_serial_ready:
self.hardware_serial_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.hardware_serial_init()
def o(dt):
self.hardware_serial_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def hardware_serial_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "hardware_serial_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def hardware_serial_init(self, sender=None):
if not self.hardware_serial_ready:
if not self.root.ids.screen_manager.has_screen("hardware_serial_screen"):
@ -2978,6 +3164,8 @@ class SidebandApp(MDApp):
self.hardware_serial_screen.ids.hardware_serial_parity.bind(on_text_validate=save_connectivity)
self.hardware_serial_screen.ids.hardware_serial_stopbits.bind(on_text_validate=save_connectivity)
self.hardware_serial_ready = True
def hardware_serial_validate(self, sender=None):
valid = True
try:
@ -3050,17 +3238,38 @@ class SidebandApp(MDApp):
self.announces_view.ids.announces_scrollview.effect_cls = ScrollEffect
self.announces_view.ids.announces_scrollview.add_widget(self.announces_view.get_widget())
def announces_action(self, sender=None):
self.root.ids.screen_manager.transition.direction = "left"
self.announces_view.update()
def announces_action(self, sender=None, direction="left"):
if self.announces_view:
self.announces_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.init_announces_view()
def o(dt):
self.announces_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def announces_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.nav_drawer.set_state("closed")
if self.sideband.getstate("app.flags.new_announces"):
self.init_announces_view()
self.announces_view.update()
self.root.ids.screen_manager.current = "announces_screen"
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def close_announces_action(self, sender=None):
self.open_conversations(direction="right")
@ -3075,14 +3284,26 @@ class SidebandApp(MDApp):
### Keys screen
######################################
def keys_action(self, sender=None):
def keys_action(self, sender=None, direction="left"):
if self.root.ids.screen_manager.has_screen("keys_screen"):
self.keys_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.keys_init()
def o(dt):
self.keys_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def keys_init(self):
if not self.root.ids.screen_manager.has_screen("keys_screen"):
self.keys_screen = Builder.load_string(layout_keys_screen)
self.keys_screen.app = self
self.root.ids.screen_manager.add_widget(self.keys_screen)
self.bind_clipboard_actions(self.keys_screen.ids)
self.keys_screen.ids.keys_scrollview.effect_cls = ScrollEffect
info = "Your primary encryption keys are stored in a Reticulum Identity within the Sideband app. If you want to backup this Identity for later use on this or another device, you can export it as a plain text blob, with the key data encoded in Base32 format. This will allow you to restore your address in Sideband or other LXMF clients at a later point.\n\n[b]Warning![/b] Anyone that gets access to the key data will be able to control your LXMF address, impersonate you, and read your messages. In is [b]extremely important[/b] that you keep the Identity data secure if you export it.\n\nBefore displaying or exporting your Identity data, make sure that no machine or person in your vicinity is able to see, copy or record your device screen or similar."
@ -3090,11 +3311,22 @@ class SidebandApp(MDApp):
self.widget_hide(self.keys_screen.ids.keys_share)
self.keys_screen.ids.keys_info.text = info
def keys_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "keys_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def close_keys_action(self, sender=None):
self.open_conversations(direction="right")
@ -3185,13 +3417,32 @@ class SidebandApp(MDApp):
self.telemetry_screen = Telemetry(self)
self.telemetry_ready = True
def telemetry_action(self, sender=None, direction="left"):
self.telemetry_init()
def telemetry_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "telemetry_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def telemetry_action(self, sender=None, direction="left"):
if self.telemetry_ready:
self.telemetry_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.telemetry_init()
def o(dt):
self.telemetry_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def close_sub_telemetry_action(self, sender=None):
self.telemetry_action(direction="right")
@ -3503,6 +3754,18 @@ class SidebandApp(MDApp):
self.map.animated_diff_scale_at(zd, px, py)
def map_action(self, sender=None, direction="left"):
if self.root.ids.screen_manager.has_screen("map_screen"):
self.map_open(sender=sender, direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.map_init()
def o(dt):
self.map_open(sender=sender, no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def map_init(self):
if not self.root.ids.screen_manager.has_screen("map_screen"):
msource = self.map_get_source()
mzoom = self.sideband.config["map_zoom"]
@ -3528,6 +3791,13 @@ class SidebandApp(MDApp):
self.map_screen.ids.map_layout.map = mapview
self.map_screen.ids.map_layout.add_widget(self.map_screen.ids.map_layout.map)
def map_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "map_screen"
self.root.ids.nav_drawer.set_state("closed")
@ -3540,6 +3810,9 @@ class SidebandApp(MDApp):
self.map_update_markers()
Clock.schedule_once(am_job, 0.15)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def map_settings_load_states(self):
if self.map_settings_screen != None:
self.map_settings_screen.ids.map_use_online.active = self.sideband.config["map_use_online"]
@ -3677,11 +3950,31 @@ class SidebandApp(MDApp):
def close_sub_map_action(self, sender=None):
self.map_action(direction="right")
def object_details_action(self, sender=None, from_conv=False, from_telemetry=False, source_dest=None):
def object_details_action(self, sender=None, from_conv=False, from_telemetry=False, source_dest=None, direction="left"):
if self.root.ids.screen_manager.has_screen("object_details_screen"):
self.object_details_open(sender=sender, from_conv=from_conv, from_telemetry=from_telemetry, source_dest=source_dest, no_transition=True)
else:
self.loader_action(direction=direction)
def final(dt):
self.object_details_init()
def o(dt):
self.object_details_open(sender=sender, from_conv=from_conv, from_telemetry=from_telemetry, source_dest=source_dest, no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def object_details_init(self):
self.object_details_screen = ObjectDetails(self)
def object_details_open(self, sender=None, from_conv=False, from_telemetry=False, source_dest=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
if self.sideband.config["telemetry_enabled"] == True:
self.sideband.update_telemetry()
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.nav_drawer.set_state("closed")
if source_dest != None:
@ -3692,7 +3985,9 @@ class SidebandApp(MDApp):
else:
telemetry_source = None
if telemetry_source != None:
if telemetry_source == None:
self.conversations_action(direction="right")
else:
if self.object_details_screen == None:
self.object_details_screen = ObjectDetails(self)
@ -3701,6 +3996,8 @@ class SidebandApp(MDApp):
def vj(dt):
self.root.ids.screen_manager.current = "object_details_screen"
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
Clock.schedule_once(vj, 0.15)
def map_create_marker(self, source, telemetry, appearance):
@ -3868,7 +4165,33 @@ class SidebandApp(MDApp):
def close_guide_action(self, sender=None):
self.open_conversations(direction="right")
def guide_action(self, sender=None):
def guide_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
self.root.ids.screen_manager.current = "guide_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def guide_action(self, sender=None, direction="left"):
if self.root.ids.screen_manager.has_screen("guide_screen"):
self.guide_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.guide_init()
def o(dt):
self.guide_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def guide_init(self):
if not self.root.ids.screen_manager.has_screen("guide_screen"):
self.guide_screen = Builder.load_string(layout_guide_screen)
self.guide_screen.app = self
@ -3955,36 +4278,55 @@ Thank you very much for using Free Communications Systems.
self.guide_screen.ids.guide_info9.text = info9
self.guide_screen.ids.guide_info9.bind(on_ref_press=link_exec)
self.guide_screen.ids.guide_scrollview.effect_cls = ScrollEffect
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "guide_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
#################################################
# Unimplemented Screens #
#################################################
def broadcasts_action(self, sender=None, direction="left"):
if self.root.ids.screen_manager.has_screen("broadcasts_screen"):
self.broadcasts_open(direction=direction)
else:
self.loader_action(direction=direction)
def final(dt):
self.broadcasts_init()
def o(dt):
self.broadcasts_open(no_transition=True)
Clock.schedule_once(o, ll_ot)
Clock.schedule_once(final, ll_ft)
def broadcasts_action(self, sender=None):
def broadcasts_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.root.ids.screen_manager.transition = self.no_transition
else:
self.root.ids.screen_manager.transition = self.slide_transition
self.root.ids.screen_manager.transition.direction = direction
info = "The [b]Local Broadcasts[/b] feature will allow you to send and listen for local broadcast transmissions on connected radio, LoRa and WiFi interfaces.\n\n[b]Local Broadcasts[/b] makes it easy to establish public information exchange with anyone in direct radio range, or even with large areas far away using the [i]Remote Broadcast Repeater[/i] feature.\n\nThese features are not yet implemented in Sideband.\n\nWant it faster? Go to [u][ref=link]https://unsigned.io/donate[/ref][/u] to support the project."
if self.theme_cls.theme_style == "Dark":
info = "[color=#"+dark_theme_text_color+"]"+info+"[/color]"
self.broadcasts_screen.ids.broadcasts_info.text = info
self.root.ids.screen_manager.current = "broadcasts_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
if no_transition:
self.root.ids.screen_manager.transition = self.slide_transition
def broadcasts_init(self):
if not self.root.ids.screen_manager.has_screen("broadcasts_screen"):
def link_exec(sender=None, event=None):
def lj():
webbrowser.open("https://unsigned.io/donate")
threading.Thread(target=lj, daemon=True).start()
if not self.root.ids.screen_manager.has_screen("broadcasts_screen"):
self.broadcasts_screen = Builder.load_string(layout_broadcasts_screen)
self.broadcasts_screen.app = self
self.root.ids.screen_manager.add_widget(self.broadcasts_screen)
self.broadcasts_screen.ids.broadcasts_scrollview.effect_cls = ScrollEffect
info = "The [b]Local Broadcasts[/b] feature will allow you to send and listen for local broadcast transmissions on connected radio, LoRa and WiFi interfaces.\n\n[b]Local Broadcasts[/b] makes it easy to establish public information exchange with anyone in direct radio range, or even with large areas far away using the [i]Remote Broadcast Repeater[/i] feature.\n\nThese features are not yet implemented in Sideband.\n\nWant it faster? Go to [u][ref=link]https://unsigned.io/donate[/ref][/u] to support the project."
if self.theme_cls.theme_style == "Dark":
info = "[color=#"+dark_theme_text_color+"]"+info+"[/color]"
self.broadcasts_screen.ids.broadcasts_info.text = info
self.broadcasts_screen.ids.broadcasts_info.bind(on_ref_press=link_exec)
self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "broadcasts_screen"
self.root.ids.nav_drawer.set_state("closed")
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
class CustomOneLineIconListItem(OneLineIconListItem):
icon = StringProperty()

View File

@ -9,7 +9,6 @@ MDNavigationLayout:
ScreenManager:
id: screen_manager
transition: SlideTransition()
# transition: NoTransition()
MDScreen:
name: "starting_screen"
@ -241,6 +240,39 @@ MDScreen:
font_size: "32dp"
"""
layout_loader_screen = """
MDScreen:
name: "loader_screen"
BoxLayout:
orientation: "vertical"
MDTopAppBar:
title: ""
anchor_title: "left"
elevation: 0
left_action_items:
[['menu', None ]]
right_action_items:
[
]
AnchorLayout:
padding: [dp(0), dp(72), dp(0), dp(0)]
anchor_x: "center"
anchor_y: "center"
BoxLayout:
spacing: dp(36)
orientation: 'vertical'
size_hint_y: None
MDIconButton:
pos_hint: {"center_x": .5, "center_y": .5}
icon: "dots-horizontal"
icon_size: "64dp"
"""
layout_connectivity_screen = """
MDScreen:
name: "connectivity_screen"

View File

@ -366,13 +366,32 @@ class Telemetry():
self.sensors_screen.ids.telemetry_s_information_text.text = str(self.app.sideband.config["telemetry_s_information_text"])
self.sensors_screen.ids.telemetry_s_information_text.bind(focus=self.sensors_save)
def sensors_action(self, sender=None):
self.sensors_init()
self.app.root.ids.screen_manager.transition.direction = "left"
def sensors_open(self, sender=None, direction="left", no_transition=False):
if no_transition:
self.app.root.ids.screen_manager.transition = self.app.no_transition
else:
self.app.root.ids.screen_manager.transition = self.app.slide_transition
self.app.root.ids.screen_manager.transition.direction = direction
self.app.root.ids.screen_manager.current = "sensors_screen"
self.app.root.ids.nav_drawer.set_state("closed")
self.app.sideband.setstate("app.displaying", self.app.root.ids.screen_manager.current)
if no_transition:
self.app.root.ids.screen_manager.transition = self.app.slide_transition
def sensors_action(self, sender=None):
if self.app.root.ids.screen_manager.has_screen("sensors_screen"):
self.sensors_open()
else:
self.app.loader_action()
def final(dt):
self.sensors_init()
def o(dt):
self.sensors_open(no_transition=True)
Clock.schedule_once(o, 0.45)
Clock.schedule_once(final, 0.275)
def telemetry_location_toggle(self, sender=None, event=None):
if sender == self.sensors_screen.ids.telemetry_s_location:
if self.sensors_screen.ids.telemetry_s_location.active: