diff options
-rw-r--r-- | AndroidManifest.xml | 9 | ||||
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java | 19 | ||||
-rw-r--r-- | res/layout/settings_transitions_screen.xml | 4 | ||||
-rw-r--r-- | res/values/cm_arrays.xml | 29 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 107 | ||||
-rw-r--r-- | res/xml/preferences_drawer.xml | 42 | ||||
-rw-r--r-- | res/xml/preferences_general.xml | 34 | ||||
-rw-r--r-- | res/xml/preferences_headers.xml | 41 | ||||
-rw-r--r-- | res/xml/preferences_homescreen.xml | 29 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/settings/SettingsActivity.java | 274 |
11 files changed, 42 insertions, 548 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5c645e3b3..34e25b8b4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -88,15 +88,6 @@ </intent-filter> </activity> - <activity android:name=".settings.SettingsActivity" - android:label="@string/preferences_title"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.DEFAULT" /> - <category android:name="com.cyanogenmod.category.LAUNCHER_PREFERENCES" /> - </intent-filter> - </activity> - <activity android:name="com.android.launcher3.LauncherWallpaperPickerActivity" android:theme="@style/Theme.WallpaperCropper" diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 08caf3b42..7f05ef42d 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -693,25 +693,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } @Override - public boolean onCreateOptionsMenu(Menu menu) { - menu.add(0, MENU_WALLPAPER_SCROLL, 0, - R.string.wallpaper_scroll).setCheckable(true); - - return super.onCreateOptionsMenu(menu); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - MenuItem wallpaperScroll = menu.findItem(MENU_WALLPAPER_SCROLL); - - wallpaperScroll.setChecked(SettingsProvider.getBoolean(this, - SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL, - R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default)); - - return super.onPrepareOptionsMenu(menu); - } - - @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { diff --git a/res/layout/settings_transitions_screen.xml b/res/layout/settings_transitions_screen.xml index 18028f4c4..37535e912 100644 --- a/res/layout/settings_transitions_screen.xml +++ b/res/layout/settings_transitions_screen.xml @@ -27,7 +27,7 @@ android:id="@+id/transition_effect_title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/transition_effect_button_text" + android:text="@string/scroll_effect_text" android:textAllCaps="true" android:fontFamily="sans-serif-condensed" android:textColor="@android:color/white" @@ -49,4 +49,4 @@ android:layout_height="wrap_content" android:listSelector="@android:color/transparent" android:splitMotionEvents="false"/> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml index 2320f1805..e8b02dbcb 100644 --- a/res/values/cm_arrays.xml +++ b/res/values/cm_arrays.xml @@ -15,30 +15,19 @@ limitations under the License. --> <resources> - <string-array name="preferences_interface_general_icons_text_font_family_entries"> - <item>Regular</item> - <item>Light</item> - <item>Condensed</item> - </string-array> - <string-array name="preferences_interface_general_icons_text_font_family_values" translatable="false"> - <item>sans-serif</item> - <item>sans-serif-light</item> - <item>sans-serif-condensed</item> - </string-array> - <string-array name="transition_effect_entries"> <item>None</item> - <item>Zoom In</item> - <item>Zoom Out</item> - <item>Rotate Up</item> - <item>Rotate Down</item> - <item>Cube In</item> - <item>Cube Out</item> + <item>Zoom in</item> + <item>Zoom out</item> + <item>Rotate up</item> + <item>Rotate down</item> + <item>Cube in</item> + <item>Cube out</item> <item>Stack</item> <item>Accordion</item> <item>Flip</item> - <item>Cylinder In</item> - <item>Cylinder Out</item> + <item>Cylinder in</item> + <item>Cylinder out</item> <item>Carousel</item> <item>Overview</item> </string-array> @@ -74,4 +63,4 @@ <item>@drawable/transition_carousel</item> <item>@drawable/transition_overview</item> </string-array> -</resources>
\ No newline at end of file +</resources> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 854db56ff..7ec28ab21 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -17,109 +17,62 @@ <resources> <!-- Application name --> <string name="cm_application_name" translatable="false">Trebuchet</string> - <!-- App copyright --> - <string name="application_copyright">Copyright \u00A9 2014 The CyanogenMod Project</string> <!-- App version --> <string name="application_version" translatable="false">1.0</string> - <!-- Strings for the customization mode --> - <!-- Text for sorting mode button --> - <string name="sort_button_text">Sort</string> - <!-- Text for filter button --> - <string name="filter_button_text">Filter</string> - <!-- Text for default screen button --> - <string name="default_screen_button_text">Default screen</string> - <!-- Text for transition effect button --> - <string name="transition_effect_button_text">Scroll effect</string> + <string name="launcher_settings">LAUNCHER SETTINGS</string> + <string name="home_screen_settings">HOME SCREEN SETTINGS</string> + <string name="drawer_settings">DRAWER SETTINGS</string> - <string name="sort_mode_title">Title</string> - <string name="sort_mode_launch_count">Launch count</string> - <string name="sort_mode_install_time">Install time</string> + <!-- Settings states --> + <string name="setting_state_on">ON</string> + <string name="setting_state_off">OFF</string> + + <!-- Themes button --> + <string name="themes_button_text">Themes</string> <string name="scrolling_page_outlines">Page outlines</string> <string name="scrolling_fade_adjacent">Fade side pages</string> - - <string name="wallpaper_scroll">Scroll wallpaper</string> - - <!-- Settings --> - <string name="preferences_title">Settings</string> - <!-- Application --> - <string name="preferences_application_title">App</string> - - <!-- UI --> - <!-- Homescreen --> - <string name="preferences_interface_homescreen_title">Homescreen</string> - <string name="preferences_interface_homescreen_search_title">Search bar</string> - <string name="preferences_interface_homescreen_search_summary">Show persistent search bar at top of screen</string> - <string name="preferences_interface_homescreen_general_hide_icon_labels_title">Hide icon labels</string> - <string name="preferences_interface_homescreen_general_hide_icon_labels_summary">Hide icon labels on homescreen</string> - - <!-- Drawer --> - <string name="preferences_interface_drawer_title">Drawer</string> - <string name="preferences_interface_drawer_summary">Apps and widgets drawer</string> - <string name="preferences_interface_drawer_apps_category">Apps</string> - <string name="preferences_interface_drawer_hidden_apps_title">Hidden apps</string> - <string name="preferences_interface_drawer_hidden_apps_summary">Hide apps from the drawer</string> - <string name="preferences_interface_drawer_hidden_apps_shortcuts_title">Remove shortcuts</string> - <string name="preferences_interface_drawer_hidden_apps_shortcuts_summary">Remove the shortcuts of hidden apps from the homescreen</string> - <string name="preferences_interface_drawer_hidden_apps_widgets_title">Remove widgets</string> - <string name="preferences_interface_drawer_hidden_apps_widgets_summary">Remove the widgets of hidden apps from the homescreen</string> - <string name="preferences_interface_drawer_hide_icon_labels_title">Hide icon labels</string> - <string name="preferences_interface_drawer_hide_icon_labels_summary">Hide icon labels in drawer</string> - - <!-- Settings toast messages --> - <string name="preferences_search_screen_left_unsupported_toast">You must have a supported search app and CyanogenMod to use this feature.</string> - - <!-- Dock --> - <string name="preferences_interface_dock_title">Dock</string> + <!-- Wallpaper scroll effect --> + <string name="scrolling_wallpaper">Scroll wallpaper</string> <!-- General --> - <string name="preferences_interface_general_title">General</string> - <string name="preferences_interface_general_icons_category">Icons</string> - <string name="preferences_interface_general_icons_large_title">Larger icons</string> - <string name="preferences_interface_general_icons_large_summary">Use extra large application icons in homescreen and drawer</string> - <string name="preferences_interface_general_icons_text_style_title">Text font style</string> - <string name="preferences_interface_general_icons_text_style_summary">Variant and style of font to use for icon text</string> <string name="dialog_pick_iconpack_title">Pick icon pack</string> <string name="default_iconpack_title">Default icons</string> - <string name="icon_packs_title">Icon packs</string> <string name="no_iconpacks_summary">No icon packs installed</string> <!-- Folder titles --> <string name="google_title" translatable="false">Google</string> - <!-- Noun, menu item used to reset hidden apps list --> - <string name="menu_hidden_apps_delete">Reset</string> - <!-- Hidden apps --> <string name="hidden_apps_title">Hidden apps</string> - <string name="launcher_settings">LAUNCHER SETTINGS</string> - <string name="home_screen_settings">HOME SCREEN SETTINGS</string> - <string name="drawer_settings">DRAWER SETTINGS</string> - <!-- Text for scroll effect --> + + <!-- Scroll effect --> <string name="scroll_effect_text">Scroll effect</string> - <!-- Text for drawer sorting --> + + <!-- Drawer sorting mode --> <string name="drawer_sorting_text">Sorting mode</string> - <!-- Text for home screen search --> + + <string name="sort_mode_title">Title</string> + <string name="sort_mode_launch_count">Launch count</string> + <string name="sort_mode_install_time">Install time</string> + + <!-- Home screen search bar --> <string name="home_screen_search_text">Search bar</string> - <!-- Text for larger icons --> + + <!-- Larger icons --> <string name="larger_icons_text">Larger icons</string> - <!-- Text for hiding icon labels --> + + <!-- Hide icon labels --> <string name="hide_icon_labels">Hide icon labels</string> - <!-- Protected Apps --> + + <!-- Protected apps --> <string name="protected_app_settings">Protected apps</string> + <!-- Text for hiding/showing search screen on left (if installed) --> <string name="search_screen_left_text">Search panel</string> - <!-- Settings states --> - <string name="setting_state_on">ON</string> - <string name="setting_state_off">OFF</string> - <!-- Themes button --> - <string name="themes_button_text">Themes</string> - <!-- Wallpaper scroll effect --> - <string name="scrolling_wallpaper">Scroll wallpaper</string> - <!-- Hidden states --> - <string name="hidden_folder">locked</string> - <string name="unhidden_folder">unlocked</string> + <!-- Toast message when search screen on left is not supported --> + <string name="search_screen_left_unsupported_toast">You must have a supported search app and CyanogenMod to use this feature.</string> </resources> diff --git a/res/xml/preferences_drawer.xml b/res/xml/preferences_drawer.xml deleted file mode 100644 index b22597516..000000000 --- a/res/xml/preferences_drawer.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher3" - android:key="ui_drawer" - android:title="@string/preferences_interface_drawer_title"> - <PreferenceCategory android:title="@string/preferences_interface_drawer_apps_category"> - <Preference android:key="ui_drawer_hidden_apps" - android:title="@string/preferences_interface_drawer_hidden_apps_title" - android:summary="@string/preferences_interface_drawer_hidden_apps_summary"> - <intent android:action=".settings.HiddenAppsActivity"/> - </Preference> - <CheckBoxPreference android:key="ui_drawer_remove_hidden_apps_shortcuts" - android:title="@string/preferences_interface_drawer_hidden_apps_shortcuts_title" - android:summary="@string/preferences_interface_drawer_hidden_apps_shortcuts_summary" - android:defaultValue="@bool/preferences_interface_drawer_remove_hidden_apps_shortcuts_default" /> - <CheckBoxPreference android:key="ui_drawer_remove_hidden_apps_widgets" - android:title="@string/preferences_interface_drawer_hidden_apps_widgets_title" - android:summary="@string/preferences_interface_drawer_hidden_apps_widgets_summary" - android:defaultValue="@bool/preferences_interface_drawer_remove_hidden_apps_widgets_default" /> - </PreferenceCategory> - <PreferenceCategory android:title="@string/preferences_interface_general_icons_category"> - <CheckBoxPreference android:key="ui_drawer_hide_icon_labels" - android:title="@string/preferences_interface_drawer_hide_icon_labels_title" - android:summary="@string/preferences_interface_drawer_hide_icon_labels_summary" - android:defaultValue="@bool/preferences_interface_drawer_hide_icon_labels_default" /> - </PreferenceCategory> -</PreferenceScreen>
\ No newline at end of file diff --git a/res/xml/preferences_general.xml b/res/xml/preferences_general.xml deleted file mode 100644 index 96b93ec44..000000000 --- a/res/xml/preferences_general.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher3" - android:key="ui_general" - android:title="@string/preferences_interface_general_title"> - <PreferenceCategory android:title="@string/preferences_interface_general_icons_category"> - <CheckBoxPreference android:key="ui_general_icons_large" - android:title="@string/preferences_interface_general_icons_large_title" - android:summary="@string/preferences_interface_general_icons_large_summary" - android:defaultValue="@bool/preferences_interface_general_icons_large_default" /> - <com.android.launcher3.settings.FontStylePreference android:key="ui_general_icons_text_font" - android:title="@string/preferences_interface_general_icons_text_style_title" - android:summary="@string/preferences_interface_general_icons_text_style_summary" - android:entries="@array/preferences_interface_general_icons_text_font_family_entries" - android:entryValues="@array/preferences_interface_general_icons_text_font_family_values" - android:defaultValue="@string/preferences_interface_general_icons_text_font_family_default" /> - </PreferenceCategory> - -</PreferenceScreen> diff --git a/res/xml/preferences_headers.xml b/res/xml/preferences_headers.xml deleted file mode 100644 index 42a08a9bd..000000000 --- a/res/xml/preferences_headers.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2014 The CyanogenMod Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<preference-headers xmlns:android="http://schemas.android.com/apk/res/android"> - - <header android:id="@+id/preferences_homescreen_section" - android:fragment="com.android.launcher3.settings.SettingsActivity$HomescreenFragment" - android:title="@string/preferences_interface_homescreen_title" /> - - <header android:id="@+id/preferences_drawer_section" - android:fragment="com.android.launcher3.settings.SettingsActivity$DrawerFragment" - android:title="@string/preferences_interface_drawer_title" - android:summary="@string/preferences_interface_drawer_summary" /> - - <!--<header android:id="@+id/preferences_dock_section" - android:title="@string/preferences_interface_dock_title" />--> - - <header android:id="@+id/preferences_general_section" - android:fragment="com.android.launcher3.settings.SettingsActivity$GeneralFragment" - android:title="@string/preferences_interface_general_title" /> - - <header android:id="@+id/preferences_application_section" - android:title="@string/preferences_application_title" /> - - <header android:id="@+id/preferences_application_version" - android:summary="@string/application_copyright" /> - -</preference-headers> diff --git a/res/xml/preferences_homescreen.xml b/res/xml/preferences_homescreen.xml deleted file mode 100644 index 1754cfa02..000000000 --- a/res/xml/preferences_homescreen.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher3" - android:key="ui_homescreen" - android:title="@string/preferences_interface_homescreen_title"> - <CheckBoxPreference android:key="ui_homescreen_search" - android:title="@string/preferences_interface_homescreen_search_title" - android:summary="@string/preferences_interface_homescreen_search_summary" - android:defaultValue="@bool/preferences_interface_homescreen_search_default" /> - <CheckBoxPreference android:key="ui_homescreen_general_hide_icon_labels" - android:title="@string/preferences_interface_homescreen_general_hide_icon_labels_title" - android:summary="@string/preferences_interface_homescreen_general_hide_icon_labels_summary" - android:defaultValue="@bool/preferences_interface_homescreen_hide_icon_labels_default" /> -</PreferenceScreen> diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index 3978b0ea7..ccfe0b1ba 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -270,7 +270,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { // If GEL integration is not supported, do not allow the user to turn it on. if(!current && !mLauncher.isGelIntegrationSupported()) { Toast.makeText(mLauncher.getApplicationContext(), - res.getString(R.string.preferences_search_screen_left_unsupported_toast), + res.getString(R.string.search_screen_left_unsupported_toast), Toast.LENGTH_SHORT).show(); } else { onSettingsBooleanChanged( diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java deleted file mode 100644 index dbbf95f52..000000000 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher3.settings; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.*; -import android.text.TextUtils; -import android.view.MenuItem; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.ListAdapter; -import android.widget.TextView; -import com.android.launcher3.R; - -import java.util.ArrayList; -import java.util.List; - -public class SettingsActivity extends PreferenceActivity - implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String TAG = "Launcher3.SettingsActivity"; - - private SharedPreferences mSettings; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mSettings = getSharedPreferences(SettingsProvider.SETTINGS_KEY, - Context.MODE_PRIVATE); - - getActionBar().setDisplayHomeAsUpEnabled(true); - } - - @Override - public SharedPreferences getSharedPreferences(String name, int mode) { - return super.getSharedPreferences(SettingsProvider.SETTINGS_KEY, - Context.MODE_PRIVATE); - } - - @Override - protected void onResume() { - super.onResume(); - mSettings.registerOnSharedPreferenceChangeListener(this); - } - - @Override - protected void onPause() { - super.onPause(); - mSettings.unregisterOnSharedPreferenceChangeListener(this); - } - - @Override - public boolean isValidFragment(String fragmentName) { - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - finish(); - return true; - default: - break; - } - return super.onOptionsItemSelected(item); - } - - @Override - public void onBuildHeaders(List<Header> target) { - loadHeadersFromResource(R.xml.preferences_headers, target); - updateHeaders(target); - } - - private void updateHeaders(List<Header> headers) { - int i = 0; - while (i < headers.size()) { - Header header = headers.get(i); - - // Version preference - if (header.id == R.id.preferences_application_version) { - header.title = getString(R.string.cm_application_name) + " " + getString(R.string.application_version); - } - - // Increment if not removed - if (headers.get(i) == header) { - i++; - } - } - } - - @Override - public void setListAdapter(ListAdapter adapter) { - if (adapter == null) { - super.setListAdapter(null); - } else { - List<Header> headers = getHeadersFromAdapter(adapter); - super.setListAdapter(new HeaderAdapter(this, headers)); - } - } - - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - SharedPreferences.Editor editor = mSettings.edit(); - editor.putBoolean(SettingsProvider.SETTINGS_CHANGED, true); - editor.commit(); - } - - private List<Header> getHeadersFromAdapter(ListAdapter adapter) { - List<Header> headers = new ArrayList<Header>(); - int count = adapter.getCount(); - for (int i = 0; i < count; i++) { - headers.add((Header)adapter.getItem(i)); - } - return headers; - } - - public static class HomescreenFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - addPreferencesFromResource(R.xml.preferences_homescreen); - } - } - - public static class GeneralFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - addPreferencesFromResource(R.xml.preferences_general); - } - } - - public static class DrawerFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - addPreferencesFromResource(R.xml.preferences_drawer); - } - } - - private static class HeaderAdapter extends ArrayAdapter<Header> { - private static final int HEADER_TYPE_NORMAL = 0; - private static final int HEADER_TYPE_CATEGORY = 1; - - private static final int HEADER_TYPE_COUNT = HEADER_TYPE_CATEGORY + 1; - - private static class HeaderViewHolder { - ImageView icon; - TextView title; - TextView summary; - } - - private LayoutInflater mInflater; - - static int getHeaderType(Header header) { - if (header.id == R.id.preferences_application_section) { - return HEADER_TYPE_CATEGORY; - } else { - return HEADER_TYPE_NORMAL; - } - } - - @Override - public int getItemViewType(int position) { - Header header = getItem(position); - return getHeaderType(header); - } - - @Override - public boolean areAllItemsEnabled() { - return false; // because of categories - } - - @Override - public boolean isEnabled(int position) { - return getItemViewType(position) != HEADER_TYPE_CATEGORY; - } - - @Override - public int getViewTypeCount() { - return HEADER_TYPE_COUNT; - } - - @Override - public boolean hasStableIds() { - return true; - } - - public HeaderAdapter(Context context, List<Header> objects) { - super(context, 0, objects); - - mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - HeaderViewHolder holder; - Header header = getItem(position); - int headerType = getHeaderType(header); - View view = null; - - if (convertView == null) { - holder = new HeaderViewHolder(); - switch (headerType) { - case HEADER_TYPE_CATEGORY: - view = new TextView(getContext(), null, - android.R.attr.listSeparatorTextViewStyle); - holder.title = (TextView) view; - break; - - case HEADER_TYPE_NORMAL: - view = mInflater.inflate( - R.layout.preference_header_item, parent, - false); - holder.icon = (ImageView) view.findViewById(android.R.id.icon); - holder.title = (TextView) - view.findViewById(android.R.id.title); - holder.summary = (TextView) - view.findViewById(android.R.id.summary); - break; - } - view.setTag(holder); - } else { - view = convertView; - holder = (HeaderViewHolder) view.getTag(); - } - - // All view fields must be updated every time, because the view may be recycled - switch (headerType) { - case HEADER_TYPE_CATEGORY: - holder.title.setText(header.getTitle(getContext().getResources())); - break; - - case HEADER_TYPE_NORMAL: - holder.icon.setImageResource(header.iconRes); - holder.title.setText(header.getTitle(getContext().getResources())); - CharSequence summary = header.getSummary(getContext().getResources()); - if (!TextUtils.isEmpty(summary)) { - holder.summary.setVisibility(View.VISIBLE); - holder.summary.setText(summary); - } else { - holder.summary.setVisibility(View.GONE); - } - break; - } - - return view; - } - } -} |