Search in sources :

Example 26 with WidgetsListContentEntry

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

the class WidgetsDiffReporterTest method headersContentsMix_contentMaxSpanSizeModified_shouldInvokeCorrectCallbacks.

@Test
public void headersContentsMix_contentMaxSpanSizeModified_shouldInvokeCorrectCallbacks() {
    // GIVEN the current list has app headers [A, B, E content].
    ArrayList<WidgetsListBaseEntry> currentList = new ArrayList<>(List.of(mHeaderA, mHeaderB, mContentE));
    // GIVEN the new list has max span size in "E content" modified.
    List<WidgetsListBaseEntry> newList = List.of(mHeaderA, mHeaderB, new WidgetsListContentEntry(mContentE.mPkgItem, mContentE.mTitleSectionName, mContentE.mWidgets, mContentE.getMaxSpanSizeInCells() + 1));
    // WHEN computing the list difference.
    mWidgetsDiffReporter.process(currentList, newList, COMPARATOR);
    // THEN notify "E content" has been changed.
    verify(mAdapter).notifyItemChanged(/* position= */
    2);
    // THEN the current list contains all elements from the new list.
    assertThat(currentList).containsExactlyElementsIn(newList);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ArrayList(java.util.ArrayList) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 27 with WidgetsListContentEntry

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

the class WidgetsListAdapterTest method generateSampleMap.

/**
 * Generates a list of sample widget entries.
 *
 * <p>Each sample app has 1 widget only. An app is represented by 2 entries,
 * {@link WidgetsListHeaderEntry} & {@link WidgetsListContentEntry}. Only
 * {@link WidgetsListHeaderEntry} is always visible in the {@link WidgetsListAdapter}.
 * {@link WidgetsListContentEntry} is only shown upon clicking the corresponding app's
 * {@link WidgetsListHeaderEntry}. Only at most one {@link WidgetsListContentEntry} is shown at
 * a time.
 *
 * @param num the number of apps that have widgets.
 */
private ArrayList<WidgetsListBaseEntry> generateSampleMap(int num) {
    ArrayList<WidgetsListBaseEntry> result = new ArrayList<>();
    if (num <= 0)
        return result;
    for (int i = 0; i < num; i++) {
        String packageName = TEST_PACKAGE_PLACEHOLDER + i;
        List<WidgetItem> widgetItems = generateWidgetItems(packageName, /* numOfWidgets= */
        1);
        PackageItemInfo pInfo = new PackageItemInfo(packageName, widgetItems.get(0).user);
        pInfo.title = pInfo.packageName;
        pInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
        result.add(new WidgetsListHeaderEntry(pInfo, /* titleSectionName= */
        "", widgetItems));
        result.add(new WidgetsListContentEntry(pInfo, /* titleSectionName= */
        "", widgetItems));
    }
    return result;
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) ArrayList(java.util.ArrayList) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry)

Example 28 with WidgetsListContentEntry

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

the class WidgetsListTableViewHolderBinderTest method generateSampleAppWithWidgets.

private WidgetsListContentEntry generateSampleAppWithWidgets(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 WidgetsListContentEntry(appInfo, /* titleSectionName= */
    "", generateWidgetItems(packageName, numOfWidgets), Integer.MAX_VALUE);
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry)

Example 29 with WidgetsListContentEntry

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

the class WidgetsListContentEntryTest method equals_entriesWithDifferentTitleSectionName_returnFalse.

@Test
public void equals_entriesWithDifferentTitleSectionName_returnFalse() {
    WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
    2, /* spanY= */
    3);
    WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
    "T", List.of(widgetItem1), /* maxSpanSizeInCells= */
    3);
    WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
    "S", List.of(widgetItem1), /* maxSpanSizeInCells= */
    3);
    assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isFalse();
}
Also used : WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 30 with WidgetsListContentEntry

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

the class WidgetsListContentEntryTest method equals_entriesWithDifferentWidgetsList_returnFalse.

@Test
public void equals_entriesWithDifferentWidgetsList_returnFalse() {
    WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
    2, /* spanY= */
    3);
    WidgetItem widgetItem2 = createWidgetItem(mWidget2, /* spanX= */
    2, /* spanY= */
    3);
    WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
    "T", List.of(widgetItem1), /* maxSpanSizeInCells= */
    3);
    WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
    "T", List.of(widgetItem2), /* maxSpanSizeInCells= */
    3);
    assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isFalse();
}
Also used : WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

WidgetsListContentEntry (com.android.launcher3.widget.model.WidgetsListContentEntry)101 WidgetItem (com.android.launcher3.model.WidgetItem)77 Test (org.junit.Test)55 SmallTest (androidx.test.filters.SmallTest)44 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)36 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)30 ArrayList (java.util.ArrayList)30 WidgetsListHeaderEntry (com.android.launcher3.widget.model.WidgetsListHeaderEntry)20 List (java.util.List)20 PackageUserKey (com.android.launcher3.util.PackageUserKey)15 Map (java.util.Map)15 Collectors (java.util.stream.Collectors)15 TableRow (android.widget.TableRow)11 Log (android.util.Log)10 NonNull (androidx.annotation.NonNull)10 Nullable (androidx.annotation.Nullable)10 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)10 WidgetsListSearchHeaderEntry (com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)10 Arrays (java.util.Arrays)10 HashMap (java.util.HashMap)10