Added connectivity status. Improved navigation.

This commit is contained in:
Mark Qvist 2022-07-06 16:08:53 +02:00
parent 8538daca3f
commit 23ab36a34f
7 changed files with 104 additions and 26 deletions

View File

@ -23,7 +23,10 @@ apk: prepare release postbuild
devapk: prepare debug postbuild devapk: prepare debug postbuild
install: install:
adb install bin/sideband-0.1.4-arm64-v8a-debug.apk adb install bin/sideband-0.1.5-arm64-v8a-debug.apk
install-release:
adb install bin/sideband-0.1.5-arm64-v8a-release.apk
console: console:
(adb logcat | grep python) (adb logcat | grep python)

76
main.py
View File

@ -9,6 +9,7 @@ from sideband.core import SidebandCore
from kivymd.app import MDApp from kivymd.app import MDApp
from kivy.core.window import Window from kivy.core.window import Window
from kivy.base import EventLoop
from kivy.clock import Clock from kivy.clock import Clock
from kivy.lang.builder import Builder from kivy.lang.builder import Builder
@ -85,13 +86,34 @@ class SidebandApp(MDApp):
self.announces_view.update() self.announces_view.update()
def on_start(self): def on_start(self):
self.last_exit_event = time.time()
EventLoop.window.bind(on_keyboard=self.keyboard_event)
EventLoop.window.bind(on_key_down=self.keydown_event)
self.root.ids.screen_manager.app = self self.root.ids.screen_manager.app = self
self.root.ids.app_version_info.text = "Sideband v"+__version__+" "+__variant__ self.root.ids.app_version_info.text = "Sideband v"+__version__+" "+__variant__
self.open_conversations() self.open_conversations()
Clock.schedule_interval(self.jobs, 1) Clock.schedule_interval(self.jobs, 1)
def keydown_event(self, instance, keyboard, keycode, text, modifiers):
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "w" or text == "q"):
self.quit_action(self)
def keyboard_event(self, window, key, *largs):
# Handle escape/back
if key == 27:
if self.root.ids.screen_manager.current == "conversations_screen":
if time.time() - self.last_exit_event < 2:
self.quit_action(self)
else:
self.last_exit_event = time.time()
else:
self.open_conversations(direction="right")
return True
def widget_hide(self, w, hide=True): def widget_hide(self, w, hide=True):
if hasattr(w, "saved_attrs"): if hasattr(w, "saved_attrs"):
if not hide: if not hide:
@ -277,6 +299,58 @@ class SidebandApp(MDApp):
self.root.ids.screen_manager.current = "conversations_screen" self.root.ids.screen_manager.current = "conversations_screen"
self.root.ids.messages_scrollview.active_conversation = None self.root.ids.messages_scrollview.active_conversation = None
def connectivity_status(self, sender):
hs = dp(22)
connectivity_status = ""
if RNS.vendor.platformutils.get_platform() == "android":
if self.sideband.reticulum.is_connected_to_shared_instance:
connectivity_status = "[size=22dp][b]Connectivity Status[/b][/size]\n\nSideband is connected via a shared Reticulum instance running on this system. Use the rnstatus utility to obtain full connectivity info."
else:
ws = "Disabled"
ts = "Disabled"
i2s = "Disabled"
if self.sideband.interface_local != None:
np = len(self.sideband.interface_local.peers)
if np == 1:
ws = "1 reachable peer"
else:
ws = str(np)+" reachable peers"
if self.sideband.interface_tcp != None:
if self.sideband.interface_tcp.online:
ts = "Connected to "+str(self.sideband.interface_tcp.target_ip)+":"+str(self.sideband.interface_tcp.target_port)
else:
ts = "Interface Down"
if self.sideband.interface_i2p != None:
if self.sideband.interface_i2p.online:
i2s = "Connected"
else:
i2s = "Connecting to I2P"
connectivity_status = "[size=22dp][b]Connectivity Status[/b][/size]\n\n[b]Local[/b]\n{ws}\n\n[b]TCP[/b]\n{ts}\n\n[b]I2P[/b]\n{i2s}".format(ws=ws, ts=ts, i2s=i2s)
else:
if self.sideband.reticulum.is_connected_to_shared_instance:
connectivity_status = "[size=22dp][b]Connectivity Status[/b][/size]\n\nSideband is connected via a shared Reticulum instance running on this system. Use the rnstatus utility to obtain full connectivity info."
else:
connectivity_status = "[size=22dp][b]Connectivity Status[/b][/size]\n\nSideband is currently running a standalone or master Reticulum instance on this system. Use the rnstatus utility to obtain full connectivity info."
yes_button = MDFlatButton(
text="OK",
)
dialog = MDDialog(
text=connectivity_status,
buttons=[ yes_button ],
)
def dl_yes(s):
dialog.dismiss()
yes_button.bind(on_release=dl_yes)
dialog.open()
def lxmf_sync_action(self, sender): def lxmf_sync_action(self, sender):
if self.sideband.message_router.get_outbound_propagation_node() == None: if self.sideband.message_router.get_outbound_propagation_node() == None:
yes_button = MDFlatButton( yes_button = MDFlatButton(

View File

@ -777,8 +777,6 @@ class SidebandCore():
if self.config["connect_i2p"]: if self.config["connect_i2p"]:
try: try:
RNS.log("Adding I2P Interface...")
if self.config["connect_i2p_b32"].endswith(".b32.i2p"): if self.config["connect_i2p_b32"].endswith(".b32.i2p"):
if self.config["connect_i2p_ifac_netname"] == "": if self.config["connect_i2p_ifac_netname"] == "":
@ -801,7 +799,10 @@ class SidebandCore():
i2pinterface.OUT = True i2pinterface.OUT = True
self.reticulum._add_interface(i2pinterface,ifac_netname=ifac_netname,ifac_netkey=ifac_netkey) self.reticulum._add_interface(i2pinterface,ifac_netname=ifac_netname,ifac_netkey=ifac_netkey)
self.interface_i2p = i2pinterface
for si in RNS.Transport.interfaces:
if type(si) == RNS.Interfaces.I2PInterface.I2PInterfacePeer:
self.interface_i2p = si
except Exception as e: except Exception as e:
@ -809,9 +810,6 @@ class SidebandCore():
self.interface_i2p = None self.interface_i2p = None
RNS.log(str(RNS.Transport.interfaces))
self.message_router = LXMF.LXMRouter(identity = self.identity, storagepath = self.lxmf_storage, autopeer = True) self.message_router = LXMF.LXMRouter(identity = self.identity, storagepath = self.lxmf_storage, autopeer = True)
self.message_router.register_delivery_callback(self.lxmf_delivery) self.message_router.register_delivery_callback(self.lxmf_delivery)

View File

@ -115,7 +115,7 @@ class Announces():
{ {
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"text": "Converse", "text": "Converse",
"height": dp(64), "height": dp(40),
"on_release": gen_conv(context_dest, item) "on_release": gen_conv(context_dest, item)
}, },
# { # {

View File

@ -186,19 +186,19 @@ class Conversations():
{ {
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"text": "Edit", "text": "Edit",
"height": dp(64), "height": dp(40),
"on_release": gen_edit(context_dest, item) "on_release": gen_edit(context_dest, item)
}, },
{ {
"text": "Clear Messages", "text": "Clear Messages",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"height": dp(64), "height": dp(40),
"on_release": gen_clear(context_dest, item) "on_release": gen_clear(context_dest, item)
}, },
{ {
"text": "Delete Conversation", "text": "Delete Conversation",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"height": dp(64), "height": dp(40),
"on_release": gen_del(context_dest, item) "on_release": gen_del(context_dest, item)
} }
] ]
@ -208,7 +208,7 @@ class Conversations():
item.dmenu = MDDropdownMenu( item.dmenu = MDDropdownMenu(
caller=item.iconr, caller=item.iconr,
items=dm_items, items=dm_items,
position="center", position="auto",
width_mult=4, width_mult=4,
) )

View File

@ -10,14 +10,17 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Conversations" title: "Conversations"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
left_action_items: left_action_items:
[['menu', lambda x: nav_drawer.set_state("open")]] [
['menu', lambda x: nav_drawer.set_state("open")],
]
right_action_items: right_action_items:
[ [
['webhook', lambda x: root.ids.screen_manager.app.connectivity_status(self)],
['access-point', lambda x: root.ids.screen_manager.app.announce_now_action(self)], ['access-point', lambda x: root.ids.screen_manager.app.announce_now_action(self)],
['email-sync', lambda x: root.ids.screen_manager.app.lxmf_sync_action(self)], ['email-sync', lambda x: root.ids.screen_manager.app.lxmf_sync_action(self)],
['account-plus', lambda x: root.ids.screen_manager.app.new_conversation_action(self)], ['account-plus', lambda x: root.ids.screen_manager.app.new_conversation_action(self)],
@ -33,7 +36,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
id: messages_toolbar id: messages_toolbar
title: "Messages" title: "Messages"
elevation: 10 elevation: 10
@ -98,7 +101,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Local Broadcasts" title: "Local Broadcasts"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -130,7 +133,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Connectivity" title: "Connectivity"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -318,7 +321,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Guide" title: "Guide"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -350,7 +353,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "App & Version Information" title: "App & Version Information"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -382,7 +385,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Local Area Map" title: "Local Area Map"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -414,7 +417,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Encryption Keys" title: "Encryption Keys"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -446,7 +449,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Announce Stream" title: "Announce Stream"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}
@ -483,7 +486,7 @@ MDNavigationLayout:
BoxLayout: BoxLayout:
orientation: "vertical" orientation: "vertical"
MDToolbar: MDTopAppBar:
title: "Settings" title: "Settings"
elevation: 10 elevation: 10
pos_hint: {"top": 1} pos_hint: {"top": 1}

View File

@ -166,13 +166,13 @@ class Messages():
{ {
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"text": "Copy", "text": "Copy",
"height": dp(64), "height": dp(40),
"on_release": gen_copy(m["content"].decode("utf-8"), item) "on_release": gen_copy(m["content"].decode("utf-8"), item)
}, },
{ {
"text": "Delete", "text": "Delete",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"height": dp(64), "height": dp(40),
"on_release": gen_del(m["hash"], item) "on_release": gen_del(m["hash"], item)
} }
] ]