Added settings item for notifications
This commit is contained in:
parent
7503737a96
commit
ca84ac7454
|
@ -856,6 +856,10 @@ class SidebandApp(MDApp):
|
||||||
self.sideband.save_configuration()
|
self.sideband.save_configuration()
|
||||||
self.update_ui_theme()
|
self.update_ui_theme()
|
||||||
|
|
||||||
|
def save_notifications_on(sender=None, event=None):
|
||||||
|
self.sideband.config["notifications_on"] = self.root.ids.settings_notifications_on.active
|
||||||
|
self.sideband.save_configuration()
|
||||||
|
|
||||||
def save_start_announce(sender=None, event=None):
|
def save_start_announce(sender=None, event=None):
|
||||||
self.sideband.config["start_announce"] = self.root.ids.settings_start_announce.active
|
self.sideband.config["start_announce"] = self.root.ids.settings_start_announce.active
|
||||||
self.sideband.save_configuration()
|
self.sideband.save_configuration()
|
||||||
|
@ -883,10 +887,9 @@ class SidebandApp(MDApp):
|
||||||
interval_text = RNS.prettytime(interval)
|
interval_text = RNS.prettytime(interval)
|
||||||
pre = self.root.ids.settings_lxmf_sync_periodic.text
|
pre = self.root.ids.settings_lxmf_sync_periodic.text
|
||||||
self.root.ids.settings_lxmf_sync_periodic.text = "Auto sync every "+interval_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:
|
||||||
if save:
|
self.sideband.config["lxmf_sync_interval"] = interval
|
||||||
self.sideband.config["lxmf_sync_interval"] = interval
|
self.sideband.save_configuration()
|
||||||
self.sideband.save_configuration()
|
|
||||||
|
|
||||||
self.root.ids.settings_lxmf_address.text = RNS.hexrep(self.sideband.lxmf_destination.hash, delimit=False)
|
self.root.ids.settings_lxmf_address.text = RNS.hexrep(self.sideband.lxmf_destination.hash, delimit=False)
|
||||||
|
|
||||||
|
@ -903,6 +906,9 @@ class SidebandApp(MDApp):
|
||||||
self.root.ids.settings_propagation_node_address.bind(on_text_validate=save_prop_addr)
|
self.root.ids.settings_propagation_node_address.bind(on_text_validate=save_prop_addr)
|
||||||
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
||||||
|
|
||||||
|
self.root.ids.settings_notifications_on.active = self.sideband.config["notifications_on"]
|
||||||
|
self.root.ids.settings_notifications_on.bind(active=save_notifications_on)
|
||||||
|
|
||||||
self.root.ids.settings_dark_ui.active = self.sideband.config["dark_ui"]
|
self.root.ids.settings_dark_ui.active = self.sideband.config["dark_ui"]
|
||||||
self.root.ids.settings_dark_ui.bind(active=save_dark_ui)
|
self.root.ids.settings_dark_ui.bind(active=save_dark_ui)
|
||||||
|
|
||||||
|
@ -916,7 +922,10 @@ class SidebandApp(MDApp):
|
||||||
self.root.ids.settings_lxmf_periodic_sync.bind(active=save_lxmf_periodic_sync)
|
self.root.ids.settings_lxmf_periodic_sync.bind(active=save_lxmf_periodic_sync)
|
||||||
save_lxmf_periodic_sync(save=False)
|
save_lxmf_periodic_sync(save=False)
|
||||||
|
|
||||||
self.root.ids.settings_lxmf_sync_interval.bind(value=sync_interval_change)
|
def sync_interval_change_cb(sender=None, event=None):
|
||||||
|
sync_interval_change(sender=sender, event=event, save=False)
|
||||||
|
self.root.ids.settings_lxmf_sync_interval.bind(value=sync_interval_change_cb)
|
||||||
|
self.root.ids.settings_lxmf_sync_interval.bind(on_touch_up=sync_interval_change)
|
||||||
self.root.ids.settings_lxmf_sync_interval.value = self.sideband.config["lxmf_sync_interval"]
|
self.root.ids.settings_lxmf_sync_interval.value = self.sideband.config["lxmf_sync_interval"]
|
||||||
sync_interval_change(save=False)
|
sync_interval_change(save=False)
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ class SidebandCore():
|
||||||
self.config = {}
|
self.config = {}
|
||||||
# Settings
|
# Settings
|
||||||
self.config["display_name"] = "Anonymous Peer"
|
self.config["display_name"] = "Anonymous Peer"
|
||||||
|
self.config["settings_notifications_on"] = False
|
||||||
self.config["dark_ui"] = False
|
self.config["dark_ui"] = False
|
||||||
self.config["start_announce"] = False
|
self.config["start_announce"] = False
|
||||||
self.config["propagation_by_default"] = False
|
self.config["propagation_by_default"] = False
|
||||||
|
@ -220,6 +221,8 @@ class SidebandCore():
|
||||||
self.config["lxmf_periodic_sync"] = False
|
self.config["lxmf_periodic_sync"] = False
|
||||||
if not "lxmf_sync_interval" in self.config:
|
if not "lxmf_sync_interval" in self.config:
|
||||||
self.config["lxmf_sync_interval"] = 43200
|
self.config["lxmf_sync_interval"] = 43200
|
||||||
|
if not "notifications_on" in self.config:
|
||||||
|
self.config["notifications_on"] = True
|
||||||
|
|
||||||
# Make sure we have a database
|
# Make sure we have a database
|
||||||
if not os.path.isfile(self.db_path):
|
if not os.path.isfile(self.db_path):
|
||||||
|
@ -267,9 +270,7 @@ class SidebandCore():
|
||||||
|
|
||||||
|
|
||||||
def notify(self, title, content, group=None, context_id=None):
|
def notify(self, title, content, group=None, context_id=None):
|
||||||
notifications_enabled = True
|
if self.config["notifications_on"]:
|
||||||
|
|
||||||
if notifications_enabled:
|
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
if self.getpersistent("permissions.notifications"):
|
if self.getpersistent("permissions.notifications"):
|
||||||
notifications_permitted = True
|
notifications_permitted = True
|
||||||
|
|
|
@ -840,6 +840,21 @@ MDNavigationLayout:
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
padding: [dp(28), dp(16), dp(28), dp(16)]
|
padding: [dp(28), dp(16), dp(28), dp(16)]
|
||||||
|
|
||||||
|
MDBoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_y: None
|
||||||
|
padding: [0,0,dp(24),dp(0)]
|
||||||
|
height: dp(48)
|
||||||
|
|
||||||
|
MDLabel:
|
||||||
|
text: "Notifications"
|
||||||
|
font_style: "H6"
|
||||||
|
|
||||||
|
MDSwitch:
|
||||||
|
id: settings_notifications_on
|
||||||
|
pos_hint: {"center_y": 0.3}
|
||||||
|
active: True
|
||||||
|
|
||||||
MDBoxLayout:
|
MDBoxLayout:
|
||||||
orientation: "horizontal"
|
orientation: "horizontal"
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
|
|
Loading…
Reference in New Issue