diff options
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> |