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

Commit 9295ada0 authored by Romain Guy's avatar Romain Guy
Browse files

Allow the use of styles with LinearLayout, make "useLargestChild" attr public.

Change-Id: I044f3f5bd9b90c684ded7a37ff85e3aa8d15af96
parent 7e28c010
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -6785,6 +6785,17 @@
 visibility="public"
>
</field>
<field name="measureWithLargestChild"
 type="int"
 transient="false"
 volatile="false"
 value="16843541"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="menuCategory"
 type="int"
 transient="false"
@@ -212019,6 +212030,20 @@
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
</constructor>
<constructor name="LinearLayout"
 type="android.widget.LinearLayout"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyle" type="int">
</parameter>
</constructor>
<method name="getBaselineAlignedChildIndex"
 return="int"
 abstract="false"
@@ -212063,6 +212088,17 @@
 visibility="public"
>
</method>
<method name="isMeasureWithLargestChildEnabled"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onLayout"
 return="void"
 abstract="false"
@@ -212136,6 +212172,19 @@
<parameter name="horizontalGravity" type="int">
</parameter>
</method>
<method name="setMeasureWithLargestChildEnabled"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="enabled" type="boolean">
</parameter>
</method>
<method name="setOrientation"
 return="void"
 abstract="false"
+8 −8
Original line number Diff line number Diff line
@@ -379,7 +379,7 @@ public abstract class LayoutInflater {
                                + "ViewGroup root and attachToRoot=true");
                    }

                    rInflate(parser, root, attrs);
                    rInflate(parser, root, attrs, false);
                } else {
                    // Temp is the root view that was found in the xml
                    View temp = createViewFromTag(name, attrs);
@@ -404,7 +404,7 @@ public abstract class LayoutInflater {
                        System.out.println("-----> start inflating children");
                    }
                    // Inflate all children under temp
                    rInflate(parser, temp, attrs);
                    rInflate(parser, temp, attrs, true);
                    if (DEBUG) {
                        System.out.println("-----> done inflating children");
                    }
@@ -590,8 +590,8 @@ public abstract class LayoutInflater {
     * Recursive method used to descend down the xml hierarchy and instantiate
     * views, instantiate their children, and then call onFinishInflate().
     */
    private void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs)
            throws XmlPullParserException, IOException {
    private void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
            boolean finishInflate) throws XmlPullParserException, IOException {

        final int depth = parser.getDepth();
        int type;
@@ -618,12 +618,12 @@ public abstract class LayoutInflater {
                final View view = createViewFromTag(name, attrs);
                final ViewGroup viewGroup = (ViewGroup) parent;
                final ViewGroup.LayoutParams params = viewGroup.generateLayoutParams(attrs);
                rInflate(parser, view, attrs);
                rInflate(parser, view, attrs, true);
                viewGroup.addView(view, params);
            }
        }

        parent.onFinishInflate();
        if (finishInflate) parent.onFinishInflate();
    }

    private void parseRequestFocus(XmlPullParser parser, View parent)
@@ -674,7 +674,7 @@ public abstract class LayoutInflater {

                    if (TAG_MERGE.equals(childName)) {
                        // Inflate all children.
                        rInflate(childParser, parent, childAttrs);
                        rInflate(childParser, parent, childAttrs, false);
                    } else {
                        final View view = createViewFromTag(childName, childAttrs);
                        final ViewGroup group = (ViewGroup) parent;
@@ -699,7 +699,7 @@ public abstract class LayoutInflater {
                        }

                        // Inflate all children.
                        rInflate(childParser, view, childAttrs);
                        rInflate(childParser, view, childAttrs, true);

                        // Attempt to override the included layout's android:id with the
                        // one set on the <include /> tag itself.
+40 −3
Original line number Diff line number Diff line
@@ -40,6 +40,13 @@ import android.widget.RemoteViews.RemoteView;
 * <p>
 * Also see {@link LinearLayout.LayoutParams android.widget.LinearLayout.LayoutParams}
 * for layout attributes </p>
 *
 * @attr ref android.R.styleable#LinearLayout_baselineAligned
 * @attr ref android.R.styleable#LinearLayout_baselineAlignedChildIndex
 * @attr ref android.R.styleable#LinearLayout_gravity
 * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild
 * @attr ref android.R.styleable#LinearLayout_orientation
 * @attr ref android.R.styleable#LinearLayout_weightSum
 */
@RemoteView
public class LinearLayout extends ViewGroup {
@@ -112,7 +119,11 @@ public class LinearLayout extends ViewGroup {
    }

    public LinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        this(context, attrs, 0);
    }
    
    public LinearLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        TypedArray a = 
            context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.LinearLayout);
@@ -137,8 +148,7 @@ public class LinearLayout extends ViewGroup {
        mBaselineAlignedChildIndex =
                a.getInt(com.android.internal.R.styleable.LinearLayout_baselineAlignedChildIndex, -1);

        // TODO: Better name, add Java APIs, make it public
        mUseLargestChild = a.getBoolean(R.styleable.LinearLayout_useLargestChild, false);
        mUseLargestChild = a.getBoolean(R.styleable.LinearLayout_measureWithLargestChild, false);

        a.recycle();
    }
@@ -167,6 +177,33 @@ public class LinearLayout extends ViewGroup {
        mBaselineAligned = baselineAligned;
    }

    /**
     * When true, all children with a weight will be considered having
     * the minimum size of the largest child. If false, all children are
     * measured normally.
     * 
     * @return True to measure children with a weight using the minimum
     *         size of the largest child, false otherwise.
     */
    public boolean isMeasureWithLargestChildEnabled() {
        return mUseLargestChild;
    }

    /**
     * When set to true, all children with a weight will be considered having
     * the minimum size of the largest child. If false, all children are
     * measured normally.
     * 
     * Disabled by default.
     * 
     * @param enabled True to measure children with a weight using the
     *        minimum size of the largest child, false otherwise.
     */
    @android.view.RemotableViewMethod
    public void setMeasureWithLargestChildEnabled(boolean enabled) {
        mUseLargestChild = enabled;
    }

    @Override
    public int getBaseline() {
        if (mBaselineAlignedChildIndex < 0) {
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@
            android:paddingTop="4dip"
            android:paddingLeft="2dip"
            android:paddingRight="2dip"
            android:useLargestChild="true">
            android:measureWithLargestChild="true">
            <LinearLayout android:id="@+id/leftSpacer"
                android:layout_weight="0.25"
                android:layout_width="0dip"
+1 −1
Original line number Diff line number Diff line
@@ -1728,7 +1728,7 @@
        <!-- When set to true, all children with a weight will be considered having
             the minimum size of the largest child. If false, all children are
             measured normally. -->
        <attr name="useLargestChild" format="boolean" />
        <attr name="measureWithLargestChild" format="boolean" />
    </declare-styleable>
    <declare-styleable name="ListView">
        <!-- Reference to an array resource that will populate the ListView.  For static content,
Loading