mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Added message details dialog
This commit is contained in:
parent
66065bc3ef
commit
12b7250a37
@ -1978,7 +1978,7 @@ class SidebandApp(MDApp):
|
|||||||
save_item,
|
save_item,
|
||||||
],
|
],
|
||||||
buttons=[ cancel_button ],
|
buttons=[ cancel_button ],
|
||||||
width_offset=dp(12),
|
width_offset=dp(32),
|
||||||
)
|
)
|
||||||
cancel_button.bind(on_release=self.rec_dialog.dismiss)
|
cancel_button.bind(on_release=self.rec_dialog.dismiss)
|
||||||
self.rec_dialog.recording = False
|
self.rec_dialog.recording = False
|
||||||
@ -2001,7 +2001,6 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
self.rec_dialog.open()
|
self.rec_dialog.open()
|
||||||
self.rec_dialog_is_open = True
|
self.rec_dialog_is_open = True
|
||||||
self.rec_dialog.update_width()
|
|
||||||
|
|
||||||
def message_attach_action(self, attach_type=None, nodialog=False):
|
def message_attach_action(self, attach_type=None, nodialog=False):
|
||||||
file_attach_types = ["lbimg", "defimg", "hqimg", "file"]
|
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",
|
text="Select the type of attachment you want to send with this message\n",
|
||||||
items=ad_items,
|
items=ad_items,
|
||||||
buttons=[ cancel_button ],
|
buttons=[ cancel_button ],
|
||||||
width_offset=dp(12),
|
width_offset=dp(32),
|
||||||
)
|
)
|
||||||
|
|
||||||
cancel_button.bind(on_release=self.attach_dialog.dismiss)
|
cancel_button.bind(on_release=self.attach_dialog.dismiss)
|
||||||
|
|
||||||
self.attach_dialog.open()
|
self.attach_dialog.open()
|
||||||
self.attach_dialog.update_width()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.attach_path = None
|
self.attach_path = None
|
||||||
|
@ -2451,6 +2451,12 @@ class SidebandCore():
|
|||||||
else:
|
else:
|
||||||
packed_lxm = entry[10]
|
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)
|
lxm = LXMF.LXMessage.unpack_from_bytes(packed_lxm, original_method = lxm_method)
|
||||||
|
|
||||||
if lxm.desired_method == LXMF.LXMessage.PAPER:
|
if lxm.desired_method == LXMF.LXMessage.PAPER:
|
||||||
@ -2466,7 +2472,8 @@ class SidebandCore():
|
|||||||
"sent": lxm.timestamp,
|
"sent": lxm.timestamp,
|
||||||
"state": entry[6],
|
"state": entry[6],
|
||||||
"method": entry[7],
|
"method": entry[7],
|
||||||
"lxm": lxm
|
"lxm": lxm,
|
||||||
|
"extras": extras,
|
||||||
}
|
}
|
||||||
return message
|
return message
|
||||||
|
|
||||||
@ -2610,6 +2617,7 @@ class SidebandCore():
|
|||||||
extras["stamp_checked"] = True
|
extras["stamp_checked"] = True
|
||||||
extras["stamp_valid"] = lxm.stamp_valid
|
extras["stamp_valid"] = lxm.stamp_valid
|
||||||
extras["stamp_value"] = lxm.stamp_value
|
extras["stamp_value"] = lxm.stamp_value
|
||||||
|
extras["stamp_raw"] = lxm.stamp
|
||||||
|
|
||||||
if lxm.ratchet_id:
|
if lxm.ratchet_id:
|
||||||
extras["ratchet_id"] = 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.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)
|
self.message_router.announce(self.lxmf_destination.hash, attached_interface=attached_interface)
|
||||||
else:
|
else:
|
||||||
|
# TODO: Remove this announce option when LXMF 0.5.0 is deployed
|
||||||
self.lxmf_destination.announce(attached_interface=attached_interface)
|
self.lxmf_destination.announce(attached_interface=attached_interface)
|
||||||
self.last_lxmf_announce = time.time()
|
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)
|
self.next_auto_announce = time.time() + 60*(random.random()*(SidebandCore.AUTO_ANNOUNCE_RANDOM_MAX-SidebandCore.AUTO_ANNOUNCE_RANDOM_MIN)+SidebandCore.AUTO_ANNOUNCE_RANDOM_MIN)
|
||||||
|
@ -45,6 +45,11 @@ if RNS.vendor.platformutils.is_darwin():
|
|||||||
from PIL import Image as PilImage
|
from PIL import Image as PilImage
|
||||||
|
|
||||||
from kivy.lang.builder import Builder
|
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):
|
||||||
# class ListLXMessageCard(MDCard, FakeRectangularElevationBehavior):
|
# class ListLXMessageCard(MDCard, FakeRectangularElevationBehavior):
|
||||||
@ -73,6 +78,7 @@ class Messages():
|
|||||||
self.widgets = []
|
self.widgets = []
|
||||||
self.send_error_dialog = None
|
self.send_error_dialog = None
|
||||||
self.load_more_button = None
|
self.load_more_button = None
|
||||||
|
self.details_dialog = None
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
@ -95,6 +101,69 @@ class Messages():
|
|||||||
self.loading_earlier_messages = True
|
self.loading_earlier_messages = True
|
||||||
self.list.remove_widget(self.load_more_button)
|
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):
|
def update(self, limit=8):
|
||||||
for new_message in self.app.sideband.list_messages(self.context_dest, after=self.latest_message_timestamp,limit=limit):
|
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)
|
self.new_messages.append(new_message)
|
||||||
@ -565,6 +634,15 @@ class Messages():
|
|||||||
|
|
||||||
return x
|
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 gen_copy(msg, item):
|
||||||
def x():
|
def x():
|
||||||
Clipboard.copy(msg)
|
Clipboard.copy(msg)
|
||||||
@ -826,6 +904,14 @@ class Messages():
|
|||||||
"height": dp(40),
|
"height": dp(40),
|
||||||
"on_release": gen_retry(m["hash"], m["content"], item)
|
"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 m["method"] == LXMF.LXMessage.PAPER:
|
||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
qr_save_text = "Share QR Code"
|
qr_save_text = "Share QR Code"
|
||||||
@ -910,6 +996,7 @@ class Messages():
|
|||||||
else:
|
else:
|
||||||
if telemeter != None:
|
if telemeter != None:
|
||||||
dm_items = [
|
dm_items = [
|
||||||
|
details_item,
|
||||||
{
|
{
|
||||||
"viewclass": "OneLineListItem",
|
"viewclass": "OneLineListItem",
|
||||||
"text": "Copy",
|
"text": "Copy",
|
||||||
@ -932,6 +1019,7 @@ class Messages():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
dm_items = [
|
dm_items = [
|
||||||
|
details_item,
|
||||||
{
|
{
|
||||||
"viewclass": "OneLineListItem",
|
"viewclass": "OneLineListItem",
|
||||||
"text": "Copy",
|
"text": "Copy",
|
||||||
|
Loading…
Reference in New Issue
Block a user