mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-26 22:20:20 +00:00
Set pip auto-enter based off live view-model value.
This commit is contained in:
@@ -370,7 +370,7 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
|
||||
private boolean enterPipModeIfPossible() {
|
||||
if (isSystemPipEnabledAndAvailable()) {
|
||||
if (viewModel.canEnterPipMode()) {
|
||||
if (Boolean.TRUE.equals(viewModel.canEnterPipMode().getValue())) {
|
||||
try {
|
||||
enterPictureInPictureMode(pipBuilderParams.build());
|
||||
} catch (Exception e) {
|
||||
@@ -380,6 +380,7 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
pipBuilderParams.setAutoEnterEnabled(false);
|
||||
}
|
||||
@@ -573,15 +574,24 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
||||
|
||||
pipBuilderParams = new PictureInPictureParams.Builder();
|
||||
pipBuilderParams.setAspectRatio(aspectRatio);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
pipBuilderParams.setAutoEnterEnabled(true);
|
||||
viewModel.canEnterPipMode().observe(this, canEnterPipMode -> {
|
||||
pipBuilderParams.setAutoEnterEnabled(canEnterPipMode);
|
||||
tryToSetPictureInPictureParams();
|
||||
});
|
||||
} else {
|
||||
tryToSetPictureInPictureParams();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
try {
|
||||
setPictureInPictureParams(pipBuilderParams.build());
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "System lied about having PiP available.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tryToSetPictureInPictureParams() {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
try {
|
||||
setPictureInPictureParams(pipBuilderParams.build());
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "System lied about having PiP available.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user