diff --git a/sbapp/main.py b/sbapp/main.py index cd63d12..6bd5b3f 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -508,7 +508,7 @@ class SidebandApp(MDApp): def message_send_action(self, sender=None): if self.root.ids.message_text.text == "": return - + def cb(dt): self.message_send_dispatch(sender) Clock.schedule_once(cb, 0.20) @@ -837,6 +837,25 @@ class SidebandApp(MDApp): self.sideband.config["lxmf_sync_limit"] = self.root.ids.settings_lxmf_sync_limit.active self.sideband.save_configuration() + def save_lxmf_periodic_sync(sender=None, event=None, save=True): + if self.root.ids.settings_lxmf_periodic_sync.active: + self.widget_hide(self.root.ids.lxmf_syncslider_container, False) + else: + self.widget_hide(self.root.ids.lxmf_syncslider_container, True) + + if save: + self.sideband.config["lxmf_periodic_sync"] = self.root.ids.settings_lxmf_periodic_sync.active + self.sideband.save_configuration() + + def sync_interval_change(sender=None, event=None, save=True): + interval = (self.root.ids.settings_lxmf_sync_interval.value//300)*300 + interval_text = RNS.prettytime(interval) + pre = self.root.ids.settings_lxmf_sync_periodic.text + self.root.ids.settings_lxmf_sync_periodic.text = "Auto sync every "+interval_text + if pre != self.root.ids.settings_lxmf_sync_periodic.text: + if save: + self.sideband.save_configuration() + self.root.ids.settings_lxmf_address.text = RNS.hexrep(self.sideband.lxmf_destination.hash, delimit=False) self.root.ids.settings_display_name.text = self.sideband.config["display_name"] @@ -861,6 +880,15 @@ class SidebandApp(MDApp): self.root.ids.settings_lxmf_delivery_by_default.active = self.sideband.config["propagation_by_default"] self.root.ids.settings_lxmf_delivery_by_default.bind(active=save_lxmf_delivery_by_default) + self.root.ids.settings_lxmf_periodic_sync.active = self.sideband.config["lxmf_periodic_sync"] + self.root.ids.settings_lxmf_periodic_sync.bind(active=save_lxmf_periodic_sync) + save_lxmf_periodic_sync(save=False) + + self.root.ids.settings_lxmf_sync_interval.bind(value=sync_interval_change) + self.root.ids.settings_lxmf_sync_interval.value = self.sideband.config["lxmf_sync_interval"] + sync_interval_change(save=False) + + if self.sideband.config["lxmf_sync_limit"] == None or self.sideband.config["lxmf_sync_limit"] == False: sync_limit = False else: diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index e978fec..7c32648 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -169,6 +169,8 @@ class SidebandCore(): self.config["lxmf_propagation_node"] = None self.config["lxmf_sync_limit"] = None self.config["lxmf_sync_max"] = 3 + self.config["lxmf_periodic_sync"] = False + self.config["lxmf_sync_interval"] = 43200 self.config["last_lxmf_propagation_node"] = None self.config["nn_home_node"] = None # Connectivity @@ -212,6 +214,10 @@ class SidebandCore(): # Migration actions from earlier config formats if not "dark_ui" in self.config: self.config["dark_ui"] = True + if not "lxmf_periodic_sync" in self.config: + self.config["lxmf_periodic_sync"] = False + if not "lxmf_sync_interval" in self.config: + self.config["lxmf_sync_interval"] = 43200 # Make sure we have a database if not os.path.isfile(self.db_path): diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py index fb8e706..5475a8a 100644 --- a/sbapp/ui/layouts.py +++ b/sbapp/ui/layouts.py @@ -779,144 +779,191 @@ MDNavigationLayout: MDBoxLayout: orientation: "vertical" - spacing: "24dp" + spacing: 0 size_hint_y: None height: self.minimum_height - padding: [dp(28), dp(16), dp(28), dp(16)] - - - MDLabel: - text: "" - font_style: "H6" - - MDLabel: - text: "User Options" - font_style: "H6" - - MDTextField: - id: settings_display_name - hint_text: "Display Name" - text: "" - max_text_length: 128 - font_size: dp(24) - - MDTextField: - id: settings_lxmf_address - hint_text: "Your LXMF Address" - text: "" - disabled: False - max_text_length: 32 - font_size: dp(24) - - MDTextField: - id: settings_propagation_node_address - hint_text: "LXMF Propagation Node" - disabled: False - text: "" - max_text_length: 32 - font_size: dp(24) - - MDTextField: - id: settings_home_node_address - hint_text: "Nomad Network Home Node" - disabled: False - text: "" - max_text_length: 32 - font_size: dp(24) + padding: [0, 0, 0, 0] MDBoxLayout: - orientation: "horizontal" + orientation: "vertical" + spacing: "16dp" size_hint_y: None - padding: [0,0,dp(24),0] - height: dp(48) + height: self.minimum_height + padding: [dp(28), dp(16), dp(28), dp(16)] + MDLabel: - text: "Dark Mode UI" + text: "" font_style: "H6" - MDSwitch: - id: settings_dark_ui - pos_hint: {"center_y": 0.3} - active: False - - MDBoxLayout: - orientation: "horizontal" - size_hint_y: None - padding: [0,0,dp(24),0] - height: dp(48) - MDLabel: - text: "Announce At App Startup" + text: "User Options" font_style: "H6" - MDSwitch: - id: settings_start_announce - pos_hint: {"center_y": 0.3} - active: False + MDTextField: + id: settings_display_name + hint_text: "Display Name" + text: "" + max_text_length: 128 + font_size: dp(24) - MDBoxLayout: - orientation: "horizontal" - size_hint_y: None - padding: [0,0,dp(24),0] - height: dp(48) - - MDLabel: - text: "Send via Propagation Node by default" - font_style: "H6" - - MDSwitch: - id: settings_lxmf_delivery_by_default - pos_hint: {"center_y": 0.3} + MDTextField: + id: settings_lxmf_address + hint_text: "Your LXMF Address" + text: "" disabled: False - active: False + max_text_length: 32 + font_size: dp(24) - MDBoxLayout: - orientation: "horizontal" - size_hint_y: None - padding: [0,0,dp(24),0] - height: dp(48) - - MDLabel: - text: "Limit each sync to 3 messages" - font_style: "H6" - - MDSwitch: - id: settings_lxmf_sync_limit - pos_hint: {"center_y": 0.3} + MDTextField: + id: settings_propagation_node_address + hint_text: "LXMF Propagation Node" disabled: False - active: False + text: "" + max_text_length: 32 + font_size: dp(24) + + MDTextField: + id: settings_home_node_address + hint_text: "Nomad Network Home Node" + disabled: False + text: "" + max_text_length: 32 + font_size: dp(24) + MDBoxLayout: - orientation: "horizontal" + orientation: "vertical" + # spacing: "24dp" size_hint_y: None - padding: [0,0,dp(24),0] - height: dp(48) - - MDLabel: - text: "Use Home Node as Broadcast Repeater" - font_style: "H6" + height: self.minimum_height + padding: [dp(28), dp(16), dp(28), dp(16)] - MDSwitch: - id: settings_home_node_as_broadcast_repeater - pos_hint: {"center_y": 0.3} - active: False - disabled: True + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + text: "Dark Mode UI" + font_style: "H6" - MDBoxLayout: - orientation: "horizontal" - size_hint_y: None - padding: [0,0,dp(24),0] - height: dp(48) - - MDLabel: - text: "Send Telemetry to Home Node" - font_style: "H6" + MDSwitch: + id: settings_dark_ui + pos_hint: {"center_y": 0.3} + active: False - MDSwitch: - id: settings_telemetry_to_home_node - pos_hint: {"center_y": 0.3} - disabled: True - active: False + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + text: "Announce At App Startup" + font_style: "H6" + + MDSwitch: + id: settings_start_announce + pos_hint: {"center_y": 0.3} + active: False + + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + text: "Send via Propagation Node by default" + font_style: "H6" + + MDSwitch: + id: settings_lxmf_delivery_by_default + pos_hint: {"center_y": 0.3} + disabled: False + active: False + + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + text: "Limit each sync to 3 messages" + font_style: "H6" + + MDSwitch: + id: settings_lxmf_sync_limit + pos_hint: {"center_y": 0.3} + disabled: False + active: False + + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + id: settings_lxmf_sync_periodic + text: "Sync with Propagation Node periodically" + font_style: "H6" + + MDSwitch: + id: settings_lxmf_periodic_sync + pos_hint: {"center_y": 0.3} + disabled: False + active: False + + MDBoxLayout: + id: lxmf_syncslider_container + orientation: "vertical" + size_hint_y: None + padding: [0,0,dp(0),0] + height: dp(68) + + MDSlider + min: 300 + max: 172800 + value: 43200 + id: settings_lxmf_sync_interval + sensitivity: "all" + hint: False + + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + text: "Use Home Node as Broadcast Repeater" + font_style: "H6" + + MDSwitch: + id: settings_home_node_as_broadcast_repeater + pos_hint: {"center_y": 0.3} + active: False + disabled: True + + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) + + MDLabel: + text: "Send Telemetry to Home Node" + font_style: "H6" + + MDSwitch: + id: settings_telemetry_to_home_node + pos_hint: {"center_y": 0.3} + disabled: True + active: False MDNavigationDrawer: