Search in sources :

Example 1 with WidgetsListSearchHeaderEntry

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

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 2 with WidgetsListSearchHeaderEntry

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

the class WidgetsListSearchHeaderViewHolderBinderTest method bindViewHolder_shouldAttachOnHeaderClickListener.

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

Example 3 with WidgetsListSearchHeaderEntry

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

the class WidgetsListSearchHeaderViewHolderBinderTest method bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle.

@Test
public void bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle() {
    WidgetsListSearchHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mTestActivity));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListSearchHeaderEntry entry = generateSampleSearchHeader(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
    3);
    mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
    0);
    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) Test(org.junit.Test)

Example 4 with WidgetsListSearchHeaderEntry

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

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 5 with WidgetsListSearchHeaderEntry

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

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)

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