diff options
Diffstat (limited to 'templates/other/ContentProvider')
5 files changed, 112 insertions, 0 deletions
diff --git a/templates/other/ContentProvider/globals.xml.ftl b/templates/other/ContentProvider/globals.xml.ftl new file mode 100644 index 0000000..bfc27eb --- /dev/null +++ b/templates/other/ContentProvider/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/ContentProvider/recipe.xml.ftl b/templates/other/ContentProvider/recipe.xml.ftl new file mode 100644 index 0000000..6cdad82 --- /dev/null +++ b/templates/other/ContentProvider/recipe.xml.ftl @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<recipe> + <merge from="AndroidManifest.xml.ftl" /> + <instantiate from="src/app_package/ContentProvider.java.ftl" + to="${srcOut}/${className}.java" /> + <open file="${srcOut}/${className}.java" /> +</recipe> diff --git a/templates/other/ContentProvider/root/AndroidManifest.xml.ftl b/templates/other/ContentProvider/root/AndroidManifest.xml.ftl new file mode 100644 index 0000000..6fa4afc --- /dev/null +++ b/templates/other/ContentProvider/root/AndroidManifest.xml.ftl @@ -0,0 +1,11 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" > + + <application> + <provider android:name=".${className}" + android:authorities="${authorities}" + android:exported="${isExported?string}" + android:enabled="${isEnabled?string}" > + </provider> + </application> + +</manifest> diff --git a/templates/other/ContentProvider/root/src/app_package/ContentProvider.java.ftl b/templates/other/ContentProvider/root/src/app_package/ContentProvider.java.ftl new file mode 100644 index 0000000..e5b43b5 --- /dev/null +++ b/templates/other/ContentProvider/root/src/app_package/ContentProvider.java.ftl @@ -0,0 +1,50 @@ +package ${packageName}; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.database.Cursor; +import android.net.Uri; + +public class ${className} extends ContentProvider { + public ${className}() { + } + + @Override + public int delete(Uri uri, String selection, String[] selectionArgs) { + // Implement this to handle requests to delete one or more rows. + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public String getType(Uri uri) { + // TODO: Implement this to handle requests for the MIME type of the data + // at the given URI. + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public Uri insert(Uri uri, ContentValues values) { + // TODO: Implement this to handle requests to insert a new row. + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public boolean onCreate() { + // TODO: Implement this to initialize your content provider on startup. + return false; + } + + @Override + public Cursor query(Uri uri, String[] projection, String selection, + String[] selectionArgs, String sortOrder) { + // TODO: Implement this to handle query requests from clients. + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public int update(Uri uri, ContentValues values, String selection, + String[] selectionArgs) { + // TODO: Implement this to handle requests to update one or more rows. + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/templates/other/ContentProvider/template.xml b/templates/other/ContentProvider/template.xml new file mode 100644 index 0000000..c6730d8 --- /dev/null +++ b/templates/other/ContentProvider/template.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<template + format="1" + revision="1" + name="New Content Provider" + description="Creates a new content provider class"> + + <parameter + id="className" + name="Class Name" + type="string" + constraints="class|unique" + default="MyContentProvider" /> + + <parameter + id="authorities" + name="URI Authorities" + type="string" + constraints="nonempty" + default="" + help="A list of one or more URI authorities that identify data under the purview of the content provider. " /> + + <parameter + id="isExported" + name="Exported" + type="boolean" + default="true" + help="Whether or not the content provider can be used by components of other applications " /> + + <parameter + id="isEnabled" + name="Enabled" + type="boolean" + default="true" + help="Whether or not the content provider can be instantiated by the system " /> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> |