[Android] Add an option to disable brightness gesture

Sébastien Toque git at videolan.org
Sat Aug 18 09:51:14 CEST 2012


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sat Aug 18 07:48:48 2012 +0200| [1e7385980413987ec5dce1807f4f2510ad9e6912] | committer: Sébastien Toque

Add an option to disable brightness gesture
also disable seek gesture when the wheel bar is used

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=1e7385980413987ec5dce1807f4f2510ad9e6912
---

 vlc-android/res/values-fr/strings.xml              |    1 +
 vlc-android/res/values/strings.xml                 |    1 +
 vlc-android/res/xml/preferences.xml                |    5 +++
 .../vlc/gui/video/VideoPlayerActivity.java         |   37 ++++++++++++--------
 4 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/vlc-android/res/values-fr/strings.xml b/vlc-android/res/values-fr/strings.xml
index 2bf7ac1..5eb6d7b 100644
--- a/vlc-android/res/values-fr/strings.xml
+++ b/vlc-android/res/values-fr/strings.xml
@@ -119,6 +119,7 @@
     <string name="detect_headset">Détecter le casque</string>
     <string name="detect_headset_detail">Pause lors du débranchement du casque, Reprise lors du branchement du casque</string>
     <string name="enable_wheel_bar">Activer la wheel bar</string>
+    <string name="enable_gesture_brightness">Activer le geste de luminosité</string>
     <string name="enable_verbose_mode">Verbosité</string>
     <string name="enable_verbose_mode_detail">Augmenter la verbosité (logcat)</string>
     <string name="aout">Sortie audio</string>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index cbfa677..e575f34 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -132,6 +132,7 @@
     <string name="detect_headset">Detect headset</string>
     <string name="detect_headset_detail">Pause on headset removed; resume on headset inserted</string>
     <string name="enable_wheel_bar">Enable wheel bar</string>
+    <string name="enable_gesture_brightness">Enable brightness gesture</string>
     <string name="enable_verbose_mode">Verbose</string>
     <string name="enable_verbose_mode_detail">Increase the verbosity (logcat)</string>
     <string name="aout">Audio output</string>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 1512e32..80b0d5b 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -29,6 +29,11 @@
             android:title="@string/enable_wheel_bar"
             android:defaultValue="false">
         </CheckBoxPreference>
+        <CheckBoxPreference
+            android:key="enable_gesture_brightness"
+            android:title="@string/enable_gesture_brightness"
+            android:defaultValue="true">
+        </CheckBoxPreference>
     </PreferenceCategory>
     <PreferenceCategory android:title="@string/privacy_prefs_category">
         <PreferenceScreen
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 9af47e5..d8a901c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -128,6 +128,8 @@ public class VideoPlayerActivity extends Activity {
     private TextView mLength;
     private TextView mInfo;
     private IPlayerControl mControls;
+    private boolean mEnableWheelbar;
+    private boolean mEnableBrightnessGesture;
     private Spinner mAudio;
     private Spinner mSubtitles;
     private ImageButton mLock;
@@ -236,7 +238,9 @@ public class VideoPlayerActivity extends Activity {
         // the info textView is not on the overlay
         mInfo = (TextView) findViewById(R.id.player_overlay_info);
 
-        mControls = pref.getBoolean("enable_wheel_bar", false)
+        mEnableWheelbar = pref.getBoolean("enable_wheel_bar", false);
+        mEnableBrightnessGesture = pref.getBoolean("enable_gesture_brightness", true);
+        mControls = mEnableWheelbar
                 ? new PlayerControlWheel(this)
                 : new PlayerControlClassic(this);
         mControls.setOnPlayerControlListener(mPlayerControlListener);
@@ -263,18 +267,21 @@ public class VideoPlayerActivity extends Activity {
         mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
         mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
 
-        // Initialize the layoutParams screen brightness
-        try {
-            int brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
-                    android.provider.Settings.System.SCREEN_BRIGHTNESS);
-            mBrightnessValue = brightnesstemp / 255.0f;
-        } catch (SettingNotFoundException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+        if (mEnableBrightnessGesture)
+        {
+            // Initialize the layoutParams screen brightness
+            try {
+                int brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
+                        android.provider.Settings.System.SCREEN_BRIGHTNESS);
+                mBrightnessValue = brightnesstemp / 255.0f;
+            } catch (SettingNotFoundException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            WindowManager.LayoutParams lp = getWindow().getAttributes();
+            lp.screenBrightness = mBrightnessValue;
+            getWindow().setAttributes(lp);
         }
-        WindowManager.LayoutParams lp = getWindow().getAttributes();
-        lp.screenBrightness = mBrightnessValue;
-        getWindow().setAttributes(lp);
 
         mSwitchingView = false;
         mEndReached = false;
@@ -686,7 +693,7 @@ public class VideoPlayerActivity extends Activity {
             // No audio/contrast action if coef < 2
             if (coef > 2) {
                 // Audio (Up or Down - Right side)
-                if (mTouchX > (screen.widthPixels / 2)){
+                if (!mEnableBrightnessGesture || mTouchX > (screen.widthPixels / 2)){
                     int delta = -(int) ((y_changed / mAudioDisplayRange) * mAudioMax);
                     int vol = (int) Math.min(Math.max(mVol + delta, 0), mAudioMax);
                     if (delta != 0) {
@@ -696,7 +703,7 @@ public class VideoPlayerActivity extends Activity {
                     }
                 }
                 // Contrast (Up or Down - Left side)
-                if (mTouchX < (screen.widthPixels / 2)){
+                if (mEnableBrightnessGesture && mTouchX < (screen.widthPixels / 2)){
                     evalTouchContrast(coef, - ygesturesize);
                 }
             }
@@ -726,7 +733,7 @@ public class VideoPlayerActivity extends Activity {
 
     private void evalTouchSeek(float coef, float gesturesize, boolean seek) {
         // No seek action if coef > 0.5 and gesturesize < 1cm
-        if (coef > 0.5 || Math.abs(gesturesize) < 1)
+        if (mEnableWheelbar || coef > 0.5 || Math.abs(gesturesize) < 1)
             return;
 
         long length = mLibVLC.getLength();



More information about the Android mailing list