diff options
author | Tor Norbye <tnorbye@google.com> | 2012-06-22 14:19:51 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-07-02 08:44:14 -0700 |
commit | e9db0a86e766f52a9cef38f7ad05a32185f0f953 (patch) | |
tree | 25c33551b9336e410ac46b694095df330c144c05 /templates | |
parent | 2b78fa53ccd6b5422c66b33ff35db3a0330f2c38 (diff) | |
download | sdk-e9db0a86e766f52a9cef38f7ad05a32185f0f953.zip sdk-e9db0a86e766f52a9cef38f7ad05a32185f0f953.tar.gz sdk-e9db0a86e766f52a9cef38f7ad05a32185f0f953.tar.bz2 |
Project template tweaks
Fix code which derives a project name from an application name such
that it skips invalid project name characters. For example, the
application name can be "I/O", but the project name should default to
just "IO".
Second, fix the validator code such that when it is validating a
template parameter constraint of "class", it validates it as a class
name, not a package name (so you cannot enter dots for example).
Third, replace the default project template icons with the standard
app icons (for when you disable Create Custom Launcher Icons).
Fourth, tweak the templates such that you don't have unused imports
when you create an activity without navigation, and remove unused
padding dimension resources.
Change-Id: I524608bb6347b4275338ec935e8de56bf3184c23
Diffstat (limited to 'templates')
14 files changed, 11 insertions, 20 deletions
diff --git a/templates/activities/BlankActivity/recipe.xml.ftl b/templates/activities/BlankActivity/recipe.xml.ftl index 6c0dc6a..05c5d57 100644 --- a/templates/activities/BlankActivity/recipe.xml.ftl +++ b/templates/activities/BlankActivity/recipe.xml.ftl @@ -9,8 +9,6 @@ <instantiate from="res/menu/main.xml.ftl" to="res/menu/${menuName}.xml" /> - <merge from="res/values/dimens.xml" /> - <merge from="res/values-large/dimens.xml" /> <merge from="res/values/strings.xml.ftl" /> <!-- Decide what kind of layout to add (viewpager or not) --> diff --git a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl index 457c0bf..a472bfe 100644 --- a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl +++ b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl @@ -8,7 +8,6 @@ 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}" /> diff --git a/templates/activities/BlankActivity/root/res/values-large/dimens.xml b/templates/activities/BlankActivity/root/res/values-large/dimens.xml deleted file mode 100644 index d8cd7c2..0000000 --- a/templates/activities/BlankActivity/root/res/values-large/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - <dimen name="padding_small">8dp</dimen> - <dimen name="padding_medium">16dp</dimen> - <dimen name="padding_large">16dp</dimen> -</resources> diff --git a/templates/activities/BlankActivity/root/res/values/dimens.xml b/templates/activities/BlankActivity/root/res/values/dimens.xml deleted file mode 100644 index d95a70f..0000000 --- a/templates/activities/BlankActivity/root/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - <dimen name="padding_small">8dp</dimen> - <dimen name="padding_medium">8dp</dimen> - <dimen name="padding_large">16dp</dimen> -</resources> diff --git a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl index 70cc3f7..6021829 100644 --- a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl +++ b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl @@ -3,8 +3,10 @@ package ${packageName}; import android.os.Bundle; import android.app.Activity; import android.view.Menu; +<#if parentActivityClass != ""> import android.view.MenuItem; import android.support.v4.app.NavUtils; +</#if> public class ${activityClass} extends Activity { @@ -22,5 +24,7 @@ public class ${activityClass} extends Activity { getMenuInflater().inflate(R.menu.${menuName}, menu); return true; } +<#if parentActivityClass != ""> <#include "include_onOptionsItemSelected.java.ftl"> +</#if> } diff --git a/templates/activities/BlankActivity/template.xml b/templates/activities/BlankActivity/template.xml index 00b8fb4..00a91e5 100644 --- a/templates/activities/BlankActivity/template.xml +++ b/templates/activities/BlankActivity/template.xml @@ -21,7 +21,7 @@ id="layoutName" name="Layout Name" type="string" - constraints="layout|unique" + constraints="layout|unique|nonempty" suggest="${activityToLayout(activityClass)}" default="activity_main" help="The name of the layout to create for the activity" /> @@ -43,7 +43,7 @@ id="parentActivityClass" name="Hierarchical Parent" type="string" - constraints="activity|exists" + constraints="activity|exists|empty" default="" help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> diff --git a/templates/activities/MasterDetailFlow/template.xml b/templates/activities/MasterDetailFlow/template.xml index 70a3995..f158d14 100644 --- a/templates/activities/MasterDetailFlow/template.xml +++ b/templates/activities/MasterDetailFlow/template.xml @@ -33,7 +33,7 @@ id="parentActivityClass" name="Hierarchical Parent" type="string" - constraints="activity|exists" + constraints="activity|exists|empty" default="" help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> diff --git a/templates/other/BroadcastReceiver/template.xml b/templates/other/BroadcastReceiver/template.xml index 09869ff..5a998f2 100644 --- a/templates/other/BroadcastReceiver/template.xml +++ b/templates/other/BroadcastReceiver/template.xml @@ -9,7 +9,7 @@ id="className" name="Class Name" type="string" - constraints="class|unique" + constraints="class|unique|nonempty" default="MyReceiver" /> <parameter diff --git a/templates/other/ContentProvider/template.xml b/templates/other/ContentProvider/template.xml index c6730d8..32a113a 100644 --- a/templates/other/ContentProvider/template.xml +++ b/templates/other/ContentProvider/template.xml @@ -9,7 +9,7 @@ id="className" name="Class Name" type="string" - constraints="class|unique" + constraints="class|unique|nonempty" default="MyContentProvider" /> <parameter diff --git a/templates/other/CustomView/template.xml b/templates/other/CustomView/template.xml index 9bd6d98..87a1b2a 100644 --- a/templates/other/CustomView/template.xml +++ b/templates/other/CustomView/template.xml @@ -18,7 +18,7 @@ id="viewClass" name="View Class" type="string" - constraints="class|unique" + constraints="class|unique|nonempty" default="MyView" help="By convention, should end in 'View'" /> diff --git a/templates/other/Service/template.xml b/templates/other/Service/template.xml index 3ce6e6a..bd22124 100644 --- a/templates/other/Service/template.xml +++ b/templates/other/Service/template.xml @@ -9,7 +9,7 @@ id="className" name="Class Name" type="string" - constraints="class|unique" + constraints="class|unique|nonempty" default="MyService" /> <parameter diff --git a/templates/projects/NewAndroidApplication/root/res/drawable-hdpi/ic_launcher.png b/templates/projects/NewAndroidApplication/root/res/drawable-hdpi/ic_launcher.png Binary files differindex fba1ff0..96a442e 100755 --- a/templates/projects/NewAndroidApplication/root/res/drawable-hdpi/ic_launcher.png +++ b/templates/projects/NewAndroidApplication/root/res/drawable-hdpi/ic_launcher.png diff --git a/templates/projects/NewAndroidApplication/root/res/drawable-mdpi/ic_launcher.png b/templates/projects/NewAndroidApplication/root/res/drawable-mdpi/ic_launcher.png Binary files differindex 72a445d..359047d 100755 --- a/templates/projects/NewAndroidApplication/root/res/drawable-mdpi/ic_launcher.png +++ b/templates/projects/NewAndroidApplication/root/res/drawable-mdpi/ic_launcher.png diff --git a/templates/projects/NewAndroidApplication/root/res/drawable-xhdpi/ic_launcher.png b/templates/projects/NewAndroidApplication/root/res/drawable-xhdpi/ic_launcher.png Binary files differindex 002e7b0..71c6d76 100755 --- a/templates/projects/NewAndroidApplication/root/res/drawable-xhdpi/ic_launcher.png +++ b/templates/projects/NewAndroidApplication/root/res/drawable-xhdpi/ic_launcher.png |