mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 11:08:31 +00:00
Improve transition to PiP mode.
Use setAutoEnterEnable to true for smooth transition to Picture-in-Picture when in gestural navigation mode. Closes #12878
This commit is contained in:
committed by
Greyson Parrelli
parent
c834cb6ff7
commit
0156e74f5a
@@ -125,6 +125,7 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
private WindowLayoutInfoConsumer windowLayoutInfoConsumer;
|
||||
private WindowInfoTrackerCallbackAdapter windowInfoTrackerCallbackAdapter;
|
||||
private ThrottledDebouncer requestNewSizesThrottle;
|
||||
private PictureInPictureParams.Builder pipBuilderParams;
|
||||
|
||||
private Disposable ephemeralStateDisposable = Disposable.empty();
|
||||
|
||||
@@ -156,6 +157,7 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
|
||||
initializeResources();
|
||||
initializeViewModel(isLandscapeEnabled);
|
||||
initializePictureInPictureParams();
|
||||
|
||||
processIntent(getIntent());
|
||||
|
||||
@@ -275,14 +277,16 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
}
|
||||
|
||||
private boolean enterPipModeIfPossible() {
|
||||
if (viewModel.canEnterPipMode() && isSystemPipEnabledAndAvailable()) {
|
||||
PictureInPictureParams params = new PictureInPictureParams.Builder()
|
||||
.setAspectRatio(new Rational(9, 16))
|
||||
.build();
|
||||
enterPictureInPictureMode(params);
|
||||
CallParticipantsListDialog.dismiss(getSupportFragmentManager());
|
||||
if (isSystemPipEnabledAndAvailable()) {
|
||||
if (viewModel.canEnterPipMode()) {
|
||||
enterPictureInPictureMode(pipBuilderParams.build());
|
||||
CallParticipantsListDialog.dismiss(getSupportFragmentManager());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
pipBuilderParams.setAutoEnterEnabled(false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -362,6 +366,19 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
});
|
||||
}
|
||||
|
||||
private void initializePictureInPictureParams() {
|
||||
if (isSystemPipEnabledAndAvailable()) {
|
||||
pipBuilderParams = new PictureInPictureParams.Builder();
|
||||
pipBuilderParams.setAspectRatio(new Rational(9, 16));
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
pipBuilderParams.setAutoEnterEnabled(true);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
setPictureInPictureParams(pipBuilderParams.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleViewModelEvent(@NonNull WebRtcCallViewModel.Event event) {
|
||||
if (event instanceof WebRtcCallViewModel.Event.StartCall) {
|
||||
startCall(((WebRtcCallViewModel.Event.StartCall) event).isVideoCall());
|
||||
|
||||
Reference in New Issue
Block a user