From 992a5f566e7f1b1fc8bd766f1fd00bee7ea2a634 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 2 Mar 2016 11:32:18 -0800 Subject: [PATCH] Starting market search whenever the search key is pressed Bug: 27365428 Change-Id: I508cb35cd1aaab1eac6cf60014fa6f80592365ef --- .../allapps/AllAppsContainerView.java | 2 +- .../launcher3/allapps/AllAppsGridAdapter.java | 2 +- .../allapps/AllAppsSearchBarController.java | 34 +++++-------------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 013bd8cccb..1d308d5020 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -229,7 +229,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc throw new RuntimeException("Expected search bar controller to only be set once"); } mSearchBarController = searchController; - mSearchBarController.initialize(mApps, mSearchInput, mAppsRecyclerView, this); + mSearchBarController.initialize(mApps, mSearchInput, mLauncher, this); updateBackgroundAndPaddings(); } diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index d9313f8ecc..e983860eb5 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -566,7 +566,7 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter 1) { + // Skip if the query is empty + String query = v.getText().toString(); + if (query.isEmpty()) { return false; } - // Otherwise, find the first icon, or fallback to the search-market-view and launch it - List items = mApps.getAdapterItems(); - for (int i = 0; i < items.size(); i++) { - AlphabeticalAppsList.AdapterItem item = items.get(i); - switch (item.viewType) { - case AllAppsGridAdapter.ICON_VIEW_TYPE: - case AllAppsGridAdapter.SEARCH_MARKET_VIEW_TYPE: - mAppsRecyclerView.getChildAt(i).performClick(); - mInputMethodManager.hideSoftInputFromWindow(mInput.getWindowToken(), 0); - return true; - } - } - return false; + return mLauncher.startActivitySafely( + v, AllAppsGridAdapter.createMarketSearchIntent(query), null); } @Override