mirror of
https://github.com/markqvist/Sideband.git
synced 2025-12-22 08:17:10 +00:00
Added call confirm dialog to calls made from call log
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user