mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
end call on closing webview
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user