diff --git a/res/layout/preference_iconless_slider.xml b/res/layout/preference_iconless_slider.xml
new file mode 100644
index 00000000000..8e2b8f37d85
--- /dev/null
+++ b/res/layout/preference_iconless_slider.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 143792ff07b..90b39f67613 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3816,6 +3816,10 @@
Color correction
This feature is experimental and may affect performance.
+
+ Click after pointer stops moving
+
+ Delay before click
Show in Quick Settings
@@ -3835,6 +3839,27 @@
Tritanomaly (blue-yellow)
+
+
+ - Extremely short delay (%1$d ms)
+
+
+
+ - Very short delay (%1$d ms)
+
+
+
+ - Short delay (%1$d ms)
+
+
+
+ - Long delay (%1$d ms)
+
+
+
+ - Very long delay (%1$d ms)
+
+
Settings
diff --git a/res/xml/accessibility_autoclick_settings.xml b/res/xml/accessibility_autoclick_settings.xml
new file mode 100644
index 00000000000..1eb4dc190de
--- /dev/null
+++ b/res/xml/accessibility_autoclick_settings.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index cd9d471fe5c..881037d7747 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -37,6 +37,11 @@
android:key="screen_magnification_preference_screen"
android:title="@string/accessibility_screen_magnification_title"/>
+
+
= MAX_AUTOCLICK_DELAY) {
+ return mAutoclickPreferenceSummaries.length - 1;
+ }
+ int rangeSize = (MAX_AUTOCLICK_DELAY - MIN_AUTOCLICK_DELAY) /
+ (mAutoclickPreferenceSummaries.length - 1);
+ return (delay - MIN_AUTOCLICK_DELAY) / rangeSize;
+ }
+
+ @Override
+ protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
+ Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
+ mDelay.setEnabled(enabled);
+ }
+
+ @Override
+ protected int getMetricsCategory() {
+ return InstrumentedFragment.ACCESSIBILITY_TOGGLE_AUTOCLICK;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.accessibility_autoclick_settings);
+
+ int delay = Settings.Secure.getInt(
+ getContentResolver(), Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY,
+ AccessibilityManager.AUTOCLICK_DELAY_DEFAULT);
+
+ // Initialize seek bar preference. Sets seek bar size to the number of possible delay
+ // values.
+ mDelay = (SeekBarPreference) findPreference("autoclick_delay");
+ mDelay.setMax(delayToSeekBarProgress(MAX_AUTOCLICK_DELAY));
+ mDelay.setProgress(delayToSeekBarProgress(delay));
+ mDelay.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ protected void onInstallSwitchBarToggleSwitch() {
+ super.onInstallSwitchBarToggleSwitch();
+
+ int value = Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, 0);
+ mSwitchBar.setCheckedInternal(value == 1);
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mDelay.setEnabled(value == 1);
+ }
+
+ @Override
+ protected void onRemoveSwitchBarToggleSwitch() {
+ super.onRemoveSwitchBarToggleSwitch();
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ }
+
+ @Override
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ onPreferenceToggled(Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, isChecked);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ setTitle(getString(R.string.accessibility_autoclick_preference_title));
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mDelay && newValue instanceof Integer) {
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY,
+ seekBarProgressToDelay((int)newValue));
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Converts seek bar preference progress value to autoclick delay associated with it.
+ */
+ private int seekBarProgressToDelay(int progress) {
+ return progress * AUTOCLICK_DELAY_STEP + MIN_AUTOCLICK_DELAY;
+ }
+
+ /**
+ * Converts autoclick delay value to seek bar preference progress values that represents said
+ * delay.
+ */
+ private int delayToSeekBarProgress(int delay) {
+ return (delay - MIN_AUTOCLICK_DELAY) / AUTOCLICK_DELAY_STEP;
+ }
+}