Added message details dialog

This commit is contained in:
Mark Qvist 2024-09-08 13:18:12 +02:00
parent 66065bc3ef
commit 12b7250a37
3 changed files with 100 additions and 5 deletions

View File

@ -1978,7 +1978,7 @@ class SidebandApp(MDApp):
save_item,
],
buttons=[ cancel_button ],
width_offset=dp(12),
width_offset=dp(32),
)
cancel_button.bind(on_release=self.rec_dialog.dismiss)
self.rec_dialog.recording = False
@ -2001,7 +2001,6 @@ class SidebandApp(MDApp):
self.rec_dialog.open()
self.rec_dialog_is_open = True
self.rec_dialog.update_width()
def message_attach_action(self, attach_type=None, nodialog=False):
file_attach_types = ["lbimg", "defimg", "hqimg", "file"]
@ -2071,13 +2070,12 @@ class SidebandApp(MDApp):
text="Select the type of attachment you want to send with this message\n",
items=ad_items,
buttons=[ cancel_button ],
width_offset=dp(12),
width_offset=dp(32),
)
cancel_button.bind(on_release=self.attach_dialog.dismiss)
self.attach_dialog.open()
self.attach_dialog.update_width()
else:
self.attach_path = None

View File

@ -2451,6 +2451,12 @@ class SidebandCore():
else:
packed_lxm = entry[10]
extras = None
try:
extras = msgpack.unpackb(entry[11])
except:
pass
lxm = LXMF.LXMessage.unpack_from_bytes(packed_lxm, original_method = lxm_method)
if lxm.desired_method == LXMF.LXMessage.PAPER:
@ -2466,7 +2472,8 @@ class SidebandCore():
"sent": lxm.timestamp,
"state": entry[6],
"method": entry[7],
"lxm": lxm
"lxm": lxm,
"extras": extras,
}
return message
@ -2610,6 +2617,7 @@ class SidebandCore():
extras["stamp_checked"] = True
extras["stamp_valid"] = lxm.stamp_valid
extras["stamp_value"] = lxm.stamp_value
extras["stamp_raw"] = lxm.stamp
if lxm.ratchet_id:
extras["ratchet_id"] = lxm.ratchet_id
@ -2682,6 +2690,7 @@ class SidebandCore():
self.message_router.set_inbound_stamp_cost(self.lxmf_destination.hash, self.config["lxmf_inbound_stamp_cost"])
self.message_router.announce(self.lxmf_destination.hash, attached_interface=attached_interface)
else:
# TODO: Remove this announce option when LXMF 0.5.0 is deployed
self.lxmf_destination.announce(attached_interface=attached_interface)
self.last_lxmf_announce = time.time()
self.next_auto_announce = time.time() + 60*(random.random()*(SidebandCore.AUTO_ANNOUNCE_RANDOM_MAX-SidebandCore.AUTO_ANNOUNCE_RANDOM_MIN)+SidebandCore.AUTO_ANNOUNCE_RANDOM_MIN)

View File

@ -45,6 +45,11 @@ if RNS.vendor.platformutils.is_darwin():
from PIL import Image as PilImage
from kivy.lang.builder import Builder
from kivymd.uix.list import OneLineIconListItem, IconLeftWidget
class DialogItem(OneLineIconListItem):
divider = None
icon = StringProperty()
class ListLXMessageCard(MDCard):
# class ListLXMessageCard(MDCard, FakeRectangularElevationBehavior):
@ -73,6 +78,7 @@ class Messages():
self.widgets = []
self.send_error_dialog = None
self.load_more_button = None
self.details_dialog = None
self.update()
def reload(self):
@ -95,6 +101,69 @@ class Messages():
self.loading_earlier_messages = True
self.list.remove_widget(self.load_more_button)
def message_details_dialog(self, lxm_hash):
RNS.log(f"Opening dialog for {RNS.prettyhexrep(lxm_hash)}", RNS.LOG_DEBUG)
ss = int(dp(16))
msg = self.app.sideband.message(lxm_hash)
if msg:
close_button = MDRectangleFlatButton(text="Close", font_size=dp(18))
# d_items = [ ]
# d_items.append(DialogItem(IconLeftWidget(icon="postage-stamp"), text="[size="+str(ss)+"]Stamp[/size]"))
d_text = ""
if "lxm" in msg and msg["lxm"] != None:
if msg["lxm"].signature_validated:
d_text += f"[size={ss}][b]Signature[/b] validated successfully[/size]\n"
else:
d_text += f"[size={ss}][b]Signature[/b] is invalid[/size]\n"
if "method" in msg:
if msg["method"] == LXMF.LXMessage.UNKNOWN:
d_text += f"[size={ss}][b]Delivered[/b] via unknown method[/size]\n"
if msg["method"] == LXMF.LXMessage.OPPORTUNISTIC:
d_text += f"[size={ss}][b]Delivered[/b] opportunistically[/size]\n"
if msg["method"] == LXMF.LXMessage.DIRECT:
d_text += f"[size={ss}][b]Delivered[/b] over direct link[/size]\n"
if msg["method"] == LXMF.LXMessage.PROPAGATED:
d_text += f"[size={ss}][b]Delivered[/b] to propagation network[/size]\n"
if msg["extras"] != None and "ratchet_id" in msg["extras"]:
r_str = RNS.prettyhexrep(msg["extras"]["ratchet_id"])
d_text += f"[size={ss}][b]Encrypted[/b] with ratchet {r_str}[/size]\n"
if msg["extras"] != None and "stamp_checked" in msg["extras"] and msg["extras"]["stamp_checked"] == True:
valid_str = " is not valid"
if msg["extras"]["stamp_valid"] == True:
valid_str = " is valid"
sv = msg["extras"]["stamp_value"]
if sv == None:
sv_str = "was not included in the message"
valid_str = ""
elif sv > 255:
sv_str = "generated from ticket"
else:
sv_str = f"with value {sv}"
if "stamp_raw" in msg["extras"] and type(msg["extras"]["stamp_raw"]) == bytes:
sstr = RNS.hexrep(msg["extras"]["stamp_raw"])
d_text += f"[size={ss}][b]Raw stamp[/b] {sstr}[/size]\n"
d_text += f"[size={ss}][b]Stamp[/b] {sv_str}{valid_str}[/size]\n"
self.details_dialog = MDDialog(
title="Message Details",
type="simple",
text=d_text,
# items=d_items,
buttons=[ close_button ],
width_offset=dp(32),
)
close_button.bind(on_release=self.details_dialog.dismiss)
self.details_dialog.open()
def update(self, limit=8):
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)
@ -565,6 +634,15 @@ class Messages():
return x
def gen_details(mhash, item):
def x():
item.dmenu.dismiss()
def cb(dt):
self.message_details_dialog(mhash)
Clock.schedule_once(cb, 0.2)
return x
def gen_copy(msg, item):
def x():
Clipboard.copy(msg)
@ -826,6 +904,14 @@ class Messages():
"height": dp(40),
"on_release": gen_retry(m["hash"], m["content"], item)
}
details_item = {
"viewclass": "OneLineListItem",
"text": "Details",
"height": dp(40),
"on_release": gen_details(m["hash"], item)
}
if m["method"] == LXMF.LXMessage.PAPER:
if RNS.vendor.platformutils.is_android():
qr_save_text = "Share QR Code"
@ -910,6 +996,7 @@ class Messages():
else:
if telemeter != None:
dm_items = [
details_item,
{
"viewclass": "OneLineListItem",
"text": "Copy",
@ -932,6 +1019,7 @@ class Messages():
else:
dm_items = [
details_item,
{
"viewclass": "OneLineListItem",
"text": "Copy",