diff options
7 files changed, 43 insertions, 15 deletions
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml index 494846aed..23439c527 100644 --- a/res/values/preferences_defaults.xml +++ b/res/values/preferences_defaults.xml @@ -8,4 +8,5 @@ <bool name="preferences_interface_drawer_dark_default">true</bool> <bool name="preferences_interface_general_icons_large_default">false</bool> <bool name="preferences_interface_use_horizontal_scrubber_default">true</bool> + <bool name="preferences_interface_drawer_search_default">true</bool> </resources> diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java index 0f1585a4a..e4ca29c88 100644 --- a/src/com/android/launcher3/BaseContainerView.java +++ b/src/com/android/launcher3/BaseContainerView.java @@ -75,11 +75,11 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab updateBackgroundAndPaddings(); } - protected void setHasSearchBar() { - mHasSearchBar = true; + public void setHasSearchBar(boolean hasSearchBar) { + mHasSearchBar = hasSearchBar; } - protected boolean hasSearchBar() { + public boolean hasSearchBar() { return mHasSearchBar; } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 228be03b7..f8044aa5b 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1581,11 +1581,7 @@ public class Launcher extends Activity // Setup Apps and Widgets mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view); mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view); - if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { - mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); - } else { - mAppsView.setSearchBarController(mAppsView.newDefaultAppSearchController()); - } + setupSearchBar(this); // Setup the drag controller (drop targets have to be added in reverse order in priority) dragController.setDragScoller(mWorkspace); @@ -1863,11 +1859,7 @@ public class Launcher extends Activity .from(this).inflate(R.layout.all_apps, mDragLayer, false); mDragLayer.addView(mAppsView, mDragLayer.getChildCount() - 1); mAppsView.setVisibility(View.INVISIBLE); - if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { - mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); - } else { - mAppsView.setSearchBarController(mAppsView.newDefaultAppSearchController()); - } + setupSearchBar(this); mAppsView.addApps(addedApps); tryAndUpdatePredictedApps(); mAppsView.reset(); @@ -5144,6 +5136,21 @@ public class Launcher extends Activity } } + private void setupSearchBar(Context context) { + boolean isDrawerSearchBarEnabled = SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_DRAWER_SEARCH, + R.bool.preferences_interface_homescreen_search_default); + + if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { + mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); + } else { + mAppsView.setSearchBarController(mAppsView.newDefaultAppSearchController()); + } + mAppsView.setHasSearchBar(isDrawerSearchBarEnabled); + mAppsView.setSearchBarContainerViewVisibility( + isDrawerSearchBarEnabled ? View.VISIBLE : View.GONE); + } + class SettingsPanelSlideListener extends VerticalSlidingPanel.SimplePanelSlideListener { ImageView mAnimatedArrow; diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index f00b2f95a..3e465d319 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -45,7 +45,8 @@ public class OverviewSettingsPanel { res.getString(R.string.icon_labels), res.getString(R.string.app_drawer_style), res.getString(R.string.app_drawer_color), - res.getString(R.string.fast_scroller_type)}; + res.getString(R.string.fast_scroller_type), + res.getString(R.string.home_screen_search_text)}; String[] valuesApp = new String[] { res.getString(R.string.larger_icons_text), diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index b82cd2d0a..feb96df29 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -300,11 +300,16 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc mSearchBarContainerView.addView(searchBarView); mSearchBarContainerView.setVisibility(View.VISIBLE); mSearchBarView = searchBarView; - setHasSearchBar(); + setHasSearchBar(true); updateBackgroundAndPaddings(); } + public void setSearchBarContainerViewVisibility(int visibility) { + mSearchBarContainerView.setVisibility(visibility); + updateBackgroundAndPaddings(); + } + /** * Scrolls this list view to the top. */ diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index f1c0cd87c..76b880e59 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -159,6 +159,12 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { : res.getString(R.string.fast_scroller_type_vertical); setStateText(stateView, settingSwitch, state); break; + case 4: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_DRAWER_SEARCH, + R.bool.preferences_interface_drawer_search_default); + setSettingSwitch(stateView, settingSwitch, current); + break; default: hideStates(stateView, settingSwitch); } @@ -279,6 +285,13 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { mLauncher.reloadAppDrawer(); mLauncher.reloadWidgetView(); break; + case 4: + + onSettingsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_DRAWER_SEARCH, + R.bool.preferences_interface_drawer_search_default); + mLauncher.reloadAppDrawer(); + break; } break; case OverviewSettingsPanel.APP_SETTINGS_POSITION: diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java index 76a49d2de..7c3a5e042 100644 --- a/src/com/android/launcher3/settings/SettingsProvider.java +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -33,6 +33,7 @@ public final class SettingsProvider { public static final String SETTINGS_UI_DRAWER_HIDE_ICON_LABELS = "ui_drawer_hide_icon_labels"; public static final String SETTINGS_UI_DRAWER_STYLE_USE_COMPACT = "ui_drawer_style_compact"; public static final String SETTINGS_UI_DRAWER_DARK = "ui_drawer_dark"; + public static final String SETTINGS_UI_DRAWER_SEARCH = "ui_drawer_search"; public static final String SETTINGS_UI_USE_HORIZONTAL_SCRUBBER = "ui_horizontal_scrubber"; public static final String SETTINGS_UI_GENERAL_ICONS_LARGE = "ui_general_icons_large"; |