mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +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.annotation.SuppressLint;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.PictureInPictureParams;
|
import android.app.PictureInPictureParams;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioAttributes;
|
||||||
@ -499,7 +500,7 @@ public class CallActivity extends BaseActivity {
|
|||||||
binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
|
binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
|
||||||
binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
|
binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
if (!deviceSupportsPipMode()) {
|
||||||
binding.pictureInPictureButton.setVisibility(View.GONE);
|
binding.pictureInPictureButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2423,23 +2424,30 @@ public class CallActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
enterPipMode();
|
enterPipMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onUserLeaveHint() {
|
public void onUserLeaveHint() {
|
||||||
enterPipMode();
|
enterPipMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterPipMode() {
|
void enterPipMode() {
|
||||||
enableKeyguard();
|
enableKeyguard();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (deviceSupportsPipMode()) {
|
||||||
enterPictureInPictureMode(getPipParams());
|
enterPictureInPictureMode(getPipParams());
|
||||||
} else {
|
} else {
|
||||||
finish();
|
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)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
public PictureInPictureParams getPipParams() {
|
public PictureInPictureParams getPipParams() {
|
||||||
Rational pipRatio = new Rational(300, 500);
|
Rational pipRatio = new Rational(300, 500);
|
||||||
|
Loading…
Reference in New Issue
Block a user