[Android] Control the contrast with a gesture on the left side of the screen
XilasZ
xilasz at gmail.com
Fri Aug 17 20:44:40 CEST 2012
> + //Contrast
> + private float mBrightnessValue = 0;
>
why an instance variable when it's used only inside onCreate ?
> + // 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);
>
Why is it needed ? it works without this for me.
Also this doesn't take SCREEN_BRIGHTNESS_MODE into account. When set to
automatic, the brightness value retrieved with SCREEN_BRIGHTNESS is not the
real value set automatically by the OS. So when the activity starts, the
brightness will be changed in onCreate. it would be ok if it was the right
value, but i don't know how to get it.
+ // Adjust contrast
> + if (jump > 0 || jump <= 1) lp.screenBrightness = jump;
> + else if (jump > 1) lp.screenBrightness = 1;
> + else if (jump <= 0) lp.screenBrightness = 0.01f;
>
The first test is wrong, it's always true :p
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20120817/0c865c23/attachment.html>
More information about the Android
mailing list