check if pip feature is available on top of doing version check

This commit is contained in:
Daniel Gultsch 2020-04-23 12:14:45 +02:00
parent 60cea03dce
commit cfb9368edb
1 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import android.annotation.SuppressLint;
import android.app.PictureInPictureParams; import android.app.PictureInPictureParams;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.databinding.DataBindingUtil; import android.databinding.DataBindingUtil;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -238,6 +239,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH));
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID); final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
if (sessionId != null) { if (sessionId != null) {
//TODO this should probably return true/false so we dont continue to accept the call after calling finish()
initializeActivityWithRunningRtpSession(account, with, sessionId); initializeActivityWithRunningRtpSession(account, with, sessionId);
if (ACTION_ACCEPT_CALL.equals(intent.getAction())) { if (ACTION_ACCEPT_CALL.equals(intent.getAction())) {
Log.d(Config.LOGTAG, "intent action was accept"); Log.d(Config.LOGTAG, "intent action was accept");
@ -323,8 +325,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
@Override @Override
public void onUserLeaveHint() { public void onUserLeaveHint() {
Log.d(Config.LOGTAG, "user leave hint"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && deviceSupportsPictureInPicture()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (shouldBePictureInPicture()) { if (shouldBePictureInPicture()) {
enterPictureInPictureMode( enterPictureInPictureMode(
new PictureInPictureParams.Builder() new PictureInPictureParams.Builder()
@ -333,7 +334,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
); );
} }
} }
}
private boolean deviceSupportsPictureInPicture() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
} else {
return false;
}
} }
private boolean shouldBePictureInPicture() { private boolean shouldBePictureInPicture() {