[Android] PiP is disabled on some devices

Geoffrey Métais git at videolan.org
Thu Jan 24 16:47:48 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 24 16:47:18 2019 +0100| [048e41ca8c059f71c45173a8e7b2d67b0a490e72] | committer: Geoffrey Métais

PiP is disabled on some devices

> https://code.videolan.org/videolan/vlc-android/commit/048e41ca8c059f71c45173a8e7b2d67b0a490e72
---

 .../src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt       | 2 +-
 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 2 +-
 vlc-android/src/org/videolan/vlc/util/AndroidDevices.java           | 6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
index 0e1ab58e9..a1e066d64 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
@@ -102,7 +102,7 @@ class PlayerOptionsDelegate(val activity: AppCompatActivity, val service: Playba
                 options.add(PlayerOption(ID_PLAY_AS_AUDIO, R.attr.ic_playasaudio_on, res.getString(R.string.play_as_audio)))
             options.add(PlayerOption(ID_SPU_DELAY, R.attr.ic_subtitledelay, res.getString(R.string.spu_delay)))
             options.add(PlayerOption(ID_AUDIO_DELAY, R.attr.ic_audiodelay, res.getString(R.string.audio_delay)))
-            if (primary && (!tvUi || AndroidDevices.hasPiP) && !AndroidDevices.isDex(activity))
+            if (primary && AndroidDevices.pipAllowed && !AndroidDevices.isDex(activity))
                 options.add(PlayerOption(ID_POPUP_VIDEO, R.attr.ic_popup_dim, res.getString(R.string.ctx_pip_title)))
             options.add(PlayerOption(ID_REPEAT, R.attr.ic_repeat, res.getString(R.string.repeat_title)))
             if (service.canShuffle()) options.add(PlayerOption(ID_SHUFFLE, R.attr.ic_shuffle, res.getString(R.string.shuffle_title)))
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 3dbde5a9c..2bfb33a07 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -485,7 +485,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
     @TargetApi(Build.VERSION_CODES.O)
     public void switchToPopup() {
         final MediaWrapper mw = mService != null ? mService.getCurrentMediaWrapper() : null;
-        if (mw == null) return;
+        if (mw == null || !AndroidDevices.pipAllowed) return;
         if (AndroidDevices.hasPiP) {
             if (AndroidUtil.isOOrLater) try {
                     final SurfaceView videoSurface = mVideoLayout.findViewById(R.id.surface_video);
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index 28c06f2de..ee5766e96 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -47,6 +47,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.StringTokenizer;
 
+ at TargetApi(VERSION_CODES.N)
 public class AndroidDevices {
     public final static String TAG = "VLC/UiTools/AndroidDevices";
     public final static String EXTERNAL_PUBLIC_DIRECTORY = Environment.getExternalStorageDirectory().getPath();
@@ -59,6 +60,7 @@ public class AndroidDevices {
     public final static boolean isAmazon = TextUtils.equals(Build.MANUFACTURER,"Amazon");
     public final static boolean isChromeBook;
     public static final boolean hasPiP;
+    public static final boolean pipAllowed;
     public final static boolean showInternalStorage = !TextUtils.equals(Build.BRAND, "Swisscom") && !TextUtils.equals(Build.BOARD, "sprint");
     private final static String[] noMediaStyleManufacturers = {"huawei", "symphony teleca"};
     public final static boolean showMediaStyle = !isManufacturerBannedForMediastyleNotifications();
@@ -102,7 +104,9 @@ public class AndroidDevices {
         isChromeBook = pm != null && pm.hasSystemFeature("org.chromium.arc.device_management");
         isTv = isAndroidTv || (!isChromeBook && !hasTsp);
         hasPlayServices = pm == null || hasPlayServices(pm);
-        hasPiP = AndroidUtil.isOOrLater || AndroidUtil.isNougatOrLater && isAndroidTv;
+        hasPiP = AndroidUtil.isOOrLater && pm != null && pm.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
+                || AndroidUtil.isNougatOrLater && isAndroidTv;
+        pipAllowed = hasPiP || (hasTsp && !AndroidUtil.isOOrLater);
         final TelephonyManager tm = ctx != null ? ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)) : null;
         isPhone = tm == null || tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
         // hasCombBar test if device has Combined Bar : only for tablet with Honeycomb or ICS



More information about the Android mailing list