diff options
author | Josiah Gaskin <josiahgaskin@google.com> | 2013-07-31 14:21:16 -0700 |
---|---|---|
committer | Josiah Gaskin <josiahgaskin@google.com> | 2013-07-31 14:21:16 -0700 |
commit | f7c5f6b3fb2f6bd820d0d70ec48be12df103cf12 (patch) | |
tree | 91e9e7227cc1a79a08edd6f742a918628b08d994 /templates/activities | |
parent | be3b71eb1f30ebaf063d0df63e1f082844df24a3 (diff) | |
download | sdk-f7c5f6b3fb2f6bd820d0d70ec48be12df103cf12.zip sdk-f7c5f6b3fb2f6bd820d0d70ec48be12df103cf12.tar.gz sdk-f7c5f6b3fb2f6bd820d0d70ec48be12df103cf12.tar.bz2 |
Update template location for SDK build
This change removes templates from the SDK source tree (from sdk/templates)
and points the build/tools.atree build location file to their new location
in tools/base/templates
Change-Id: Id37b24eceaae6dcc0b3bf5078a759a337cb13467
Diffstat (limited to 'templates/activities')
79 files changed, 0 insertions, 3244 deletions
diff --git a/templates/activities/BlankActivity/globals.xml.ftl b/templates/activities/BlankActivity/globals.xml.ftl deleted file mode 100644 index 11aabd7..0000000 --- a/templates/activities/BlankActivity/globals.xml.ftl +++ /dev/null @@ -1,8 +0,0 @@ -<?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="menuName" value="${classToResource(activityClass)}" /> -</globals> diff --git a/templates/activities/BlankActivity/recipe.xml.ftl b/templates/activities/BlankActivity/recipe.xml.ftl deleted file mode 100644 index 1889cdc..0000000 --- a/templates/activities/BlankActivity/recipe.xml.ftl +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0"?> -<recipe> - <merge from="AndroidManifest.xml.ftl" - to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> - - <instantiate from="res/menu/main.xml.ftl" - to="${escapeXmlAttribute(resOut)}/menu/${menuName}.xml" /> - - <merge from="res/values/strings.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values/strings.xml" /> - - <merge from="res/values/dimens.xml" - to="${escapeXmlAttribute(resOut)}/values/dimens.xml" /> - <merge from="res/values-sw600dp/dimens.xml" - to="${escapeXmlAttribute(resOut)}/values-sw600dp/dimens.xml" /> - <merge from="res/values-sw720dp-land/dimens.xml" - to="${escapeXmlAttribute(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="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> - <instantiate from="res/layout/fragment_dummy.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/fragment_${classToResource(activityClass)}_dummy.xml" /> - - <#elseif navType == "tabs" || navType == "dropdown"> - <instantiate from="res/layout/activity_fragment_container.xml" - to="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> - <instantiate from="res/layout/fragment_dummy.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/fragment_${classToResource(activityClass)}_dummy.xml" /> - - <#else> - <instantiate from="res/layout/activity_simple.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> - </#if> - - <!-- Decide which activity code to add --> - <#if navType == "none"> - <instantiate from="src/app_package/SimpleActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - - <#elseif navType == "tabs_pager" || navType == "pager_strip"> - <instantiate from="src/app_package/TabsAndPagerActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - - <#elseif navType == "tabs"> - <instantiate from="src/app_package/TabsActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - - <#elseif navType == "dropdown"> - <instantiate from="src/app_package/DropdownActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - - </#if> - - <open file="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> -</recipe> diff --git a/templates/activities/BlankActivity/root/AndroidManifest.xml.ftl b/templates/activities/BlankActivity/root/AndroidManifest.xml.ftl deleted file mode 100644 index b8ae72e..0000000 --- a/templates/activities/BlankActivity/root/AndroidManifest.xml.ftl +++ /dev/null @@ -1,24 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" > - - <application> - <activity android:name=".${activityClass}" - <#if isNewProject> - android:label="@string/app_name" - <#else> - android:label="@string/title_${activityToLayout(activityClass)}" - </#if> - <#if buildApi gte 16 && parentActivityClass != "">android:parentActivityName="${parentActivityClass}"</#if>> - <#if parentActivityClass != ""> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="${parentActivityClass}" /> - </#if> - <#if isLauncher> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </#if> - </activity> - </application> - -</manifest> diff --git a/templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml b/templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml deleted file mode 100644 index 935d379..0000000 --- a/templates/activities/BlankActivity/root/res/layout/activity_fragment_container.xml +++ /dev/null @@ -1,7 +0,0 @@ -<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}" - tools:ignore="MergeRootFrame" /> diff --git a/templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl b/templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl deleted file mode 100644 index ab57463..0000000 --- a/templates/activities/BlankActivity/root/res/layout/activity_pager.xml.ftl +++ /dev/null @@ -1,24 +0,0 @@ -<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:paddingBottom="4dp" - android:paddingTop="4dp" - android:textColor="#fff" /> - -</android.support.v4.view.ViewPager> -</#if> diff --git a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl b/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl deleted file mode 100644 index 9ddd213..0000000 --- a/templates/activities/BlankActivity/root/res/layout/activity_simple.xml.ftl +++ /dev/null @@ -1,16 +0,0 @@ -<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}"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - 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 deleted file mode 100644 index 1f21998..0000000 --- a/templates/activities/BlankActivity/root/res/layout/fragment_dummy.xml.ftl +++ /dev/null @@ -1,16 +0,0 @@ -<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 deleted file mode 100644 index e35aa1b..0000000 --- a/templates/activities/BlankActivity/root/res/menu/main.xml.ftl +++ /dev/null @@ -1,6 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <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 deleted file mode 100644 index 886b05f..0000000 --- a/templates/activities/BlankActivity/root/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,4 +0,0 @@ -<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 deleted file mode 100644 index 00059fc..0000000 --- a/templates/activities/BlankActivity/root/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<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 deleted file mode 100644 index 47c8224..0000000 --- a/templates/activities/BlankActivity/root/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ -<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 deleted file mode 100644 index 1c9bc8b..0000000 --- a/templates/activities/BlankActivity/root/res/values/strings.xml.ftl +++ /dev/null @@ -1,15 +0,0 @@ -<resources> - <#if !isNewProject> - <string name="title_${activityToLayout(activityClass)}">${escapeXmlString(activityTitle)}</string> - </#if> - - <string name="action_settings">Settings</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> - <#else> - <string name="hello_world">Hello world!</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 deleted file mode 100644 index cb0665e..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/DropdownActivity.java.ftl +++ /dev/null @@ -1,108 +0,0 @@ -package ${packageName}; - -<#if minApiLevel < 14>import android.annotation.TargetApi;</#if> -import android.app.ActionBar; -import android.os.Bundle; -<#if minApiLevel < 14>import android.content.Context; -import android.os.Build;</#if> -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.NavUtils; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.TextView; - -public class ${activityClass} extends FragmentActivity implements ActionBar.OnNavigationListener { - - /** - * The serialization (saved instance state) Bundle key representing the - * current dropdown position. - */ - private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.${layoutName}); - - // Set up the action bar to show a dropdown list. - final ActionBar actionBar = getActionBar(); - actionBar.setDisplayShowTitleEnabled(false); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - <#if parentActivityClass != ""> - // Show the Up button in the action bar. - actionBar.setDisplayHomeAsUpEnabled(true); - </#if> - - // Set up the dropdown list navigation in the action bar. - actionBar.setListNavigationCallbacks( - // Specify a SpinnerAdapter to populate the dropdown list. - new ArrayAdapter<String>( - <#if minApiLevel gte 14>actionBar.getThemedContext()<#else>getActionBarThemedContextCompat()</#if>, - 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); - } - - <#if minApiLevel < 14> - /** - * Backward-compatible version of {@link ActionBar#getThemedContext()} that - * simply returns the {@link android.app.Activity} if - * <code>getThemedContext</code> is unavailable. - */ - @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) - private Context getActionBarThemedContextCompat() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - return getActionBar().getThemedContext(); - } else { - return this; - } - } - </#if> - - @Override - public void onRestoreInstanceState(Bundle savedInstanceState) { - // Restore the previously serialized current dropdown position. - if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) { - getActionBar().setSelectedNavigationItem( - savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM)); - } - } - - @Override - public void onSaveInstanceState(Bundle outState) { - // Serialize the current dropdown position. - outState.putInt(STATE_SELECTED_NAVIGATION_ITEM, - getActionBar().getSelectedNavigationIndex()); - } - - <#include "include_onCreateOptionsMenu.java.ftl"> - <#include "include_onOptionsItemSelected.java.ftl"> - - @Override - public boolean onNavigationItemSelected(int position, long id) { - // When the given dropdown item is selected, show its contents in the - // container view. - 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; - } - - <#include "include_DummySectionFragment.java.ftl"> - -} diff --git a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl deleted file mode 100644 index 7edd647..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/SimpleActivity.java.ftl +++ /dev/null @@ -1,42 +0,0 @@ -package ${packageName}; - -import android.os.Bundle; -import android.app.Activity; -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 { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.${layoutName}); - <#if parentActivityClass != ""> - // Show the Up button in the action bar. - 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/TabsActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/TabsActivity.java.ftl deleted file mode 100644 index 0bf975e..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/TabsActivity.java.ftl +++ /dev/null @@ -1,86 +0,0 @@ -package ${packageName}; - -import android.app.ActionBar; -import android.app.FragmentTransaction; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.NavUtils; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -public class ${activityClass} extends FragmentActivity implements ActionBar.TabListener { - - /** - * The serialization (saved instance state) Bundle key representing the - * current tab position. - */ - private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.${layoutName}); - - // Set up the action bar to show tabs. - final ActionBar actionBar = getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); - <#if parentActivityClass != ""> - // Show the Up button in the action bar. - actionBar.setDisplayHomeAsUpEnabled(true); - </#if> - - // 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) { - // Restore the previously serialized current tab position. - if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) { - getActionBar().setSelectedNavigationItem( - savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM)); - } - } - - @Override - public void onSaveInstanceState(Bundle outState) { - // Serialize the current tab position. - outState.putInt(STATE_SELECTED_NAVIGATION_ITEM, - getActionBar().getSelectedNavigationIndex()); - } - - <#include "include_onCreateOptionsMenu.java.ftl"> - <#include "include_onOptionsItemSelected.java.ftl"> - - @Override - public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { - // When the given tab is selected, show the tab contents in the - // container view. - 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 onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { - } - - @Override - public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { - } - - <#include "include_DummySectionFragment.java.ftl"> - -} diff --git a/templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl b/templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl deleted file mode 100644 index 30c4f4a..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/TabsAndPagerActivity.java.ftl +++ /dev/null @@ -1,153 +0,0 @@ -package ${packageName}; - -import java.util.Locale; - -<#if navType?contains("tabs")>import android.app.ActionBar; -import android.app.FragmentTransaction;</#if> -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.app.NavUtils; -import android.support.v4.view.ViewPager; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -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; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.${layoutName}); - - <#if navType?contains("tabs")> - // Set up the action bar. - final ActionBar actionBar = getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); - <#if parentActivityClass != ""> - // Show the Up button in the action bar. - actionBar.setDisplayHomeAsUpEnabled(true); - </#if> - <#elseif parentActivityClass != ""> - // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); - </#if> - - // Create the adapter that will return a fragment for each of the three - // primary sections of the app. - mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); - - // 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 callback (listener) for when - // this tab is selected. - actionBar.addTab( - actionBar.newTab() - .setText(mSectionsPagerAdapter.getPageTitle(i)) - .setTabListener(this)); - } - </#if> - } - - <#include "include_onCreateOptionsMenu.java.ftl"> - <#include "include_onOptionsItemSelected.java.ftl"> - - <#if navType?contains("tabs")>@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 onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { - } - - @Override - public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { - }</#if> - - /** - * A {@link FragmentPagerAdapter} that returns a fragment corresponding to - * one of the sections/tabs/pages. - */ - public class SectionsPagerAdapter extends FragmentPagerAdapter { - - public SectionsPagerAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int position) { - // getItem is called to instantiate the fragment for the given page. - // Return a DummySectionFragment (defined as a static inner class - // below) with the page number as its lone argument. - Fragment fragment = new DummySectionFragment(); - Bundle args = new Bundle(); - args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1); - fragment.setArguments(args); - return fragment; - } - - @Override - public int getCount() { - // Show 3 total pages. - return 3; - } - - @Override - public CharSequence getPageTitle(int position) { - Locale l = Locale.getDefault(); - switch (position) { - case 0: - return getString(R.string.title_section1).toUpperCase(l); - case 1: - return getString(R.string.title_section2).toUpperCase(l); - case 2: - return getString(R.string.title_section3).toUpperCase(l); - } - return null; - } - } - - <#include "include_DummySectionFragment.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 deleted file mode 100644 index 8eb1399..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/include_DummySectionFragment.java.ftl +++ /dev/null @@ -1,23 +0,0 @@ - /** - * A dummy fragment representing a section of the app, but that simply - * displays dummy text. - */ - public static class DummySectionFragment extends Fragment { - /** - * The fragment argument representing the section number for this - * fragment. - */ - public static final String ARG_SECTION_NUMBER = "section_number"; - - public DummySectionFragment() { - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - 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/root/src/app_package/include_onCreateOptionsMenu.java.ftl b/templates/activities/BlankActivity/root/src/app_package/include_onCreateOptionsMenu.java.ftl deleted file mode 100644 index 005d629..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/include_onCreateOptionsMenu.java.ftl +++ /dev/null @@ -1,6 +0,0 @@ - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.${menuName}, menu); - return true; - } diff --git a/templates/activities/BlankActivity/root/src/app_package/include_onOptionsItemSelected.java.ftl b/templates/activities/BlankActivity/root/src/app_package/include_onOptionsItemSelected.java.ftl deleted file mode 100644 index e1dc462..0000000 --- a/templates/activities/BlankActivity/root/src/app_package/include_onOptionsItemSelected.java.ftl +++ /dev/null @@ -1,19 +0,0 @@ - <#if parentActivityClass != ""> - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // This ID represents the Home or Up button. In the case of this - // activity, the Up button is shown. Use NavUtils to allow users - // to navigate up one level in the application structure. For - // more details, see the Navigation pattern on Android Design: - // - // http://developer.android.com/design/patterns/navigation.html#up-vs-back - // - NavUtils.navigateUpFromSameTask(this); - return true; - } - return super.onOptionsItemSelected(item); - } - </#if> diff --git a/templates/activities/BlankActivity/template.xml b/templates/activities/BlankActivity/template.xml deleted file mode 100644 index 8b02ba9..0000000 --- a/templates/activities/BlankActivity/template.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0"?> -<template - format="3" - revision="3" - name="Blank Activity" - description="Creates a new blank activity, with an action bar and optional navigational elements such as tabs or horizontal swipe."> - <dependency name="android-support-v4" revision="8" /> - - <category value="Activities" /> - - <parameter - id="activityClass" - name="Activity Name" - type="string" - constraints="class|unique|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|nonempty" - suggest="${activityToLayout(activityClass)}" - default="activity_main" - help="The name of the layout to create for the activity" /> - - <parameter - id="activityTitle" - name="Title" - type="string" - constraints="nonempty" - default="MainActivity" - suggest="${activityClass}" - help="The name of the activity. For launcher activities, the application title." /> - - <parameter - id="isLauncher" - name="Launcher Activity" - type="boolean" - default="false" - help="If true, this activity will have a CATEGORY_LAUNCHER intent filter, making it visible in the launcher" /> - - <parameter - id="parentActivityClass" - name="Hierarchical Parent" - type="string" - constraints="activity|exists|empty" - default="" - help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> - - <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" 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> - - <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 Binary files differdeleted file mode 100644 index 729dd1c..0000000 --- a/templates/activities/BlankActivity/template_blank_activity.png +++ /dev/null diff --git a/templates/activities/BlankActivity/template_blank_activity_dropdown.png b/templates/activities/BlankActivity/template_blank_activity_dropdown.png Binary files differdeleted file mode 100644 index 09fa2cf..0000000 --- a/templates/activities/BlankActivity/template_blank_activity_dropdown.png +++ /dev/null diff --git a/templates/activities/BlankActivity/template_blank_activity_pager.png b/templates/activities/BlankActivity/template_blank_activity_pager.png Binary files differdeleted file mode 100644 index 7cd8e0e..0000000 --- a/templates/activities/BlankActivity/template_blank_activity_pager.png +++ /dev/null diff --git a/templates/activities/BlankActivity/template_blank_activity_tabs.png b/templates/activities/BlankActivity/template_blank_activity_tabs.png Binary files differdeleted file mode 100644 index 86a09d6..0000000 --- a/templates/activities/BlankActivity/template_blank_activity_tabs.png +++ /dev/null diff --git a/templates/activities/BlankActivity/template_blank_activity_tabs_pager.png b/templates/activities/BlankActivity/template_blank_activity_tabs_pager.png Binary files differdeleted file mode 100644 index 0697a56..0000000 --- a/templates/activities/BlankActivity/template_blank_activity_tabs_pager.png +++ /dev/null diff --git a/templates/activities/FullscreenActivity/globals.xml.ftl b/templates/activities/FullscreenActivity/globals.xml.ftl deleted file mode 100644 index 6d73e17..0000000 --- a/templates/activities/FullscreenActivity/globals.xml.ftl +++ /dev/null @@ -1,8 +0,0 @@ -<?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 deleted file mode 100644 index 6f121a8..0000000 --- a/templates/activities/FullscreenActivity/recipe.xml.ftl +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<recipe> - <merge from="AndroidManifest.xml.ftl" - to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> - - <merge from="res/values/attrs.xml" - to="${escapeXmlAttribute(resOut)}/values/attrs.xml" /> - <merge from="res/values/colors.xml" - to="${escapeXmlAttribute(resOut)}/values/colors.xml" /> - <merge from="res/values/styles.xml" - to="${escapeXmlAttribute(resOut)}/values/styles.xml" /> - <merge from="res/values-v11/styles.xml" - to="${escapeXmlAttribute(resOut)}/values-v11/styles.xml" /> - <instantiate from="res/layout/activity_fullscreen.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> - - <merge from="res/values/strings.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values/strings.xml" /> - - <instantiate from="src/app_package/FullscreenActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - <instantiate from="src/app_package/util/SystemUiHider.java.ftl" - to="${escapeXmlAttribute(srcOut)}/util/SystemUiHider.java" /> - <instantiate from="src/app_package/util/SystemUiHiderBase.java.ftl" - to="${escapeXmlAttribute(srcOut)}/util/SystemUiHiderBase.java" /> - <instantiate from="src/app_package/util/SystemUiHiderHoneycomb.java.ftl" - to="${escapeXmlAttribute(srcOut)}/util/SystemUiHiderHoneycomb.java" /> - - <open file="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> -</recipe> diff --git a/templates/activities/FullscreenActivity/root/AndroidManifest.xml.ftl b/templates/activities/FullscreenActivity/root/AndroidManifest.xml.ftl deleted file mode 100644 index b909732..0000000 --- a/templates/activities/FullscreenActivity/root/AndroidManifest.xml.ftl +++ /dev/null @@ -1,26 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" > - - <application> - <activity android:name=".${activityClass}" - <#if isNewProject> - android:label="@string/app_name" - <#else> - android:label="@string/title_${simpleName}" - </#if> - android:configChanges="orientation|keyboardHidden|screenSize" - android:theme="@style/FullscreenTheme" - <#if buildApi gte 16 && parentActivityClass != "">android:parentActivityName="${parentActivityClass}"</#if>> - <#if parentActivityClass != ""> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="${parentActivityClass}" /> - </#if> - <#if isLauncher> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </#if> - </activity> - </application> - -</manifest> diff --git a/templates/activities/FullscreenActivity/root/res/layout/activity_fullscreen.xml.ftl b/templates/activities/FullscreenActivity/root/res/layout/activity_fullscreen.xml.ftl deleted file mode 100644 index 39f801a..0000000 --- a/templates/activities/FullscreenActivity/root/res/layout/activity_fullscreen.xml.ftl +++ /dev/null @@ -1,46 +0,0 @@ -<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" - android:background="#0099cc" - tools:context=".${activityClass}"> - - <!-- The primary full-screen view. This can be replaced with whatever view - is needed to present your content, e.g. VideoView, SurfaceView, - TextureView, etc. --> - <TextView android:id="@+id/fullscreen_content" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:keepScreenOn="true" - android:textColor="#33b5e5" - android:textStyle="bold" - android:textSize="50sp" - android:gravity="center" - android:text="@string/dummy_content" /> - - <!-- This FrameLayout insets its children based on system windows using - android:fitsSystemWindows. --> - <FrameLayout android:layout_width="match_parent" - android:layout_height="match_parent" - android:fitsSystemWindows="true"> - - <LinearLayout android:id="@+id/fullscreen_content_controls" - style="?buttonBarStyle" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="bottom|center_horizontal" - android:background="@color/black_overlay" - android:orientation="horizontal" - tools:ignore="UselessParent"> - - <Button android:id="@+id/dummy_button" - style="?buttonBarButtonStyle" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="@string/dummy_button" /> - - </LinearLayout> - </FrameLayout> - -</FrameLayout> diff --git a/templates/activities/FullscreenActivity/root/res/values-v11/styles.xml b/templates/activities/FullscreenActivity/root/res/values-v11/styles.xml deleted file mode 100644 index feaeb70..0000000 --- a/templates/activities/FullscreenActivity/root/res/values-v11/styles.xml +++ /dev/null @@ -1,15 +0,0 @@ -<resources> - - <style name="FullscreenTheme" parent="android:Theme.Holo"> - <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item> - <item name="android:windowActionBarOverlay">true</item> - <item name="android:windowBackground">@null</item> - <item name="buttonBarStyle">?android:attr/buttonBarStyle</item> - <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item> - </style> - - <style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar"> - <item name="android:background">@color/black_overlay</item> - </style> - -</resources> diff --git a/templates/activities/FullscreenActivity/root/res/values/attrs.xml b/templates/activities/FullscreenActivity/root/res/values/attrs.xml deleted file mode 100644 index 2cf1a1a..0000000 --- a/templates/activities/FullscreenActivity/root/res/values/attrs.xml +++ /dev/null @@ -1,12 +0,0 @@ -<resources> - - <!-- Declare custom theme attributes that allow changing which styles are - used for button bars depending on the API level. - ?android:attr/buttonBarStyle is new as of API 11 so this is - necessary to support previous API levels. --> - <declare-styleable name="ButtonBarContainerTheme"> - <attr name="buttonBarStyle" format="reference" /> - <attr name="buttonBarButtonStyle" format="reference" /> - </declare-styleable> - -</resources> diff --git a/templates/activities/FullscreenActivity/root/res/values/colors.xml b/templates/activities/FullscreenActivity/root/res/values/colors.xml deleted file mode 100644 index 327c060..0000000 --- a/templates/activities/FullscreenActivity/root/res/values/colors.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - - <color name="black_overlay">#66000000</color> - -</resources> diff --git a/templates/activities/FullscreenActivity/root/res/values/strings.xml.ftl b/templates/activities/FullscreenActivity/root/res/values/strings.xml.ftl deleted file mode 100644 index 00043bd..0000000 --- a/templates/activities/FullscreenActivity/root/res/values/strings.xml.ftl +++ /dev/null @@ -1,9 +0,0 @@ -<resources> - - <#if !isNewProject> - <string name="title_${simpleName}">${escapeXmlString(activityTitle)}</string> - </#if> - <string name="dummy_button">Dummy Button</string> - <string name="dummy_content">DUMMY\nCONTENT</string> - -</resources> diff --git a/templates/activities/FullscreenActivity/root/res/values/styles.xml b/templates/activities/FullscreenActivity/root/res/values/styles.xml deleted file mode 100644 index 48bb968..0000000 --- a/templates/activities/FullscreenActivity/root/res/values/styles.xml +++ /dev/null @@ -1,22 +0,0 @@ -<resources> - - <style name="FullscreenTheme" parent="android:Theme.NoTitleBar"> - <item name="android:windowContentOverlay">@null</item> - <item name="android:windowBackground">@null</item> - <item name="buttonBarStyle">@style/ButtonBar</item> - <item name="buttonBarButtonStyle">@style/ButtonBarButton</item> - </style> - - <!-- Backward-compatible version of ?android:attr/buttonBarStyle --> - <style name="ButtonBar"> - <item name="android:paddingLeft">2dp</item> - <item name="android:paddingTop">5dp</item> - <item name="android:paddingRight">2dp</item> - <item name="android:paddingBottom">0dp</item> - <item name="android:background">@android:drawable/bottom_bar</item> - </style> - - <!-- Backward-compatible version of ?android:attr/buttonBarButtonStyle --> - <style name="ButtonBarButton" /> - -</resources> diff --git a/templates/activities/FullscreenActivity/root/src/app_package/FullscreenActivity.java.ftl b/templates/activities/FullscreenActivity/root/src/app_package/FullscreenActivity.java.ftl deleted file mode 100644 index 4714244..0000000 --- a/templates/activities/FullscreenActivity/root/src/app_package/FullscreenActivity.java.ftl +++ /dev/null @@ -1,197 +0,0 @@ -package ${packageName}; - -import ${packageName}.util.SystemUiHider; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.view.MotionEvent; -import android.view.View; -<#if parentActivityClass != ""> -import android.view.MenuItem; -import android.support.v4.app.NavUtils; -</#if> - -/** - * An example full-screen activity that shows and hides the system UI (i.e. - * status bar and navigation/system bar) with user interaction. - * - * @see SystemUiHider - */ -public class ${activityClass} extends Activity { - /** - * Whether or not the system UI should be auto-hidden after - * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds. - */ - private static final boolean AUTO_HIDE = true; - - /** - * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after - * user interaction before hiding the system UI. - */ - private static final int AUTO_HIDE_DELAY_MILLIS = 3000; - - /** - * If set, will toggle the system UI visibility upon interaction. Otherwise, - * will show the system UI visibility upon interaction. - */ - private static final boolean TOGGLE_ON_CLICK = true; - - /** - * The flags to pass to {@link SystemUiHider#getInstance}. - */ - private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION; - - /** - * The instance of the {@link SystemUiHider} for this activity. - */ - private SystemUiHider mSystemUiHider; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.${layoutName}); - <#if parentActivityClass != ""> - setupActionBar(); - </#if> - - final View controlsView = findViewById(R.id.fullscreen_content_controls); - final View contentView = findViewById(R.id.fullscreen_content); - - // Set up an instance of SystemUiHider to control the system UI for - // this activity. - mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS); - mSystemUiHider.setup(); - mSystemUiHider - .setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() { - // Cached values. - int mControlsHeight; - int mShortAnimTime; - - @Override - @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) - public void onVisibilityChange(boolean visible) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { - // If the ViewPropertyAnimator API is available - // (Honeycomb MR2 and later), use it to animate the - // in-layout UI controls at the bottom of the - // screen. - if (mControlsHeight == 0) { - mControlsHeight = controlsView.getHeight(); - } - if (mShortAnimTime == 0) { - mShortAnimTime = getResources().getInteger( - android.R.integer.config_shortAnimTime); - } - controlsView.animate() - .translationY(visible ? 0 : mControlsHeight) - .setDuration(mShortAnimTime); - } else { - // If the ViewPropertyAnimator APIs aren't - // available, simply show or hide the in-layout UI - // controls. - controlsView.setVisibility(visible ? View.VISIBLE : View.GONE); - } - - if (visible && AUTO_HIDE) { - // Schedule a hide(). - delayedHide(AUTO_HIDE_DELAY_MILLIS); - } - } - }); - - // Set up the user interaction to manually show or hide the system UI. - contentView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (TOGGLE_ON_CLICK) { - mSystemUiHider.toggle(); - } else { - mSystemUiHider.show(); - } - } - }); - - // Upon interacting with UI controls, delay any scheduled hide() - // operations to prevent the jarring behavior of controls going away - // while interacting with the UI. - findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - - // Trigger the initial hide() shortly after the activity has been - // created, to briefly hint to the user that UI controls - // are available. - delayedHide(100); - } - - <#if parentActivityClass != ""> - /** - * Set up the {@link android.app.ActionBar}, if the API is available. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - private void setupActionBar() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // This ID represents the Home or Up button. In the case of this - // activity, the Up button is shown. Use NavUtils to allow users - // to navigate up one level in the application structure. For - // more details, see the Navigation pattern on Android Design: - // - // http://developer.android.com/design/patterns/navigation.html#up-vs-back - // - // TODO: If Settings has multiple levels, Up should navigate up - // that hierarchy. - NavUtils.navigateUpFromSameTask(this); - return true; - } - return super.onOptionsItemSelected(item); - } - </#if> - - /** - * Touch listener to use for in-layout UI controls to delay hiding the - * system UI. This is to prevent the jarring behavior of controls going away - * while interacting with activity UI. - */ - View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() { - @Override - public boolean onTouch(View view, MotionEvent motionEvent) { - if (AUTO_HIDE) { - delayedHide(AUTO_HIDE_DELAY_MILLIS); - } - return false; - } - }; - - Handler mHideHandler = new Handler(); - Runnable mHideRunnable = new Runnable() { - @Override - public void run() { - mSystemUiHider.hide(); - } - }; - - /** - * Schedules a call to hide() in [delay] milliseconds, canceling any - * previously scheduled calls. - */ - private void delayedHide(int delayMillis) { - mHideHandler.removeCallbacks(mHideRunnable); - mHideHandler.postDelayed(mHideRunnable, delayMillis); - } -} diff --git a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHider.java.ftl b/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHider.java.ftl deleted file mode 100644 index 28efb77..0000000 --- a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHider.java.ftl +++ /dev/null @@ -1,172 +0,0 @@ -package ${packageName}.util; - -import android.app.Activity; -import android.os.Build; -import android.view.View; - -/** - * A utility class that helps with showing and hiding system UI such as the - * status bar and navigation/system bar. This class uses backward-compatibility - * techniques described in <a href= - * "http://developer.android.com/training/backward-compatible-ui/index.html"> - * Creating Backward-Compatible UIs</a> to ensure that devices running any - * version of ndroid OS are supported. More specifically, there are separate - * implementations of this abstract class: for newer devices, - * {@link #getInstance} will return a {@link SystemUiHiderHoneycomb} instance, - * while on older devices {@link #getInstance} will return a - * {@link SystemUiHiderBase} instance. - * <p> - * For more on system bars, see <a href= - * "http://developer.android.com/design/get-started/ui-overview.html#system-bars" - * > System Bars</a>. - * - * @see android.view.View#setSystemUiVisibility(int) - * @see android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN - */ -public abstract class SystemUiHider { - /** - * When this flag is set, the - * {@link android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} - * flag will be set on older devices, making the status bar "float" on top - * of the activity layout. This is most useful when there are no controls at - * the top of the activity layout. - * <p> - * This flag isn't used on newer devices because the <a - * href="http://developer.android.com/design/patterns/actionbar.html">action - * bar</a>, the most important structural element of an Android app, should - * be visible and not obscured by the system UI. - */ - public static final int FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES = 0x1; - - /** - * When this flag is set, {@link #show()} and {@link #hide()} will toggle - * the visibility of the status bar. If there is a navigation bar, show and - * hide will toggle low profile mode. - */ - public static final int FLAG_FULLSCREEN = 0x2; - - /** - * When this flag is set, {@link #show()} and {@link #hide()} will toggle - * the visibility of the navigation bar, if it's present on the device and - * the device allows hiding it. In cases where the navigation bar is present - * but cannot be hidden, show and hide will toggle low profile mode. - */ - public static final int FLAG_HIDE_NAVIGATION = FLAG_FULLSCREEN | 0x4; - - /** - * The activity associated with this UI hider object. - */ - protected Activity mActivity; - - /** - * The view on which {@link View#setSystemUiVisibility(int)} will be called. - */ - protected View mAnchorView; - - /** - * The current UI hider flags. - * - * @see #FLAG_FULLSCREEN - * @see #FLAG_HIDE_NAVIGATION - * @see #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES - */ - protected int mFlags; - - /** - * The current visibility callback. - */ - protected OnVisibilityChangeListener mOnVisibilityChangeListener = sDummyListener; - - /** - * Creates and returns an instance of {@link SystemUiHider} that is - * appropriate for this device. The object will be either a - * {@link SystemUiHiderBase} or {@link SystemUiHiderHoneycomb} depending on - * the device. - * - * @param activity The activity whose window's system UI should be - * controlled by this class. - * @param anchorView The view on which - * {@link View#setSystemUiVisibility(int)} will be called. - * @param flags Either 0 or any combination of {@link #FLAG_FULLSCREEN}, - * {@link #FLAG_HIDE_NAVIGATION}, and - * {@link #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES}. - */ - public static SystemUiHider getInstance(Activity activity, View anchorView, int flags) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - return new SystemUiHiderHoneycomb(activity, anchorView, flags); - } else { - return new SystemUiHiderBase(activity, anchorView, flags); - } - } - - protected SystemUiHider(Activity activity, View anchorView, int flags) { - mActivity = activity; - mAnchorView = anchorView; - mFlags = flags; - } - - /** - * Sets up the system UI hider. Should be called from - * {@link Activity#onCreate}. - */ - public abstract void setup(); - - /** - * Returns whether or not the system UI is visible. - */ - public abstract boolean isVisible(); - - /** - * Hide the system UI. - */ - public abstract void hide(); - - /** - * Show the system UI. - */ - public abstract void show(); - - /** - * Toggle the visibility of the system UI. - */ - public void toggle() { - if (isVisible()) { - hide(); - } else { - show(); - } - } - - /** - * Registers a callback, to be triggered when the system UI visibility - * changes. - */ - public void setOnVisibilityChangeListener(OnVisibilityChangeListener listener) { - if (listener == null) { - listener = sDummyListener; - } - - mOnVisibilityChangeListener = listener; - } - - /** - * A dummy no-op callback for use when there is no other listener set. - */ - private static OnVisibilityChangeListener sDummyListener = new OnVisibilityChangeListener() { - @Override - public void onVisibilityChange(boolean visible) { - } - }; - - /** - * A callback interface used to listen for system UI visibility changes. - */ - public interface OnVisibilityChangeListener { - /** - * Called when the system UI visibility has changed. - * - * @param visible True if the system UI is visible. - */ - public void onVisibilityChange(boolean visible); - } -} diff --git a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderBase.java.ftl b/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderBase.java.ftl deleted file mode 100644 index da08842..0000000 --- a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderBase.java.ftl +++ /dev/null @@ -1,63 +0,0 @@ -package ${packageName}.util; - -import android.app.Activity; -import android.view.View; -import android.view.WindowManager; - -/** - * A base implementation of {@link SystemUiHider}. Uses APIs available in all - * API levels to show and hide the status bar. - */ -public class SystemUiHiderBase extends SystemUiHider { - /** - * Whether or not the system UI is currently visible. This is a cached value - * from calls to {@link #hide()} and {@link #show()}. - */ - private boolean mVisible = true; - - /** - * Constructor not intended to be called by clients. Use - * {@link SystemUiHider#getInstance} to obtain an instance. - */ - protected SystemUiHiderBase(Activity activity, View anchorView, int flags) { - super(activity, anchorView, flags); - } - - @Override - public void setup() { - if ((mFlags & FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES) == 0) { - mActivity.getWindow().setFlags( - WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, - WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - } - } - - @Override - public boolean isVisible() { - return mVisible; - } - - @Override - public void hide() { - if ((mFlags & FLAG_FULLSCREEN) != 0) { - mActivity.getWindow().setFlags( - WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - mOnVisibilityChangeListener.onVisibilityChange(false); - mVisible = false; - } - - @Override - public void show() { - if ((mFlags & FLAG_FULLSCREEN) != 0) { - mActivity.getWindow().setFlags( - 0, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - mOnVisibilityChangeListener.onVisibilityChange(true); - mVisible = true; - } -} 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 deleted file mode 100644 index 2e2d8a9..0000000 --- a/templates/activities/FullscreenActivity/root/src/app_package/util/SystemUiHiderHoneycomb.java.ftl +++ /dev/null @@ -1,133 +0,0 @@ -package ${packageName}.util; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.os.Build; -import android.view.View; -import android.view.WindowManager; - -/** - * An API 11+ implementation of {@link SystemUiHider}. Uses APIs available in - * Honeycomb and later (specifically {@link View#setSystemUiVisibility(int)}) to - * show and hide the system UI. - */ -@TargetApi(Build.VERSION_CODES.HONEYCOMB) -public class SystemUiHiderHoneycomb extends SystemUiHiderBase { - /** - * Flags for {@link View#setSystemUiVisibility(int)} to use when showing the - * system UI. - */ - private int mShowFlags; - - /** - * Flags for {@link View#setSystemUiVisibility(int)} to use when hiding the - * system UI. - */ - private int mHideFlags; - - /** - * Flags to test against the first parameter in - * {@link android.view.View.OnSystemUiVisibilityChangeListener#onSystemUiVisibilityChange(int)} - * to determine the system UI visibility state. - */ - private int mTestFlags; - - /** - * Whether or not the system UI is currently visible. This is cached from - * {@link android.view.View.OnSystemUiVisibilityChangeListener}. - */ - private boolean mVisible = true; - - /** - * Constructor not intended to be called by clients. Use - * {@link SystemUiHider#getInstance} to obtain an instance. - */ - protected SystemUiHiderHoneycomb(Activity activity, View anchorView, int flags) { - super(activity, anchorView, flags); - - mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE; - mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; - mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; - - if ((mFlags & FLAG_FULLSCREEN) != 0) { - // If the client requested fullscreen, add flags relevant to hiding - // the status bar. Note that some of these constants are new as of - // API 16 (Jelly Bean). It is safe to use them, as they are inlined - // at compile-time and do nothing on pre-Jelly Bean devices. - mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; - mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_FULLSCREEN; - } - - if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) { - // If the client requested hiding navigation, add relevant flags. - 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; - } - } - - /** {@inheritDoc} */ - @Override - public void setup() { - mAnchorView.setOnSystemUiVisibilityChangeListener(mSystemUiVisibilityChangeListener); - } - - /** {@inheritDoc} */ - @Override - public void hide() { - mAnchorView.setSystemUiVisibility(mHideFlags); - } - - /** {@inheritDoc} */ - @Override - public void show() { - mAnchorView.setSystemUiVisibility(mShowFlags); - } - - /** {@inheritDoc} */ - @Override - public boolean isVisible() { - return mVisible; - } - - private View.OnSystemUiVisibilityChangeListener mSystemUiVisibilityChangeListener - = new View.OnSystemUiVisibilityChangeListener() { - @Override - public void onSystemUiVisibilityChange(int vis) { - // Test against mTestFlags to see if the system UI is visible. - if ((vis & mTestFlags) != 0) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { - // Pre-Jelly Bean, we must manually hide the action bar - // and use the old window flags API. - mActivity.getActionBar().hide(); - mActivity.getWindow().setFlags( - WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - - // Trigger the registered listener and cache the visibility - // state. - mOnVisibilityChangeListener.onVisibilityChange(false); - mVisible = false; - - } else { - mAnchorView.setSystemUiVisibility(mShowFlags); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { - // Pre-Jelly Bean, we must manually show the action bar - // and use the old window flags API. - mActivity.getActionBar().show(); - mActivity.getWindow().setFlags( - 0, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - - // Trigger the registered listener and cache the visibility - // state. - mOnVisibilityChangeListener.onVisibilityChange(true); - mVisible = true; - } - } - }; -} diff --git a/templates/activities/FullscreenActivity/template.xml b/templates/activities/FullscreenActivity/template.xml deleted file mode 100644 index d2617fb..0000000 --- a/templates/activities/FullscreenActivity/template.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0"?> -<template - format="3" - revision="3" - name="Fullscreen Activity" - description="Creates a new activity that toggles the visibility of the system UI (status and navigation bars) and action bar upon user interaction." - minApi="4" - minBuildApi="16"> - <dependency name="android-support-v4" revision="8" /> - - <category value="Activities" /> - - <parameter - id="activityClass" - name="Activity Name" - type="string" - constraints="class|unique|nonempty" - default="FullscreenActivity" - help="The name of the activity class to create" /> - - <parameter - id="layoutName" - name="Layout Name" - type="string" - constraints="layout|unique|nonempty" - suggest="${activityToLayout(activityClass)}" - default="activity_fullscreen" - help="The name of the layout to create for the activity" /> - - <parameter - id="activityTitle" - name="Title" - type="string" - constraints="nonempty" - default="FullscreenActivity" - suggest="${activityClass}" - help="The name of the activity." /> - - <parameter - id="isLauncher" - name="Launcher Activity" - type="boolean" - default="false" - help="If true, this activity will have a CATEGORY_LAUNCHER intent filter, making it visible in the launcher" /> - - <parameter - id="parentActivityClass" - name="Hierarchical Parent" - type="string" - constraints="activity|exists|empty" - default="" - help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> - - <parameter - id="packageName" - name="Package name" - type="string" - constraints="package" - default="com.mycompany.myapp" /> - - <thumbs> - <thumb>template_fullscreen_activity.png</thumb> - </thumbs> - - <globals file="globals.xml.ftl" /> - <execute file="recipe.xml.ftl" /> - -</template> diff --git a/templates/activities/FullscreenActivity/template_fullscreen_activity.png b/templates/activities/FullscreenActivity/template_fullscreen_activity.png Binary files differdeleted file mode 100644 index a8597b2..0000000 --- a/templates/activities/FullscreenActivity/template_fullscreen_activity.png +++ /dev/null diff --git a/templates/activities/LoginActivity/globals.xml.ftl b/templates/activities/LoginActivity/globals.xml.ftl deleted file mode 100644 index fbe8985..0000000 --- a/templates/activities/LoginActivity/globals.xml.ftl +++ /dev/null @@ -1,9 +0,0 @@ -<?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="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 deleted file mode 100644 index 94f93d6..0000000 --- a/templates/activities/LoginActivity/recipe.xml.ftl +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0"?> -<recipe> - <merge from="AndroidManifest.xml.ftl" - to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> - - <merge from="res/values/styles.xml" - to="${escapeXmlAttribute(resOut)}/values/styles.xml" /> - <merge from="res/values-large/styles.xml" - to="${escapeXmlAttribute(resOut)}/values-large/styles.xml" /> - <copy from="res/menu/activity_login.xml" - to="${escapeXmlAttribute(resOut)}/menu/${menuName}.xml" /> - <instantiate from="res/layout/activity_login.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> - - <instantiate from="res/values/strings.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values/strings_${simpleName}.xml" /> - - <instantiate from="src/app_package/LoginActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - - <open file="${escapeXmlAttribute(resOut)}/layout/${layoutName}.xml" /> -</recipe> diff --git a/templates/activities/LoginActivity/root/AndroidManifest.xml.ftl b/templates/activities/LoginActivity/root/AndroidManifest.xml.ftl deleted file mode 100644 index c5f02d2..0000000 --- a/templates/activities/LoginActivity/root/AndroidManifest.xml.ftl +++ /dev/null @@ -1,19 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" > - - <application> - <activity android:name=".${activityClass}" - <#if isNewProject> - android:label="@string/app_name" - <#else> - android:label="@string/title_${simpleName}" - </#if> - android:windowSoftInputMode="adjustResize|stateVisible" - <#if buildApi gte 16 && parentActivityClass != "">android:parentActivityName="${parentActivityClass}"</#if>> - <#if parentActivityClass != ""> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="${parentActivityClass}" /> - </#if> - </activity> - </application> - -</manifest> diff --git a/templates/activities/LoginActivity/root/res/layout/activity_login.xml.ftl b/templates/activities/LoginActivity/root/res/layout/activity_login.xml.ftl deleted file mode 100644 index 9434e5b..0000000 --- a/templates/activities/LoginActivity/root/res/layout/activity_login.xml.ftl +++ /dev/null @@ -1,69 +0,0 @@ -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - tools:context=".${activityClass}"> - - <!-- Login progress --> - <LinearLayout android:id="@+id/login_status" - android:visibility="gone" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center" - android:gravity="center_horizontal" - android:orientation="vertical"> - <ProgressBar style="?android:attr/progressBarStyleLarge" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp"/> - <TextView - android:id="@+id/login_status_message" - android:textAppearance="?android:attr/textAppearanceMedium" - android:fontFamily="sans-serif-light" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="16dp" - android:text="@string/login_progress_signing_in" /> - </LinearLayout> - - <!-- Login form --> - <ScrollView - android:id="@+id/login_form" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout style="@style/LoginFormContainer" - android:orientation="vertical"> - - <EditText - android:id="@+id/email" - android:singleLine="true" - android:maxLines="1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:inputType="textEmailAddress" - android:hint="@string/prompt_email" /> - - <EditText - android:id="@+id/password" - android:singleLine="true" - android:maxLines="1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/prompt_password" - android:inputType="textPassword" - android:imeActionLabel="@string/action_sign_in_short" - android:imeActionId="@+id/login" - android:imeOptions="actionUnspecified" /> - - <Button android:id="@+id/sign_in_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:text="@string/action_sign_in_register" - android:paddingLeft="32dp" - android:paddingRight="32dp" - android:layout_gravity="right" /> - - </LinearLayout> - - </ScrollView> -</merge> diff --git a/templates/activities/LoginActivity/root/res/menu/activity_login.xml b/templates/activities/LoginActivity/root/res/menu/activity_login.xml deleted file mode 100644 index 2965794..0000000 --- a/templates/activities/LoginActivity/root/res/menu/activity_login.xml +++ /dev/null @@ -1,5 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <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-large/styles.xml b/templates/activities/LoginActivity/root/res/values-large/styles.xml deleted file mode 100644 index 7b56acd..0000000 --- a/templates/activities/LoginActivity/root/res/values-large/styles.xml +++ /dev/null @@ -1,10 +0,0 @@ -<resources> - - <style name="LoginFormContainer"> - <item name="android:layout_width">400dp</item> - <item name="android:layout_height">wrap_content</item> - <item name="android:layout_gravity">center</item> - <item name="android:padding">16dp</item> - </style> - -</resources> diff --git a/templates/activities/LoginActivity/root/res/values/strings.xml.ftl b/templates/activities/LoginActivity/root/res/values/strings.xml.ftl deleted file mode 100644 index def1b2f..0000000 --- a/templates/activities/LoginActivity/root/res/values/strings.xml.ftl +++ /dev/null @@ -1,21 +0,0 @@ -<resources> - <#if !isNewProject> - <string name="title_${simpleName}">${escapeXmlString(activityTitle)}</string> - </#if> - - <!-- Strings related to login --> - <string name="prompt_email">Email</string> - <string name="prompt_password">Password</string> - - <string name="action_sign_in_register"><b>Sign in</b> or register</string> - <string name="action_sign_in_short">Sign in</string> - - <string name="action_forgot_password">Recover lost password</string> - - <string name="login_progress_signing_in">Signing in…</string> - - <string name="error_invalid_email">This email address is invalid</string> - <string name="error_invalid_password">This password is too short</string> - <string name="error_incorrect_password">This password is incorrect</string> - <string name="error_field_required">This field is required</string> -</resources> diff --git a/templates/activities/LoginActivity/root/res/values/styles.xml b/templates/activities/LoginActivity/root/res/values/styles.xml deleted file mode 100644 index eaec28d..0000000 --- a/templates/activities/LoginActivity/root/res/values/styles.xml +++ /dev/null @@ -1,9 +0,0 @@ -<resources> - - <style name="LoginFormContainer"> - <item name="android:layout_width">match_parent</item> - <item name="android:layout_height">wrap_content</item> - <item name="android:padding">16dp</item> - </style> - -</resources> diff --git a/templates/activities/LoginActivity/root/src/app_package/LoginActivity.java.ftl b/templates/activities/LoginActivity/root/src/app_package/LoginActivity.java.ftl deleted file mode 100644 index 8defdc7..0000000 --- a/templates/activities/LoginActivity/root/src/app_package/LoginActivity.java.ftl +++ /dev/null @@ -1,278 +0,0 @@ -package ${packageName}; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.annotation.TargetApi; -import android.app.Activity; -import android.os.AsyncTask; -import android.os.Build; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.widget.EditText; -import android.widget.TextView; -<#if parentActivityClass != ""> -import android.view.MenuItem; -import android.support.v4.app.NavUtils; -</#if> - -/** - * Activity which displays a login screen to the user, offering registration as - * well. - */ -public class ${activityClass} extends Activity { - /** - * A dummy authentication store containing known user names and passwords. - * TODO: remove after connecting to a real authentication system. - */ - private static final String[] DUMMY_CREDENTIALS = new String[]{ - "foo@example.com:hello", - "bar@example.com:world" - }; - - /** - * The default email to populate the email field with. - */ - public static final String EXTRA_EMAIL = "com.example.android.authenticatordemo.extra.EMAIL"; - - /** - * Keep track of the login task to ensure we can cancel it if requested. - */ - private UserLoginTask mAuthTask = null; - - // Values for email and password at the time of the login attempt. - private String mEmail; - private String mPassword; - - // UI references. - private EditText mEmailView; - private EditText mPasswordView; - private View mLoginFormView; - private View mLoginStatusView; - private TextView mLoginStatusMessageView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.${layoutName}); - <#if parentActivityClass != ""> - setupActionBar(); - </#if> - - // Set up the login form. - mEmail = getIntent().getStringExtra(EXTRA_EMAIL); - mEmailView = (EditText) findViewById(R.id.email); - mEmailView.setText(mEmail); - - mPasswordView = (EditText) findViewById(R.id.password); - mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { - if (id == R.id.login || id == EditorInfo.IME_NULL) { - attemptLogin(); - return true; - } - return false; - } - }); - - mLoginFormView = findViewById(R.id.login_form); - mLoginStatusView = findViewById(R.id.login_status); - mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message); - - findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - attemptLogin(); - } - }); - } - - <#if parentActivityClass != ""> - /** - * Set up the {@link android.app.ActionBar}, if the API is available. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - private void setupActionBar() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // This ID represents the Home or Up button. In the case of this - // activity, the Up button is shown. Use NavUtils to allow users - // to navigate up one level in the application structure. For - // more details, see the Navigation pattern on Android Design: - // - // http://developer.android.com/design/patterns/navigation.html#up-vs-back - // - // TODO: If Settings has multiple levels, Up should navigate up - // that hierarchy. - NavUtils.navigateUpFromSameTask(this); - return true; - } - return super.onOptionsItemSelected(item); - } - </#if> - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - getMenuInflater().inflate(R.menu.${menuName}, menu); - return true; - } - - /** - * Attempts to sign in or register the account specified by the login form. - * If there are form errors (invalid email, missing fields, etc.), the - * errors are presented and no actual login attempt is made. - */ - public void attemptLogin() { - if (mAuthTask != null) { - return; - } - - // Reset errors. - mEmailView.setError(null); - mPasswordView.setError(null); - - // Store values at the time of the login attempt. - mEmail = mEmailView.getText().toString(); - mPassword = mPasswordView.getText().toString(); - - boolean cancel = false; - View focusView = null; - - // Check for a valid password. - if (TextUtils.isEmpty(mPassword)) { - mPasswordView.setError(getString(R.string.error_field_required)); - focusView = mPasswordView; - cancel = true; - } else if (mPassword.length() < 4) { - mPasswordView.setError(getString(R.string.error_invalid_password)); - focusView = mPasswordView; - cancel = true; - } - - // Check for a valid email address. - if (TextUtils.isEmpty(mEmail)) { - mEmailView.setError(getString(R.string.error_field_required)); - focusView = mEmailView; - cancel = true; - } else if (!mEmail.contains("@")) { - mEmailView.setError(getString(R.string.error_invalid_email)); - focusView = mEmailView; - cancel = true; - } - - if (cancel) { - // There was an error; don't attempt login and focus the first - // form field with an error. - focusView.requestFocus(); - } else { - // Show a progress spinner, and kick off a background task to - // perform the user login attempt. - mLoginStatusMessageView.setText(R.string.login_progress_signing_in); - showProgress(true); - mAuthTask = new UserLoginTask(); - mAuthTask.execute((Void) null); - } - } - - /** - * Shows the progress UI and hides the login form. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) - private void showProgress(final boolean show) { - // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow - // for very easy animations. If available, use these APIs to fade-in - // the progress spinner. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { - int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); - - mLoginStatusView.setVisibility(View.VISIBLE); - mLoginStatusView.animate() - .setDuration(shortAnimTime) - .alpha(show ? 1 : 0) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); - } - }); - - mLoginFormView.setVisibility(View.VISIBLE); - mLoginFormView.animate() - .setDuration(shortAnimTime) - .alpha(show ? 0 : 1) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); - } - }); - } else { - // The ViewPropertyAnimator APIs are not available, so simply show - // and hide the relevant UI components. - mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); - mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); - } - } - - /** - * Represents an asynchronous login/registration task used to authenticate - * the user. - */ - public class UserLoginTask extends AsyncTask<Void, Void, Boolean> { - @Override - protected Boolean doInBackground(Void... params) { - // TODO: attempt authentication against a network service. - - try { - // Simulate network access. - Thread.sleep(2000); - } catch (InterruptedException e) { - return false; - } - - for (String credential : DUMMY_CREDENTIALS) { - String[] pieces = credential.split(":"); - if (pieces[0].equals(mEmail)) { - // Account exists, return true if the password matches. - return pieces[1].equals(mPassword); - } - } - - // TODO: register the new account here. - return true; - } - - @Override - protected void onPostExecute(final Boolean success) { - mAuthTask = null; - showProgress(false); - - if (success) { - finish(); - } else { - mPasswordView.setError(getString(R.string.error_incorrect_password)); - mPasswordView.requestFocus(); - } - } - - @Override - protected void onCancelled() { - mAuthTask = null; - showProgress(false); - } - } -} diff --git a/templates/activities/LoginActivity/template.xml b/templates/activities/LoginActivity/template.xml deleted file mode 100644 index ccfc7ad..0000000 --- a/templates/activities/LoginActivity/template.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0"?> -<template - format="3" - revision="3" - name="Login Activity" - description="Creates a new login activity, allowing users to enter an email address and password to log in to or register with your application." - minApi="3" - minBuildApi="13"> - <dependency name="android-support-v4" revision="8" /> - - <category value="Activities" /> - - <parameter - id="activityClass" - name="Activity Name" - type="string" - constraints="class|unique|nonempty" - default="LoginActivity" - help="The name of the activity class to create" /> - - <parameter - id="layoutName" - name="Layout Name" - type="string" - constraints="layout|unique|nonempty" - suggest="${activityToLayout(activityClass)}" - default="activity_login" - help="The name of the layout to create for the activity" /> - - <parameter - id="activityTitle" - name="Title" - type="string" - constraints="nonempty" - default="Sign in" - help="The name of the activity." /> - - <parameter - id="parentActivityClass" - name="Hierarchical Parent" - type="string" - constraints="activity|exists|empty" - default="" - help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> - - <parameter - id="packageName" - name="Package name" - type="string" - constraints="package" - default="com.mycompany.myapp" /> - - <thumbs> - <thumb>template_login_activity.png</thumb> - </thumbs> - - <globals file="globals.xml.ftl" /> - <execute file="recipe.xml.ftl" /> - -</template> diff --git a/templates/activities/LoginActivity/template_login_activity.png b/templates/activities/LoginActivity/template_login_activity.png Binary files differdeleted file mode 100644 index 0f9bfc0..0000000 --- a/templates/activities/LoginActivity/template_login_activity.png +++ /dev/null diff --git a/templates/activities/MasterDetailFlow/globals.xml.ftl b/templates/activities/MasterDetailFlow/globals.xml.ftl deleted file mode 100644 index 415d60e..0000000 --- a/templates/activities/MasterDetailFlow/globals.xml.ftl +++ /dev/null @@ -1,11 +0,0 @@ -<?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" /> - <global id="detail_name" value="${extractLetters(objectKind?lower_case)}_detail" /> -</globals> diff --git a/templates/activities/MasterDetailFlow/recipe.xml.ftl b/templates/activities/MasterDetailFlow/recipe.xml.ftl deleted file mode 100644 index 4b39f74..0000000 --- a/templates/activities/MasterDetailFlow/recipe.xml.ftl +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<recipe> - <merge from="AndroidManifest.xml.ftl" - to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> - - <merge from="res/values-large/refs.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values-large/refs.xml" /> - <merge from="res/values-sw600dp/refs.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values-sw600dp/refs.xml" /> - <merge from="res/values/strings.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values/strings.xml" /> - - <instantiate from="res/layout/activity_content_detail.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/activity_${detail_name}.xml" /> - <instantiate from="res/layout/activity_content_list.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/activity_${collection_name}.xml" /> - <instantiate from="res/layout/activity_content_twopane.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/activity_${extractLetters(objectKind?lower_case)}_twopane.xml" /> - <instantiate from="res/layout/fragment_content_detail.xml.ftl" - to="${escapeXmlAttribute(resOut)}/layout/fragment_${detail_name}.xml" /> - - <instantiate from="src/app_package/ContentDetailActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${DetailName}Activity.java" /> - <instantiate from="src/app_package/ContentDetailFragment.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${DetailName}Fragment.java" /> - <instantiate from="src/app_package/ContentListActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${CollectionName}Activity.java" /> - <instantiate from="src/app_package/ContentListFragment.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${CollectionName}Fragment.java" /> - <instantiate from="src/app_package/dummy/DummyContent.java.ftl" - to="${escapeXmlAttribute(srcOut)}/dummy/DummyContent.java" /> -</recipe> diff --git a/templates/activities/MasterDetailFlow/root/AndroidManifest.xml.ftl b/templates/activities/MasterDetailFlow/root/AndroidManifest.xml.ftl deleted file mode 100644 index 4707bd6..0000000 --- a/templates/activities/MasterDetailFlow/root/AndroidManifest.xml.ftl +++ /dev/null @@ -1,31 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android"> - - <application> - <activity android:name=".${CollectionName}Activity" - <#if isNewProject> - android:label="@string/app_name" - <#else> - android:label="@string/title_${collection_name}" - </#if> - <#if buildApi gte 16 && parentActivityClass != "">android:parentActivityName="${parentActivityClass}"</#if>> - <#if parentActivityClass != ""> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="${parentActivityClass}" /> - </#if> - <#if isLauncher> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </#if> - </activity> - - <activity android:name=".${DetailName}Activity" - android:label="@string/title_${detail_name}" - <#if buildApi gte 16>android:parentActivityName=".${CollectionName}Activity"</#if>> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value=".${CollectionName}Activity" /> - </activity> - </application> - -</manifest> diff --git a/templates/activities/MasterDetailFlow/root/res/layout/activity_content_detail.xml.ftl b/templates/activities/MasterDetailFlow/root/res/layout/activity_content_detail.xml.ftl deleted file mode 100644 index ddc1ecc..0000000 --- a/templates/activities/MasterDetailFlow/root/res/layout/activity_content_detail.xml.ftl +++ /dev/null @@ -1,7 +0,0 @@ -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/${detail_name}_container" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".${DetailName}Activity" - tools:ignore="MergeRootFrame" /> diff --git a/templates/activities/MasterDetailFlow/root/res/layout/activity_content_list.xml.ftl b/templates/activities/MasterDetailFlow/root/res/layout/activity_content_list.xml.ftl deleted file mode 100644 index 065cd42..0000000 --- a/templates/activities/MasterDetailFlow/root/res/layout/activity_content_list.xml.ftl +++ /dev/null @@ -1,10 +0,0 @@ -<fragment xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/${collection_name}" - android:name="${packageName}.${CollectionName}Fragment" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - tools:context=".${CollectionName}Activity" - tools:layout="@android:layout/list_content" /> diff --git a/templates/activities/MasterDetailFlow/root/res/layout/activity_content_twopane.xml.ftl b/templates/activities/MasterDetailFlow/root/res/layout/activity_content_twopane.xml.ftl deleted file mode 100644 index 575e9e6..0000000 --- a/templates/activities/MasterDetailFlow/root/res/layout/activity_content_twopane.xml.ftl +++ /dev/null @@ -1,38 +0,0 @@ -<LinearLayout 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:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:baselineAligned="false" - android:divider="?android:attr/dividerHorizontal" - android:orientation="horizontal" - android:showDividers="middle" - tools:context=".${CollectionName}Activity"> - - <!-- - This layout is a two-pane layout for the ${objectKindPlural} - master/detail flow. See res/values-large/refs.xml and - res/values-sw600dp/refs.xml for an example of layout aliases - that replace the single-pane version of the layout with - this two-pane version. - - For more on layout aliases, see: - http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters - --> - - <fragment - android:id="@+id/${collection_name}" - android:name="${packageName}.${CollectionName}Fragment" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - tools:layout="@android:layout/list_content" /> - - <FrameLayout - android:id="@+id/${detail_name}_container" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="3" /> - -</LinearLayout> diff --git a/templates/activities/MasterDetailFlow/root/res/layout/fragment_content_detail.xml.ftl b/templates/activities/MasterDetailFlow/root/res/layout/fragment_content_detail.xml.ftl deleted file mode 100644 index 808fc31..0000000 --- a/templates/activities/MasterDetailFlow/root/res/layout/fragment_content_detail.xml.ftl +++ /dev/null @@ -1,9 +0,0 @@ -<TextView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/${detail_name}" - style="?android:attr/textAppearanceLarge" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:padding="16dp" - android:textIsSelectable="true" - tools:context=".${DetailName}Fragment" /> diff --git a/templates/activities/MasterDetailFlow/root/res/values-large/refs.xml.ftl b/templates/activities/MasterDetailFlow/root/res/values-large/refs.xml.ftl deleted file mode 100644 index 97215c3..0000000 --- a/templates/activities/MasterDetailFlow/root/res/values-large/refs.xml.ftl +++ /dev/null @@ -1,10 +0,0 @@ -<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 type="layout" name="activity_${collection_name}">@layout/activity_${extractLetters(objectKind?lower_case)}_twopane</item> -</resources> diff --git a/templates/activities/MasterDetailFlow/root/res/values-sw600dp/refs.xml.ftl b/templates/activities/MasterDetailFlow/root/res/values-sw600dp/refs.xml.ftl deleted file mode 100644 index d592404..0000000 --- a/templates/activities/MasterDetailFlow/root/res/values-sw600dp/refs.xml.ftl +++ /dev/null @@ -1,11 +0,0 @@ -<resources> - <!-- - Layout alias to replace the single-pane version of the layout with a - two-pane version on screens with a smallest width (smallest dimension) - of at least 600 density-independent pixels (dips). - - For more on layout aliases, see: - http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters - --> - <item type="layout" name="activity_${collection_name}">@layout/activity_${extractLetters(objectKind?lower_case)}_twopane</item> -</resources> diff --git a/templates/activities/MasterDetailFlow/root/res/values/strings.xml.ftl b/templates/activities/MasterDetailFlow/root/res/values/strings.xml.ftl deleted file mode 100644 index ea882bc..0000000 --- a/templates/activities/MasterDetailFlow/root/res/values/strings.xml.ftl +++ /dev/null @@ -1,6 +0,0 @@ -<resources> - <#if !isNewProject> - <string name="title_${collection_name}">${escapeXmlString(objectKindPlural)}</string> - </#if> - <string name="title_${detail_name}">${escapeXmlString(objectKind)} Detail</string> -</resources> diff --git a/templates/activities/MasterDetailFlow/root/src/app_package/ContentDetailActivity.java.ftl b/templates/activities/MasterDetailFlow/root/src/app_package/ContentDetailActivity.java.ftl deleted file mode 100644 index 2cc6054..0000000 --- a/templates/activities/MasterDetailFlow/root/src/app_package/ContentDetailActivity.java.ftl +++ /dev/null @@ -1,67 +0,0 @@ -package ${packageName}; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.NavUtils; -import android.view.MenuItem; - -/** - * An activity representing a single ${objectKind} detail screen. This - * activity is only used on handset devices. On tablet-size devices, - * item details are presented side-by-side with a list of items - * in a {@link ${CollectionName}Activity}. - * <p> - * This activity is mostly just a 'shell' activity containing nothing - * more than a {@link ${DetailName}Fragment}. - */ -public class ${DetailName}Activity extends FragmentActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_${detail_name}); - - // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); - - // savedInstanceState is non-null when there is fragment state - // saved from previous configurations of this activity - // (e.g. when rotating the screen from portrait to landscape). - // In this case, the fragment will automatically be re-added - // to its container so we don't need to manually add it. - // For more information, see the Fragments API guide at: - // - // http://developer.android.com/guide/components/fragments.html - // - if (savedInstanceState == null) { - // Create the detail fragment and add it to the activity - // using a fragment transaction. - Bundle arguments = new Bundle(); - arguments.putString(${DetailName}Fragment.ARG_ITEM_ID, - getIntent().getStringExtra(${DetailName}Fragment.ARG_ITEM_ID)); - ${DetailName}Fragment fragment = new ${DetailName}Fragment(); - fragment.setArguments(arguments); - getSupportFragmentManager().beginTransaction() - .add(R.id.${detail_name}_container, fragment) - .commit(); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // This ID represents the Home or Up button. In the case of this - // activity, the Up button is shown. Use NavUtils to allow users - // to navigate up one level in the application structure. For - // more details, see the Navigation pattern on Android Design: - // - // http://developer.android.com/design/patterns/navigation.html#up-vs-back - // - NavUtils.navigateUpTo(this, new Intent(this, ${CollectionName}Activity.class)); - return true; - } - return super.onOptionsItemSelected(item); - } -} diff --git a/templates/activities/MasterDetailFlow/root/src/app_package/ContentDetailFragment.java.ftl b/templates/activities/MasterDetailFlow/root/src/app_package/ContentDetailFragment.java.ftl deleted file mode 100644 index 2cecaec..0000000 --- a/templates/activities/MasterDetailFlow/root/src/app_package/ContentDetailFragment.java.ftl +++ /dev/null @@ -1,61 +0,0 @@ -package ${packageName}; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import ${packageName}.dummy.DummyContent; - -/** - * A fragment representing a single ${objectKind} detail screen. - * This fragment is either contained in a {@link ${CollectionName}Activity} - * in two-pane mode (on tablets) or a {@link ${DetailName}Activity} - * on handsets. - */ -public class ${DetailName}Fragment extends Fragment { - /** - * The fragment argument representing the item ID that this fragment - * represents. - */ - public static final String ARG_ITEM_ID = "item_id"; - - /** - * The dummy content this fragment is presenting. - */ - private DummyContent.DummyItem mItem; - - /** - * Mandatory empty constructor for the fragment manager to instantiate the - * fragment (e.g. upon screen orientation changes). - */ - public ${DetailName}Fragment() { - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (getArguments().containsKey(ARG_ITEM_ID)) { - // Load the dummy content specified by the fragment - // arguments. In a real-world scenario, use a Loader - // to load content from a content provider. - mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_${detail_name}, container, false); - - // Show the dummy content as text in a TextView. - if (mItem != null) { - ((TextView) rootView.findViewById(R.id.${detail_name})).setText(mItem.content); - } - - return rootView; - } -} diff --git a/templates/activities/MasterDetailFlow/root/src/app_package/ContentListActivity.java.ftl b/templates/activities/MasterDetailFlow/root/src/app_package/ContentListActivity.java.ftl deleted file mode 100644 index ae73f7d..0000000 --- a/templates/activities/MasterDetailFlow/root/src/app_package/ContentListActivity.java.ftl +++ /dev/null @@ -1,105 +0,0 @@ -package ${packageName}; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v4.app.FragmentActivity; -<#if parentActivityClass != "">import android.support.v4.app.NavUtils; -import android.view.MenuItem;</#if> - -/** - * An activity representing a list of ${objectKindPlural}. This activity - * has different presentations for handset and tablet-size devices. On - * handsets, the activity presents a list of items, which when touched, - * lead to a {@link ${DetailName}Activity} representing - * item details. On tablets, the activity presents the list of items and - * item details side-by-side using two vertical panes. - * <p> - * The activity makes heavy use of fragments. The list of items is a - * {@link ${CollectionName}Fragment} and the item details - * (if present) is a {@link ${DetailName}Fragment}. - * <p> - * This activity also implements the required - * {@link ${CollectionName}Fragment.Callbacks} interface - * to listen for item selections. - */ -public class ${CollectionName}Activity extends FragmentActivity - implements ${CollectionName}Fragment.Callbacks { - - /** - * Whether or not the activity is in two-pane mode, i.e. running on a tablet - * device. - */ - private boolean mTwoPane; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_${collection_name}); - <#if parentActivityClass != ""> - // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); - </#if> - - if (findViewById(R.id.${detail_name}_container) != null) { - // The detail container view will be present only in the - // large-screen layouts (res/values-large and - // res/values-sw600dp). If this view is present, then the - // activity should be in two-pane mode. - mTwoPane = true; - - // In two-pane mode, list items should be given the - // 'activated' state when touched. - ((${CollectionName}Fragment) getSupportFragmentManager() - .findFragmentById(R.id.${collection_name})) - .setActivateOnItemClick(true); - } - - // TODO: If exposing deep links into your app, handle intents here. - } - <#if parentActivityClass != ""> - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // This ID represents the Home or Up button. In the case of this - // activity, the Up button is shown. Use NavUtils to allow users - // to navigate up one level in the application structure. For - // more details, see the Navigation pattern on Android Design: - // - // http://developer.android.com/design/patterns/navigation.html#up-vs-back - // - NavUtils.navigateUpFromSameTask(this); - return true; - } - return super.onOptionsItemSelected(item); - } - </#if> - - /** - * Callback method from {@link ${CollectionName}Fragment.Callbacks} - * indicating that the item with the given ID was selected. - */ - @Override - public void onItemSelected(String id) { - if (mTwoPane) { - // In two-pane mode, show the detail view in this activity by - // adding or replacing the detail fragment using a - // fragment transaction. - Bundle arguments = new Bundle(); - arguments.putString(${DetailName}Fragment.ARG_ITEM_ID, id); - ${DetailName}Fragment fragment = new ${DetailName}Fragment(); - fragment.setArguments(arguments); - getSupportFragmentManager().beginTransaction() - .replace(R.id.${detail_name}_container, fragment) - .commit(); - - } else { - // In single-pane mode, simply start the detail activity - // for the selected item ID. - Intent detailIntent = new Intent(this, ${DetailName}Activity.class); - detailIntent.putExtra(${DetailName}Fragment.ARG_ITEM_ID, id); - startActivity(detailIntent); - } - } -} diff --git a/templates/activities/MasterDetailFlow/root/src/app_package/ContentListFragment.java.ftl b/templates/activities/MasterDetailFlow/root/src/app_package/ContentListFragment.java.ftl deleted file mode 100644 index e9a2e74..0000000 --- a/templates/activities/MasterDetailFlow/root/src/app_package/ContentListFragment.java.ftl +++ /dev/null @@ -1,151 +0,0 @@ -package ${packageName}; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v4.app.ListFragment; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.ListView; - -import ${packageName}.dummy.DummyContent; - -/** - * A list fragment representing a list of ${objectKindPlural}. This fragment - * also supports tablet devices by allowing list items to be given an - * 'activated' state upon selection. This helps indicate which item is - * currently being viewed in a {@link ${DetailName}Fragment}. - * <p> - * Activities containing this fragment MUST implement the {@link Callbacks} - * interface. - */ -public class ${CollectionName}Fragment extends ListFragment { - - /** - * The serialization (saved instance state) Bundle key representing the - * activated item position. Only used on tablets. - */ - private static final String STATE_ACTIVATED_POSITION = "activated_position"; - - /** - * The fragment's current callback object, which is notified of list item - * clicks. - */ - private Callbacks mCallbacks = sDummyCallbacks; - - /** - * The current activated item position. Only used on tablets. - */ - private int mActivatedPosition = ListView.INVALID_POSITION; - - /** - * A callback interface that all activities containing this fragment must - * implement. This mechanism allows activities to be notified of item - * selections. - */ - public interface Callbacks { - /** - * Callback for when an item has been selected. - */ - public void onItemSelected(String id); - } - - /** - * A dummy implementation of the {@link Callbacks} interface that does - * nothing. Used only when this fragment is not attached to an activity. - */ - private static Callbacks sDummyCallbacks = new Callbacks() { - @Override - public void onItemSelected(String id) { - } - }; - - /** - * Mandatory empty constructor for the fragment manager to instantiate the - * fragment (e.g. upon screen orientation changes). - */ - public ${CollectionName}Fragment() { - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // TODO: replace with a real list adapter. - setListAdapter(new ArrayAdapter<DummyContent.DummyItem>( - getActivity(), - android.R.layout.simple_list_item_activated_1, - android.R.id.text1, - DummyContent.ITEMS)); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - // Restore the previously serialized activated item position. - if (savedInstanceState != null - && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) { - setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); - } - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - - // Activities containing this fragment must implement its callbacks. - if (!(activity instanceof Callbacks)) { - throw new IllegalStateException("Activity must implement fragment's callbacks."); - } - - mCallbacks = (Callbacks) activity; - } - - @Override - public void onDetach() { - super.onDetach(); - - // Reset the active callbacks interface to the dummy implementation. - mCallbacks = sDummyCallbacks; - } - - @Override - public void onListItemClick(ListView listView, View view, int position, long id) { - super.onListItemClick(listView, view, position, id); - - // Notify the active callbacks interface (the activity, if the - // fragment is attached to one) that an item has been selected. - mCallbacks.onItemSelected(DummyContent.ITEMS.get(position).id); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - if (mActivatedPosition != ListView.INVALID_POSITION) { - // Serialize and persist the activated item position. - outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition); - } - } - - /** - * Turns on activate-on-click mode. When this mode is on, list items will be - * given the 'activated' state when touched. - */ - public void setActivateOnItemClick(boolean activateOnItemClick) { - // When setting CHOICE_MODE_SINGLE, ListView will automatically - // give items the 'activated' state when touched. - getListView().setChoiceMode(activateOnItemClick - ? ListView.CHOICE_MODE_SINGLE - : ListView.CHOICE_MODE_NONE); - } - - private void setActivatedPosition(int position) { - if (position == ListView.INVALID_POSITION) { - getListView().setItemChecked(mActivatedPosition, false); - } else { - getListView().setItemChecked(position, true); - } - - mActivatedPosition = position; - } -} diff --git a/templates/activities/MasterDetailFlow/root/src/app_package/dummy/DummyContent.java.ftl b/templates/activities/MasterDetailFlow/root/src/app_package/dummy/DummyContent.java.ftl deleted file mode 100644 index 3545ba3..0000000 --- a/templates/activities/MasterDetailFlow/root/src/app_package/dummy/DummyContent.java.ftl +++ /dev/null @@ -1,55 +0,0 @@ -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/activities/MasterDetailFlow/template.xml b/templates/activities/MasterDetailFlow/template.xml deleted file mode 100644 index 47de074..0000000 --- a/templates/activities/MasterDetailFlow/template.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0"?> -<template - format="3" - revision="3" - name="Master/Detail Flow" - minApi="11" - description="Creates a new master/detail flow, allowing users to view a collection of objects as well as details for each object. This flow is presented using two columns on tablet-size screens and one column on handsets and smaller screens. This template creates two activities, a master fragment, and a detail fragment."> - <dependency name="android-support-v4" revision="8" /> - - <thumbs> - <thumb>template_master_detail.png</thumb> - </thumbs> - - <category value="Flows" /> - - <parameter - id="objectKind" - name="Object Kind" - type="string" - constraints="nonempty" - default="Item" - help="Other examples are 'Person', 'Book', etc." /> - - <parameter - id="objectKindPlural" - name="Object Kind Plural" - type="string" - constraints="nonempty" - default="Items" - help="Other examples are 'People', 'Books', etc." /> - - <parameter - id="activityTitle" - name="Title" - type="string" - constraints="nonempty" - suggest="${objectKindPlural}" - default="Items" /> - - <parameter - id="isLauncher" - name="Launcher Activity" - type="boolean" - default="false" - help="If true, the primary activity in the flow will have a CATEGORY_LAUNCHER intent filter, making it visible in the launcher" /> - - <parameter - id="parentActivityClass" - name="Hierarchical Parent" - type="string" - constraints="activity|exists|empty" - default="" - help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> - - <parameter - id="packageName" - name="Package name" - type="string" - constraints="package" - default="com.mycompany.myapp" /> - - <globals file="globals.xml.ftl" /> - <execute file="recipe.xml.ftl" /> - -</template> diff --git a/templates/activities/MasterDetailFlow/template_master_detail.png b/templates/activities/MasterDetailFlow/template_master_detail.png Binary files differdeleted file mode 100644 index f9d3f23..0000000 --- a/templates/activities/MasterDetailFlow/template_master_detail.png +++ /dev/null diff --git a/templates/activities/SettingsActivity/globals.xml.ftl b/templates/activities/SettingsActivity/globals.xml.ftl deleted file mode 100644 index 6d73e17..0000000 --- a/templates/activities/SettingsActivity/globals.xml.ftl +++ /dev/null @@ -1,8 +0,0 @@ -<?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 deleted file mode 100644 index b6d46ce..0000000 --- a/templates/activities/SettingsActivity/recipe.xml.ftl +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0"?> -<recipe> - <merge from="AndroidManifest.xml.ftl" - to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" /> - - <copy from="res/xml/pref_data_sync.xml" - to="${escapeXmlAttribute(resOut)}/xml/pref_data_sync.xml" /> - <copy from="res/xml/pref_general.xml" - to="${escapeXmlAttribute(resOut)}/xml/pref_general.xml" /> - <merge from="res/xml/pref_headers.xml.ftl" - to="${escapeXmlAttribute(resOut)}/xml/pref_headers.xml" /> - <copy from="res/xml/pref_notification.xml" - to="${escapeXmlAttribute(resOut)}/xml/pref_notification.xml" /> - - <instantiate from="res/values/strings.xml.ftl" - to="${escapeXmlAttribute(resOut)}/values/strings_${simpleName}.xml" /> - - <instantiate from="src/app_package/SettingsActivity.java.ftl" - to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> - - <open file="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /> -</recipe> diff --git a/templates/activities/SettingsActivity/root/AndroidManifest.xml.ftl b/templates/activities/SettingsActivity/root/AndroidManifest.xml.ftl deleted file mode 100644 index 9f78fcf..0000000 --- a/templates/activities/SettingsActivity/root/AndroidManifest.xml.ftl +++ /dev/null @@ -1,18 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" > - - <application> - <activity android:name=".${activityClass}" - <#if isNewProject> - android:label="@string/app_name" - <#else> - android:label="@string/title_${simpleName}" - </#if> - <#if buildApi gte 16 && parentActivityClass != "">android:parentActivityName="${parentActivityClass}"</#if>> - <#if parentActivityClass != ""> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="${parentActivityClass}" /> - </#if> - </activity> - </application> - -</manifest> diff --git a/templates/activities/SettingsActivity/root/res/values/strings.xml.ftl b/templates/activities/SettingsActivity/root/res/values/strings.xml.ftl deleted file mode 100644 index 8dc52ac..0000000 --- a/templates/activities/SettingsActivity/root/res/values/strings.xml.ftl +++ /dev/null @@ -1,61 +0,0 @@ -<resources> - <#if !isNewProject> - <string name="title_${simpleName}">${escapeXmlString(activityTitle)}</string> - </#if> - - <!-- Strings related to Settings --> - - <!-- Example General settings --> - <string name="pref_header_general">General</string> - - <string name="pref_title_social_recommendations">Enable social recommendations</string> - <string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string> - - <string name="pref_title_display_name">Display name</string> - <string name="pref_default_display_name">John Smith</string> - - <string name="pref_title_add_friends_to_messages">Add friends to messages</string> - <string-array name="pref_example_list_titles"> - <item>Always</item> - <item>When possible</item> - <item>Never</item> - </string-array> - <string-array name="pref_example_list_values"> - <item>1</item> - <item>0</item> - <item>-1</item> - </string-array> - - <!-- Example settings for Data & Sync --> - <string name="pref_header_data_sync">Data & sync</string> - - <string name="pref_title_sync_frequency">Sync frequency</string> - <string-array name="pref_sync_frequency_titles"> - <item>15 minutes</item> - <item>30 minutes</item> - <item>1 hour</item> - <item>3 hours</item> - <item>6 hours</item> - <item>Never</item> - </string-array> - <string-array name="pref_sync_frequency_values"> - <item>15</item> - <item>30</item> - <item>60</item> - <item>180</item> - <item>360</item> - <item>-1</item> - </string-array> - - <string name="pref_title_system_sync_settings">System sync settings</string> - - <!-- Example settings for Notifications --> - <string name="pref_header_notifications">Notifications</string> - - <string name="pref_title_new_message_notifications">New message notifications</string> - - <string name="pref_title_ringtone">Ringtone</string> - <string name="pref_ringtone_silent">Silent</string> - - <string name="pref_title_vibrate">Vibrate</string> -</resources> diff --git a/templates/activities/SettingsActivity/root/res/xml/pref_data_sync.xml b/templates/activities/SettingsActivity/root/res/xml/pref_data_sync.xml deleted file mode 100644 index ffda831..0000000 --- a/templates/activities/SettingsActivity/root/res/xml/pref_data_sync.xml +++ /dev/null @@ -1,21 +0,0 @@ -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - - <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to - dismiss it. --> - <!-- NOTE: ListPreference's summary should be set to its value by the activity code. --> - <ListPreference - android:key="sync_frequency" - android:title="@string/pref_title_sync_frequency" - android:entries="@array/pref_sync_frequency_titles" - android:entryValues="@array/pref_sync_frequency_values" - android:defaultValue="180" - android:negativeButtonText="@null" - android:positiveButtonText="@null" /> - - <!-- This preference simply launches an intent when selected. Use this UI sparingly, per - design guidelines. --> - <Preference android:title="@string/pref_title_system_sync_settings"> - <intent android:action="android.settings.SYNC_SETTINGS" /> - </Preference> - -</PreferenceScreen> diff --git a/templates/activities/SettingsActivity/root/res/xml/pref_general.xml b/templates/activities/SettingsActivity/root/res/xml/pref_general.xml deleted file mode 100644 index c49cbed..0000000 --- a/templates/activities/SettingsActivity/root/res/xml/pref_general.xml +++ /dev/null @@ -1,33 +0,0 @@ -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - - <CheckBoxPreference - android:key="example_checkbox" - android:title="@string/pref_title_social_recommendations" - android:summary="@string/pref_description_social_recommendations" - android:defaultValue="true" /> - - <!-- NOTE: EditTextPreference accepts EditText attributes. --> - <!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. --> - <EditTextPreference - android:key="example_text" - android:title="@string/pref_title_display_name" - android:defaultValue="@string/pref_default_display_name" - android:selectAllOnFocus="true" - android:inputType="textCapWords" - android:capitalize="words" - android:singleLine="true" - android:maxLines="1" /> - - <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to - dismiss it. --> - <!-- NOTE: ListPreference's summary should be set to its value by the activity code. --> - <ListPreference - android:key="example_list" - android:title="@string/pref_title_add_friends_to_messages" - android:defaultValue="-1" - android:entries="@array/pref_example_list_titles" - android:entryValues="@array/pref_example_list_values" - android:negativeButtonText="@null" - android:positiveButtonText="@null" /> - -</PreferenceScreen> diff --git a/templates/activities/SettingsActivity/root/res/xml/pref_headers.xml.ftl b/templates/activities/SettingsActivity/root/res/xml/pref_headers.xml.ftl deleted file mode 100644 index a3da325..0000000 --- a/templates/activities/SettingsActivity/root/res/xml/pref_headers.xml.ftl +++ /dev/null @@ -1,17 +0,0 @@ -<preference-headers xmlns:android="http://schemas.android.com/apk/res/android"> - - <!-- These settings headers are only used on tablets. --> - - <header - android:fragment="${packageName}.${activityClass}$GeneralPreferenceFragment" - android:title="@string/pref_header_general" /> - - <header - android:fragment="${packageName}.${activityClass}$NotificationPreferenceFragment" - android:title="@string/pref_header_notifications" /> - - <header - android:fragment="${packageName}.${activityClass}$DataSyncPreferenceFragment" - android:title="@string/pref_header_data_sync" /> - -</preference-headers> diff --git a/templates/activities/SettingsActivity/root/res/xml/pref_notification.xml b/templates/activities/SettingsActivity/root/res/xml/pref_notification.xml deleted file mode 100644 index b4b8cae..0000000 --- a/templates/activities/SettingsActivity/root/res/xml/pref_notification.xml +++ /dev/null @@ -1,27 +0,0 @@ -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - - <!-- A 'parent' preference, which enables/disables child preferences (below) - when checked/unchecked. --> - <CheckBoxPreference - android:key="notifications_new_message" - android:title="@string/pref_title_new_message_notifications" - android:defaultValue="true" /> - - <!-- Allows the user to choose a ringtone in the 'notification' category. --> - <!-- NOTE: This preference will be enabled only when the checkbox above is checked. --> - <!-- NOTE: RingtonePreference's summary should be set to its value by the activity code. --> - <RingtonePreference - android:dependency="notifications_new_message" - android:key="notifications_new_message_ringtone" - android:title="@string/pref_title_ringtone" - android:ringtoneType="notification" - android:defaultValue="content://settings/system/notification_sound" /> - - <!-- NOTE: This preference will be enabled only when the checkbox above is checked. --> - <CheckBoxPreference - android:dependency="notifications_new_message" - android:key="notifications_new_message_vibrate" - android:title="@string/pref_title_vibrate" - android:defaultValue="true" /> - -</PreferenceScreen> diff --git a/templates/activities/SettingsActivity/root/src/app_package/SettingsActivity.java.ftl b/templates/activities/SettingsActivity/root/src/app_package/SettingsActivity.java.ftl deleted file mode 100644 index bf67aca..0000000 --- a/templates/activities/SettingsActivity/root/src/app_package/SettingsActivity.java.ftl +++ /dev/null @@ -1,295 +0,0 @@ -package ${packageName}; - -import android.annotation.TargetApi; -import android.content.Context; -import android.content.res.Configuration; -import android.media.Ringtone; -import android.media.RingtoneManager; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceCategory; -import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; -import android.preference.RingtonePreference; -import android.text.TextUtils; -<#if parentActivityClass != ""> -import android.view.MenuItem; -import android.support.v4.app.NavUtils; -</#if> - -import java.util.List; - -/** - * A {@link PreferenceActivity} that presents a set of application settings. On - * handset devices, settings are presented as a single list. On tablets, - * settings are split by category, with category headers shown to the left of - * the list of settings. - * <p> - * See <a href="http://developer.android.com/design/patterns/settings.html"> - * Android Design: Settings</a> for design guidelines and the <a - * href="http://developer.android.com/guide/topics/ui/settings.html">Settings - * API Guide</a> for more information on developing a Settings UI. - */ -public class ${activityClass} extends PreferenceActivity { - /** - * Determines whether to always show the simplified settings UI, where - * settings are presented in a single list. When false, settings are shown - * as a master/detail two-pane view on tablets. When true, a single pane is - * shown on tablets. - */ - private static final boolean ALWAYS_SIMPLE_PREFS = false; - - <#if parentActivityClass != ""> - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setupActionBar(); - } - - /** - * Set up the {@link android.app.ActionBar}, if the API is available. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - private void setupActionBar() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - // Show the Up button in the action bar. - getActionBar().setDisplayHomeAsUpEnabled(true); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // This ID represents the Home or Up button. In the case of this - // activity, the Up button is shown. Use NavUtils to allow users - // to navigate up one level in the application structure. For - // more details, see the Navigation pattern on Android Design: - // - // http://developer.android.com/design/patterns/navigation.html#up-vs-back - // - // TODO: If Settings has multiple levels, Up should navigate up - // that hierarchy. - NavUtils.navigateUpFromSameTask(this); - return true; - } - return super.onOptionsItemSelected(item); - } - </#if> - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - - setupSimplePreferencesScreen(); - } - - /** - * Shows the simplified settings UI if the device configuration if the - * device configuration dictates that a simplified, single-pane UI should be - * shown. - */ - private void setupSimplePreferencesScreen() { - if (!isSimplePreferences(this)) { - return; - } - - // In the simplified UI, fragments are not used at all and we instead - // use the older PreferenceActivity APIs. - - // Add 'general' preferences. - addPreferencesFromResource(R.xml.pref_general); - - // Add 'notifications' preferences, and a corresponding header. - PreferenceCategory fakeHeader = new PreferenceCategory(this); - fakeHeader.setTitle(R.string.pref_header_notifications); - getPreferenceScreen().addPreference(fakeHeader); - addPreferencesFromResource(R.xml.pref_notification); - - // Add 'data and sync' preferences, and a corresponding header. - fakeHeader = new PreferenceCategory(this); - fakeHeader.setTitle(R.string.pref_header_data_sync); - getPreferenceScreen().addPreference(fakeHeader); - addPreferencesFromResource(R.xml.pref_data_sync); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences to - // their values. When their values change, their summaries are updated - // to reflect the new value, per the Android Design guidelines. - bindPreferenceSummaryToValue(findPreference("example_text")); - bindPreferenceSummaryToValue(findPreference("example_list")); - bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); - bindPreferenceSummaryToValue(findPreference("sync_frequency")); - } - - /** {@inheritDoc} */ - @Override - public boolean onIsMultiPane() { - return isXLargeTablet(this) && !isSimplePreferences(this); - } - - /** - * Helper method to determine if the device has an extra-large screen. For - * example, 10" tablets are extra-large. - */ - private static boolean isXLargeTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; - } - - /** - * Determines whether the simplified settings UI should be shown. This is - * true if this is forced via {@link #ALWAYS_SIMPLE_PREFS}, or the device - * doesn't have newer APIs like {@link PreferenceFragment}, or the device - * doesn't have an extra-large screen. In these cases, a single-pane - * "simplified" settings UI should be shown. - */ - private static boolean isSimplePreferences(Context context) { - return ALWAYS_SIMPLE_PREFS - || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB - || !isXLargeTablet(context); - } - - /** {@inheritDoc} */ - @Override - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public void onBuildHeaders(List<Header> target) { - if (!isSimplePreferences(this)) { - loadHeadersFromResource(R.xml.pref_headers, target); - } - } - - /** - * A preference value change listener that updates the preference's summary - * to reflect its new value. - */ - private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - String stringValue = value.toString(); - - if (preference instanceof ListPreference) { - // For list preferences, look up the correct display value in - // the preference's 'entries' list. - ListPreference listPreference = (ListPreference) preference; - int index = listPreference.findIndexOfValue(stringValue); - - // Set the summary to reflect the new value. - preference.setSummary( - index >= 0 - ? listPreference.getEntries()[index] - : null); - - } else if (preference instanceof RingtonePreference) { - // For ringtone preferences, look up the correct display value - // using RingtoneManager. - if (TextUtils.isEmpty(stringValue)) { - // Empty values correspond to 'silent' (no ringtone). - preference.setSummary(R.string.pref_ringtone_silent); - - } else { - Ringtone ringtone = RingtoneManager.getRingtone( - preference.getContext(), Uri.parse(stringValue)); - - if (ringtone == null) { - // Clear the summary if there was a lookup error. - preference.setSummary(null); - } else { - // Set the summary to reflect the new ringtone display - // name. - String name = ringtone.getTitle(preference.getContext()); - preference.setSummary(name); - } - } - - } else { - // For all other preferences, set the summary to the value's - // simple string representation. - preference.setSummary(stringValue); - } - return true; - } - }; - - /** - * Binds a preference's summary to its value. More specifically, when the - * preference's value is changed, its summary (line of text below the - * preference title) is updated to reflect the value. The summary is also - * immediately updated upon calling this method. The exact display format is - * dependent on the type of preference. - * - * @see #sBindPreferenceSummaryToValueListener - */ - private static void bindPreferenceSummaryToValue(Preference preference) { - // Set the listener to watch for value changes. - preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); - - // Trigger the listener immediately with the preference's - // current value. - sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, - PreferenceManager - .getDefaultSharedPreferences(preference.getContext()) - .getString(preference.getKey(), "")); - } - - /** - * This fragment shows general preferences only. It is used when the - * activity is showing a two-pane settings UI. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static class GeneralPreferenceFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_general); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. - bindPreferenceSummaryToValue(findPreference("example_text")); - bindPreferenceSummaryToValue(findPreference("example_list")); - } - } - - /** - * This fragment shows notification preferences only. It is used when the - * activity is showing a two-pane settings UI. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static class NotificationPreferenceFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_notification); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. - bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); - } - } - - /** - * This fragment shows data and sync preferences only. It is used when the - * activity is showing a two-pane settings UI. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static class DataSyncPreferenceFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_data_sync); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. - bindPreferenceSummaryToValue(findPreference("sync_frequency")); - } - } -} diff --git a/templates/activities/SettingsActivity/template.xml b/templates/activities/SettingsActivity/template.xml deleted file mode 100644 index 21956d1..0000000 --- a/templates/activities/SettingsActivity/template.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0"?> -<template - format="3" - revision="3" - name="Settings Activity" - description="Creates a new application settings activity that presents alternative layouts on handset and tablet-size screens." - minApi="4" - minBuildApi="11"> - <dependency name="android-support-v4" revision="8" /> - - <category value="Activities" /> - - <parameter - id="activityClass" - name="Activity Name" - type="string" - constraints="class|unique|nonempty" - default="SettingsActivity" - help="The name of the activity class to create" /> - - <parameter - id="activityTitle" - name="Title" - type="string" - constraints="nonempty" - default="Settings" - help="The name of the activity." /> - - <parameter - id="parentActivityClass" - name="Hierarchical Parent" - type="string" - constraints="activity|exists|empty" - default="" - help="The hierarchical parent activity, used to provide a default implementation for the 'Up' button" /> - - <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_settings_activity.png</thumb> - </thumbs> - - <globals file="globals.xml.ftl" /> - <execute file="recipe.xml.ftl" /> - -</template> diff --git a/templates/activities/SettingsActivity/template_settings_activity.png b/templates/activities/SettingsActivity/template_settings_activity.png Binary files differdeleted file mode 100644 index c1a65cb..0000000 --- a/templates/activities/SettingsActivity/template_settings_activity.png +++ /dev/null |