From 9431e2669673e516af6146087f3049979b097675 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 5 Sep 2025 14:58:10 +0200 Subject: [PATCH] end call on closing webview --- .../securesms/videochat/VideochatActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java index 85596d43b..0073baac7 100644 --- a/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/videochat/VideochatActivity.java @@ -30,6 +30,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. private DcContext dcContext; private int chatId; private int callId; + private boolean ended = false; @SuppressLint("SetJavaScriptEnabled") @Override @@ -68,6 +69,13 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. webView.loadUrl(url + hash); } + @Override + protected void onDestroy() { + DcHelper.getEventCenter(this).removeObservers(this); + if (callId != 0 && !ended) dcContext.endCall(callId); + super.onDestroy(); + } + @Override public boolean onPrepareOptionsMenu(Menu menu) { // do not call super.onPrepareOptionsMenu() as the default "Search" menu is not needed @@ -91,6 +99,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. break; case DcContext.DC_EVENT_CALL_ENDED: if (event.getData1Int() == callId) { + ended = true; finish(); } break; @@ -111,7 +120,7 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter. @JavascriptInterface public void endCall() { - dcContext.endCall(callId); + finish(); } } }