Add a11y setting for Automatically click after pointer stops
Adds new preference screen for the feature, where the feature can be enabled/disabled, and delay before click can be specified (implemented as seek bar preference, enabled iff the feature is enabled). Preference is added to Accessibility setting. The preference summary is set to string describing the delay after pointer stops moving before click is scheduled (the string also contains numerical value of the delay). BUG=20049245 Change-Id: Ib7b2f5c24efbd08e3200143c069bcdbc9b5a327a
This commit is contained in:
55
res/layout/preference_iconless_slider.xml
Normal file
55
res/layout/preference_iconless_slider.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginBottom="8dip">
|
||||
|
||||
<TextView android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dip">
|
||||
|
||||
<SeekBar android:id="@*android:id/seekbar"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
@@ -3816,6 +3816,10 @@
|
||||
<string name="accessibility_display_daltonizer_preference_title">Color correction</string>
|
||||
<!-- Subtitle for the accessibility preference to configure display color space correction. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_display_daltonizer_preference_subtitle">This feature is experimental and may affect performance.</string>
|
||||
<!-- Title for accessibility preference for configuring feature that performs click action soon after mouse/trackpad pointer stops moving. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_autoclick_preference_title">Click after pointer stops moving</string>
|
||||
<!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_autoclick_delay_preference_title">Delay before click</string>
|
||||
|
||||
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
|
||||
<string name="enable_quick_setting">Show in Quick Settings</string>
|
||||
@@ -3835,6 +3839,27 @@
|
||||
<!-- Label for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
|
||||
<string name="daltonizer_mode_tritanomaly">Tritanomaly (blue-yellow)</string>
|
||||
|
||||
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="accessibilty_autoclick_preference_subtitle_extremely_short_delay">
|
||||
<item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
|
||||
</plurals>
|
||||
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="accessibilty_autoclick_preference_subtitle_very_short_delay">
|
||||
<item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
|
||||
</plurals>
|
||||
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="accessibilty_autoclick_preference_subtitle_short_delay">
|
||||
<item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
|
||||
</plurals>
|
||||
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="accessibilty_autoclick_preference_subtitle_long_delay">
|
||||
<item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
|
||||
</plurals>
|
||||
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
|
||||
<plurals name="accessibilty_autoclick_preference_subtitle_very_long_delay">
|
||||
<item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Title for accessibility menu item to lauch a settings activity. [CHAR LIMIT=15] -->
|
||||
<string name="accessibility_menu_item_settings">Settings</string>
|
||||
|
||||
|
26
res/xml/accessibility_autoclick_settings.xml
Normal file
26
res/xml/accessibility_autoclick_settings.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/accessibility_autoclick_preference_title" >
|
||||
|
||||
|
||||
<SeekBarPreference
|
||||
android:key="autoclick_delay"
|
||||
android:title="@string/accessibility_autoclick_delay_preference_title"
|
||||
android:layout="@layout/preference_iconless_slider" />
|
||||
|
||||
</PreferenceScreen>
|
@@ -37,6 +37,11 @@
|
||||
android:key="screen_magnification_preference_screen"
|
||||
android:title="@string/accessibility_screen_magnification_title"/>
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
|
||||
android:key="autoclick_preference_screen"
|
||||
android:title="@string/accessibility_autoclick_preference_title"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="toggle_large_text_preference"
|
||||
android:title="@string/accessibility_toggle_large_text_preference_title"
|
||||
|
@@ -26,6 +26,8 @@ public abstract class InstrumentedFragment extends PreferenceFragment {
|
||||
// Declare new temporary categories here, starting after this value.
|
||||
public static final int UNDECLARED = 100000;
|
||||
|
||||
public static final int ACCESSIBILITY_TOGGLE_AUTOCLICK = UNDECLARED + 1;
|
||||
|
||||
/**
|
||||
* Declare the view of this category.
|
||||
*
|
||||
|
@@ -96,6 +96,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
"captioning_preference_screen";
|
||||
private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN =
|
||||
"screen_magnification_preference_screen";
|
||||
private static final String AUTOCLICK_PREFERENCE_SCREEN =
|
||||
"autoclick_preference_screen";
|
||||
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
|
||||
"daltonizer_preference_screen";
|
||||
|
||||
@@ -190,6 +192,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private Preference mNoServicesMessagePreference;
|
||||
private PreferenceScreen mCaptioningPreferenceScreen;
|
||||
private PreferenceScreen mDisplayMagnificationPreferenceScreen;
|
||||
private PreferenceScreen mAutoclickPreferenceScreen;
|
||||
private PreferenceScreen mGlobalGesturePreferenceScreen;
|
||||
private PreferenceScreen mDisplayDaltonizerPreferenceScreen;
|
||||
private SwitchPreference mToggleInversionPreference;
|
||||
@@ -410,6 +413,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
mDisplayMagnificationPreferenceScreen = (PreferenceScreen) findPreference(
|
||||
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
|
||||
|
||||
// Autoclick after pointer stops.
|
||||
mAutoclickPreferenceScreen = (PreferenceScreen) findPreference(
|
||||
AUTOCLICK_PREFERENCE_SCREEN);
|
||||
|
||||
// Display color adjustments.
|
||||
mDisplayDaltonizerPreferenceScreen = (PreferenceScreen) findPreference(
|
||||
DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
|
||||
@@ -582,6 +589,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
||||
mDisplayDaltonizerPreferenceScreen);
|
||||
|
||||
updateAutoclickSummary(mAutoclickPreferenceScreen);
|
||||
|
||||
// Global gesture
|
||||
final boolean globalGestureEnabled = Settings.Global.getInt(getContentResolver(),
|
||||
Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1;
|
||||
@@ -600,6 +609,20 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
: R.string.accessibility_feature_state_off);
|
||||
}
|
||||
|
||||
private void updateAutoclickSummary(Preference pref) {
|
||||
final boolean enabled = Settings.Secure.getInt(
|
||||
getContentResolver(), Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, 0) == 1;
|
||||
if (!enabled) {
|
||||
pref.setSummary(R.string.accessibility_feature_state_off);
|
||||
return;
|
||||
}
|
||||
int delay = Settings.Secure.getInt(
|
||||
getContentResolver(), Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY,
|
||||
AccessibilityManager.AUTOCLICK_DELAY_DEFAULT);
|
||||
pref.setSummary(ToggleAutoclickPreferenceFragment.getAutoclickPreferenceSummary(
|
||||
getResources(), delay));
|
||||
}
|
||||
|
||||
private void updateLockScreenRotationCheckbox() {
|
||||
Context context = getActivity();
|
||||
if (context != null) {
|
||||
|
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.preference.SeekBarPreference;
|
||||
import android.preference.Preference;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
|
||||
|
||||
/**
|
||||
* Fragment for preference screen for settings related to Automatically click after mouse stops
|
||||
* feature.
|
||||
*/
|
||||
public class ToggleAutoclickPreferenceFragment extends ToggleFeaturePreferenceFragment
|
||||
implements SwitchBar.OnSwitchChangeListener, Preference.OnPreferenceChangeListener {
|
||||
|
||||
/** Min allowed autoclick delay value. */
|
||||
private static final int MIN_AUTOCLICK_DELAY = 200;
|
||||
/** Max allowed autoclick delay value. */
|
||||
private static final int MAX_AUTOCLICK_DELAY = 1000;
|
||||
/**
|
||||
* Allowed autoclick delay values are discrete. This is the difference between two allowed
|
||||
* values.
|
||||
*/
|
||||
private static final int AUTOCLICK_DELAY_STEP = 100;
|
||||
|
||||
/**
|
||||
* Resource ids from which autoclick preference summaries should be derived. The strings have
|
||||
* placeholder for integer delay value.
|
||||
*/
|
||||
private static final int[] mAutoclickPreferenceSummaries = {
|
||||
R.plurals.accessibilty_autoclick_preference_subtitle_extremely_short_delay,
|
||||
R.plurals.accessibilty_autoclick_preference_subtitle_very_short_delay,
|
||||
R.plurals.accessibilty_autoclick_preference_subtitle_short_delay,
|
||||
R.plurals.accessibilty_autoclick_preference_subtitle_long_delay,
|
||||
R.plurals.accessibilty_autoclick_preference_subtitle_very_long_delay
|
||||
};
|
||||
|
||||
/**
|
||||
* Seek bar preference for autoclick delay value. The seek bar has values between 0 and
|
||||
* number of possible discrete autoclick delay values. These will have to be converted to actual
|
||||
* delay values before saving them in settings.
|
||||
*/
|
||||
private SeekBarPreference mDelay;
|
||||
|
||||
/**
|
||||
* Gets string that should be used as a autoclick preference summary for provided autoclick
|
||||
* delay.
|
||||
* @param resources Resources from which string should be retrieved.
|
||||
* @param delay Delay for whose value summary should be retrieved.
|
||||
*/
|
||||
static CharSequence getAutoclickPreferenceSummary(Resources resources, int delay) {
|
||||
int summaryIndex = getAutoclickPreferenceSummaryIndex(delay);
|
||||
return resources.getQuantityString(
|
||||
mAutoclickPreferenceSummaries[summaryIndex], delay, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds index of the summary that should be used for the provided autoclick delay.
|
||||
*/
|
||||
private static int getAutoclickPreferenceSummaryIndex(int delay) {
|
||||
if (delay <= MIN_AUTOCLICK_DELAY) {
|
||||
return 0;
|
||||
}
|
||||
if (delay >= 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user