Prepare interface modularity. Fixed occasional missing view redraw on wake on Android.

This commit is contained in:
Mark Qvist 2024-11-21 16:42:27 +01:00
parent 6fb9a94a43
commit 9f86c4130c
2 changed files with 108 additions and 84 deletions

View File

@ -303,6 +303,7 @@ class SidebandApp(MDApp):
self.hw_error_dialog = None self.hw_error_dialog = None
self.final_load_completed = False self.final_load_completed = False
self.wants_wake_update = False
self.service_last_available = 0 self.service_last_available = 0
self.closing_app = False self.closing_app = False
@ -699,6 +700,10 @@ class SidebandApp(MDApp):
else: else:
RNS.log("Conversations view did not exist", RNS.LOG_DEBUG) RNS.log("Conversations view did not exist", RNS.LOG_DEBUG)
def cb(dt):
self.wants_wake_update = True
Clock.schedule_once(cb, 1.2)
RNS.log("App resumed", RNS.LOG_DEBUG) RNS.log("App resumed", RNS.LOG_DEBUG)
def on_stop(self): def on_stop(self):
@ -972,6 +977,11 @@ class SidebandApp(MDApp):
if self.conversations_view != None: if self.conversations_view != None:
self.conversations_view.update() self.conversations_view.update()
if self.wants_wake_update:
self.wants_wake_update = False
if self.conversations_view != None:
self.conversations_view.update()
if self.sideband.getstate("app.flags.lxmf_sync_dialog_open", allow_cache=True) and self.sync_dialog != None: if self.sideband.getstate("app.flags.lxmf_sync_dialog_open", allow_cache=True) and self.sync_dialog != None:
state = self.sideband.message_router.propagation_transfer_state state = self.sideband.message_router.propagation_transfer_state
@ -993,6 +1003,11 @@ class SidebandApp(MDApp):
if self.announces_view != None: if self.announces_view != None:
self.announces_view.update() self.announces_view.update()
if self.wants_wake_update:
self.wants_wake_update = False
if self.announces_view != None:
self.announces_view.update()
elif self.root.ids.screen_manager.current == "map_screen": elif self.root.ids.screen_manager.current == "map_screen":
if self.map_screen and hasattr(self.map_screen.ids.map_layout, "map") and self.map_screen.ids.map_layout.map != None: if self.map_screen and hasattr(self.map_screen.ids.map_layout, "map") and self.map_screen.ids.map_layout.map != None:
self.sideband.config["map_lat"] = self.map_screen.ids.map_layout.map.lat self.sideband.config["map_lat"] = self.map_screen.ids.map_layout.map.lat
@ -1003,6 +1018,10 @@ class SidebandApp(MDApp):
if self.last_telemetry_received > self.last_map_update: if self.last_telemetry_received > self.last_map_update:
self.map_update_markers() self.map_update_markers()
if self.wants_wake_update:
self.wants_wake_update = False
self.map_update_markers()
if self.sideband.getstate("app.flags.new_conversations", allow_cache=True): if self.sideband.getstate("app.flags.new_conversations", allow_cache=True):
if self.conversations_view != None: if self.conversations_view != None:
self.conversations_view.update() self.conversations_view.update()
@ -2400,11 +2419,11 @@ class SidebandApp(MDApp):
else: else:
sl = None sl = None
sync_title = "LXMF Sync"
if not hasattr(self, "message_sync_dialog") or self.message_sync_dialog == None: if not hasattr(self, "message_sync_dialog") or self.message_sync_dialog == None:
close_button = MDRectangleFlatButton(text="Close",font_size=dp(18)) close_button = MDRectangleFlatButton(text="Close",font_size=dp(18))
stop_button = MDRectangleFlatButton(text="Stop",font_size=dp(18), theme_text_color="Custom", line_color=self.color_reject, text_color=self.color_reject) stop_button = MDRectangleFlatButton(text="Stop",font_size=dp(18), theme_text_color="Custom", line_color=self.color_reject, text_color=self.color_reject)
sync_title = "LXMF Sync"
dialog_content = MsgSync() dialog_content = MsgSync()
dialog = MDDialog( dialog = MDDialog(
title=sync_title, title=sync_title,

View File

@ -3437,11 +3437,12 @@ class SidebandCore():
else: else:
ifac_netkey = self.config["connect_local_ifac_passphrase"] ifac_netkey = self.config["connect_local_ifac_passphrase"]
autointerface = RNS.Interfaces.AutoInterface.AutoInterface( interface_config = {
RNS.Transport, "name": "AutoInterface",
name = "AutoInterface", "group_id": group_id
group_id = group_id }
)
autointerface = RNS.Interfaces.AutoInterface.AutoInterface(RNS.Transport, interface_config)
autointerface.OUT = True autointerface.OUT = True
if RNS.Reticulum.transport_enabled(): if RNS.Reticulum.transport_enabled():
@ -3529,45 +3530,50 @@ class SidebandCore():
else: else:
atl_long = self.config["hw_rnode_atl_long"] atl_long = self.config["hw_rnode_atl_long"]
interface_config = None
if rnode_allow_ble: if rnode_allow_ble:
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface( interface_config = {
RNS.Transport, "name": "RNodeInterface",
"RNodeInterface", "port": None,
None, "frequency": self.config["hw_rnode_frequency"],
frequency = self.config["hw_rnode_frequency"], "bandwidth": self.config["hw_rnode_bandwidth"],
bandwidth = self.config["hw_rnode_bandwidth"], "txpower": self.config["hw_rnode_tx_power"],
txpower = self.config["hw_rnode_tx_power"], "spreadingfactor": self.config["hw_rnode_spreading_factor"],
sf = self.config["hw_rnode_spreading_factor"], "codingrate": self.config["hw_rnode_coding_rate"],
cr = self.config["hw_rnode_coding_rate"], "flow_control": False,
flow_control = None, "id_interval": self.config["hw_rnode_beaconinterval"],
id_interval = self.config["hw_rnode_beaconinterval"], "id_callsign": self.config["hw_rnode_beacondata"],
id_callsign = self.config["hw_rnode_beacondata"], "st_alock": atl_short,
allow_bluetooth = False, "lt_alock": atl_long,
st_alock = atl_short, "allow_bluetooth": False,
lt_alock = atl_long, "target_device_name": None,
force_ble = True, "force_ble": True,
ble_name = bt_device_name, "ble_name": bt_device_name,
) "ble_addr": None,
}
else: else:
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface( interface_config = {
RNS.Transport, "name": "RNodeInterface",
"RNodeInterface", "port": target_port,
target_port, "frequency": self.config["hw_rnode_frequency"],
frequency = self.config["hw_rnode_frequency"], "bandwidth": self.config["hw_rnode_bandwidth"],
bandwidth = self.config["hw_rnode_bandwidth"], "txpower": self.config["hw_rnode_tx_power"],
txpower = self.config["hw_rnode_tx_power"], "spreadingfactor": self.config["hw_rnode_spreading_factor"],
sf = self.config["hw_rnode_spreading_factor"], "codingrate": self.config["hw_rnode_coding_rate"],
cr = self.config["hw_rnode_coding_rate"], "flow_control": False,
flow_control = None, "id_interval": self.config["hw_rnode_beaconinterval"],
id_interval = self.config["hw_rnode_beaconinterval"], "id_callsign": self.config["hw_rnode_beacondata"],
id_callsign = self.config["hw_rnode_beacondata"], "st_alock": atl_short,
allow_bluetooth = rnode_allow_bluetooth, "lt_alock": atl_long,
target_device_name = bt_device_name, "allow_bluetooth": rnode_allow_bluetooth,
st_alock = atl_short, "target_device_name": bt_device_name,
lt_alock = atl_long, "force_ble": False,
) "ble_name": None,
"ble_addr": None,
}
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface(RNS.Transport, interface_config)
rnodeinterface.OUT = True rnodeinterface.OUT = True
if RNS.Reticulum.transport_enabled(): if RNS.Reticulum.transport_enabled():
@ -3603,6 +3609,7 @@ class SidebandCore():
except Exception as e: except Exception as e:
RNS.log("Error while adding RNode Interface. The contained exception was: "+str(e)) RNS.log("Error while adding RNode Interface. The contained exception was: "+str(e))
RNS.trace_exception(e)
self.interface_rnode = None self.interface_rnode = None
self.interface_rnode_adding = False self.interface_rnode_adding = False
@ -3678,15 +3685,14 @@ class SidebandCore():
else: else:
ifac_size = None ifac_size = None
tcpinterface = RNS.Interfaces.TCPInterface.TCPClientInterface( interface_config = {
RNS.Transport, "name": "TCPClientInterface",
"TCPClientInterface", "target_host": tcp_host,
tcp_host, "target_port": tcp_port,
tcp_port, "kiss_framing": False,
kiss_framing = False, "i2p_tunneled": False,
i2p_tunneled = False }
) tcpinterface = RNS.Interfaces.TCPInterface.TCPClientInterface(RNS.Transport, interface_config)
tcpinterface.OUT = True tcpinterface.OUT = True
if RNS.Reticulum.transport_enabled(): if RNS.Reticulum.transport_enabled():
@ -3730,13 +3736,14 @@ class SidebandCore():
else: else:
ifac_size = None ifac_size = None
i2pinterface = RNS.Interfaces.I2PInterface.I2PInterface( interface_config = {
RNS.Transport, "name": "I2PInterface",
"I2PInterface", "storagepath": RNS.Reticulum.storagepath,
RNS.Reticulum.storagepath, "peers": [self.config["connect_i2p_b32"]],
[self.config["connect_i2p_b32"]], "connectable": False,
connectable = False, }
)
i2pinterface = RNS.Interfaces.I2PInterface.I2PInterface(RNS.Transport, interface_config)
i2pinterface.OUT = True i2pinterface.OUT = True
@ -3789,16 +3796,15 @@ class SidebandCore():
else: else:
ifac_netkey = self.config["connect_serial_ifac_passphrase"] ifac_netkey = self.config["connect_serial_ifac_passphrase"]
serialinterface = RNS.Interfaces.Android.SerialInterface.SerialInterface( interface_config = {
RNS.Transport, "name": "SerialInterface",
"SerialInterface", "port": target_device["port"],
target_device["port"], "speed": self.config["hw_serial_baudrate"],
self.config["hw_serial_baudrate"], "databits": self.config["hw_serial_databits"],
self.config["hw_serial_databits"], "parity": self.config["hw_serial_parity"],
self.config["hw_serial_parity"], "stopbits": self.config["hw_serial_stopbits"],
self.config["hw_serial_stopbits"], }
) serialinterface = RNS.Interfaces.Android.SerialInterface.SerialInterface(RNS.Transport, interface_config)
serialinterface.OUT = True serialinterface.OUT = True
if RNS.Reticulum.transport_enabled(): if RNS.Reticulum.transport_enabled():
@ -3842,23 +3848,22 @@ class SidebandCore():
else: else:
ifac_netkey = self.config["connect_modem_ifac_passphrase"] ifac_netkey = self.config["connect_modem_ifac_passphrase"]
modeminterface = RNS.Interfaces.Android.KISSInterface.KISSInterface( interface_config = {
RNS.Transport, "name": "ModemInterface",
"ModemInterface", "port": target_device["port"],
target_device["port"], "speed": self.config["hw_modem_baudrate"],
self.config["hw_modem_baudrate"], "databits": self.config["hw_modem_databits"],
self.config["hw_modem_databits"], "parity": self.config["hw_modem_parity"],
self.config["hw_modem_parity"], "stopbits": self.config["hw_modem_stopbits"],
self.config["hw_modem_stopbits"], "preamble": self.config["hw_modem_preamble"],
self.config["hw_modem_preamble"], "txtail": self.config["hw_modem_tail"],
self.config["hw_modem_tail"], "persistence": self.config["hw_modem_persistence"],
self.config["hw_modem_persistence"], "slottime": self.config["hw_modem_slottime"],
self.config["hw_modem_slottime"], "flow_control": False,
False, # flow control "beacon_interval": self.config["hw_modem_beaconinterval"],
self.config["hw_modem_beaconinterval"], "beacon_data": self.config["hw_modem_beacondata"],
self.config["hw_modem_beacondata"], }
) modeminterface = RNS.Interfaces.Android.KISSInterface.KISSInterface(RNS.Transport, interface_config)
modeminterface.OUT = True modeminterface.OUT = True
if RNS.Reticulum.transport_enabled(): if RNS.Reticulum.transport_enabled():