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

Commit 61fdf405 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add vector-specific fill color A11Y settings to PointerIcon." into main

parents 7f5a3ef9 6585b1d6
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -6146,6 +6146,15 @@ public final class Settings {
         */
        public static final String TOUCHPAD_RIGHT_CLICK_ZONE = "touchpad_right_click_zone";
        /**
         * Pointer fill style, specified by
         * {@link android.view.PointerIcon.PointerIconVectorStyleFill} constants.
         *
         * @hide
         */
        @Readable
        public static final String POINTER_FILL_STYLE = "pointer_fill_style";
        /**
         * Whether lock-to-app will be triggered by long-press on recents.
         * @hide
@@ -6348,6 +6357,7 @@ public final class Settings {
            PRIVATE_SETTINGS.add(SIP_ADDRESS_ONLY);
            PRIVATE_SETTINGS.add(SIP_ASK_ME_EACH_TIME);
            PRIVATE_SETTINGS.add(POINTER_SPEED);
            PRIVATE_SETTINGS.add(POINTER_FILL_STYLE);
            PRIVATE_SETTINGS.add(LOCK_TO_APP_ENABLED);
            PRIVATE_SETTINGS.add(EGG_MODE);
            PRIVATE_SETTINGS.add(SHOW_BATTERY_PERCENT);
+65 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.view;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
@@ -43,8 +44,13 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.flags.Flags;

import androidx.annotation.VisibleForTesting;

import com.android.internal.util.XmlUtils;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Represents an icon that can be used as a mouse pointer.
 * <p>
@@ -164,6 +170,29 @@ public final class PointerIcon implements Parcelable {
    // every time we need to resolve the icon (i.e. on each input event).
    private static final SparseArray<PointerIcon> SYSTEM_ICONS = new SparseArray<>();

    /** @hide */
    @IntDef(prefix = {"POINTER_ICON_VECTOR_STYLE_FILL_"}, value = {
            POINTER_ICON_VECTOR_STYLE_FILL_BLACK,
            POINTER_ICON_VECTOR_STYLE_FILL_GREEN,
            POINTER_ICON_VECTOR_STYLE_FILL_YELLOW,
            POINTER_ICON_VECTOR_STYLE_FILL_PINK,
            POINTER_ICON_VECTOR_STYLE_FILL_BLUE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface PointerIconVectorStyleFill {}

    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_BLACK = 0;
    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_GREEN = 1;
    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_YELLOW = 2;
    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_PINK = 3;
    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_BLUE = 4;

    // If adding a PointerIconVectorStyleFill, update END value for {@link SystemSettingsValidators}
    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_BEGIN =
            POINTER_ICON_VECTOR_STYLE_FILL_BLACK;
    /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_END =
            POINTER_ICON_VECTOR_STYLE_FILL_BLUE;

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private final int mType;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@@ -261,7 +290,7 @@ public final class PointerIcon implements Parcelable {
        }

        final PointerIcon icon = new PointerIcon(type);
        icon.loadResource(context.getResources(), resourceId);
        icon.loadResource(context.getResources(), resourceId, context.getTheme());
        return icon;
    }

@@ -324,7 +353,7 @@ public final class PointerIcon implements Parcelable {
        }

        PointerIcon icon = new PointerIcon(TYPE_CUSTOM);
        icon.loadResource(resources, resourceId);
        icon.loadResource(resources, resourceId, null);
        return icon;
    }

@@ -443,7 +472,8 @@ public final class PointerIcon implements Parcelable {
        return new BitmapDrawable(resources, bitmap);
    }

    private void loadResource(@NonNull Resources resources, @XmlRes int resourceId) {
    private void loadResource(@NonNull Resources resources, @XmlRes int resourceId,
            @Nullable Resources.Theme theme) {
        final XmlResourceParser parser = resources.getXml(resourceId);
        final int bitmapRes;
        final float hotSpotX;
@@ -467,7 +497,7 @@ public final class PointerIcon implements Parcelable {
            throw new IllegalArgumentException("<pointer-icon> is missing bitmap attribute.");
        }

        Drawable drawable = resources.getDrawable(bitmapRes);
        Drawable drawable = resources.getDrawable(bitmapRes, theme);
        if (drawable instanceof AnimationDrawable) {
            // Extract animation frame bitmaps.
            final AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
@@ -648,6 +678,27 @@ public final class PointerIcon implements Parcelable {
        }
    }

    /**
     * Convert fill style constant to resource ID.
     *
     * @hide
     */
    public static int vectorFillStyleToResource(@PointerIconVectorStyleFill int fillStyle) {
        return switch (fillStyle) {
            case POINTER_ICON_VECTOR_STYLE_FILL_BLACK ->
                    com.android.internal.R.style.PointerIconVectorStyleFillBlack;
            case POINTER_ICON_VECTOR_STYLE_FILL_GREEN ->
                    com.android.internal.R.style.PointerIconVectorStyleFillGreen;
            case POINTER_ICON_VECTOR_STYLE_FILL_YELLOW ->
                    com.android.internal.R.style.PointerIconVectorStyleFillYellow;
            case POINTER_ICON_VECTOR_STYLE_FILL_PINK ->
                    com.android.internal.R.style.PointerIconVectorStyleFillPink;
            case POINTER_ICON_VECTOR_STYLE_FILL_BLUE ->
                    com.android.internal.R.style.PointerIconVectorStyleFillBlue;
            default -> com.android.internal.R.style.PointerIconVectorStyleFillBlack;
        };
    }

    /**
     * Sets whether drop shadow will draw in the native code.
     *
@@ -658,4 +709,14 @@ public final class PointerIcon implements Parcelable {
    public void setDrawNativeDropShadow(boolean drawNativeDropShadow) {
        mDrawNativeDropShadow = drawNativeDropShadow;
    }

    /**
     * Gets the PointerIcon's bitmap.
     *
     * @hide
     */
    @VisibleForTesting
    public Bitmap getBitmap() {
        return mBitmap;
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,14 @@ flag {
    is_fixed_read_only: true
}

flag {
    name: "enable_vector_cursor_a11y_settings"
    namespace: "systemui"
    description: "Feature flag to enable accessibility settings for vector cursors."
    bug: "302275042"
    is_fixed_read_only: true
}

flag {
  name: "sensitive_content_app_protection_api"
  is_exported: true
+7 −1
Original line number Diff line number Diff line
@@ -122,6 +122,12 @@ message SystemSettingsProto {
    }
    optional Notification notification = 17;

    message Pointer {
        option (android.msg_privacy).dest = DEST_EXPLICIT;

        optional SettingProto pointer_fill_style = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
    }
    optional Pointer pointer = 37;
    optional SettingProto pointer_speed = 18 [ (android.privacy).dest = DEST_AUTOMATIC ];

    message Ringtone {
@@ -268,5 +274,5 @@ message SystemSettingsProto {

    // Please insert fields in alphabetical order and group them into messages
    // if possible (to avoid reaching the method limit).
    // Next tag = 37;
    // Next tag = 38;
}
+6 −0
Original line number Diff line number Diff line
@@ -9702,6 +9702,12 @@
        <attr name="hotSpotY" format="dimension" />
    </declare-styleable>
    <!-- @hide -->
    <declare-styleable name="PointerIconVectorTheme">
        <attr name="pointerIconVectorFill" format="color" />
        <attr name="pointerIconVectorFillInverse" format="color" />
    </declare-styleable>
    <declare-styleable name="Storage">
        <!-- path to mount point for the storage. -->
        <attr name="mountPoint" format="string" />
Loading