diff options
Diffstat (limited to 'templates')
160 files changed, 2159 insertions, 68 deletions
diff --git a/templates/activities/BlankActivity/globals.xml.ftl b/templates/activities/BlankActivity/globals.xml.ftl index 3a26abd..11aabd7 100644 --- a/templates/activities/BlankActivity/globals.xml.ftl +++ b/templates/activities/BlankActivity/globals.xml.ftl @@ -1,5 +1,8 @@ <?xml version="1.0"?> <globals> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> - <global id="menuName" value="${layoutName}" /> + <global id="resOut" value="res" /> + <global id="menuName" value="${classToResource(activityClass)}" /> </globals> diff --git a/templates/activities/BlankActivity/recipe.xml.ftl b/templates/activities/BlankActivity/recipe.xml.ftl index 8ed9f51..148b09d 100644 --- a/templates/activities/BlankActivity/recipe.xml.ftl +++ b/templates/activities/BlankActivity/recipe.xml.ftl @@ -1,24 +1,37 @@ <?xml version="1.0"?> <recipe> - <merge from="AndroidManifest.xml.ftl" /> + <merge from="AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> <instantiate from="res/menu/main.xml.ftl" - to="res/menu/${menuName}.xml" /> + to="${resOut}/menu/${menuName}.xml" /> - <merge from="res/values/strings.xml.ftl" /> + <merge from="res/values/strings.xml.ftl" + to="${resOut}/values/strings.xml" /> + + <merge from="res/values/dimens.xml" + to="${resOut}/values/dimens.xml" /> + <merge from="res/values-sw600dp/dimens.xml" + to="${resOut}/values-sw600dp/dimens.xml" /> + <merge from="res/values-sw720dp-land/dimens.xml" + to="${resOut}/values-sw720dp-land/dimens.xml" /> <!-- Decide what kind of layout to add (viewpager or not) --> <#if navType?contains("pager")> <instantiate from="res/layout/activity_pager.xml.ftl" - to="res/layout/${layoutName}.xml" /> + to="${resOut}/layout/${layoutName}.xml" /> + <instantiate from="res/layout/fragment_dummy.xml.ftl" + to="${resOut}/layout/fragment_${classToResource(activityClass)}_dummy.xml" /> <#elseif navType == "tabs" || navType == "dropdown"> <instantiate from="res/layout/activity_fragment_container.xml" - to="res/layout/${layoutName}.xml" /> + to="${resOut}/layout/${layoutName}.xml" /> + <instantiate from="res/layout/fragment_dummy.xml.ftl" + to="${resOut}/layout/fragment_${classToResource(activityClass)}_dummy.xml" /> <#else> <instantiate from="res/layout/activity_simple.xml.ftl" - to="res/layout/${layoutName}.xml" /> + to="${resOut}/layout/${layoutName}.xml" /> </#if> <!-- Decide which activity code to add --> @@ -40,5 +53,5 @@ </#if> - <open file="res/layout/${layoutName}.xml" /> + <open file="${resOut}/layout/${layoutName}.xml" /> </recipe> 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 5f97369..9ddd213 100644 --- a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl +++ b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl @@ -1,14 +1,16 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" - tools:context=".${activityClass}" android:layout_width=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if> - android:layout_height=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if> > + android:layout_height=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if> + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" + tools:context=".${activityClass}"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerHorizontal="true" - android:layout_centerVertical="true" android:text="@string/hello_world" /> </RelativeLayout> diff --git a/templates/activities/BlankActivity/root/res/layout/fragment_dummy.xml.ftl b/templates/activities/BlankActivity/root/res/layout/fragment_dummy.xml.ftl new file mode 100644 index 0000000..1f21998 --- /dev/null +++ b/templates/activities/BlankActivity/root/res/layout/fragment_dummy.xml.ftl @@ -0,0 +1,16 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if> + android:layout_height=<#if buildApi lt 8 >"fill_parent"<#else>"match_parent"</#if> + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" + tools:context=".${activityClass}$DummySectionFragment"> + + <TextView + android:id="@+id/section_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + +</RelativeLayout> diff --git a/templates/activities/BlankActivity/root/res/menu/main.xml.ftl b/templates/activities/BlankActivity/root/res/menu/main.xml.ftl index 41bdfee..e35aa1b 100644 --- a/templates/activities/BlankActivity/root/res/menu/main.xml.ftl +++ b/templates/activities/BlankActivity/root/res/menu/main.xml.ftl @@ -1,6 +1,6 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/menu_settings" - android:title="@string/menu_settings" + <item android:id="@+id/action_settings" + android:title="@string/action_settings" android:orderInCategory="100"<#if buildApi gte 11> android:showAsAction="never"</#if> /> </menu> diff --git a/templates/activities/BlankActivity/root/res/values-sw600dp/dimens.xml b/templates/activities/BlankActivity/root/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000..886b05f --- /dev/null +++ b/templates/activities/BlankActivity/root/res/values-sw600dp/dimens.xml @@ -0,0 +1,4 @@ +<resources> + <!-- Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw600dp devices (e.g. 7" tablets) here. --> +</resources> diff --git a/templates/activities/BlankActivity/root/res/values-sw720dp-land/dimens.xml b/templates/activities/BlankActivity/root/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000..00059fc --- /dev/null +++ b/templates/activities/BlankActivity/root/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,5 @@ +<resources> + <!-- Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. --> + <dimen name="activity_horizontal_margin">128dp</dimen> +</resources> diff --git a/templates/activities/BlankActivity/root/res/values/dimens.xml b/templates/activities/BlankActivity/root/res/values/dimens.xml new file mode 100644 index 0000000..47c8224 --- /dev/null +++ b/templates/activities/BlankActivity/root/res/values/dimens.xml @@ -0,0 +1,5 @@ +<resources> + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> +</resources> diff --git a/templates/activities/BlankActivity/root/res/values/strings.xml.ftl b/templates/activities/BlankActivity/root/res/values/strings.xml.ftl index 8c7636e..1c9bc8b 100644 --- a/templates/activities/BlankActivity/root/res/values/strings.xml.ftl +++ b/templates/activities/BlankActivity/root/res/values/strings.xml.ftl @@ -3,7 +3,7 @@ <string name="title_${activityToLayout(activityClass)}">${escapeXmlString(activityTitle)}</string> </#if> - <string name="menu_settings">Settings</string> + <string name="action_settings">Settings</string> <#if navType != "none"> <string name="title_section1">Section 1</string> 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 feae824..7edd647 100644 --- a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl +++ b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl @@ -6,6 +6,10 @@ import android.view.Menu; <#if parentActivityClass != ""> import android.view.MenuItem; import android.support.v4.app.NavUtils; +<#if minApiLevel < 11> +import android.annotation.TargetApi; +import android.os.Build; +</#if> </#if> public class ${activityClass} extends Activity { @@ -16,10 +20,22 @@ public class ${activityClass} extends Activity { setContentView(R.layout.${layoutName}); <#if parentActivityClass != ""> // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); + setupActionBar(); </#if> } + <#if parentActivityClass != ""> + /** + * Set up the {@link android.app.ActionBar}<#if minApiLevel < 11>, if the API is available</#if>. + */ + <#if minApiLevel < 11>@TargetApi(Build.VERSION_CODES.HONEYCOMB) + </#if>private void setupActionBar() { + <#if minApiLevel < 11>if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {</#if> + getActionBar().setDisplayHomeAsUpEnabled(true); + <#if minApiLevel < 11>}</#if> + } + </#if> + <#include "include_onCreateOptionsMenu.java.ftl"> <#include "include_onOptionsItemSelected.java.ftl"> diff --git a/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl b/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl index c455fc5..8eb1399 100644 --- a/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl +++ b/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl @@ -15,11 +15,9 @@ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Create a new TextView and set its text to the fragment's section - // number argument value. - TextView textView = new TextView(getActivity()); - textView.setGravity(Gravity.CENTER); - textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER))); - return textView; + View rootView = inflater.inflate(R.layout.fragment_${classToResource(activityClass)}_dummy, container, false); + TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label); + dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER))); + return rootView; } } diff --git a/templates/activities/BlankActivity/template.xml b/templates/activities/BlankActivity/template.xml index 6afe523..08a306d 100644 --- a/templates/activities/BlankActivity/template.xml +++ b/templates/activities/BlankActivity/template.xml @@ -57,9 +57,9 @@ default="none" help="The type of navigation to use for the activity" > <option id="none" default="true">None</option> - <option id="tabs" minApi="11">Tabs</option> - <option id="tabs_pager" minApi="11">Tabs + Swipe</option> - <option id="pager_strip" minApi="11">Swipe Views + Title Strip</option> + <!--<option id="tabs" minApi="11">Fixed Tabs</option>--> + <option id="tabs_pager" minApi="11">Fixed Tabs + Swipe</option> + <option id="pager_strip" minApi="11">Scrollable Tabs + Swipe</option> <option id="dropdown" minApi="11">Dropdown</option> </parameter> diff --git a/templates/activities/FullscreenActivity/globals.xml.ftl b/templates/activities/FullscreenActivity/globals.xml.ftl index a416d3a..6d73e17 100644 --- a/templates/activities/FullscreenActivity/globals.xml.ftl +++ b/templates/activities/FullscreenActivity/globals.xml.ftl @@ -1,5 +1,8 @@ <?xml version="1.0"?> <globals> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="resOut" value="res" /> <global id="simpleName" value="${activityToLayout(activityClass)}" /> </globals> diff --git a/templates/activities/FullscreenActivity/recipe.xml.ftl b/templates/activities/FullscreenActivity/recipe.xml.ftl index 1e41e5f..b3e1f20 100644 --- a/templates/activities/FullscreenActivity/recipe.xml.ftl +++ b/templates/activities/FullscreenActivity/recipe.xml.ftl @@ -1,16 +1,21 @@ <?xml version="1.0"?> <recipe> - <merge from="AndroidManifest.xml.ftl" /> + <merge from="AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> - <merge from="res/values/attrs.xml" /> - <merge from="res/values/colors.xml" /> - <merge from="res/values/styles.xml" /> - <merge from="res/values-v11/styles.xml" /> + <merge from="res/values/attrs.xml" + to="${resOut}/values/attrs.xml" /> + <merge from="res/values/colors.xml" + to="${resOut}/values/colors.xml" /> + <merge from="res/values/styles.xml" + to="${resOut}/values/styles.xml" /> + <merge from="res/values-v11/styles.xml" + to="${resOut}/values-v11/styles.xml" /> <instantiate from="res/layout/activity_fullscreen.xml.ftl" - to="res/layout/${layoutName}.xml" /> + to="${resOut}/layout/${layoutName}.xml" /> <merge from="res/values/strings.xml.ftl" - to="res/values/strings.xml" /> + to="${resOut}/values/strings.xml" /> <instantiate from="src/app_package/FullscreenActivity.java.ftl" to="${srcOut}/${activityClass}.java" /> @@ -21,5 +26,5 @@ <instantiate from="src/app_package/util/SystemUiHiderHoneycomb.java.ftl" to="${srcOut}/util/SystemUiHiderHoneycomb.java" /> - <open file="res/layout/${layoutName}.xml" /> + <open file="${resOut}/layout/${layoutName}.xml" /> </recipe> diff --git a/templates/activities/FullscreenActivity/root/res/values/attrs.xml b/templates/activities/FullscreenActivity/root/res/values/attrs.xml index 0201588..2cf1a1a 100644 --- a/templates/activities/FullscreenActivity/root/res/values/attrs.xml +++ b/templates/activities/FullscreenActivity/root/res/values/attrs.xml @@ -9,4 +9,4 @@ <attr name="buttonBarButtonStyle" format="reference" /> </declare-styleable> -</resources>
\ No newline at end of file +</resources> diff --git a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderHoneycomb.java.ftl b/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderHoneycomb.java.ftl index f2460eb..2e2d8a9 100644 --- a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderHoneycomb.java.ftl +++ b/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderHoneycomb.java.ftl @@ -64,7 +64,7 @@ public class SystemUiHiderHoneycomb extends SystemUiHiderBase { mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - mTestFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + mTestFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } } diff --git a/templates/activities/LoginActivity/globals.xml.ftl b/templates/activities/LoginActivity/globals.xml.ftl index cb45205..fbe8985 100644 --- a/templates/activities/LoginActivity/globals.xml.ftl +++ b/templates/activities/LoginActivity/globals.xml.ftl @@ -1,6 +1,9 @@ <?xml version="1.0"?> <globals> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> - <global id="menuName" value="${layoutName}" /> + <global id="resOut" value="res" /> + <global id="menuName" value="${classToResource(activityClass)}" /> <global id="simpleName" value="${activityToLayout(activityClass)}" /> </globals> diff --git a/templates/activities/LoginActivity/recipe.xml.ftl b/templates/activities/LoginActivity/recipe.xml.ftl index ece4285..58d823f 100644 --- a/templates/activities/LoginActivity/recipe.xml.ftl +++ b/templates/activities/LoginActivity/recipe.xml.ftl @@ -1,19 +1,22 @@ <?xml version="1.0"?> <recipe> - <merge from="AndroidManifest.xml.ftl" /> + <merge from="AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> - <merge from="res/values/styles.xml" /> - <merge from="res/values-large/styles.xml" /> + <merge from="res/values/styles.xml" + to="${resOut}/values/styles.xml" /> + <merge from="res/values-large/styles.xml" + to="${resOut}/values-large/styles.xml" /> <copy from="res/menu/activity_login.xml" - to="res/menu/${menuName}.xml" /> + to="${resOut}/menu/${menuName}.xml" /> <instantiate from="res/layout/activity_login.xml.ftl" - to="res/layout/${layoutName}.xml" /> + to="${resOut}/layout/${layoutName}.xml" /> <instantiate from="res/values/strings.xml.ftl" - to="res/values/strings_${simpleName}.xml" /> + to="${resOut}/values/strings_${simpleName}.xml" /> <instantiate from="src/app_package/LoginActivity.java.ftl" to="${srcOut}/${activityClass}.java" /> - <open file="res/layout/${layoutName}.xml" /> + <open file="${resOut}/layout/${layoutName}.xml" /> </recipe> diff --git a/templates/activities/LoginActivity/root/res/menu/activity_login.xml b/templates/activities/LoginActivity/root/res/menu/activity_login.xml index 1254dce..2965794 100644 --- a/templates/activities/LoginActivity/root/res/menu/activity_login.xml +++ b/templates/activities/LoginActivity/root/res/menu/activity_login.xml @@ -1,5 +1,5 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/menu_forgot_password" - android:title="@string/menu_forgot_password" + <item android:id="@+id/action_forgot_password" + android:title="@string/action_forgot_password" android:showAsAction="never" /> </menu> diff --git a/templates/activities/LoginActivity/root/res/values/strings.xml.ftl b/templates/activities/LoginActivity/root/res/values/strings.xml.ftl index 18bf85f..def1b2f 100644 --- a/templates/activities/LoginActivity/root/res/values/strings.xml.ftl +++ b/templates/activities/LoginActivity/root/res/values/strings.xml.ftl @@ -10,7 +10,7 @@ <string name="action_sign_in_register"><b>Sign in</b> or register</string> <string name="action_sign_in_short">Sign in</string> - <string name="menu_forgot_password">Recover lost password</string> + <string name="action_forgot_password">Recover lost password</string> <string name="login_progress_signing_in">Signing in…</string> diff --git a/templates/activities/MasterDetailFlow/globals.xml.ftl b/templates/activities/MasterDetailFlow/globals.xml.ftl index 952e278..415d60e 100644 --- a/templates/activities/MasterDetailFlow/globals.xml.ftl +++ b/templates/activities/MasterDetailFlow/globals.xml.ftl @@ -1,6 +1,9 @@ <?xml version="1.0"?> <globals> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="resOut" value="res" /> <global id="CollectionName" value="${extractLetters(objectKind)}List" /> <global id="collection_name" value="${extractLetters(objectKind?lower_case)}_list" /> <global id="DetailName" value="${extractLetters(objectKind)}Detail" /> diff --git a/templates/activities/MasterDetailFlow/recipe.xml.ftl b/templates/activities/MasterDetailFlow/recipe.xml.ftl index 8b09c84..c06e517 100644 --- a/templates/activities/MasterDetailFlow/recipe.xml.ftl +++ b/templates/activities/MasterDetailFlow/recipe.xml.ftl @@ -1,19 +1,23 @@ <?xml version="1.0"?> <recipe> - <merge from="AndroidManifest.xml.ftl" /> + <merge from="AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> - <merge from="res/values-large/refs.xml.ftl" /> - <merge from="res/values-sw600dp/refs.xml.ftl" /> - <merge from="res/values/strings.xml.ftl" /> + <merge from="res/values-large/refs.xml.ftl" + to="${resOut}/values-large/refs.xml" /> + <merge from="res/values-sw600dp/refs.xml.ftl" + to="${resOut}/values-sw600dp/refs.xml" /> + <merge from="res/values/strings.xml.ftl" + to="${resOut}/values/strings.xml" /> <instantiate from="res/layout/activity_content_detail.xml.ftl" - to="res/layout/activity_${detail_name}.xml" /> + to="${resOut}/layout/activity_${detail_name}.xml" /> <instantiate from="res/layout/activity_content_list.xml.ftl" - to="res/layout/activity_${collection_name}.xml" /> + to="${resOut}/layout/activity_${collection_name}.xml" /> <instantiate from="res/layout/activity_content_twopane.xml.ftl" - to="res/layout/activity_${extractLetters(objectKind?lower_case)}_twopane.xml" /> + to="${resOut}/layout/activity_${extractLetters(objectKind?lower_case)}_twopane.xml" /> <instantiate from="res/layout/fragment_content_detail.xml.ftl" - to="res/layout/fragment_${detail_name}.xml" /> + to="${resOut}/layout/fragment_${detail_name}.xml" /> <instantiate from="src/app_package/ContentDetailActivity.java.ftl" to="${srcOut}/${DetailName}Activity.java" /> diff --git a/templates/activities/SettingsActivity/globals.xml.ftl b/templates/activities/SettingsActivity/globals.xml.ftl index a416d3a..6d73e17 100644 --- a/templates/activities/SettingsActivity/globals.xml.ftl +++ b/templates/activities/SettingsActivity/globals.xml.ftl @@ -1,5 +1,8 @@ <?xml version="1.0"?> <globals> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="resOut" value="res" /> <global id="simpleName" value="${activityToLayout(activityClass)}" /> </globals> diff --git a/templates/activities/SettingsActivity/recipe.xml.ftl b/templates/activities/SettingsActivity/recipe.xml.ftl index e315963..6f68147 100644 --- a/templates/activities/SettingsActivity/recipe.xml.ftl +++ b/templates/activities/SettingsActivity/recipe.xml.ftl @@ -1,14 +1,19 @@ <?xml version="1.0"?> <recipe> - <merge from="AndroidManifest.xml.ftl" /> + <merge from="AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> - <copy from="res/xml/pref_data_sync.xml" /> - <copy from="res/xml/pref_general.xml" /> - <merge from="res/xml/pref_headers.xml.ftl" /> - <copy from="res/xml/pref_notification.xml" /> + <copy from="res/xml/pref_data_sync.xml" + to="${resOut}/xml/pref_data_sync.xml" /> + <copy from="res/xml/pref_general.xml" + to="${resOut}/xml/pref_general.xml" /> + <merge from="res/xml/pref_headers.xml.ftl" + to="${resOut}/xml/pref_headers.xml" /> + <copy from="res/xml/pref_notification.xml" + to="${resOut}/xml/pref_notification.xml" /> <instantiate from="res/values/strings.xml.ftl" - to="res/values/strings_${simpleName}.xml" /> + to="${resOut}/values/strings_${simpleName}.xml" /> <instantiate from="src/app_package/SettingsActivity.java.ftl" to="${srcOut}/${activityClass}.java" /> diff --git a/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.jar b/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..8c0fb64 --- /dev/null +++ b/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.jar diff --git a/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.properties b/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..45925d9 --- /dev/null +++ b/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-rc-1-bin.zip diff --git a/templates/gradle/wrapper/gradlew b/templates/gradle/wrapper/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/templates/gradle/wrapper/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/templates/gradle/wrapper/gradlew.bat b/templates/gradle/wrapper/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/templates/gradle/wrapper/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/templates/ic_launcher_xxhdpi.png b/templates/ic_launcher_xxhdpi.png Binary files differnew file mode 100644 index 0000000..549135a --- /dev/null +++ b/templates/ic_launcher_xxhdpi.png diff --git a/templates/other/AppWidget/globals.xml.ftl b/templates/other/AppWidget/globals.xml.ftl new file mode 100644 index 0000000..ac85374 --- /dev/null +++ b/templates/other/AppWidget/globals.xml.ftl @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<globals> + <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="class_name" value="${camelCaseToUnderscore(className)}" /> +</globals> diff --git a/templates/other/AppWidget/recipe.xml.ftl b/templates/other/AppWidget/recipe.xml.ftl new file mode 100644 index 0000000..876b7b0 --- /dev/null +++ b/templates/other/AppWidget/recipe.xml.ftl @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<recipe> + + <merge from="AndroidManifest.xml.ftl" /> + + <copy from="res/drawable-nodpi/example_appwidget_preview.png" /> + <instantiate from="res/layout/appwidget.xml" + to="res/layout/${class_name}.xml" /> + + + <#if configurable> + <instantiate from="res/layout/appwidget_configure.xml" + to="res/layout/${class_name}_configure.xml" /> + </#if> + + <instantiate from="res/xml/appwidget_info.xml.ftl" + to="res/xml/${class_name}_info.xml" /> + <merge from="res/values/strings.xml.ftl" /> + <merge from="res/values-v14/dimens.xml" /> + <merge from="res/values/dimens.xml" /> + + <instantiate from="src/app_package/AppWidget.java.ftl" + to="${srcOut}/${className}.java" /> + + <#if configurable> + <instantiate from="src/app_package/AppWidgetConfigureActivity.java.ftl" + to="${srcOut}/${className}ConfigureActivity.java" /> + </#if> + + <open file="${srcOut}/${className}.java" /> +</recipe> diff --git a/templates/other/AppWidget/root/AndroidManifest.xml.ftl b/templates/other/AppWidget/root/AndroidManifest.xml.ftl new file mode 100644 index 0000000..8b96d56 --- /dev/null +++ b/templates/other/AppWidget/root/AndroidManifest.xml.ftl @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <application> + + <receiver android:name=".${className}" > + <intent-filter> + <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> + </intent-filter> + + <meta-data + android:name="android.appwidget.provider" + android:resource="@xml/${class_name}_info" /> + </receiver> + + <#if configurable> + <activity android:name=".${className}ConfigureActivity" > + <intent-filter> + <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> + </intent-filter> + </activity> + </#if> + </application> + +</manifest>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/res/drawable-nodpi/example_appwidget_preview.png b/templates/other/AppWidget/root/res/drawable-nodpi/example_appwidget_preview.png Binary files differnew file mode 100644 index 0000000..894b069 --- /dev/null +++ b/templates/other/AppWidget/root/res/drawable-nodpi/example_appwidget_preview.png diff --git a/templates/other/AppWidget/root/res/layout/appwidget.xml b/templates/other/AppWidget/root/res/layout/appwidget.xml new file mode 100644 index 0000000..3a00464 --- /dev/null +++ b/templates/other/AppWidget/root/res/layout/appwidget.xml @@ -0,0 +1,21 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="@dimen/widget_margin" + android:background="#09C" > + + <TextView + android:id="@+id/appwidget_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:text="@string/appwidget_text" + android:textColor="#ffffff" + android:textSize="24sp" + android:textStyle="bold|italic" + android:layout_margin="8dp" + android:contentDescription="@string/appwidget_text" + android:background="#09C"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/res/layout/appwidget_configure.xml b/templates/other/AppWidget/root/res/layout/appwidget_configure.xml new file mode 100644 index 0000000..8ddc335 --- /dev/null +++ b/templates/other/AppWidget/root/res/layout/appwidget_configure.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="16dp"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/configure" + android:layout_marginBottom="8dp" /> + + <EditText + android:id="@+id/appwidget_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="text" /> + + <Button + android:id="@+id/add_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/add_widget" + android:layout_marginTop="8dp" /> + +</LinearLayout>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/res/values-v14/dimens.xml b/templates/other/AppWidget/root/res/values-v14/dimens.xml new file mode 100644 index 0000000..4db8c59 --- /dev/null +++ b/templates/other/AppWidget/root/res/values-v14/dimens.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <!-- +Refer to App Widget Documentation for margin information +http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout + --> + <dimen name="widget_margin">0dp</dimen> + +</resources>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/res/values/dimens.xml b/templates/other/AppWidget/root/res/values/dimens.xml new file mode 100644 index 0000000..fdececf --- /dev/null +++ b/templates/other/AppWidget/root/res/values/dimens.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <!-- +Refer to App Widget Documentation for margin information +http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout + --> + <dimen name="widget_margin">8dp</dimen> + +</resources>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/res/values/strings.xml.ftl b/templates/other/AppWidget/root/res/values/strings.xml.ftl new file mode 100644 index 0000000..66c06bc --- /dev/null +++ b/templates/other/AppWidget/root/res/values/strings.xml.ftl @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="appwidget_text">EXAMPLE</string> + <#if configurable> + <string name="configure">Configure</string> + </#if> + <string name="add_widget">Add widget</string> +</resources>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/res/xml/appwidget_info.xml.ftl b/templates/other/AppWidget/root/res/xml/appwidget_info.xml.ftl new file mode 100644 index 0000000..75791be --- /dev/null +++ b/templates/other/AppWidget/root/res/xml/appwidget_info.xml.ftl @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" + android:minWidth="${-30 + 70 * minWidth?number}dp" + android:minHeight="${-30 + 70 * minHeight?number}dp" + android:updatePeriodMillis="86400000" + android:previewImage="@drawable/example_appwidget_preview" + android:initialLayout="@layout/${class_name}" +<#if configurable> + android:configure="${packageName}.${className}ConfigureActivity" +</#if> +<#if resizable='both'> + android:resizeMode="horizontal|vertical" +<#elseif resizable='horizontal'> + android:resizeMode="horizontal" +<#elseif resizable='vertical'> + android:resizeMode="vertical" +<#elseif resizable='none'> +</#if> +<#if placement='both'> + android:widgetCategory="home_screen|keyguard" +<#elseif placement='homescreen'> + android:widgetCategory="home_screen" +<#elseif placement='keyguard'> + android:widgetCategory="keyguard" +</#if> + android:initialKeyguardLayout="@layout/${class_name}"> +</appwidget-provider>
\ No newline at end of file diff --git a/templates/other/AppWidget/root/src/app_package/AppWidget.java.ftl b/templates/other/AppWidget/root/src/app_package/AppWidget.java.ftl new file mode 100644 index 0000000..d86b0b5 --- /dev/null +++ b/templates/other/AppWidget/root/src/app_package/AppWidget.java.ftl @@ -0,0 +1,63 @@ +package ${packageName}; + +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.Context; +import android.widget.RemoteViews; + +/** + * Implementation of App Widget functionality. +<#if configurable> + * App Widget Configuration implemented in {@link ${className}ConfigureActivity ${className}ConfigureActivity} +</#if> + */ +public class ${className} extends AppWidgetProvider { + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + // There may be multiple widgets active, so update all of them + final int N = appWidgetIds.length; + for (int i=0; i<N; i++) { + updateAppWidget(context, appWidgetManager, appWidgetIds[i]); + } + } + +<#if configurable> + @Override + public void onDeleted(Context context, int[] appWidgetIds) { + // When the user deletes the widget, delete the preference associated with it. + final int N = appWidgetIds.length; + for (int i=0; i<N; i++) { + ${className}ConfigureActivity.deleteTitlePref(context, appWidgetIds[i]); + } + } +</#if> + + @Override + public void onEnabled(Context context) { + // Enter relevant functionality for when the first widget is created + } + + @Override + public void onDisabled(Context context) { + // Enter relevant functionality for when the last widget is disabled + } + + static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, + int appWidgetId) { + +<#if configurable> + CharSequence widgetText = ${className}ConfigureActivity.loadTitlePref(context, appWidgetId); +<#else> + CharSequence widgetText = context.getString(R.string.appwidget_text); +</#if> + // Construct the RemoteViews object + RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.${class_name}); + views.setTextViewText(R.id.appwidget_text, widgetText); + + // Instruct the widget manager to update the widget + appWidgetManager.updateAppWidget(appWidgetId, views); + } +} + + diff --git a/templates/other/AppWidget/root/src/app_package/AppWidgetConfigureActivity.java.ftl b/templates/other/AppWidget/root/src/app_package/AppWidgetConfigureActivity.java.ftl new file mode 100644 index 0000000..3c2be67 --- /dev/null +++ b/templates/other/AppWidget/root/src/app_package/AppWidgetConfigureActivity.java.ftl @@ -0,0 +1,102 @@ +package ${packageName}; + +import android.app.Activity; +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; + +/** + * The configuration screen for the {@link ${className} ${className}} AppWidget. + */ +public class ${className}ConfigureActivity extends Activity { + + int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; + EditText mAppWidgetText; + private static final String PREFS_NAME = "${packageName}.${className}"; + private static final String PREF_PREFIX_KEY = "appwidget_"; + + public ${className}ConfigureActivity() { + super(); + } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + // Set the result to CANCELED. This will cause the widget host to cancel + // out of the widget placement if the user presses the back button. + setResult(RESULT_CANCELED); + + setContentView(R.layout.${class_name}_configure); + mAppWidgetText = (EditText)findViewById(R.id.appwidget_text); + findViewById(R.id.add_button).setOnClickListener(mOnClickListener); + + // Find the widget id from the intent. + Intent intent = getIntent(); + Bundle extras = intent.getExtras(); + if (extras != null) { + mAppWidgetId = extras.getInt( + AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + } + + // If this activity was started with an intent without an app widget ID, finish with an error. + if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { + finish(); + return; + } + + mAppWidgetText.setText(loadTitlePref(${className}ConfigureActivity.this, mAppWidgetId)); + } + + View.OnClickListener mOnClickListener = new View.OnClickListener() { + public void onClick(View v) { + final Context context = ${className}ConfigureActivity.this; + + // When the button is clicked, store the string locally + String widgetText = mAppWidgetText.getText().toString(); + saveTitlePref(context,mAppWidgetId,widgetText); + + // It is the responsibility of the configuration activity to update the app widget + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); + ${className}.updateAppWidget(context, appWidgetManager, mAppWidgetId); + + // Make sure we pass back the original appWidgetId + Intent resultValue = new Intent(); + resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); + setResult(RESULT_OK, resultValue); + finish(); + } + }; + + // Write the prefix to the SharedPreferences object for this widget + static void saveTitlePref(Context context, int appWidgetId, String text) { + SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit(); + prefs.putString(PREF_PREFIX_KEY + appWidgetId, text); + prefs.commit(); + } + + // Read the prefix from the SharedPreferences object for this widget. + // If there is no preference saved, get the default from a resource + static String loadTitlePref(Context context, int appWidgetId) { + SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, 0); + String titleValue = prefs.getString(PREF_PREFIX_KEY + appWidgetId, null); + if (titleValue != null) { + return titleValue; + } else { + return context.getString(R.string.appwidget_text); + } + } + + static void deleteTitlePref(Context context, int appWidgetId) { + SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit(); + prefs.remove(PREF_PREFIX_KEY + appWidgetId); + prefs.commit(); + } +} + + + diff --git a/templates/other/AppWidget/template.xml b/templates/other/AppWidget/template.xml new file mode 100644 index 0000000..f071363 --- /dev/null +++ b/templates/other/AppWidget/template.xml @@ -0,0 +1,148 @@ +<?xml version="1.0"?> +<template + format="3" + revision="1" + name="New App Widget" + description="Creates a new App Widget" + minApi="4" + minBuildApi="16"> + + <category value="Other" /> + + <parameter + id="className" + name="Class Name" + type="string" + constraints="class|unique|nonempty" + default="NewAppWidget" + help="The name of the App Widget to create" /> + + <parameter + id="placement" + name="Placement" + type="enum" + default="homescreen" + help="Make the widget available on the Home-screen and/or on the Keyguard. Keyguard placement is only supported in Android 4.2 and above; this setting is ignored on earlier versions and defaults to Home-screen."> + <option id="both">Home-screen and Keyguard</option> + <option id="homescreen" default="true" >Home-screen only</option> + <option id="keyguard" >Keyguard only (API 17+)</option> + </parameter> + + <parameter + id="resizable" + name="Resizable (API 12+)" + type="enum" + default="both" + help="Allow the user to resize the widget. Feature only available on Android 3.1 and above."> + <option id="both" default="true">Horizontally and vertically</option> + <option id="horizontal">Only horizontally</option> + <option id="vertical" >Only vertically</option> + <option id="none">Not resizable</option> + </parameter> + + <parameter + id="minWidth" + name="Minimum Width (cells)" + type="enum" + default="1"> + <option id="1" default="true">1</option> + <option id="2" >2</option> + <option id="3" >3</option> + <option id="4" >4</option> + </parameter> + + <parameter + id="minHeight" + name="Minimum Height (cells)" + type="enum" + default="1"> + <option id="1" default="true">1</option> + <option id="2" >2</option> + <option id="3" >3</option> + <option id="4" >4</option> + </parameter> + + <parameter + id="configurable" + name="Configuration Screen" + type="boolean" + default="false" + help="Generates a widget configuration activity" /> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + + + <thumbs> + <thumb>thumbs/template_widget_3x3_vh.png</thumb> + + <thumb minWidth="1" minHeight="1" resizable="none" >thumbs/template_widget_1x1.png</thumb> + <thumb minWidth="2" minHeight="1" resizable="none" >thumbs/template_widget_2x1.png</thumb> + <thumb minWidth="3" minHeight="1" resizable="none" >thumbs/template_widget_3x1.png</thumb> + <thumb minWidth="4" minHeight="1" resizable="none" >thumbs/template_widget_4x1.png</thumb> + <thumb minWidth="1" minHeight="2" resizable="none" >thumbs/template_widget_1x2.png</thumb> + <thumb minWidth="2" minHeight="2" resizable="none" >thumbs/template_widget_2x2.png</thumb> + <thumb minWidth="3" minHeight="2" resizable="none" >thumbs/template_widget_3x2.png</thumb> + <thumb minWidth="4" minHeight="2" resizable="none" >thumbs/template_widget_4x2.png</thumb> + <thumb minWidth="1" minHeight="3" resizable="none" >thumbs/template_widget_1x3.png</thumb> + <thumb minWidth="2" minHeight="3" resizable="none" >thumbs/template_widget_2x3.png</thumb> + <thumb minWidth="3" minHeight="3" resizable="none" >thumbs/template_widget_3x3.png</thumb> + <thumb minWidth="4" minHeight="3" resizable="none" >thumbs/template_widget_4x3.png</thumb> + <thumb minWidth="1" minHeight="4" resizable="none" >thumbs/template_widget_1x4.png</thumb> + <thumb minWidth="2" minHeight="4" resizable="none" >thumbs/template_widget_2x4.png</thumb> + <thumb minWidth="3" minHeight="4" resizable="none" >thumbs/template_widget_3x4.png</thumb> + <thumb minWidth="4" minHeight="4" resizable="none" >thumbs/template_widget_4x4.png</thumb> + + <thumb minWidth="1" minHeight="1" resizable="horizontal">thumbs/template_widget_1x1_h.png</thumb> + <thumb minWidth="2" minHeight="1" resizable="horizontal">thumbs/template_widget_2x1_h.png</thumb> + <thumb minWidth="3" minHeight="1" resizable="horizontal">thumbs/template_widget_3x1_h.png</thumb> + <thumb minWidth="4" minHeight="1" resizable="horizontal">thumbs/template_widget_4x1_h.png</thumb> + <thumb minWidth="1" minHeight="2" resizable="horizontal">thumbs/template_widget_1x2_h.png</thumb> + <thumb minWidth="2" minHeight="2" resizable="horizontal">thumbs/template_widget_2x2_h.png</thumb> + <thumb minWidth="3" minHeight="2" resizable="horizontal">thumbs/template_widget_3x2_h.png</thumb> + <thumb minWidth="4" minHeight="2" resizable="horizontal">thumbs/template_widget_4x2_h.png</thumb> + <thumb minWidth="1" minHeight="3" resizable="horizontal">thumbs/template_widget_1x3_h.png</thumb> + <thumb minWidth="2" minHeight="3" resizable="horizontal">thumbs/template_widget_2x3_h.png</thumb> + <thumb minWidth="3" minHeight="3" resizable="horizontal">thumbs/template_widget_3x3_h.png</thumb> + <thumb minWidth="4" minHeight="3" resizable="horizontal">thumbs/template_widget_4x3_h.png</thumb> + <thumb minWidth="1" minHeight="4" resizable="horizontal">thumbs/template_widget_1x4_h.png</thumb> + <thumb minWidth="2" minHeight="4" resizable="horizontal">thumbs/template_widget_2x4_h.png</thumb> + <thumb minWidth="3" minHeight="4" resizable="horizontal">thumbs/template_widget_3x4_h.png</thumb> + <thumb minWidth="4" minHeight="4" resizable="horizontal">thumbs/template_widget_4x4_h.png</thumb> + + <thumb minWidth="1" minHeight="1" resizable="vertical" >thumbs/template_widget_1x1_v.png</thumb> + <thumb minWidth="2" minHeight="1" resizable="vertical" >thumbs/template_widget_2x1_v.png</thumb> + <thumb minWidth="3" minHeight="1" resizable="vertical" >thumbs/template_widget_3x1_v.png</thumb> + <thumb minWidth="4" minHeight="1" resizable="vertical" >thumbs/template_widget_4x1_v.png</thumb> + <thumb minWidth="1" minHeight="2" resizable="vertical" >thumbs/template_widget_1x2_v.png</thumb> + <thumb minWidth="2" minHeight="2" resizable="vertical" >thumbs/template_widget_2x2_v.png</thumb> + <thumb minWidth="3" minHeight="2" resizable="vertical" >thumbs/template_widget_3x2_v.png</thumb> + <thumb minWidth="4" minHeight="2" resizable="vertical" >thumbs/template_widget_4x2_v.png</thumb> + <thumb minWidth="1" minHeight="3" resizable="vertical" >thumbs/template_widget_1x3_v.png</thumb> + <thumb minWidth="2" minHeight="3" resizable="vertical" >thumbs/template_widget_2x3_v.png</thumb> + <thumb minWidth="3" minHeight="3" resizable="vertical" >thumbs/template_widget_3x3_v.png</thumb> + <thumb minWidth="4" minHeight="3" resizable="vertical" >thumbs/template_widget_4x3_v.png</thumb> + <thumb minWidth="1" minHeight="4" resizable="vertical" >thumbs/template_widget_1x4_v.png</thumb> + <thumb minWidth="2" minHeight="4" resizable="vertical" >thumbs/template_widget_2x4_v.png</thumb> + <thumb minWidth="3" minHeight="4" resizable="vertical" >thumbs/template_widget_3x4_v.png</thumb> + <thumb minWidth="4" minHeight="4" resizable="vertical" >thumbs/template_widget_4x4_v.png</thumb> + + <thumb minWidth="1" minHeight="1" resizable="both" >thumbs/template_widget_1x1_vh.png</thumb> + <thumb minWidth="2" minHeight="1" resizable="both" >thumbs/template_widget_2x1_vh.png</thumb> + <thumb minWidth="3" minHeight="1" resizable="both" >thumbs/template_widget_3x1_vh.png</thumb> + <thumb minWidth="4" minHeight="1" resizable="both" >thumbs/template_widget_4x1_vh.png</thumb> + <thumb minWidth="1" minHeight="2" resizable="both" >thumbs/template_widget_1x2_vh.png</thumb> + <thumb minWidth="2" minHeight="2" resizable="both" >thumbs/template_widget_2x2_vh.png</thumb> + <thumb minWidth="3" minHeight="2" resizable="both" >thumbs/template_widget_3x2_vh.png</thumb> + <thumb minWidth="4" minHeight="2" resizable="both" >thumbs/template_widget_4x2_vh.png</thumb> + <thumb minWidth="1" minHeight="3" resizable="both" >thumbs/template_widget_1x3_vh.png</thumb> + <thumb minWidth="2" minHeight="3" resizable="both" >thumbs/template_widget_2x3_vh.png</thumb> + <thumb minWidth="3" minHeight="3" resizable="both" >thumbs/template_widget_3x3_vh.png</thumb> + <thumb minWidth="4" minHeight="3" resizable="both" >thumbs/template_widget_4x3_vh.png</thumb> + <thumb minWidth="1" minHeight="4" resizable="both" >thumbs/template_widget_1x4_vh.png</thumb> + <thumb minWidth="2" minHeight="4" resizable="both" >thumbs/template_widget_2x4_vh.png</thumb> + <thumb minWidth="3" minHeight="4" resizable="both" >thumbs/template_widget_3x4_vh.png</thumb> + <thumb minWidth="4" minHeight="4" resizable="both" >thumbs/template_widget_4x4_vh.png</thumb> + </thumbs> + +</template> diff --git a/templates/other/AppWidget/thumbs/template_widget_1x1.png b/templates/other/AppWidget/thumbs/template_widget_1x1.png Binary files differnew file mode 100644 index 0000000..8b34a24 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x1.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x1_h.png b/templates/other/AppWidget/thumbs/template_widget_1x1_h.png Binary files differnew file mode 100644 index 0000000..38ce687 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x1_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x1_v.png b/templates/other/AppWidget/thumbs/template_widget_1x1_v.png Binary files differnew file mode 100644 index 0000000..0aedac7 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x1_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x1_vh.png b/templates/other/AppWidget/thumbs/template_widget_1x1_vh.png Binary files differnew file mode 100644 index 0000000..301ee0f --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x1_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x2.png b/templates/other/AppWidget/thumbs/template_widget_1x2.png Binary files differnew file mode 100644 index 0000000..0e4181d --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x2.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x2_h.png b/templates/other/AppWidget/thumbs/template_widget_1x2_h.png Binary files differnew file mode 100644 index 0000000..37f3b94 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x2_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x2_v.png b/templates/other/AppWidget/thumbs/template_widget_1x2_v.png Binary files differnew file mode 100644 index 0000000..2d13903 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x2_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x2_vh.png b/templates/other/AppWidget/thumbs/template_widget_1x2_vh.png Binary files differnew file mode 100644 index 0000000..431f929 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x2_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x3.png b/templates/other/AppWidget/thumbs/template_widget_1x3.png Binary files differnew file mode 100644 index 0000000..b0fb55a --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x3.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x3_h.png b/templates/other/AppWidget/thumbs/template_widget_1x3_h.png Binary files differnew file mode 100644 index 0000000..14fdc46 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x3_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x3_v.png b/templates/other/AppWidget/thumbs/template_widget_1x3_v.png Binary files differnew file mode 100644 index 0000000..136b8de --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x3_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x3_vh.png b/templates/other/AppWidget/thumbs/template_widget_1x3_vh.png Binary files differnew file mode 100644 index 0000000..5e18856 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x3_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x4.png b/templates/other/AppWidget/thumbs/template_widget_1x4.png Binary files differnew file mode 100644 index 0000000..2922d34 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x4.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x4_h.png b/templates/other/AppWidget/thumbs/template_widget_1x4_h.png Binary files differnew file mode 100644 index 0000000..462c802 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x4_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x4_v.png b/templates/other/AppWidget/thumbs/template_widget_1x4_v.png Binary files differnew file mode 100644 index 0000000..f239e73 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x4_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_1x4_vh.png b/templates/other/AppWidget/thumbs/template_widget_1x4_vh.png Binary files differnew file mode 100644 index 0000000..b05e168 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_1x4_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x1.png b/templates/other/AppWidget/thumbs/template_widget_2x1.png Binary files differnew file mode 100644 index 0000000..9e14ef8 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x1.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x1_h.png b/templates/other/AppWidget/thumbs/template_widget_2x1_h.png Binary files differnew file mode 100644 index 0000000..3a8019e --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x1_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x1_v.png b/templates/other/AppWidget/thumbs/template_widget_2x1_v.png Binary files differnew file mode 100644 index 0000000..d09ff28 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x1_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x1_vh.png b/templates/other/AppWidget/thumbs/template_widget_2x1_vh.png Binary files differnew file mode 100644 index 0000000..b6093e1 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x1_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x2.png b/templates/other/AppWidget/thumbs/template_widget_2x2.png Binary files differnew file mode 100644 index 0000000..2894704 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x2.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x2_h.png b/templates/other/AppWidget/thumbs/template_widget_2x2_h.png Binary files differnew file mode 100644 index 0000000..a2ab77c --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x2_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x2_v.png b/templates/other/AppWidget/thumbs/template_widget_2x2_v.png Binary files differnew file mode 100644 index 0000000..c09f1f7 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x2_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x2_vh.png b/templates/other/AppWidget/thumbs/template_widget_2x2_vh.png Binary files differnew file mode 100644 index 0000000..21becb2 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x2_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x3.png b/templates/other/AppWidget/thumbs/template_widget_2x3.png Binary files differnew file mode 100644 index 0000000..3226127 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x3.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x3_h.png b/templates/other/AppWidget/thumbs/template_widget_2x3_h.png Binary files differnew file mode 100644 index 0000000..db2037a --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x3_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x3_v.png b/templates/other/AppWidget/thumbs/template_widget_2x3_v.png Binary files differnew file mode 100644 index 0000000..af21176 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x3_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x3_vh.png b/templates/other/AppWidget/thumbs/template_widget_2x3_vh.png Binary files differnew file mode 100644 index 0000000..e0edfb4 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x3_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x4.png b/templates/other/AppWidget/thumbs/template_widget_2x4.png Binary files differnew file mode 100644 index 0000000..dfcda22 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x4.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x4_h.png b/templates/other/AppWidget/thumbs/template_widget_2x4_h.png Binary files differnew file mode 100644 index 0000000..dc21139 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x4_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x4_v.png b/templates/other/AppWidget/thumbs/template_widget_2x4_v.png Binary files differnew file mode 100644 index 0000000..6bfc884 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x4_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_2x4_vh.png b/templates/other/AppWidget/thumbs/template_widget_2x4_vh.png Binary files differnew file mode 100644 index 0000000..922aeee --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_2x4_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x1.png b/templates/other/AppWidget/thumbs/template_widget_3x1.png Binary files differnew file mode 100644 index 0000000..bb394b9 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x1.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x1_h.png b/templates/other/AppWidget/thumbs/template_widget_3x1_h.png Binary files differnew file mode 100644 index 0000000..47b19c3 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x1_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x1_v.png b/templates/other/AppWidget/thumbs/template_widget_3x1_v.png Binary files differnew file mode 100644 index 0000000..5575850 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x1_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x1_vh.png b/templates/other/AppWidget/thumbs/template_widget_3x1_vh.png Binary files differnew file mode 100644 index 0000000..c4a5f3f --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x1_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x2.png b/templates/other/AppWidget/thumbs/template_widget_3x2.png Binary files differnew file mode 100644 index 0000000..200fba4 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x2.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x2_h.png b/templates/other/AppWidget/thumbs/template_widget_3x2_h.png Binary files differnew file mode 100644 index 0000000..b027430 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x2_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x2_v.png b/templates/other/AppWidget/thumbs/template_widget_3x2_v.png Binary files differnew file mode 100644 index 0000000..b350ae8 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x2_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x2_vh.png b/templates/other/AppWidget/thumbs/template_widget_3x2_vh.png Binary files differnew file mode 100644 index 0000000..129b706 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x2_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x3.png b/templates/other/AppWidget/thumbs/template_widget_3x3.png Binary files differnew file mode 100644 index 0000000..30dfb4b --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x3.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x3_h.png b/templates/other/AppWidget/thumbs/template_widget_3x3_h.png Binary files differnew file mode 100644 index 0000000..9b062e9 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x3_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x3_v.png b/templates/other/AppWidget/thumbs/template_widget_3x3_v.png Binary files differnew file mode 100644 index 0000000..af8b494 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x3_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x3_vh.png b/templates/other/AppWidget/thumbs/template_widget_3x3_vh.png Binary files differnew file mode 100644 index 0000000..bc92413 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x3_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x4.png b/templates/other/AppWidget/thumbs/template_widget_3x4.png Binary files differnew file mode 100644 index 0000000..1759b62 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x4.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x4_h.png b/templates/other/AppWidget/thumbs/template_widget_3x4_h.png Binary files differnew file mode 100644 index 0000000..e09fa7e --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x4_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x4_v.png b/templates/other/AppWidget/thumbs/template_widget_3x4_v.png Binary files differnew file mode 100644 index 0000000..e6451fe --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x4_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_3x4_vh.png b/templates/other/AppWidget/thumbs/template_widget_3x4_vh.png Binary files differnew file mode 100644 index 0000000..376611f --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_3x4_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x1.png b/templates/other/AppWidget/thumbs/template_widget_4x1.png Binary files differnew file mode 100644 index 0000000..75031c8 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x1.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x1_h.png b/templates/other/AppWidget/thumbs/template_widget_4x1_h.png Binary files differnew file mode 100644 index 0000000..7a4b81f --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x1_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x1_v.png b/templates/other/AppWidget/thumbs/template_widget_4x1_v.png Binary files differnew file mode 100644 index 0000000..2c8c604 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x1_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x1_vh.png b/templates/other/AppWidget/thumbs/template_widget_4x1_vh.png Binary files differnew file mode 100644 index 0000000..0b43cd7 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x1_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x2.png b/templates/other/AppWidget/thumbs/template_widget_4x2.png Binary files differnew file mode 100644 index 0000000..8328141 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x2.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x2_h.png b/templates/other/AppWidget/thumbs/template_widget_4x2_h.png Binary files differnew file mode 100644 index 0000000..d83062c --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x2_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x2_v.png b/templates/other/AppWidget/thumbs/template_widget_4x2_v.png Binary files differnew file mode 100644 index 0000000..561f47a --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x2_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x2_vh.png b/templates/other/AppWidget/thumbs/template_widget_4x2_vh.png Binary files differnew file mode 100644 index 0000000..132ccd1 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x2_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x3.png b/templates/other/AppWidget/thumbs/template_widget_4x3.png Binary files differnew file mode 100644 index 0000000..c3ea452 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x3.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x3_h.png b/templates/other/AppWidget/thumbs/template_widget_4x3_h.png Binary files differnew file mode 100644 index 0000000..57d84ce --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x3_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x3_v.png b/templates/other/AppWidget/thumbs/template_widget_4x3_v.png Binary files differnew file mode 100644 index 0000000..e8d93fc --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x3_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x3_vh.png b/templates/other/AppWidget/thumbs/template_widget_4x3_vh.png Binary files differnew file mode 100644 index 0000000..71dfbb3 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x3_vh.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x4.png b/templates/other/AppWidget/thumbs/template_widget_4x4.png Binary files differnew file mode 100644 index 0000000..340244f --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x4.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x4_h.png b/templates/other/AppWidget/thumbs/template_widget_4x4_h.png Binary files differnew file mode 100644 index 0000000..f20c14e --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x4_h.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x4_v.png b/templates/other/AppWidget/thumbs/template_widget_4x4_v.png Binary files differnew file mode 100644 index 0000000..d490c79 --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x4_v.png diff --git a/templates/other/AppWidget/thumbs/template_widget_4x4_vh.png b/templates/other/AppWidget/thumbs/template_widget_4x4_vh.png Binary files differnew file mode 100644 index 0000000..52e1b4d --- /dev/null +++ b/templates/other/AppWidget/thumbs/template_widget_4x4_vh.png diff --git a/templates/other/BlankFragment/globals.xml.ftl b/templates/other/BlankFragment/globals.xml.ftl new file mode 100644 index 0000000..bfc27eb --- /dev/null +++ b/templates/other/BlankFragment/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/BlankFragment/recipe.xml.ftl b/templates/other/BlankFragment/recipe.xml.ftl new file mode 100644 index 0000000..add6d27 --- /dev/null +++ b/templates/other/BlankFragment/recipe.xml.ftl @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<recipe> + + <merge from="res/values/strings.xml" /> + + <#if includeLayout> + <instantiate from="res/layout/fragment_blank.xml.ftl" + to="res/layout/fragment_${classToResource(className)}.xml" /> + + <open file="res/layout/fragment_${classToResource(className)}.xml" /> + </#if> + + <open file="${srcOut}/${className}.java" /> + + <instantiate from="src/app_package/BlankFragment.java.ftl" + to="${srcOut}/${className}.java" /> + +</recipe> diff --git a/templates/other/BlankFragment/root/res/layout/fragment_blank.xml.ftl b/templates/other/BlankFragment/root/res/layout/fragment_blank.xml.ftl new file mode 100644 index 0000000..3e04f05 --- /dev/null +++ b/templates/other/BlankFragment/root/res/layout/fragment_blank.xml.ftl @@ -0,0 +1,13 @@ +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".${className}"> + + <!-- TODO: Update blank fragment layout --> + <TextView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:text="@string/hello_blank_fragment" /> + +</FrameLayout> diff --git a/templates/other/BlankFragment/root/res/values/strings.xml b/templates/other/BlankFragment/root/res/values/strings.xml new file mode 100644 index 0000000..c8d8b1a --- /dev/null +++ b/templates/other/BlankFragment/root/res/values/strings.xml @@ -0,0 +1,6 @@ +<resources> + +<!-- TODO: Remove or change this placeholder text --> + <string name="hello_blank_fragment">Hello blank fragment</string> + +</resources> diff --git a/templates/other/BlankFragment/root/src/app_package/BlankFragment.java.ftl b/templates/other/BlankFragment/root/src/app_package/BlankFragment.java.ftl new file mode 100644 index 0000000..6b3fb1e --- /dev/null +++ b/templates/other/BlankFragment/root/src/app_package/BlankFragment.java.ftl @@ -0,0 +1,129 @@ +package ${packageName}; + +<#if includeCallbacks>import android.app.Activity;</#if> +<#if includeCallbacks>import android.net.Uri;</#if> +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +<#if !includeLayout>import android.widget.TextView;</#if> + +/** + * A simple {@link android.support.v4.app.Fragment} subclass. +<#if includeCallbacks> + * Activities that contain this fragment must implement the + * {@link ${className}.OnFragmentInteractionListener} interface + * to handle interaction events. +</#if> +<#if includeFactory> + * Use the {@link ${className}#newInstance} factory method to + * create an instance of this fragment. +</#if> + * + */ +public class ${className} extends Fragment { +<#if includeFactory> + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; +</#if> + +<#if includeCallbacks> + private OnFragmentInteractionListener mListener; +</#if> + +<#if includeFactory> + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment ${className}. + */ + // TODO: Rename and change types and number of parameters + public static ${className} newInstance(String param1, String param2) { + ${className} fragment = new ${className}(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } +</#if> + public ${className}() { + // Required empty public constructor + } + +<#if includeFactory> + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } +</#if> + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { +<#if includeLayout> + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_${classToResource(className)}, container, false); +<#else> + TextView textView = new TextView(getActivity()); + textView.setText(R.string.hello_blank_fragment); + return textView; +</#if> + } + +<#if includeCallbacks> + // TODO: Rename method, update argument and hook method into UI event + public void onButtonPressed(Uri uri) { + if (mListener != null) { + mListener.onFragmentInteraction(uri); + } + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mListener = (OnFragmentInteractionListener) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnFragmentInteractionListener"); + } + } + + @Override + public void onDetach() { + super.onDetach(); + mListener = null; + } + + /** + * This interface must be implemented by activities that contain this + * fragment to allow an interaction in this fragment to be communicated + * to the activity and potentially other fragments contained in that + * activity. + * <p> + * See the Android Training lesson <a href= + * "http://developer.android.com/training/basics/fragments/communicating.html" + * >Communicating with Other Fragments</a> for more information. + */ + public interface OnFragmentInteractionListener { + // TODO: Update argument type and name + public void onFragmentInteraction(Uri uri); + } +</#if> + +} diff --git a/templates/other/BlankFragment/template.xml b/templates/other/BlankFragment/template.xml new file mode 100644 index 0000000..9434c18 --- /dev/null +++ b/templates/other/BlankFragment/template.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<template + format="3" + revision="1" + name="New Blank Fragment" + description="Creates a blank fragment that is compatible back to API level 4." + minApi="7" + minBuildApi="8"> + + <dependency name="android-support-v4" revision="8" /> + + <category value="Other" /> + + <parameter + id="className" + name="Fragment Name" + type="string" + constraints="class|nonempty|unique" + default="BlankFragment" + help="The name of the fragment class to create" /> + + <parameter + id="includeLayout" + name="Create layout XML?" + type="boolean" + default="true" + help="Generate a layout XML for the fragment" /> + + <parameter + id="includeFactory" + name="Include fragment factory methods?" + type="boolean" + default="true" + help="Generate static fragment factory methods for easy instantiation" /> + + <parameter + id="includeCallbacks" + name="Include interface callbacks?" + type="boolean" + default="true" + help="Generate event callbacks for communication with an Activity or other fragments" /> + + <thumbs> + <thumb>template_blank_fragment.png</thumb> + </thumbs> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> diff --git a/templates/other/BlankFragment/template_blank_fragment.png b/templates/other/BlankFragment/template_blank_fragment.png Binary files differnew file mode 100644 index 0000000..e0e71ce --- /dev/null +++ b/templates/other/BlankFragment/template_blank_fragment.png diff --git a/templates/other/Daydream/globals.xml.ftl b/templates/other/Daydream/globals.xml.ftl new file mode 100644 index 0000000..04537f9 --- /dev/null +++ b/templates/other/Daydream/globals.xml.ftl @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<globals> + <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="class_name" value="${classToResource(className)}" /> + <global id="info_name" value="${classToResource(className)}_info" /> + <global id="settingsClassName" value="${className}SettingsActivity" /> + <global id="prefs_name" value="${classToResource(className)}_prefs" /> +</globals> diff --git a/templates/other/Daydream/recipe.xml.ftl b/templates/other/Daydream/recipe.xml.ftl new file mode 100644 index 0000000..8db9811 --- /dev/null +++ b/templates/other/Daydream/recipe.xml.ftl @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<recipe> + + <merge from="AndroidManifest.xml.ftl" /> + <merge from="res/values/strings.xml.ftl" /> + + <copy from="res/layout-v17/dream.xml" + to="res/layout-v17/${class_name}.xml" /> + + <instantiate from="src/app_package/DreamService.java.ftl" + to="${srcOut}/${className}.java" /> + +<#if configurable> + <copy from="res/xml/dream_prefs.xml" + to="res/xml/${prefs_name}.xml" /> + + <instantiate from="src/app_package/SettingsActivity.java.ftl" + to="${srcOut}/${settingsClassName}.java" /> + + <instantiate from="res/xml/xml_dream.xml.ftl" + to="res/xml/${info_name}.xml" /> +</#if> + + <open file="${srcOut}/${className}.java" /> + +</recipe> diff --git a/templates/other/Daydream/root/AndroidManifest.xml.ftl b/templates/other/Daydream/root/AndroidManifest.xml.ftl new file mode 100644 index 0000000..c23bc6e --- /dev/null +++ b/templates/other/Daydream/root/AndroidManifest.xml.ftl @@ -0,0 +1,28 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <application> + +<#if configurable> + <activity + android:name=".${settingsClassName}" /> +</#if> + + <!-- This service is only used on devices with API v17+ --> + <service + android:name=".${className}" + android:exported="true" > + <intent-filter> + <action android:name="android.service.dreams.DreamService" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +<#if configurable> + + <!-- Point to additional information for this dream --> + <meta-data + android:name="android.service.dream" + android:resource="@xml/${info_name}" /> +</#if> + </service> + </application> + +</manifest> diff --git a/templates/other/Daydream/root/res/layout-v17/dream.xml b/templates/other/Daydream/root/res/layout-v17/dream.xml new file mode 100644 index 0000000..25593f3 --- /dev/null +++ b/templates/other/Daydream/root/res/layout-v17/dream.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <TextView + android:id="@+id/dream_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="sans-serif-light" + android:textSize="50sp" /> + +</FrameLayout> diff --git a/templates/other/Daydream/root/res/values/strings.xml.ftl b/templates/other/Daydream/root/res/values/strings.xml.ftl new file mode 100644 index 0000000..b3d208f --- /dev/null +++ b/templates/other/Daydream/root/res/values/strings.xml.ftl @@ -0,0 +1,7 @@ +<resources> + <string name="pref_dream_text_key">pref_dream_text</string> + <string name="pref_dream_text_default">zzzZZZzzz</string> +<#if configurable> + <string name="pref_dream_text_title">Ticker text</string> +</#if> +</resources> diff --git a/templates/other/Daydream/root/res/xml/dream_prefs.xml b/templates/other/Daydream/root/res/xml/dream_prefs.xml new file mode 100644 index 0000000..997e5b2 --- /dev/null +++ b/templates/other/Daydream/root/res/xml/dream_prefs.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > + + <EditTextPreference + android:key="@string/pref_dream_text_key" + android:title="@string/pref_dream_text_title" + android:defaultValue="@string/pref_dream_text_default" /> + +</PreferenceScreen> diff --git a/templates/other/Daydream/root/res/xml/xml_dream.xml.ftl b/templates/other/Daydream/root/res/xml/xml_dream.xml.ftl new file mode 100644 index 0000000..5367ae1 --- /dev/null +++ b/templates/other/Daydream/root/res/xml/xml_dream.xml.ftl @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<dream xmlns:android="http://schemas.android.com/apk/res/android" + android:settingsActivity="${packageName}/.${settingsClassName}" /> diff --git a/templates/other/Daydream/root/src/app_package/DreamService.java.ftl b/templates/other/Daydream/root/src/app_package/DreamService.java.ftl new file mode 100644 index 0000000..30f080f --- /dev/null +++ b/templates/other/Daydream/root/src/app_package/DreamService.java.ftl @@ -0,0 +1,140 @@ +package ${packageName}; + +import java.util.Random; + +import android.animation.Animator; +import android.animation.Animator.AnimatorListener; +import android.animation.AnimatorListenerAdapter; +import android.animation.TimeInterpolator; +import android.annotation.TargetApi; +import android.content.SharedPreferences; +import android.graphics.Point; +import android.os.Build; +import android.preference.PreferenceManager; +import android.service.dreams.DreamService; +import android.view.ViewPropertyAnimator; +import android.view.animation.LinearInterpolator; +import android.widget.TextView; + +/** + * This class is a sample implementation of a DreamService. When activated, a + * TextView will repeatedly, move from the left to the right of screen, at a + * random y-value. +<#if configurable> + * The generated {@link BlahDreamServiceSettingsActivity} allows + * the user to change the text which is displayed. +</#if> + * <p /> + * Daydreams are only available on devices running API v17+. + */ +@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) +public class ${className} extends DreamService { + + private static final TimeInterpolator sInterpolator = new LinearInterpolator(); + + private final AnimatorListener mAnimListener = new AnimatorListenerAdapter() { + + @Override + public void onAnimationEnd(Animator animation) { + // Start animation again + startTextViewScrollAnimation(); + } + + }; + + private final Random mRandom = new Random(); + private final Point mPointSize = new Point(); + + private TextView mDreamTextView; + private ViewPropertyAnimator mAnimator; + + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + + // Exit dream upon user touch? +<#if isInteractive> + setInteractive(true); +<#else> + setInteractive(false); +</#if> + + // Hide system UI? +<#if isFullscreen> + setFullscreen(true); +<#else> + setFullscreen(false); +</#if> + + // Keep screen at full brightness? +<#if isScreenBright> + setScreenBright(true); +<#else> + setScreenBright(false); +</#if> + + // Set the content view, just like you would with an Activity. + setContentView(R.layout.${class_name}); + + mDreamTextView = (TextView) findViewById(R.id.dream_text); + mDreamTextView.setText(getTextFromPreferences()); + } + + @Override + public void onDreamingStarted() { + super.onDreamingStarted(); + + // TODO: Begin animations or other behaviors here. + + startTextViewScrollAnimation(); + } + + @Override + public void onDreamingStopped() { + super.onDreamingStopped(); + + // TODO: Stop anything that was started in onDreamingStarted() + + mAnimator.cancel(); + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + + // TODO: Dismantle resources + // (for example, detach from handlers and listeners). + } + + private String getTextFromPreferences() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + return prefs.getString(getString(R.string.pref_dream_text_key), + getString(R.string.pref_dream_text_default)); + } + + private void startTextViewScrollAnimation() { + // Refresh Size of Window + getWindowManager().getDefaultDisplay().getSize(mPointSize); + + final int windowWidth = mPointSize.x; + final int windowHeight = mPointSize.y; + + // Move TextView so it's moved all the way to the left + mDreamTextView.setTranslationX(-mDreamTextView.getWidth()); + + // Move TextView to random y value + final int yRange = windowHeight - mDreamTextView.getHeight(); + mDreamTextView.setTranslationY(mRandom.nextInt(yRange)); + + // Create an Animator and keep a reference to it + mAnimator = mDreamTextView.animate().translationX(windowWidth) + .setDuration(3000) + .setStartDelay(500) + .setListener(mAnimListener) + .setInterpolator(sInterpolator); + + // Start the animation + mAnimator.start(); + } + +} diff --git a/templates/other/Daydream/root/src/app_package/SettingsActivity.java.ftl b/templates/other/Daydream/root/src/app_package/SettingsActivity.java.ftl new file mode 100644 index 0000000..62d5887 --- /dev/null +++ b/templates/other/Daydream/root/src/app_package/SettingsActivity.java.ftl @@ -0,0 +1,36 @@ +package ${packageName}; + +import android.annotation.TargetApi; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.preference.PreferenceFragment; + +/** + * A settings Activity for {@link ${className}}. + * <p /> + * A DreamService can only be used on devices with API v17+, so it is safe + * for us to use a {@link PreferenceFragment} here. + */ +@TargetApi(Build.VERSION_CODES.HONEYCOMB) +public class ${settingsClassName} extends PreferenceActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new DreamPreferenceFragment()).commit(); + } + + public static class DreamPreferenceFragment extends PreferenceFragment { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.${prefs_name}); + } + + } + +} diff --git a/templates/other/Daydream/template.xml b/templates/other/Daydream/template.xml new file mode 100644 index 0000000..2014eee --- /dev/null +++ b/templates/other/Daydream/template.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<template + format="3" + revision="1" + name="New Daydream" + description="Creates a new Daydream service component, for use on devices running Android 4.2 and later." + minBuildApi="17"> + + <category value="Other" /> + + <parameter + id="className" + name="Class Name" + type="string" + constraints="class|unique|nonempty" + default="MyDaydreamService" /> + + <parameter + id="isInteractive" + name="Interactive?" + type="boolean" + default="false" + help="Whether or not the Daydream is interactive. Touching anywhere on a non-interactive Daydreams dismisses it." /> + + <parameter + id="isFullscreen" + name="Fullscreen?" + type="boolean" + default="true" + help="Whether or not the Daydream should be in fullscreen mode (in which case system UI will be hidden)." /> + + <parameter + id="isScreenBright" + name="Bright Screen?" + type="boolean" + default="true" + help="Whether or not the screen should be bright when this Daydream is running. The screen will be dim otherwise." /> + + <parameter + id="configurable" + name="Configuration Activity" + type="boolean" + default="false" + help="Whether or not to generate an associated settings Activity." /> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> diff --git a/templates/other/ListFragment/globals.xml.ftl b/templates/other/ListFragment/globals.xml.ftl new file mode 100644 index 0000000..577250d --- /dev/null +++ b/templates/other/ListFragment/globals.xml.ftl @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<globals> + <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="collection_name" value="${extractLetters(objectKind?lower_case)}" /> + <global id="className" value="${extractLetters(objectKind)}Fragment" /> + <global id="fragment_layout" value="fragment_${extractLetters(objectKind?lower_case)}" /> +</globals> diff --git a/templates/other/ListFragment/recipe.xml.ftl b/templates/other/ListFragment/recipe.xml.ftl new file mode 100644 index 0000000..5db4fdb --- /dev/null +++ b/templates/other/ListFragment/recipe.xml.ftl @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<recipe> + +<#if switchGrid == true> + <merge from="res/values/refs.xml.ftl" /> + <merge from="res/values/refs_lrg.xml.ftl" + to="res/values-large/refs.xml" /> + <merge from="res/values/refs_lrg.xml.ftl" + to="res/values-sw600dp/refs.xml" /> + + <instantiate from="res/layout/fragment_grid.xml" + to="res/layout/${fragment_layout}_grid.xml" /> + + <instantiate from="res/layout/fragment_list.xml" + to="res/layout/${fragment_layout}_list.xml" /> +</#if> + + <instantiate from="src/app_package/ListFragment.java.ftl" + to="${srcOut}/${className}.java" /> + + <instantiate from="src/app_package/dummy/DummyContent.java.ftl" + to="${srcOut}/dummy/DummyContent.java" /> + + <open file="${srcOut}/${className}.java" /> + +</recipe> diff --git a/templates/other/ListFragment/root/res/layout/fragment_grid.xml b/templates/other/ListFragment/root/res/layout/fragment_grid.xml new file mode 100644 index 0000000..87ae969 --- /dev/null +++ b/templates/other/ListFragment/root/res/layout/fragment_grid.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".${className}"> + + <GridView + android:id="@android:id/list" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:numColumns="2" /> + + <TextView + android:id="@android:id/empty" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" /> + +</FrameLayout>
\ No newline at end of file diff --git a/templates/other/ListFragment/root/res/layout/fragment_list.xml b/templates/other/ListFragment/root/res/layout/fragment_list.xml new file mode 100644 index 0000000..5b0e178 --- /dev/null +++ b/templates/other/ListFragment/root/res/layout/fragment_list.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".${className}"> + + <ListView + android:id="@android:id/list" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + <TextView + android:id="@android:id/empty" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" /> + +</FrameLayout>
\ No newline at end of file diff --git a/templates/other/ListFragment/root/res/values-large/refs_lrg.xml.ftl b/templates/other/ListFragment/root/res/values-large/refs_lrg.xml.ftl new file mode 100644 index 0000000..fb20a27 --- /dev/null +++ b/templates/other/ListFragment/root/res/values-large/refs_lrg.xml.ftl @@ -0,0 +1,12 @@ +<resources> + + <!-- + Layout alias to replace the single-pane version of the layout with a + two-pane version on Large screens. + + For more on layout aliases, see: + http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters + --> + <item name="${fragment_layout}" type="layout">@layout/${fragment_layout}_grid</item> + +</resources>
\ No newline at end of file diff --git a/templates/other/ListFragment/root/res/values-sw600dp/refs_lrg.xml.ftl b/templates/other/ListFragment/root/res/values-sw600dp/refs_lrg.xml.ftl new file mode 100644 index 0000000..fb20a27 --- /dev/null +++ b/templates/other/ListFragment/root/res/values-sw600dp/refs_lrg.xml.ftl @@ -0,0 +1,12 @@ +<resources> + + <!-- + Layout alias to replace the single-pane version of the layout with a + two-pane version on Large screens. + + For more on layout aliases, see: + http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters + --> + <item name="${fragment_layout}" type="layout">@layout/${fragment_layout}_grid</item> + +</resources>
\ No newline at end of file diff --git a/templates/other/ListFragment/root/res/values/refs.xml.ftl b/templates/other/ListFragment/root/res/values/refs.xml.ftl new file mode 100644 index 0000000..59ca92c --- /dev/null +++ b/templates/other/ListFragment/root/res/values/refs.xml.ftl @@ -0,0 +1,12 @@ +<resources> + + <!-- + Layout alias to replace the single-pane version of the layout with a + two-pane version on Large screens. + + For more on layout aliases, see: + http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters + --> + <item name="${fragment_layout}" type="layout">@layout/${fragment_layout}_list</item> + +</resources>
\ No newline at end of file diff --git a/templates/other/ListFragment/root/res/values/refs_lrg.xml.ftl b/templates/other/ListFragment/root/res/values/refs_lrg.xml.ftl new file mode 100644 index 0000000..fb20a27 --- /dev/null +++ b/templates/other/ListFragment/root/res/values/refs_lrg.xml.ftl @@ -0,0 +1,12 @@ +<resources> + + <!-- + Layout alias to replace the single-pane version of the layout with a + two-pane version on Large screens. + + For more on layout aliases, see: + http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters + --> + <item name="${fragment_layout}" type="layout">@layout/${fragment_layout}_grid</item> + +</resources>
\ No newline at end of file diff --git a/templates/other/ListFragment/root/src/app_package/ListFragment.java.ftl b/templates/other/ListFragment/root/src/app_package/ListFragment.java.ftl new file mode 100644 index 0000000..6100448 --- /dev/null +++ b/templates/other/ListFragment/root/src/app_package/ListFragment.java.ftl @@ -0,0 +1,195 @@ +package ${packageName}; + +import android.app.Activity; +import android.os.Bundle; +<#if switchGrid == true> +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +<#else> +import android.support.v4.app.ListFragment; +</#if> +import android.view.View; +<#if switchGrid == true> +import android.view.ViewGroup; +import android.widget.AbsListView; +import android.widget.AdapterView; +</#if> +import android.widget.ArrayAdapter; +<#if switchGrid == true> +import android.widget.ListAdapter; +import android.widget.TextView; +<#else> +import android.widget.ListView; +</#if> + +import ${packageName}.dummy.DummyContent; + +/** + * A fragment representing a list of Items. + * <p /> +<#if switchGrid == true> + * Large screen devices (such as tablets) are supported by replacing the ListView + * with a GridView. +</#if> + * <p /> + * Activities containing this fragment MUST implement the {@link Callbacks} + * interface. + */ +<#if switchGrid == true> +public class ${className} extends Fragment implements AbsListView.OnItemClickListener { +<#else> +public class ${className} extends ListFragment { +</#if> + +<#if includeFactory> + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + +</#if> + private OnFragmentInteractionListener mListener; + +<#if switchGrid == true> + /** + * The fragment's ListView/GridView. + */ + private AbsListView mListView; + + /** + * The Adapter which will be used to populate the ListView/GridView with + * Views. + */ + private ListAdapter mAdapter; + +</#if> +<#if includeFactory> + // TODO: Rename and change types of parameters + public static ${className} newInstance(String param1, String param2) { + ${className} fragment = new ${className}(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + +</#if> + /** + * Mandatory empty constructor for the fragment manager to instantiate the + * fragment (e.g. upon screen orientation changes). + */ + public ${className}() { + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + +<#if includeFactory> + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } +</#if> + + // TODO: Change Adapter to display your content +<#if switchGrid == true> + mAdapter = new ArrayAdapter<DummyContent.DummyItem>(getActivity(), + android.R.layout.simple_list_item_1, android.R.id.text1, DummyContent.ITEMS); +<#else> + setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(), + android.R.layout.simple_list_item_1, android.R.id.text1, DummyContent.ITEMS)); +</#if> + } + +<#if switchGrid == true> + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.${fragment_layout}, container, false); + + // Set the adapter + mListView = (AbsListView) view.findViewById(android.R.id.list); + ((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter); + + // Set OnItemClickListener so we can be notified on item clicks + mListView.setOnItemClickListener(this); + + return view; + } +</#if> + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mListener = (OnFragmentInteractionListener) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnFragmentInteractionListener"); + } + } + + @Override + public void onDetach() { + super.onDetach(); + mListener = null; + } + + +<#if switchGrid == true> + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + if (null != mListener) { + // Notify the active callbacks interface (the activity, if the + // fragment is attached to one) that an item has been selected. + mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id); + } + } + + /** + * The default content for this Fragment has a TextView that is shown when + * the list is empty. If you would like to change the text, call this method + * to supply the text it should use. + */ + public void setEmptyText(CharSequence emptyText) { + View emptyView = mListView.getEmptyView(); + + if (emptyText instanceof TextView) { + ((TextView) emptyView).setText(emptyText); + } + } +<#else> + @Override + public void onListItemClick(ListView l, View v, int position, long id) { + super.onListItemClick(l, v, position, id); + + if (null != mListener) { + // Notify the active callbacks interface (the activity, if the + // fragment is attached to one) that an item has been selected. + mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id); + } + } +</#if> + + /** + * This interface must be implemented by activities that contain this + * fragment to allow an interaction in this fragment to be communicated + * to the activity and potentially other fragments contained in that + * activity. + * <p> + * See the Android Training lesson <a href= + * "http://developer.android.com/training/basics/fragments/communicating.html" + * >Communicating with Other Fragments</a> for more information. + */ + public interface OnFragmentInteractionListener { + // TODO: Update argument type and name + public void onFragmentInteraction(String id); + } + +} diff --git a/templates/other/ListFragment/root/src/app_package/dummy/DummyContent.java.ftl b/templates/other/ListFragment/root/src/app_package/dummy/DummyContent.java.ftl new file mode 100644 index 0000000..3545ba3 --- /dev/null +++ b/templates/other/ListFragment/root/src/app_package/dummy/DummyContent.java.ftl @@ -0,0 +1,55 @@ +package ${packageName}.dummy; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Helper class for providing sample content for user interfaces created by + * Android template wizards. + * <p> + * TODO: Replace all uses of this class before publishing your app. + */ +public class DummyContent { + + /** + * An array of sample (dummy) items. + */ + public static List<DummyItem> ITEMS = new ArrayList<DummyItem>(); + + /** + * A map of sample (dummy) items, by ID. + */ + public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>(); + + static { + // Add 3 sample items. + addItem(new DummyItem("1", "Item 1")); + addItem(new DummyItem("2", "Item 2")); + addItem(new DummyItem("3", "Item 3")); + } + + private static void addItem(DummyItem item) { + ITEMS.add(item); + ITEM_MAP.put(item.id, item); + } + + /** + * A dummy item representing a piece of content. + */ + public static class DummyItem { + public String id; + public String content; + + public DummyItem(String id, String content) { + this.id = id; + this.content = content; + } + + @Override + public String toString() { + return content; + } + } +} diff --git a/templates/other/ListFragment/template.xml b/templates/other/ListFragment/template.xml new file mode 100644 index 0000000..e00257c --- /dev/null +++ b/templates/other/ListFragment/template.xml @@ -0,0 +1,52 @@ +<?xml version="1.0"?> +<template + format="3" + revision="1" + name="New List Fragment" + description="Creates a new empty fragment containing a list that can optionally change to a grid when on large screens. Compatible back to API level 4." + minApi="7" + minBuildApi="8"> + + <dependency name="android-support-v4" revision="8" /> + + <category value="UI Components" /> + + <parameter + id="packageName" + name="Package name" + type="string" + constraints="package" + default="com.mycompany.myapp" /> + + <parameter + id="objectKind" + name="Object Kind" + type="string" + constraints="nonempty" + default="Item" + help="Other examples are 'Person', 'Book', etc." /> + + <parameter + id="includeFactory" + name="Include fragment factory methods?" + type="boolean" + default="true" + help="Generate static fragment factory methods for easy instantiation" /> + + <parameter + id="switchGrid" + name="Switch to grid view on large screens?" + type="boolean" + default="true" /> + + <!-- 128x128 thumbnails relative to template.xml --> + <thumbs> + <!-- default thumbnail is required --> + <thumb>templates_list_fragment.png</thumb> + </thumbs> + + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> diff --git a/templates/other/ListFragment/templates_list_fragment.png b/templates/other/ListFragment/templates_list_fragment.png Binary files differnew file mode 100644 index 0000000..92ac799 --- /dev/null +++ b/templates/other/ListFragment/templates_list_fragment.png diff --git a/templates/projects/NewAndroidApplication/globals.xml.ftl b/templates/projects/NewAndroidApplication/globals.xml.ftl index bfc27eb..8c419d8 100644 --- a/templates/projects/NewAndroidApplication/globals.xml.ftl +++ b/templates/projects/NewAndroidApplication/globals.xml.ftl @@ -1,4 +1,11 @@ <?xml version="1.0"?> <globals> + <global id="isGradle" value="false" /> + <global id="topOut" value="." /> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="resOut" value="res" /> + <global id="mavenUrl" value="http://repo1.maven.org/maven2" /> + <global id="buildToolsVersion" value="${buildApi}" /> </globals> diff --git a/templates/projects/NewAndroidApplication/recipe.xml.ftl b/templates/projects/NewAndroidApplication/recipe.xml.ftl index bc8f02e..79210a9 100644 --- a/templates/projects/NewAndroidApplication/recipe.xml.ftl +++ b/templates/projects/NewAndroidApplication/recipe.xml.ftl @@ -1,21 +1,33 @@ <?xml version="1.0"?> <recipe> - <instantiate from="AndroidManifest.xml.ftl" /> +<#if isGradle == "true"> + <merge from="settings.gradle.ftl" + to="${topOut}/settings.gradle" /> + <instantiate from="build.gradle.ftl" + to="${projectOut}/build.gradle" /> +</#if> + <instantiate from="AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> <#if copyIcons> - <copy from="res/drawable-hdpi" /> - <copy from="res/drawable-mdpi" /> - <copy from="res/drawable-xhdpi" /> + <copy from="res/drawable-hdpi" + to="${resOut}/drawable-hdpi" /> + <copy from="res/drawable-mdpi" + to="${resOut}/drawable-mdpi" /> + <copy from="res/drawable-xhdpi" + to="${resOut}/drawable-xhdpi" /> </#if> - <instantiate from="res/values/styles.xml.ftl" /> + <instantiate from="res/values/styles.xml.ftl" + to="${resOut}/values/styles.xml" /> <#if buildApi gte 11 && baseTheme != "none"> <instantiate from="res/values-v11/styles_hc.xml.ftl" - to="res/values-v11/styles.xml" /> + to="${resOut}/values-v11/styles.xml" /> </#if> <#if buildApi gte 14 && baseTheme?contains("darkactionbar")> <copy from="res/values-v14/styles_ics.xml" - to="res/values-v14/styles.xml" /> + to="${resOut}/values-v14/styles.xml" /> </#if> - <instantiate from="res/values/strings.xml.ftl" /> + <instantiate from="res/values/strings.xml.ftl" + to="${resOut}/values/strings.xml" /> </recipe> diff --git a/templates/projects/NewAndroidApplication/root/build.gradle.ftl b/templates/projects/NewAndroidApplication/root/build.gradle.ftl new file mode 100644 index 0000000..513c6d5 --- /dev/null +++ b/templates/projects/NewAndroidApplication/root/build.gradle.ftl @@ -0,0 +1,23 @@ +buildscript { + repositories { + maven { url '${mavenUrl}' } + } + dependencies { + classpath 'com.android.tools.build:gradle:0.4-SNAPSHOT' + } +} +apply plugin: 'android' + +dependencies { + compile files('libs/android-support-v4.jar') +} + +android { + compileSdkVersion ${buildApi} + buildToolsVersion "${buildToolsVersion}" + + defaultConfig { + minSdkVersion ${minApi} + targetSdkVersion ${targetApi} + } +} diff --git a/templates/projects/NewAndroidApplication/root/settings.gradle.ftl b/templates/projects/NewAndroidApplication/root/settings.gradle.ftl new file mode 100644 index 0000000..b12004b --- /dev/null +++ b/templates/projects/NewAndroidApplication/root/settings.gradle.ftl @@ -0,0 +1 @@ +include ':${projectName}' diff --git a/templates/projects/NewAndroidLibrary/globals.xml.ftl b/templates/projects/NewAndroidLibrary/globals.xml.ftl new file mode 100644 index 0000000..8c419d8 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/globals.xml.ftl @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<globals> + <global id="isGradle" value="false" /> + <global id="topOut" value="." /> + <global id="projectOut" value="." /> + <global id="manifestOut" value="." /> + <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> + <global id="resOut" value="res" /> + <global id="mavenUrl" value="http://repo1.maven.org/maven2" /> + <global id="buildToolsVersion" value="${buildApi}" /> +</globals> diff --git a/templates/projects/NewAndroidLibrary/recipe.xml.ftl b/templates/projects/NewAndroidLibrary/recipe.xml.ftl new file mode 100644 index 0000000..9999701 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/recipe.xml.ftl @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<recipe> +<#if isGradle == "true"> + <merge from="settings.gradle.ftl" + to="${topOut}/settings.gradle" /> + <instantiate from="build.gradle.ftl" + to="${projectOut}/build.gradle" /> +</#if> + <instantiate from="MODULE_NAME/src/main/AndroidManifest.xml.ftl" + to="${manifestOut}/AndroidManifest.xml" /> + +<#if copyIcons> + <copy from="res/drawable-hdpi" + to="${resOut}/drawable-hdpi" /> + <copy from="res/drawable-mdpi" + to="${resOut}/drawable-mdpi" /> + <copy from="res/drawable-xhdpi" + to="${resOut}/drawable-xhdpi" /> +</#if> + <instantiate from="res/values/styles.xml.ftl" + to="${resOut}/values/styles.xml" /> +<#if buildApi gte 11 && baseTheme != "none"> + <instantiate from="res/values-v11/styles_hc.xml.ftl" + to="${resOut}/values-v11/styles.xml" /> +</#if> +<#if buildApi gte 14 && baseTheme?contains("darkactionbar")> + <copy from="res/values-v14/styles_ics.xml" + to="${resOut}/values-v14/styles.xml" /> +</#if> + + <instantiate from="res/values/strings.xml.ftl" + to="${resOut}/values/strings.xml" /> +</recipe> diff --git a/templates/projects/NewAndroidLibrary/root/AndroidManifest.xml.ftl b/templates/projects/NewAndroidLibrary/root/AndroidManifest.xml.ftl new file mode 100644 index 0000000..390a9da --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/AndroidManifest.xml.ftl @@ -0,0 +1,15 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="${packageName}" + android:versionCode="1" + android:versionName="1.0"> + + <uses-sdk android:minSdkVersion="${minApi}" <#if buildApi gte 4>android:targetSdkVersion="${targetApi}" </#if>/> + + <application <#if minApiLevel gte 4 && buildApi gte 4>android:allowBackup="true"</#if> + android:label="@string/app_name" + android:icon="@drawable/ic_launcher"<#if baseTheme != "none"> + android:theme="@style/AppTheme"</#if>> + + </application> + +</manifest> diff --git a/templates/projects/NewAndroidLibrary/root/build.gradle.ftl b/templates/projects/NewAndroidLibrary/root/build.gradle.ftl new file mode 100644 index 0000000..9919ca5 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/build.gradle.ftl @@ -0,0 +1,23 @@ +buildscript { + repositories { + maven { url '${mavenUrl}' } + } + dependencies { + classpath 'com.android.tools.build:gradle:0.4-SNAPSHOT' + } +} +apply plugin: 'android-library' + +dependencies { + compile files('libs/android-support-v4.jar') +} + +android { + compileSdkVersion ${buildApi} + buildToolsVersion "${buildToolsVersion}" + + defaultConfig { + minSdkVersion ${minApi} + targetSdkVersion ${targetApi} + } +} diff --git a/templates/projects/NewAndroidLibrary/root/res/drawable-hdpi/ic_launcher.png b/templates/projects/NewAndroidLibrary/root/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..96a442e --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/res/drawable-hdpi/ic_launcher.png diff --git a/templates/projects/NewAndroidLibrary/root/res/drawable-mdpi/ic_launcher.png b/templates/projects/NewAndroidLibrary/root/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..359047d --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/res/drawable-mdpi/ic_launcher.png diff --git a/templates/projects/NewAndroidLibrary/root/res/drawable-xhdpi/ic_launcher.png b/templates/projects/NewAndroidLibrary/root/res/drawable-xhdpi/ic_launcher.png Binary files differnew file mode 100755 index 0000000..71c6d76 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/res/drawable-xhdpi/ic_launcher.png diff --git a/templates/projects/NewAndroidLibrary/root/res/values-v11/styles_hc.xml.ftl b/templates/projects/NewAndroidLibrary/root/res/values-v11/styles_hc.xml.ftl new file mode 100644 index 0000000..f8993c3 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/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/NewAndroidLibrary/root/res/values-v14/styles_ics.xml b/templates/projects/NewAndroidLibrary/root/res/values-v14/styles_ics.xml new file mode 100644 index 0000000..a91fd03 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/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/NewAndroidLibrary/root/res/values/strings.xml.ftl b/templates/projects/NewAndroidLibrary/root/res/values/strings.xml.ftl new file mode 100644 index 0000000..ee03444 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/res/values/strings.xml.ftl @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">${escapeXmlString(appTitle)}</string> +</resources> diff --git a/templates/projects/NewAndroidLibrary/root/res/values/styles.xml.ftl b/templates/projects/NewAndroidLibrary/root/res/values/styles.xml.ftl new file mode 100644 index 0000000..30fe5b5 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/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/NewAndroidLibrary/root/settings.gradle.ftl b/templates/projects/NewAndroidLibrary/root/settings.gradle.ftl new file mode 100644 index 0000000..b12004b --- /dev/null +++ b/templates/projects/NewAndroidLibrary/root/settings.gradle.ftl @@ -0,0 +1 @@ +include ':${projectName}' diff --git a/templates/projects/NewAndroidLibrary/template.xml b/templates/projects/NewAndroidLibrary/template.xml new file mode 100644 index 0000000..463643d --- /dev/null +++ b/templates/projects/NewAndroidLibrary/template.xml @@ -0,0 +1,82 @@ +<?xml version="1.0"?> +<template + format="1" + revision="1" + name="Android Library" + description="Creates a new Android library."> + <dependency name="android-support-v4" revision="8" /> + + <thumbs> + <thumb>template_new_project.png</thumb> + </thumbs> + + <category value="Applications" /> + + <parameter + id="packageName" + name="Package name" + type="string" + constraints="package" + default="com.mycompany.myapp" /> + + <parameter + id="appTitle" + name="Library title" + type="string" + constraints="nonempty" + default="My Library"/> + + <parameter + id="baseTheme" + name="Base Theme" + type="enum" + default="holo_light_darkactionbar" + help="The base user interface theme for the library"> + <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" + constraints="apilevel" + default="7" /> + + <!-- + Usually the same as minApi, but when minApi is a code name this will be the corresponding + API level + --> + <parameter + id="minApiLevel" + name="Minimum API level" + type="string" + constraints="apilevel" + default="7" /> + + <parameter + id="targetApi" + name="Target API level" + type="string" + constraints="apilevel" + default="16" /> + + <parameter + id="buildApi" + name="Build API level" + type="string" + constraints="apilevel" + default="16" /> + + <parameter + id="copyIcons" + name="Include launcher icons" + type="boolean" + default="true" /> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> diff --git a/templates/projects/NewAndroidLibrary/template_new_project.png b/templates/projects/NewAndroidLibrary/template_new_project.png Binary files differnew file mode 100644 index 0000000..92e8556 --- /dev/null +++ b/templates/projects/NewAndroidLibrary/template_new_project.png diff --git a/templates/projects/NewJavaLibrary/globals.xml.ftl b/templates/projects/NewJavaLibrary/globals.xml.ftl new file mode 100644 index 0000000..5b9b620 --- /dev/null +++ b/templates/projects/NewJavaLibrary/globals.xml.ftl @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<globals> + <global id="isGradle" value="false" /> + <global id="topOut" value="." /> + <global id="projectOut" value="." /> + <global id="srcOut" value="src/${slashedPackageName(packageName)}" /> +</globals> diff --git a/templates/projects/NewJavaLibrary/recipe.xml.ftl b/templates/projects/NewJavaLibrary/recipe.xml.ftl new file mode 100644 index 0000000..e2d943a --- /dev/null +++ b/templates/projects/NewJavaLibrary/recipe.xml.ftl @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<recipe> +<#if isGradle == "true"> + <merge from="settings.gradle.ftl" + to="${topOut}/settings.gradle" /> + <instantiate from="build.gradle.ftl" + to="${projectOut}/build.gradle" /> +</#if> + <instantiate from="/src/library_package/Placeholder.java" + to="${srcOut}/Placeholder.java" /> +</recipe> diff --git a/templates/projects/NewJavaLibrary/root/build.gradle.ftl b/templates/projects/NewJavaLibrary/root/build.gradle.ftl new file mode 100644 index 0000000..bbfeb03 --- /dev/null +++ b/templates/projects/NewJavaLibrary/root/build.gradle.ftl @@ -0,0 +1 @@ +apply plugin: 'java' diff --git a/templates/projects/NewJavaLibrary/root/settings.gradle.ftl b/templates/projects/NewJavaLibrary/root/settings.gradle.ftl new file mode 100644 index 0000000..b12004b --- /dev/null +++ b/templates/projects/NewJavaLibrary/root/settings.gradle.ftl @@ -0,0 +1 @@ +include ':${projectName}' diff --git a/templates/projects/NewJavaLibrary/root/src/library_package/Placeholder.java b/templates/projects/NewJavaLibrary/root/src/library_package/Placeholder.java new file mode 100644 index 0000000..016aacb --- /dev/null +++ b/templates/projects/NewJavaLibrary/root/src/library_package/Placeholder.java @@ -0,0 +1,4 @@ +package com.example; + +public class Placeholder { +} diff --git a/templates/projects/NewJavaLibrary/template.xml b/templates/projects/NewJavaLibrary/template.xml new file mode 100644 index 0000000..4a3ed90 --- /dev/null +++ b/templates/projects/NewJavaLibrary/template.xml @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<template + format="1" + revision="1" + name="Java Library" + description="Creates a new Java library."> + + <thumbs> + <thumb>template_new_project.png</thumb> + </thumbs> + + <category value="Applications" /> + + <parameter + id="projectName" + name="Library name" + type="string" + constraints="nonempty" + default="MyLibrary"/> + + <globals file="globals.xml.ftl" /> + <execute file="recipe.xml.ftl" /> + +</template> diff --git a/templates/projects/NewJavaLibrary/template_new_project.png b/templates/projects/NewJavaLibrary/template_new_project.png Binary files differnew file mode 100644 index 0000000..92e8556 --- /dev/null +++ b/templates/projects/NewJavaLibrary/template_new_project.png |