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

Commit 93cd6a6c authored by Philip Milne's avatar Philip Milne
Browse files

Rationalize API after adding maximum size feature.

. Change name of Group to Spec
	(with the addition of the fglexibility field, this class no longer represents a group)

. Replace overloaded Group/Spec constructors with factory method

. Bugfix for measure() when alignmentMode == ALIGN_BOUNDS

. Bury as much Java API as possible, to minimize restrictions on future API enhancements

	- make all field access in Group package private
	- use factory methods in place of field assignment

Change-Id: I46a5027a013bf7c3110b77108b8fd0427165cd18
parent 64bd196f
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -25253,6 +25253,10 @@ package android.widget {
    method public void setRowCount(int);
    method public void setRowOrderPreserved(boolean);
    method public void setUseDefaultMargins(boolean);
    method public static android.widget.GridLayout.Spec spec(int, int, android.widget.GridLayout.Alignment, int);
    method public static android.widget.GridLayout.Spec spec(int, android.widget.GridLayout.Alignment, int);
    method public static android.widget.GridLayout.Spec spec(int, int, android.widget.GridLayout.Alignment);
    method public static android.widget.GridLayout.Spec spec(int, android.widget.GridLayout.Alignment);
    field public static final int ALIGN_BOUNDS = 0; // 0x0
    field public static final int ALIGN_MARGINS = 1; // 0x1
    field public static final android.widget.GridLayout.Alignment BASELINE;
@@ -25271,23 +25275,19 @@ package android.widget {
  public static abstract class GridLayout.Alignment {
  }
  public static class GridLayout.Group {
    ctor public GridLayout.Group(int, int, android.widget.GridLayout.Alignment);
    ctor public GridLayout.Group(int, android.widget.GridLayout.Alignment);
    field public final android.widget.GridLayout.Alignment alignment;
    field public int flexibility;
  }
  public static class GridLayout.LayoutParams extends android.view.ViewGroup.MarginLayoutParams {
    ctor public GridLayout.LayoutParams(android.widget.GridLayout.Group, android.widget.GridLayout.Group);
    ctor public GridLayout.LayoutParams(android.widget.GridLayout.Spec, android.widget.GridLayout.Spec);
    ctor public GridLayout.LayoutParams();
    ctor public GridLayout.LayoutParams(android.view.ViewGroup.LayoutParams);
    ctor public GridLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams);
    ctor public GridLayout.LayoutParams(android.widget.GridLayout.LayoutParams);
    ctor public GridLayout.LayoutParams(android.content.Context, android.util.AttributeSet);
    method public void setGravity(int);
    field public android.widget.GridLayout.Group columnGroup;
    field public android.widget.GridLayout.Group rowGroup;
    field public android.widget.GridLayout.Spec columnSpec;
    field public android.widget.GridLayout.Spec rowSpec;
  }
  public static class GridLayout.Spec {
  }
  public class GridView extends android.widget.AbsListView {
+230 −187

File changed.

Preview size limit exceeded, changes collapsed.

+4 −6
Original line number Diff line number Diff line
@@ -3345,7 +3345,7 @@
        <!-- The row span: the difference between the bottom and top
        boundaries delimiting the group of cells occupied by this view.
        The default is one.
        See {@link android.widget.GridLayout.Group}. -->
        See {@link android.widget.GridLayout.Spec}. -->
        <attr name="layout_rowSpan" format="integer" min="1" />
        <!-- The column boundary delimiting the left of the group of cells
        occupied by this view. -->
@@ -3353,23 +3353,21 @@
        <!-- The column span: the difference between the right and left
        boundaries delimiting the group of cells occupied by this view.
        The default is one.
        See {@link android.widget.GridLayout.Group}. -->
        See {@link android.widget.GridLayout.Spec}. -->
        <attr name="layout_columnSpan" format="integer" min="1" />
        <!-- Gravity specifies how a component should be placed in its group of cells.
        The default is LEFT | BASELINE.
        See {@link android.widget.GridLayout.LayoutParams#setGravity(int)}. -->
        <attr name="layout_gravity" />
        <!-- A value specifying how much deficit or excess width this component can accomodate.
        The default is FIXED.
        See {@link android.widget.GridLayout.Group#flexibility}.-->
        The default is FIXED. -->
        <attr name="layout_columnFlexibility" >
            <!-- If possible, width should be greater than or equal to the specified width.
            See {@link android.widget.GridLayout#CAN_STRETCH}. -->
            <enum name="canStretch" value="2" />
        </attr>
        <!-- A value specifying how much deficit or excess height this component can accomodate.
        The default is FIXED.
        See {@link android.widget.GridLayout.Group#flexibility}.-->
        The default is FIXED. -->
        <attr name="layout_rowFlexibility" >
            <!-- If possible, height should be greater than or equal to the specified height.
            See {@link android.widget.GridLayout#CAN_STRETCH}. -->
+14 −17
Original line number Diff line number Diff line
@@ -38,20 +38,20 @@ public class Activity2 extends Activity {
        vg.setUseDefaultMargins(true);
        vg.setAlignmentMode(ALIGN_BOUNDS);

        Group row1 = new Group(1, CENTER);
        Group row2 = new Group(2, CENTER);
        Group row3 = new Group(3, BASELINE);
        Group row4 = new Group(4, BASELINE);
        Group row5 = new Group(5, FILL);
        Group row6 = new Group(6, CENTER);
        Group row7 = new Group(7, CENTER);
        Spec row1 = spec(0, CENTER);
        Spec row2 = spec(1, CENTER);
        Spec row3 = spec(2, BASELINE);
        Spec row4 = spec(3, BASELINE);
        Spec row5 = spec(4, FILL, CAN_STRETCH);
        Spec row6 = spec(5, CENTER);
        Spec row7 = spec(6, CENTER);

        Group col1a = new Group(1, 4, CENTER);
        Group col1b = new Group(1, 4, LEFT);
        Group col1c = new Group(1, RIGHT);
        Group col2 = new Group(2, LEFT);
        Group col3 = new Group(3, FILL);
        Group col4 = new Group(4, FILL);
        Spec col1a = spec(0, 4, CENTER);
        Spec col1b = spec(0, 4, LEFT);
        Spec col1c = spec(0, RIGHT);
        Spec col2 = spec(1, LEFT);
        Spec col3 = spec(2, FILL, CAN_STRETCH);
        Spec col4 = spec(3, FILL);

        {
            TextView v = new TextView(context);
@@ -96,10 +96,7 @@ public class Activity2 extends Activity {
        {
            Space v = new Space(context);
            {
                LayoutParams lp = new LayoutParams(row5, col3);
                lp.columnGroup.flexibility = CAN_STRETCH;
                lp.rowGroup.flexibility = CAN_STRETCH;
                vg.addView(v, lp);
                vg.addView(v, new LayoutParams(row5, col3));
            }
        }
        {
+1 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridLayout;
@@ -84,9 +83,7 @@ public class AlignmentTest extends Activity {
            Alignment va = VERTICAL_ALIGNMENTS[i];
            for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
                Alignment ha = HORIZONTAL_ALIGNMENTS[j];
                Group rowGroup = new Group(i, va);
                Group colGroup = new Group(j, ha);
                LayoutParams layoutParams = new LayoutParams(rowGroup, colGroup);
                LayoutParams layoutParams = new LayoutParams(spec(i, va), spec(j, ha));
                String name = VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j];
                ViewFactory factory = FACTORIES[(i + j) % FACTORIES.length];
                container.addView(factory.create(name, 20), layoutParams);
Loading