Open jebai0521 opened 4 years ago
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; }
This seems like a good solution! I'm having this issue too while testing on my Xiaomi device
Do you have some news for this issue ?
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