Skip to content
Snippets Groups Projects
Commit f7dfe23b authored by Rayan Osseiran's avatar Rayan Osseiran
Browse files

calls: fix app exit after calls with pip

When you enter PIP mode, Android moves the PIP activity is moved to
a new task. When you restore the full screen after PIP, the back stack is lost
and must be reinitialized.

Change-Id: I9911b69c86c2fc26c0c8c155618e2fdd8906477d
parent c1532d4d
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ import android.app.Activity;
import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.app.RemoteAction;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
......@@ -120,6 +121,8 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
private int mPreviewWidth = 720, mPreviewHeight = 1280;
private int mPreviewSurfaceWidth = 0, mPreviewSurfaceHeight = 0;
private boolean mBackstackLost = false;
@Inject
DeviceRuntimeService mDeviceRuntimeService;
......@@ -247,8 +250,7 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
displayVideoSurface(true, !presenter.isPipMode());
restartVideo = false;
restartPreview = false;
}
else if (restartVideo) {
} else if (restartVideo) {
displayVideoSurface(true, false);
restartVideo = false;
}
......@@ -444,11 +446,13 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
AppCompatActivity activity = (AppCompatActivity) getActivity();
ActionBar actionBar = activity == null ? null : activity.getSupportActionBar();
if (actionBar != null) {
if (isInPictureInPictureMode)
if (isInPictureInPictureMode) {
actionBar.hide();
else
} else {
mBackstackLost = true;
actionBar.show();
}
}
presenter.pipModeChanged(isInPictureInPictureMode);
}
......@@ -753,9 +757,18 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
@Override
public void finish() {
Activity activity = getActivity();
if (activity != null)
if (activity != null) {
if (mBackstackLost) {
activity.finishAndRemoveTask();
startActivity(
Intent.makeMainActivity(
new ComponentName(activity, HomeActivity.class)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else {
activity.finish();
}
}
}
public void speakerClicked() {
presenter.speakerClick(binding.callSpeakerBtn.isChecked());
......
......@@ -22,7 +22,9 @@ package cx.ring.tv.call;
import android.Manifest;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Matrix;
......@@ -67,6 +69,7 @@ import cx.ring.model.CallContact;
import cx.ring.model.SipCall;
import cx.ring.mvp.BaseFragment;
import cx.ring.services.DeviceRuntimeService;
import cx.ring.tv.main.HomeActivity;
import cx.ring.views.AvatarDrawable;
import io.reactivex.disposables.CompositeDisposable;
......@@ -95,6 +98,8 @@ public class TVCallFragment extends BaseFragment<CallPresenter> implements CallV
private int mPreviewWidth = 720, mPreviewHeight = 1280;
private int mPreviewWidthRot = 720, mPreviewHeightRot = 1280;
private boolean mBackstackLost = false;
@Inject
DeviceRuntimeService mDeviceRuntimeService;
......@@ -253,6 +258,9 @@ public class TVCallFragment extends BaseFragment<CallPresenter> implements CallV
@Override
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
if(!isInPictureInPictureMode) {
mBackstackLost = true;
}
presenter.pipModeChanged(isInPictureInPictureMode);
}
......@@ -537,7 +545,17 @@ public class TVCallFragment extends BaseFragment<CallPresenter> implements CallV
@Override
public void finish() {
getActivity().finish();
Activity activity = getActivity();
if (activity != null) {
if (mBackstackLost) {
activity.finishAndRemoveTask();
startActivity(
Intent.makeMainActivity(
new ComponentName(activity, HomeActivity.class)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else {
activity.finish();
}
}
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment