Search in sources :

Example 21 with PackageItemInfo

use of com.android.launcher3.model.PackageItemInfo in project Neo-Launcher by NeoApplications.

the class WidgetsListAdapterTest method generateSampleMap.

/**
 * Helper method to generate the sample widget model map that can be used for the tests
 * @param num the number of WidgetItem the map should contain
 * @return
 */
private ArrayList<WidgetListRowEntry> generateSampleMap(int num) {
    ArrayList<WidgetListRowEntry> result = new ArrayList<>();
    if (num <= 0)
        return result;
    MultiHashMap<PackageItemInfo, WidgetItem> newMap = new MultiHashMap();
    AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(mContext);
    for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(null)) {
        WidgetItem wi = new WidgetItem(LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo), mTestProfile, mIconCache);
        PackageItemInfo pInfo = new PackageItemInfo(wi.componentName.getPackageName());
        pInfo.title = pInfo.packageName;
        pInfo.user = wi.user;
        pInfo.iconBitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8);
        newMap.addToList(pInfo, wi);
        if (newMap.size() == num) {
            break;
        }
    }
    for (Map.Entry<PackageItemInfo, ArrayList<WidgetItem>> entry : newMap.entrySet()) {
        result.add(new WidgetListRowEntry(entry.getKey(), entry.getValue()));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) PackageItemInfo(com.android.launcher3.model.PackageItemInfo) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.LauncherAppWidgetProviderInfo) WidgetItem(com.android.launcher3.model.WidgetItem) AppWidgetManagerCompat(com.android.launcher3.compat.AppWidgetManagerCompat) MultiHashMap(com.android.launcher3.util.MultiHashMap) Map(java.util.Map) MultiHashMap(com.android.launcher3.util.MultiHashMap)

Example 22 with PackageItemInfo

use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.

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 23 with PackageItemInfo

use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.

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 24 with PackageItemInfo

use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.

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 25 with PackageItemInfo

use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsListHeaderViewHolderBinderTest method generateSampleAppHeader.

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

Aggregations

PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)94 WidgetsListContentEntry (com.android.launcher3.widget.model.WidgetsListContentEntry)39 WidgetsListHeaderEntry (com.android.launcher3.widget.model.WidgetsListHeaderEntry)39 WidgetItem (com.android.launcher3.model.WidgetItem)28 ArrayList (java.util.ArrayList)28 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)24 Map (java.util.Map)22 HashMap (java.util.HashMap)20 ComponentName (android.content.ComponentName)19 List (java.util.List)19 IconCache (com.android.launcher3.icons.IconCache)17 Context (android.content.Context)16 AlphabeticIndexCompat (com.android.launcher3.compat.AlphabeticIndexCompat)16 PackageUserKey (com.android.launcher3.util.PackageUserKey)16 Log (android.util.Log)14 Nullable (androidx.annotation.Nullable)14 ArrayMap (androidx.collection.ArrayMap)14 ShortcutConfigActivityInfo.queryList (com.android.launcher3.pm.ShortcutConfigActivityInfo.queryList)14 Arrays (java.util.Arrays)14 Predicate (java.util.function.Predicate)14