Loading core/java/com/android/internal/accessibility/AccessibilityShortcutController.java +36 −9 Original line number Diff line number Diff line Loading @@ -91,6 +91,10 @@ public class AccessibilityShortcutController { public static final ComponentName ACCESSIBILITY_BUTTON_COMPONENT_NAME = new ComponentName("com.android.server.accessibility", "AccessibilityButton"); // The component name for the sub setting of Hearing aids in Accessibility settings public static final ComponentName ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME = new ComponentName("com.android.server.accessibility", "HearingAids"); public static final ComponentName COLOR_INVERSION_TILE_COMPONENT_NAME = new ComponentName("com.android.server.accessibility", "ColorInversionTile"); public static final ComponentName DALTONIZER_TILE_COMPONENT_NAME = Loading @@ -104,7 +108,7 @@ public class AccessibilityShortcutController { .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY) .build(); private static Map<ComponentName, ToggleableFrameworkFeatureInfo> sFrameworkShortcutFeaturesMap; private static Map<ComponentName, FrameworkFeatureInfo> sFrameworkShortcutFeaturesMap; private final Context mContext; private final Handler mHandler; Loading Loading @@ -133,10 +137,10 @@ public class AccessibilityShortcutController { * @return An immutable map from placeholder component names to feature * info for toggling a framework feature */ public static Map<ComponentName, ToggleableFrameworkFeatureInfo> public static Map<ComponentName, FrameworkFeatureInfo> getFrameworkShortcutFeaturesMap() { if (sFrameworkShortcutFeaturesMap == null) { Map<ComponentName, ToggleableFrameworkFeatureInfo> featuresMap = new ArrayMap<>(4); Map<ComponentName, FrameworkFeatureInfo> featuresMap = new ArrayMap<>(4); featuresMap.put(COLOR_INVERSION_COMPONENT_NAME, new ToggleableFrameworkFeatureInfo( Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, Loading @@ -157,6 +161,8 @@ public class AccessibilityShortcutController { Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, "1" /* Value to enable */, "0" /* Value to disable */, R.string.reduce_bright_colors_feature_name)); featuresMap.put(ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME, new LaunchableFrameworkFeatureInfo(R.string.hearing_aids_feature_name)); sFrameworkShortcutFeaturesMap = Collections.unmodifiableMap(featuresMap); } return sFrameworkShortcutFeaturesMap; Loading Loading @@ -391,7 +397,7 @@ public class AccessibilityShortcutController { if (targetComponentName == null) { return null; } final ToggleableFrameworkFeatureInfo frameworkFeatureInfo = final FrameworkFeatureInfo frameworkFeatureInfo = getFrameworkShortcutFeaturesMap().get(targetComponentName); if (frameworkFeatureInfo != null) { return frameworkFeatureInfo.getLabel(mContext); Loading Loading @@ -670,15 +676,13 @@ public class AccessibilityShortcutController { /** * Immutable class to hold info about framework features that can be controlled by shortcut */ public static class ToggleableFrameworkFeatureInfo { public abstract static class FrameworkFeatureInfo { private final String mSettingKey; private final String mSettingOnValue; private final String mSettingOffValue; private final int mLabelStringResourceId; // These go to the settings wrapper private int mIconDrawableId; ToggleableFrameworkFeatureInfo(String settingKey, String settingOnValue, FrameworkFeatureInfo(String settingKey, String settingOnValue, String settingOffValue, int labelStringResourceId) { mSettingKey = settingKey; mSettingOnValue = settingOnValue; Loading Loading @@ -711,6 +715,29 @@ public class AccessibilityShortcutController { return context.getString(mLabelStringResourceId); } } /** * Immutable class to hold framework features that have on/off state settings key and can be * controlled by shortcut. */ public static class ToggleableFrameworkFeatureInfo extends FrameworkFeatureInfo { ToggleableFrameworkFeatureInfo(String settingKey, String settingOnValue, String settingOffValue, int labelStringResourceId) { super(settingKey, settingOnValue, settingOffValue, labelStringResourceId); } } /** * Immutable class to hold framework features that don't have settings key and can be controlled * by shortcut. */ public static class LaunchableFrameworkFeatureInfo extends FrameworkFeatureInfo { LaunchableFrameworkFeatureInfo(int labelStringResourceId) { super(/* settingKey= */ null, /* settingOnValue= */ null, /* settingOffValue= */ null, labelStringResourceId); } } // Class to allow mocking of static framework calls public static class FrameworkObjectProvider { Loading core/java/com/android/internal/accessibility/dialog/AccessibilityTargetHelper.java +11 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.accessibility.dialog; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON; import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; Loading Loading @@ -250,11 +251,21 @@ public final class AccessibilityTargetHelper { context.getDrawable(R.drawable.ic_accessibility_reduce_bright_colors), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED); final InvisibleToggleAllowListingFeatureTarget hearingAids = new InvisibleToggleAllowListingFeatureTarget(context, shortcutType, isShortcutContained(context, shortcutType, ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME.flattenToString()), ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME.flattenToString(), context.getString(R.string.hearing_aids_feature_name), context.getDrawable(R.drawable.ic_accessibility_hearing_aid), /* key= */ null); targets.add(magnification); targets.add(daltonizer); targets.add(colorInversion); targets.add(oneHandedMode); targets.add(reduceBrightColors); targets.add(hearingAids); return targets; } Loading core/res/res/drawable/ic_accessibility_hearing_aid.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2022 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. --> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/accessibility_feature_background" /> <foreground> <inset android:drawable="@drawable/ic_accessibility_hearing_aid_foreground" android:inset="@dimen/accessibility_icon_foreground_padding_ratio" /> </foreground> </adaptive-icon> core/res/res/drawable/ic_accessibility_hearing_aid_foreground.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2022 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 xmlns:android="http://schemas.android.com/apk/res/android" android:width="18dp" android:height="18dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="#ffffff" android:pathData="M17,20c-0.29,0 -0.56,-0.06 -0.76,-0.15 -0.71,-0.37 -1.21,-0.88 -1.71,-2.38 -0.51,-1.56 -1.47,-2.29 -2.39,-3 -0.79,-0.61 -1.61,-1.24 -2.32,-2.53C9.29,10.98 9,9.93 9,9c0,-2.8 2.2,-5 5,-5s5,2.2 5,5h2c0,-3.93 -3.07,-7 -7,-7S7,5.07 7,9c0,1.26 0.38,2.65 1.07,3.9 0.91,1.65 1.98,2.48 2.85,3.15 0.81,0.62 1.39,1.07 1.71,2.05 0.6,1.82 1.37,2.84 2.73,3.55 0.51,0.23 1.07,0.35 1.64,0.35 2.21,0 4,-1.79 4,-4h-2c0,1.1 -0.9,2 -2,2zM7.64,2.64L6.22,1.22C4.23,3.21 3,5.96 3,9s1.23,5.79 3.22,7.78l1.41,-1.41C6.01,13.74 5,11.49 5,9s1.01,-4.74 2.64,-6.36zM11.5,9c0,1.38 1.12,2.5 2.5,2.5s2.5,-1.12 2.5,-2.5 -1.12,-2.5 -2.5,-2.5 -2.5,1.12 -2.5,2.5z"/> </vector> No newline at end of file core/res/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -4715,6 +4715,9 @@ <!-- Title of Reduce Brightness feature, shown in the warning dialog about the accessibility shortcut. [CHAR LIMIT=none] --> <string name="reduce_bright_colors_feature_name">Extra dim</string> <!-- Title of hearing aids feature, shown in the warning dialog about the accessibility shortcut. [CHAR LIMIT=none] --> <string name="hearing_aids_feature_name">Hearing devices</string> <!-- Text in toast to alert the user that the accessibility shortcut turned on an accessibility service. [CHAR LIMIT=none] --> <string name="accessibility_shortcut_enabling_service">Held volume keys. <xliff:g id="service_name" example="TalkBack">%1$s</xliff:g> turned on.</string> Loading Loading
core/java/com/android/internal/accessibility/AccessibilityShortcutController.java +36 −9 Original line number Diff line number Diff line Loading @@ -91,6 +91,10 @@ public class AccessibilityShortcutController { public static final ComponentName ACCESSIBILITY_BUTTON_COMPONENT_NAME = new ComponentName("com.android.server.accessibility", "AccessibilityButton"); // The component name for the sub setting of Hearing aids in Accessibility settings public static final ComponentName ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME = new ComponentName("com.android.server.accessibility", "HearingAids"); public static final ComponentName COLOR_INVERSION_TILE_COMPONENT_NAME = new ComponentName("com.android.server.accessibility", "ColorInversionTile"); public static final ComponentName DALTONIZER_TILE_COMPONENT_NAME = Loading @@ -104,7 +108,7 @@ public class AccessibilityShortcutController { .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY) .build(); private static Map<ComponentName, ToggleableFrameworkFeatureInfo> sFrameworkShortcutFeaturesMap; private static Map<ComponentName, FrameworkFeatureInfo> sFrameworkShortcutFeaturesMap; private final Context mContext; private final Handler mHandler; Loading Loading @@ -133,10 +137,10 @@ public class AccessibilityShortcutController { * @return An immutable map from placeholder component names to feature * info for toggling a framework feature */ public static Map<ComponentName, ToggleableFrameworkFeatureInfo> public static Map<ComponentName, FrameworkFeatureInfo> getFrameworkShortcutFeaturesMap() { if (sFrameworkShortcutFeaturesMap == null) { Map<ComponentName, ToggleableFrameworkFeatureInfo> featuresMap = new ArrayMap<>(4); Map<ComponentName, FrameworkFeatureInfo> featuresMap = new ArrayMap<>(4); featuresMap.put(COLOR_INVERSION_COMPONENT_NAME, new ToggleableFrameworkFeatureInfo( Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, Loading @@ -157,6 +161,8 @@ public class AccessibilityShortcutController { Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, "1" /* Value to enable */, "0" /* Value to disable */, R.string.reduce_bright_colors_feature_name)); featuresMap.put(ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME, new LaunchableFrameworkFeatureInfo(R.string.hearing_aids_feature_name)); sFrameworkShortcutFeaturesMap = Collections.unmodifiableMap(featuresMap); } return sFrameworkShortcutFeaturesMap; Loading Loading @@ -391,7 +397,7 @@ public class AccessibilityShortcutController { if (targetComponentName == null) { return null; } final ToggleableFrameworkFeatureInfo frameworkFeatureInfo = final FrameworkFeatureInfo frameworkFeatureInfo = getFrameworkShortcutFeaturesMap().get(targetComponentName); if (frameworkFeatureInfo != null) { return frameworkFeatureInfo.getLabel(mContext); Loading Loading @@ -670,15 +676,13 @@ public class AccessibilityShortcutController { /** * Immutable class to hold info about framework features that can be controlled by shortcut */ public static class ToggleableFrameworkFeatureInfo { public abstract static class FrameworkFeatureInfo { private final String mSettingKey; private final String mSettingOnValue; private final String mSettingOffValue; private final int mLabelStringResourceId; // These go to the settings wrapper private int mIconDrawableId; ToggleableFrameworkFeatureInfo(String settingKey, String settingOnValue, FrameworkFeatureInfo(String settingKey, String settingOnValue, String settingOffValue, int labelStringResourceId) { mSettingKey = settingKey; mSettingOnValue = settingOnValue; Loading Loading @@ -711,6 +715,29 @@ public class AccessibilityShortcutController { return context.getString(mLabelStringResourceId); } } /** * Immutable class to hold framework features that have on/off state settings key and can be * controlled by shortcut. */ public static class ToggleableFrameworkFeatureInfo extends FrameworkFeatureInfo { ToggleableFrameworkFeatureInfo(String settingKey, String settingOnValue, String settingOffValue, int labelStringResourceId) { super(settingKey, settingOnValue, settingOffValue, labelStringResourceId); } } /** * Immutable class to hold framework features that don't have settings key and can be controlled * by shortcut. */ public static class LaunchableFrameworkFeatureInfo extends FrameworkFeatureInfo { LaunchableFrameworkFeatureInfo(int labelStringResourceId) { super(/* settingKey= */ null, /* settingOnValue= */ null, /* settingOffValue= */ null, labelStringResourceId); } } // Class to allow mocking of static framework calls public static class FrameworkObjectProvider { Loading
core/java/com/android/internal/accessibility/dialog/AccessibilityTargetHelper.java +11 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.accessibility.dialog; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON; import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; Loading Loading @@ -250,11 +251,21 @@ public final class AccessibilityTargetHelper { context.getDrawable(R.drawable.ic_accessibility_reduce_bright_colors), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED); final InvisibleToggleAllowListingFeatureTarget hearingAids = new InvisibleToggleAllowListingFeatureTarget(context, shortcutType, isShortcutContained(context, shortcutType, ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME.flattenToString()), ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME.flattenToString(), context.getString(R.string.hearing_aids_feature_name), context.getDrawable(R.drawable.ic_accessibility_hearing_aid), /* key= */ null); targets.add(magnification); targets.add(daltonizer); targets.add(colorInversion); targets.add(oneHandedMode); targets.add(reduceBrightColors); targets.add(hearingAids); return targets; } Loading
core/res/res/drawable/ic_accessibility_hearing_aid.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2022 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. --> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/accessibility_feature_background" /> <foreground> <inset android:drawable="@drawable/ic_accessibility_hearing_aid_foreground" android:inset="@dimen/accessibility_icon_foreground_padding_ratio" /> </foreground> </adaptive-icon>
core/res/res/drawable/ic_accessibility_hearing_aid_foreground.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2022 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 xmlns:android="http://schemas.android.com/apk/res/android" android:width="18dp" android:height="18dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="#ffffff" android:pathData="M17,20c-0.29,0 -0.56,-0.06 -0.76,-0.15 -0.71,-0.37 -1.21,-0.88 -1.71,-2.38 -0.51,-1.56 -1.47,-2.29 -2.39,-3 -0.79,-0.61 -1.61,-1.24 -2.32,-2.53C9.29,10.98 9,9.93 9,9c0,-2.8 2.2,-5 5,-5s5,2.2 5,5h2c0,-3.93 -3.07,-7 -7,-7S7,5.07 7,9c0,1.26 0.38,2.65 1.07,3.9 0.91,1.65 1.98,2.48 2.85,3.15 0.81,0.62 1.39,1.07 1.71,2.05 0.6,1.82 1.37,2.84 2.73,3.55 0.51,0.23 1.07,0.35 1.64,0.35 2.21,0 4,-1.79 4,-4h-2c0,1.1 -0.9,2 -2,2zM7.64,2.64L6.22,1.22C4.23,3.21 3,5.96 3,9s1.23,5.79 3.22,7.78l1.41,-1.41C6.01,13.74 5,11.49 5,9s1.01,-4.74 2.64,-6.36zM11.5,9c0,1.38 1.12,2.5 2.5,2.5s2.5,-1.12 2.5,-2.5 -1.12,-2.5 -2.5,-2.5 -2.5,1.12 -2.5,2.5z"/> </vector> No newline at end of file
core/res/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -4715,6 +4715,9 @@ <!-- Title of Reduce Brightness feature, shown in the warning dialog about the accessibility shortcut. [CHAR LIMIT=none] --> <string name="reduce_bright_colors_feature_name">Extra dim</string> <!-- Title of hearing aids feature, shown in the warning dialog about the accessibility shortcut. [CHAR LIMIT=none] --> <string name="hearing_aids_feature_name">Hearing devices</string> <!-- Text in toast to alert the user that the accessibility shortcut turned on an accessibility service. [CHAR LIMIT=none] --> <string name="accessibility_shortcut_enabling_service">Held volume keys. <xliff:g id="service_name" example="TalkBack">%1$s</xliff:g> turned on.</string> Loading