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/SettingsActivity | |
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/SettingsActivity')
11 files changed, 0 insertions, 555 deletions
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 |