end call on closing webview

This commit is contained in:
adbenitez
2025-09-05 14:58:10 +02:00
parent 9ef01dd352
commit 9431e26696
@@ -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();
}
}
}