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