diff options
author | Roman Nurik <romannurik@google.com> | 2012-07-26 16:13:23 -0700 |
---|---|---|
committer | Roman Nurik <romannurik@google.com> | 2012-07-27 08:44:23 -0700 |
commit | 8e21ca949e494438c9ad36d9b30ea4d85e3ac473 (patch) | |
tree | 0f78dc9ca1ba0a04555ca63d2d936170a4bc7780 /templates/projects/NewAndroidApplication | |
parent | 3d1fd6f05a58463a8d56f7ba374240a093a061d0 (diff) | |
download | sdk-8e21ca949e494438c9ad36d9b30ea4d85e3ac473.zip sdk-8e21ca949e494438c9ad36d9b30ea4d85e3ac473.tar.gz sdk-8e21ca949e494438c9ad36d9b30ea4d85e3ac473.tar.bz2 |
Add theme selection to New Android App template.
- Add a parameter to allow selecting the application theme.
Includes backward-compatibility support using resource
directory qualifiers. Default theme is Holo.Light.DarkActionBar.
Change-Id: Id046a2806fba9ea8ae296859b6d76af18a312b9f
Diffstat (limited to 'templates/projects/NewAndroidApplication')
9 files changed, 65 insertions, 17 deletions
diff --git a/templates/projects/NewAndroidApplication/recipe.xml.ftl b/templates/projects/NewAndroidApplication/recipe.xml.ftl index 7e0711a..bc8f02e 100644 --- a/templates/projects/NewAndroidApplication/recipe.xml.ftl +++ b/templates/projects/NewAndroidApplication/recipe.xml.ftl @@ -7,12 +7,14 @@ <copy from="res/drawable-mdpi" /> <copy from="res/drawable-xhdpi" /> </#if> - <copy from="res/values/styles.xml" /> -<#if buildApi gte 11> - <copy from="res/values-v11/styles.xml" /> + <instantiate from="res/values/styles.xml.ftl" /> +<#if buildApi gte 11 && baseTheme != "none"> + <instantiate from="res/values-v11/styles_hc.xml.ftl" + to="res/values-v11/styles.xml" /> </#if> -<#if buildApi gte 14> - <copy from="res/values-v14/styles.xml" /> +<#if buildApi gte 14 && baseTheme?contains("darkactionbar")> + <copy from="res/values-v14/styles_ics.xml" + to="res/values-v14/styles.xml" /> </#if> <instantiate from="res/values/strings.xml.ftl" /> diff --git a/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl b/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl index c97c601..f80cb6a 100644 --- a/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl +++ b/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl @@ -6,8 +6,8 @@ <uses-sdk android:minSdkVersion="${minApi}" android:targetSdkVersion="${targetApi}" /> <application android:label="@string/app_name" - android:icon="@drawable/ic_launcher" - android:theme="@style/AppTheme"> + android:icon="@drawable/ic_launcher"<#if baseTheme != "none"> + android:theme="@style/AppTheme"</#if>> </application> diff --git a/templates/projects/NewAndroidApplication/root/res/values-v11/styles.xml b/templates/projects/NewAndroidApplication/root/res/values-v11/styles.xml deleted file mode 100644 index ca53b2b..0000000 --- a/templates/projects/NewAndroidApplication/root/res/values-v11/styles.xml +++ /dev/null @@ -1,3 +0,0 @@ -<resources> - <style name="AppTheme" parent="android:Theme.Holo.Light" /> -</resources> diff --git a/templates/projects/NewAndroidApplication/root/res/values-v11/styles_hc.xml.ftl b/templates/projects/NewAndroidApplication/root/res/values-v11/styles_hc.xml.ftl new file mode 100644 index 0000000..f8993c3 --- /dev/null +++ b/templates/projects/NewAndroidApplication/root/res/values-v11/styles_hc.xml.ftl @@ -0,0 +1,11 @@ +<resources> + + <!-- + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Holo<#if baseTheme?contains("light")>.Light</#if>"> + <!-- API 11 theme customizations can go here. --> + </style> + +</resources> diff --git a/templates/projects/NewAndroidApplication/root/res/values-v14/styles.xml b/templates/projects/NewAndroidApplication/root/res/values-v14/styles.xml deleted file mode 100644 index 5cd7c2f..0000000 --- a/templates/projects/NewAndroidApplication/root/res/values-v14/styles.xml +++ /dev/null @@ -1,3 +0,0 @@ -<resources> - <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" /> -</resources> diff --git a/templates/projects/NewAndroidApplication/root/res/values-v14/styles_ics.xml b/templates/projects/NewAndroidApplication/root/res/values-v14/styles_ics.xml new file mode 100644 index 0000000..a91fd03 --- /dev/null +++ b/templates/projects/NewAndroidApplication/root/res/values-v14/styles_ics.xml @@ -0,0 +1,12 @@ +<resources> + + <!-- + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + --> + <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> + <!-- API 14 theme customizations can go here. --> + </style> + +</resources> diff --git a/templates/projects/NewAndroidApplication/root/res/values/styles.xml b/templates/projects/NewAndroidApplication/root/res/values/styles.xml deleted file mode 100644 index 8f4d89b..0000000 --- a/templates/projects/NewAndroidApplication/root/res/values/styles.xml +++ /dev/null @@ -1,3 +0,0 @@ -<resources> - <style name="AppTheme" parent="android:Theme.Light" /> -</resources> diff --git a/templates/projects/NewAndroidApplication/root/res/values/styles.xml.ftl b/templates/projects/NewAndroidApplication/root/res/values/styles.xml.ftl new file mode 100644 index 0000000..30fe5b5 --- /dev/null +++ b/templates/projects/NewAndroidApplication/root/res/values/styles.xml.ftl @@ -0,0 +1,20 @@ +<resources> + + <!-- + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + --> + <style name="AppBaseTheme" parent="android:Theme<#if baseTheme?contains("light")>.Light</#if>"> + <!-- + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + --> + </style> + + <!-- Application theme. --> + <style name="AppTheme" parent="AppBaseTheme"> + <!-- All customizations that are NOT specific to a particular API-level can go here. --> + </style> + +</resources> diff --git a/templates/projects/NewAndroidApplication/template.xml b/templates/projects/NewAndroidApplication/template.xml index 184844f..fd5ee5e 100644 --- a/templates/projects/NewAndroidApplication/template.xml +++ b/templates/projects/NewAndroidApplication/template.xml @@ -3,7 +3,7 @@ format="1" revision="1" name="New Android Application" - description="Creates a new Android application with an activity."> + description="Creates a new Android application."> <dependency name="android-support-v4" revision="8" /> <thumbs> @@ -27,6 +27,18 @@ default="My Application" /> <parameter + id="baseTheme" + name="Base Theme" + type="enum" + default="holo_light_darkactionbar" + help="The base user interface theme for the application"> + <option id="none">None</option> + <option id="holo_dark" minBuildApi="11">Holo Dark</option> + <option id="holo_light" minBuildApi="11">Holo Light</option> + <option id="holo_light_darkactionbar" minBuildApi="14" default="true">Holo Light with Dark Action Bar</option> + </parameter> + + <parameter id="minApi" name="Minimum API level" type="string" |