()
| 832 | private final static int MIN_BACKLIGHT_LEVEL_PERCENT = DeviceInfo.AMOLED_SCREEN ? 2 : 16; |
| 833 | |
| 834 | public void onUserActivity() |
| 835 | { |
| 836 | if (backlightControl != null) |
| 837 | backlightControl.onUserActivity(); |
| 838 | // Hack |
| 839 | //if ( backlightControl.isHeld() ) |
| 840 | BackgroundThread.guiExecutor.execute(new Runnable() { |
| 841 | @Override |
| 842 | public void run() { |
| 843 | try { |
| 844 | float b; |
| 845 | int dimmingAlpha = 255; |
| 846 | // screenBacklightBrightness is 0..100 |
| 847 | if (screenBacklightBrightness >= 0) { |
| 848 | float minb = MIN_BACKLIGHT_LEVEL_PERCENT / 100.0f; |
| 849 | if ( screenBacklightBrightness >= 10 ) { |
| 850 | // real brightness control, no colors dimming |
| 851 | b = (screenBacklightBrightness - 10) / (100.0f - 10.0f); // 0..1 |
| 852 | b = minb + b * (1-minb); // minb..1 |
| 853 | if (b < minb) // BRIGHTNESS_OVERRIDE_OFF |
| 854 | b = minb; |
| 855 | else if (b > 1.0f) |
| 856 | b = 1.0f; //BRIGHTNESS_OVERRIDE_FULL |
| 857 | } else { |
| 858 | // minimal brightness with colors dimming |
| 859 | b = minb; |
| 860 | dimmingAlpha = 255 - (11-screenBacklightBrightness) * 180 / 10; |
| 861 | } |
| 862 | } else { |
| 863 | // system |
| 864 | b = -1.0f; //BRIGHTNESS_OVERRIDE_NONE |
| 865 | } |
| 866 | mReaderView.setDimmingAlpha(dimmingAlpha); |
| 867 | log.d("Brightness: " + b + ", dim: " + dimmingAlpha); |
| 868 | updateBacklightBrightness(b); |
| 869 | updateButtonsBrightness(keyBacklightOff ? 0.0f : -1.0f); |
| 870 | } catch ( Exception e ) { |
| 871 | // ignore |
| 872 | } |
| 873 | } |
| 874 | }); |
| 875 | } |
| 876 | |
| 877 | boolean mDestroyed = false; |
| 878 | @Override |
no test coverage detected