mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02:00
Added map view and telemetry configuration
This commit is contained in:
parent
f0fa742339
commit
a7c84660a0
244
sbapp/main.py
244
sbapp/main.py
@ -1,6 +1,6 @@
|
||||
__debug_build__ = False
|
||||
__disable_shaders__ = False
|
||||
__version__ = "0.6.2"
|
||||
__version__ = "0.6.3"
|
||||
__variant__ = "beta"
|
||||
|
||||
import sys
|
||||
@ -30,7 +30,9 @@ if RNS.vendor.platformutils.get_platform() != "android":
|
||||
local = os.path.dirname(__file__)
|
||||
sys.path.append(local)
|
||||
|
||||
from typing import Union
|
||||
from kivymd.app import MDApp
|
||||
from kivymd.icon_definitions import md_icons
|
||||
from kivy.core.window import Window
|
||||
from kivy.core.clipboard import Clipboard
|
||||
from kivy.base import EventLoop
|
||||
@ -39,6 +41,9 @@ from kivy.lang.builder import Builder
|
||||
from kivy.effects.scroll import ScrollEffect
|
||||
from kivy.uix.screenmanager import ScreenManager
|
||||
from kivy.uix.screenmanager import FadeTransition, NoTransition
|
||||
from kivymd.uix.list import OneLineIconListItem
|
||||
from kivy.properties import StringProperty
|
||||
from kivymd.uix.pickers import MDColorPicker
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
from sideband.core import SidebandCore
|
||||
@ -111,6 +116,7 @@ class SidebandApp(MDApp):
|
||||
self.conversations_view = None
|
||||
self.sync_dialog = None
|
||||
self.settings_ready = False
|
||||
self.telemetry_ready = False
|
||||
self.connectivity_ready = False
|
||||
self.hardware_ready = False
|
||||
self.repository_ready = False
|
||||
@ -683,7 +689,7 @@ class SidebandApp(MDApp):
|
||||
if self.root.ids.screen_manager.current == "conversations_screen":
|
||||
self.quit_action(self)
|
||||
else:
|
||||
self.open_conversations()
|
||||
self.open_conversations(direction="right")
|
||||
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "s" or text == "d"):
|
||||
if self.root.ids.screen_manager.current == "messages_screen":
|
||||
self.message_send_action()
|
||||
@ -2802,6 +2808,220 @@ class SidebandApp(MDApp):
|
||||
|
||||
c_dialog.open()
|
||||
|
||||
### Telemetry Screen
|
||||
######################################
|
||||
|
||||
def telemetry_init(self):
|
||||
if not self.telemetry_ready:
|
||||
self.root.ids.telemetry_collector.bind(focus=self.telemetry_save)
|
||||
if self.sideband.config["telemetry_collector"] == None:
|
||||
self.root.ids.telemetry_collector.text = ""
|
||||
else:
|
||||
self.root.ids.telemetry_collector.text = RNS.hexrep(self.sideband.config["telemetry_collector"], delimit=False)
|
||||
|
||||
self.root.ids.telemetry_icon_preview.icon_color = self.sideband.config["telemetry_fg"]
|
||||
self.root.ids.telemetry_icon_preview.md_bg_color = self.sideband.config["telemetry_bg"]
|
||||
self.root.ids.telemetry_icon_preview.icon = self.sideband.config["telemetry_icon"]
|
||||
|
||||
self.root.ids.telemetry_enabled.active = self.sideband.config["telemetry_enabled"]
|
||||
self.root.ids.telemetry_enabled.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_send_to_collector.active = self.sideband.config["telemetry_send_to_collector"]
|
||||
self.root.ids.telemetry_send_to_collector.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_send_to_trusted.active = self.sideband.config["telemetry_send_to_trusted"]
|
||||
self.root.ids.telemetry_send_to_trusted.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_location.active = self.sideband.config["telemetry_s_location"]
|
||||
self.root.ids.telemetry_s_location.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_orientation.active = self.sideband.config["telemetry_s_orientation"]
|
||||
self.root.ids.telemetry_s_orientation.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_battery.active = self.sideband.config["telemetry_s_battery"]
|
||||
self.root.ids.telemetry_s_battery.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_barometer.active = self.sideband.config["telemetry_s_barometer"]
|
||||
self.root.ids.telemetry_s_barometer.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_temperature.active = self.sideband.config["telemetry_s_temperature"]
|
||||
self.root.ids.telemetry_s_temperature.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_humidity.active = self.sideband.config["telemetry_s_humidity"]
|
||||
self.root.ids.telemetry_s_humidity.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_compass.active = self.sideband.config["telemetry_s_compass"]
|
||||
self.root.ids.telemetry_s_compass.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_light.active = self.sideband.config["telemetry_s_light"]
|
||||
self.root.ids.telemetry_s_light.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_gravity.active = self.sideband.config["telemetry_s_gravity"]
|
||||
self.root.ids.telemetry_s_gravity.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_gyroscope.active = self.sideband.config["telemetry_s_gyroscope"]
|
||||
self.root.ids.telemetry_s_gyroscope.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_accelerometer.active = self.sideband.config["telemetry_s_accelerometer"]
|
||||
self.root.ids.telemetry_s_accelerometer.bind(active=self.telemetry_save)
|
||||
|
||||
self.root.ids.telemetry_s_proximity.active = self.sideband.config["telemetry_s_proximity"]
|
||||
self.root.ids.telemetry_s_proximity.bind(active=self.telemetry_save)
|
||||
|
||||
self.telemetry_ready = True
|
||||
|
||||
def telemetry_set_icon(self, text="", search=False):
|
||||
if text in md_icons.keys():
|
||||
self.root.ids.telemetry_icon_preview.icon = text
|
||||
else:
|
||||
self.root.ids.telemetry_icon_preview.icon = "alpha-p-circle-outline"
|
||||
|
||||
self.sideband.config["telemetry_icon"] = self.root.ids.telemetry_icon_preview.icon
|
||||
self.sideband.save_configuration()
|
||||
|
||||
|
||||
def telemetry_save(self, sender=None, event=None):
|
||||
if len(self.root.ids.telemetry_collector.text) != 32:
|
||||
self.root.ids.telemetry_collector.text = ""
|
||||
self.sideband.config["telemetry_collector"] = None
|
||||
else:
|
||||
try:
|
||||
self.sideband.config["telemetry_collector"] = bytes.fromhex(self.root.ids.telemetry_collector.text)
|
||||
except:
|
||||
self.root.ids.telemetry_collector.text = ""
|
||||
self.sideband.config["telemetry_collector"] = None
|
||||
|
||||
self.sideband.config["telemetry_enabled"] = self.root.ids.telemetry_enabled.active
|
||||
self.sideband.config["telemetry_send_to_collector"] = self.root.ids.telemetry_send_to_collector.active
|
||||
self.sideband.config["telemetry_send_to_trusted"] = self.root.ids.telemetry_send_to_trusted.active
|
||||
|
||||
self.sideband.config["telemetry_s_location"] = self.root.ids.telemetry_s_location.active
|
||||
self.sideband.config["telemetry_s_orientation"] = self.root.ids.telemetry_s_orientation.active
|
||||
self.sideband.config["telemetry_s_battery"] = self.root.ids.telemetry_s_battery.active
|
||||
self.sideband.config["telemetry_s_barometer"] = self.root.ids.telemetry_s_barometer.active
|
||||
self.sideband.config["telemetry_s_temperature"] = self.root.ids.telemetry_s_temperature.active
|
||||
self.sideband.config["telemetry_s_humidity"] = self.root.ids.telemetry_s_humidity.active
|
||||
self.sideband.config["telemetry_s_compass"] = self.root.ids.telemetry_s_compass.active
|
||||
self.sideband.config["telemetry_s_light"] = self.root.ids.telemetry_s_light.active
|
||||
self.sideband.config["telemetry_s_gravity"] = self.root.ids.telemetry_s_gravity.active
|
||||
self.sideband.config["telemetry_s_gyroscope"] = self.root.ids.telemetry_s_gyroscope.active
|
||||
self.sideband.config["telemetry_s_accelerometer"] = self.root.ids.telemetry_s_accelerometer.active
|
||||
self.sideband.config["telemetry_s_proximity"] = self.root.ids.telemetry_s_proximity.active
|
||||
|
||||
self.sideband.save_configuration()
|
||||
|
||||
def telemetry_action(self, sender=None, direction="left"):
|
||||
self.telemetry_init()
|
||||
self.root.ids.telemetry_scrollview.effect_cls = ScrollEffect
|
||||
info = "\nSideband allows you to securely share telemetry, such as location and sensor data, with people, custom programs, machines or other system over LXMF. You have complete control over what kind of telemetry to send, and who you share it with. Telemetry data is never sent to, via or processed by any external services or servers, but is carried exclusively within encrypted LXMF messages over Reticulum.\n\nWhen telemetry is enabled, it is possible to embed telemetry data in normal messages on a per-peer basis. You can control this from the [b]Conversations[/b] list, by selecting the [b]Edit[/b] option for the relevant peer.\n\nYou can also define a [b]Telemetry Collector[/b], that Sideband will automatically send telemetry to on a periodic basis - for example your Nomad Network home node.\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.theme_cls.theme_style == "Dark":
|
||||
info = "[color=#"+dark_theme_text_color+"]"+info+"[/color]"
|
||||
# info2 = "[color=#"+dark_theme_text_color+"]"+info2+"[/color]"
|
||||
info3 = "[color=#"+dark_theme_text_color+"]"+info3+"[/color]"
|
||||
|
||||
self.root.ids.telemetry_info.text = info
|
||||
# self.root.ids.telemetry_info2.text = info2
|
||||
self.root.ids.telemetry_info3.text = info3
|
||||
self.root.ids.screen_manager.transition.direction = direction
|
||||
self.root.ids.screen_manager.current = "telemetry_screen"
|
||||
self.root.ids.nav_drawer.set_state("closed")
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
def telemetry_fg_color(self, sender=None):
|
||||
color_picker = MDColorPicker(size_hint=(0.85, 0.85))
|
||||
color_picker.open()
|
||||
color_picker.bind(
|
||||
on_release=self.telemetry_fg_select,
|
||||
)
|
||||
self.color_picker = color_picker
|
||||
|
||||
def telemetry_fg_select(self, instance_color_picker: MDColorPicker, type_color: str, selected_color: Union[list, str]):
|
||||
color = selected_color[:-1] + [1]
|
||||
self.root.ids.telemetry_icon_preview.icon_color = color
|
||||
self.sideband.config["telemetry_fg"] = color
|
||||
self.sideband.save_configuration()
|
||||
if hasattr(self, "color_picker") and self.color_picker != None:
|
||||
self.color_picker.dismiss()
|
||||
self.color_picker = None
|
||||
|
||||
def telemetry_bg_color(self, sender=None):
|
||||
color_picker = MDColorPicker(size_hint=(0.85, 0.85))
|
||||
color_picker.open()
|
||||
color_picker.bind(
|
||||
on_release=self.telemetry_bg_select,
|
||||
)
|
||||
self.color_picker = color_picker
|
||||
|
||||
def telemetry_bg_select(self, instance_color_picker: MDColorPicker, type_color: str, selected_color: Union[list, str]):
|
||||
color = selected_color[:-1] + [1]
|
||||
self.root.ids.telemetry_icon_preview.md_bg_color = color
|
||||
self.sideband.config["telemetry_bg"] = color
|
||||
if hasattr(self, "color_picker") and self.color_picker != None:
|
||||
self.color_picker.dismiss()
|
||||
self.color_picker = None
|
||||
|
||||
def close_sub_telemetry_action(self, sender=None):
|
||||
self.telemetry_action(direction="right")
|
||||
|
||||
### Icons Screen
|
||||
######################################
|
||||
|
||||
def icons_action(self, sender=None):
|
||||
self.icons_filter()
|
||||
self.root.ids.screen_manager.transition.direction = "left"
|
||||
self.root.ids.screen_manager.current = "icons_screen"
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
def icons_selected(self, selected=None):
|
||||
RNS.log("Selected: "+str(selected))
|
||||
if selected == None:
|
||||
selected = "alpha-p-circle-outline"
|
||||
self.telemetry_set_icon(selected)
|
||||
self.close_sub_telemetry_action()
|
||||
|
||||
|
||||
def icons_filter(self, text="", search=False):
|
||||
def add_icon_item(name_icon):
|
||||
def select_factory(x):
|
||||
def f():
|
||||
self.root.ids.screen_manager.app.icons_selected(x)
|
||||
return f
|
||||
|
||||
self.root.ids.icons_rv.data.append(
|
||||
{
|
||||
"viewclass": "CustomOneLineIconListItem",
|
||||
"icon": name_icon,
|
||||
"text": name_icon,
|
||||
"callback": lambda x: x,
|
||||
"on_release": select_factory(name_icon)
|
||||
}
|
||||
)
|
||||
|
||||
self.root.ids.icons_rv.data = []
|
||||
for name_icon in md_icons.keys():
|
||||
if search:
|
||||
if text in name_icon:
|
||||
add_icon_item(name_icon)
|
||||
else:
|
||||
add_icon_item(name_icon)
|
||||
|
||||
### Map Screen
|
||||
######################################
|
||||
|
||||
def map_action(self, sender=None):
|
||||
if not hasattr(self.root.ids.map_layout, "map") or self.root.ids.map_layout.map == None:
|
||||
from mapview import MapView
|
||||
mapview = MapView(zoom=11, lat=50.6394, lon=3.057)
|
||||
mapview.snap_to_zoom = False
|
||||
mapview.double_tap_zoom = False
|
||||
self.root.ids.map_layout.map = mapview
|
||||
self.root.ids.map_layout.add_widget(self.root.ids.map_layout.map)
|
||||
|
||||
self.root.ids.screen_manager.transition.direction = "left"
|
||||
self.root.ids.screen_manager.current = "map_screen"
|
||||
self.root.ids.nav_drawer.set_state("closed")
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
### Guide screen
|
||||
######################################
|
||||
@ -2892,27 +3112,10 @@ Thank you very much for using Free Communications Systems.
|
||||
self.root.ids.nav_drawer.set_state("closed")
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
|
||||
#################################################
|
||||
# Unimplemented Screens #
|
||||
#################################################
|
||||
|
||||
def map_action(self, sender=None):
|
||||
def link_exec(sender=None, event=None):
|
||||
import webbrowser
|
||||
webbrowser.open("https://unsigned.io/donate")
|
||||
|
||||
self.root.ids.map_scrollview.effect_cls = ScrollEffect
|
||||
info = "The [b]Local Area[/b] feature is not yet implemented in Sideband.\n\nWant it faster? Go to [u][ref=link]https://unsigned.io/donate[/ref][/u] to support the project."
|
||||
if self.theme_cls.theme_style == "Dark":
|
||||
info = "[color=#"+dark_theme_text_color+"]"+info+"[/color]"
|
||||
self.root.ids.map_info.text = info
|
||||
self.root.ids.map_info.bind(on_ref_press=link_exec)
|
||||
self.root.ids.screen_manager.transition.direction = "left"
|
||||
self.root.ids.screen_manager.current = "map_screen"
|
||||
self.root.ids.nav_drawer.set_state("closed")
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
def broadcasts_action(self, sender=None):
|
||||
def link_exec(sender=None, event=None):
|
||||
import webbrowser
|
||||
@ -2929,7 +3132,8 @@ Thank you very much for using Free Communications Systems.
|
||||
self.root.ids.nav_drawer.set_state("closed")
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
|
||||
class CustomOneLineIconListItem(OneLineIconListItem):
|
||||
icon = StringProperty()
|
||||
|
||||
def run():
|
||||
SidebandApp().run()
|
||||
|
@ -11,6 +11,7 @@ import RNS.vendor.umsgpack as msgpack
|
||||
import RNS.Interfaces.Interface as Interface
|
||||
|
||||
from .res import sideband_fb_data
|
||||
from .sense import Telemeter
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
from jnius import autoclass, cast
|
||||
@ -96,6 +97,7 @@ class SidebandCore():
|
||||
self.owner_app = owner_app
|
||||
self.reticulum = None
|
||||
self.webshare_server = None
|
||||
self.telemeter = None
|
||||
|
||||
self.app_dir = plyer.storagepath.get_home_dir()+"/.config/sideband"
|
||||
if self.app_dir.startswith("file://"):
|
||||
@ -267,6 +269,7 @@ class SidebandCore():
|
||||
self.config["connect_ifmode_modem"] = "full"
|
||||
self.config["connect_ifmode_serial"] = "full"
|
||||
self.config["connect_ifmode_bluetooth"] = "full"
|
||||
|
||||
# Hardware
|
||||
self.config["hw_rnode_frequency"] = None
|
||||
self.config["hw_rnode_modulation"] = "LoRa"
|
||||
@ -293,6 +296,12 @@ class SidebandCore():
|
||||
self.config["hw_serial_stopbits"] = 1
|
||||
self.config["hw_serial_parity"] = "none"
|
||||
|
||||
# Telemetry
|
||||
self.config["telemetry_enabled"] = False
|
||||
self.config["telemetry_icon"] = "alpha-p-circle-outline"
|
||||
self.config["telemetry_send_to_trusted"] = False
|
||||
self.config["telemetry_send_to_collector"] = False
|
||||
|
||||
if not os.path.isfile(self.db_path):
|
||||
self.__db_init()
|
||||
else:
|
||||
@ -427,6 +436,47 @@ class SidebandCore():
|
||||
if not "hw_serial_parity" in self.config:
|
||||
self.config["hw_serial_parity"] = "none"
|
||||
|
||||
if not "telemetry_enabled" in self.config:
|
||||
self.config["telemetry_enabled"] = False
|
||||
if not "telemetry_collector" in self.config:
|
||||
self.config["telemetry_collector"] = None
|
||||
if not "telemetry_send_to_trusted" in self.config:
|
||||
self.config["telemetry_send_to_trusted"] = False
|
||||
if not "telemetry_send_to_collector" in self.config:
|
||||
self.config["telemetry_send_to_collector"] = False
|
||||
|
||||
if not "telemetry_icon" in self.config:
|
||||
self.config["telemetry_icon"] = "alpha-p-circle-outline"
|
||||
if not "telemetry_fg" in self.config:
|
||||
self.config["telemetry_fg"] = [0,0,0,1]
|
||||
if not "telemetry_bg" in self.config:
|
||||
self.config["telemetry_bg"] = [1,1,1,1]
|
||||
|
||||
if not "telemetry_s_location" in self.config:
|
||||
self.config["telemetry_s_location"] = False
|
||||
if not "telemetry_s_orientation" in self.config:
|
||||
self.config["telemetry_s_orientation"] = False
|
||||
if not "telemetry_s_battery" in self.config:
|
||||
self.config["telemetry_s_battery"] = False
|
||||
if not "telemetry_s_barometer" in self.config:
|
||||
self.config["telemetry_s_barometer"] = False
|
||||
if not "telemetry_s_temperature" in self.config:
|
||||
self.config["telemetry_s_temperature"] = False
|
||||
if not "telemetry_s_humidity" in self.config:
|
||||
self.config["telemetry_s_humidity"] = False
|
||||
if not "telemetry_s_compass" in self.config:
|
||||
self.config["telemetry_s_compass"] = False
|
||||
if not "telemetry_s_light" in self.config:
|
||||
self.config["telemetry_s_light"] = False
|
||||
if not "telemetry_s_gravity" in self.config:
|
||||
self.config["telemetry_s_gravity"] = False
|
||||
if not "telemetry_s_gyroscope" in self.config:
|
||||
self.config["telemetry_s_gyroscope"] = False
|
||||
if not "telemetry_s_accelerometer" in self.config:
|
||||
self.config["telemetry_s_accelerometer"] = False
|
||||
if not "telemetry_s_proximity" in self.config:
|
||||
self.config["telemetry_s_proximity"] = False
|
||||
|
||||
# Make sure we have a database
|
||||
if not os.path.isfile(self.db_path):
|
||||
self.__db_init()
|
||||
@ -547,6 +597,22 @@ class SidebandCore():
|
||||
RNS.log("Error while checking trust for "+RNS.prettyhexrep(context_dest)+": "+str(e), RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
def should_send_telemetry(self, context_dest):
|
||||
try:
|
||||
existing_conv = self._db_conversation(context_dest)
|
||||
if existing_conv != None:
|
||||
cd = existing_conv["data"]
|
||||
if cd != None and "telemetry" in cd and cd["telemetry"] == True:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while checking telemetry sending for "+RNS.prettyhexrep(context_dest)+": "+str(e), RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
def raw_display_name(self, context_dest):
|
||||
try:
|
||||
existing_conv = self._db_conversation(context_dest)
|
||||
@ -621,6 +687,12 @@ class SidebandCore():
|
||||
def untrusted_conversation(self, context_dest):
|
||||
self._db_conversation_set_trusted(context_dest, False)
|
||||
|
||||
def send_telemetry_in_conversation(self, context_dest):
|
||||
self._db_conversation_set_telemetry(context_dest, True)
|
||||
|
||||
def no_telemetry_in_conversation(self, context_dest):
|
||||
self._db_conversation_set_telemetry(context_dest, False)
|
||||
|
||||
def named_conversation(self, name, context_dest):
|
||||
self._db_conversation_set_name(context_dest, name)
|
||||
|
||||
@ -920,6 +992,24 @@ class SidebandCore():
|
||||
result = dbc.fetchall()
|
||||
db.commit()
|
||||
|
||||
def _db_conversation_set_telemetry(self, context_dest, send_telemetry=False):
|
||||
conv = self._db_conversation(context_dest)
|
||||
data_dict = conv["data"]
|
||||
if data_dict == None:
|
||||
data_dict = {}
|
||||
|
||||
data_dict["telemetry"] = send_telemetry
|
||||
packed_dict = msgpack.packb(data_dict)
|
||||
|
||||
db = self.__db_connect()
|
||||
dbc = db.cursor()
|
||||
|
||||
query = "UPDATE conv set data = ? where dest_context = ?"
|
||||
data = (packed_dict, context_dest)
|
||||
dbc.execute(query, data)
|
||||
result = dbc.fetchall()
|
||||
db.commit()
|
||||
|
||||
def _db_conversation_set_trusted(self, context_dest, trusted):
|
||||
db = self.__db_connect()
|
||||
dbc = db.cursor()
|
||||
@ -1322,6 +1412,9 @@ class SidebandCore():
|
||||
# TODO: The "start_announce" config entry should be
|
||||
# renamed to "auto_announce", which is its current
|
||||
# meaning.
|
||||
if self.config["telemetry_enabled"] == True:
|
||||
pass
|
||||
|
||||
if self.config["start_announce"] == True:
|
||||
needs_if_change_announce = False
|
||||
|
||||
|
@ -25,6 +25,7 @@ class ConvSettings(BoxLayout):
|
||||
disp_name = StringProperty()
|
||||
context_dest = StringProperty()
|
||||
trusted = BooleanProperty()
|
||||
telemetry = BooleanProperty()
|
||||
|
||||
class Conversations():
|
||||
def __init__(self, app):
|
||||
@ -116,10 +117,11 @@ class Conversations():
|
||||
try:
|
||||
disp_name = self.app.sideband.raw_display_name(dest)
|
||||
is_trusted = self.app.sideband.is_trusted(dest)
|
||||
send_telemetry = self.app.sideband.should_send_telemetry(dest)
|
||||
|
||||
yes_button = MDRectangleFlatButton(text="Save",font_size=dp(18), theme_text_color="Custom", line_color=self.app.color_accept, text_color=self.app.color_accept)
|
||||
no_button = MDRectangleFlatButton(text="Cancel",font_size=dp(18))
|
||||
dialog_content = ConvSettings(disp_name=disp_name, context_dest=RNS.hexrep(dest, delimit=False), trusted=is_trusted)
|
||||
dialog_content = ConvSettings(disp_name=disp_name, context_dest=RNS.hexrep(dest, delimit=False), trusted=is_trusted, telemetry=send_telemetry)
|
||||
dialog = MDDialog(
|
||||
title="Edit Conversation",
|
||||
text= "With "+RNS.prettyhexrep(dest),
|
||||
@ -133,14 +135,17 @@ class Conversations():
|
||||
try:
|
||||
name = dialog.d_content.ids["name_field"].text
|
||||
trusted = dialog.d_content.ids["trusted_switch"].active
|
||||
telemetry = dialog.d_content.ids["telemetry_switch"].active
|
||||
if trusted:
|
||||
RNS.log("Setting Trusted "+str(trusted))
|
||||
self.app.sideband.trusted_conversation(dest)
|
||||
else:
|
||||
RNS.log("Setting Untrusted "+str(trusted))
|
||||
self.app.sideband.untrusted_conversation(dest)
|
||||
|
||||
RNS.log("Name="+name)
|
||||
if telemetry:
|
||||
self.app.sideband.send_telemetry_in_conversation(dest)
|
||||
else:
|
||||
self.app.sideband.no_telemetry_in_conversation(dest)
|
||||
|
||||
self.app.sideband.named_conversation(name, dest)
|
||||
|
||||
except Exception as e:
|
||||
@ -159,7 +164,7 @@ class Conversations():
|
||||
no_button.bind(on_release=dl_no)
|
||||
item.dmenu.dismiss()
|
||||
dialog.open()
|
||||
RNS.log("Generated edit dialog in "+str(RNS.prettytime(time.time()-t_s)))
|
||||
RNS.log("Generated edit dialog in "+str(RNS.prettytime(time.time()-t_s)), RNS.LOG_DEBUG)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while creating conversation settings: "+str(e), RNS.LOG_ERROR)
|
||||
|
@ -1,6 +1,7 @@
|
||||
root_layout = """
|
||||
#: import NoTransition kivy.uix.screenmanager.NoTransition
|
||||
#: import SlideTransition kivy.uix.screenmanager.SlideTransition
|
||||
#:import images_path kivymd.images_path
|
||||
|
||||
MDNavigationLayout:
|
||||
md_bg_color: app.theme_cls.bg_darkest
|
||||
@ -816,7 +817,27 @@ MDNavigationLayout:
|
||||
orientation: "vertical"
|
||||
|
||||
MDTopAppBar:
|
||||
title: "Local Area Map"
|
||||
title: "Situation Map"
|
||||
anchor_title: "left"
|
||||
elevation: 0
|
||||
left_action_items:
|
||||
[['menu', lambda x: nav_drawer.set_state("open")]]
|
||||
right_action_items:
|
||||
[
|
||||
['close', lambda x: root.ids.screen_manager.app.close_any_action(self)],
|
||||
]
|
||||
|
||||
MDBoxLayout:
|
||||
id: map_layout
|
||||
|
||||
MDScreen:
|
||||
name: "telemetry_screen"
|
||||
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
|
||||
MDTopAppBar:
|
||||
title: "Telemetry"
|
||||
anchor_title: "left"
|
||||
elevation: 0
|
||||
left_action_items:
|
||||
@ -827,24 +848,426 @@ MDNavigationLayout:
|
||||
]
|
||||
|
||||
ScrollView:
|
||||
id:map_scrollview
|
||||
id: telemetry_scrollview
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "vertical"
|
||||
spacing: "24dp"
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
padding: [dp(35), dp(35), dp(35), dp(35)]
|
||||
|
||||
padding: [dp(28), dp(48), dp(28), dp(16)]
|
||||
|
||||
MDLabel:
|
||||
id: map_info
|
||||
text: "Telemetry Over LXMF"
|
||||
font_style: "H6"
|
||||
|
||||
MDLabel:
|
||||
id: telemetry_info
|
||||
markup: True
|
||||
text: ""
|
||||
size_hint_y: None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
|
||||
|
||||
MDBoxLayout:
|
||||
id: telemetry_enabled_fields
|
||||
orientation: "vertical"
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
padding: [0, 0, 0, dp(0)]
|
||||
|
||||
MDTextField:
|
||||
id: telemetry_collector
|
||||
max_text_length: 32
|
||||
hint_text: "Telemetry Collector Address"
|
||||
text: ""
|
||||
font_size: dp(24)
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
padding: [0,0,dp(24),0]
|
||||
size_hint_y: None
|
||||
height: dp(48)
|
||||
|
||||
MDLabel:
|
||||
id: telemetry_enabled_label
|
||||
text: "Enable Telemetry"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_enabled
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Automatically send to collector"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_send_to_collector
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Send to all trusted peers"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_send_to_trusted
|
||||
pos_hint: {"center_y": 0.3}
|
||||
active: False
|
||||
|
||||
MDLabel:
|
||||
markup: True
|
||||
text: "\\n\\n"
|
||||
size_hint_y: None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
|
||||
MDLabel:
|
||||
text: "Display Options"
|
||||
font_style: "H6"
|
||||
|
||||
MDLabel:
|
||||
id: telemetry_info4
|
||||
markup: True
|
||||
text: "\\nYou can customise the display style of your telemetry data when viewed by others, by setting an icon and color options. This is usually used by clients to display your telemetry entry on a map or in lists and overviews. If left unset, the receiver will decide how to display the data.\\n\\n"
|
||||
size_hint_y: None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "vertical"
|
||||
size_hint_y: None
|
||||
size_hint_x: None
|
||||
# height: dp(96)
|
||||
# width: dp(64)
|
||||
spacing: dp(0)
|
||||
padding: [dp(0), dp(24), dp(0), dp(24)]
|
||||
pos_hint: {"center_x": .5}
|
||||
|
||||
MDIconButton:
|
||||
pos_hint: {"center_x": .5, "center_y": .5}
|
||||
id: telemetry_icon_preview
|
||||
icon: "alpha-p-circle-outline"
|
||||
type: "large"
|
||||
theme_icon_color: "Custom"
|
||||
icon_color: [0, 0, 0, 1]
|
||||
md_bg_color: [1, 1, 1, 1]
|
||||
icon_size: dp(64)
|
||||
# width: dp(64)
|
||||
# height: dp(64)
|
||||
|
||||
|
||||
MDRectangleFlatIconButton:
|
||||
id: telemetry_icons_button
|
||||
icon: "list-box-outline"
|
||||
text: "Select From Available Icons"
|
||||
padding: [dp(0), dp(14), dp(0), dp(14)]
|
||||
icon_size: dp(24)
|
||||
font_size: dp(16)
|
||||
size_hint: [1.0, None]
|
||||
on_release: root.ids.screen_manager.app.icons_action(self)
|
||||
disabled: False
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "vertical"
|
||||
size_hint_y: None
|
||||
padding: [dp(0),dp(24),dp(0),dp(0)]
|
||||
height: dp(74)
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
#size_hint_y: None
|
||||
spacing: dp(24)
|
||||
# padding: [0,0,dp(24),dp(0)]
|
||||
# height: dp(48)
|
||||
|
||||
MDRectangleFlatIconButton:
|
||||
id: telemetry_icons_button
|
||||
icon: "list-box-outline"
|
||||
text: "Set Foreground Color"
|
||||
padding: [dp(0), dp(14), dp(0), dp(14)]
|
||||
icon_size: dp(24)
|
||||
font_size: dp(16)
|
||||
size_hint: [1.0, None]
|
||||
on_release: root.ids.screen_manager.app.telemetry_fg_color(self)
|
||||
disabled: False
|
||||
|
||||
MDRectangleFlatIconButton:
|
||||
id: telemetry_icons_button
|
||||
icon: "list-box-outline"
|
||||
text: "Set Background Color"
|
||||
padding: [dp(0), dp(14), dp(0), dp(14)]
|
||||
icon_size: dp(24)
|
||||
font_size: dp(16)
|
||||
size_hint: [1.0, None]
|
||||
on_release: root.ids.screen_manager.app.telemetry_bg_color(self)
|
||||
disabled: False
|
||||
|
||||
MDLabel:
|
||||
markup: True
|
||||
text: "\\n\\n\\n"
|
||||
size_hint_y: None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
|
||||
MDLabel:
|
||||
text: "Sensor Types"
|
||||
font_style: "H6"
|
||||
|
||||
MDLabel:
|
||||
id: telemetry_info3
|
||||
markup: True
|
||||
text: ""
|
||||
size_hint_y: None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
padding: [0,0,dp(24),dp(0)]
|
||||
height: dp(48)
|
||||
|
||||
MDLabel:
|
||||
text: "Location"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_location
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Orientation"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_orientation
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Battery State"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_battery
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Barometer"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_barometer
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Temperature"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_temperature
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Humidity"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_humidity
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Compass"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_compass
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Ambient Light"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_light
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Gravity"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_gravity
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Gyroscope"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_gyroscope
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Accelerometer"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_accelerometer
|
||||
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)
|
||||
|
||||
MDLabel:
|
||||
text: "Proximity"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_s_proximity
|
||||
pos_hint: {"center_y": 0.3}
|
||||
active: False
|
||||
|
||||
MDLabel:
|
||||
markup: True
|
||||
text: "\\n"
|
||||
size_hint_y: None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
|
||||
MDScreen:
|
||||
name: "icons_screen"
|
||||
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
|
||||
MDTopAppBar:
|
||||
title: "Available Icons"
|
||||
anchor_title: "left"
|
||||
elevation: 0
|
||||
left_action_items:
|
||||
[['menu', lambda x: nav_drawer.set_state("open")]]
|
||||
right_action_items:
|
||||
[
|
||||
['close', lambda x: root.ids.screen_manager.app.close_sub_telemetry_action(self)],
|
||||
]
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: 'vertical'
|
||||
spacing: dp(10)
|
||||
padding: dp(20)
|
||||
|
||||
MDBoxLayout:
|
||||
adaptive_height: True
|
||||
|
||||
MDIconButton:
|
||||
icon: 'magnify'
|
||||
|
||||
MDTextField:
|
||||
id: icons_search_field
|
||||
hint_text: 'Search icon'
|
||||
on_text: root.ids.screen_manager.app.icons_filter(self.text, True)
|
||||
|
||||
RecycleView:
|
||||
id: icons_rv
|
||||
key_viewclass: 'viewclass'
|
||||
key_size: 'height'
|
||||
|
||||
RecycleBoxLayout:
|
||||
padding: dp(10)
|
||||
default_size: None, dp(48)
|
||||
default_size_hint: 1, None
|
||||
size_hint_y: None
|
||||
height: self.minimum_height
|
||||
orientation: 'vertical'
|
||||
|
||||
|
||||
MDScreen:
|
||||
name: "keys_screen"
|
||||
@ -1032,14 +1455,6 @@ MDNavigationLayout:
|
||||
max_text_length: 32
|
||||
font_size: dp(24)
|
||||
|
||||
MDTextField:
|
||||
id: settings_home_node_address
|
||||
hint_text: "Nomad Network Home Node"
|
||||
disabled: False
|
||||
text: ""
|
||||
max_text_length: 32
|
||||
font_size: dp(24)
|
||||
|
||||
MDTextField:
|
||||
id: settings_print_command
|
||||
hint_text: "Print Command"
|
||||
@ -1235,22 +1650,6 @@ MDNavigationLayout:
|
||||
active: False
|
||||
disabled: True
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
padding: [0,0,dp(24),dp(0)]
|
||||
height: dp(48)
|
||||
|
||||
MDLabel:
|
||||
text: "Send Telemetry to Home Node"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: settings_telemetry_to_home_node
|
||||
pos_hint: {"center_y": 0.3}
|
||||
disabled: True
|
||||
active: False
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
@ -1974,7 +2373,7 @@ MDNavigationLayout:
|
||||
|
||||
|
||||
OneLineIconListItem:
|
||||
text: "Local Area Map"
|
||||
text: "Situation Map"
|
||||
on_release: root.ids.screen_manager.app.map_action(self)
|
||||
|
||||
IconLeftWidget:
|
||||
@ -1982,6 +2381,15 @@ MDNavigationLayout:
|
||||
on_release: root.ids.screen_manager.app.map_action(self)
|
||||
|
||||
|
||||
OneLineIconListItem:
|
||||
text: "Telemetry"
|
||||
on_release: root.ids.screen_manager.app.telemetry_action(self)
|
||||
|
||||
IconLeftWidget:
|
||||
icon: "axis-arrow-lock"
|
||||
on_release: root.ids.screen_manager.app.telemetry_action(self)
|
||||
|
||||
|
||||
OneLineIconListItem:
|
||||
text: "Preferences"
|
||||
on_release: root.ids.screen_manager.app.settings_action(self)
|
||||
@ -2146,6 +2554,22 @@ MDNavigationLayout:
|
||||
pos_hint: {"center_y": 0.43}
|
||||
active: root.trusted
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
# spacing: "24dp"
|
||||
size_hint_y: None
|
||||
padding: [0,0,dp(8),0]
|
||||
height: dp(48)
|
||||
MDLabel:
|
||||
id: telemetry_switch_label
|
||||
text: "Include Telemetry"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: telemetry_switch
|
||||
pos_hint: {"center_y": 0.43}
|
||||
active: root.telemetry
|
||||
|
||||
<NewConv>
|
||||
orientation: "vertical"
|
||||
spacing: "24dp"
|
||||
@ -2181,4 +2605,8 @@ MDNavigationLayout:
|
||||
id: n_trusted
|
||||
pos_hint: {"center_y": 0.3}
|
||||
active: False
|
||||
|
||||
<CustomOneLineIconListItem>
|
||||
IconLeftWidget:
|
||||
icon: root.icon
|
||||
"""
|
Loading…
Reference in New Issue
Block a user