diff options
author | Joey <joey@lineageos.org> | 2018-12-27 12:40:07 +0100 |
---|---|---|
committer | Joey <joey@lineageos.org> | 2018-12-27 12:42:40 +0100 |
commit | 2b56ff08e4a04d72e1901203110fd3d150388863 (patch) | |
tree | fb3d70c2f41c224e8b87b57913a0308c47eaf12e | |
parent | 514e4c750ffe8e9049f64fe86c61a7e5d6872f15 (diff) | |
download | android_packages_apps_Trebuchet-2b56ff08e4a04d72e1901203110fd3d150388863.tar.gz android_packages_apps_Trebuchet-2b56ff08e4a04d72e1901203110fd3d150388863.tar.bz2 android_packages_apps_Trebuchet-2b56ff08e4a04d72e1901203110fd3d150388863.zip |
Trebuchet: reorganize preferences
Change-Id: I1fb2877bdb0fd031f43240feeca21a42b65eb09e
Signed-off-by: Joey <joey@lineageos.org>
-rw-r--r-- | res/values/lineage_strings.xml | 9 | ||||
-rw-r--r-- | res/xml/launcher_preferences.xml | 118 | ||||
-rw-r--r-- | src/com/android/launcher3/SettingsActivity.java | 37 |
3 files changed, 97 insertions, 67 deletions
diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml index ab5863426..d580a7a76 100644 --- a/res/values/lineage_strings.xml +++ b/res/values/lineage_strings.xml @@ -19,6 +19,11 @@ <!-- Settings --> + <!-- Categories --> + <string name="settings_category_home">Home screen settings</string> + <string name="settings_category_drawer">Drawer settings</string> + <string name="settings_category_icons">Icons settings</string> + <!-- Settings title to show Google Now at -1 screen on launcher. [CHAR LIMIT=50] --> <string name="title_show_google_app">Show Google app</string> <!-- Settings message explaining when the -1 screen is available on an LTR device. [CHAR LIMIT=100] --> @@ -49,6 +54,10 @@ <string name="settings_edit_allow_summary_off">Icons and widgets can\'t be added, removed and moved on the homescreen</string> <string name="settings_edit_widgets_error">It\'s not possible to add widgets to the home screen</string> + <!-- Icon badging --> + <string name="settings_icon_badging_desc_on">A bubble will be displayed above the icon when there\'s a notification</string> + <string name="settings_icon_badging_desc_off">No bubble will be displayed above the icon when there\'s a notification</string> + <!-- Folder titles --> <string name="google_title" translatable="false">Google</string> <string name="play_folder_title">Play</string> diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml index 343b40033..85efcd03b 100644 --- a/res/xml/launcher_preferences.xml +++ b/res/xml/launcher_preferences.xml @@ -24,62 +24,74 @@ android:summaryOn="@string/settings_edit_allow_summary_on" android:summaryOff="@string/settings_edit_allow_summary_off" /> - <com.android.launcher3.views.ButtonPreference - android:key="pref_icon_badging" - android:title="@string/icon_badging_title" - android:persistent="false" - android:widgetLayout="@layout/notification_pref_warning" > - <intent android:action="android.settings.NOTIFICATION_SETTINGS"> - <!-- This extra highlights the "Allow icon badges" field in Notification settings --> - <extra - android:name=":settings:fragment_args_key" - android:value="notification_badging" /> - </intent> - </com.android.launcher3.views.ButtonPreference> + <PreferenceCategory + android:key="category_home" + android:title="@string/settings_category_home"> - <SwitchPreference - android:key="pref_add_icon_to_home" - android:title="@string/auto_add_shortcuts_label" - android:summary="@string/auto_add_shortcuts_description" - android:defaultValue="true" - android:persistent="true" /> + <SwitchPreference + android:defaultValue="true" + android:key="pref_enable_minus_one" + android:summary="@string/pref_show_google_now_summary" + android:title="@string/title_show_google_app" /> - <SwitchPreference - android:key="pref_allowRotation" - android:title="@string/allow_rotation_title" - android:summary="@string/allow_rotation_desc" - android:defaultValue="@bool/allow_rotation" - android:persistent="true" /> + <SwitchPreference + android:key="pref_allowRotation" + android:title="@string/allow_rotation_title" + android:defaultValue="@bool/allow_rotation" + android:persistent="true" /> - <SwitchPreference - android:defaultValue="true" - android:key="pref_enable_minus_one" - android:summary="@string/pref_show_google_now_summary" - android:title="@string/title_show_google_app" /> - - <ListPreference - android:key="pref_override_icon_shape" - android:title="@string/icon_shape_override_label" - android:summary="%s" - android:entries="@array/icon_shape_entries" - android:entryValues="@array/icon_shape_paths" - android:defaultValue="@string/icon_shape_default" - android:persistent="false" /> - - <Preference - android:key="pref_grid_size" - android:title="@string/grid_size_text" - android:persistent="true" /> + <Preference + android:key="pref_grid_size" + android:title="@string/grid_size_text" + android:persistent="true" /> - <SwitchPreference - android:key="pref_desktop_show_labels" - android:title="@string/desktop_show_labels" - android:defaultValue="true" - android:persistent="true" /> + <SwitchPreference + android:key="pref_add_icon_to_home" + android:title="@string/auto_add_shortcuts_label" + android:summary="@string/auto_add_shortcuts_description" + android:defaultValue="true" + android:persistent="true" /> - <SwitchPreference - android:key="pref_drawer_show_labels" - android:title="@string/drawer_show_labels" - android:defaultValue="true" - android:persistent="true" /> + <SwitchPreference + android:key="pref_desktop_show_labels" + android:title="@string/desktop_show_labels" + android:defaultValue="true" + android:persistent="true" /> + </PreferenceCategory> + + <PreferenceCategory android:title="@string/settings_category_drawer"> + + <SwitchPreference + android:key="pref_drawer_show_labels" + android:title="@string/drawer_show_labels" + android:defaultValue="true" + android:persistent="true" /> + </PreferenceCategory> + + <PreferenceCategory + android:key="category_icons" + android:title="@string/settings_category_icons"> + + <ListPreference + android:key="pref_override_icon_shape" + android:title="@string/icon_shape_override_label" + android:summary="%s" + android:entries="@array/icon_shape_entries" + android:entryValues="@array/icon_shape_paths" + android:defaultValue="@string/icon_shape_default" + android:persistent="false" /> + + <com.android.launcher3.views.ButtonPreference + android:key="pref_icon_badging" + android:title="@string/icon_badging_title" + android:persistent="false" + android:widgetLayout="@layout/notification_pref_warning" > + <intent android:action="android.settings.NOTIFICATION_SETTINGS"> + <!-- This extra highlights the "Allow icon badges" field in Notification settings --> + <extra + android:name=":settings:fragment_args_key" + android:value="notification_badging" /> + </intent> + </com.android.launcher3.views.ButtonPreference> + </PreferenceCategory> </PreferenceScreen> diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java index 26ca61a82..c055c130f 100644 --- a/src/com/android/launcher3/SettingsActivity.java +++ b/src/com/android/launcher3/SettingsActivity.java @@ -39,6 +39,7 @@ import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; +import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.preference.SwitchPreference; import android.provider.Settings; @@ -129,15 +130,20 @@ public class SettingsActivity extends Activity { ContentResolver resolver = getActivity().getContentResolver(); + PreferenceCategory homeGroup = (PreferenceCategory) + findPreference("category_home"); + PreferenceCategory iconGroup = (PreferenceCategory) + findPreference("category_icons"); + ButtonPreference iconBadgingPref = - (ButtonPreference) findPreference(ICON_BADGING_PREFERENCE_KEY); + (ButtonPreference) iconGroup.findPreference(ICON_BADGING_PREFERENCE_KEY); if (!Utilities.ATLEAST_OREO) { getPreferenceScreen().removePreference( findPreference(SessionCommitReceiver.ADD_ICON_PREFERENCE_KEY)); - getPreferenceScreen().removePreference(iconBadgingPref); + iconGroup.removePreference(iconBadgingPref); } else if (!getResources().getBoolean(R.bool.notification_badging_enabled) || getContext().getSystemService(ActivityManager.class).isLowRamDevice()) { - getPreferenceScreen().removePreference(iconBadgingPref); + iconGroup.removePreference(iconBadgingPref); } else { // Listen to system notification badge settings while this UI is active. mIconBadgingObserver = new IconBadgingObserver( @@ -145,32 +151,33 @@ public class SettingsActivity extends Activity { mIconBadgingObserver.register(NOTIFICATION_BADGING, NOTIFICATION_ENABLED_LISTENERS); } - Preference iconShapeOverride = findPreference(IconShapeOverride.KEY_PREFERENCE); + Preference iconShapeOverride = iconGroup.findPreference( + IconShapeOverride.KEY_PREFERENCE); if (iconShapeOverride != null) { if (IconShapeOverride.isSupported(getActivity())) { IconShapeOverride.handlePreferenceUi((ListPreference) iconShapeOverride); } else { - getPreferenceScreen().removePreference(iconShapeOverride); + iconGroup.removePreference(iconShapeOverride); } } // Setup allow rotation preference - Preference rotationPref = findPreference(ALLOW_ROTATION_PREFERENCE_KEY); + Preference rotationPref = homeGroup.findPreference(ALLOW_ROTATION_PREFERENCE_KEY); if (getResources().getBoolean(R.bool.allow_rotation)) { // Launcher supports rotation by default. No need to show this setting. - getPreferenceScreen().removePreference(rotationPref); + homeGroup.removePreference(rotationPref); } else { // Initialize the UI once rotationPref.setDefaultValue(getAllowRotationDefaultValue()); + } - SwitchPreference minusOne = (SwitchPreference) findPreference(KEY_MINUS_ONE); - if (!LineageUtils.hasPackageInstalled(getActivity(), - LineageLauncherCallbacks.SEARCH_PACKAGE)) { - getPreferenceScreen().removePreference(minusOne); - } + SwitchPreference minusOne = (SwitchPreference) findPreference(KEY_MINUS_ONE); + if (!LineageUtils.hasPackageInstalled(getActivity(), + LineageLauncherCallbacks.SEARCH_PACKAGE)) { + homeGroup.removePreference(minusOne); } - mGridPref = findPreference(KEY_GRID_SIZE); + mGridPref = homeGroup.findPreference(KEY_GRID_SIZE); if (mGridPref != null) { mGridPref.setOnPreferenceClickListener(preference -> { setCustomGridSize(); @@ -352,7 +359,9 @@ public class SettingsActivity extends Activity { @Override public void onSettingChanged(boolean enabled) { - int summary = enabled ? R.string.icon_badging_desc_on : R.string.icon_badging_desc_off; + int summary = enabled ? + R.string.settings_icon_badging_desc_on : + R.string.settings_icon_badging_desc_off; boolean serviceEnabled = true; if (enabled) { |