summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-06-16 11:36:19 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-06-16 11:41:38 -0700
commit5183285847816cee9d0db6a8a7ab1a5929163e4e (patch)
tree97f9cfa0316860cb060540e5a78466582fd2e966 /src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
parentb42120300ec622804af2de9c29ce849f96e4de23 (diff)
downloadandroid_packages_apps_Trebuchet-5183285847816cee9d0db6a8a7ab1a5929163e4e.tar.gz
android_packages_apps_Trebuchet-5183285847816cee9d0db6a8a7ab1a5929163e4e.tar.bz2
android_packages_apps_Trebuchet-5183285847816cee9d0db6a8a7ab1a5929163e4e.zip
Using component key for app search results
Change-Id: Idc610cde340331892a5fabfa8bf952d136675f81
Diffstat (limited to 'src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java')
-rw-r--r--src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java b/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
index 28854be0e..9ca5ccd06 100644
--- a/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
+++ b/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
@@ -15,9 +15,10 @@
*/
package com.android.launcher3.allapps;
-import android.content.ComponentName;
import android.os.Handler;
+
import com.android.launcher3.AppInfo;
+import com.android.launcher3.util.ComponentKey;
import java.util.ArrayList;
import java.util.List;
@@ -46,19 +47,7 @@ public class DefaultAppSearchAlgorithm {
public void doSearch(final String query,
final AllAppsSearchBarController.Callbacks callback) {
- // Do an intersection of the words in the query and each title, and filter out all the
- // apps that don't match all of the words in the query.
- final String queryTextLower = query.toLowerCase();
- final String[] queryWords = SPLIT_PATTERN.split(queryTextLower);
- final ArrayList<ComponentName> result = new ArrayList<>();
- int total = mApps.size();
-
- for (int i = 0; i < total; i++) {
- AppInfo info = mApps.get(i);
- if (!result.contains(info.componentName) && matches(info, queryWords)) {
- result.add(info.componentName);
- }
- }
+ final ArrayList<ComponentKey> result = getTitleMatchResult(query);
mResultHandler.post(new Runnable() {
@Override
@@ -68,7 +57,22 @@ public class DefaultAppSearchAlgorithm {
});
}
- private boolean matches(AppInfo info, String[] queryWords) {
+ protected ArrayList<ComponentKey> getTitleMatchResult(String query) {
+ // Do an intersection of the words in the query and each title, and filter out all the
+ // apps that don't match all of the words in the query.
+ final String queryTextLower = query.toLowerCase();
+ final String[] queryWords = SPLIT_PATTERN.split(queryTextLower);
+
+ final ArrayList<ComponentKey> result = new ArrayList<>();
+ for (AppInfo info : mApps) {
+ if (matches(info, queryWords)) {
+ result.add(info.toComponentKey());
+ }
+ }
+ return result;
+ }
+
+ protected boolean matches(AppInfo info, String[] queryWords) {
String title = info.title.toString();
String[] words = SPLIT_PATTERN.split(title.toLowerCase());
for (int qi = 0; qi < queryWords.length; qi++) {
@@ -87,5 +91,4 @@ public class DefaultAppSearchAlgorithm {
}
return true;
}
-
}