mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Added improved copy/paste behaviour for fields
This commit is contained in:
parent
bab181ae76
commit
fd7f8dfd76
@ -895,6 +895,17 @@ class SidebandApp(MDApp):
|
|||||||
w.saved_attrs = w.height, w.size_hint_y, w.opacity, w.disabled
|
w.saved_attrs = w.height, w.size_hint_y, w.opacity, w.disabled
|
||||||
w.height, w.size_hint_y, w.opacity, w.disabled = 0, None, 0, True
|
w.height, w.size_hint_y, w.opacity, w.disabled = 0, None, 0, True
|
||||||
|
|
||||||
|
def ui_clipboard_action(self, sender=None, event=None):
|
||||||
|
try:
|
||||||
|
if len(sender.text) == 0:
|
||||||
|
sender.text = Clipboard.paste()
|
||||||
|
else:
|
||||||
|
Clipboard.copy(sender.text)
|
||||||
|
action = "tap" if RNS.vendor.platformutils.is_android() else "click"
|
||||||
|
toast(f"Field copied, double-{action} any empty field to paste")
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("An error occurred while handling clipboard action: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
def quit_action(self, sender):
|
def quit_action(self, sender):
|
||||||
self.root.ids.nav_drawer.set_state("closed")
|
self.root.ids.nav_drawer.set_state("closed")
|
||||||
self.sideband.should_persist_data()
|
self.sideband.should_persist_data()
|
||||||
@ -1486,15 +1497,36 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
return sv
|
return sv
|
||||||
|
|
||||||
|
def bind_clipboard_actions(self, ids, force=False):
|
||||||
|
if force or RNS.vendor.platformutils.is_android():
|
||||||
|
BIND_CLASSES = ["kivymd.uix.textfield.textfield.MDTextField",]
|
||||||
|
for e in ids:
|
||||||
|
te = ids[e]
|
||||||
|
ts = str(te).split(" ")[0].replace("<", "")
|
||||||
|
if ts in BIND_CLASSES and not hasattr(e, "no_clipboard"):
|
||||||
|
RNS.log("Binding clipboard action to "+str(e))
|
||||||
|
te.bind(on_double_tap=self.ui_clipboard_action)
|
||||||
|
|
||||||
def settings_init(self, sender=None):
|
def settings_init(self, sender=None):
|
||||||
if not self.settings_ready:
|
if not self.settings_ready:
|
||||||
if not self.root.ids.screen_manager.has_screen("settings_screen"):
|
if not self.root.ids.screen_manager.has_screen("settings_screen"):
|
||||||
self.settings_screen = Builder.load_string(layout_settings_screen)
|
self.settings_screen = Builder.load_string(layout_settings_screen)
|
||||||
self.settings_screen.app = self
|
self.settings_screen.app = self
|
||||||
self.root.ids.screen_manager.add_widget(self.settings_screen)
|
self.root.ids.screen_manager.add_widget(self.settings_screen)
|
||||||
|
self.bind_clipboard_actions(self.settings_screen.ids)
|
||||||
|
|
||||||
self.settings_screen.ids.settings_scrollview.effect_cls = ScrollEffect
|
self.settings_screen.ids.settings_scrollview.effect_cls = ScrollEffect
|
||||||
|
|
||||||
|
info1_text = "\nYou can set your [b]Display Name[/b] to a custom value, or leave it as the default unspecified value. "
|
||||||
|
info1_text += "This name will be included in any announces you send, and will be visible to others on the network. "
|
||||||
|
info1_text += "\n\nYou can manually specify which [b]Propagation Node[/b] to use, but if none is specified, Sideband will "
|
||||||
|
info1_text += "automatically select one nearby."
|
||||||
|
if RNS.vendor.platformutils.is_android():
|
||||||
|
info1_text += "\n\nDouble-tap any field to copy its value, and double-tap an empty field to paste into it."
|
||||||
|
|
||||||
|
self.settings_screen.ids.settings_info1.text = info1_text
|
||||||
|
|
||||||
|
|
||||||
def save_disp_name(sender=None, event=None):
|
def save_disp_name(sender=None, event=None):
|
||||||
if not sender.focus:
|
if not sender.focus:
|
||||||
in_name = self.settings_screen.ids.settings_display_name.text
|
in_name = self.settings_screen.ids.settings_display_name.text
|
||||||
@ -1717,6 +1749,7 @@ class SidebandApp(MDApp):
|
|||||||
self.connectivity_screen = Builder.load_string(layout_connectivity_screen)
|
self.connectivity_screen = Builder.load_string(layout_connectivity_screen)
|
||||||
self.connectivity_screen.app = self
|
self.connectivity_screen.app = self
|
||||||
self.root.ids.screen_manager.add_widget(self.connectivity_screen)
|
self.root.ids.screen_manager.add_widget(self.connectivity_screen)
|
||||||
|
self.bind_clipboard_actions(self.connectivity_screen.ids)
|
||||||
|
|
||||||
self.connectivity_screen.ids.connectivity_scrollview.effect_cls = ScrollEffect
|
self.connectivity_screen.ids.connectivity_scrollview.effect_cls = ScrollEffect
|
||||||
def con_hide_settings():
|
def con_hide_settings():
|
||||||
@ -3047,6 +3080,8 @@ class SidebandApp(MDApp):
|
|||||||
self.keys_screen = Builder.load_string(layout_keys_screen)
|
self.keys_screen = Builder.load_string(layout_keys_screen)
|
||||||
self.keys_screen.app = self
|
self.keys_screen.app = self
|
||||||
self.root.ids.screen_manager.add_widget(self.keys_screen)
|
self.root.ids.screen_manager.add_widget(self.keys_screen)
|
||||||
|
self.bind_clipboard_actions(self.keys_screen.ids)
|
||||||
|
|
||||||
|
|
||||||
self.keys_screen.ids.keys_scrollview.effect_cls = ScrollEffect
|
self.keys_screen.ids.keys_scrollview.effect_cls = ScrollEffect
|
||||||
info = "Your primary encryption keys are stored in a Reticulum Identity within the Sideband app. If you want to backup this Identity for later use on this or another device, you can export it as a plain text blob, with the key data encoded in Base32 format. This will allow you to restore your address in Sideband or other LXMF clients at a later point.\n\n[b]Warning![/b] Anyone that gets access to the key data will be able to control your LXMF address, impersonate you, and read your messages. In is [b]extremely important[/b] that you keep the Identity data secure if you export it.\n\nBefore displaying or exporting your Identity data, make sure that no machine or person in your vicinity is able to see, copy or record your device screen or similar."
|
info = "Your primary encryption keys are stored in a Reticulum Identity within the Sideband app. If you want to backup this Identity for later use on this or another device, you can export it as a plain text blob, with the key data encoded in Base32 format. This will allow you to restore your address in Sideband or other LXMF clients at a later point.\n\n[b]Warning![/b] Anyone that gets access to the key data will be able to control your LXMF address, impersonate you, and read your messages. In is [b]extremely important[/b] that you keep the Identity data secure if you export it.\n\nBefore displaying or exporting your Identity data, make sure that no machine or person in your vicinity is able to see, copy or record your device screen or similar."
|
||||||
|
@ -1121,7 +1121,6 @@ MDScreen:
|
|||||||
|
|
||||||
MDGridLayout:
|
MDGridLayout:
|
||||||
cols: 1
|
cols: 1
|
||||||
spacing: dp(16)
|
|
||||||
padding: [dp(28), dp(28), dp(28), dp(28)]
|
padding: [dp(28), dp(28), dp(28), dp(28)]
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
@ -1132,13 +1131,18 @@ MDScreen:
|
|||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.texture_size[1]
|
height: self.texture_size[1]
|
||||||
|
|
||||||
MDBoxLayout:
|
MDLabel:
|
||||||
id: telemetry_information_fields
|
id: settings_info1
|
||||||
orientation: "horizontal"
|
markup: True
|
||||||
|
text: ""
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
spacing: dp(16)
|
height: self.texture_size[1]
|
||||||
height: dp(64)
|
|
||||||
padding: [0, dp(0), 0, dp(0)]
|
MDBoxLayout:
|
||||||
|
orientation: "vertical"
|
||||||
|
size_hint_y: None
|
||||||
|
height: self.minimum_height
|
||||||
|
padding: [0, dp(24), 0, dp(24)]
|
||||||
|
|
||||||
MDTextField:
|
MDTextField:
|
||||||
id: settings_display_name
|
id: settings_display_name
|
||||||
@ -1147,20 +1151,20 @@ MDScreen:
|
|||||||
max_text_length: 128
|
max_text_length: 128
|
||||||
font_size: dp(24)
|
font_size: dp(24)
|
||||||
|
|
||||||
MDTextField:
|
MDTextField:
|
||||||
id: settings_propagation_node_address
|
id: settings_propagation_node_address
|
||||||
hint_text: "LXMF Propagation Node"
|
hint_text: "LXMF Propagation Node"
|
||||||
text: ""
|
text: ""
|
||||||
max_text_length: 32
|
max_text_length: 32
|
||||||
font_size: dp(24)
|
font_size: dp(24)
|
||||||
height: dp(64)
|
height: dp(64)
|
||||||
|
|
||||||
MDTextField:
|
MDTextField:
|
||||||
id: settings_print_command
|
id: settings_print_command
|
||||||
hint_text: "Print Command"
|
hint_text: "Print Command"
|
||||||
text: ""
|
text: ""
|
||||||
font_size: dp(24)
|
font_size: dp(24)
|
||||||
height: dp(64)
|
height: dp(64)
|
||||||
|
|
||||||
MDLabel:
|
MDLabel:
|
||||||
text: "Address & Identity"
|
text: "Address & Identity"
|
||||||
@ -1169,27 +1173,33 @@ MDScreen:
|
|||||||
height: self.texture_size[1]
|
height: self.texture_size[1]
|
||||||
|
|
||||||
MDLabel:
|
MDLabel:
|
||||||
id: settings_info1
|
id: settings_info2
|
||||||
markup: True
|
markup: True
|
||||||
text: "\\nYour address and identity hashes are derived from your primary identity keys, and are therefore not editable, but these fields can be used to view and copy the hashes. If you want a new LXMF address, create or import a new primary identity."
|
text: "\\nYour address and identity hashes are derived from your primary identity keys, and are therefore not editable, but these fields can be used to view and copy the hashes. If you want a new LXMF address, create or import a new primary identity.\\n"
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.texture_size[1]
|
height: self.texture_size[1]
|
||||||
|
|
||||||
MDTextField:
|
MDBoxLayout:
|
||||||
id: settings_lxmf_address
|
orientation: "vertical"
|
||||||
hint_text: "Your LXMF Address"
|
size_hint_y: None
|
||||||
text: ""
|
height: self.minimum_height
|
||||||
max_text_length: 32
|
padding: [0, dp(0), 0, dp(24)]
|
||||||
font_size: dp(24)
|
|
||||||
height: dp(64)
|
|
||||||
|
|
||||||
MDTextField:
|
MDTextField:
|
||||||
id: settings_identity_hash
|
id: settings_lxmf_address
|
||||||
hint_text: "Your Identity Hash"
|
hint_text: "Your LXMF Address"
|
||||||
text: ""
|
text: ""
|
||||||
max_text_length: 32
|
max_text_length: 32
|
||||||
font_size: dp(24)
|
font_size: dp(24)
|
||||||
height: dp(64)
|
height: dp(64)
|
||||||
|
|
||||||
|
MDTextField:
|
||||||
|
id: settings_identity_hash
|
||||||
|
hint_text: "Your Identity Hash"
|
||||||
|
text: ""
|
||||||
|
max_text_length: 32
|
||||||
|
font_size: dp(24)
|
||||||
|
height: dp(64)
|
||||||
|
|
||||||
MDBoxLayout:
|
MDBoxLayout:
|
||||||
orientation: "horizontal"
|
orientation: "horizontal"
|
||||||
|
@ -38,6 +38,7 @@ class Telemetry():
|
|||||||
self.screen.app = self.app
|
self.screen.app = self.app
|
||||||
self.screen.delegate = self
|
self.screen.delegate = self
|
||||||
self.app.root.ids.screen_manager.add_widget(self.screen)
|
self.app.root.ids.screen_manager.add_widget(self.screen)
|
||||||
|
self.app.bind_clipboard_actions(self.screen.ids)
|
||||||
|
|
||||||
self.screen.ids.telemetry_collector.bind(focus=self.telemetry_save)
|
self.screen.ids.telemetry_collector.bind(focus=self.telemetry_save)
|
||||||
if self.app.sideband.config["telemetry_collector"] == None:
|
if self.app.sideband.config["telemetry_collector"] == None:
|
||||||
@ -319,6 +320,7 @@ class Telemetry():
|
|||||||
self.sensors_screen.app = self.app
|
self.sensors_screen.app = self.app
|
||||||
self.sensors_screen.delegate = self
|
self.sensors_screen.delegate = self
|
||||||
self.app.root.ids.screen_manager.add_widget(self.sensors_screen)
|
self.app.root.ids.screen_manager.add_widget(self.sensors_screen)
|
||||||
|
self.bind_clipboard_actions(self.sensors_screen.ids)
|
||||||
|
|
||||||
info3 = "\nTo include a specific type of telemetry data while sending, it must be enabled below. Please note that some sensor types are not supported on all devices. Sideband will only be able to read a specific type of sensor if your device actually includes hardware for it.\n"
|
info3 = "\nTo include a specific type of telemetry data while sending, it must be enabled below. Please note that some sensor types are not supported on all devices. Sideband will only be able to read a specific type of sensor if your device actually includes hardware for it.\n"
|
||||||
if self.app.theme_cls.theme_style == "Dark":
|
if self.app.theme_cls.theme_style == "Dark":
|
||||||
|
Loading…
Reference in New Issue
Block a user