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

Commit 908309fe authored by Aurimas Liutikas's avatar Aurimas Liutikas Committed by Android (Google) Code Review
Browse files

Merge "Clean up attribute apis based on api council feedback."

parents 65f7350b f9dbd5fe
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -12377,7 +12377,7 @@ package android.content.res {
    method public String getPositionDescription();
    method @AnyRes public int getResourceId(@StyleableRes int, int);
    method public android.content.res.Resources getResources();
    method @StyleRes public int getSourceResourceId(@StyleableRes int, @StyleRes int);
    method @AnyRes public int getSourceResourceId(@StyleableRes int, @AnyRes int);
    method @Nullable public String getString(@StyleableRes int);
    method public CharSequence getText(@StyleableRes int);
    method public CharSequence[] getTextArray(@StyleableRes int);
@@ -50334,7 +50334,7 @@ package android.view {
    method @android.view.ViewDebug.ExportedProperty(category="drawing") public float getAlpha();
    method public android.view.animation.Animation getAnimation();
    method public android.os.IBinder getApplicationWindowToken();
    method @NonNull public java.util.List<java.lang.Integer> getAttributeResolutionStack(@AttrRes int);
    method @NonNull public int[] getAttributeResolutionStack(@AttrRes int);
    method @NonNull public java.util.Map<java.lang.Integer,java.lang.Integer> getAttributeSourceResourceMap();
    method @android.view.ViewDebug.ExportedProperty @Nullable public String[] getAutofillHints();
    method public final android.view.autofill.AutofillId getAutofillId();
+5 −6
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.content.res;
import android.annotation.AnyRes;
import android.annotation.ColorInt;
import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.annotation.StyleableRes;
import android.annotation.UnsupportedAppUsage;
import android.content.pm.ActivityInfo;
@@ -72,7 +71,7 @@ public class TypedArray {
    static final int STYLE_RESOURCE_ID = 3;
    static final int STYLE_CHANGING_CONFIGURATIONS = 4;
    static final int STYLE_DENSITY = 5;
    static final int SYTLE_SOURCE_RESOURCE_ID = 6;
    static final int STYLE_SOURCE_RESOURCE_ID = 6;

    @UnsupportedAppUsage
    private final Resources mResources;
@@ -1134,14 +1133,14 @@ public class TypedArray {
     * resolved in a style or layout.
     * @throws RuntimeException if the TypedArray has already been recycled.
     */
    @StyleRes
    public int getSourceResourceId(@StyleableRes int index, @StyleRes int defaultValue) {
    @AnyRes
    public int getSourceResourceId(@StyleableRes int index, @AnyRes int defaultValue) {
        if (mRecycled) {
            throw new RuntimeException("Cannot make calls to a recycled instance!");
        }

        index *= STYLE_NUM_ENTRIES;
        final int resid = mData[index + SYTLE_SOURCE_RESOURCE_ID];
        final int resid = mData[index + STYLE_SOURCE_RESOURCE_ID];
        if (resid != 0) {
            return resid;
        }
@@ -1360,7 +1359,7 @@ public class TypedArray {
                data[index + STYLE_CHANGING_CONFIGURATIONS]);
        outValue.density = data[index + STYLE_DENSITY];
        outValue.string = (type == TypedValue.TYPE_STRING) ? loadStringValueAt(index) : null;
        outValue.sourceResourceId = data[index + SYTLE_SOURCE_RESOURCE_ID];
        outValue.sourceResourceId = data[index + STYLE_SOURCE_RESOURCE_ID];
        return true;
    }

+20 −10
Original line number Diff line number Diff line
@@ -5974,20 +5974,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * this {@link View}.
     */
    @NonNull
    public List<Integer> getAttributeResolutionStack(@AttrRes int attribute) {
        ArrayList<Integer> stack = new ArrayList<>();
        if (!sDebugViewAttributes || mAttributeResolutionStacks == null) {
            return stack;
    public int[] getAttributeResolutionStack(@AttrRes int attribute) {
        if (!sDebugViewAttributes
                || mAttributeResolutionStacks == null
                || mAttributeResolutionStacks.get(attribute) == null) {
            return new int[0];
        }
        int[] attributeResolutionStack = mAttributeResolutionStacks.get(attribute);
        int stackSize = attributeResolutionStack.length;
        if (mSourceLayoutId != ID_NULL) {
            stack.add(mSourceLayoutId);
            stackSize++;
        }
        int[] attributeResolutionStack = mAttributeResolutionStacks.get(attribute);
        if (attributeResolutionStack == null) {
            return stack;
        int currentIndex = 0;
        int[] stack = new int[stackSize];
        if (mSourceLayoutId != ID_NULL) {
            stack[currentIndex] = mSourceLayoutId;
            currentIndex++;
        }
        for (int i = 0; i < attributeResolutionStack.length; i++) {
            stack.add(attributeResolutionStack[i]);
            stack[currentIndex] = attributeResolutionStack[i];
            currentIndex++;
        }
        return stack;
    }
@@ -6138,7 +6146,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * Stores debugging information about attributes. This should be called in a constructor by
     * every custom {@link View} that uses a custom styleable.
     * every custom {@link View} that uses a custom styleable. If the custom view does not call it,
     * then the custom attributes used by this view will not be visible in layout inspection tools.
     *
     *  @param context Context under which this view is created.
     * @param styleable A reference to styleable array R.styleable.Foo
     * @param attrs AttributeSet used to construct this view.
+1 −1
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr,
    out_values[STYLE_RESOURCE_ID] = resid;
    out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags;
    out_values[STYLE_DENSITY] = config.density;
    out_values[SYTLE_SOURCE_RESOURCE_ID] = value_source_resid;
    out_values[STYLE_SOURCE_RESOURCE_ID] = value_source_resid;

    if (value.dataType != Res_value::TYPE_NULL || value.data == Res_value::DATA_NULL_EMPTY) {
      indices_idx++;
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ enum {
  STYLE_RESOURCE_ID = 3,
  STYLE_CHANGING_CONFIGURATIONS = 4,
  STYLE_DENSITY = 5,
  SYTLE_SOURCE_RESOURCE_ID = 6
  STYLE_SOURCE_RESOURCE_ID = 6
};

// These are all variations of the same method. They each perform the exact same operation,