summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2018-04-09 00:04:02 +0200
committerByteHamster <info@bytehamster.com>2018-04-09 00:04:02 +0200
commit1831430a6e47be1e34d2e8a4b977e79289ca7b2b (patch)
treed3188cd4b89b6b5de58dea9f1261561025ca8313 /app/src/main/java
parent0a5a31a16918f1f1935f89974015d9fc8206ebab (diff)
downloadAntennaPod-1831430a6e47be1e34d2e8a4b977e79289ca7b2b.zip
Added checks for PiP support
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java20
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java10
2 files changed, 24 insertions, 6 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
index f3c0760f3..b51f45d93 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.PixelFormat;
@@ -225,7 +226,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
@Override
protected void onPause() {
- if (Build.VERSION.SDK_INT < 26 || !isInPictureInPictureMode()) {
+ if (!supportsAndisInPictureInPictureMode()) {
if (controller != null) {
controller.reinitServiceIfPaused();
controller.pause();
@@ -907,6 +908,23 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
}
}
+ /* package */ boolean supportsPictureInPicture() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ PackageManager packageManager = getApplicationContext().getPackageManager();
+ return packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
+ } else {
+ return false;
+ }
+ }
+
+ /* package */ boolean supportsAndisInPictureInPictureMode() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && supportsPictureInPicture()) {
+ return isInPictureInPictureMode();
+ } else {
+ return false;
+ }
+ }
+
private void checkFavorite() {
Playable playable = controller.getMedia();
if (playable != null && playable instanceof FeedMedia) {
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
index e23291e0d..4ab934cc2 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -101,14 +101,14 @@ public class VideoplayerActivity extends MediaplayerActivity {
@Override
protected void onStop() {
super.onStop();
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N || !isInPictureInPictureMode()) {
+ if (!supportsAndisInPictureInPictureMode()) {
videoControlsHider.stop();
}
}
@Override
protected void onPause() {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N || !isInPictureInPictureMode()) {
+ if (!supportsAndisInPictureInPictureMode()) {
if (controller != null && controller.getStatus() == PlayerStatus.PLAYING) {
controller.pause();
}
@@ -191,7 +191,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
private final View.OnTouchListener onVideoviewTouched = (v, event) -> {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInPictureInPictureMode()) {
+ if (supportsAndisInPictureInPictureMode()) {
return true;
}
videoControlsHider.stop();
@@ -381,7 +381,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ if (supportsPictureInPicture()) {
menu.findItem(R.id.player_go_to_picture_in_picture).setVisible(true);
}
return true;
@@ -390,7 +390,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.player_go_to_picture_in_picture) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ if (supportsPictureInPicture() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
getSupportActionBar().hide();
hideVideoControls(false);
enterPictureInPictureMode();