@@ -261,6 +261,7 @@ public void invalidate() {
261261
262262 private final static int BRIGHTNESS_TYPE_COMMON = 0 ;
263263 private final static int BRIGHTNESS_TYPE_WARM = 1 ;
264+ private final static int BRIGHTNESS_TYPE_BOTH = 2 ;
264265
265266 /// Always sync this constants with crengine/include/lvdocview.h!
266267 /// Battery state: no battery
@@ -668,6 +669,7 @@ public void copyToClipboard(String text) {
668669
669670 private int isBacklightControlFlick = 1 ;
670671 private int isWarmBacklightControlFlick = 2 ;
672+ private boolean isColdWarmBacklightControlTogether = false ;
671673 private boolean isTouchScreenEnabled = true ;
672674 // private boolean isManualScrollActive = false;
673675// private boolean isBrightnessControlActive = false;
@@ -1329,7 +1331,7 @@ public boolean onTouchEvent(MotionEvent event) {
13291331 || start_x > width - dragThreshold * 170 / 100 && isBacklightControlFlick == 2 ) {
13301332 // brightness
13311333 state = STATE_BRIGHTNESS ;
1332- brightness_type = BRIGHTNESS_TYPE_COMMON ;
1334+ brightness_type = isColdWarmBacklightControlTogether ? BRIGHTNESS_TYPE_BOTH : BRIGHTNESS_TYPE_COMMON ;
13331335 startBrightnessControl (start_x , start_y , brightness_type );
13341336 return true ;
13351337 }
@@ -2860,6 +2862,8 @@ public void applyAppSetting(String key, String value) {
28602862 isBacklightControlFlick = "1" .equals (value ) ? 1 : ("2" .equals (value ) ? 2 : 0 );
28612863 } else if (key .equals (PROP_APP_FLICK_WARMLIGHT_CONTROL )) {
28622864 isWarmBacklightControlFlick = "1" .equals (value ) ? 1 : ("2" .equals (value ) ? 2 : 0 );
2865+ } else if (key .equals (PROP_APP_FLICK_BACKLIGHT_CONTROL_TOGETHER )) {
2866+ isColdWarmBacklightControlTogether = flg ;
28632867 } else if (PROP_APP_HIGHLIGHT_BOOKMARKS .equals (key )) {
28642868 flgHighlightBookmarks = !"0" .equals (value );
28652869 clearSelection ();
@@ -2915,6 +2919,7 @@ public void setAppSettings(Properties newSettings, Properties oldSettings) {
29152919 || PROP_APP_BOUNCE_TAP_INTERVAL .equals (key )
29162920 || PROP_APP_FLICK_BACKLIGHT_CONTROL .equals (key )
29172921 || PROP_APP_FLICK_WARMLIGHT_CONTROL .equals (key )
2922+ || PROP_APP_FLICK_BACKLIGHT_CONTROL_TOGETHER .equals (key )
29182923 || PROP_APP_FILE_BROWSER_HIDE_EMPTY_FOLDERS .equals (key )
29192924 || PROP_APP_FILE_BROWSER_HIDE_EMPTY_GENRES .equals (key )
29202925 || PROP_APP_SELECTION_ACTION .equals (key )
@@ -3877,6 +3882,8 @@ private void scheduleUnhilite(int delay) {
38773882
38783883 int currentBrightnessValueIndex = -1 ;
38793884 int currentBrightnessValue = -1 ;
3885+ int currentBrightnessWarmValueIndex = -1 ;
3886+ int currentBrightnessWarmValue = -1 ;
38803887 int currentBrightnessPrevYPos = -1 ;
38813888
38823889 private void startBrightnessControl (final int startX , final int startY , int type ) {
@@ -3891,14 +3898,22 @@ private void startBrightnessControl(final int startX, final int startY, int type
38913898 currentBrightnessValue = 50 ;
38923899 currentBrightnessValueIndex = OptionsDialog .findBacklightSettingIndex (currentBrightnessValue );
38933900 }
3894- }
3895- else if (DeviceInfo .EINK_HAVE_FRONTLIGHT )
3901+ } else if (DeviceInfo .EINK_HAVE_FRONTLIGHT )
38963902 currentBrightnessValueIndex = Utils .findNearestIndex (mEinkScreen .getFrontLightLevels (mActivity ), currentBrightnessValue );
38973903 break ;
3904+ case BRIGHTNESS_TYPE_BOTH :
3905+ // only for e-ink
3906+ currentBrightnessValue = mActivity .getScreenBacklightLevel ();
3907+ currentBrightnessWarmValue = mActivity .getWarmBacklightLevel ();
3908+ if (DeviceInfo .EINK_HAVE_FRONTLIGHT )
3909+ currentBrightnessValueIndex = Utils .findNearestIndex (mEinkScreen .getFrontLightLevels (mActivity ), currentBrightnessValue );
3910+ if (DeviceInfo .EINK_HAVE_NATURAL_BACKLIGHT )
3911+ currentBrightnessWarmValueIndex = Utils .findNearestIndex (mEinkScreen .getWarmLightLevels (mActivity ), currentBrightnessWarmValue );
3912+ break ;
38983913 case BRIGHTNESS_TYPE_WARM :
3899- currentBrightnessValue = mActivity .getWarmBacklightLevel ();
3914+ currentBrightnessWarmValue = mActivity .getWarmBacklightLevel ();
39003915 if (DeviceInfo .EINK_HAVE_NATURAL_BACKLIGHT )
3901- currentBrightnessValueIndex = Utils .findNearestIndex (mEinkScreen .getWarmLightLevels (mActivity ), currentBrightnessValue );
3916+ currentBrightnessWarmValueIndex = Utils .findNearestIndex (mEinkScreen .getWarmLightLevels (mActivity ), currentBrightnessWarmValue );
39023917 break ;
39033918 default :
39043919 return ;
@@ -3909,7 +3924,9 @@ else if (DeviceInfo.EINK_HAVE_FRONTLIGHT)
39093924
39103925 private void updateBrightnessControl (final int x , final int y , int type ) {
39113926 List <Integer > levelList = null ;
3927+ List <Integer > levelWarmList = null ;
39123928 int count = 0 ;
3929+ int countWarm = 0 ;
39133930 switch (type ) {
39143931 case BRIGHTNESS_TYPE_COMMON :
39153932 if (!DeviceInfo .EINK_SCREEN )
@@ -3922,77 +3939,126 @@ else if (null != mEinkScreen) {
39223939 return ;
39233940 }
39243941 break ;
3925- case BRIGHTNESS_TYPE_WARM :
3942+ case BRIGHTNESS_TYPE_BOTH :
3943+ // only for e-ink
39263944 if (null != mEinkScreen ) {
3927- levelList = mEinkScreen .getWarmLightLevels (mActivity );
3945+ levelList = mEinkScreen .getFrontLightLevels (mActivity );
39283946 if (null != levelList )
39293947 count = levelList .size ();
39303948 else
39313949 return ;
3950+ levelWarmList = mEinkScreen .getWarmLightLevels (mActivity );
3951+ if (null != levelWarmList )
3952+ countWarm = levelWarmList .size ();
3953+ else
3954+ return ;
3955+ }
3956+ break ;
3957+ case BRIGHTNESS_TYPE_WARM :
3958+ if (null != mEinkScreen ) {
3959+ levelWarmList = mEinkScreen .getWarmLightLevels (mActivity );
3960+ if (null != levelWarmList )
3961+ countWarm = levelWarmList .size ();
3962+ else
3963+ return ;
39323964 }
39333965 break ;
39343966 default :
39353967 return ;
39363968 }
3937- if (0 == count )
3938- return ;
3939- int diff = count *(currentBrightnessPrevYPos - y )/surface .getHeight ();
3940- int index = currentBrightnessValueIndex + diff ;
3941- if (index < 0 )
3942- index = 0 ;
3943- else if (index >= count )
3944- index = count - 1 ;
3945- if (!DeviceInfo .EINK_SCREEN ) {
3946- if (index == 0 ) {
3947- // ignore system brightness level on non eink devices
3948- currentBrightnessPrevYPos = y ;
3949- return ;
3969+ int index = currentBrightnessValueIndex ;
3970+ if (count > 0 ) {
3971+ int diff = count * (currentBrightnessPrevYPos - y ) / surface .getHeight ();
3972+ index += diff ;
3973+ if (index < 0 )
3974+ index = 0 ;
3975+ else if (index >= count )
3976+ index = count - 1 ;
3977+ if (!DeviceInfo .EINK_SCREEN ) {
3978+ if (index == 0 ) {
3979+ // ignore system brightness level on non eink devices
3980+ currentBrightnessPrevYPos = y ;
3981+ return ;
3982+ }
39503983 }
39513984 }
3952- if (index != currentBrightnessValueIndex ) {
3985+ int indexWarm = currentBrightnessWarmValueIndex ;
3986+ if (countWarm > 0 ) {
3987+ int diffWarm = countWarm * (currentBrightnessPrevYPos - y ) / surface .getHeight ();
3988+ indexWarm += diffWarm ;
3989+ if (indexWarm < 0 )
3990+ indexWarm = 0 ;
3991+ else if (indexWarm >= countWarm )
3992+ indexWarm = countWarm - 1 ;
3993+ }
3994+ if (index != currentBrightnessValueIndex || indexWarm != currentBrightnessWarmValueIndex ) {
39533995 currentBrightnessValueIndex = index ;
3954- if (!DeviceInfo .EINK_SCREEN )
3955- currentBrightnessValue = OptionsDialog .mBacklightLevels [currentBrightnessValueIndex ];
3956- else {
3957- // Here levelList already != null
3958- currentBrightnessValue = levelList .get (currentBrightnessValueIndex );
3959- }
3996+ currentBrightnessWarmValueIndex = indexWarm ;
39603997 switch (type ) {
39613998 case BRIGHTNESS_TYPE_COMMON :
3999+ if (!DeviceInfo .EINK_SCREEN )
4000+ currentBrightnessValue = OptionsDialog .mBacklightLevels [currentBrightnessValueIndex ];
4001+ else {
4002+ // Here levelList already != null
4003+ currentBrightnessValue = levelList .get (currentBrightnessValueIndex );
4004+ }
4005+ log .e ("C: setScreenBacklightLevel()" );
39624006 mActivity .setScreenBacklightLevel (currentBrightnessValue );
39634007 break ;
4008+ case BRIGHTNESS_TYPE_BOTH :
4009+ // only for e-ink
4010+ if (DeviceInfo .EINK_SCREEN ) {
4011+ // Here levelList already != null
4012+ currentBrightnessValue = levelList .get (currentBrightnessValueIndex );
4013+ currentBrightnessWarmValue = levelWarmList .get (currentBrightnessWarmValueIndex );
4014+ log .e ("B: setScreenBacklightLevel()" );
4015+ mActivity .setScreenBacklightLevel (currentBrightnessValue );
4016+ mActivity .setScreenWarmBacklightLevel (currentBrightnessWarmValue );
4017+ }
4018+ break ;
39644019 case BRIGHTNESS_TYPE_WARM :
3965- mActivity .setScreenWarmBacklightLevel (currentBrightnessValue );
4020+ if (DeviceInfo .EINK_SCREEN ) {
4021+ // Here levelList already != null
4022+ currentBrightnessWarmValue = levelWarmList .get (currentBrightnessWarmValueIndex );
4023+ log .e ("W: setScreenWarmBacklightLevel()" );
4024+ mActivity .setScreenWarmBacklightLevel (currentBrightnessWarmValue );
4025+ }
39664026 break ;
39674027 }
39684028 currentBrightnessPrevYPos = y ;
39694029 }
39704030 }
39714031
39724032 private void stopBrightnessControl (final int x , final int y , int type ) {
3973- if (currentBrightnessValueIndex >= 0 ) {
4033+ if (currentBrightnessValueIndex >= 0 || currentBrightnessWarmValueIndex >= 0 ) {
39744034 if (x >= 0 && y >= 0 ) {
39754035 updateBrightnessControl (x , y , type );
39764036 }
39774037 switch (type ) {
39784038 case BRIGHTNESS_TYPE_COMMON :
39794039 mSettings .setInt (PROP_APP_SCREEN_BACKLIGHT , currentBrightnessValue );
39804040 break ;
4041+ case BRIGHTNESS_TYPE_BOTH :
4042+ mSettings .setInt (PROP_APP_SCREEN_BACKLIGHT , currentBrightnessValue );
4043+ mSettings .setInt (PROP_APP_SCREEN_WARM_BACKLIGHT , currentBrightnessWarmValue );
4044+ break ;
39814045 case BRIGHTNESS_TYPE_WARM :
3982- mSettings .setInt (PROP_APP_SCREEN_WARM_BACKLIGHT , currentBrightnessValue );
4046+ mSettings .setInt (PROP_APP_SCREEN_WARM_BACKLIGHT , currentBrightnessWarmValue );
39834047 break ;
39844048 default :
39854049 return ;
39864050 }
3987- if (showBrightnessFlickToast ) {
4051+ if (showBrightnessFlickToast && currentBrightnessValueIndex >= 0 ) {
39884052 OptionsDialog .mBacklightLevelsTitles [0 ] = mActivity .getString (R .string .options_app_backlight_screen_default );
39894053 String s = OptionsDialog .mBacklightLevelsTitles [currentBrightnessValueIndex ];
39904054 mActivity .showToast (s );
39914055 }
39924056 if (!DeviceInfo .EINK_SCREEN )
39934057 saveSettings (mSettings );
39944058 currentBrightnessValue = -1 ;
4059+ currentBrightnessWarmValue = -1 ;
39954060 currentBrightnessValueIndex = -1 ;
4061+ currentBrightnessWarmValueIndex = -1 ;
39964062 currentBrightnessPrevYPos = -1 ;
39974063 }
39984064 }
0 commit comments