From f2e75a7b71f7cd1c9c642c258ac5e6cf3a2f23d9 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 15 Nov 2021 12:17:05 +0100 Subject: [PATCH] add workaround to start videocalls when PIP is disabled this is a dirty workaround for issue #1677 Somehow onUserLeaveHint is executed when the user starts a videocall. If PIP is disabled, the logic inside enterPipMode would finish the activity right after it was started. This workaround suppresses the execution of enterPipMode right after the activity was started. However if a user would press the home button in the first three seconds, the call would continue in background without the ability to recover the UI. To better fix this bug it must be found out why onUserLeaveHint is executed on start (this should not happen!). Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/activities/CallBaseActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.java index 66da91360..8401fd9ea 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.java @@ -22,12 +22,15 @@ public abstract class CallBaseActivity extends BaseActivity { public PictureInPictureParams.Builder mPictureInPictureParamsBuilder; public Boolean isInPipMode = false; + long onCreateTime; @SuppressLint("ClickableViewAccessibility") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + onCreateTime = System.currentTimeMillis(); + requestWindowFeature(Window.FEATURE_NO_TITLE); dismissKeyguard(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -88,7 +91,15 @@ public abstract class CallBaseActivity extends BaseActivity { @Override protected void onUserLeaveHint() { - enterPipMode(); + long onUserLeaveHintTime = System.currentTimeMillis(); + long diff = onUserLeaveHintTime - onCreateTime; + Log.d(TAG, "onUserLeaveHintTime - onCreateTime: " + diff); + + if (diff < 3000) { + Log.d(TAG, "enterPipMode skipped"); + } else { + enterPipMode(); + } } void enterPipMode() {