Add icons for color inversion and daltonizer

For accessibilty settings, both on the main page
and the shortcut picker.

Also now observing settings that could be toggled
by the shortcut, so changes can be reflected immediately
in the settings ui.

Bug: 34621067
Fixes: 70335904
Test: Observe icons in settings and shortcut picker.
Toggling color inversion and color correction now changes
the setting ui immediately.

Change-Id: Id27b6471376059288ff971e5aea72d76078bef36
This commit is contained in:
Phil Weaver
2017-12-08 17:10:06 -08:00
parent b8eb89579c
commit 0db26b3a87
7 changed files with 313 additions and 30 deletions

View File

@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="4">
<issue
id="LintError"
severity="Error"
message="No `.class` files were found in project &quot;.&quot;, so none of the classfile based checks could be run. Does the project need to be built first?"
category="Lint"
priority="10"
summary="Lint Failure"
explanation="This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.&#xA;These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.">
<location
file="."/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
@@ -93,7 +105,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/layout-land/choose_lock_pattern.xml"
line="152"
line="160"
column="17"/>
</issue>
@@ -1085,7 +1097,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/layout-land/confirm_lock_pattern_internal.xml"
line="110"
line="111"
column="17"/>
</issue>
@@ -1281,6 +1293,134 @@
column="17"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#19263238&quot; android:offset=&quot;0.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
line="17"
column="23"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#00212121&quot; android:offset=&quot;1.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
line="18"
column="23"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#19FFFFFF&quot; android:offset=&quot;0.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
line="32"
column="23"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#00FFFFFF&quot; android:offset=&quot;1.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
line="33"
column="23"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#19263238&quot; android:offset=&quot;0.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
line="16"
column="27"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#00212121&quot; android:offset=&quot;1.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
line="17"
column="27"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#19FFFFFF&quot; android:offset=&quot;0.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
line="36"
column="23"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
category="Correctness"
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" &lt;item android:color=&quot;#00FFFFFF&quot; android:offset=&quot;1.0&quot;/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
line="37"
column="23"/>
</issue>
<issue
id="HardCodedColor"
severity="Error"
@@ -1869,7 +2009,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/layout/settings_main_dashboard.xml"
line="29"
line="30"
column="9"/>
</issue>
@@ -1933,7 +2073,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
line="2335"
line="2333"
column="168"/>
</issue>
@@ -1949,7 +2089,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
line="2341"
line="2334"
column="64"/>
</issue>
@@ -1965,7 +2105,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
line="2341"
line="2334"
column="64"/>
</issue>
@@ -1981,7 +2121,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
line="2341"
line="2334"
column="64"/>
</issue>
@@ -1997,7 +2137,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
line="2341"
line="2334"
column="64"/>
</issue>
@@ -2013,7 +2153,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
line="5501"
line="5512"
column="36"/>
</issue>
@@ -2029,7 +2169,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
line="245"
line="246"
column="41"/>
</issue>
@@ -2045,7 +2185,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
line="364"
line="366"
column="42"/>
</issue>
@@ -2061,7 +2201,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
line="441"
line="443"
column="44"/>
</issue>
@@ -2077,7 +2217,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
line="447"
line="449"
column="44"/>
</issue>
@@ -2093,7 +2233,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
line="448"
line="450"
column="44"/>
</issue>
@@ -2109,7 +2249,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
line="471"
line="473"
column="41"/>
</issue>

View File

@@ -0,0 +1,52 @@
<!--
Copyright 2017 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.
-->
<vector android:height="192dp" android:viewportHeight="192.0"
android:viewportWidth="192.0" android:width="192dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#546E7A" android:pathData="M37.2,173.6l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1L178.6,70c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.9,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.9 39,179.7 37.2,173.6z"/>
<path android:fillAlpha="0.2" android:fillColor="#263238"
android:pathData="M183.3,84.5l-28.5,88.2c-1.8,6.1 -7.4,10.2 -13.7,10.2H50.9c-6.3,0 -11.9,-4.2 -13.7,-10.3l-28.5,-90C8.2,81.4 8,80.1 8,78.9c-0.1,1.6 0.1,3.1 0.6,4.7l28.5,90c1.8,6.1 7.4,10.3 13.7,10.3h90.3c6.3,0 11.8,-4.1 13.7,-10.2l28.5,-88.2c0.5,-1.6 0.7,-3.2 0.6,-4.7C183.9,82 183.7,83.3 183.3,84.5z" android:strokeAlpha="0.2"/>
<path android:fillAlpha="0.2" android:fillColor="#FFFFFF"
android:pathData="M13.6,69l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c3.4,2.7 5.3,6.7 5.4,10.8c0.2,-4.5 -1.8,-8.9 -5.4,-11.8L104.8,11c-5.2,-4.1 -12.4,-4.1 -17.6,-0.1L13.5,68C9.8,70.9 7.8,75.4 8,80C8.1,75.8 10.1,71.7 13.6,69z" android:strokeAlpha="0.2"/>
<path android:fillAlpha="0.2" android:fillColor="#FFFFFF"
android:pathData="M53.1,129.9l5,-4.8l-13.9,-13.3c0,0.8 -0.1,1.5 -0.2,2.3c-0.4,22.3 17.2,40.2 39.9,41.7l0.1,-5.3C70.2,149.5 58.6,141.4 53.1,129.9z" android:strokeAlpha="0.2"/>
<path android:fillAlpha="0.2" android:fillColor="#FFFFFF"
android:pathData="M108.7,51.8l-0.1,5.3c13.6,1 25,9.2 30.4,20.7l-4.9,4.8l13.6,13.3c0.1,-0.8 0.2,-1.5 0.2,-2.3C148.3,71.2 131,53.2 108.7,51.8z" android:strokeAlpha="0.2"/>
<path android:pathData="M154.9,173.7l13.7,-41.7l-49.5,-49.6l-18.6,-7.2l-19.6,3.1L65.9,98.6L74,128l55.9,55.9h11.2C147.5,183.9 153.1,179.8 154.9,173.7z">
<aapt:attr name="android:fillColor">
<gradient android:endX="139.008" android:endY="147.6131"
android:startX="98.1033" android:startY="106.7084" android:type="linear">
<item android:color="#19263238" android:offset="0.0"/>
<item android:color="#00212121" android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path android:fillAlpha="0.1" android:fillColor="#FF000000"
android:pathData="M70.3,104.5c0,0.2 0,0.3 0,0.5c0.3,-13.9 11.6,-25.1 25.6,-25.1v-1C81.8,78.9 70.3,90.4 70.3,104.5z" android:strokeAlpha="0.1"/>
<path android:fillAlpha="0.1" android:fillColor="#FF000000"
android:pathData="M95.9,136.5c-17.5,0 -31.7,-14 -32,-31.5c0,0.2 0,0.3 0,0.5c0,17.7 14.3,32 32,32c17.7,0 32,-14.3 32,-32c0,-0.2 0,-0.3 0,-0.5C127.6,122.5 113.4,136.5 95.9,136.5z" android:strokeAlpha="0.1"/>
<path android:fillColor="#FFFFFF" android:pathData="M95.9,72.5c-17.7,0 -32,14.3 -32,32c0,17.7 14.3,32 32,32c17.7,0 32,-14.3 32,-32S113.6,72.5 95.9,72.5zM70.3,104.5c0,-14.1 11.5,-25.6 25.6,-25.6v51.2C81.8,130.1 70.3,118.6 70.3,104.5z"/>
<path android:pathData="M37.1,173.6l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.5,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.8,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.9 38.9,179.7 37.1,173.6z">
<aapt:attr name="android:fillColor">
<gradient android:centerX="21.9873"
android:centerY="23.7751"
android:gradientRadius="158.0384" android:type="radial">
<item android:color="#19FFFFFF" android:offset="0.0"/>
<item android:color="#00FFFFFF" android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
</vector>

View File

@@ -0,0 +1,56 @@
<!--
Copyright 2017 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.
-->
<vector android:height="192dp" android:viewportHeight="192.0"
android:viewportWidth="192.0" android:width="192dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00BCD4" android:pathData="M37.1,173.5l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.9,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.8 39,179.6 37.1,173.5z"/>
<path android:fillAlpha="0.2" android:fillColor="#263238"
android:pathData="M183.3,84.3l-28.5,88.2c-1.8,6.1 -7.4,10.2 -13.7,10.2H50.8c-6.3,0 -11.9,-4.2 -13.7,-10.3l-28.5,-90C8.2,81.2 8,79.9 8,78.7c-0.1,1.6 0.1,3.1 0.6,4.7l28.5,90c1.8,6.1 7.4,10.3 13.7,10.3h90.3c6.3,0 11.8,-4.1 13.7,-10.2l28.5,-88.2c0.5,-1.6 0.7,-3.2 0.6,-4.7C183.9,81.8 183.7,83.2 183.3,84.3z" android:strokeAlpha="0.2"/>
<path android:fillAlpha="0.2" android:fillColor="#FFFFFF"
android:pathData="M13.5,68.8l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c3.4,2.7 5.3,6.7 5.4,10.8c0.2,-4.5 -1.8,-8.9 -5.4,-11.8l-73.8,-58.9c-5.2,-4.1 -12.4,-4.1 -17.6,-0.1L13.5,67.8c-3.7,2.9 -5.7,7.4 -5.5,12C8.1,75.6 10.1,71.5 13.5,68.8z" android:strokeAlpha="0.2"/>
<group>
<clip-path android:pathData="M37.1,173.5l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.6,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.9,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.8 39,179.6 37.1,173.5z M 0,0"/>
<path android:pathData="M131.3,74.7L105,79.3l-5,-0.2l-3.8,2.4l-30.8,34.4L60.5,136l47.8,47.8 h32.9c6.3,0,11.8,-4.1,13.7,-10.2l18.4,-56.9L131.3,74.7z">
<aapt:attr name="android:fillColor">
<gradient android:endX="151.1709"
android:endY="160.5809" android:startX="91.7117"
android:startY="101.1217" android:type="linear">
<item android:color="#19263238" android:offset="0.0"/>
<item android:color="#00212121" android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
</group>
<path android:fillAlpha="0.1" android:fillColor="#263238"
android:pathData="M79.5,136l-18.9,0l1,1l18.9,0l35.6,-35.6l-1,-1z" android:strokeAlpha="0.1"/>
<path android:fillAlpha="0.1" android:fillColor="#263238"
android:pathData="M68.59,120.37l32.17,-32.17l0.99,0.99l-32.17,32.17z" android:strokeAlpha="0.1"/>
<path android:fillAlpha="0.1" android:fillColor="#263238"
android:pathData="M132.3,75.6l-1,-1c1.6,1.6 1.6,4.1 0,5.7l-12.4,12.4l1,1l12.4,-12.4C133.8,79.7 133.8,77.2 132.3,75.6z" android:strokeAlpha="0.1"/>
<path android:fillAlpha="0.1" android:fillColor="#263238"
android:pathData="M120.75,106.06l5.66,-5.66l0.99,0.99l-5.66,5.66z" android:strokeAlpha="0.1"/>
<path android:fillColor="#0097A7" android:pathData="M68.56,120.37l32.17,-32.17l7.64,7.64l-32.17,32.17z"/>
<path android:fillColor="#FFFFFF" android:pathData="M131.3,74.6l-9.3,-9.3c-1.6,-1.6 -4.1,-1.6 -5.6,0l-12.4,12.4l-7.7,-7.6l-5.6,5.6l5.7,5.7L60.6,117v19h19l35.6,-35.6l5.7,5.7l5.6,-5.6l-7.7,-7.7l12.4,-12.4C132.8,78.7 132.8,76.2 131.3,74.6zM76.2,128l-7.7,-7.7l32.2,-32.2l7.7,7.7L76.2,128z"/>
<path android:pathData="M37.1,173.5l-28.5,-90c-1.7,-5.8 0.3,-12 5,-15.6l73.5,-57.1c5.2,-4 12.5,-4 17.6,0.1l73.8,58.9c4.6,3.7 6.5,9.9 4.8,15.6l-28.5,88.2c-1.8,6.1 -7.4,10.2 -13.7,10.2H50.8C44.5,183.8 38.9,179.6 37.1,173.5z">
<aapt:attr name="android:fillColor">
<gradient android:centerX="21.977" android:centerY="23.6809"
android:gradientRadius="158.0384" android:type="radial">
<item android:color="#19FFFFFF" android:offset="0.0"/>
<item android:color="#00FFFFFF" android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
</vector>

View File

@@ -118,12 +118,14 @@
<Preference
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
android:key="daltonizer_preference_screen"
android:title="@string/accessibility_display_daltonizer_preference_title" />
android:title="@string/accessibility_display_daltonizer_preference_title"
android:icon="@drawable/ic_daltonizer"/>
<SwitchPreference
android:key="toggle_inversion_preference"
android:title="@string/accessibility_display_inversion_preference_title"
android:summary="@string/accessibility_display_inversion_preference_subtitle"
android:persistent="false" />
android:persistent="false"
android:icon="@drawable/ic_color_inversion"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -42,6 +42,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityManager;
import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.internal.content.PackageMonitor;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.view.RotationPolicy;
@@ -57,6 +58,7 @@ import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -172,13 +174,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
}
};
private final SettingsContentObserver mSettingsContentObserver =
new SettingsContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
updateServicePreferences();
}
};
private final SettingsContentObserver mSettingsContentObserver;
private final RotationPolicyListener mRotationPolicyListener = new RotationPolicyListener() {
@Override
@@ -224,6 +220,22 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
.getBoolean(com.android.internal.R.bool.config_setColorTransformAccelerated);
}
public AccessibilitySettings() {
// Observe changes to anything that the shortcut can toggle, so we can reflect updates
final Collection<AccessibilityShortcutController.ToggleableFrameworkFeatureInfo> features =
AccessibilityShortcutController.getFrameworkShortcutFeaturesMap().values();
final List<String> shortcutFeatureKeys = new ArrayList<>(features.size());
for (AccessibilityShortcutController.ToggleableFrameworkFeatureInfo feature : features) {
shortcutFeatureKeys.add(feature.getSettingKey());
}
mSettingsContentObserver = new SettingsContentObserver(mHandler, shortcutFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
updateAllPreferences();
}
};
}
@Override
public int getMetricsCategory() {
return MetricsEvent.ACCESSIBILITY;

View File

@@ -22,16 +22,28 @@ import android.net.Uri;
import android.os.Handler;
import android.provider.Settings;
import java.util.ArrayList;
import java.util.List;
abstract class SettingsContentObserver extends ContentObserver {
private final List<String> mKeysToObserve = new ArrayList<>(2);
public SettingsContentObserver(Handler handler) {
super(handler);
mKeysToObserve.add(Settings.Secure.ACCESSIBILITY_ENABLED);
mKeysToObserve.add(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
}
public SettingsContentObserver(Handler handler, List<String> keysToObserve) {
this(handler);
mKeysToObserve.addAll(keysToObserve);
}
public void register(ContentResolver contentResolver) {
contentResolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_ENABLED), false, this);
contentResolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES), false, this);
for (int i = 0; i < mKeysToObserve.size(); i++) {
contentResolver.registerContentObserver(
Settings.Secure.getUriFor(mKeysToObserve.get(i)), false, this);
}
}
public void unregister(ContentResolver contentResolver) {

View File

@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
import static android.content.DialogInterface.BUTTON_POSITIVE;
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
@@ -85,9 +87,16 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
Map<ComponentName, ToggleableFrameworkFeatureInfo> frameworkFeatureInfoMap =
AccessibilityShortcutController.getFrameworkShortcutFeaturesMap();
for (ComponentName componentName : frameworkFeatureInfoMap.keySet()) {
// Lookup icon
final int iconId;
if (componentName.equals(COLOR_INVERSION_COMPONENT_NAME)) {
iconId = R.drawable.ic_color_inversion;
} else if (componentName.equals(DALTONIZER_COMPONENT_NAME)) {
iconId = R.drawable.ic_daltonizer;
} else {
iconId = R.drawable.empty_icon;
}
candidates.add(new FrameworkCandidateInfo(frameworkFeatureInfoMap.get(componentName),
R.drawable.empty_icon, componentName.flattenToString()));
iconId, componentName.flattenToString()));
}
for (int i = 0; i < numInstalledServices; i++) {
final AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);