[Android] Contrast Gesture : move initialize contrast gesture to fix auto-brightness
Alexandre Perraud
git at videolan.org
Mon Aug 20 17:20:15 CEST 2012
vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Mon Aug 20 17:09:38 2012 +0200| [2f68bce4237e84ad8b16d1e56e6ad38b33d525d2] | committer: Jean-Baptiste Kempf
Contrast Gesture : move initialize contrast gesture to fix auto-brightness
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=2f68bce4237e84ad8b16d1e56e6ad38b33d525d2
---
.../vlc/gui/video/VideoPlayerActivity.java | 39 +++++++++++---------
1 file changed, 22 insertions(+), 17 deletions(-)
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 e2b5704..4308d81 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -156,6 +156,9 @@ public class VideoPlayerActivity extends Activity {
//Audio Or Contrast
private boolean mIsAudioOrContrastChanged;
+ // Contrast
+ private boolean mIsFirstContrastGesture = true;
+
@Override
@TargetApi(11)
protected void onCreate(Bundle savedInstanceState) {
@@ -266,21 +269,6 @@ public class VideoPlayerActivity extends Activity {
mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
- if (mEnableBrightnessGesture) {
- float brightnesstemp = 0;
- // Initialize the layoutParams screen brightness
- try {
- brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
- android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
- } catch (SettingNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- WindowManager.LayoutParams lp = getWindow().getAttributes();
- lp.screenBrightness = brightnesstemp;
- getWindow().setAttributes(lp);
- }
-
mSwitchingView = false;
mEndReached = false;
@@ -702,7 +690,8 @@ public class VideoPlayerActivity extends Activity {
}
// Contrast (Up or Down - Left side)
if (mEnableBrightnessGesture && mTouchX < (screen.widthPixels / 2)){
- evalTouchContrast(coef, - ygesturesize);
+ if (mIsFirstContrastGesture) initContrastTouch();
+ doContrastTouch( - ygesturesize);
}
}
// Seek (Right or Left move)
@@ -760,7 +749,23 @@ public class VideoPlayerActivity extends Activity {
Util.millisToString(time + jump)), 1000);
}
- private void evalTouchContrast(float coef, float gesturesize) {
+ private void initContrastTouch() {
+ float brightnesstemp = 0.01f;
+ // Initialize the layoutParams screen brightness
+ try {
+ brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(),
+ android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f;
+ } catch (SettingNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ WindowManager.LayoutParams lp = getWindow().getAttributes();
+ lp.screenBrightness = brightnesstemp;
+ getWindow().setAttributes(lp);
+ mIsFirstContrastGesture = false;
+ }
+
+ private void doContrastTouch(float gesturesize) {
// No contrast action if gesturesize < 0.4 cm
if (Math.abs(gesturesize) < 0.4)
return;
More information about the Android
mailing list