react-native-system-setting icon indicating copy to clipboard operation
react-native-system-setting copied to clipboard

maxBrightness hardcode to 255

Open jebai0521 opened this issue 5 years ago • 2 comments

now, we hardcode max brightness value to 255

https://github.com/c19354837/react-native-system-setting/blob/001d7efc72a1ae2b5bcb6c3d41846337c33508a5/android/src/main/java/com/ninty/system/setting/SystemSetting.java#L225

https://github.com/c19354837/react-native-system-setting/blob/001d7efc72a1ae2b5bcb6c3d41846337c33508a5/android/src/main/java/com/ninty/system/setting/SystemSetting.java#L255

https://github.com/c19354837/react-native-system-setting/blob/001d7efc72a1ae2b5bcb6c3d41846337c33508a5/android/src/main/java/com/ninty/system/setting/SystemSetting.java#L275

but, the value may not equal to 255 on some device

for example, the value is 4096 on Xiaomi, we could get value via the below code

    private static int getMaxBrightness() {
        int brightness = 255;
        try {
            Resources system = Resources.getSystem();
            int resId = system.getIdentifier("config_screenBrightnessSettingMaximum", "integer", "android");
            if (resId != 0) {
                brightness = system.getInteger(resId);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return brightness;
    }

jebai0521 avatar Sep 18 '20 14:09 jebai0521

This seems like a good solution!
I'm having this issue too while testing on my Xiaomi device

xskipy avatar Apr 06 '21 14:04 xskipy

Do you have some news for this issue ?

dsumac avatar Oct 22 '21 15:10 dsumac