Search in sources :

Example 36 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo 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 37 with PackageItemInfo

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

the class IconCache method getShortcutInfoBadge.

/**
 * Returns the badging info for the shortcut
 */
public BitmapInfo getShortcutInfoBadge(ShortcutInfo shortcutInfo) {
    ComponentName cn = shortcutInfo.getActivity();
    if (cn != null) {
        // Get the app info for the source activity.
        AppInfo appInfo = new AppInfo();
        appInfo.user = shortcutInfo.getUserHandle();
        appInfo.componentName = cn;
        appInfo.intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(cn);
        getTitleAndIcon(appInfo, false);
        return appInfo.bitmap;
    } else {
        PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage(), shortcutInfo.getUserHandle());
        getTitleAndIconForApp(pkgInfo, false);
        return pkgInfo.bitmap;
    }
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) ComponentName(android.content.ComponentName) Intent(android.content.Intent) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 38 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.

the class SearchActionItemInfo method createWorkspaceItem.

/**
 * Creates a {@link WorkspaceItemInfo} coorsponding to search action to be stored in launcher db
 */
public WorkspaceItemInfo createWorkspaceItem(LauncherModel model) {
    WorkspaceItemInfo info = new WorkspaceItemInfo();
    info.title = title;
    info.bitmap = bitmap;
    info.intent = mIntent;
    if (hasFlags(FLAG_SHOULD_START_FOR_RESULT)) {
        info.options |= WorkspaceItemInfo.FLAG_START_FOR_RESULT;
    }
    model.enqueueModelUpdateTask(new BaseModelUpdateTask() {

        @Override
        public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
            model.updateAndBindWorkspaceItem(() -> {
                PackageItemInfo pkgInfo = new PackageItemInfo(getIntentPackageName(), user);
                app.getIconCache().getTitleAndIconForApp(pkgInfo, false);
                try (LauncherIcons li = LauncherIcons.obtain(app.getContext())) {
                    info.bitmap = li.badgeBitmap(info.bitmap.icon, pkgInfo.bitmap);
                }
                return info;
            });
        }
    });
    return info;
}
Also used : BaseModelUpdateTask(com.android.launcher3.model.BaseModelUpdateTask) LauncherAppState(com.android.launcher3.LauncherAppState) BgDataModel(com.android.launcher3.model.BgDataModel) LauncherIcons(com.android.launcher3.icons.LauncherIcons) AllAppsList(com.android.launcher3.model.AllAppsList)

Example 39 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.

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

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.

the class WidgetsListHeader method setIcon.

private void setIcon(PackageItemInfo info) {
    Drawable icon;
    if (info.widgetCategory == NO_CATEGORY) {
        icon = info.newIcon(getContext());
    } else {
        WidgetSection widgetSection = WidgetSections.getWidgetSections(getContext()).get(info.widgetCategory);
        icon = getContext().getDrawable(widgetSection.mSectionDrawable);
    }
    applyDrawables(icon);
    mIconDrawable = icon;
    if (mIconDrawable != null) {
        mIconDrawable.setVisible(/* visible= */
        getWindowVisibility() == VISIBLE && isShown(), /* restart= */
        false);
    }
}
Also used : WidgetSection(com.android.launcher3.widget.WidgetSections.WidgetSection) Drawable(android.graphics.drawable.Drawable) PlaceHolderIconDrawable(com.android.launcher3.icons.PlaceHolderIconDrawable)

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