OSDN Git Service

Cherrypick 4cd282 from master. do not merge.
authorTor Norbye <tnorbye@google.com>
Wed, 7 Sep 2011 18:28:54 +0000 (11:28 -0700)
committerXavier Ducrohet <xav@android.com>
Thu, 29 Sep 2011 21:17:01 +0000 (14:17 -0700)
commit8a06163380b3df70071df08a17f2f8c2aa77513c
tree3af395acd2fa0922870820436b8e2ca80f017742
parentfdef32c01440dda37650ddf534c2b17093c30531
Cherrypick 4cd282 from master. do not merge.

Grid Layout and Convert to Grid Layout improvements

First, some improvements to Grid Layout handling:

(1) When dropping a new widget, look up the sizing metadata and use it
    to determine what fill gravity to set. For example, a button will
    use gravity left, and a text field will use gravity
    fill_horizontal.

(2) Don't warn about reflection problems when failing to find
    GridLayout layout data; this probably means the layout is being
    attempted opened in an unsupporting SDK. There's a fallback case
    to compute the data instead already.

Second, improvements to the conversion to GridLayout handling:

(1) It now looks at the layout_gravity values to see whether each row
    and column is flexible, and if there's no flexible column in each
    of the horizontal and vertical dimensions, it will insert a
    special <Space> element to absorb any available extra space. This
    avoids constraints warnings from GridLayout.

(2) It treats layout_width or layout_height attributes of match_parent
    or fill_parent as the same as a fill gravity (and removes it) and
    uses this in the flexibility computation above.

(3) It removes unsupported layout params for all children (earlier
    this would only remove unsupported layout params on the direct
    children of the layout, which isn't enough when a hierarchy is
    being flattened.)

(4) It's smarter about computing implicit rows and columns, so it
    avoids writing out redundant layout_row and layout_column
    attributes in some cases.

(5) It avoids throwing refactoring errors in cases where an attribute
    is removed twice

(6) Fixes a bug where the root layout was included when computing the
    set of used x and y coordinates, which means you'd often end up
    with a blank row and column 0.

(7) Various refactoring to make the code cleaner.

(8) More unit tests and updates to existing unit tests to reflect the
    new behavior such as an absorbing spacer and removal of redundant
    attributes.

Change-Id: Ifaca43458a4961fa032dfe22dc033b6def3c38d3
15 files changed:
eclipse/dictionary.txt
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/grid/GridDropHandler.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/grid/GridModel.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11-expected-insertSpacer.xml [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.info [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.xml [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml