diff options
author | menghanli <menghanli@google.com> | 2020-04-16 22:33:06 +0800 |
---|---|---|
committer | Menghan Li <menghanli@google.com> | 2020-04-23 09:22:01 +0000 |
commit | 771163f0d3cfac4e94e12153d057828e4cdfa916 (patch) | |
tree | 752e12af953f71c8bf258c1d74ca1123abbf1244 | |
parent | 1f91111c3af35dc3a379d1b457d6dbde918c435d (diff) | |
download | packages_apps_Settings-771163f0d3cfac4e94e12153d057828e4cdfa916.tar.gz packages_apps_Settings-771163f0d3cfac4e94e12153d057828e4cdfa916.tar.bz2 packages_apps_Settings-771163f0d3cfac4e94e12153d057828e4cdfa916.zip |
Fix Auto click (dwell timing) the checked option isn't the same as the option before upgrading the OS
Root cause:
After OS upgrade to R, the original logic only check SP key but does not consider the setting enabled key to cause it cannot not show correctly.
Next:
1) accessibility_autoclick_enabled=1 but does not have SP key, customize layout is checked and show the right value
2) accessibility_autoclick_enabled=1 and have SP key, show according items is checked
3) accessibility_autoclick_enabled=0, off button is checked
Bug: 151123423
Test: local test
Change-Id: I9ebcbb35ee0071dbf8c969d0a70ea6293f4c6edb
-rw-r--r-- | src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java | 11 | ||||
-rw-r--r-- | src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java | 29 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java index b98a503fe8..47c1ca787d 100644 --- a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java +++ b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java @@ -153,7 +153,7 @@ public class ToggleAutoclickCustomSeekbarController extends BasePreferenceContro @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (KEY_DELAY_MODE.equals(key)) { - int delayMillis = getSharedPreferenceForDelayValue(); + final int delayMillis = getSharedPreferenceForDelayValue(); updateCustomDelayValue(delayMillis); } } @@ -172,10 +172,11 @@ public class ToggleAutoclickCustomSeekbarController extends BasePreferenceContro } private int getSharedPreferenceForDelayValue() { - int delayMillis = mSharedPreferences.getInt(KEY_CUSTOM_DELAY_VALUE, + final int delayMillis = Settings.Secure.getInt(mContentResolver, + Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY, AccessibilityManager.AUTOCLICK_DELAY_DEFAULT); - return delayMillis; + return mSharedPreferences.getInt(KEY_CUSTOM_DELAY_VALUE, delayMillis); } private void putSecureInt(String name, int value) { @@ -190,14 +191,14 @@ public class ToggleAutoclickCustomSeekbarController extends BasePreferenceContro } private void minusDelayByImageView() { - int delayMillis = getSharedPreferenceForDelayValue(); + final int delayMillis = getSharedPreferenceForDelayValue(); if (delayMillis > MIN_AUTOCLICK_DELAY_MS) { updateCustomDelayValue(delayMillis - AUTOCLICK_DELAY_STEP); } } private void plusDelayByImageView() { - int delayMillis = getSharedPreferenceForDelayValue(); + final int delayMillis = getSharedPreferenceForDelayValue(); if (delayMillis < MAX_AUTOCLICK_DELAY_MS) { updateCustomDelayValue(delayMillis + AUTOCLICK_DELAY_STEP); } diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java index 45cdf913fe..b9af7ce3ee 100644 --- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java +++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java @@ -116,7 +116,7 @@ public class ToggleAutoclickPreferenceController extends BasePreferenceControlle @Override public void onRadioButtonClicked(RadioButtonPreference preference) { - int value = mAccessibilityAutoclickKeyToValueMap.get(mPreferenceKey); + final int value = mAccessibilityAutoclickKeyToValueMap.get(mPreferenceKey); handleRadioButtonPreferenceChange(value); if (mOnChangeListener != null) { mOnChangeListener.onCheckedChanged(mDelayModePref); @@ -137,11 +137,15 @@ public class ToggleAutoclickPreferenceController extends BasePreferenceControlle public void updateState(Preference preference) { super.updateState(preference); - mCurrentUiAutoClickMode = getSharedPreferenceForAutoClickMode(); + final boolean enabled = Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, 0) == 1; + + mCurrentUiAutoClickMode = + enabled ? getSharedPreferenceForAutoClickMode() : AUTOCLICK_OFF_MODE; // Reset RadioButton. mDelayModePref.setChecked(false); - int mode = mAccessibilityAutoclickKeyToValueMap.get(mDelayModePref.getKey()); + final int mode = mAccessibilityAutoclickKeyToValueMap.get(mDelayModePref.getKey()); updatePreferenceCheckedState(mode); updatePreferenceVisibleState(mode); } @@ -155,10 +159,10 @@ public class ToggleAutoclickPreferenceController extends BasePreferenceControlle } private void setAutoclickModeToKeyMap() { - String[] autoclickKeys = mResources.getStringArray( + final String[] autoclickKeys = mResources.getStringArray( R.array.accessibility_autoclick_control_selector_keys); - int[] autoclickValues = mResources.getIntArray( + final int[] autoclickValues = mResources.getIntArray( R.array.accessibility_autoclick_selector_values); final int autoclickValueCount = autoclickValues.length; @@ -168,19 +172,14 @@ public class ToggleAutoclickPreferenceController extends BasePreferenceControlle } private void handleRadioButtonPreferenceChange(int preference) { - if (preference == AUTOCLICK_OFF_MODE) { - putSecureInt(Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, /*value= */ 0); - } else { - putSecureInt(Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, /*value= */ 1); - } + putSecureInt(Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, + (preference != AUTOCLICK_OFF_MODE) ? /* enabled */ 1 : /* disabled */ 0); mSharedPreferences.edit().putInt(KEY_DELAY_MODE, preference).apply(); - if (preference == AUTOCLICK_CUSTOM_MODE) { - return; + if (preference != AUTOCLICK_CUSTOM_MODE) { + putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, preference); } - - putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, preference); } private void putSecureInt(String name, int value) { @@ -188,6 +187,6 @@ public class ToggleAutoclickPreferenceController extends BasePreferenceControlle } private int getSharedPreferenceForAutoClickMode() { - return mSharedPreferences.getInt(KEY_DELAY_MODE, AUTOCLICK_OFF_MODE); + return mSharedPreferences.getInt(KEY_DELAY_MODE, AUTOCLICK_CUSTOM_MODE); } } |