aboutsummaryrefslogtreecommitdiffstats
path: root/templates/activities/BlankActivity
diff options
context:
space:
mode:
Diffstat (limited to 'templates/activities/BlankActivity')
-rw-r--r--templates/activities/BlankActivity/globals.xml.ftl5
-rw-r--r--templates/activities/BlankActivity/recipe.xml.ftl56
-rw-r--r--templates/activities/BlankActivity/root/AndroidManifest.xml.ftl15
-rw-r--r--templates/activities/BlankActivity/root/res/drawable-hdpi/ic_action_search.pngbin0 -> 3120 bytes
-rw-r--r--templates/activities/BlankActivity/root/res/drawable-mdpi/ic_action_search.pngbin0 -> 3030 bytes
-rw-r--r--templates/activities/BlankActivity/root/res/drawable-xhdpi/ic_action_search.pngbin0 -> 3199 bytes
-rw-r--r--templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml6
-rw-r--r--templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl22
-rw-r--r--templates/activities/BlankActivity/root/res/layout/activity_simple.xml8
-rw-r--r--templates/activities/BlankActivity/root/res/menu/main.xml6
-rw-r--r--templates/activities/BlankActivity/root/res/values-large/dimens.xml5
-rw-r--r--templates/activities/BlankActivity/root/res/values/dimens.xml5
-rw-r--r--templates/activities/BlankActivity/root/res/values/strings.xml.ftl13
-rw-r--r--templates/activities/BlankActivity/root/src/app_package/DropdownActivity.java.ftl98
-rw-r--r--templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl19
-rw-r--r--templates/activities/BlankActivity/root/src/app_package/TabsActivity.java.ftl94
-rw-r--r--templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl151
-rw-r--r--templates/activities/BlankActivity/template.xml69
-rw-r--r--templates/activities/BlankActivity/template_blank_activity.pngbin0 -> 4322 bytes
-rw-r--r--templates/activities/BlankActivity/template_blank_activity_dropdown.pngbin0 -> 5662 bytes
-rw-r--r--templates/activities/BlankActivity/template_blank_activity_pager.pngbin0 -> 5441 bytes
-rw-r--r--templates/activities/BlankActivity/template_blank_activity_tabs.pngbin0 -> 4873 bytes
-rw-r--r--templates/activities/BlankActivity/template_blank_activity_tabs_pager.pngbin0 -> 5257 bytes
23 files changed, 572 insertions, 0 deletions
diff --git a/templates/activities/BlankActivity/globals.xml.ftl b/templates/activities/BlankActivity/globals.xml.ftl
new file mode 100644
index 0000000..3a26abd
--- /dev/null
+++ b/templates/activities/BlankActivity/globals.xml.ftl
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<globals>
+ <global id="srcOut" value="src/${slashedPackageName(packageName)}" />
+ <global id="menuName" value="${layoutName}" />
+</globals>
diff --git a/templates/activities/BlankActivity/recipe.xml.ftl b/templates/activities/BlankActivity/recipe.xml.ftl
new file mode 100644
index 0000000..2ce72db
--- /dev/null
+++ b/templates/activities/BlankActivity/recipe.xml.ftl
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<recipe>
+ <merge from="AndroidManifest.xml.ftl" />
+
+ <copy from="res/drawable-hdpi" />
+ <copy from="res/drawable-mdpi" />
+ <copy from="res/drawable-xhdpi" />
+
+ <copy from="res/menu/main.xml"
+ to="res/menu/${menuName}.xml" />
+
+ <merge from="res/values/dimens.xml" />
+ <merge from="res/values-large/dimens.xml" />
+ <merge from="res/values/strings.xml.ftl" />
+
+ <!-- Decide whether or not to add the support library -->
+ <#if navType != "none">
+ <copy from="${android.templatesRes}/android-support-v4.jar.bin"
+ to="libs/android-support-v4.jar" />
+ </#if>
+
+ <!-- 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" />
+
+ <#elseif navType == "tabs" || navType == "dropdown">
+ <instantiate from="res/layout/activity_fragment_container.xml"
+ to="res/layout/${layoutName}.xml" />
+
+ <#else>
+ <instantiate from="res/layout/activity_simple.xml"
+ to="res/layout/${layoutName}.xml" />
+ </#if>
+
+ <!-- Decide which activity code to add -->
+ <#if navType == "none">
+ <instantiate from="src/app_package/SimpleActivity.java.ftl"
+ to="${srcOut}/${activityClass}.java" />
+
+ <#elseif navType == "tabs_pager" || navType == "pager_strip">
+ <instantiate from="src/app_package/TabsAndPagerActivity.java.ftl"
+ to="${srcOut}/${activityClass}.java" />
+
+ <#elseif navType == "tabs">
+ <instantiate from="src/app_package/TabsActivity.java.ftl"
+ to="${srcOut}/${activityClass}.java" />
+
+ <#elseif navType == "dropdown">
+ <instantiate from="src/app_package/DropdownActivity.java.ftl"
+ to="${srcOut}/${activityClass}.java" />
+
+ </#if>
+
+ <open file="res/layout/${layoutName}.xml" />
+</recipe>
diff --git a/templates/activities/BlankActivity/root/AndroidManifest.xml.ftl b/templates/activities/BlankActivity/root/AndroidManifest.xml.ftl
new file mode 100644
index 0000000..ffcce79
--- /dev/null
+++ b/templates/activities/BlankActivity/root/AndroidManifest.xml.ftl
@@ -0,0 +1,15 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <application>
+
+ <activity android:name=".${activityClass}"
+ android:label="@string/activity_name">
+ <intent-filter android:label="@string/activity_name">
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+</manifest>
diff --git a/templates/activities/BlankActivity/root/res/drawable-hdpi/ic_action_search.png b/templates/activities/BlankActivity/root/res/drawable-hdpi/ic_action_search.png
new file mode 100644
index 0000000..67de12d
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/drawable-hdpi/ic_action_search.png
Binary files differ
diff --git a/templates/activities/BlankActivity/root/res/drawable-mdpi/ic_action_search.png b/templates/activities/BlankActivity/root/res/drawable-mdpi/ic_action_search.png
new file mode 100644
index 0000000..134d549
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/drawable-mdpi/ic_action_search.png
Binary files differ
diff --git a/templates/activities/BlankActivity/root/res/drawable-xhdpi/ic_action_search.png b/templates/activities/BlankActivity/root/res/drawable-xhdpi/ic_action_search.png
new file mode 100644
index 0000000..d699c6b
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/drawable-xhdpi/ic_action_search.png
Binary files differ
diff --git a/templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml b/templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml
new file mode 100644
index 0000000..3128b5f
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml
@@ -0,0 +1,6 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".${activityClass}" />
diff --git a/templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl b/templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl
new file mode 100644
index 0000000..c8f1604
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl
@@ -0,0 +1,22 @@
+<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".${activityClass}"<#if navType != "pager_strip"> /><#else>>
+
+ <!--
+ This title strip will display the currently visible page title, as well as the page
+ titles for adjacent pages.
+ -->
+ <android.support.v4.view.PagerTitleStrip android:id="@+id/pager_title_strip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:background="#33b5e5"
+ android:textColor="#fff"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp" />
+
+</android.support.v4.view.ViewPager>
+</#if>
diff --git a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml
new file mode 100644
index 0000000..aa34ee3
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml
@@ -0,0 +1,8 @@
+<TextView 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"
+ android:gravity="center"
+ android:text="@string/hello_world"
+ android:padding="@dimen/padding_medium"
+ tools:context=".${activityClass}" />
diff --git a/templates/activities/BlankActivity/root/res/menu/main.xml b/templates/activities/BlankActivity/root/res/menu/main.xml
new file mode 100644
index 0000000..cfc10fd
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/menu/main.xml
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/menu_settings"
+ android:title="@string/menu_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never" />
+</menu>
diff --git a/templates/activities/BlankActivity/root/res/values-large/dimens.xml b/templates/activities/BlankActivity/root/res/values-large/dimens.xml
new file mode 100644
index 0000000..d8cd7c2
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/values-large/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">16dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+</resources>
diff --git a/templates/activities/BlankActivity/root/res/values/dimens.xml b/templates/activities/BlankActivity/root/res/values/dimens.xml
new file mode 100644
index 0000000..d95a70f
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">8dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+</resources>
diff --git a/templates/activities/BlankActivity/root/res/values/strings.xml.ftl b/templates/activities/BlankActivity/root/res/values/strings.xml.ftl
new file mode 100644
index 0000000..753649d
--- /dev/null
+++ b/templates/activities/BlankActivity/root/res/values/strings.xml.ftl
@@ -0,0 +1,13 @@
+<resources>
+ <string name="activity_name">${appTitle}</string>
+
+ <string name="menu_settings">Settings</string>
+
+ <string name="hello_world">Hello world!</string>
+
+ <#if navType != "none">
+ <string name="title_section1">Section 1</string>
+ <string name="title_section2">Section 2</string>
+ <string name="title_section3">Section 3</string>
+ </#if>
+</resources>
diff --git a/templates/activities/BlankActivity/root/src/app_package/DropdownActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/DropdownActivity.java.ftl
new file mode 100644
index 0000000..98c1a8f
--- /dev/null
+++ b/templates/activities/BlankActivity/root/src/app_package/DropdownActivity.java.ftl
@@ -0,0 +1,98 @@
+package ${packageName};
+
+import android.app.ActionBar;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+public class ${activityClass} extends FragmentActivity implements ActionBar.OnNavigationListener {
+
+ private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.${layoutName});
+
+ // Set up the action bar.
+ final ActionBar actionBar = getActionBar();
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+
+ // Set up the dropdown list navigation in the action bar.
+ actionBar.setListNavigationCallbacks(
+ // Specify a SpinnerAdapter to populate the dropdown list.
+ new ArrayAdapter(
+ actionBar.getThemedContext(),
+ android.R.layout.simple_list_item_1,
+ android.R.id.text1,
+ new String[]{
+ getString(R.string.title_section1),
+ getString(R.string.title_section2),
+ getString(R.string.title_section3),
+ }),
+ this);
+ }
+
+ @Override
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
+ getActionBar().setSelectedNavigationItem(
+ savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putInt(STATE_SELECTED_NAVIGATION_ITEM,
+ getActionBar().getSelectedNavigationIndex());
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.${menuName}, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onNavigationItemSelected(int position, long id) {
+ // When the given tab is selected, show the tab contents in the container
+ Fragment fragment = new DummySectionFragment();
+ Bundle args = new Bundle();
+ args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
+ fragment.setArguments(args);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.container, fragment)
+ .commit();
+ return true;
+ }
+
+ /**
+ * A dummy fragment representing a section of the app, but that simply displays dummy text.
+ */
+ public static class DummySectionFragment extends Fragment {
+ public DummySectionFragment() {
+ }
+
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ TextView textView = new TextView(getActivity());
+ textView.setGravity(Gravity.CENTER);
+ Bundle args = getArguments();
+ textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
+ return textView;
+ }
+ }
+}
diff --git a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl
new file mode 100644
index 0000000..1ebc0fa
--- /dev/null
+++ b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl
@@ -0,0 +1,19 @@
+package ${packageName};
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class ${activityClass} extends Activity {
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.${layoutName});
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.${menuName}, menu);
+ return true;
+ }
+}
diff --git a/templates/activities/BlankActivity/root/src/app_package/TabsActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/TabsActivity.java.ftl
new file mode 100644
index 0000000..ab11a7f
--- /dev/null
+++ b/templates/activities/BlankActivity/root/src/app_package/TabsActivity.java.ftl
@@ -0,0 +1,94 @@
+package ${packageName};
+
+import android.app.ActionBar;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+public class ${activityClass} extends FragmentActivity implements ActionBar.TabListener {
+
+ private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.${layoutName});
+
+ // Set up the action bar.
+ final ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+
+ // For each of the sections in the app, add a tab to the action bar.
+ actionBar.addTab(actionBar.newTab().setText(R.string.title_section1).setTabListener(this));
+ actionBar.addTab(actionBar.newTab().setText(R.string.title_section2).setTabListener(this));
+ actionBar.addTab(actionBar.newTab().setText(R.string.title_section3).setTabListener(this));
+ }
+
+ @Override
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
+ getActionBar().setSelectedNavigationItem(
+ savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putInt(STATE_SELECTED_NAVIGATION_ITEM,
+ getActionBar().getSelectedNavigationIndex());
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.${menuName}, menu);
+ return true;
+ }
+
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ // When the given tab is selected, show the tab contents in the container
+ Fragment fragment = new DummySectionFragment();
+ Bundle args = new Bundle();
+ args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
+ fragment.setArguments(args);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.container, fragment)
+ .commit();
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+
+ /**
+ * A dummy fragment representing a section of the app, but that simply displays dummy text.
+ */
+ public static class DummySectionFragment extends Fragment {
+ public DummySectionFragment() {
+ }
+
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ TextView textView = new TextView(getActivity());
+ textView.setGravity(Gravity.CENTER);
+ Bundle args = getArguments();
+ textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
+ return textView;
+ }
+ }
+}
diff --git a/templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl
new file mode 100644
index 0000000..eb47519
--- /dev/null
+++ b/templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl
@@ -0,0 +1,151 @@
+package ${packageName};
+
+import android.app.ActionBar;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+public class ${activityClass} extends FragmentActivity<#if navType?contains("tabs")> implements ActionBar.TabListener</#if> {
+
+ /**
+ * The {@link android.support.v4.view.PagerAdapter} that will provide fragments for each of the
+ * sections. We use a {@link android.support.v4.app.FragmentPagerAdapter} derivative, which will
+ * keep every loaded fragment in memory. If this becomes too memory intensive, it may be best
+ * to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}.
+ */
+ SectionsPagerAdapter mSectionsPagerAdapter;
+
+ /**
+ * The {@link ViewPager} that will host the section contents.
+ */
+ ViewPager mViewPager;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.${layoutName});
+
+ // Create the adapter that will return a fragment for each of the three primary sections
+ // of the app.
+ mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
+
+ <#if navType?contains("tabs")>
+ // Set up the action bar.
+ final ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ </#if>
+
+ // Set up the ViewPager with the sections adapter.
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+
+ <#if navType?contains("tabs")>
+ // When swiping between different sections, select the corresponding tab.
+ // We can also use ActionBar.Tab#select() to do this if we have a reference to the
+ // Tab.
+ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ @Override
+ public void onPageSelected(int position) {
+ actionBar.setSelectedNavigationItem(position);
+ }
+ });
+
+ // For each of the sections in the app, add a tab to the action bar.
+ for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
+ // Create a tab with text corresponding to the page title defined by the adapter.
+ // Also specify this Activity object, which implements the TabListener interface, as the
+ // listener for when this tab is selected.
+ actionBar.addTab(
+ actionBar.newTab()
+ .setText(mSectionsPagerAdapter.getPageTitle(i))
+ .setTabListener(this));
+ }
+ </#if>
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.${menuName}, menu);
+ return true;
+ }
+ <#if navType?contains("tabs")>
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ // When the given tab is selected, switch to the corresponding page in the ViewPager.
+ mViewPager.setCurrentItem(tab.getPosition());
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+ </#if>
+
+ /**
+ * A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the primary
+ * sections of the app.
+ */
+ public class SectionsPagerAdapter extends FragmentPagerAdapter {
+
+ public SectionsPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int i) {
+ Fragment fragment = new DummySectionFragment();
+ Bundle args = new Bundle();
+ args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public int getCount() {
+ return 3;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0: return getString(R.string.title_section1).toUpperCase();
+ case 1: return getString(R.string.title_section2).toUpperCase();
+ case 2: return getString(R.string.title_section3).toUpperCase();
+ }
+ return null;
+ }
+ }
+
+ /**
+ * A dummy fragment representing a section of the app, but that simply displays dummy text.
+ */
+ public static class DummySectionFragment extends Fragment {
+ public DummySectionFragment() {
+ }
+
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ TextView textView = new TextView(getActivity());
+ textView.setGravity(Gravity.CENTER);
+ Bundle args = getArguments();
+ textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
+ return textView;
+ }
+ }
+}
diff --git a/templates/activities/BlankActivity/template.xml b/templates/activities/BlankActivity/template.xml
new file mode 100644
index 0000000..10e6bc8
--- /dev/null
+++ b/templates/activities/BlankActivity/template.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<template
+ name="New Blank Activity"
+ description="Creates a new blank activity, with optional inner navigation.">
+
+ <category value="Activities" />
+
+ <parameter
+ id="activityClass"
+ name="Activity Name"
+ type="string"
+ constraints="class|nonempty"
+ suggest="${layoutToActivity(layoutName)}"
+ default="MainActivity"
+ help="The name of the activity class to create" />
+
+ <parameter
+ id="layoutName"
+ name="Layout Name"
+ type="string"
+ constraints="layout|unique"
+ suggest="${activityToLayout(activityClass)}"
+ default="activity_main"
+ help="The name of the layout to create for the activity" />
+
+ <parameter
+ id="navType"
+ name="Navigation Type"
+ type="enum"
+ default="none"
+ help="The type of navigation to use for the activity" >
+ <option id="none" default="true">None</option>
+ <option id="tabs">Tabs</option>
+ <option id="tabs_pager">Tabs + Swipe</option>
+ <option id="pager_strip">Swipe Views + Title Strip</option>
+ <option id="dropdown">Dropdown</option>
+ </parameter>
+
+ <parameter
+ id="appTitle"
+ name="Title"
+ type="string"
+ constraints="nonempty"
+ default="My Application"
+ help="The name of the activity. For launcher activities, the application title." />
+
+ <parameter
+ id="packageName"
+ name="Package name"
+ type="string"
+ constraints="package"
+ default="com.mycompany.myapp" />
+
+ <!-- 128x128 thumbnails relative to template.xml -->
+ <thumbs>
+ <!-- default thumbnail is required -->
+ <thumb>template_blank_activity.png</thumb>
+ <!-- attributes act as selectors based on chosen parameters -->
+ <thumb navType="none">template_blank_activity.png</thumb>
+ <thumb navType="tabs">template_blank_activity_tabs.png</thumb>
+ <thumb navType="tabs_pager">template_blank_activity_tabs_pager.png</thumb>
+ <thumb navType="pager_strip">template_blank_activity_pager.png</thumb>
+ <thumb navType="dropdown">template_blank_activity_dropdown.png</thumb>
+ </thumbs>
+
+ <globals file="globals.xml.ftl" />
+ <execute file="recipe.xml.ftl" />
+
+</template>
diff --git a/templates/activities/BlankActivity/template_blank_activity.png b/templates/activities/BlankActivity/template_blank_activity.png
new file mode 100644
index 0000000..729dd1c
--- /dev/null
+++ b/templates/activities/BlankActivity/template_blank_activity.png
Binary files differ
diff --git a/templates/activities/BlankActivity/template_blank_activity_dropdown.png b/templates/activities/BlankActivity/template_blank_activity_dropdown.png
new file mode 100644
index 0000000..09fa2cf
--- /dev/null
+++ b/templates/activities/BlankActivity/template_blank_activity_dropdown.png
Binary files differ
diff --git a/templates/activities/BlankActivity/template_blank_activity_pager.png b/templates/activities/BlankActivity/template_blank_activity_pager.png
new file mode 100644
index 0000000..7cd8e0e
--- /dev/null
+++ b/templates/activities/BlankActivity/template_blank_activity_pager.png
Binary files differ
diff --git a/templates/activities/BlankActivity/template_blank_activity_tabs.png b/templates/activities/BlankActivity/template_blank_activity_tabs.png
new file mode 100644
index 0000000..86a09d6
--- /dev/null
+++ b/templates/activities/BlankActivity/template_blank_activity_tabs.png
Binary files differ
diff --git a/templates/activities/BlankActivity/template_blank_activity_tabs_pager.png b/templates/activities/BlankActivity/template_blank_activity_tabs_pager.png
new file mode 100644
index 0000000..0697a56
--- /dev/null
+++ b/templates/activities/BlankActivity/template_blank_activity_tabs_pager.png
Binary files differ