mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Dark/light mode theme support
This commit is contained in:
parent
96d671e9a2
commit
29071fbdfc
@ -70,7 +70,6 @@ class SidebandApp(MDApp):
|
|||||||
self.title = "Sideband"
|
self.title = "Sideband"
|
||||||
self.app_state = SidebandApp.STARTING
|
self.app_state = SidebandApp.STARTING
|
||||||
self.android_service = None
|
self.android_service = None
|
||||||
|
|
||||||
self.app_dir = plyer.storagepath.get_application_dir()
|
self.app_dir = plyer.storagepath.get_application_dir()
|
||||||
|
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
@ -78,8 +77,9 @@ class SidebandApp(MDApp):
|
|||||||
else:
|
else:
|
||||||
self.sideband = SidebandCore(self, is_client=False)
|
self.sideband = SidebandCore(self, is_client=False)
|
||||||
|
|
||||||
self.conversations_view = None
|
self.update_ui_theme()
|
||||||
|
|
||||||
|
self.conversations_view = None
|
||||||
self.sync_dialog = None
|
self.sync_dialog = None
|
||||||
|
|
||||||
Window.softinput_mode = "below_target"
|
Window.softinput_mode = "below_target"
|
||||||
@ -138,6 +138,12 @@ class SidebandApp(MDApp):
|
|||||||
# General helpers #
|
# General helpers #
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
|
def update_ui_theme(self):
|
||||||
|
if self.sideband.config["dark_ui"]:
|
||||||
|
self.theme_cls.theme_style = "Dark"
|
||||||
|
else:
|
||||||
|
self.theme_cls.theme_style = "Light"
|
||||||
|
|
||||||
def share_text(self, text):
|
def share_text(self, text):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
Intent = autoclass('android.content.Intent')
|
Intent = autoclass('android.content.Intent')
|
||||||
@ -198,7 +204,6 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
FONT_PATH = self.sideband.asset_dir+"/fonts"
|
FONT_PATH = self.sideband.asset_dir+"/fonts"
|
||||||
self.theme_cls.theme_style = "Dark"
|
|
||||||
screen = Builder.load_string(root_layout)
|
screen = Builder.load_string(root_layout)
|
||||||
|
|
||||||
return screen
|
return screen
|
||||||
@ -708,6 +713,12 @@ class SidebandApp(MDApp):
|
|||||||
self.sideband.config["lxmf_propagation_node"] = new_addr
|
self.sideband.config["lxmf_propagation_node"] = new_addr
|
||||||
self.sideband.set_active_propagation_node(self.sideband.config["lxmf_propagation_node"])
|
self.sideband.set_active_propagation_node(self.sideband.config["lxmf_propagation_node"])
|
||||||
|
|
||||||
|
def save_dark_ui(sender=None, event=None):
|
||||||
|
RNS.log("Save UI mode")
|
||||||
|
self.sideband.config["dark_ui"] = self.root.ids.settings_dark_ui.active
|
||||||
|
self.sideband.save_configuration()
|
||||||
|
self.update_ui_theme()
|
||||||
|
|
||||||
def save_start_announce(sender=None, event=None):
|
def save_start_announce(sender=None, event=None):
|
||||||
RNS.log("Save announce")
|
RNS.log("Save announce")
|
||||||
self.sideband.config["start_announce"] = self.root.ids.settings_start_announce.active
|
self.sideband.config["start_announce"] = self.root.ids.settings_start_announce.active
|
||||||
@ -738,6 +749,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_dark_ui.active = self.sideband.config["dark_ui"]
|
||||||
|
self.root.ids.settings_dark_ui.bind(active=save_dark_ui)
|
||||||
|
|
||||||
self.root.ids.settings_start_announce.active = self.sideband.config["start_announce"]
|
self.root.ids.settings_start_announce.active = self.sideband.config["start_announce"]
|
||||||
self.root.ids.settings_start_announce.bind(active=save_start_announce)
|
self.root.ids.settings_start_announce.bind(active=save_start_announce)
|
||||||
|
|
||||||
@ -1040,8 +1054,6 @@ If you use Reticulum and LXMF on hardware that does not carry any identifiers ti
|
|||||||
|
|
||||||
Thank you very much for using Free Communications Systems.
|
Thank you very much for using Free Communications Systems.
|
||||||
"""
|
"""
|
||||||
guide_text = "[color=#ddd]"+guide_text+"[/color]"
|
|
||||||
|
|
||||||
info = guide_text
|
info = guide_text
|
||||||
self.root.ids.guide_info.text = info
|
self.root.ids.guide_info.text = info
|
||||||
self.root.ids.guide_info.bind(on_ref_press=link_exec)
|
self.root.ids.guide_info.bind(on_ref_press=link_exec)
|
||||||
|
@ -155,6 +155,7 @@ class SidebandCore():
|
|||||||
self.config = {}
|
self.config = {}
|
||||||
# Settings
|
# Settings
|
||||||
self.config["display_name"] = "Anonymous Peer"
|
self.config["display_name"] = "Anonymous Peer"
|
||||||
|
self.config["dark_ui"] = True
|
||||||
self.config["start_announce"] = False
|
self.config["start_announce"] = False
|
||||||
self.config["propagation_by_default"] = False
|
self.config["propagation_by_default"] = False
|
||||||
self.config["home_node_as_broadcast_repeater"] = False
|
self.config["home_node_as_broadcast_repeater"] = False
|
||||||
@ -199,6 +200,11 @@ class SidebandCore():
|
|||||||
self.config = msgpack.unpackb(config_file.read())
|
self.config = msgpack.unpackb(config_file.read())
|
||||||
config_file.close()
|
config_file.close()
|
||||||
|
|
||||||
|
# Migration actions from earlier config formats
|
||||||
|
if not "dark_ui" in self.config:
|
||||||
|
self.config["dark_ui"] = True
|
||||||
|
|
||||||
|
# Make sure we have a database
|
||||||
if not os.path.isfile(self.db_path):
|
if not os.path.isfile(self.db_path):
|
||||||
self.__db_init()
|
self.__db_init()
|
||||||
else:
|
else:
|
||||||
|
@ -670,6 +670,20 @@ MDNavigationLayout:
|
|||||||
id: settings_start_announce
|
id: settings_start_announce
|
||||||
active: False
|
active: False
|
||||||
|
|
||||||
|
MDBoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
# spacing: "24dp"
|
||||||
|
size_hint_y: None
|
||||||
|
height: dp(48)
|
||||||
|
|
||||||
|
MDLabel:
|
||||||
|
text: "Dark Mode UI"
|
||||||
|
font_style: "H6"
|
||||||
|
|
||||||
|
MDSwitch:
|
||||||
|
id: settings_dark_ui
|
||||||
|
active: False
|
||||||
|
|
||||||
MDBoxLayout:
|
MDBoxLayout:
|
||||||
orientation: "horizontal"
|
orientation: "horizontal"
|
||||||
# spacing: "24dp"
|
# spacing: "24dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user