Have a recycler view to show search results.
-Have a recycler view layout for search widgets list. -Make WidgetsFullSheet implement interface- SearchModeListener to get notified when user is using search and also when search results are ready. -Have a WidgetsListSearchHeaderViewHolderBinder for search result headers which shows subtext in header as concatenated string of widget/shortcut labels. -Modify WidgetsListAdapter and WidgetsDiffReporter to work well with search recycler view. Test: Tested prototype locally. Also added robolectric test. Bug: b/157286785 Change-Id: Ie29d9f295fddb6d727b5fc26a360f514f2f4a763
This commit is contained in:
1 parent
24a63bacd6
commit
334e65935b
21 files changed
+698
-68
No files matched your search
@@ -17,21 +17,25 @@ package com.android.launcher3.widget.model;
|
||||
|
||||
import com.android.launcher3.model.WidgetItem;
|
||||
import com.android.launcher3.model.data.PackageItemInfo;
|
||||
import com.android.launcher3.widget.WidgetItemComparator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** An information holder for an app which has widgets or/and shortcuts. */
|
||||
public final class WidgetsListHeaderEntry extends WidgetsListBaseEntry {
|
||||
|
||||
public final int widgetsCount;
|
||||
public final int shortcutsCount;
|
||||
public final List<WidgetItem> mWidgets;
|
||||
|
||||
private boolean mIsWidgetListShown = false;
|
||||
private boolean mHasEntryUpdated = false;
|
||||
|
||||
public WidgetsListHeaderEntry(PackageItemInfo pkgItem, String titleSectionName,
|
||||
Collection<WidgetItem> items) {
|
||||
List<WidgetItem> items) {
|
||||
super(pkgItem, titleSectionName);
|
||||
mWidgets = items.stream().sorted(new WidgetItemComparator()).collect(Collectors.toList());
|
||||
widgetsCount = (int) items.stream().filter(item -> item.widgetInfo != null).count();
|
||||
shortcutsCount = Math.max(0, items.size() - widgetsCount);
|
||||
}
|
||||
@@ -56,9 +60,22 @@ public final class WidgetsListHeaderEntry extends WidgetsListBaseEntry {
|
||||
return mHasEntryUpdated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Header:" + mPkgItem.packageName + ":" + mWidgets.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Rank
|
||||
public int getRank() {
|
||||
return RANK_WIDGETS_LIST_HEADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof WidgetsListHeaderEntry)) return false;
|
||||
WidgetsListHeaderEntry otherEntry = (WidgetsListHeaderEntry) obj;
|
||||
return mWidgets.equals(otherEntry.mWidgets) && mPkgItem.equals(otherEntry.mPkgItem)
|
||||
&& mTitleSectionName.equals(otherEntry.mTitleSectionName);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user