[Android] Option to always keep screen ON in Pop-Up mode

Geoffrey Métais git at videolan.org
Wed May 24 11:06:50 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 24 11:06:16 2017 +0200| [f86e6ad6407692042bc1917e3cc7d6ce2afec875] | committer: Geoffrey Métais

Option to always keep screen ON in Pop-Up mode

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

 vlc-android/res/values/strings.xml                           |  2 ++
 vlc-android/res/xml/preferences_video.xml                    |  5 +++++
 .../videolan/vlc/gui/tv/preferences/PreferencesVideo.java    |  1 +
 vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java | 12 +++++++++---
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index cf8b21f3f..f36e8c778 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -301,6 +301,8 @@
     <string name="enable_seek_buttons_summary">Show rewind and forward buttons on the video interface</string>
     <string name="enable_double_tap_seek_title">Double tap to seek</string>
     <string name="enable_double_tap_seek_summary">Double tap on screen edges to seek by 10 seconds</string>
+    <string name="popup_keepscreen_title">Keep screen ON in Pop-Up mode</string>
+    <string name="popup_keepscreen_summary">Always keep screen ON while Pop-Up is displayed, even if video is paused.</string>
 
     <string name="subtitles_prefs_category">Subtitles</string>
     <string name="subtitles_size_title">Subtitles Size</string>
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index 38a69d8a7..777a3ce93 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -60,6 +60,11 @@
             android:key="enable_seek_buttons"
             android:summary="@string/enable_seek_buttons_summary"
             android:title="@string/enable_seek_buttons" />
+        <CheckBoxPreference
+            android:defaultValue="false"
+            android:key="popup_keepscreen"
+            android:summary="@string/popup_keepscreen_summary"
+            android:title="@string/popup_keepscreen_title" />
     </PreferenceCategory>
 
 </PreferenceScreen>
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 913b943e7..de2a51f80 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
@@ -53,6 +53,7 @@ public class PreferencesVideo extends BasePreferenceFragment {
         findPreference("enable_double_tap_seek").setVisible(false);
         findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
         findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
+        findPreference("popup_keepscreen").setVisible(false);
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index 41cc9dabe..bee8162f1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -33,10 +33,10 @@ import android.net.Uri;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
-import android.preference.PreferenceManager;
 import android.support.v4.app.NotificationCompat;
 import android.support.v4.app.NotificationManagerCompat;
 import android.support.v4.view.GestureDetectorCompat;
+import android.support.v7.preference.PreferenceManager;
 import android.util.Log;
 import android.view.GestureDetector;
 import android.view.LayoutInflater;
@@ -71,9 +71,11 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
     private ImageView mExpandButton;
     private ImageView mCloseButton;
     private ImageView mPlayPauseButton;
+    private final boolean mAlwaysOn;
 
     public PopupManager(PlaybackService service) {
         mService = service;
+        mAlwaysOn = PreferenceManager.getDefaultSharedPreferences(service).getBoolean("popup_keepscreen", false);
     }
 
     public void removePopup() {
@@ -92,6 +94,8 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
         mService.addCallback(this);
         LayoutInflater li = (LayoutInflater) VLCApplication.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         mRootView = (PopupLayout) li.inflate(R.layout.video_popup, null);
+        if (mAlwaysOn)
+            mRootView.setKeepScreenOn(true);
         mPlayPauseButton = (ImageView) mRootView.findViewById(R.id.video_play_pause);
         mCloseButton = (ImageView) mRootView.findViewById(R.id.popup_close);
         mExpandButton = (ImageView) mRootView.findViewById(R.id.popup_expand);
@@ -225,12 +229,14 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
                 mService.removePopup();
                 break;
             case MediaPlayer.Event.Playing:
-                mRootView.setKeepScreenOn(true);
+                if (!mAlwaysOn)
+                    mRootView.setKeepScreenOn(true);
                 mPlayPauseButton.setImageResource(R.drawable.ic_popup_pause);
                 showNotification();
                 break;
             case MediaPlayer.Event.Paused:
-                mRootView.setKeepScreenOn(false);
+                if (!mAlwaysOn)
+                    mRootView.setKeepScreenOn(false);
                 mPlayPauseButton.setImageResource(R.drawable.ic_popup_play);
                 showNotification();
                 break;



More information about the Android mailing list