Search in sources :

Example 16 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListAdapterTest method setWidgets_expandedApp_moreWidgets_shouldNotifyItemChangedWithWidgetItemInfoDiff.

@Test
public void setWidgets_expandedApp_moreWidgets_shouldNotifyItemChangedWithWidgetItemInfoDiff() {
    // GIVEN the adapter was first populated with com.google.test0 & com.google.test1. Each app
    // has one widget.
    ArrayList<WidgetsListBaseEntry> allEntries = generateSampleMap(2);
    mAdapter.setWidgets(allEntries);
    // GIVEN test com.google.test1 is expanded.
    // Visible entries in the adapter are:
    // [com.google.test0, com.google.test1, com.google.test1 content]
    mAdapter.onHeaderClicked(/* showWidgets= */
    true, new PackageUserKey(TEST_PACKAGE_PLACEHOLDER + 1, mUserHandle));
    Mockito.reset(mListener);
    // WHEN the adapter is updated with the same list of apps but com.google.test1 has 2 widgets
    // now.
    WidgetsListContentEntry testPackage1ContentEntry = (WidgetsListContentEntry) allEntries.get(3);
    WidgetItem widgetItem = testPackage1ContentEntry.mWidgets.get(0);
    WidgetsListContentEntry newTestPackage1ContentEntry = new WidgetsListContentEntry(testPackage1ContentEntry.mPkgItem, testPackage1ContentEntry.mTitleSectionName, List.of(widgetItem, widgetItem));
    allEntries.set(3, newTestPackage1ContentEntry);
    mAdapter.setWidgets(allEntries);
    // THEN the onItemRangeChanged is invoked for "com.google.test1 content" at index 2.
    verify(mListener).onItemRangeChanged(eq(2), eq(1), isNull());
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) PackageUserKey(com.android.launcher3.util.PackageUserKey) WidgetItem(com.android.launcher3.model.WidgetItem) Test(org.junit.Test)

Example 17 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListHeaderViewHolderBinderTest method bindViewHolder_shouldAttachOnHeaderClickListener.

@Test
public void bindViewHolder_shouldAttachOnHeaderClickListener() {
    WidgetsListHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mTestActivity));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListHeaderEntry entry = generateSampleAppHeader(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) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) Test(org.junit.Test)

Example 18 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey 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 19 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by crdroidandroid.

the class BindWidgetTest method getInvalidWidgetInfo.

/**
 * Returns a LauncherAppWidgetInfo with package name which is not present on the device
 */
private LauncherAppWidgetInfo getInvalidWidgetInfo() {
    String invalidPackage = "com.invalidpackage";
    int count = 0;
    String pkg = invalidPackage;
    Set<String> activePackage = getOnUiThread(() -> {
        Set<String> packages = new HashSet<>();
        InstallSessionHelper.INSTANCE.get(mTargetContext).getActiveSessions().keySet().forEach(packageUserKey -> packages.add(packageUserKey.mPackageName));
        return packages;
    });
    while (true) {
        try {
            mTargetContext.getPackageManager().getPackageInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES);
        } catch (Exception e) {
            if (!activePackage.contains(pkg)) {
                break;
            }
        }
        pkg = invalidPackage + count;
        count++;
    }
    LauncherAppWidgetInfo item = new LauncherAppWidgetInfo(10, new ComponentName(pkg, "com.test.widgetprovider"));
    item.spanX = 2;
    item.spanY = 2;
    item.minSpanX = 2;
    item.minSpanY = 2;
    item.cellX = 0;
    item.cellY = 1;
    item.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
    return item;
}
Also used : LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet)

Example 20 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by AOSPA.

the class PopupDataProvider method onNotificationRemoved.

@Override
public void onNotificationRemoved(PackageUserKey removedPackageUserKey, NotificationKeyData notificationKey) {
    DotInfo oldDotInfo = mPackageUserToDotInfos.get(removedPackageUserKey);
    if (oldDotInfo != null && oldDotInfo.removeNotificationKey(notificationKey)) {
        if (oldDotInfo.getNotificationKeys().size() == 0) {
            mPackageUserToDotInfos.remove(removedPackageUserKey);
        }
        updateNotificationDots(removedPackageUserKey::equals);
        trimNotifications(mPackageUserToDotInfos);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Aggregations

PackageUserKey (com.android.launcher3.util.PackageUserKey)94 ArrayList (java.util.ArrayList)53 Context (android.content.Context)42 ComponentName (android.content.ComponentName)39 UserHandle (android.os.UserHandle)35 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)31 HashMap (java.util.HashMap)31 HashSet (java.util.HashSet)31 List (java.util.List)29 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)26 IconCache (com.android.launcher3.icons.IconCache)24 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)24 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)24 DotInfo (com.android.launcher3.dot.DotInfo)22 Log (android.util.Log)21 FeatureFlags (com.android.launcher3.config.FeatureFlags)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 IntSet (com.android.launcher3.util.IntSet)21 Predicate (java.util.function.Predicate)21 Test (org.junit.Test)21