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

Commit 1722613b authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Fix default gravity value for FrameLayout.LayoutParams" into nyc-dev

parents 228137fa bd53c989
Loading
Loading
Loading
Loading
+32 −61
Original line number Diff line number Diff line
@@ -16,17 +16,15 @@

package android.widget;

import java.util.ArrayList;
import com.android.internal.R;

import android.annotation.AttrRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -36,8 +34,7 @@ import android.view.ViewGroup;
import android.view.ViewHierarchyEncoder;
import android.widget.RemoteViews.RemoteView;

import com.android.internal.R;

import java.util.ArrayList;

/**
 * FrameLayout is designed to block out an area on the screen to display
@@ -75,31 +72,29 @@ public class FrameLayout extends ViewGroup {
    @ViewDebug.ExportedProperty(category = "padding")
    private int mForegroundPaddingBottom = 0;

    private final Rect mSelfBounds = new Rect();
    private final Rect mOverlayBounds = new Rect();
    
    private final ArrayList<View> mMatchParentChildren = new ArrayList<View>(1);
    private final ArrayList<View> mMatchParentChildren = new ArrayList<>(1);

    public FrameLayout(Context context) {
    public FrameLayout(@NonNull Context context) {
        super(context);
    }

    public FrameLayout(Context context, @Nullable AttributeSet attrs) {
    public FrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FrameLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    public FrameLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public FrameLayout(
            Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    public FrameLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedArray a = context.obtainStyledAttributes(
                attrs, com.android.internal.R.styleable.FrameLayout, defStyleAttr, defStyleRes);
                attrs, R.styleable.FrameLayout, defStyleAttr, defStyleRes);

        if (a.getBoolean(com.android.internal.R.styleable.FrameLayout_measureAllChildren, false)) {
        if (a.getBoolean(R.styleable.FrameLayout_measureAllChildren, false)) {
            setMeasureAllChildren(true);
        }

@@ -171,10 +166,6 @@ public class FrameLayout extends ViewGroup {
            mPaddingBottom + mForegroundPaddingBottom;
    }


    /**
     * {@inheritDoc}
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int count = getChildCount();
@@ -265,16 +256,12 @@ public class FrameLayout extends ViewGroup {
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        layoutChildren(left, top, right, bottom, false /* no force left gravity */);
    }

    void layoutChildren(int left, int top, int right, int bottom,
                                  boolean forceLeftGravity) {
    void layoutChildren(int left, int top, int right, int bottom, boolean forceLeftGravity) {
        final int count = getChildCount();

        final int parentLeft = getPaddingLeftWithForeground();
@@ -378,9 +365,6 @@ public class FrameLayout extends ViewGroup {
        return mMeasureAllChildren;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new FrameLayout.LayoutParams(getContext(), attrs);
@@ -391,9 +375,6 @@ public class FrameLayout extends ViewGroup {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof LayoutParams;
@@ -438,27 +419,23 @@ public class FrameLayout extends ViewGroup {
        /**
         * The gravity to apply with the View to which these layout parameters
         * are associated.
         * <p>
         * The default value is {@code Gravity.TOP | Gravity.START}
         *
         * @see android.view.Gravity
         * 
         * @attr ref android.R.styleable#FrameLayout_Layout_layout_gravity
         */
        public int gravity = -1;
        public int gravity = DEFAULT_CHILD_GRAVITY;

        /**
         * {@inheritDoc}
         */
        public LayoutParams(Context c, AttributeSet attrs) {
        public LayoutParams(@NonNull Context c, @Nullable AttributeSet attrs) {
            super(c, attrs);

            TypedArray a = c.obtainStyledAttributes(attrs, com.android.internal.R.styleable.FrameLayout_Layout);
            gravity = a.getInt(com.android.internal.R.styleable.FrameLayout_Layout_layout_gravity, -1);
            final TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.FrameLayout_Layout);
            gravity = a.getInt(R.styleable.FrameLayout_Layout_layout_gravity,
                    DEFAULT_CHILD_GRAVITY);
            a.recycle();
        }

        /**
         * {@inheritDoc}
         */
        public LayoutParams(int width, int height) {
            super(width, height);
        }
@@ -480,17 +457,11 @@ public class FrameLayout extends ViewGroup {
            this.gravity = gravity;
        }

        /**
         * {@inheritDoc}
         */
        public LayoutParams(ViewGroup.LayoutParams source) {
        public LayoutParams(@NonNull ViewGroup.LayoutParams source) {
            super(source);
        }

        /**
         * {@inheritDoc}
         */
        public LayoutParams(ViewGroup.MarginLayoutParams source) {
        public LayoutParams(@NonNull ViewGroup.MarginLayoutParams source) {
            super(source);
        }

@@ -500,7 +471,7 @@ public class FrameLayout extends ViewGroup {
         *
         * @param source The layout params to copy from.
         */
        public LayoutParams(LayoutParams source) {
        public LayoutParams(@NonNull LayoutParams source) {
            super(source);

            this.gravity = source.gravity;