Search in sources :

Example 21 with WidgetsListSearchHeaderEntry

use of com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class SimpleWidgetsSearchAlgorithm method getFilteredWidgets.

/**
 * Returns entries for all matched widgets
 */
public static ArrayList<WidgetsListBaseEntry> getFilteredWidgets(PopupDataProvider dataProvider, String input) {
    ArrayList<WidgetsListBaseEntry> results = new ArrayList<>();
    dataProvider.getAllWidgets().stream().filter(entry -> entry instanceof WidgetsListHeaderEntry).forEach(headerEntry -> {
        List<WidgetItem> matchedWidgetItems = filterWidgetItems(input, headerEntry.mPkgItem.title.toString(), headerEntry.mWidgets);
        if (matchedWidgetItems.size() > 0) {
            results.add(new WidgetsListSearchHeaderEntry(headerEntry.mPkgItem, headerEntry.mTitleSectionName, matchedWidgetItems));
            results.add(new WidgetsListContentEntry(headerEntry.mPkgItem, headerEntry.mTitleSectionName, matchedWidgetItems));
        }
    });
    return results;
}
Also used : PopupDataProvider(com.android.launcher3.popup.PopupDataProvider) SearchCallback(com.android.launcher3.search.SearchCallback) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) SearchAlgorithm(com.android.launcher3.search.SearchAlgorithm) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StringMatcher(com.android.launcher3.search.StringMatcherUtility.StringMatcher) List(java.util.List) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) StringMatcherUtility.matches(com.android.launcher3.search.StringMatcherUtility.matches) Handler(android.os.Handler) WidgetItem(com.android.launcher3.model.WidgetItem) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ArrayList(java.util.ArrayList) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)

Example 22 with WidgetsListSearchHeaderEntry

use of com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListSearchHeaderViewHolderBinderTest method bindViewHolder_shouldAttachOnHeaderClickListener.

@Test
public void bindViewHolder_shouldAttachOnHeaderClickListener() {
    WidgetsListSearchHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mContext));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListSearchHeaderEntry entry = generateSampleSearchHeader(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
    3);
    mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
    0, EMPTY_LIST);
    widgetsListHeader.callOnClick();
    verify(mOnHeaderClickListener).onHeaderClicked(eq(true), eq(PackageUserKey.fromPackageItemInfo(entry.mPkgItem)));
}
Also used : FrameLayout(android.widget.FrameLayout) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 23 with WidgetsListSearchHeaderEntry

use of com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListSearchHeaderViewHolderBinderTest method generateSampleSearchHeader.

private WidgetsListSearchHeaderEntry generateSampleSearchHeader(String appName, String packageName, int numOfWidgets) {
    PackageItemInfo appInfo = new PackageItemInfo(packageName, UserHandle.CURRENT);
    appInfo.title = appName;
    appInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
    return new WidgetsListSearchHeaderEntry(appInfo, /* titleSectionName= */
    "", generateWidgetItems(packageName, numOfWidgets));
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)

Example 24 with WidgetsListSearchHeaderEntry

use of com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListHeader method applyIconAndLabel.

@UiThread
private void applyIconAndLabel(WidgetsListSearchHeaderEntry entry) {
    PackageItemInfo info = entry.mPkgItem;
    setIcon(info);
    setTitles(entry);
    setExpanded(entry.isWidgetListShown());
    super.setTag(info);
    verifyHighRes();
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) UiThread(androidx.annotation.UiThread)

Example 25 with WidgetsListSearchHeaderEntry

use of com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListSearchHeaderViewHolderBinderTest method bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle.

@Test
public void bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle() {
    WidgetsListSearchHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mContext));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListSearchHeaderEntry entry = generateSampleSearchHeader(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
    3);
    mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
    0, EMPTY_LIST);
    TextView appTitle = widgetsListHeader.findViewById(R.id.app_title);
    TextView appSubtitle = widgetsListHeader.findViewById(R.id.app_subtitle);
    assertThat(appTitle.getText()).isEqualTo(APP_NAME);
    assertThat(appSubtitle.getText()).isEqualTo(".SampleWidget0, .SampleWidget1, .SampleWidget2");
}
Also used : FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

WidgetsListSearchHeaderEntry (com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)20 FrameLayout (android.widget.FrameLayout)10 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)10 Test (org.junit.Test)10 SmallTest (androidx.test.filters.SmallTest)8 Handler (android.os.Handler)5 TextView (android.widget.TextView)5 UiThread (androidx.annotation.UiThread)5 WidgetItem (com.android.launcher3.model.WidgetItem)5 PopupDataProvider (com.android.launcher3.popup.PopupDataProvider)5 SearchAlgorithm (com.android.launcher3.search.SearchAlgorithm)5 SearchCallback (com.android.launcher3.search.SearchCallback)5 StringMatcher (com.android.launcher3.search.StringMatcherUtility.StringMatcher)5 StringMatcherUtility.matches (com.android.launcher3.search.StringMatcherUtility.matches)5 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)5 WidgetsListContentEntry (com.android.launcher3.widget.model.WidgetsListContentEntry)5 WidgetsListHeaderEntry (com.android.launcher3.widget.model.WidgetsListHeaderEntry)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5