Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9448611 authored by Bill Lin's avatar Bill Lin Committed by Android (Google) Code Review
Browse files

Merge changes from topic "ohm-shortcut" into sc-dev

* changes:
  3/ Listen ONE_HANDED_MODE_ACTIVATED for A11y shortcut action
  2/ Implement Shortcut for One Handed mode feature
parents 720add59 eb9b719b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ public class AccessibilityShortcutController {
            "com.android.server.accessibility.MagnificationController";
    public static final ComponentName MAGNIFICATION_COMPONENT_NAME =
            new ComponentName("com.android.server.accessibility", "Magnification");
    public static final ComponentName ONE_HANDED_COMPONENT_NAME =
            new ComponentName("com.android.server.accessibility", "OneHandedMode");
    public static final ComponentName REDUCE_BRIGHT_COLORS_COMPONENT_NAME =
            new ComponentName("com.android.server.accessibility", "ReduceBrightColors");

@@ -117,7 +119,7 @@ public class AccessibilityShortcutController {
    public static Map<ComponentName, ToggleableFrameworkFeatureInfo>
        getFrameworkShortcutFeaturesMap() {
        if (sFrameworkShortcutFeaturesMap == null) {
            Map<ComponentName, ToggleableFrameworkFeatureInfo> featuresMap = new ArrayMap<>(2);
            Map<ComponentName, ToggleableFrameworkFeatureInfo> featuresMap = new ArrayMap<>(4);
            featuresMap.put(COLOR_INVERSION_COMPONENT_NAME,
                    new ToggleableFrameworkFeatureInfo(
                            Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
@@ -128,6 +130,11 @@ public class AccessibilityShortcutController {
                            Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
                            "1" /* Value to enable */, "0" /* Value to disable */,
                            R.string.color_correction_feature_name));
            featuresMap.put(ONE_HANDED_COMPONENT_NAME,
                    new ToggleableFrameworkFeatureInfo(
                            Settings.Secure.ONE_HANDED_MODE_ACTIVATED,
                            "1" /* Value to enable */, "0" /* Value to disable */,
                            R.string.one_handed_mode_feature_name));
            featuresMap.put(REDUCE_BRIGHT_COLORS_COMPONENT_NAME,
                    new ToggleableFrameworkFeatureInfo(
                            Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
+12 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTT
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;
import static com.android.internal.accessibility.AccessibilityShortcutController.ONE_HANDED_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_COMPONENT_NAME;
import static com.android.internal.accessibility.util.AccessibilityUtils.getAccessibilityServiceFragmentType;
import static com.android.internal.accessibility.util.ShortcutUtils.isShortcutContained;
@@ -230,6 +231,16 @@ public final class AccessibilityTargetHelper {
                        context.getDrawable(R.drawable.ic_accessibility_color_inversion),
                        Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);

        final ToggleAllowListingFeatureTarget oneHandedMode =
                new ToggleAllowListingFeatureTarget(context,
                        shortcutType,
                        isShortcutContained(context, shortcutType,
                                ONE_HANDED_COMPONENT_NAME.flattenToString()),
                        ONE_HANDED_COMPONENT_NAME.flattenToString(),
                        context.getString(R.string.one_handed_mode_feature_name),
                        context.getDrawable(R.drawable.ic_accessibility_one_handed),
                        Settings.Secure.ONE_HANDED_MODE_ACTIVATED);

        final ToggleAllowListingFeatureTarget reduceBrightColors =
                new ToggleAllowListingFeatureTarget(context,
                        shortcutType,
@@ -243,6 +254,7 @@ public final class AccessibilityTargetHelper {
        targets.add(magnification);
        targets.add(daltonizer);
        targets.add(colorInversion);
        targets.add(oneHandedMode);
        targets.add(reduceBrightColors);

        return targets;
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
   Copyright (C) 2021 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_one_handed_foreground"
        android:inset="@dimen/accessibility_icon_foreground_padding_ratio" />
</foreground>
</adaptive-icon>
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
   Copyright (C) 2021 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="@android:color/white"
          android:pathData="M4.64169 3C3.88567 3 3.27271 3.61296 3.27271 4.36898V18.4011C3.27271 19.154 3.88875 19.7701 4.64169 19.7701H12.5339C12.5339 19.7701 12.5425 18.0588 11.2324 18.0588H6.01067C5.44597 18.0588 4.98393 17.5968 4.98393 17.0321V5.73797C4.98393 5.17326 5.44597 4.71123 6.01067 4.71123H15.9358C16.5005 4.71123 16.9625 5.17326 16.9625 5.73797V9.84492C16.9625 10.9651 16.4899 12.5952 15.5936 13.2674L9.77538 9.16043C8.58505 10.425 8.88177 11.705 10.1176 12.9251L13.1978 16.0053C13.1978 16.0053 13.3231 17.4572 13.5401 18.0588C14.2034 19.8984 16.2781 20.7968 16.2781 20.7968H19.231H19.2967C20.0835 20.7968 20.7273 20.153 20.7273 19.3662V12.2543L18.9441 4.06781C18.7662 3.23718 18.4068 3 17.8729 3H4.64169Z"/>
</vector>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -4636,6 +4636,9 @@
     shown in the warning dialog about the accessibility shortcut. -->
    <string name="color_correction_feature_name">Color Correction</string>

    <!-- Title of One Handed Mode feature, shown in the system gestures of the accessibility shortcut. [CHAR LIMIT=none] -->
    <string name="one_handed_mode_feature_name">One-Handed mode</string>

    <!-- 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>

Loading