diff options
author | Tor Norbye <tnorbye@google.com> | 2012-06-21 18:20:13 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-06-21 18:20:13 -0700 |
commit | a85ff38b62bbeb35ace582729a0cf07088d3905a (patch) | |
tree | db1a865d1844684f39c349c808e7fc9f5d880381 /templates/other/BroadcastReceiver | |
parent | db2bdb124c713e8d56750e9c6406240023f2cc34 (diff) | |
download | sdk-a85ff38b62bbeb35ace582729a0cf07088d3905a.zip sdk-a85ff38b62bbeb35ace582729a0cf07088d3905a.tar.gz sdk-a85ff38b62bbeb35ace582729a0cf07088d3905a.tar.bz2 |
More template tweaks
Generalize the Add Activity wizard into an Add Android Object
wizard and move Custom View in there, such that it's no longer
a top level wizard. Also place service, content provider and
broadcast receivers there.
Fix indentation in simple activity template, and fix template
wizard such that it doesn't reset all the values when you
leave the page (to preview page or previous selector page)
and come back - unless the template has changed.
Change-Id: Idc1e7f76255d8f0010ccc09fbfc79915cc58690d
Diffstat (limited to 'templates/other/BroadcastReceiver')
5 files changed, 70 insertions, 0 deletions
diff --git a/templates/other/BroadcastReceiver/globals.xml.ftl b/templates/other/BroadcastReceiver/globals.xml.ftl new file mode 100644 index 0000000..bfc27eb --- /dev/null +++ b/templates/other/BroadcastReceiver/globals.xml.ftl @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<globals> + <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> +</globals> diff --git a/templates/other/BroadcastReceiver/recipe.xml.ftl b/templates/other/BroadcastReceiver/recipe.xml.ftl new file mode 100644 index 0000000..a9d2623 --- /dev/null +++ b/templates/other/BroadcastReceiver/recipe.xml.ftl @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<recipe> + <merge from="AndroidManifest.xml.ftl" /> + <instantiate from="src/app_package/BroadcastReceiver.java.ftl" + to="${srcOut}/${className}.java" /> + <open file="${srcOut}/${className}.java" /> +</recipe> diff --git a/templates/other/BroadcastReceiver/root/AndroidManifest.xml.ftl b/templates/other/BroadcastReceiver/root/AndroidManifest.xml.ftl new file mode 100644 index 0000000..d107f00 --- /dev/null +++ b/templates/other/BroadcastReceiver/root/AndroidManifest.xml.ftl @@ -0,0 +1,10 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" > + + <receiver> + <service android:name=".${className}" + android:exported="${isExported?string}" + android:enabled="${isEnabled?string}" > + </service> + </receiver> + +</manifest> diff --git a/templates/other/BroadcastReceiver/root/src/app_package/BroadcastReceiver.java.ftl b/templates/other/BroadcastReceiver/root/src/app_package/BroadcastReceiver.java.ftl new file mode 100644 index 0000000..560c132 --- /dev/null +++ b/templates/other/BroadcastReceiver/root/src/app_package/BroadcastReceiver.java.ftl @@ -0,0 +1,17 @@ +package ${packageName}; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class ${className} extends BroadcastReceiver { + public ${className}() { + } + + @Override + public void onReceive(Context context, Intent intent) { + // TODO: This method is called when the BroadcastReceiver is receiving + // an Intent broadcast. + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/templates/other/BroadcastReceiver/template.xml b/templates/other/BroadcastReceiver/template.xml new file mode 100644 index 0000000..09869ff --- /dev/null +++ b/templates/other/BroadcastReceiver/template.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<template + format="1" + revision="1" + name="New Broadcast Receiver" + description="Creates a new broadcast receiver class"> + + <parameter + id="className" + name="Class Name" + type="string" + constraints="class|unique" + default="MyReceiver" /> + + <parameter + id="isExported" + name="Exported" + type="boolean" + default="true" + help="Whether or not the broadcast receiver can receive messages from sources outside its application" /> + + <parameter + id="isEnabled" + name="Enabled" + type="boolean" + default="true" + help="Whether or not the broadcast receiver can be instantiated by the system" /> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> |