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

Commit e31a55b3 authored by Sally Yuen's avatar Sally Yuen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "a11y_rbc"

* changes:
  Add Reduce Bright Colors page to settings_enum.proto
  Use inclusive language
  Add infrastructure for supporting Reduce Bright Colors as an A11y shortcut
parents 377af5a7 75db7c4b
Loading
Loading
Loading
Loading
+7 −0
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 REDUCE_BRIGHT_COLORS_COMPONENT_NAME =
            new ComponentName("com.android.server.accessibility", "ReduceBrightColors");

    private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
@@ -126,6 +128,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(REDUCE_BRIGHT_COLORS_COMPONENT_NAME,
                    new ToggleableFrameworkFeatureInfo(
                            Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
                            "1" /* Value to enable */, "0" /* Value to disable */,
                            R.string.reduce_bright_colors_feature_name));
            sFrameworkShortcutFeaturesMap = Collections.unmodifiableMap(featuresMap);
        }
        return sFrameworkShortcutFeaturesMap;
+21 −8
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.REDUCE_BRIGHT_COLORS_COMPONENT_NAME;
import static com.android.internal.accessibility.util.AccessibilityUtils.getAccessibilityServiceFragmentType;
import static com.android.internal.accessibility.util.ShortcutUtils.isShortcutContained;

@@ -112,7 +113,7 @@ public final class AccessibilityTargetHelper {
            @ShortcutType int shortcutType) {
        final List<AccessibilityTarget> targets = new ArrayList<>();
        targets.addAll(getAccessibilityFilteredTargets(context, shortcutType));
        targets.addAll(getWhiteListingFeatureTargets(context, shortcutType));
        targets.addAll(getAllowListingFeatureTargets(context, shortcutType));

        return targets;
    }
@@ -196,12 +197,12 @@ public final class AccessibilityTargetHelper {
        return targets;
    }

    private static List<AccessibilityTarget> getWhiteListingFeatureTargets(Context context,
    private static List<AccessibilityTarget> getAllowListingFeatureTargets(Context context,
            @ShortcutType int shortcutType) {
        final List<AccessibilityTarget> targets = new ArrayList<>();

        final InvisibleToggleWhiteListingFeatureTarget magnification =
                new InvisibleToggleWhiteListingFeatureTarget(context,
        final InvisibleToggleAllowListingFeatureTarget magnification =
                new InvisibleToggleAllowListingFeatureTarget(context,
                shortcutType,
                isShortcutContained(context, shortcutType, MAGNIFICATION_CONTROLLER_NAME),
                MAGNIFICATION_CONTROLLER_NAME,
@@ -209,8 +210,8 @@ public final class AccessibilityTargetHelper {
                context.getDrawable(R.drawable.ic_accessibility_magnification),
                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);

        final ToggleWhiteListingFeatureTarget daltonizer =
                new ToggleWhiteListingFeatureTarget(context,
        final ToggleAllowListingFeatureTarget daltonizer =
                new ToggleAllowListingFeatureTarget(context,
                shortcutType,
                isShortcutContained(context, shortcutType,
                        DALTONIZER_COMPONENT_NAME.flattenToString()),
@@ -219,8 +220,8 @@ public final class AccessibilityTargetHelper {
                context.getDrawable(R.drawable.ic_accessibility_color_correction),
                Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED);

        final ToggleWhiteListingFeatureTarget colorInversion =
                new ToggleWhiteListingFeatureTarget(context,
        final ToggleAllowListingFeatureTarget colorInversion =
                new ToggleAllowListingFeatureTarget(context,
                shortcutType,
                isShortcutContained(context, shortcutType,
                        COLOR_INVERSION_COMPONENT_NAME.flattenToString()),
@@ -229,9 +230,21 @@ public final class AccessibilityTargetHelper {
                context.getDrawable(R.drawable.ic_accessibility_color_inversion),
                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);

        // TODO: Update with shortcut icon
        final ToggleAllowListingFeatureTarget reduceBrightColors =
                new ToggleAllowListingFeatureTarget(context,
                        shortcutType,
                        isShortcutContained(context, shortcutType,
                                REDUCE_BRIGHT_COLORS_COMPONENT_NAME.flattenToString()),
                        REDUCE_BRIGHT_COLORS_COMPONENT_NAME.flattenToString(),
                        context.getString(R.string.reduce_bright_colors_feature_name),
                        null,
                        Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED);

        targets.add(magnification);
        targets.add(daltonizer);
        targets.add(colorInversion);
        targets.add(reduceBrightColors);

        return targets;
    }
+2 −2
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ import com.android.internal.accessibility.common.ShortcutConstants.Accessibility
 * Extension for {@link AccessibilityTarget} with {@link AccessibilityFragmentType#INVISIBLE_TOGGLE}
 * type.
 */
class InvisibleToggleWhiteListingFeatureTarget extends AccessibilityTarget {
class InvisibleToggleAllowListingFeatureTarget extends AccessibilityTarget {

    InvisibleToggleWhiteListingFeatureTarget(Context context, @ShortcutType int shortcutType,
    InvisibleToggleAllowListingFeatureTarget(Context context, @ShortcutType int shortcutType,
            boolean isShortcutSwitched, String id, CharSequence label, Drawable icon, String key) {
        super(context, shortcutType, AccessibilityFragmentType.INVISIBLE_TOGGLE,
                isShortcutSwitched, id, label, icon, key);
+2 −2
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@ import com.android.internal.accessibility.dialog.TargetAdapter.ViewHolder;
 * Extension for {@link AccessibilityTarget} with {@link AccessibilityFragmentType#TOGGLE}
 * type.
 */
class ToggleWhiteListingFeatureTarget extends AccessibilityTarget {
class ToggleAllowListingFeatureTarget extends AccessibilityTarget {

    ToggleWhiteListingFeatureTarget(Context context, @ShortcutType int shortcutType,
    ToggleAllowListingFeatureTarget(Context context, @ShortcutType int shortcutType,
            boolean isShortcutSwitched, String id, CharSequence label, Drawable icon, String key) {
        super(context, shortcutType, AccessibilityFragmentType.TOGGLE,
                isShortcutSwitched, id, label, icon, key);
+5 −0
Original line number Diff line number Diff line
@@ -2756,4 +2756,9 @@ enum PageId {
    // CATEGORY: SETTINGS
    // OS: S
    SCREEN_TIMEOUT = 1852;

    // OPEN: Settings > Accessibility > Reduce Bright Colors
    // CATEGORY: SETTINGS
    // OS: S
    REDUCE_BRIGHT_COLORS_SETTINGS = 1853;
}
Loading