aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java87
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml32
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml28
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml13
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml28
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml39
13 files changed, 242 insertions, 49 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java
index ae76322..12bea3a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java
@@ -20,7 +20,10 @@ import static com.android.ide.common.layout.LayoutConstants.ANDROID_WIDGET_PREFI
import static com.android.ide.common.layout.LayoutConstants.ATTR_BASELINE_ALIGNED;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_BELOW;
+import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT;
+import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_PREFIX;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_TO_RIGHT_OF;
+import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH;
import static com.android.ide.common.layout.LayoutConstants.ATTR_ORIENTATION;
import static com.android.ide.common.layout.LayoutConstants.FQCN_GESTURE_OVERLAY_VIEW;
import static com.android.ide.common.layout.LayoutConstants.FQCN_GRID_LAYOUT;
@@ -32,6 +35,7 @@ import static com.android.ide.common.layout.LayoutConstants.LINEAR_LAYOUT;
import static com.android.ide.common.layout.LayoutConstants.TABLE_ROW;
import static com.android.ide.common.layout.LayoutConstants.VALUE_FALSE;
import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL;
+import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT;
import static com.android.ide.eclipse.adt.AdtConstants.EXT_XML;
import com.android.annotations.VisibleForTesting;
@@ -40,6 +44,7 @@ import com.android.ide.eclipse.adt.internal.editors.formatting.XmlFormatStyle;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.CanvasViewInfo;
+import com.android.ide.eclipse.adt.internal.editors.layout.gle2.DomUtilities;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.ViewHierarchy;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
@@ -62,6 +67,7 @@ import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -246,6 +252,7 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
String oldType = getOldType();
String newType = mTypeFqcn;
+
if (newType.equals(FQCN_RELATIVE_LAYOUT)) {
if (oldType.equals(FQCN_LINEAR_LAYOUT) && !mFlatten) {
// Hand-coded conversion specifically tailored for linear to relative, provided
@@ -253,22 +260,25 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
// TODO: use the RelativeLayoutConversionHelper for this; it does a better job
// analyzing gravities etc.
convertLinearToRelative(rootEdit);
- removeUndefinedLayoutAttrs(rootEdit, layout);
+ removeUndefinedAttrs(rootEdit, layout);
+ addMissingWrapContentAttributes(rootEdit, layout, oldType, newType, null);
} else {
// Generic conversion to relative - can also flatten the hierarchy
- convertAnyToRelative(rootEdit);
+ convertAnyToRelative(rootEdit, oldType, newType);
// This already handles removing undefined layout attributes -- right?
//removeUndefinedLayoutAttrs(rootEdit, layout);
}
} else if (newType.equals(FQCN_GRID_LAYOUT)) {
convertAnyToGridLayout(rootEdit);
- removeUndefinedLayoutAttrs(rootEdit, layout);
+ removeUndefinedAttrs(rootEdit, layout);
} else if (oldType.equals(FQCN_RELATIVE_LAYOUT) && newType.equals(FQCN_LINEAR_LAYOUT)) {
convertRelativeToLinear(rootEdit);
- removeUndefinedLayoutAttrs(rootEdit, layout);
+ removeUndefinedAttrs(rootEdit, layout);
+ addMissingWrapContentAttributes(rootEdit, layout, oldType, newType, null);
} else if (oldType.equals(FQCN_LINEAR_LAYOUT) && newType.equals(FQCN_TABLE_LAYOUT)) {
convertLinearToTable(rootEdit);
- removeUndefinedLayoutAttrs(rootEdit, layout);
+ removeUndefinedAttrs(rootEdit, layout);
+ addMissingWrapContentAttributes(rootEdit, layout, oldType, newType, null);
} else {
convertGeneric(rootEdit, oldType, newType, layout);
}
@@ -284,6 +294,29 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
return changes;
}
+ /** Checks whether we need to add any missing attributes on the elements */
+ private void addMissingWrapContentAttributes(MultiTextEdit rootEdit, Element layout,
+ String oldType, String newType, Set<Element> skip) {
+ if (oldType.equals(FQCN_GRID_LAYOUT) && !newType.equals(FQCN_GRID_LAYOUT)) {
+ String namespace = getAndroidNamespacePrefix();
+
+ for (Element child : DomUtilities.getChildren(layout)) {
+ if (skip != null && skip.contains(child)) {
+ continue;
+ }
+
+ if (!child.hasAttributeNS(ANDROID_URI, ATTR_LAYOUT_WIDTH)) {
+ setAttribute(rootEdit, child, ANDROID_URI,
+ namespace, ATTR_LAYOUT_WIDTH, VALUE_WRAP_CONTENT);
+ }
+ if (!child.hasAttributeNS(ANDROID_URI, ATTR_LAYOUT_HEIGHT)) {
+ setAttribute(rootEdit, child, ANDROID_URI,
+ namespace, ATTR_LAYOUT_HEIGHT, VALUE_WRAP_CONTENT);
+ }
+ }
+ }
+ }
+
/** Hand coded conversion from a LinearLayout to a TableLayout */
private void convertLinearToTable(MultiTextEdit rootEdit) {
// This is pretty easy; just switch the root tag (already done by the initial generic
@@ -331,8 +364,6 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
boolean isVertical = VALUE_VERTICAL.equals(layout.getAttributeNS(ANDROID_URI,
ATTR_ORIENTATION));
- removeOrientationAttribute(rootEdit, layout);
-
String attributePrefix = getAndroidNamespacePrefix();
// TODO: Consider gravity of each element
@@ -432,11 +463,16 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
// For now we simply go with the default behavior, which is to just strip the
// layout attributes that aren't supported.
- removeUndefinedLayoutAttrs(rootEdit, layout);
+ removeUndefinedAttrs(rootEdit, layout);
+ addMissingWrapContentAttributes(rootEdit, layout, oldType, newType, null);
}
- /** Removes all the unused attributes after a conversion */
- private void removeUndefinedLayoutAttrs(MultiTextEdit rootEdit, Element layout) {
+ /**
+ * Removes all the unavailable attributes after a conversion, both on the
+ * layout element itself as well as the layout attributes of any of the
+ * children
+ */
+ private void removeUndefinedAttrs(MultiTextEdit rootEdit, Element layout) {
ViewElementDescriptor descriptor = getElementDescriptor(mTypeFqcn);
if (descriptor == null) {
return;
@@ -464,10 +500,33 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
}
}
}
+
+ // Also remove the unavailable attributes (not layout attributes) on the
+ // converted element
+ defined = new HashSet<String>();
+ AttributeDescriptor[] attributes = descriptor.getAttributes();
+ for (AttributeDescriptor attribute : attributes) {
+ defined.add(attribute.getXmlLocalName());
+ }
+
+ // Remove undefined attributes on the layout element itself
+ NamedNodeMap attributeMap = layout.getAttributes();
+ for (int i = 0, n = attributeMap.getLength(); i < n; i++) {
+ Node attributeNode = attributeMap.item(i);
+
+ String name = attributeNode.getLocalName();
+ if (!name.startsWith(ATTR_LAYOUT_PREFIX)
+ && ANDROID_URI.equals(attributeNode.getNamespaceURI())) {
+ if (!defined.contains(name)) {
+ // Remove it
+ removeAttribute(rootEdit, layout, ANDROID_URI, name);
+ }
+ }
+ }
}
/** Hand coded conversion from any layout to a RelativeLayout */
- private void convertAnyToRelative(MultiTextEdit rootEdit) {
+ private void convertAnyToRelative(MultiTextEdit rootEdit, String oldType, String newType) {
// To perform a conversion from any other layout type, including nested conversion,
Element layout = getPrimaryElement();
CanvasViewInfo rootView = mRootView;
@@ -480,6 +539,12 @@ public class ChangeLayoutRefactoring extends VisualRefactoring {
RelativeLayoutConversionHelper helper =
new RelativeLayoutConversionHelper(this, layout, mFlatten, rootEdit, rootView);
helper.convertToRelative();
+ List<Element> deletedElements = helper.getDeletedElements();
+ Set<Element> deleted = null;
+ if (deletedElements != null && deletedElements.size() > 0) {
+ deleted = new HashSet<Element>(deletedElements);
+ }
+ addMissingWrapContentAttributes(rootEdit, layout, oldType, newType, deleted);
}
/** Hand coded conversion from any layout to a GridLayout */
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java
index 774d548..2b21b85 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java
@@ -195,6 +195,16 @@ class GridLayoutConverter {
}
nextRow = Math.max(nextRow, row + rowSpan);
+ // wrap_content is redundant in GridLayouts
+ Attr width = element.getAttributeNodeNS(ANDROID_URI, ATTR_LAYOUT_WIDTH);
+ if (width != null && VALUE_WRAP_CONTENT.equals(width.getValue())) {
+ mRefactoring.removeAttribute(mRootEdit, width);
+ }
+ Attr height = element.getAttributeNodeNS(ANDROID_URI, ATTR_LAYOUT_HEIGHT);
+ if (height != null && VALUE_WRAP_CONTENT.equals(height.getValue())) {
+ mRefactoring.removeAttribute(mRootEdit, height);
+ }
+
// Fix up children moved from LinearLayouts that have "invalid" sizes that
// was intended for layout weight handling in their old parent
if (LINEAR_LAYOUT.equals(element.getParentNode().getNodeName())) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
index 27b3fbf..dabbca8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RelativeLayoutConversionHelper.java
@@ -108,6 +108,7 @@ class RelativeLayoutConversionHelper {
private final Element mLayout;
private final ChangeLayoutRefactoring mRefactoring;
private final CanvasViewInfo mRootView;
+ private List<Element> mDeletedElements;
RelativeLayoutConversionHelper(ChangeLayoutRefactoring refactoring,
Element layout, boolean flatten, MultiTextEdit rootEdit, CanvasViewInfo rootView) {
@@ -138,13 +139,19 @@ class RelativeLayoutConversionHelper {
createAttachments(views);
}
+ /** Returns the elements that were deleted, or null */
+ List<Element> getDeletedElements() {
+ return mDeletedElements;
+ }
+
/**
* Analyzes the given view hierarchy and produces a list of {@link View} objects which
* contain placement information for each element
*/
private List<View> analyzeLayout(CanvasViewInfo layoutView) {
EdgeList edgeList = new EdgeList(layoutView);
- deleteRemovedElements(edgeList.getDeletedElements());
+ mDeletedElements = edgeList.getDeletedElements();
+ deleteRemovedElements(mDeletedElements);
List<Integer> columnOffsets = edgeList.getColumnOffsets();
List<Integer> rowOffsets = edgeList.getRowOffsets();
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java
index ff2f78a..8b825ad 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.editors.layout.refactoring;
import static com.android.ide.common.layout.LayoutConstants.FQCN_GRID_LAYOUT;
+import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT;
import static com.android.ide.common.layout.LayoutConstants.FQCN_RELATIVE_LAYOUT;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.CanvasViewInfo;
@@ -28,6 +29,7 @@ import org.w3c.dom.Element;
import java.util.Collections;
import java.util.List;
+@SuppressWarnings("javadoc")
public class ChangeLayoutRefactoringTest extends RefactoringTest {
public void testChangeLayout1a() throws Exception {
@@ -80,6 +82,14 @@ public class ChangeLayoutRefactoringTest extends RefactoringTest {
checkRefactoring(FQCN_GRID_LAYOUT, "sample5.xml", true);
}
+ public void testConvertToGrid() throws Exception {
+ checkRefactoring(FQCN_GRID_LAYOUT, "sample9.xml", true);
+ }
+
+ public void testConvertFromGrid() throws Exception {
+ checkRefactoring(FQCN_LINEAR_LAYOUT, "sample10.xml", true);
+ }
+
private void checkRefactoring(String basename, boolean flatten) throws Exception {
checkRefactoring(FQCN_RELATIVE_LAYOUT, basename, flatten);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml
new file mode 100644
index 0000000..faa95d7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/LinearLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button" />
+
+ <RadioButton
+ android:id="@+id/radioButton1"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content"
+ android:text="RadioButton" />
+
+ <RadioButton
+ android:id="@+id/radioButton2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="RadioButton" />
+
+ <CheckBox
+ android:id="@+id/checkBox1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="CheckBox" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info
new file mode 100644
index 0000000..c964b0e
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info
@@ -0,0 +1,5 @@
+android.widget.GridLayout [0,73,320,480] <GridLayout>
+ android.widget.Button [0,0,79,48] <Button>
+ android.widget.RadioButton [0,48,150,86] <RadioButton>
+ android.widget.RadioButton [150,48,273,86] <RadioButton>
+ android.widget.CheckBox [0,86,107,124] <CheckBox>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml
new file mode 100644
index 0000000..1fcaab5
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/GridLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:columnCount="2"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/button1"
+ android:text="Button" />
+
+ <RadioButton
+ android:id="@+id/radioButton1"
+ android:layout_width="150dp"
+ android:layout_column="0"
+ android:layout_row="1"
+ android:text="RadioButton" />
+
+ <RadioButton
+ android:id="@+id/radioButton2"
+ android:text="RadioButton" />
+
+ <CheckBox
+ android:id="@+id/checkBox1"
+ android:text="CheckBox" />
+
+</GridLayout>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml
index 89932a5..a5cbc35 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml
@@ -8,15 +8,11 @@
<Button
android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:text="FirstButton" >
</Button>
<Button
android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="1"
android:text="SecondButton" >
@@ -24,38 +20,29 @@
<Button
android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:text="ThirdButton" >
</Button>
<CheckBox
android:id="@+id/checkBox1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:text="CheckBox" >
</CheckBox>
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
android:layout_columnSpan="3"
android:text="FourthButton" >
</Button>
<Button
android:id="@+id/button5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="FifthButton" >
</Button>
<Button
android:id="@+id/button6"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="4"
android:text="Button" >
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml
index bfd130a..40031a6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml
@@ -8,16 +8,12 @@
<Button
android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_columnSpan="2"
android:text="Button" >
</Button>
<Button
android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_column="0"
android:layout_columnSpan="2"
@@ -27,8 +23,6 @@
<Button
android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_below="@+id/button2"
android:layout_row="2"
android:layout_toRightOf="@+id/button2"
@@ -37,8 +31,6 @@
<Button
android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_below="@+id/button3"
android:layout_row="3"
android:layout_toRightOf="@+id/button3"
@@ -47,8 +39,6 @@
<CheckBox
android:id="@+id/checkBox1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_below="@+id/button4"
android:layout_column="1"
android:layout_columnSpan="2"
@@ -59,8 +49,6 @@
<Button
android:id="@+id/button5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_column="4"
android:layout_row="1"
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml
index 6625529..09f8d36 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml
@@ -8,8 +8,6 @@
<Button
android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_column="2"
android:layout_columnSpan="2"
android:layout_gravity="center_horizontal"
@@ -18,8 +16,6 @@
<Button
android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_column="2"
android:layout_columnSpan="2"
android:layout_gravity="center"
@@ -28,8 +24,6 @@
<Button
android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_column="2"
android:layout_columnSpan="2"
android:layout_gravity="right"
@@ -38,16 +32,12 @@
<Button
android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button" >
</Button>
<Button
android:id="@+id/button5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_columnSpan="2"
android:layout_gravity="center_vertical"
android:text="Button" >
@@ -55,8 +45,6 @@
<Button
android:id="@+id/button6"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Button" >
</Button>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml
new file mode 100644
index 0000000..15f1c3b
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/GridLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:columnCount="2"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/button1"
+ android:text="Button" />
+
+ <RadioButton
+ android:id="@+id/radioButton1"
+ android:layout_width="150dp"
+ android:layout_column="0"
+ android:layout_row="1"
+ android:text="RadioButton" />
+
+ <RadioButton
+ android:id="@+id/radioButton2"
+ android:text="RadioButton" />
+
+ <CheckBox
+ android:id="@+id/checkBox1"
+ android:text="CheckBox" />
+
+</GridLayout> \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info
new file mode 100644
index 0000000..3085ff0
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info
@@ -0,0 +1,6 @@
+android.widget.LinearLayout [0,73,320,480] <LinearLayout>
+ android.widget.Button [0,0,79,48] <Button>
+ android.widget.LinearLayout [0,48,320,86] <LinearLayout>
+ android.widget.RadioButton [0,0,150,38] <RadioButton>
+ android.widget.RadioButton [150,0,273,38] <RadioButton>
+ android.widget.CheckBox [0,86,107,124] <CheckBox>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml
new file mode 100644
index 0000000..13068e7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/LinearLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button" />
+
+ <LinearLayout
+ android:id="@+id/linearLayout2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <RadioButton
+ android:id="@+id/radioButton1"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content"
+ android:text="RadioButton" />
+
+ <RadioButton
+ android:id="@+id/radioButton2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="RadioButton" />
+
+ </LinearLayout>
+
+ <CheckBox
+ android:id="@+id/checkBox1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="CheckBox" />
+
+</LinearLayout>