Added e-ink display mode

This commit is contained in:
Mark Qvist 2023-10-07 16:54:38 +02:00
parent a4ecfb12b9
commit 5e8ed17bb3
3 changed files with 47 additions and 6 deletions

View File

@ -90,6 +90,9 @@ class SidebandApp(MDApp):
SERVICE_TIMEOUT = 30 SERVICE_TIMEOUT = 30
EINK_BG_STR = "1,0,0,1"
EINK_BG_ARR = [1,0,0,1]
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
self.title = "Sideband" self.title = "Sideband"
@ -248,16 +251,25 @@ class SidebandApp(MDApp):
self.color_reject = colors["DeepOrange"]["800"] self.color_reject = colors["DeepOrange"]["800"]
self.color_accept = colors["LightGreen"]["700"] self.color_accept = colors["LightGreen"]["700"]
self.apply_eink_mods()
def update_ui_theme(self): def update_ui_theme(self):
if self.sideband.config["dark_ui"]: if self.sideband.config["dark_ui"]:
self.theme_cls.theme_style = "Dark" self.theme_cls.theme_style = "Dark"
else: else:
self.theme_cls.theme_style = "Light" self.theme_cls.theme_style = "Light"
self.apply_eink_mods()
self.update_ui_colors() self.update_ui_colors()
# for wid in self.root.ids: def apply_eink_mods(self):
# RNS.log("Found: "+str(wid)+str(self.root.ids[wid])) if self.sideband.config["eink_mode"]:
if self.root != None:
self.root.md_bg_color = self.theme_cls.bg_light
else:
if self.root != None:
self.root.md_bg_color = self.theme_cls.bg_darkest
def set_bars_colors(self): def set_bars_colors(self):
if RNS.vendor.platformutils.get_platform() == "android": if RNS.vendor.platformutils.get_platform() == "android":
@ -522,6 +534,9 @@ class SidebandApp(MDApp):
from android import activity as a_activity from android import activity as a_activity
a_activity.bind(on_new_intent=self.on_new_intent) a_activity.bind(on_new_intent=self.on_new_intent)
if self.sideband.config["eink_mode"] == True:
screen = Builder.load_string(root_layout.replace("app.theme_cls.bg_darkest", "app.theme_cls.bg_light"))
else:
screen = Builder.load_string(root_layout) screen = Builder.load_string(root_layout)
return screen return screen
@ -541,14 +556,14 @@ class SidebandApp(MDApp):
) )
def dl_ok(s): def dl_ok(s):
dialog.dismiss() dialog.dismiss()
self.quit_action() self.quit_action(s)
ok_button.bind(on_release=dl_ok) ok_button.bind(on_release=dl_ok)
self.final_load_completed = False self.final_load_completed = False
dialog.open() dialog.open()
else: else:
self.quit_action() self.quit_action(s)
else: else:
self.service_last_available = time.time() self.service_last_available = time.time()
@ -1246,6 +1261,11 @@ class SidebandApp(MDApp):
self.sideband.save_configuration() self.sideband.save_configuration()
self.update_ui_theme() self.update_ui_theme()
def save_eink_mode(sender=None, event=None):
self.sideband.config["eink_mode"] = self.root.ids.settings_eink_mode.active
self.sideband.save_configuration()
self.update_ui_theme()
def save_notifications_on(sender=None, event=None): def save_notifications_on(sender=None, event=None):
self.sideband.config["notifications_on"] = self.root.ids.settings_notifications_on.active self.sideband.config["notifications_on"] = self.root.ids.settings_notifications_on.active
self.sideband.save_configuration() self.sideband.save_configuration()
@ -1331,6 +1351,9 @@ class SidebandApp(MDApp):
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)
self.root.ids.settings_eink_mode.active = self.sideband.config["eink_mode"]
self.root.ids.settings_eink_mode.bind(active=save_eink_mode)
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)

View File

@ -234,6 +234,7 @@ class SidebandCore():
self.config["last_lxmf_propagation_node"] = None self.config["last_lxmf_propagation_node"] = None
self.config["nn_home_node"] = None self.config["nn_home_node"] = None
self.config["print_command"] = "lp" self.config["print_command"] = "lp"
self.config["eink_mode"] = False
# Connectivity # Connectivity
self.config["connect_transport"] = False self.config["connect_transport"] = False
@ -330,6 +331,8 @@ class SidebandCore():
self.config["notifications_on"] = True self.config["notifications_on"] = True
if not "print_command" in self.config: if not "print_command" in self.config:
self.config["print_command"] = "lp" self.config["print_command"] = "lp"
if not "eink_mode" in self.config:
self.config["eink_mode"] = False
if not "connect_transport" in self.config: if not "connect_transport" in self.config:
self.config["connect_transport"] = False self.config["connect_transport"] = False

View File

@ -1100,7 +1100,7 @@ MDNavigationLayout:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
text: "Dark Mode UI" text: "Dark Mode"
font_style: "H6" font_style: "H6"
MDSwitch: MDSwitch:
@ -1108,6 +1108,21 @@ MDNavigationLayout:
pos_hint: {"center_y": 0.3} pos_hint: {"center_y": 0.3}
active: False active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "E-Ink Mode"
font_style: "H6"
MDSwitch:
id: settings_eink_mode
pos_hint: {"center_y": 0.3}
active: False
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None