[Android] Option to enable swipe controls in video player

Geoffrey Métais git at videolan.org
Fri Jan 8 15:20:20 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan  8 15:12:36 2016 +0100| [aa43e26a12d5e5e4184273b4ed9506db19f9b4b5] | committer: Geoffrey Métais

Option to enable swipe controls in video player

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

 vlc-android/res/values/strings.xml                           |  2 ++
 vlc-android/res/xml/preferences_ui.xml                       |  5 +++++
 .../src/org/videolan/vlc/gui/preferences/PreferencesUi.java  |  3 +++
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java  | 12 ++++++++----
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 421088f..72c3aff 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -351,6 +351,8 @@
     <string name="directory_empty">Directory is empty</string>
     <string name="save_brightness_summary">Remember brightness level in video player</string>
     <string name="save_brightness_title">Save brightness level for video</string>
+    <string name="player_touch_summary">Enable swipe gestures and double tap in video player</string>
+    <string name="player_touch_title">Touch controls for Video</string>
 
     <!--Accessibility-->
     <string name="more_actions">More Actions</string>
diff --git a/vlc-android/res/xml/preferences_ui.xml b/vlc-android/res/xml/preferences_ui.xml
index 75b6905..7874679 100644
--- a/vlc-android/res/xml/preferences_ui.xml
+++ b/vlc-android/res/xml/preferences_ui.xml
@@ -19,6 +19,11 @@
             android:summary="@string/save_brightness_summary"
             android:title="@string/save_brightness_title" />
         <CheckBoxPreference
+            android:defaultValue="true"
+            android:key="enable_touch_player"
+            android:summary="@string/player_touch_summary"
+            android:title="@string/player_touch_title" />
+        <CheckBoxPreference
             android:defaultValue="false"
             android:key="dialog_confirm_resume"
             android:summary="@string/confirm_resume_summary"
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
index 20574f9..c4aa468 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
@@ -32,6 +32,9 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.util.AndroidDevices;
 
 public class PreferencesUi extends BasePreferenceFragment {
+
+    public static final String KEY_ENABLE_TOUCH_PLAYER = "enable_touch_player";
+
     @Override
     protected int getXml() {
         return R.xml.preferences_ui;
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 b031cba..def5f40 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -113,6 +113,7 @@ import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
 import org.videolan.vlc.gui.helpers.OnRepeatListener;
 import org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback;
 import org.videolan.vlc.gui.preferences.PreferencesActivity;
+import org.videolan.vlc.gui.preferences.PreferencesUi;
 import org.videolan.vlc.interfaces.IDelayController;
 import org.videolan.vlc.media.MediaDatabase;
 import org.videolan.vlc.media.MediaWrapper;
@@ -193,6 +194,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     private int mCurrentSize = SURFACE_BEST_FIT;
 
     private SharedPreferences mSettings;
+    private boolean mTouchControls = true;
 
     /** Overlay */
     private ActionBar mActionBar;
@@ -357,6 +359,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
         mSettings = PreferenceManager.getDefaultSharedPreferences(this);
 
+        mTouchControls = mSettings.getBoolean(PreferencesUi.KEY_ENABLE_TOUCH_PLAYER, true);
+
         /* Services and miscellaneous */
         mAudioManager = (AudioManager) VLCApplication.getAppContext().getSystemService(AUDIO_SERVICE);
         mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
@@ -1778,10 +1782,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             togglePlaylist();
             return true;
         }
-        if (mDetector != null && mDetector.onTouchEvent(event))
-            return true;
-        if (mIsLocked) {
-            // locked, only handle show/hide & ignore all actions
+        if (!mTouchControls || mIsLocked) {
+            // locked or swipe disabled, only handle show/hide & ignore all actions
             if (event.getAction() == MotionEvent.ACTION_UP) {
                 if (!mShowing) {
                     showOverlay();
@@ -1791,6 +1793,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             }
             return false;
         }
+        if (mDetector != null && mDetector.onTouchEvent(event))
+            return true;
 
         DisplayMetrics screen = new DisplayMetrics();
         getWindowManager().getDefaultDisplay().getMetrics(screen);



More information about the Android mailing list