From 919cd6a44951f311adb2e5eb7d9ba70df9ddd9aa Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 23 Sep 2024 00:03:13 +0200 Subject: [PATCH] Allow predictive text on Android by default, add option to block predictive text. Fixes #55. --- sbapp/main.py | 7 +++++++ sbapp/sideband/core.py | 2 ++ sbapp/ui/layouts.py | 26 +++++++++++++------------- sbapp/ui/messages.py | 10 ++++++++++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/sbapp/main.py b/sbapp/main.py index f428539..100d91a 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -2751,6 +2751,10 @@ class SidebandApp(MDApp): self.sideband.save_configuration() self.sideband._reticulum_log_debug(self.sideband.config["debug"]) + def save_block_predictive_text(sender=None, event=None): + self.sideband.config["block_predictive_text"] = self.settings_screen.ids.settings_block_predictive_text.active + self.sideband.save_configuration() + def save_print_command(sender=None, event=None): if not sender.focus: in_cmd = self.settings_screen.ids.settings_print_command.text @@ -2917,6 +2921,9 @@ class SidebandApp(MDApp): self.settings_screen.ids.settings_debug.active = self.sideband.config["debug"] self.settings_screen.ids.settings_debug.bind(active=save_debug) + self.settings_screen.ids.settings_block_predictive_text.active = self.sideband.config["block_predictive_text"] + self.settings_screen.ids.settings_block_predictive_text.bind(active=save_block_predictive_text) + self.settings_screen.ids.settings_lang_default.active = False self.settings_screen.ids.settings_lang_chinese.active = False self.settings_screen.ids.settings_lang_japanese.active = False diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index e605e05..5d346cd 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -531,6 +531,8 @@ class SidebandCore(): self.config["input_language"] = None if not "allow_predictive_text" in self.config: self.config["allow_predictive_text"] = False + if not "block_predictive_text" in self.config: + self.config["block_predictive_text"] = False if not "connect_transport" in self.config: self.config["connect_transport"] = False diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py index 66acdd0..afe4f01 100644 --- a/sbapp/ui/layouts.py +++ b/sbapp/ui/layouts.py @@ -1822,20 +1822,20 @@ MDScreen: 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) + MDBoxLayout: + orientation: "horizontal" + size_hint_y: None + padding: [0,0,dp(24),dp(0)] + height: dp(48) - # MDLabel: - # text: "Allow Predictive Text" - # font_style: "H6" + MDLabel: + text: "Block Predictive Text" + font_style: "H6" - # MDSwitch: - # id: settings_allow_predictive_text - # pos_hint: {"center_y": 0.3} - # active: False + MDSwitch: + id: settings_block_predictive_text + pos_hint: {"center_y": 0.3} + active: False # MDBoxLayout: # orientation: "vertical" @@ -1844,7 +1844,7 @@ MDScreen: # padding: [0, dp(24), 0, dp(24)] # MDRectangleFlatIconButton: - # id: hardware_rnode_button + # id: input_language_button # icon: "translate" # text: "Input Languages" # padding: [dp(0), dp(14), dp(0), dp(14)] diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index 8798723..7a18569 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -194,6 +194,15 @@ class Messages(): self.details_dialog.open() def update(self, limit=8): + if self.app.sideband.config["block_predictive_text"]: + if self.ids.message_text.input_type != "null": + self.ids.message_text.input_type = "null" + self.ids.message_text.keyboard_suggestions = False + else: + if self.ids.message_text.input_type != "text": + self.ids.message_text.input_type = "text" + self.ids.message_text.keyboard_suggestions = False + for new_message in self.app.sideband.list_messages(self.context_dest, after=self.latest_message_timestamp,limit=limit): self.new_messages.append(new_message) @@ -1229,6 +1238,7 @@ MDScreen: MDTextField: id: message_text + input_type: "text" keyboard_suggestions: True multiline: True hint_text: "Write message"