Skip to content

Commit f451b50

Browse files
committed
Shade: Use AllAppsStore instead of AppsList for search results
1 parent aeba41a commit f451b50

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

shade/src/amirz/shade/hidden/HiddenAppsSearchAlgorithm.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
package amirz.shade.hidden;
22

33
import android.content.Context;
4+
import android.os.Process;
45

56
import com.android.launcher3.AppInfo;
67
import com.android.launcher3.R;
8+
import com.android.launcher3.allapps.AppInfoComparator;
79
import com.android.launcher3.allapps.search.AllAppsSearchBarController;
810
import com.android.launcher3.allapps.search.DefaultAppSearchAlgorithm;
911
import com.android.launcher3.util.ComponentKey;
12+
import com.android.launcher3.util.ItemInfoMatcher;
1013

1114
import java.util.ArrayList;
15+
import java.util.Collection;
16+
import java.util.Collections;
1217
import java.util.List;
1318

1419
public class HiddenAppsSearchAlgorithm extends DefaultAppSearchAlgorithm {
1520
private final Context mContext;
16-
private final List<AppInfo> mApps;
21+
private final AppInfoComparator mAppNameComparator;
22+
private final Collection<AppInfo> mApps;
1723
private final String mKeyGlobal;
1824
private final String mKeyTranslated;
1925

20-
public HiddenAppsSearchAlgorithm(Context context, List<AppInfo> apps) {
21-
super(apps);
26+
public HiddenAppsSearchAlgorithm(Context context, Collection<AppInfo> apps) {
27+
super(Collections.emptyList());
2228
mContext = context;
29+
mAppNameComparator = new AppInfoComparator(context);
2330
mApps = apps;
2431
mKeyGlobal = context.getString(R.string.search_hidden_global).toLowerCase();
2532
mKeyTranslated = context.getString(R.string.search_hidden).toLowerCase();
@@ -43,14 +50,19 @@ private ArrayList<ComponentKey> getTitleMatchResult(String query, boolean showHi
4350
// Do an intersection of the words in the query and each title, and filter out all the
4451
// apps that don't match all of the words in the query.
4552
final String queryTextLower = query.toLowerCase();
46-
final ArrayList<ComponentKey> result = new ArrayList<>();
53+
final List<AppInfo> result = new ArrayList<>();
4754
StringMatcher matcher = StringMatcher.getInstance();
4855
for (AppInfo info : mApps) {
4956
if (matches(info, queryTextLower, matcher) || (showHidden
5057
&& HiddenAppsDatabase.isHidden(mContext, info.componentName, info.user))) {
51-
result.add(info.toComponentKey());
58+
result.add(info);
5259
}
5360
}
54-
return result;
61+
Collections.sort(result, mAppNameComparator);
62+
ArrayList<ComponentKey> resultKeys = new ArrayList<>();
63+
for (AppInfo appInfo : result) {
64+
resultKeys.add(appInfo.toComponentKey());
65+
}
66+
return resultKeys;
5567
}
5668
}

shade/src/amirz/shade/search/AllAppsQsb.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public void initialize(AllAppsContainerView appsView) {
230230
mAppsView = appsView;
231231
mFallbackSearchView = findViewById(R.id.fallback_search_view);
232232
mSearchBarController.initialize(
233-
new HiddenAppsSearchAlgorithm(mLauncher, mApps.getApps()),
233+
new HiddenAppsSearchAlgorithm(mLauncher, appsView.getAppsStore().getApps()),
234234
mFallbackSearchView, mLauncher, this);
235235

236236
appsView.setRecyclerViewVerticalFadingEdgeEnabled(true);

0 commit comments

Comments
 (0)