[Android] Auto switch to popup option for everyone
Geoffrey Métais
git at videolan.org
Thu Jun 22 13:09:21 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jun 21 17:24:51 2017 +0200| [b9f73df706c4eabff2bee12ba78ee8cd96718f2b] | committer: Geoffrey Métais
Auto switch to popup option for everyone
> https://code.videolan.org/videolan/vlc-android/commit/b9f73df706c4eabff2bee12ba78ee8cd96718f2b
---
.../videolan/vlc/gui/dialogs/AdvOptionsDialog.java | 11 +------
.../vlc/gui/preferences/PreferencesVideo.java | 9 ++----
.../vlc/gui/tv/preferences/PreferencesVideo.java | 3 +-
.../vlc/gui/video/VideoPlayerActivity.java | 37 +++++++++++-----------
4 files changed, 24 insertions(+), 36 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index a5a211e19..46439dcfa 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -59,7 +59,6 @@ import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.gui.view.AutoFitRecyclerView;
import org.videolan.vlc.interfaces.IPlaybackSettingsController;
import org.videolan.vlc.util.AndroidDevices;
-import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Strings;
import java.util.ArrayList;
@@ -474,15 +473,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
((VideoPlayerActivity)getActivity()).switchToAudioMode(true);
break;
case ID_POPUP_VIDEO:
- if (AndroidDevices.hasPiP) {
- //noinspection deprecation
- getActivity().enterPictureInPictureMode();
- } else {
- if (Permissions.canDrawOverlays(mActivity))
- ((VideoPlayerActivity)getActivity()).switchToPopupMode();
- else
- Permissions.checkDrawOverlaysPermission(mActivity);
- }
+ ((VideoPlayerActivity)getActivity()).switchToPopup();
break;
case ID_EQUALIZER:
showFragment(ID_EQUALIZER);
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
index e0c46b4dd..bcadfaaf1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.java
@@ -50,12 +50,9 @@ public class PreferencesVideo extends BasePreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CheckBoxPreference pip = (CheckBoxPreference) findPreference("video_home_pip");
- if (AndroidUtil.isOOrLater) {
- CheckBoxPreference background = (CheckBoxPreference) findPreference("video_background");
- pip.setEnabled(!background.isChecked());
- background.setEnabled(!pip.isChecked());
- }
- pip.setVisible(AndroidUtil.isOOrLater);
+ CheckBoxPreference background = (CheckBoxPreference) findPreference("video_background");
+ pip.setEnabled(!background.isChecked());
+ background.setEnabled(!pip.isChecked());
}
@Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
index c5da5e0bd..a873da5d0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesVideo.java
@@ -27,7 +27,6 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.Preference;
-import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
@@ -55,7 +54,7 @@ public class PreferencesVideo extends BasePreferenceFragment {
findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("popup_keepscreen").setVisible(false);
- findPreference("video_home_pip").setVisible(AndroidUtil.isOOrLater);
+ findPreference("video_home_pip").setVisible(AndroidDevices.isAndroidTv());
}
@Override
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 2b69d0d9b..bbba0e186 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -605,19 +605,29 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
(AndroidUtil.isNougatOrLater && !AndroidUtil.isOOrLater //Video on background on Nougat Android TVs
&& AndroidDevices.isAndroidTv() && !requestVisibleBehind(true)))
stopPlayback();
- else if (AndroidUtil.isOOrLater && mSettings.getBoolean("video_home_pip", false) && isInteractive()) {
- enterPictureInPictureMode();
+ else if (mSettings.getBoolean("video_home_pip", false) && isInteractive()) {
+ switchToPopup();
}
}
}
- @SuppressWarnings("deprecation")
- @Override
- public void enterPictureInPictureMode() {
- if (AndroidUtil.isOOrLater)
- enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(new Rational(mVideoWidth, mVideoHeight)).build());
- else
- super.enterPictureInPictureMode();
+ @TargetApi(Build.VERSION_CODES.N)
+ public void switchToPopup() {
+ if (AndroidDevices.hasPiP) {
+ if (AndroidUtil.isOOrLater)
+ enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(new Rational(mVideoWidth, mVideoHeight)).build());
+ else
+ //noinspection deprecation
+ enterPictureInPictureMode();
+ } else {
+ if (Permissions.canDrawOverlays(this)) {
+ mSwitchingView = true;
+ mSwitchToPopup = true;
+ cleanUI();
+ exitOK();
+ } else
+ Permissions.checkDrawOverlaysPermission(this);
+ }
}
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
@@ -1840,15 +1850,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
}
- public void switchToPopupMode() {
- if (mService == null)
- return;
- mSwitchingView = true;
- mSwitchToPopup = true;
- cleanUI();
- exitOK();
- }
-
public void switchToAudioMode(boolean showUI) {
if (mService == null)
return;
More information about the Android
mailing list