mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
add checks if pip is supported by device
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
a0c95113bf
commit
4a1c637efc
@ -26,6 +26,7 @@ import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.PictureInPictureParams;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.media.AudioAttributes;
|
||||
@ -499,7 +500,7 @@ public class CallActivity extends BaseActivity {
|
||||
binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
|
||||
binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
if (!deviceSupportsPipMode()) {
|
||||
binding.pictureInPictureButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -2423,23 +2424,30 @@ public class CallActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
enterPipMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserLeaveHint() {
|
||||
enterPipMode();
|
||||
}
|
||||
|
||||
void enterPipMode() {
|
||||
enableKeyguard();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (deviceSupportsPipMode()) {
|
||||
enterPictureInPictureMode(getPipParams());
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deviceSupportsPipMode() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||
&& getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
public PictureInPictureParams getPipParams() {
|
||||
Rational pipRatio = new Rational(300, 500);
|
||||
|
Loading…
Reference in New Issue
Block a user