aboutsummaryrefslogtreecommitdiffstats
path: root/templates/activities
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-06-20 17:40:10 -0700
committerTor Norbye <tnorbye@google.com>2012-06-20 18:16:44 -0700
commit6d1e4fdd6b2132b895aae80de3dba83c3960d43f (patch)
tree3d43bcbde68453413dc5c84393ede4cf1c09a626 /templates/activities
parent71c8c3f1186fe27b21aaddc90f8278c27733edd9 (diff)
downloadsdk-6d1e4fdd6b2132b895aae80de3dba83c3960d43f.zip
sdk-6d1e4fdd6b2132b895aae80de3dba83c3960d43f.tar.gz
sdk-6d1e4fdd6b2132b895aae80de3dba83c3960d43f.tar.bz2
Miscellaneous wizard fixes
* Add minSdk requirements on templates, and attempting to pick a template with a higher minimum SDK than the one used by the current project will result in a validation error message (and the Next button is disabled). Similarly, add a minSdk requirement on options, such as the BlankActivity's navigation type. This is used to block all navigation types except for "none", unless minSdkVersion >= 14. * Add a buildApi property, which the templates use to only conditionally write contents which requires a higher compilation target. For example, the values-v11 and values-v14 folders specifying Theme.Holo.Light and Theme.Holo.Light.DarkActionBar are only written if the build target is at least 11 and 14 respectively. * Fix some other minor issues which prevented the projects from compiling with low minSdkVersions and low build targets. * Replace the default simple activity's layout (which was just a <TextView> with a center gravity, with a <RelativeLayout> containing the <TextView> with center constraints * Make the code which combines the list of templates from extras/ and tools/ smarter; instead of just concatenating the two lists, it now compares them, and when they have the same names (same templates, different versions), it now chooses which one to use based on the template revision number in the metadata file. Moved some code out of TemplateHandler and into a new TemplateManager class, such that I could add metadata caching (since the code to merge templates in multiple files would repeatedly read and parse the metadata for each pair comparison.) Change-Id: I94fc4f754dd7125b5be5c78e61efcfc268f73af5
Diffstat (limited to 'templates/activities')
-rw-r--r--templates/activities/BlankActivity/recipe.xml.ftl4
-rw-r--r--templates/activities/BlankActivity/root/res/layout/activity_simple.xml8
-rw-r--r--templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl15
-rw-r--r--templates/activities/BlankActivity/root/res/menu/main.xml.ftl (renamed from templates/activities/BlankActivity/root/res/menu/main.xml)4
-rw-r--r--templates/activities/BlankActivity/template.xml8
-rw-r--r--templates/activities/MasterDetailFlow/template.xml1
6 files changed, 24 insertions, 16 deletions
diff --git a/templates/activities/BlankActivity/recipe.xml.ftl b/templates/activities/BlankActivity/recipe.xml.ftl
index a6d0ce9..6c0dc6a 100644
--- a/templates/activities/BlankActivity/recipe.xml.ftl
+++ b/templates/activities/BlankActivity/recipe.xml.ftl
@@ -6,7 +6,7 @@
<copy from="res/drawable-mdpi" />
<copy from="res/drawable-xhdpi" />
- <copy from="res/menu/main.xml"
+ <instantiate from="res/menu/main.xml.ftl"
to="res/menu/${menuName}.xml" />
<merge from="res/values/dimens.xml" />
@@ -23,7 +23,7 @@
to="res/layout/${layoutName}.xml" />
<#else>
- <instantiate from="res/layout/activity_simple.xml"
+ <instantiate from="res/layout/activity_simple.xml.ftl"
to="res/layout/${layoutName}.xml" />
</#if>
diff --git a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml
deleted file mode 100644
index aa34ee3..0000000
--- a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/hello_world"
- android:padding="@dimen/padding_medium"
- tools:context=".${activityClass}" />
diff --git a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl
new file mode 100644
index 0000000..457c0bf
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl
@@ -0,0 +1,15 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if>
+ android:layout_height=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if> >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true"
+ android:padding="@dimen/padding_medium"
+ android:text="@string/hello_world"
+ tools:context=".${activityClass}" />
+
+</RelativeLayout>
diff --git a/templates/activities/BlankActivity/root/res/menu/main.xml b/templates/activities/BlankActivity/root/res/menu/main.xml.ftl
index cfc10fd..41bdfee 100644
--- a/templates/activities/BlankActivity/root/res/menu/main.xml
+++ b/templates/activities/BlankActivity/root/res/menu/main.xml.ftl
@@ -1,6 +1,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_settings"
android:title="@string/menu_settings"
- android:orderInCategory="100"
- android:showAsAction="never" />
+ android:orderInCategory="100"<#if buildApi gte 11>
+ android:showAsAction="never"</#if> />
</menu>
diff --git a/templates/activities/BlankActivity/template.xml b/templates/activities/BlankActivity/template.xml
index bce675d..00b8fb4 100644
--- a/templates/activities/BlankActivity/template.xml
+++ b/templates/activities/BlankActivity/template.xml
@@ -33,10 +33,10 @@
default="none"
help="The type of navigation to use for the activity" >
<option id="none" default="true">None</option>
- <option id="tabs">Tabs</option>
- <option id="tabs_pager">Tabs + Swipe</option>
- <option id="pager_strip">Swipe Views + Title Strip</option>
- <option id="dropdown">Dropdown</option>
+ <option id="tabs" minApi="14">Tabs</option>
+ <option id="tabs_pager" minApi="14">Tabs + Swipe</option>
+ <option id="pager_strip" minApi="14">Swipe Views + Title Strip</option>
+ <option id="dropdown" minApi="14">Dropdown</option>
</parameter>
<parameter
diff --git a/templates/activities/MasterDetailFlow/template.xml b/templates/activities/MasterDetailFlow/template.xml
index 05ddb68..70a3995 100644
--- a/templates/activities/MasterDetailFlow/template.xml
+++ b/templates/activities/MasterDetailFlow/template.xml
@@ -3,6 +3,7 @@
format="1"
revision="1"
name="New Master/Detail Flow"
+ minApi="11"
description="Creates a new master/detail flow, which is two columns on tablets, and one column on smaller screens. This creates a master fragment, detail fragment, and two activities.">
<dependency name="android-support-v4" revision="8" />