summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-03-02 11:32:18 -0800
committerSunny Goyal <sunnygoyal@google.com>2016-03-02 11:32:18 -0800
commit992a5f566e7f1b1fc8bd766f1fd00bee7ea2a634 (patch)
treed3e2a970a546cceab2afe5caef6e7e41b03e02f6
parenta10bf37446e5d6714fb000ee5e5afea1a0c27baf (diff)
downloadandroid_packages_apps_Trebuchet-992a5f566e7f1b1fc8bd766f1fd00bee7ea2a634.tar.gz
android_packages_apps_Trebuchet-992a5f566e7f1b1fc8bd766f1fd00bee7ea2a634.tar.bz2
android_packages_apps_Trebuchet-992a5f566e7f1b1fc8bd766f1fd00bee7ea2a634.zip
Starting market search whenever the search key is pressed
Bug: 27365428 Change-Id: I508cb35cd1aaab1eac6cf60014fa6f80592365ef
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java2
-rw-r--r--src/com/android/launcher3/allapps/AllAppsGridAdapter.java2
-rw-r--r--src/com/android/launcher3/allapps/AllAppsSearchBarController.java34
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 013bd8ccc..1d308d502 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 d9313f8ec..e983860eb 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<AllAppsGridAdapter.
/**
* Creates a new market search intent.
*/
- private Intent createMarketSearchIntent(String query) {
+ public static Intent createMarketSearchIntent(String query) {
Uri marketSearchUri = Uri.parse("market://search")
.buildUpon()
.appendQueryParameter("q", query)
diff --git a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
index fdce3895f..f832a548f 100644
--- a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
@@ -28,11 +28,11 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.android.launcher3.ExtendedEditText;
+import com.android.launcher3.Launcher;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.ComponentKey;
import java.util.ArrayList;
-import java.util.List;
/**
* An interface to a search box that AllApps can command.
@@ -40,9 +40,7 @@ import java.util.List;
public abstract class AllAppsSearchBarController
implements TextWatcher, OnEditorActionListener, ExtendedEditText.OnBackKeyListener {
- private static final boolean ALLOW_SINGLE_APP_LAUNCH = true;
-
- protected AllAppsRecyclerView mAppsRecyclerView;
+ protected Launcher mLauncher;
protected AlphabeticalAppsList mApps;
protected Callbacks mCb;
protected ExtendedEditText mInput;
@@ -55,10 +53,10 @@ public abstract class AllAppsSearchBarController
*/
public final void initialize(
AlphabeticalAppsList apps, ExtendedEditText input,
- AllAppsRecyclerView recycleView, Callbacks cb) {
+ Launcher launcher, Callbacks cb) {
mApps = apps;
mCb = cb;
- mAppsRecyclerView = recycleView;
+ mLauncher = launcher;
mInput = input;
mInput.addTextChangedListener(this);
@@ -102,31 +100,17 @@ public abstract class AllAppsSearchBarController
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- // Skip if we disallow app-launch-on-enter
- if (!ALLOW_SINGLE_APP_LAUNCH) {
- return false;
- }
// Skip if it's not the right action
if (actionId != EditorInfo.IME_ACTION_SEARCH) {
return false;
}
- // Skip if there are more than one icon
- if (mApps.getNumFilteredApps() > 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<AlphabeticalAppsList.AdapterItem> 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