2/ Implement Shortcut for One Handed mode feature
- Define ONE_HANDED_COMPONENT_NAME - Define one handed mode string - Add one handed mode temp drawable - Add ToggleAllowListingFeatureTarget for OHM - Add ONE_HANDED_COMPONEMENT_NAME to featuresMap Test: manual enable shortcut of one handed mode Bug: 182425480 Change-Id: I5993cd8dbd3925efeebb9b75bb10d423c9a02601
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
core/res/res/drawable/ic_accessibility_one_handed.xml
Normal file
25
core/res/res/drawable/ic_accessibility_one_handed.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -3409,9 +3409,12 @@
|
||||
<java-symbol type="drawable" name="ic_accessibility_color_correction" />
|
||||
<java-symbol type="drawable" name="ic_accessibility_magnification" />
|
||||
<java-symbol type="drawable" name="ic_accessibility_reduce_bright_colors" />
|
||||
<java-symbol type="drawable" name="ic_accessibility_one_handed" />
|
||||
|
||||
<java-symbol type="string" name="reduce_bright_colors_feature_name" />
|
||||
|
||||
<java-symbol type="string" name="one_handed_mode_feature_name" />
|
||||
|
||||
<!-- com.android.internal.widget.RecyclerView -->
|
||||
<java-symbol type="id" name="item_touch_helper_previous_elevation"/>
|
||||
<java-symbol type="dimen" name="item_touch_helper_max_drag_scroll_per_frame"/>
|
||||
|
||||
Reference in New Issue
Block a user