[Android] Control the contrast with a gesture on the left side of the screen
Alexandre Perraud
4leyx4ndre at gmail.com
Fri Aug 17 21:50:12 CEST 2012
2012/8/17 XilasZ <xilasz at gmail.com>
>
> + //Contrast
>> + private float mBrightnessValue = 0;
>>
>
> why an instance variable when it's used only inside onCreate ?
>
It's ugly, you right.
>
>
>
>> + // 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.
>
SCREEN_BRIGHTNESS is set by default to -1, that means that the screen
brightness to use is the OS one. If you don't set the "real value" to
SCREEN_BRIGHTNESS, the first "touch contrast" you do make a title jump ( -1
to 0,01) and make the screen dark. After that, the variation goes normaly.
> 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.
>
>
Hum... You probably right, it works fine on my Defy whith a good contrast
variation, but not on a Galaxy Nexus, for exemple...i'm gonna
investitgate...
> + // 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
>
>
True... yes... hum... :p
In fact... there is many other bugs, i'm gonna see this on monday.
Bon Week-end à tous !
> _______________________________________________
> Android mailing list
> Android at videolan.org
> http://mailman.videolan.org/listinfo/android
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20120817/204b49ff/attachment-0001.html>
More information about the Android
mailing list