summaryrefslogtreecommitdiff
path: root/android/testData/designer
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-04-15 12:49:11 -0700
committerTor Norbye <tnorbye@google.com>2014-04-28 14:29:26 -0700
commitdc80802a09675eb00cb9962a9dc7fea227d9713c (patch)
treec799aa1f6d981a113c20bf9dda9310d9d0ec414a /android/testData/designer
parent7dad7ac35b6a9adc5339a17a8589266f3e242d78 (diff)
downloadidea-dc80802a09675eb00cb9962a9dc7fea227d9713c.tar.gz
Layout editor: Hover, Show Included In, and model improvements
This changeset adds the following features to the layout editor: (1) Show Included In. For a layout that is included from another layout, this lets you view and edit the included layout "in place" in the outer layout. The outer layout is masked out with a partially translucent mask, and does not respond to edits. The outline will show the outer layout's name at the root level. The included rendering is controlled with a tools attribute, and is therefore persistent. The Extract Include refactoring will automatically enter show-included-in mode for the extracted layout. (2) Highlight the view under the mouse ("hover"). This makes it easier to see the structure of the layout. In addition to the faint highlight (same as in ADT) it also shows a faint dashed outline of the widget bounds. The above two features are supported for both the layout editor as well as the XML layout preview. To facilitate sharing between the two, there is a new "Overlays" concept; each overlay is a mask that is painted on top of the area, and the hover and include layers are individual overlays. There can be more in the future, such as an overlay to show empty components, an overlay to show lint badges, etc. Prior to this CL, the layout editor built up its component hierarchy by parsing the XML file, and the reconciling that parse with layoutlib's set of view infos by comparing element children. This does not work when the view hierarchy does not correspond to the XML file, as is the case for show-included-in rendering. This CL replaces this with a new RadModelBuilder, which does not look at the XML at all; it instead infers the structure from the layoutlib ViewInfo hierarchy and the corresponding view cookies. This means that the layout editor will now only operate on valid layoutlib render results. There is unit test support for testing the layout editor directly. In addition to dumping out its inferred component tree using the android tree decorator, it also has utility methods to drop components and set attributes using the layout editor itself. In subsequent CLs this will be used to add tests for more of the layout editor functionality. This CL also contains misc other fixes as I encountered code in the layout editor, such as getting rid of all the getClientProperty calls to look up the current module / file / tree decorator, adding more nullness annotations and removing warnings, removing the nested throwables in our crash reports, etc. Change-Id: I9ce55593a1bf4ec385c8828e4a53050740a72d29
Diffstat (limited to 'android/testData/designer')
-rw-r--r--android/testData/designer/included.xml23
-rw-r--r--android/testData/designer/includer.xml29
-rw-r--r--android/testData/designer/layout.xml104
-rw-r--r--android/testData/designer/simple2.xml16
4 files changed, 132 insertions, 40 deletions
diff --git a/android/testData/designer/included.xml b/android/testData/designer/included.xml
new file mode 100644
index 00000000000..3b4ec452abd
--- /dev/null
+++ b/android/testData/designer/included.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="vertical"
+ android:background="ffff0000"
+ tools:showIn="@layout/includer">
+
+ <TextView
+ android:id="@+id/textView4"
+ android:layout_width="500px"
+ android:layout_height="80px"
+ android:text="Included Layout"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <TextView
+ android:id="@+id/textView5"
+ android:layout_width="500px"
+ android:layout_height="80px"
+ android:text="This text is from the included layout" />
+</LinearLayout>
diff --git a/android/testData/designer/includer.xml b/android/testData/designer/includer.xml
new file mode 100644
index 00000000000..a25ed05a66a
--- /dev/null
+++ b/android/testData/designer/includer.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="ffff0000"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="500px"
+ android:layout_height="80px"
+ android:layout_gravity="center_horizontal"
+ android:text="Outer Layout"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <TextView
+ android:id="@+id/textView2"
+ android:layout_width="500px"
+ android:layout_height="80px"
+ android:text="This text is from the outer layout" />
+
+ <include layout="@layout/included" />
+
+ <TextView
+ android:id="@+id/textView3"
+ android:layout_width="500px"
+ android:layout_height="80px"
+ android:text="This text is at the end of the outer layout" />
+</LinearLayout>
diff --git a/android/testData/designer/layout.xml b/android/testData/designer/layout.xml
index 96bb7da4995..81e6c8e9576 100644
--- a/android/testData/designer/layout.xml
+++ b/android/testData/designer/layout.xml
@@ -1,77 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <LinearLayout style="@style/TitleBar" android:id="@+id/header">
- <ImageView style="@style/TitleBarLogo"
- android:contentDescription="@string/description_logo"
- android:src="@drawable/title_logo" />
-
- <View style="@style/TitleBarSpring" />
-
- <ImageView style="@style/TitleBarSeparator" />
- <ImageButton style="@style/TitleBarAction"
- android:id="@+id/btn_title_refresh"
- android:contentDescription="@string/description_refresh"
- android:src="@drawable/ic_title_refresh"
- android:layout_width="wrap_content"
- android:layout_height="42dp"
- android:onClick="onRefreshClick" />
- <ProgressBar style="@style/TitleBarProgressIndicator"
- android:id="@+id/title_refresh_progress"
- android:layout_width="wrap_content"
- android:visibility="visible"/>
-
- <ImageView style="@style/TitleBarSeparator" />
- <ImageButton style="@style/TitleBarAction"
- android:contentDescription="@string/description_search"
- android:src="@drawable/ic_title_search"
- android:layout_width="wrap_content"
- android:layout_height="42dp"
- android:onClick="onSearchClick" />
+ android:layout_height="fill_parent"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:id="@+id/header"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@android:string/ok"
+ android:src="@android:drawable/btn_plus" />
+
+ <View
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ImageButton
+ android:id="@+id/btn_title_refresh"
+ android:layout_width="wrap_content"
+ android:layout_height="42dp"
+ android:contentDescription="@android:string/ok"
+ android:onClick="onRefreshClick"
+ android:src="@android:drawable/btn_plus" />
+
+ <ProgressBar
+ android:id="@+id/title_refresh_progress"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="visible" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ImageButton
+ android:layout_width="wrap_content"
+ android:layout_height="42dp"
+ android:contentDescription="@android:string/ok"
+ android:onClick="onSearchClick"
+ android:src="@android:drawable/btn_plus" />
</LinearLayout>
<LinearLayout
android:id="@+id/noteArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_margin="5dip">
+ android:layout_margin="5dip"
+ android:layout_weight="1">
+
<EditText
android:id="@android:id/text1"
+ android:layout_width="wrap_content"
android:layout_height="fill_parent"
- android:hint="@string/note_hint"
+ android:layout_weight="1"
android:freezesText="true"
- android:gravity="top" android:layout_width="wrap_content" android:layout_weight="1">
- </EditText>
+ android:gravity="top"
+ android:hint="@android:string/ok"></EditText>
+
<EditText
android:id="@android:id/text2"
+ android:layout_width="wrap_content"
android:layout_height="fill_parent"
+ android:layout_weight="1"
android:freezesText="true"
- android:gravity="top" android:layout_width="wrap_content" android:layout_weight="1">
+ android:gravity="top">
+
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
- android:orientation="horizontal"
+ style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- style="@android:style/ButtonBar">
+ android:orientation="horizontal">
+
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onSaveClick"
- android:text="@string/note_save" />
+ android:text="@android:string/ok" />
+
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onDiscardClick"
- android:text="@string/note_discard" />
+ android:text="@android:string/ok" />
</LinearLayout>
</LinearLayout>
diff --git a/android/testData/designer/simple2.xml b/android/testData/designer/simple2.xml
new file mode 100644
index 00000000000..78879530658
--- /dev/null
+++ b/android/testData/designer/simple2.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical">
+ <!-- Using fixed pixel heights to make unit test bounds predictable, avoid font height platform differences -->
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="200px"
+ android:text="My Button" />
+
+ <TextView
+ android:layout_width="400px"
+ android:layout_height="220px"
+ android:text="My TextView" />
+</LinearLayout>