From 24bf675ca3fbac5c8cefd3c188ac9283a7ad9741 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 20 Nov 2025 23:55:45 +0100 Subject: [PATCH] Added call confirm dialog to calls made from call log --- sbapp/main.py | 28 +++++++++++++++------------- sbapp/ui/voice.py | 19 +++++++++++++------ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/sbapp/main.py b/sbapp/main.py index 7787f9a..2021874 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -2011,6 +2011,19 @@ class SidebandApp(MDApp): item = c[(len(c)-1)-i] self.conversation_action(item) + def init_confirm_call_dialog(self, call_dialog_text): + yes_button = MDRectangleFlatButton(text="Call",font_size=dp(18), theme_text_color="Custom", line_color=self.color_accept, text_color=self.color_accept) + no_button = MDRectangleFlatButton(text="Cancel",font_size=dp(18)) + self.confirm_call_dialog = MDDialog(text=call_dialog_text, buttons=[ no_button, yes_button ]) + def dl_no(s): self.confirm_call_dialog.dismiss() + def dl_yes(s): + self.confirm_call_dialog.dismiss() + def cb(dt): self.dial_action(self.confirm_call_dialog.dest_identity_hash) + Clock.schedule_once(cb, 0.15) + + yes_button.bind(on_release=dl_yes) + no_button.bind(on_release=dl_no) + def conversation_action(self, sender): if sender.conv_type == self.sideband.CONV_P2P: context_dest = sender.sb_uid @@ -2025,20 +2038,9 @@ class SidebandApp(MDApp): def cb(dt): self.dial_action(identity_hash) Clock.schedule_once(cb, 0.15) else: - call_dialog_text = f"[b]Initiate Voice Call?[/b]\n\nDestination Identity:\n{RNS.prettyhexrep(identity_hash)}?" + call_dialog_text = f"[b]Initiate Voice Call?[/b]\n\nDestination Identity:\n{RNS.prettyhexrep(identity_hash)}" if hasattr(self, "confirm_call_dialog"): self.confirm_call_dialog.text = call_dialog_text - else: - yes_button = MDRectangleFlatButton(text="Call",font_size=dp(18), theme_text_color="Custom", line_color=self.color_accept, text_color=self.color_accept) - no_button = MDRectangleFlatButton(text="Cancel",font_size=dp(18)) - self.confirm_call_dialog = MDDialog(text=call_dialog_text, buttons=[ no_button, yes_button ]) - def dl_no(s): self.confirm_call_dialog.dismiss() - def dl_yes(s): - self.confirm_call_dialog.dismiss() - def cb(dt): self.dial_action(self.confirm_call_dialog.dest_identity_hash) - Clock.schedule_once(cb, 0.15) - - yes_button.bind(on_release=dl_yes) - no_button.bind(on_release=dl_no) + else: self.init_confirm_call_dialog(call_dialog_text) self.confirm_call_dialog.dest_identity_hash = identity_hash self.confirm_call_dialog.open() diff --git a/sbapp/ui/voice.py b/sbapp/ui/voice.py index 0f0e32e..a9acfa3 100644 --- a/sbapp/ui/voice.py +++ b/sbapp/ui/voice.py @@ -165,12 +165,19 @@ class Voice(): toast("Path request timed out") def log_dial_action(self, sender=None): - if sender and self.app.sideband.voice_running and self.app.sideband.telephone != None: - telephone = self.app.sideband.telephone - if not telephone.is_ringing and not telephone.is_in_call and not telephone.call_is_connecting: - self.screen.ids.identity_hash.text = RNS.hexrep(sender.identity, delimit=False) - self.dial_target = sender.identity - self.dial_action() + def job(dt=None): + if not self.app.root.ids.screen_manager.current == "voice_screen": return + if sender and self.app.sideband.voice_running and self.app.sideband.telephone != None: + telephone = self.app.sideband.telephone + if not telephone.is_ringing and not telephone.is_in_call and not telephone.call_is_connecting: + call_dialog_text = f"[b]Initiate Voice Call?[/b]\n\nDestination Identity:\n{RNS.prettyhexrep(sender.identity)}" + if hasattr(self.app, "confirm_call_dialog"): self.app.confirm_call_dialog.text = call_dialog_text + else: self.app.init_confirm_call_dialog(call_dialog_text) + self.app.confirm_call_dialog.dest_identity_hash = sender.identity + self.app.confirm_call_dialog.open() + + Clock.schedule_once(job, 0.1) + def reject_action(self, sender=None): if self.app.sideband.voice_running: