Merge "Modify Accessibility Setting UI for timeout feature" into qt-dev am: 764b8491e1
am: dfae7fe0e0
Change-Id: I14b955b57ebafbc99a656270c967cd3a7c5417e9
This commit is contained in:
@@ -674,15 +674,6 @@
|
|||||||
<item>Accessibility volume</item>
|
<item>Accessibility volume</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Keys for the list of accessibility timeouts xml. -->
|
|
||||||
<string-array name="accessibility_timeout_content_selector_keys" translatable="false">
|
|
||||||
<item>accessibility_content_timeout_default</item>
|
|
||||||
<item>accessibility_content_timeout_10secs</item>
|
|
||||||
<item>accessibility_content_timeout_30secs</item>
|
|
||||||
<item>accessibility_content_timeout_1min</item>
|
|
||||||
<item>accessibility_content_timeout_2mins</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<!-- Keys for the list of accessibility timeouts xml. -->
|
<!-- Keys for the list of accessibility timeouts xml. -->
|
||||||
<string-array name="accessibility_timeout_control_selector_keys" translatable="false">
|
<string-array name="accessibility_timeout_control_selector_keys" translatable="false">
|
||||||
<item>accessibility_control_timeout_default</item>
|
<item>accessibility_control_timeout_default</item>
|
||||||
|
@@ -4893,12 +4893,10 @@
|
|||||||
<string name="accessibility_timeout_1min">1 minute</string>
|
<string name="accessibility_timeout_1min">1 minute</string>
|
||||||
<!-- Option heading to leave the timeout requirement for accessibility users at 2 mins. [CHAR LIMIT=35] -->
|
<!-- Option heading to leave the timeout requirement for accessibility users at 2 mins. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_timeout_2mins">2 minutes</string>
|
<string name="accessibility_timeout_2mins">2 minutes</string>
|
||||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
<!-- Title for accessibility settings timeout item. [CHAR LIMIT=43] -->
|
||||||
<string name="accessibility_content_timeout_preference_title">Time to read</string>
|
<string name="accessibility_setting_item_control_timeout_title">Time to take action (Accessibility timeout)</string>
|
||||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
||||||
<!-- Descriptive text for accessibility preference to accessibility content timeout. [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="accessibility_content_timeout_preference_summary">Choose how long to show messages that you need to read, but are visible only temporarily.\n\nNot all apps support this setting.</string>
|
|
||||||
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_control_timeout_preference_summary">Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting.</string>
|
<string name="accessibility_control_timeout_preference_summary">Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting.</string>
|
||||||
|
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2018 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"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:key="accessibility_content_timeout_preference"
|
|
||||||
android:title="@string/accessibility_content_timeout_preference_title"
|
|
||||||
android:persistent="false" >
|
|
||||||
|
|
||||||
<com.android.settings.widget.VideoPreference
|
|
||||||
android:key="accessibility_content_timeout_video"
|
|
||||||
android:title="@string/summary_placeholder"
|
|
||||||
settings:animation="@raw/accessibility_timeout"
|
|
||||||
settings:preview="@drawable/accessibility_timeout"
|
|
||||||
settings:controller="com.android.settings.widget.VideoPreferenceController"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.RadioButtonPreference
|
|
||||||
android:key="accessibility_content_timeout_default"
|
|
||||||
android:title="@string/accessibility_timeout_default"
|
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.RadioButtonPreference
|
|
||||||
android:key="accessibility_content_timeout_10secs"
|
|
||||||
android:title="@string/accessibility_timeout_10secs"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.RadioButtonPreference
|
|
||||||
android:key="accessibility_content_timeout_30secs"
|
|
||||||
android:title="@string/accessibility_timeout_30secs"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.RadioButtonPreference
|
|
||||||
android:key="accessibility_content_timeout_1min"
|
|
||||||
android:title="@string/accessibility_timeout_1min"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.RadioButtonPreference
|
|
||||||
android:key="accessibility_content_timeout_2mins"
|
|
||||||
android:title="@string/accessibility_timeout_2mins"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
|
||||||
android:title="@string/accessibility_content_timeout_preference_summary"
|
|
||||||
android:selectable="false" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -77,12 +77,6 @@
|
|||||||
android:key="toggle_disable_animations"
|
android:key="toggle_disable_animations"
|
||||||
android:title="@string/accessibility_disable_animations" />
|
android:title="@string/accessibility_disable_animations" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:fragment="com.android.settings.accessibility.AccessibilityContentTimeoutPreferenceFragment"
|
|
||||||
android:key="accessibility_content_timeout_preference_fragment"
|
|
||||||
android:title="@string/accessibility_content_timeout_preference_title"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
@@ -115,7 +109,7 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.accessibility.AccessibilityControlTimeoutPreferenceFragment"
|
android:fragment="com.android.settings.accessibility.AccessibilityControlTimeoutPreferenceFragment"
|
||||||
android:key="accessibility_control_timeout_preference_fragment"
|
android:key="accessibility_control_timeout_preference_fragment"
|
||||||
android:title="@string/accessibility_control_timeout_preference_title"
|
android:title="@string/accessibility_setting_item_control_timeout_title"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
@@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SearchIndexable
|
|
||||||
public final class AccessibilityContentTimeoutPreferenceFragment extends DashboardFragment
|
|
||||||
implements AccessibilityTimeoutController.OnChangeListener {
|
|
||||||
|
|
||||||
static final String TAG = "AccessibilityContentTimeoutPreferenceFragment";
|
|
||||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(Preference preference) {
|
|
||||||
for (AbstractPreferenceController controller : sControllers) {
|
|
||||||
controller.updateState(preference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
for (AbstractPreferenceController controller :
|
|
||||||
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
|
|
||||||
((AccessibilityTimeoutController)controller).setOnChangeListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
for (AbstractPreferenceController controller :
|
|
||||||
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
|
|
||||||
((AccessibilityTimeoutController)controller).setOnChangeListener(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.ACCESSIBILITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.accessibility_content_timeout_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
||||||
return buildPreferenceControllers(context, getSettingsLifecycle());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
|
||||||
Lifecycle lifecycle) {
|
|
||||||
if (sControllers.size() == 0) {
|
|
||||||
Resources resources = context.getResources();
|
|
||||||
|
|
||||||
String[] timeoutKeys = resources.getStringArray(
|
|
||||||
R.array.accessibility_timeout_content_selector_keys);
|
|
||||||
|
|
||||||
for (int i=0; i < timeoutKeys.length; i++) {
|
|
||||||
sControllers.add(new AccessibilityTimeoutController(
|
|
||||||
context, lifecycle, timeoutKeys[i], TAG));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sControllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
||||||
new BaseSearchIndexProvider() {
|
|
||||||
@Override
|
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
|
||||||
boolean enabled) {
|
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = R.xml.accessibility_content_timeout_settings;
|
|
||||||
return Arrays.asList(sir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getNonIndexableKeys(Context context) {
|
|
||||||
final List<String> keys = super.getNonIndexableKeys(context);
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
|
||||||
Context context) {
|
|
||||||
return buildPreferenceControllers(context, null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@@ -98,7 +98,7 @@ public final class AccessibilityControlTimeoutPreferenceFragment extends Dashboa
|
|||||||
|
|
||||||
for (int i=0; i < timeoutKeys.length; i++) {
|
for (int i=0; i < timeoutKeys.length; i++) {
|
||||||
sControllers.add(new AccessibilityTimeoutController(
|
sControllers.add(new AccessibilityTimeoutController(
|
||||||
context, lifecycle, timeoutKeys[i], TAG));
|
context, lifecycle, timeoutKeys[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sControllers;
|
return sControllers;
|
||||||
@@ -126,4 +126,4 @@ public final class AccessibilityControlTimeoutPreferenceFragment extends Dashboa
|
|||||||
return buildPreferenceControllers(context, null);
|
return buildPreferenceControllers(context, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -132,8 +132,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
"vibration_preference_screen";
|
"vibration_preference_screen";
|
||||||
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
|
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
|
||||||
"daltonizer_preference";
|
"daltonizer_preference";
|
||||||
private static final String ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE =
|
|
||||||
"accessibility_content_timeout_preference_fragment";
|
|
||||||
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
|
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
|
||||||
"accessibility_control_timeout_preference_fragment";
|
"accessibility_control_timeout_preference_fragment";
|
||||||
private static final String DARK_UI_MODE_PREFERENCE =
|
private static final String DARK_UI_MODE_PREFERENCE =
|
||||||
@@ -727,8 +725,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
mToggleInversionPreference.getOrder() + 1);
|
mToggleInversionPreference.getOrder() + 1);
|
||||||
mToggleDisableAnimationsPreference.setOrder(
|
mToggleDisableAnimationsPreference.setOrder(
|
||||||
mToggleLargePointerIconPreference.getOrder() + 1);
|
mToggleLargePointerIconPreference.getOrder() + 1);
|
||||||
findPreference(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE).setOrder(
|
|
||||||
mToggleDisableAnimationsPreference.getOrder() + 1);
|
|
||||||
mToggleInversionPreference.setSummary(R.string.summary_empty);
|
mToggleInversionPreference.setSummary(R.string.summary_empty);
|
||||||
displayCategory.addPreference(mToggleInversionPreference);
|
displayCategory.addPreference(mToggleInversionPreference);
|
||||||
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
|
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
|
||||||
@@ -794,8 +790,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
|
updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
|
||||||
|
|
||||||
updateAccessibilityTimeoutSummary(getContentResolver(),
|
|
||||||
findPreference(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE));
|
|
||||||
updateAccessibilityTimeoutSummary(getContentResolver(),
|
updateAccessibilityTimeoutSummary(getContentResolver(),
|
||||||
findPreference(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE));
|
findPreference(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE));
|
||||||
}
|
}
|
||||||
@@ -806,14 +800,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
int[] timeoutValues = getResources().getIntArray(
|
int[] timeoutValues = getResources().getIntArray(
|
||||||
R.array.accessibility_timeout_selector_values);
|
R.array.accessibility_timeout_selector_values);
|
||||||
|
|
||||||
int timeoutValue = 0;
|
int timeoutValue = AccessibilityTimeoutController.getSecureAccessibilityTimeoutValue(
|
||||||
if (pref.getKey().equals(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE)) {
|
|
||||||
timeoutValue = AccessibilityTimeoutController.getSecureAccessibilityTimeoutValue(
|
|
||||||
resolver, AccessibilityTimeoutController.CONTENT_TIMEOUT_SETTINGS_SECURE);
|
|
||||||
} else if (pref.getKey().equals(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE)) {
|
|
||||||
timeoutValue = AccessibilityTimeoutController.getSecureAccessibilityTimeoutValue(
|
|
||||||
resolver, AccessibilityTimeoutController.CONTROL_TIMEOUT_SETTINGS_SECURE);
|
resolver, AccessibilityTimeoutController.CONTROL_TIMEOUT_SETTINGS_SECURE);
|
||||||
}
|
|
||||||
|
|
||||||
int idx = Ints.indexOf(timeoutValues, timeoutValue);
|
int idx = Ints.indexOf(timeoutValues, timeoutValue);
|
||||||
pref.setSummary(timeoutSummarys[idx == -1 ? 0 : idx]);
|
pref.setSummary(timeoutSummarys[idx == -1 ? 0 : idx]);
|
||||||
|
@@ -36,6 +36,9 @@ import com.google.common.primitives.Ints;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller class that control accessibility time out settings.
|
||||||
|
*/
|
||||||
public class AccessibilityTimeoutController extends AbstractPreferenceController implements
|
public class AccessibilityTimeoutController extends AbstractPreferenceController implements
|
||||||
LifecycleObserver, RadioButtonPreference.OnClickListener, PreferenceControllerMixin {
|
LifecycleObserver, RadioButtonPreference.OnClickListener, PreferenceControllerMixin {
|
||||||
static final String CONTENT_TIMEOUT_SETTINGS_SECURE =
|
static final String CONTENT_TIMEOUT_SETTINGS_SECURE =
|
||||||
@@ -43,11 +46,11 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
static final String CONTROL_TIMEOUT_SETTINGS_SECURE =
|
static final String CONTROL_TIMEOUT_SETTINGS_SECURE =
|
||||||
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS;
|
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS;
|
||||||
|
|
||||||
// pair the preference key and timeout value
|
// pair the preference key and timeout value.
|
||||||
private final Map<String, Integer> mAccessibilityTimeoutKeyToValueMap = new HashMap<>();
|
private final Map<String, Integer> mAccessibilityTimeoutKeyToValueMap = new HashMap<>();
|
||||||
|
|
||||||
|
// RadioButtonPreference key, each preference represent a timeout value.
|
||||||
private final String mPreferenceKey;
|
private final String mPreferenceKey;
|
||||||
private final String mfragmentTag;
|
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
private final Resources mResources;
|
private final Resources mResources;
|
||||||
private OnChangeListener mOnChangeListener;
|
private OnChangeListener mOnChangeListener;
|
||||||
@@ -55,7 +58,7 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
private int mAccessibilityUiTimeoutValue;
|
private int mAccessibilityUiTimeoutValue;
|
||||||
|
|
||||||
public AccessibilityTimeoutController(Context context, Lifecycle lifecycle,
|
public AccessibilityTimeoutController(Context context, Lifecycle lifecycle,
|
||||||
String preferenceKey, String fragmentTag) {
|
String preferenceKey) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
mContentResolver = context.getContentResolver();
|
mContentResolver = context.getContentResolver();
|
||||||
@@ -65,7 +68,6 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
mPreferenceKey = preferenceKey;
|
mPreferenceKey = preferenceKey;
|
||||||
mfragmentTag = fragmentTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int getSecureAccessibilityTimeoutValue(ContentResolver resolver, String name) {
|
protected static int getSecureAccessibilityTimeoutValue(ContentResolver resolver, String name) {
|
||||||
@@ -84,14 +86,8 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
private Map<String, Integer> getTimeoutValueToKeyMap() {
|
private Map<String, Integer> getTimeoutValueToKeyMap() {
|
||||||
if (mAccessibilityTimeoutKeyToValueMap.size() == 0) {
|
if (mAccessibilityTimeoutKeyToValueMap.size() == 0) {
|
||||||
|
|
||||||
String[] timeoutKeys = null;
|
String[] timeoutKeys = mResources.getStringArray(
|
||||||
if (mfragmentTag.equals(AccessibilityContentTimeoutPreferenceFragment.TAG)) {
|
|
||||||
timeoutKeys = mResources.getStringArray(
|
|
||||||
R.array.accessibility_timeout_content_selector_keys);
|
|
||||||
} else if (mfragmentTag.equals(AccessibilityControlTimeoutPreferenceFragment.TAG)) {
|
|
||||||
timeoutKeys = mResources.getStringArray(
|
|
||||||
R.array.accessibility_timeout_control_selector_keys);
|
R.array.accessibility_timeout_control_selector_keys);
|
||||||
}
|
|
||||||
|
|
||||||
int[] timeoutValues = mResources.getIntArray(
|
int[] timeoutValues = mResources.getIntArray(
|
||||||
R.array.accessibility_timeout_selector_values);
|
R.array.accessibility_timeout_selector_values);
|
||||||
@@ -109,11 +105,9 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handlePreferenceChange(String value) {
|
private void handlePreferenceChange(String value) {
|
||||||
if (mfragmentTag.equals(AccessibilityContentTimeoutPreferenceFragment.TAG)) {
|
// save value to both content and control timeout setting.
|
||||||
putSecureString(Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, value);
|
putSecureString(Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, value);
|
||||||
} else if (mfragmentTag.equals(AccessibilityControlTimeoutPreferenceFragment.TAG)) {
|
putSecureString(Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, value);
|
||||||
putSecureString(Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,16 +138,10 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getAccessibilityTimeoutValue(String fragmentTag) {
|
private int getAccessibilityTimeoutValue() {
|
||||||
int timeoutValue = 0;
|
// get accessibility control timeout value
|
||||||
// two kinds of Secure value, one is content timeout, the other is control timeout.
|
int timeoutValue = getSecureAccessibilityTimeoutValue(mContentResolver,
|
||||||
if (AccessibilityContentTimeoutPreferenceFragment.TAG.equals(fragmentTag)) {
|
|
||||||
timeoutValue = getSecureAccessibilityTimeoutValue(mContentResolver,
|
|
||||||
CONTENT_TIMEOUT_SETTINGS_SECURE);
|
|
||||||
} else if (AccessibilityControlTimeoutPreferenceFragment.TAG.equals(fragmentTag)) {
|
|
||||||
timeoutValue = getSecureAccessibilityTimeoutValue(mContentResolver,
|
|
||||||
CONTROL_TIMEOUT_SETTINGS_SECURE);
|
CONTROL_TIMEOUT_SETTINGS_SECURE);
|
||||||
}
|
|
||||||
return timeoutValue;
|
return timeoutValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +155,7 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
super.updateState(preference);
|
super.updateState(preference);
|
||||||
|
|
||||||
mAccessibilityUiTimeoutValue = getAccessibilityTimeoutValue(mfragmentTag);
|
mAccessibilityUiTimeoutValue = getAccessibilityTimeoutValue();
|
||||||
|
|
||||||
// reset RadioButton
|
// reset RadioButton
|
||||||
mPreference.setChecked(false);
|
mPreference.setChecked(false);
|
||||||
@@ -175,7 +163,13 @@ public class AccessibilityTimeoutController extends AbstractPreferenceController
|
|||||||
updatePreferenceCheckedState(preferenceValue);
|
updatePreferenceCheckedState(preferenceValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface OnChangeListener {
|
/**
|
||||||
|
* Listener interface handles checked event.
|
||||||
|
*/
|
||||||
|
public interface OnChangeListener {
|
||||||
|
/**
|
||||||
|
* A hook that is called when preference checked.
|
||||||
|
*/
|
||||||
void onCheckedChanged(Preference preference);
|
void onCheckedChanged(Preference preference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,11 +27,9 @@ import android.content.Context;
|
|||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.ListPreference;
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.display.DarkUIPreferenceController;
|
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -46,8 +44,6 @@ import java.util.List;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class AccessibilitySettingsTest {
|
public class AccessibilitySettingsTest {
|
||||||
private static final String VIBRATION_PREFERENCE_SCREEN = "vibration_preference_screen";
|
private static final String VIBRATION_PREFERENCE_SCREEN = "vibration_preference_screen";
|
||||||
private static final String ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE =
|
|
||||||
"accessibility_content_timeout_preference_fragment";
|
|
||||||
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
|
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
|
||||||
"accessibility_control_timeout_preference_fragment";
|
"accessibility_control_timeout_preference_fragment";
|
||||||
private static final String DARK_UI_MODE_PREFERENCE =
|
private static final String DARK_UI_MODE_PREFERENCE =
|
||||||
@@ -71,9 +67,9 @@ public class AccessibilitySettingsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testNonIndexableKeys_existInXmlLayout() {
|
public void testNonIndexableKeys_existInXmlLayout() {
|
||||||
final List<String> niks = AccessibilitySettings.SEARCH_INDEX_DATA_PROVIDER
|
final List<String> niks = AccessibilitySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
.getNonIndexableKeys(mContext);
|
.getNonIndexableKeys(mContext);
|
||||||
final List<String> keys =
|
final List<String> keys =
|
||||||
XmlTestUtils.getKeysFromPreferenceXml(mContext, R.xml.accessibility_settings);
|
XmlTestUtils.getKeysFromPreferenceXml(mContext, R.xml.accessibility_settings);
|
||||||
|
|
||||||
assertThat(keys).containsAllIn(niks);
|
assertThat(keys).containsAllIn(niks);
|
||||||
}
|
}
|
||||||
@@ -112,12 +108,6 @@ public class AccessibilitySettingsTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < testingValues.length; i++) {
|
for (int i = 0; i < testingValues.length; i++) {
|
||||||
Settings.Secure.putString(mContentResolver,
|
|
||||||
Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, testingValues[i]);
|
|
||||||
|
|
||||||
verifyAccessibilityTimeoutSummary(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE,
|
|
||||||
exceptedResIds[i]);
|
|
||||||
|
|
||||||
Settings.Secure.putString(mContentResolver,
|
Settings.Secure.putString(mContentResolver,
|
||||||
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, testingValues[i]);
|
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, testingValues[i]);
|
||||||
|
|
||||||
|
@@ -45,8 +45,7 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class AccessibilityTimeoutControllerTest
|
public class AccessibilityTimeoutControllerTest
|
||||||
implements AccessibilityTimeoutController.OnChangeListener {
|
implements AccessibilityTimeoutController.OnChangeListener {
|
||||||
private static final String PREF_KEY = "accessibility_content_timeout_30secs";
|
private static final String PREF_KEY = "accessibility_control_timeout_30secs";
|
||||||
private static String PREF_TITLE;
|
|
||||||
|
|
||||||
private AccessibilityTimeoutController mController;
|
private AccessibilityTimeoutController mController;
|
||||||
|
|
||||||
@@ -62,15 +61,14 @@ public class AccessibilityTimeoutControllerTest
|
|||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mController = new AccessibilityTimeoutController(mContext, mock(Lifecycle.class),
|
mController = new AccessibilityTimeoutController(mContext, mock(Lifecycle.class), PREF_KEY);
|
||||||
PREF_KEY, AccessibilityContentTimeoutPreferenceFragment.TAG);
|
|
||||||
mController.setOnChangeListener(this);
|
mController.setOnChangeListener(this);
|
||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
PREF_TITLE = mContext.getResources().getString(R.string.accessibility_timeout_30secs);
|
String prefTitle = mContext.getResources().getString(R.string.accessibility_timeout_30secs);
|
||||||
|
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mMockPref);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mMockPref);
|
||||||
when(mMockPref.getKey()).thenReturn(PREF_KEY);
|
when(mMockPref.getKey()).thenReturn(PREF_KEY);
|
||||||
when(mMockPref.getTitle()).thenReturn(PREF_TITLE);
|
when(mMockPref.getTitle()).thenReturn(prefTitle);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +85,7 @@ public class AccessibilityTimeoutControllerTest
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_notChecked() {
|
public void updateState_notChecked() {
|
||||||
Settings.Secure.putString(mContentResolver,
|
Settings.Secure.putString(mContentResolver,
|
||||||
Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, "0");
|
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, "0");
|
||||||
|
|
||||||
mController.updateState(mMockPref);
|
mController.updateState(mMockPref);
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ public class AccessibilityTimeoutControllerTest
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_checked() {
|
public void updateState_checked() {
|
||||||
Settings.Secure.putString(mContentResolver,
|
Settings.Secure.putString(mContentResolver,
|
||||||
Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, "30000");
|
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, "30000");
|
||||||
|
|
||||||
mController.updateState(mMockPref);
|
mController.updateState(mMockPref);
|
||||||
|
|
||||||
@@ -113,8 +111,8 @@ public class AccessibilityTimeoutControllerTest
|
|||||||
mController.onRadioButtonClicked(mMockPref);
|
mController.onRadioButtonClicked(mMockPref);
|
||||||
|
|
||||||
String accessibilityUiTimeoutValue = Settings.Secure.getString(mContentResolver,
|
String accessibilityUiTimeoutValue = Settings.Secure.getString(mContentResolver,
|
||||||
Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS);
|
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS);
|
||||||
|
|
||||||
assertThat(accessibilityUiTimeoutValue).isEqualTo("30000");
|
assertThat(accessibilityUiTimeoutValue).isEqualTo("30000");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user