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

Commit dcf59629 authored by Jim Miller's avatar Jim Miller Committed by Android (Google) Code Review
Browse files

This restores JB MR0 behavior where the framework throws an exception for...

This restores JB MR0 behavior where the framework throws an exception for improper layouts that are missing layout_width and/or layout_height.

Revert "Revert "Revert "Fix for bug 6050753."""

This reverts commit 6868d6f3

Change-Id: I8843d92dba14c82f06d9ee59517cf11b2abbbf04
parent 6868d6f3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7094,7 +7094,7 @@ package android.content.res {
    method public int getIndexCount();
    method public int getInt(int, int);
    method public int getInteger(int, int);
    method public deprecated int getLayoutDimension(int, java.lang.String);
    method public int getLayoutDimension(int, java.lang.String);
    method public int getLayoutDimension(int, int);
    method public java.lang.String getNonResourceString(int);
    method public java.lang.String getPositionDescription();
@@ -16149,7 +16149,7 @@ package android.os {
  public class Looper {
    method public void dump(android.util.Printer, java.lang.String);
    method public static android.os.Looper getMainLooper();
    method public static synchronized android.os.Looper getMainLooper();
    method public java.lang.Thread getThread();
    method public static void loop();
    method public static android.os.Looper myLooper();
+1 −8
Original line number Diff line number Diff line
@@ -475,14 +475,7 @@ public class TypedArray {
     * 
     * @return Attribute dimension value multiplied by the appropriate 
     * metric and truncated to integer pixels.
     *
     * @throws RuntimeException
     *             if this TypedArray does not contain an entry for <code>index</code>
     *
     * @deprecated Use {@link #getLayoutDimension(int, int)} instead.
     *
     */
    @Deprecated
    public int getLayoutDimension(int index, String name) {
        index *= AssetManager.STYLE_NUM_ENTRIES;
        final int[] data = mData;
+53 −47
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.graphics.Canvas;
import android.os.Handler;
import android.os.Message;
import android.widget.FrameLayout;
import com.android.internal.R;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

@@ -811,14 +810,21 @@ public abstract class LayoutInflater {
                        // We try to load the layout params set in the <include /> tag. If
                        // they don't exist, we will rely on the layout params set in the
                        // included XML file.
                        TypedArray ta = getContext().obtainStyledAttributes(attrs,
                                                            R.styleable.ViewGroup_Layout);
                        boolean definesBothWidthAndHeight =
                                ta.hasValue(R.styleable.ViewGroup_Layout_layout_width) &&
                                ta.hasValue(R.styleable.ViewGroup_Layout_layout_height);
                        AttributeSet attributes = definesBothWidthAndHeight ? attrs : childAttrs;
                        view.setLayoutParams(group.generateLayoutParams(attributes));
                        ta.recycle();
                        // During a layoutparams generation, a runtime exception is thrown
                        // if either layout_width or layout_height is missing. We catch
                        // this exception and set localParams accordingly: true means we
                        // successfully loaded layout params from the <include /> tag,
                        // false means we need to rely on the included layout params.
                        ViewGroup.LayoutParams params = null;
                        try {
                            params = group.generateLayoutParams(attrs);
                        } catch (RuntimeException e) {
                            params = group.generateLayoutParams(childAttrs);
                        } finally {
                            if (params != null) {
                                view.setLayoutParams(params);
                            }
                        }

                        // Inflate all children.
                        rInflate(childParser, view, childAttrs, true);
+3 −7
Original line number Diff line number Diff line
@@ -5611,19 +5611,15 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        }

        /**
         * Extracts the <code>width</code> and <code>height</code> layout parameters
         * from the supplied TypedArray, <code>a</code>, and assigns them
         * to the appropriate fields. If, <code>a</code>, does not contain an
         * entry for either attribute, the value, {@link ViewGroup.LayoutParams#WRAP_CONTENT},
         * is used as a default.
         * Extracts the layout parameters from the supplied attributes.
         *
         * @param a the style attributes to extract the parameters from
         * @param widthAttr the identifier of the width attribute
         * @param heightAttr the identifier of the height attribute
         */
        protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr) {
            width = a.getLayoutDimension(widthAttr, WRAP_CONTENT);
            height = a.getLayoutDimension(heightAttr, WRAP_CONTENT);
            width = a.getLayoutDimension(widthAttr, "layout_width");
            height = a.getLayoutDimension(heightAttr, "layout_height");
        }

        /**
+0 −6
Original line number Diff line number Diff line
@@ -608,12 +608,6 @@ public class FrameLayout extends ViewGroup {
         */
        public int gravity = -1;

        @Override
        protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr) {
            width = a.getLayoutDimension(widthAttr, MATCH_PARENT);
            height = a.getLayoutDimension(heightAttr, MATCH_PARENT);
        }

        /**
         * {@inheritDoc}
         */
Loading