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

Commit 7e547fbe authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Replace AutoFillType by view constants."

parents 932eb90e 8931e303
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -6562,8 +6562,9 @@ package android.app.assist {
    method public int getAutoFillHint();
    method public android.view.autofill.AutoFillId getAutoFillId();
    method public java.lang.String[] getAutoFillOptions();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public deprecated android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public int getAutofillType();
    method public android.app.assist.AssistStructure.ViewNode getChildAt(int);
    method public int getChildCount();
    method public java.lang.String getClassName();
@@ -45052,8 +45053,9 @@ package android.view {
    method public android.os.IBinder getApplicationWindowToken();
    method public int getAutoFillHint();
    method public int getAutoFillMode();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public final deprecated android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public int getAutofillType();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -45511,6 +45513,11 @@ package android.view {
    field public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0; // 0x0
    field public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 1; // 0x1
    field public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
    field public static final int AUTOFILL_TYPE_DATE = 4; // 0x4
    field public static final int AUTOFILL_TYPE_LIST = 3; // 0x3
    field public static final int AUTOFILL_TYPE_NONE = 0; // 0x0
    field public static final int AUTOFILL_TYPE_TEXT = 1; // 0x1
    field public static final int AUTOFILL_TYPE_TOGGLE = 2; // 0x2
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 512; // 0x200
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 4096; // 0x1000
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 1024; // 0x400
@@ -46180,8 +46187,9 @@ package android.view {
    method public abstract void setAlpha(float);
    method public abstract void setAutoFillHint(int);
    method public abstract void setAutoFillOptions(java.lang.String[]);
    method public abstract void setAutoFillType(android.view.autofill.AutoFillType);
    method public abstract deprecated void setAutoFillType(android.view.autofill.AutoFillType);
    method public abstract void setAutoFillValue(android.view.autofill.AutoFillValue);
    method public abstract void setAutofillType(int);
    method public abstract void setCheckable(boolean);
    method public abstract void setChecked(boolean);
    method public abstract void setChildCount(int);
+11 −3
Original line number Diff line number Diff line
@@ -6811,8 +6811,9 @@ package android.app.assist {
    method public int getAutoFillHint();
    method public android.view.autofill.AutoFillId getAutoFillId();
    method public java.lang.String[] getAutoFillOptions();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public deprecated android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public int getAutofillType();
    method public android.app.assist.AssistStructure.ViewNode getChildAt(int);
    method public int getChildCount();
    method public java.lang.String getClassName();
@@ -48512,8 +48513,9 @@ package android.view {
    method public android.os.IBinder getApplicationWindowToken();
    method public int getAutoFillHint();
    method public int getAutoFillMode();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public final deprecated android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public int getAutofillType();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -48971,6 +48973,11 @@ package android.view {
    field public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0; // 0x0
    field public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 1; // 0x1
    field public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
    field public static final int AUTOFILL_TYPE_DATE = 4; // 0x4
    field public static final int AUTOFILL_TYPE_LIST = 3; // 0x3
    field public static final int AUTOFILL_TYPE_NONE = 0; // 0x0
    field public static final int AUTOFILL_TYPE_TEXT = 1; // 0x1
    field public static final int AUTOFILL_TYPE_TOGGLE = 2; // 0x2
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 512; // 0x200
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 4096; // 0x1000
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 1024; // 0x400
@@ -49640,8 +49647,9 @@ package android.view {
    method public abstract void setAlpha(float);
    method public abstract void setAutoFillHint(int);
    method public abstract void setAutoFillOptions(java.lang.String[]);
    method public abstract void setAutoFillType(android.view.autofill.AutoFillType);
    method public abstract deprecated void setAutoFillType(android.view.autofill.AutoFillType);
    method public abstract void setAutoFillValue(android.view.autofill.AutoFillValue);
    method public abstract void setAutofillType(int);
    method public abstract void setCheckable(boolean);
    method public abstract void setChecked(boolean);
    method public abstract void setChildCount(int);
+11 −3
Original line number Diff line number Diff line
@@ -6589,8 +6589,9 @@ package android.app.assist {
    method public int getAutoFillHint();
    method public android.view.autofill.AutoFillId getAutoFillId();
    method public java.lang.String[] getAutoFillOptions();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public deprecated android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public int getAutofillType();
    method public android.app.assist.AssistStructure.ViewNode getChildAt(int);
    method public int getChildCount();
    method public java.lang.String getClassName();
@@ -45412,8 +45413,9 @@ package android.view {
    method public android.os.IBinder getApplicationWindowToken();
    method public int getAutoFillHint();
    method public int getAutoFillMode();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public final deprecated android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public int getAutofillType();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -45874,6 +45876,11 @@ package android.view {
    field public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0; // 0x0
    field public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 1; // 0x1
    field public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
    field public static final int AUTOFILL_TYPE_DATE = 4; // 0x4
    field public static final int AUTOFILL_TYPE_LIST = 3; // 0x3
    field public static final int AUTOFILL_TYPE_NONE = 0; // 0x0
    field public static final int AUTOFILL_TYPE_TEXT = 1; // 0x1
    field public static final int AUTOFILL_TYPE_TOGGLE = 2; // 0x2
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_DATE = 512; // 0x200
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_DAY = 4096; // 0x1000
    field public static final int AUTO_FILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = 1024; // 0x400
@@ -46547,8 +46554,9 @@ package android.view {
    method public abstract void setAlpha(float);
    method public abstract void setAutoFillHint(int);
    method public abstract void setAutoFillOptions(java.lang.String[]);
    method public abstract void setAutoFillType(android.view.autofill.AutoFillType);
    method public abstract deprecated void setAutoFillType(android.view.autofill.AutoFillType);
    method public abstract void setAutoFillValue(android.view.autofill.AutoFillValue);
    method public abstract void setAutofillType(int);
    method public abstract void setCheckable(boolean);
    method public abstract void setChecked(boolean);
    method public abstract void setChildCount(int);
+41 −8
Original line number Diff line number Diff line
@@ -538,7 +538,7 @@ public class AssistStructure implements Parcelable {
        // TODO(b/33197203): once we have more flags, it might be better to store the individual
        // fields (viewId and childId) of the field.
        AutoFillId mAutoFillId;
        AutoFillType mAutoFillType;
        @View.AutofillType int mAutofillType;
        @View.AutoFillHint int mAutoFillHint;
        AutoFillValue mAutoFillValue;
        String[] mAutoFillOptions;
@@ -623,7 +623,7 @@ public class AssistStructure implements Parcelable {
            if ((flags&FLAGS_HAS_AUTO_FILL_DATA) != 0) {
                mSanitized = in.readInt() == 1;
                mAutoFillId = in.readParcelable(null);
                mAutoFillType = in.readParcelable(null);
                mAutofillType = in.readInt();
                mAutoFillHint = in.readInt();
                mAutoFillValue = in.readParcelable(null);
                mAutoFillOptions = in.readStringArray();
@@ -757,7 +757,7 @@ public class AssistStructure implements Parcelable {
                writeSensitive = mSanitized || !sanitizeOnWrite;
                out.writeInt(mSanitized ? 1 : 0);
                out.writeParcelable(mAutoFillId, 0);
                out.writeParcelable(mAutoFillType,  0);
                out.writeInt(mAutofillType);
                out.writeInt(mAutoFillHint);
                final AutoFillValue sanitizedValue = writeSensitive ? mAutoFillValue : null;
                out.writeParcelable(sanitizedValue,  0);
@@ -850,15 +850,33 @@ public class AssistStructure implements Parcelable {
            return mAutoFillId;
        }

        /**
         * @deprecated TODO(b/35956626): remove once clients use getAutoFilltype()
         */
        @Deprecated
        public AutoFillType getAutoFillType() {
            switch (getAutofillType()) {
                case View.AUTOFILL_TYPE_TEXT:
                    return AutoFillType.forText();
                case View.AUTOFILL_TYPE_TOGGLE:
                    return AutoFillType.forToggle();
                case View.AUTOFILL_TYPE_LIST:
                    return AutoFillType.forList();
                case View.AUTOFILL_TYPE_DATE:
                    return AutoFillType.forDate();
                default:
                    return null;
            }
        }

        /**
         * Gets the the type of value that can be used to auto-fill the view contents.
         *
         * <p>It's only set when the {@link AssistStructure} is used for auto-filling purposes, not
         * for assist.
         */
        // TODO(b/33197203, b/33802548): add CTS/unit test
        public AutoFillType getAutoFillType() {
            return mAutoFillType;
        public @View.AutofillType int getAutofillType() {
            return mAutofillType;
        }

        /**
@@ -1562,7 +1580,22 @@ public class AssistStructure implements Parcelable {

        @Override
        public void setAutoFillType(AutoFillType type) {
           mNode.mAutoFillType = type;
            if (type == null) return;

            if (type.isText()) {
                mNode.mAutofillType = View.AUTOFILL_TYPE_TEXT;
            } else if (type.isToggle()) {
                mNode.mAutofillType = View.AUTOFILL_TYPE_TOGGLE;
            } else if (type.isList()) {
                mNode.mAutofillType = View.AUTOFILL_TYPE_LIST;
            } else if (type.isDate()) {
                mNode.mAutofillType = View.AUTOFILL_TYPE_DATE;
            }
        }

        @Override
        public void setAutofillType(@View.AutofillType int type) {
            mNode.mAutofillType = type;
        }

        @Override
@@ -1711,7 +1744,7 @@ public class AssistStructure implements Parcelable {
            Log.i(TAG, prefix + " NO AUTO-FILL ID");
        } else {
            Log.i(TAG, prefix + "AutoFill info: id= " + autoFillId
                    + ", type=" + node.getAutoFillType()
                    + ", type=" + node.getAutofillType()
                    + ", options=" + Arrays.toString(node.getAutoFillOptions())
                    + ", inputType=" + node.getInputType()
                    + ", hint=" + Integer.toHexString(node.getAutoFillHint())
+88 −10
Original line number Diff line number Diff line
@@ -1115,6 +1115,65 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    @AutoFillHint private int mAutoFillHint;
    /** @hide */
    @IntDef({
            AUTOFILL_TYPE_NONE,
            AUTOFILL_TYPE_TEXT,
            AUTOFILL_TYPE_TOGGLE,
            AUTOFILL_TYPE_LIST,
            AUTOFILL_TYPE_DATE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AutofillType {}
    /**
     * Autofill type for views that cannot be autofilled.
     */
    public static final int AUTOFILL_TYPE_NONE = 0;
    /**
     * Autofill type for a text field, which is filled by a {@link CharSequence}.
     *
     * <p>{@link AutoFillValue} instances for autofilling a {@link View} can be obtained through
     * {@link AutoFillValue#forText(CharSequence)}, and the value passed to auto-fill a
     * {@link View} can be fetched through {@link AutoFillValue#getTextValue()}.
     */
    public static final int AUTOFILL_TYPE_TEXT = 1;
    /**
     * Autofill type for a togglable field, which is filled by a {@code boolean}.
     *
     * <p>{@link AutoFillValue} instances for auto-filling a {@link View} can be obtained through
     * {@link AutoFillValue#forToggle(boolean)}, and the value passed to auto-fill a
     * {@link View} can be fetched through {@link AutoFillValue#getToggleValue()}.
     */
    public static final int AUTOFILL_TYPE_TOGGLE = 2;
    /**
     * Autofill type for a selection list field, which is filled by an {@code int}
     * representing the element index inside the list (starting at {@code 0}).
     *
     * <p>{@link AutoFillValue} instances for autofilling a {@link View} can be obtained through
     * {@link AutoFillValue#forList(int)}, and the value passed to auto-fill a
     * {@link View} can be fetched through {@link AutoFillValue#getListValue()}.
     *
     * <p>The available options in the selection list are typically provided by
     * {@link android.app.assist.AssistStructure.ViewNode#getAutoFillOptions()}.
     */
    public static final int AUTOFILL_TYPE_LIST = 3;
    /**
     * Autofill type for a field that contains a date, which is represented by a long representing
     * the number of milliseconds since the standard base time known as "the epoch", namely
     * January 1, 1970, 00:00:00 GMT (see {@link java.util.Date#getTime()}.
     *
     * <p>{@link AutoFillValue} instances for autofilling a {@link View} can be obtained through
     * {@link AutoFillValue#forDate(long)}, and the values passed to
     * auto-fill a {@link View} can be fetched through {@link AutoFillValue#getDateValue()}.
     */
    public static final int AUTOFILL_TYPE_DATE = 4;
    /**
     * This view is enabled. Interpretation varies by subclass.
     * Use with ENABLED_MASK when calling setFlags.
@@ -7178,14 +7237,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        if (forAutoFill) {
            final AutoFillType autoFillType = getAutoFillType();
            final @AutofillType int autofillType = getAutofillType();
            // Don't need to fill auto-fill info if view does not support it.
            // For example, only TextViews that are editable support auto-fill
            if (autoFillType != null) {
            if (autofillType != AUTOFILL_TYPE_NONE) {
                // The auto-fill id needs to be unique, but its value doesn't matter, so it's better
                // to reuse the accessibility id to save space.
                structure.setAutoFillId(getAccessibilityViewId());
                structure.setAutoFillType(autoFillType);
                structure.setAutofillType(autofillType);
                structure.setAutoFillHint(getAutoFillHint());
                structure.setAutoFillValue(getAutoFillValue());
            }
@@ -7291,7 +7350,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * Automatically fills the content of this view with the {@code value}.
     *
     * <p>By default does nothing, but views should override it (and {@link #getAutoFillType()},
     * <p>By default does nothing, but views should override it (and {@link #getAutofillType()},
     * {@link #getAutoFillValue()}, and {@link #onProvideAutoFillStructure(ViewStructure, int)}
     * to support the AutoFill Framework.
     *
@@ -7329,16 +7388,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            @SuppressWarnings("unused") AutoFillValue value) {
    }
    /**
     * @deprecated TODO(b/35956626): remove once clients use getAutoFilltype
     */
    @Deprecated
    @Nullable
    public final AutoFillType getAutoFillType() {
        switch (getAutofillType()) {
            case AUTOFILL_TYPE_TEXT:
                return AutoFillType.forText();
            case AUTOFILL_TYPE_TOGGLE:
                return AutoFillType.forToggle();
            case AUTOFILL_TYPE_LIST:
                return AutoFillType.forList();
            case AUTOFILL_TYPE_DATE:
                return AutoFillType.forDate();
            default:
                return null;
        }
    }
    /**
     * Describes the auto-fill type that should be used on calls to
     * {@link #autoFill(AutoFillValue)} and {@link #autoFillVirtual(int, AutoFillValue)}.
     *
     * <p>By default returns {@code null}, but views should override it (and
     * <p>By default returns {@link #AUTOFILL_TYPE_NONE}, but views should override it (and
     * {@link #autoFill(AutoFillValue)} to support the AutoFill Framework.
     */
    @Nullable
    public AutoFillType getAutoFillType() {
        return null;
    public @AutofillType int getAutofillType() {
        return AUTOFILL_TYPE_NONE;
    }
    /**
@@ -7357,7 +7435,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Gets the {@link View}'s current auto-fill value.
     *
     * <p>By default returns {@code null}, but views should override it (and
     * {@link #autoFill(AutoFillValue)}, and {@link #getAutoFillType()} to support the AutoFill
     * {@link #autoFill(AutoFillValue)}, and {@link #getAutofillType()} to support the AutoFill
     * Framework.
     */
    @Nullable
@@ -7371,7 +7449,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    private boolean isAutoFillable() {
        return getAutoFillType() != null && !isAutoFillBlocked();
        return getAutofillType() != AUTOFILL_TYPE_NONE && !isAutoFillBlocked();
    }
    private void populateVirtualStructure(ViewStructure structure,
Loading