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

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

Merge "Add View#getSourceLayoutResId()."

parents 68f93a1f aae06631
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50361,6 +50361,7 @@ package android.view {
    method public final int getScrollX();
    method public final int getScrollY();
    method @android.view.ViewDebug.ExportedProperty(category="drawing") @ColorInt public int getSolidColor();
    method @LayoutRes public int getSourceLayoutResId();
    method public android.animation.StateListAnimator getStateListAnimator();
    method protected int getSuggestedMinimumHeight();
    method protected int getSuggestedMinimumWidth();
+11 −0
Original line number Diff line number Diff line
@@ -1394,6 +1394,17 @@ public class Resources {
        mResourcesImpl.getValue(name, outValue, resolveRefs);
    }


    /**
     * @param set AttributeSet for which we want to find the source.
     * @return The resource id for the source that is backing the given AttributeSet
     * @hide
     */
    @AnyRes
    public static int getAttributeSetSourceResId(@Nullable AttributeSet set) {
        return ResourcesImpl.getAttributeSetSourceResId(set);
    }

    /**
     * This class holds the current attribute values for a particular theme.
     * In other words, a Theme is a set of values for resource attributes;
+12 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package android.content.res;

import static android.content.res.Resources.ID_NULL;

import android.animation.Animator;
import android.animation.StateListAnimator;
import android.annotation.AnyRes;
@@ -1222,7 +1224,7 @@ public class ResourcesImpl {
                    for (int i = 0; i < num; i++) {
                        if (cachedXmlBlockCookies[i] == assetCookie && cachedXmlBlockFiles[i] != null
                                && cachedXmlBlockFiles[i].equals(file)) {
                            return cachedXmlBlocks[i].newParser();
                            return cachedXmlBlocks[i].newParser(id);
                        }
                    }

@@ -1239,7 +1241,7 @@ public class ResourcesImpl {
                        cachedXmlBlockCookies[pos] = assetCookie;
                        cachedXmlBlockFiles[pos] = file;
                        cachedXmlBlocks[pos] = block;
                        return block.newParser();
                        return block.newParser(id);
                    }
                }
            } catch (Exception e) {
@@ -1299,6 +1301,14 @@ public class ResourcesImpl {
        }
    }

    @AnyRes
    static int getAttributeSetSourceResId(@Nullable AttributeSet set) {
        if (set == null) {
            return ID_NULL;
        }
        return ((XmlBlock.Parser) set).getSourceResId();
    }

    LongSparseArray<Drawable.ConstantState> getPreloadedDrawables() {
        return sPreloadedDrawables[0];
    }
+16 −2
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.content.res;

import static android.content.res.Resources.ID_NULL;

import android.annotation.AnyRes;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.util.TypedValue;
@@ -73,19 +76,29 @@ final class XmlBlock implements AutoCloseable {

    @UnsupportedAppUsage
    public XmlResourceParser newParser() {
        return newParser(ID_NULL);
    }

    public XmlResourceParser newParser(@AnyRes int resId) {
        synchronized (this) {
            if (mNative != 0) {
                return new Parser(nativeCreateParseState(mNative), this);
                return new Parser(nativeCreateParseState(mNative), this, resId);
            }
            return null;
        }
    }

    /*package*/ final class Parser implements XmlResourceParser {
        Parser(long parseState, XmlBlock block) {
        Parser(long parseState, XmlBlock block, @AnyRes int sourceResId) {
            mParseState = parseState;
            mBlock = block;
            block.mOpenCount++;
            mSourceResId = sourceResId;
        }

        @AnyRes
        public int getSourceResId() {
            return mSourceResId;
        }

        public void setFeature(String name, boolean state) throws XmlPullParserException {
@@ -473,6 +486,7 @@ final class XmlBlock implements AutoCloseable {
        private boolean mDecNextDepth = false;
        private int mDepth = 0;
        private int mEventType = START_DOCUMENT;
        private @AnyRes int mSourceResId;
    }

    protected void finalize() throws Throwable {
+18 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.view;
import static android.content.res.Resources.ID_NULL;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED;
@@ -5052,6 +5053,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    @Nullable
    private WeakReference<ContentCaptureSession> mContentCaptureSession;
    @LayoutRes
    private int mSourceLayoutId = ID_NULL;
    /**
     * Simple constructor to use when creating a view from code.
     *
@@ -5217,6 +5221,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    public View(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        this(context);
        mSourceLayoutId = Resources.getAttributeSetSourceResId(attrs);
        final TypedArray a = context.obtainStyledAttributes(
                attrs, com.android.internal.R.styleable.View, defStyleAttr, defStyleRes);
@@ -23252,6 +23258,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    /**
     * A {@link View} can be inflated from an XML layout. For such Views this method returns the
     * resource ID of the source layout.
     *
     * @return The layout resource id if this view was inflated from XML, otherwise
     * {@link Resources#ID_NULL}.
     */
    @LayoutRes
    public int getSourceLayoutResId() {
        return mSourceLayoutId;
    }
    /**
     * Returns the top padding of this view.
     *