summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--proguard.flags8
-rw-r--r--res/layout/preference_header_item.xml66
-rw-r--r--res/values/dimens.xml3
-rw-r--r--res/values/strings.xml6
-rw-r--r--res/xml/preferences.xml177
-rw-r--r--res/xml/preferences_dock.xml25
-rw-r--r--res/xml/preferences_drawer.xml55
-rw-r--r--res/xml/preferences_general.xml23
-rw-r--r--res/xml/preferences_headers.xml43
-rw-r--r--res/xml/preferences_homescreen.xml102
-rw-r--r--src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java2
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java12
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/Folder.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java11
-rw-r--r--src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java2
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java35
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/Preferences.java212
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java148
20 files changed, 636 insertions, 306 deletions
diff --git a/proguard.flags b/proguard.flags
index 903cf4aad..570902309 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -56,10 +56,4 @@
public float getHorizontalWallpaperOffset();
}
--keep class com.cyanogenmod.trebuchet.AllApps3D$Defines {
- *;
-}
-
--keep class com.cyanogenmod.trebuchet.ClippedImageView {
- *;
-}
+-keep class com.cyanogenmod.trebuchet.preference.Preferences$*Fragment \ No newline at end of file
diff --git a/res/layout/preference_header_item.xml b/res/layout/preference_header_item.xml
new file mode 100644
index 000000000..75536afc4
--- /dev/null
+++ b/res/layout/preference_header_item.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<!-- Layout of a header item in PreferenceActivity. -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="48dp"
+ android:background="?android:attr/activatedBackgroundIndicator"
+ android:gravity="center_vertical"
+ android:paddingEnd="?android:attr/scrollbarSize">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_marginStart="6dip"
+ android:layout_marginEnd="6dip"
+ android:layout_height="wrap_content">
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+ </LinearLayout>
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="2dip"
+ android:layout_marginEnd="6dip"
+ android:layout_marginTop="6dip"
+ android:layout_marginBottom="6dip"
+ android:layout_weight="1">
+
+ <TextView android:id="@+android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <TextView android:id="@+android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_alignStart="@android:id/title"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:ellipsize="end"
+ android:maxLines="2" />
+
+ </RelativeLayout>
+
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index eb4e2cd81..c148d449b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -160,4 +160,7 @@
<dimen name="workspace_width_gap_port">0dp</dimen>
<dimen name="workspace_height_gap_land">0dp</dimen>
<dimen name="workspace_height_gap_port">0dp</dimen>
+
+<!-- Preferences -->
+ <dimen name="header_icon_width">28dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b50b7af20..bfdad6bd8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -304,6 +304,7 @@ s -->
<!-- UI -->
<!-- Homescreen -->
<string name="preferences_interface_homescreen_title">Homescreen</string>
+ <string name="preferences_interface_homescreen_summary">Screens and wallpaper</string>
<string name="preferences_interface_homescreen_general_category">General</string>
<string name="preferences_interface_homescreen_general_screens_title">Homescreens</string>
<string name="preferences_interface_homescreen_general_screens_summary">Number of screens on the homescreen</string>
@@ -339,11 +340,10 @@ s -->
<string name="preferences_interface_homescreen_indicator_fade_summary">Fade away the indicator after the homescreen has changed</string>
<string name="preferences_interface_homescreen_indicator_position_title">Indicator position</string>
<string name="preferences_interface_homescreen_indicator_position_summary">Choose where to show the indicator on the screen</string>
- <string name="preferences_interface_homescreen_indicator_background_title">Show dock divider</string>
- <string name="preferences_interface_homescreen_indicator_background_summary">Show the background behind the indicator</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_orientation_title">Orientation</string>
<string name="preferences_interface_drawer_orientation_summary">Choose which way the drawer scrolls</string>
<string name="preferences_interface_drawer_widgets_category">Widgets</string>
@@ -362,6 +362,8 @@ s -->
<!-- Dock -->
<string name="preferences_interface_dock_title">Dock</string>
+ <string name="preferences_interface_dock_divider_title">Show dock divider</string>
+ <string name="preferences_interface_dock_divider_summary">Show divider between homescreen and dock</string>
<!-- Icons -->
<string name="preferences_interface_icons_title">Icons</string>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
deleted file mode 100644
index 413440264..000000000
--- a/res/xml/preferences.xml
+++ /dev/null
@@ -1,177 +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.cyanogenmod.trebuchet">
- <!-- UI -->
- <PreferenceCategory android:title="@string/preferences_interface_title">
- <!-- Homescreen -->
- <PreferenceScreen android:key="ui_homescreen"
- android:title="@string/preferences_interface_homescreen_title">
- <PreferenceCategory android:title="@string/preferences_interface_homescreen_general_category">
- <com.cyanogenmod.trebuchet.preference.DoubleNumberPickerPreference android:key="ui_homescreen_grid"
- android:title="@string/preferences_interface_homescreen_general_grid_title"
- android:summary="@string/preferences_interface_homescreen_general_grid_summary"
- launcher:pickerTitle1="@string/preferences_interface_homescreen_general_grid_rows_title"
- launcher:pickerTitle2="@string/preferences_interface_homescreen_general_grid_columns_title"
- launcher:defaultValue1="@integer/cell_count_x"
- launcher:defaultValue2="@integer/cell_count_y"
- launcher:max1="7"
- launcher:min1="3"
- launcher:max2="7"
- launcher:min2="3" />
- <com.cyanogenmod.trebuchet.preference.NumberPickerPreference android:key="ui_homescreen_screens"
- android:title="@string/preferences_interface_homescreen_general_screens_title"
- android:summary="@string/preferences_interface_homescreen_general_screens_summary"
- android:defaultValue="5"
- launcher:max="7"
- launcher:min="1" />
- <com.cyanogenmod.trebuchet.preference.NumberPickerPreference android:key="ui_homescreen_default_screen"
- android:title="@string/preferences_interface_homescreen_general_default_screen_title"
- android:summary="@string/preferences_interface_homescreen_general_default_screen_summary"
- android:defaultValue="3"
- launcher:maxExternal="ui_homescreen_screens"
- launcher:max="7"
- launcher:min="1" />
- <CheckBoxPreference android:key="ui_homescreen_stretch_screens"
- android:title="@string/preferences_interface_homescreen_general_stretch_screens_title"
- android:summary="@string/preferences_interface_homescreen_general_stretch_screens_summary" />
- <CheckBoxPreference android:key="ui_homescreen_general_search"
- android:title="@string/preferences_interface_homescreen_general_search_title"
- android:summary="@string/preferences_interface_homescreen_general_search_summary"
- android:defaultValue="true" />
- <CheckBoxPreference android:key="ui_homescreen_general_resize_any_widget"
- android:title="@string/preferences_interface_homescreen_general_resize_any_widget_title"
- android:summary="@string/preferences_interface_homescreen_general_resize_any_widget_summary" />
- <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" />
- </PreferenceCategory>
- <PreferenceCategory android:title="@string/preferences_interface_homescreen_scrolling_category">
- <ListPreference android:key="ui_homescreen_scrolling_transition_effect"
- android:title="@string/preferences_interface_homescreen_scrolling_transition_effect_title"
- android:summary="@string/preferences_interface_homescreen_scrolling_transition_effect_summary"
- android:entries="@array/preferences_interface_homescreen_scrolling_transition_effect_entries"
- android:entryValues="@array/preferences_interface_homescreen_scrolling_transition_effect_values"
- android:defaultValue="@string/config_workspaceDefaultTransitionEffect" />
- <CheckBoxPreference android:key="ui_homescreen_scrolling_scroll_wallpaper"
- android:title="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_title"
- android:summary="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_summary"
- android:defaultValue="true" />
- <CheckBoxPreference android:key="ui_homescreen_scrolling_wallpaper_hack"
- android:title="@string/preferences_interface_homescreen_scrolling_wallpaper_hack_title"
- android:summary="@string/preferences_interface_homescreen_scrolling_wallpaper_hack_summary"
- android:defaultValue="false" />
- <CheckBoxPreference android:key="ui_homescreen_scrolling_fade_adjacent_screens"
- android:title="@string/preferences_interface_homescreen_scrolling_fade_adjacent_screens_title"
- android:summary="@string/preferences_interface_homescreen_scrolling_fade_adjacent_screens_summary"
- android:defaultValue="@bool/config_workspaceDefualtFadeInAdjacentScreens" />
- <CheckBoxPreference android:key="ui_homescreen_scrolling_show_outlines"
- android:title="@string/preferences_interface_homescreen_scrolling_show_outlines_title"
- android:summary="@string/preferences_interface_homescreen_scrolling_show_outlines_summary"
- android:defaultValue="@bool/config_workspaceDefaultShowOutlines" />
- </PreferenceCategory>
- <PreferenceCategory android:title="@string/preferences_interface_homescreen_indicator_category">
- <CheckBoxPreference android:key="ui_homescreen_indicator_enable"
- android:title="@string/preferences_interface_homescreen_indicator_enable_title"
- android:summary="@string/preferences_interface_homescreen_indicator_enable_summary"
- android:defaultValue="true" />
- <CheckBoxPreference android:key="ui_homescreen_indicator_fade"
- android:title="@string/preferences_interface_homescreen_indicator_fade_title"
- android:summary="@string/preferences_interface_homescreen_indicator_fade_summary"
- android:defaultValue="true"
- android:dependency="ui_homescreen_indicator_enable" />
- <ListPreference android:key="ui_homescreen_indicator_position"
- android:title="@string/preferences_interface_homescreen_indicator_position_title"
- android:summary="@string/preferences_interface_homescreen_indicator_position_summary"
- android:entries="@array/preferences_interface_homescreen_indicator_position_entries"
- android:entryValues="@array/preferences_interface_homescreen_indicator_position_values"
- android:defaultValue="0"
- android:dependency="ui_homescreen_indicator_enable" />
- <CheckBoxPreference android:key="ui_homescreen_indicator_background"
- android:title="@string/preferences_interface_homescreen_indicator_background_title"
- android:summary="@string/preferences_interface_homescreen_indicator_background_summary"
- android:defaultValue="true" />
- </PreferenceCategory>
- </PreferenceScreen>
-
- <!-- Drawer -->
- <PreferenceScreen android:key="ui_drawer"
- android:title="@string/preferences_interface_drawer_title">
- <ListPreference android:key="ui_drawer_orientation"
- android:title="@string/preferences_interface_drawer_orientation_title"
- android:summary="@string/preferences_interface_drawer_orientation_summary"
- android:entries="@array/preferences_interface_drawer_orientation_entries"
- android:entryValues="@array/preferences_interface_drawer_orientation_values"
- android:defaultValue="horizontal" />
- <PreferenceCategory android:title="@string/preferences_interface_drawer_widgets_category">
- <CheckBoxPreference android:key="ui_drawer_widgets_join_apps"
- android:title="@string/preferences_interface_drawer_widgets_join_apps_title"
- android:summary="@string/preferences_interface_drawer_widgets_join_apps_summary"
- android:defaultValue="true" />
- </PreferenceCategory>
- <PreferenceCategory android:title="@string/preferences_interface_drawer_scrolling_category">
- <ListPreference android:key="ui_drawer_scrolling_transition_effect"
- android:title="@string/preferences_interface_drawer_scrolling_transition_effect_title"
- android:summary="@string/preferences_interface_drawer_scrolling_transition_effect_summary"
- android:entries="@array/preferences_interface_drawer_scrolling_transition_effect_entries"
- android:entryValues="@array/preferences_interface_drawer_scrolling_transition_effect_values"
- android:defaultValue="@string/config_drawerDefaultTransitionEffect" />
- <CheckBoxPreference android:key="ui_drawer_scrolling_fade_adjacent_screens"
- android:title="@string/preferences_interface_drawer_scrolling_fade_adjacent_screens_title"
- android:summary="@string/preferences_interface_drawer_scrolling_fade_adjacent_screens_summary" />
- </PreferenceCategory>
- <PreferenceCategory android:title="@string/preferences_interface_drawer_indicator_category">
- <CheckBoxPreference android:key="ui_drawer_indicator_enable"
- android:title="@string/preferences_interface_drawer_indicator_enable_title"
- android:summary="@string/preferences_interface_drawer_indicator_enable_summary"
- android:defaultValue="true" />
- <CheckBoxPreference android:key="ui_drawer_indicator_fade"
- android:title="@string/preferences_interface_drawer_indicator_fade_title"
- android:summary="@string/preferences_interface_drawer_indicator_fade_summary"
- android:defaultValue="true"
- android:dependency="ui_drawer_indicator_enable" />
- </PreferenceCategory>
- </PreferenceScreen>
-
- <!-- Dock -->
- <!-- <PreferenceScreen android:key="ui_dock"
- android:title="@string/preferences_interface_dock_title">
-
- </PreferenceScreen> -->
-
- <!-- Icons -->
- <!-- <PreferenceScreen android:key="ui_icons"
- android:title="@string/preferences_interface_icons_title">
-
- </PreferenceScreen> -->
-
- <!-- General -->
- <PreferenceScreen android:key="ui_general"
- android:title="@string/preferences_interface_general_title">
- <CheckBoxPreference android:key="ui_general_orientation"
- android:title="@string/preferences_interface_general_orientation_title" />
- </PreferenceScreen>
-
- </PreferenceCategory>
-
- <!-- Application -->
- <PreferenceCategory android:title="@string/preferences_application_title">
- <Preference android:key="application_version"
- style="?android:preferenceInformationStyle"
- android:summary="@string/application_copyright" />
- </PreferenceCategory>
-</PreferenceScreen>
diff --git a/res/xml/preferences_dock.xml b/res/xml/preferences_dock.xml
new file mode 100644
index 000000000..10fabe262
--- /dev/null
+++ b/res/xml/preferences_dock.xml
@@ -0,0 +1,25 @@
+<?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.cyanogenmod.trebuchet"
+ android:key="ui_dock"
+ android:title="@string/preferences_interface_dock_title">
+ <CheckBoxPreference android:key="ui_dock_divider"
+ android:title="@string/preferences_interface_dock_divider_title"
+ android:summary="@string/preferences_interface_dock_divider_summary"
+ android:defaultValue="true" />
+</PreferenceScreen> \ No newline at end of file
diff --git a/res/xml/preferences_drawer.xml b/res/xml/preferences_drawer.xml
new file mode 100644
index 000000000..8cb6e4feb
--- /dev/null
+++ b/res/xml/preferences_drawer.xml
@@ -0,0 +1,55 @@
+<?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.cyanogenmod.trebuchet"
+ android:key="ui_drawer"
+ android:title="@string/preferences_interface_drawer_title">
+ <ListPreference android:key="ui_drawer_orientation"
+ android:title="@string/preferences_interface_drawer_orientation_title"
+ android:summary="@string/preferences_interface_drawer_orientation_summary"
+ android:entries="@array/preferences_interface_drawer_orientation_entries"
+ android:entryValues="@array/preferences_interface_drawer_orientation_values"
+ android:defaultValue="horizontal" />
+ <PreferenceCategory android:title="@string/preferences_interface_drawer_widgets_category">
+ <CheckBoxPreference android:key="ui_drawer_widgets_join_apps"
+ android:title="@string/preferences_interface_drawer_widgets_join_apps_title"
+ android:summary="@string/preferences_interface_drawer_widgets_join_apps_summary"
+ android:defaultValue="true" />
+ </PreferenceCategory>
+ <PreferenceCategory android:title="@string/preferences_interface_drawer_scrolling_category">
+ <ListPreference android:key="ui_drawer_scrolling_transition_effect"
+ android:title="@string/preferences_interface_drawer_scrolling_transition_effect_title"
+ android:summary="@string/preferences_interface_drawer_scrolling_transition_effect_summary"
+ android:entries="@array/preferences_interface_drawer_scrolling_transition_effect_entries"
+ android:entryValues="@array/preferences_interface_drawer_scrolling_transition_effect_values"
+ android:defaultValue="@string/config_drawerDefaultTransitionEffect" />
+ <CheckBoxPreference android:key="ui_drawer_scrolling_fade_adjacent_screens"
+ android:title="@string/preferences_interface_drawer_scrolling_fade_adjacent_screens_title"
+ android:summary="@string/preferences_interface_drawer_scrolling_fade_adjacent_screens_summary" />
+ </PreferenceCategory>
+ <PreferenceCategory android:title="@string/preferences_interface_drawer_indicator_category">
+ <CheckBoxPreference android:key="ui_drawer_indicator_enable"
+ android:title="@string/preferences_interface_drawer_indicator_enable_title"
+ android:summary="@string/preferences_interface_drawer_indicator_enable_summary"
+ android:defaultValue="true" />
+ <CheckBoxPreference android:key="ui_drawer_indicator_fade"
+ android:title="@string/preferences_interface_drawer_indicator_fade_title"
+ android:summary="@string/preferences_interface_drawer_indicator_fade_summary"
+ android:defaultValue="true"
+ android:dependency="ui_drawer_indicator_enable" />
+ </PreferenceCategory>
+</PreferenceScreen> \ No newline at end of file
diff --git a/res/xml/preferences_general.xml b/res/xml/preferences_general.xml
new file mode 100644
index 000000000..1385bd282
--- /dev/null
+++ b/res/xml/preferences_general.xml
@@ -0,0 +1,23 @@
+<?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.cyanogenmod.trebuchet"
+ android:key="ui_general"
+ android:title="@string/preferences_interface_general_title">
+ <CheckBoxPreference android:key="ui_general_orientation"
+ android:title="@string/preferences_interface_general_orientation_title" />
+</PreferenceScreen> \ No newline at end of file
diff --git a/res/xml/preferences_headers.xml b/res/xml/preferences_headers.xml
new file mode 100644
index 000000000..b5d66f146
--- /dev/null
+++ b/res/xml/preferences_headers.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+
+<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <header android:id="@+id/preferences_homescreen_section"
+ android:fragment="com.cyanogenmod.trebuchet.preference.Preferences$HomescreenFragment"
+ android:title="@string/preferences_interface_homescreen_title"
+ android:summary="@string/preferences_interface_homescreen_summary" />
+
+ <header android:id="@+id/preferences_drawer_section"
+ android:fragment="com.cyanogenmod.trebuchet.preference.Preferences$DrawerFragment"
+ android:title="@string/preferences_interface_drawer_title"
+ android:summary="@string/preferences_interface_drawer_summary" />
+
+ <header android:id="@+id/preferences_dock_section"
+ android:fragment="com.cyanogenmod.trebuchet.preference.Preferences$DockFragment"
+ android:title="@string/preferences_interface_dock_title" />
+
+ <header android:id="@+id/preferences_general_section"
+ android:fragment="com.cyanogenmod.trebuchet.preference.Preferences$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> \ No newline at end of file
diff --git a/res/xml/preferences_homescreen.xml b/res/xml/preferences_homescreen.xml
new file mode 100644
index 000000000..c1996bc9c
--- /dev/null
+++ b/res/xml/preferences_homescreen.xml
@@ -0,0 +1,102 @@
+<?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.cyanogenmod.trebuchet"
+ android:key="ui_homescreen"
+ android:title="@string/preferences_interface_homescreen_title">
+ <PreferenceCategory android:title="@string/preferences_interface_homescreen_general_category">
+ <com.cyanogenmod.trebuchet.preference.DoubleNumberPickerPreference android:key="ui_homescreen_grid"
+ android:title="@string/preferences_interface_homescreen_general_grid_title"
+ android:summary="@string/preferences_interface_homescreen_general_grid_summary"
+ launcher:pickerTitle1="@string/preferences_interface_homescreen_general_grid_rows_title"
+ launcher:pickerTitle2="@string/preferences_interface_homescreen_general_grid_columns_title"
+ launcher:defaultValue1="@integer/cell_count_x"
+ launcher:defaultValue2="@integer/cell_count_y"
+ launcher:max1="7"
+ launcher:min1="3"
+ launcher:max2="7"
+ launcher:min2="3" />
+ <com.cyanogenmod.trebuchet.preference.NumberPickerPreference android:key="ui_homescreen_screens"
+ android:title="@string/preferences_interface_homescreen_general_screens_title"
+ android:summary="@string/preferences_interface_homescreen_general_screens_summary"
+ android:defaultValue="5"
+ launcher:max="7"
+ launcher:min="1" />
+ <com.cyanogenmod.trebuchet.preference.NumberPickerPreference android:key="ui_homescreen_default_screen"
+ android:title="@string/preferences_interface_homescreen_general_default_screen_title"
+ android:summary="@string/preferences_interface_homescreen_general_default_screen_summary"
+ android:defaultValue="3"
+ launcher:maxExternal="ui_homescreen_screens"
+ launcher:max="7"
+ launcher:min="1" />
+ <CheckBoxPreference android:key="ui_homescreen_stretch_screens"
+ android:title="@string/preferences_interface_homescreen_general_stretch_screens_title"
+ android:summary="@string/preferences_interface_homescreen_general_stretch_screens_summary" />
+ <CheckBoxPreference android:key="ui_homescreen_general_search"
+ android:title="@string/preferences_interface_homescreen_general_search_title"
+ android:summary="@string/preferences_interface_homescreen_general_search_summary"
+ android:defaultValue="true" />
+ <CheckBoxPreference android:key="ui_homescreen_general_resize_any_widget"
+ android:title="@string/preferences_interface_homescreen_general_resize_any_widget_title"
+ android:summary="@string/preferences_interface_homescreen_general_resize_any_widget_summary" />
+ <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" />
+ </PreferenceCategory>
+ <PreferenceCategory android:title="@string/preferences_interface_homescreen_scrolling_category">
+ <ListPreference android:key="ui_homescreen_scrolling_transition_effect"
+ android:title="@string/preferences_interface_homescreen_scrolling_transition_effect_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_transition_effect_summary"
+ android:entries="@array/preferences_interface_homescreen_scrolling_transition_effect_entries"
+ android:entryValues="@array/preferences_interface_homescreen_scrolling_transition_effect_values"
+ android:defaultValue="@string/config_workspaceDefaultTransitionEffect" />
+ <CheckBoxPreference android:key="ui_homescreen_scrolling_scroll_wallpaper"
+ android:title="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_summary"
+ android:defaultValue="true" />
+ <CheckBoxPreference android:key="ui_homescreen_scrolling_wallpaper_hack"
+ android:title="@string/preferences_interface_homescreen_scrolling_wallpaper_hack_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_wallpaper_hack_summary"
+ android:defaultValue="false" />
+ <CheckBoxPreference android:key="ui_homescreen_scrolling_fade_adjacent_screens"
+ android:title="@string/preferences_interface_homescreen_scrolling_fade_adjacent_screens_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_fade_adjacent_screens_summary"
+ android:defaultValue="@bool/config_workspaceDefualtFadeInAdjacentScreens" />
+ <CheckBoxPreference android:key="ui_homescreen_scrolling_show_outlines"
+ android:title="@string/preferences_interface_homescreen_scrolling_show_outlines_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_show_outlines_summary"
+ android:defaultValue="@bool/config_workspaceDefaultShowOutlines" />
+ </PreferenceCategory>
+ <PreferenceCategory android:title="@string/preferences_interface_homescreen_indicator_category">
+ <CheckBoxPreference android:key="ui_homescreen_indicator_enable"
+ android:title="@string/preferences_interface_homescreen_indicator_enable_title"
+ android:summary="@string/preferences_interface_homescreen_indicator_enable_summary"
+ android:defaultValue="true" />
+ <CheckBoxPreference android:key="ui_homescreen_indicator_fade"
+ android:title="@string/preferences_interface_homescreen_indicator_fade_title"
+ android:summary="@string/preferences_interface_homescreen_indicator_fade_summary"
+ android:defaultValue="true"
+ android:dependency="ui_homescreen_indicator_enable" />
+ <ListPreference android:key="ui_homescreen_indicator_position"
+ android:title="@string/preferences_interface_homescreen_indicator_position_title"
+ android:summary="@string/preferences_interface_homescreen_indicator_position_summary"
+ android:entries="@array/preferences_interface_homescreen_indicator_position_entries"
+ android:entryValues="@array/preferences_interface_homescreen_indicator_position_values"
+ android:defaultValue="0"
+ android:dependency="ui_homescreen_indicator_enable" />
+ </PreferenceCategory>
+</PreferenceScreen> \ No newline at end of file
diff --git a/src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java b/src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java
index 133527e1c..39b5356f5 100644
--- a/src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java
+++ b/src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java
@@ -126,7 +126,7 @@ public class AppWidgetResizeFrame extends FrameLayout {
mWidgetPaddingBottom = p.bottom;
// Resize any widget
- if (PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context)) {
+ if (PreferencesProvider.Interface.Homescreen.getResizeAnyWidget()) {
mResizeMode = AppWidgetProviderInfo.RESIZE_BOTH;
mMinHSpan = 1;
mMinVSpan = 1;
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 00bb16619..fbeb26931 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -384,13 +384,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mCameraDistance = resources.getInteger(R.integer.config_cameraDistance);
// Preferences
- mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
- mVertical = PreferencesProvider.Interface.Drawer.getVertical(context);
- mTransitionEffect = PreferencesProvider.Interface.Drawer.Scrolling.getTransitionEffect(context,
+ mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps();
+ mVertical = PreferencesProvider.Interface.Drawer.getVertical();
+ mTransitionEffect = PreferencesProvider.Interface.Drawer.Scrolling.getTransitionEffect(
resources.getString(R.string.config_drawerDefaultTransitionEffect));
- mFadeInAdjacentScreens = PreferencesProvider.Interface.Drawer.Scrolling.getFadeInAdjacentScreens(context);
- mShowScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getShowScrollingIndicator(context);
- mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
+ mFadeInAdjacentScreens = PreferencesProvider.Interface.Drawer.Scrolling.getFadeInAdjacentScreens();
+ mShowScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getShowScrollingIndicator();
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator();
if (!mShowScrollingIndicator) {
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
index 8a07883af..de7adcc99 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -72,8 +72,8 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
};
// Preferences
- mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
- mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
+ mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps();
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator();
}
/**
diff --git a/src/com/cyanogenmod/trebuchet/Folder.java b/src/com/cyanogenmod/trebuchet/Folder.java
index a43473b28..465f32cad 100644
--- a/src/com/cyanogenmod/trebuchet/Folder.java
+++ b/src/com/cyanogenmod/trebuchet/Folder.java
@@ -174,7 +174,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mFolderName.setInputType(mFolderName.getInputType() |
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
- if (PreferencesProvider.Interface.Homescreen.getHideIconLabels(mLauncher)){
+ if (PreferencesProvider.Interface.Homescreen.getHideIconLabels()){
mFolderName.setVisibility(View.GONE);
mFolderNameHeight = getPaddingBottom();
}
@@ -260,7 +260,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
// Convert to a string here to ensure that no other state associated with the text field
// gets saved.
String newTitle = mFolderName.getText().toString();
- if (!PreferencesProvider.Interface.Homescreen.getHideIconLabels(mLauncher)) {
+ if (!PreferencesProvider.Interface.Homescreen.getHideIconLabels()) {
mInfo.setTitle(newTitle);
}
LauncherModel.updateItemInDatabase(mLauncher, mInfo);
diff --git a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
index f0d114e56..c9627d710 100644
--- a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
+++ b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
@@ -137,8 +137,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
// Try adding to the workspace screens incrementally, starting at the default or center
// screen and alternating between +1, -1, +2, -2, etc. (using ~ ceil(i/2f)*(-1)^(i-1))
- final int screenCount = PreferencesProvider.Interface.Homescreen.getNumberHomescreens(context);
- final int screenDefault = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(context, screenCount / 2);
+ final int screenCount = PreferencesProvider.Interface.Homescreen.getNumberHomescreens();
+ final int screenDefault = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(screenCount / 2);
final int screen = (screenDefault >= screenCount) ? screenCount / 2 : screenDefault;
for (int i = 0; i <= (2 * screenCount) + 1 && !found; ++i) {
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index a18f43cfe..de47f77b7 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -373,6 +373,9 @@ public final class Launcher extends Activity
mDragController = new DragController(this);
mInflater = getLayoutInflater();
+ // Load all preferences
+ PreferencesProvider.load(this);
+
mAppWidgetManager = AppWidgetManager.getInstance(this);
mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
mAppWidgetHost.startListening();
@@ -382,10 +385,10 @@ public final class Launcher extends Activity
// LauncherModel load.
mPaused = false;
// Preferences
- mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(this);
- mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(this);
- mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels(this);
- mAutoRotate = PreferencesProvider.Interface.General.getAutoRotate(this, getResources().getBoolean(R.bool.allow_rotation));
+ mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar();
+ mShowDockDivider = PreferencesProvider.Interface.Dock.getShowDivider();
+ mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels();
+ mAutoRotate = PreferencesProvider.Interface.General.getAutoRotate(getResources().getBoolean(R.bool.allow_rotation));
if (PROFILE_STARTUP) {
android.os.Debug.startMethodTracing(
diff --git a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
index 00b5f389e..1f6335fdf 100644
--- a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
+++ b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
@@ -64,7 +64,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
public SearchDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mShowQSBSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
+ mShowQSBSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar();
}
public void setup(Launcher launcher, DragController dragController) {
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index efd2199a0..f92d5c9fd 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -385,37 +385,36 @@ public class Workspace extends SmoothPagedView
// if there is a value set it the preferences, use that instead
if (!LauncherApplication.isScreenLarge()) {
- cellCountX = PreferencesProvider.Interface.Homescreen.getCellCountX(context, cellCountX);
- cellCountY = PreferencesProvider.Interface.Homescreen.getCellCountY(context, cellCountY);
+ cellCountX = PreferencesProvider.Interface.Homescreen.getCellCountX(cellCountX);
+ cellCountY = PreferencesProvider.Interface.Homescreen.getCellCountY(cellCountY);
}
LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY);
setHapticFeedbackEnabled(false);
// Preferences
- mNumberHomescreens = PreferencesProvider.Interface.Homescreen.getNumberHomescreens(context);
- mDefaultHomescreen = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(context,
- mNumberHomescreens / 2);
+ mNumberHomescreens = PreferencesProvider.Interface.Homescreen.getNumberHomescreens();
+ mDefaultHomescreen = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(mNumberHomescreens / 2);
if (mDefaultHomescreen >= mNumberHomescreens) {
mDefaultHomescreen = mNumberHomescreens / 2;
}
- mStretchScreens = PreferencesProvider.Interface.Homescreen.getStretchScreens(context);
- mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
- mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context);
- mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels(context);
- mTransitionEffect = PreferencesProvider.Interface.Homescreen.Scrolling.getTransitionEffect(context,
+ mStretchScreens = PreferencesProvider.Interface.Homescreen.getStretchScreens();
+ mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar();
+ mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget();
+ mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels();
+ mTransitionEffect = PreferencesProvider.Interface.Homescreen.Scrolling.getTransitionEffect(
res.getString(R.string.config_workspaceDefaultTransitionEffect));
- mScrollWallpaper = PreferencesProvider.Interface.Homescreen.Scrolling.getScrollWallpaper(context);
- mWallpaperHack = PreferencesProvider.Interface.Homescreen.Scrolling.getWallpaperHack(context);
- mShowOutlines = PreferencesProvider.Interface.Homescreen.Scrolling.getShowOutlines(context,
+ mScrollWallpaper = PreferencesProvider.Interface.Homescreen.Scrolling.getScrollWallpaper();
+ mWallpaperHack = PreferencesProvider.Interface.Homescreen.Scrolling.getWallpaperHack();
+ mShowOutlines = PreferencesProvider.Interface.Homescreen.Scrolling.getShowOutlines(
res.getBoolean(R.bool.config_workspaceDefaultShowOutlines));
- mFadeInAdjacentScreens = PreferencesProvider.Interface.Homescreen.Scrolling.getFadeInAdjacentScreens(context,
+ mFadeInAdjacentScreens = PreferencesProvider.Interface.Homescreen.Scrolling.getFadeInAdjacentScreens(
res.getBoolean(R.bool.config_workspaceDefualtFadeInAdjacentScreens));
- mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator(context);
- mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator(context);
- mScrollingIndicatorPosition = PreferencesProvider.Interface.Homescreen.Indicator.getScrollingIndicatorPosition(context);
- mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(context);
+ mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator();
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator();
+ mScrollingIndicatorPosition = PreferencesProvider.Interface.Homescreen.Indicator.getScrollingIndicatorPosition();
+ mShowDockDivider = PreferencesProvider.Interface.Dock.getShowDivider();
initWorkspace();
checkWallpaper();
diff --git a/src/com/cyanogenmod/trebuchet/preference/Preferences.java b/src/com/cyanogenmod/trebuchet/preference/Preferences.java
index d4013a25c..abb692115 100644
--- a/src/com/cyanogenmod/trebuchet/preference/Preferences.java
+++ b/src/com/cyanogenmod/trebuchet/preference/Preferences.java
@@ -18,47 +18,239 @@ package com.cyanogenmod.trebuchet.preference;
import android.content.Context;
import android.content.SharedPreferences;
+import android.content.res.Resources;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.text.TextUtils;
+import android.util.Log;
+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.cyanogenmod.trebuchet.LauncherApplication;
import com.cyanogenmod.trebuchet.R;
+import java.util.List;
+
public class Preferences extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "Trebuchet.Preferences";
- private SharedPreferences mPrefs;
+ private SharedPreferences mPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.preferences);
-
- mPrefs = getSharedPreferences(PreferencesProvider.PREFERENCES_KEY,
+ mPreferences = getSharedPreferences(PreferencesProvider.PREFERENCES_KEY,
Context.MODE_PRIVATE);
-
- Preference version = findPreference("application_version");
- version.setTitle(getString(R.string.application_name) + " " + getString(R.string.application_version));
}
@Override
protected void onResume() {
super.onResume();
- mPrefs.registerOnSharedPreferenceChangeListener(this);
+ mPreferences.registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onPause() {
- mPrefs.unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
+ mPreferences.unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ @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.application_name) + " " + getString(R.string.application_version);
+ }
+
+ // Remove dock header on tablets
+ if (LauncherApplication.isScreenLarge() && header.id == R.id.preferences_dock_section) {
+ headers.remove(header);
+ }
+
+ // Increment if not removed
+ if (headers.get(i) == header) {
+ i++;
+ }
+ }
+ }
+
+ @Override
+ public void setListAdapter(ListAdapter adapter) {
+ if (adapter == null) {
+ super.setListAdapter(null);
+ } else {
+ super.setListAdapter(new HeaderAdapter(this, getHeaders()));
+ }
+ }
+
+ @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- SharedPreferences.Editor editor = mPrefs.edit();
+ SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(PreferencesProvider.PREFERENCES_CHANGED, true);
editor.commit();
}
+ public static class HomescreenFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preferences_homescreen);
+ }
+ }
+
+ public static class DrawerFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preferences_drawer);
+ }
+ }
+
+ public static class DockFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preferences_dock);
+ }
+ }
+
+ public static class GeneralFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preferences_general);
+ }
+ }
+
+ 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(R.id.icon);
+ holder.title = (TextView)
+ view.findViewById(com.android.internal.R.id.title);
+ holder.summary = (TextView)
+ view.findViewById(com.android.internal.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;
+ }
+ }
}
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 0f4c2d5cc..4146ebfd6 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -23,60 +23,76 @@ import com.cyanogenmod.trebuchet.LauncherApplication;
import com.cyanogenmod.trebuchet.Workspace;
import com.cyanogenmod.trebuchet.AppsCustomizePagedView;
+import java.util.Map;
+
public final class PreferencesProvider {
public static final String PREFERENCES_KEY = "com.cyanogenmod.trebuchet_preferences";
public static final String PREFERENCES_CHANGED = "preferences_changed";
+
+ private static Map<String, ?> sKeyValues;
+
+ public static void load(Context context) {
+ SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ sKeyValues = preferences.getAll();
+ }
+
+ private static int getInt(String key, int def) {
+ return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Integer ?
+ (Integer) sKeyValues.get(key) : def;
+ }
+
+ private static boolean getBoolean(String key, boolean def) {
+ return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Boolean ?
+ (Boolean) sKeyValues.get(key) : def;
+ }
+
+ private static String getString(String key, String def) {
+ return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof String ?
+ (String) sKeyValues.get(key) : def;
+ }
+
public static class Interface {
public static class Homescreen {
- public static int getNumberHomescreens(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getInt("ui_homescreen_screens", 5);
+ public static int getNumberHomescreens() {
+ return getInt("ui_homescreen_screens", 5);
}
- public static int getDefaultHomescreen(Context context, int def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getInt("ui_homescreen_default_screen", def + 1) - 1;
+ public static int getDefaultHomescreen(int def) {
+ return getInt("ui_homescreen_default_screen", def + 1) - 1;
}
- public static int getCellCountX(Context context, int def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- String[] values = preferences.getString("ui_homescreen_grid", "0|" + def).split("\\|");
+ public static int getCellCountX(int def) {
+ String[] values = getString("ui_homescreen_grid", "0|" + def).split("\\|");
try {
return Integer.parseInt(values[1]);
} catch (NumberFormatException e) {
return def;
}
}
- public static int getCellCountY(Context context, int def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- String[] values = preferences.getString("ui_homescreen_grid", def + "|0").split("\\|");;
+ public static int getCellCountY(int def) {
+ String[] values = getString("ui_homescreen_grid", def + "|0").split("\\|");;
try {
return Integer.parseInt(values[0]);
} catch (NumberFormatException e) {
return def;
}
}
- public static boolean getStretchScreens(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_stretch_screens", false);
+ public static boolean getStretchScreens() {
+ return getBoolean("ui_homescreen_stretch_screens", false);
}
- public static boolean getShowSearchBar(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_general_search", true);
+ public static boolean getShowSearchBar() {
+ return getBoolean("ui_homescreen_general_search", true);
}
- public static boolean getResizeAnyWidget(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_general_resize_any_widget", false);
+ public static boolean getResizeAnyWidget() {
+ return getBoolean("ui_homescreen_general_resize_any_widget", false);
}
- public static boolean getHideIconLabels(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_general_hide_icon_labels", false);
+ public static boolean getHideIconLabels() {
+ return getBoolean("ui_homescreen_general_hide_icon_labels", false);
}
public static class Scrolling {
- public static Workspace.TransitionEffect getTransitionEffect(Context context, String def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ public static Workspace.TransitionEffect getTransitionEffect(String def) {
try {
return Workspace.TransitionEffect.valueOf(
- preferences.getString("ui_homescreen_scrolling_transition_effect", def));
+ getString("ui_homescreen_scrolling_transition_effect", def));
} catch (IllegalArgumentException iae) {
// Continue
}
@@ -89,58 +105,44 @@ public final class PreferencesProvider {
return Workspace.TransitionEffect.Standard;
}
- public static boolean getScrollWallpaper(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true);
+ public static boolean getScrollWallpaper() {
+ return getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true);
}
- public static boolean getWallpaperHack(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_scrolling_wallpaper_hack", false);
+ public static boolean getWallpaperHack() {
+ return getBoolean("ui_homescreen_scrolling_wallpaper_hack", false);
}
- public static boolean getFadeInAdjacentScreens(Context context, boolean def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_scrolling_fade_adjacent_screens", def);
+ public static boolean getFadeInAdjacentScreens(boolean def) {
+ return getBoolean("ui_homescreen_scrolling_fade_adjacent_screens", def);
}
- public static boolean getShowOutlines(Context context, boolean def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_scrolling_show_outlines", def);
+ public static boolean getShowOutlines(boolean def) {
+ return getBoolean("ui_homescreen_scrolling_show_outlines", def);
}
}
public static class Indicator {
- public static boolean getShowScrollingIndicator(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_indicator_enable", true);
+ public static boolean getShowScrollingIndicator() {
+ return getBoolean("ui_homescreen_indicator_enable", true);
}
- public static boolean getFadeScrollingIndicator(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_indicator_fade", true);
+ public static boolean getFadeScrollingIndicator() {
+ return getBoolean("ui_homescreen_indicator_fade", true);
}
- public static int getScrollingIndicatorPosition(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return Integer.parseInt(preferences.getString("ui_homescreen_indicator_position", "0"));
- }
- public static boolean getShowDockDivider(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_homescreen_indicator_background", true);
+ public static int getScrollingIndicatorPosition() {
+ return Integer.parseInt(getString("ui_homescreen_indicator_position", "0"));
}
}
}
public static class Drawer {
- public static boolean getVertical(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getString("ui_drawer_orientation", "horizontal").equals("vertical");
+ public static boolean getVertical() {
+ return getString("ui_drawer_orientation", "horizontal").equals("vertical");
}
- public static boolean getJoinWidgetsApps(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_drawer_widgets_join_apps", true);
+ public static boolean getJoinWidgetsApps() {
+ return getBoolean("ui_drawer_widgets_join_apps", true);
}
public static class Scrolling {
- public static AppsCustomizePagedView.TransitionEffect getTransitionEffect(Context context, String def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ public static AppsCustomizePagedView.TransitionEffect getTransitionEffect(String def) {
try {
return AppsCustomizePagedView.TransitionEffect.valueOf(
- preferences.getString("ui_drawer_scrolling_transition_effect", def));
+ getString("ui_drawer_scrolling_transition_effect", def));
} catch (IllegalArgumentException iae) {
// Continue
}
@@ -153,25 +155,24 @@ public final class PreferencesProvider {
return AppsCustomizePagedView.TransitionEffect.Standard;
}
- public static boolean getFadeInAdjacentScreens(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_drawer_scrolling_fade_adjacent_screens", false);
+ public static boolean getFadeInAdjacentScreens() {
+ return getBoolean("ui_drawer_scrolling_fade_adjacent_screens", false);
}
}
public static class Indicator {
- public static boolean getShowScrollingIndicator(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_drawer_indicator_enable", true);
+ public static boolean getShowScrollingIndicator() {
+ return getBoolean("ui_drawer_indicator_enable", true);
}
- public static boolean getFadeScrollingIndicator(Context context) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_drawer_indicator_fade", true);
+ public static boolean getFadeScrollingIndicator() {
+ return getBoolean("ui_drawer_indicator_fade", true);
}
}
}
public static class Dock {
-
+ public static boolean getShowDivider() {
+ return getBoolean("ui_dock_divider", true);
+ }
}
public static class Icons {
@@ -179,9 +180,8 @@ public final class PreferencesProvider {
}
public static class General {
- public static boolean getAutoRotate(Context context, boolean def) {
- final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
- return preferences.getBoolean("ui_general_orientation", def);
+ public static boolean getAutoRotate(boolean def) {
+ return getBoolean("ui_general_orientation", def);
}
}
}