[Android] Set Brightness and Volume gestures in 2 distinct settings

Alexandre Perraud git at videolan.org
Fri Jul 8 11:30:39 CEST 2016


vlc-android | branch: 2.0.x | Alexandre Perraud <4leyx4ndre at gmail.com> | Fri Jul  1 15:58:11 2016 +0200| [1f086a1129d2d237fce71ee7a2c1d8609e457643] | committer: Alexandre Perraud

Set Brightness and Volume gestures in 2 distinct settings

(cherry picked from commit b42279e3e8e2d70ccf79a1fc7a033a413aa58870)

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

 vlc-android/res/values/strings.xml                       | 15 +++------------
 vlc-android/res/xml/preferences_ui.xml                   | 16 ++++++++++------
 .../org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java   |  2 +-
 .../org/videolan/vlc/gui/preferences/PreferencesUi.java  |  2 --
 .../videolan/vlc/gui/tv/preferences/PreferencesUi.java   |  5 ++---
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java  | 11 +++++++----
 6 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index e7c20fc..25ba585 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -275,8 +275,10 @@
     <string name="enable_clone_mode">Prefer clone</string>
     <string name="enable_clone_mode_summary">Clone the device screen without remote control.</string>
     <string name="interface_other_category">Interface - Other</string>
-    <string name="enable_brightness_gesture">Enable brightness gesture</string>
+    <string name="enable_brightness_gesture_title">Brightness gesture</string>
     <string name="enable_brightness_gesture_summary">Control brightness by gesture during video playback</string>
+    <string name="enable_volume_gesture_title">Volume gesture</string>
+    <string name="enable_volume_gesture_summary">Control volume by gesture during video playback</string>
     <string name="enable_seek_buttons">Enable seek buttons</string>
     <string name="enable_seek_buttons_summary">Show rewind and forward buttons on the video interface</string>
     <string name="force_list_portrait">No grid in portrait mode</string>
@@ -595,17 +597,6 @@
         <item>Windows-1258</item>
     </string-array>
 
-    <string-array name="touch_entries">
-        <item>@string/player_touch_enable_all</item>
-        <item>@string/player_touch_disable_brightness</item>
-        <item>@string/player_touch_disable_all</item>
-    </string-array>
-    <string-array name="touch_values" translatable="false">
-        <item>0</item>
-        <item>1</item>
-        <item>2</item>
-    </string-array>
-
     <string-array name="aouts">
         <item>@string/aout_audiotrack</item>
         <item>@string/aout_opensles</item>
diff --git a/vlc-android/res/xml/preferences_ui.xml b/vlc-android/res/xml/preferences_ui.xml
index f65e000..e044c0c 100644
--- a/vlc-android/res/xml/preferences_ui.xml
+++ b/vlc-android/res/xml/preferences_ui.xml
@@ -53,12 +53,16 @@
             android:key="save_brightness"
             android:summary="@string/save_brightness_summary"
             android:title="@string/save_brightness_title" />
-        <ListPreference
-            android:defaultValue="0"
-            android:key="enable_touch_player"
-            android:title="@string/player_touch_title"
-            android:entries="@array/touch_entries"
-            android:entryValues="@array/touch_values"/>
+        <CheckBoxPreference
+            android:defaultValue="true"
+            android:key="enable_volume_gesture"
+            android:summary="@string/enable_volume_gesture_summary"
+            android:title="@string/enable_volume_gesture_title" />
+        <CheckBoxPreference
+            android:defaultValue="true"
+            android:key="enable_brightness_gesture"
+            android:summary="@string/enable_brightness_gesture_summary"
+            android:title="@string/enable_brightness_gesture_title" />
         <CheckBoxPreference
             android:defaultValue="false"
             android:key="dialog_confirm_resume"
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 d2b9dfe..4dd6b3f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -623,7 +623,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
 
         public AdvOptionsAdapter() {
             SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AdvOptionsDialog.this.getContext());
-            if (TextUtils.equals(prefs.getString(PreferencesUi.KEY_ENABLE_TOUCH_PLAYER, AndroidDevices.hasTsp() ? "0" : "2"), "2"))
+            if (!(prefs.getBoolean("enable_volume_gesture",false) || prefs.getBoolean("enable_volume_gesture",false)))
                 mSelection = 0;
         }
 
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 abeea83..69ef6b8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.java
@@ -33,8 +33,6 @@ import org.videolan.vlc.R;
 
 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/tv/preferences/PreferencesUi.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
index 3251c4f..433ddc3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
@@ -36,8 +36,6 @@ import org.videolan.vlc.util.AndroidDevices;
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 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;
@@ -56,7 +54,8 @@ public class PreferencesUi extends BasePreferenceFragment {
         findPreference("force_list_portrait").setVisible(false);
         findPreference("enable_headset_detection").setVisible(false);
         findPreference("enable_steal_remote_control").setVisible(false);
-        findPreference(KEY_ENABLE_TOUCH_PLAYER).setVisible(AndroidDevices.hasTsp());
+        findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
+        findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
         findPreference("tv_ui").setVisible(AndroidDevices.hasTsp());
         findPreference("lockscreen_cover").setVisible(false);
         findPreference("enable_black_theme").setVisible(false);
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 5ab5b80..235e0cd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -368,7 +368,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
         mSettings = PreferenceManager.getDefaultSharedPreferences(this);
 
-        mTouchControls = VLCApplication.showTvUi() ? 2 : Integer.valueOf(mSettings.getString(PreferencesUi.KEY_ENABLE_TOUCH_PLAYER, "0")).intValue();
+        if (!VLCApplication.showTvUi()) {
+            mTouchControls = (mSettings.getBoolean("enable_volume_gesture", true) ? 1 : 0)
+                    + (mSettings.getBoolean("enable_brightness_gesture", true) ? 2 : 0);
+        }
 
         /* Services and miscellaneous */
         mAudioManager = (AudioManager) VLCApplication.getAppContext().getSystemService(AUDIO_SERVICE);
@@ -1915,7 +1918,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             togglePlaylist();
             return true;
         }
-        if (mTouchControls == 2 || mIsLocked) {
+        if (mTouchControls == 0 || mIsLocked) {
             // locked or swipe disabled, only handle show/hide & ignore all actions
             if (event.getAction() == MotionEvent.ACTION_UP) {
                 if (!mShowing) {
@@ -1981,12 +1984,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 mTouchY = event.getRawY();
                 mTouchX = event.getRawX();
                 // Volume (Up or Down - Right side)
-                if (mTouchControls == 1 || (int)mTouchX > (3 * screen.widthPixels / 5)){
+                if (mTouchControls == 1 || (mTouchControls == 3 && (int)mTouchX > (4 * screen.widthPixels / 7))){
                     doVolumeTouch(y_changed);
                     hideOverlay(true);
                 }
                 // Brightness (Up or Down - Left side)
-                else if ((int)mTouchX < (2 * screen.widthPixels / 5)){
+                if (mTouchControls == 2 || (mTouchControls == 3 && (int)mTouchX < (3 * screen.widthPixels / 7))){
                     doBrightnessTouch(y_changed);
                     hideOverlay(true);
                 }



More information about the Android mailing list