Search in sources :

Example 21 with ShortcutConfigActivityInfo

use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Utilities method loadFullDrawableWithoutTheme.

private static Drawable loadFullDrawableWithoutTheme(Context context, ItemInfo info, int width, int height, Object[] outObj) {
    ActivityContext activity = ActivityContext.lookupContext(context);
    LauncherAppState appState = LauncherAppState.getInstance(context);
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        LauncherActivityInfo activityInfo = context.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
        outObj[0] = activityInfo;
        return activityInfo == null ? null : LauncherAppState.getInstance(context).getIconProvider().getIcon(activityInfo, activity.getDeviceProfile().inv.fillResIconDpi);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        if (info instanceof PendingAddShortcutInfo) {
            ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
            outObj[0] = activityInfo;
            return activityInfo.getFullResIcon(appState.getIconCache());
        }
        List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(context).query(ShortcutRequest.ALL);
        if (si.isEmpty()) {
            return null;
        } else {
            outObj[0] = si.get(0);
            return ShortcutCachingLogic.getIcon(context, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
        }
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(activity, info.id, new Point(width, height));
        if (icon == null) {
            return null;
        }
        outObj[0] = icon;
        return icon;
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SEARCH_ACTION && info instanceof SearchActionItemInfo) {
        return new AdaptiveIconDrawable(new FastBitmapDrawable(((SearchActionItemInfo) info).bitmap), null);
    } else {
        return null;
    }
}
Also used : ActivityContext(com.android.launcher3.views.ActivityContext) FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) Point(android.graphics.Point) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable)

Example 22 with ShortcutConfigActivityInfo

use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project android_packages_apps_Launcher3 by AOSPA.

the class Utilities method loadFullDrawableWithoutTheme.

private static Drawable loadFullDrawableWithoutTheme(Context context, ItemInfo info, int width, int height, Object[] outObj) {
    ActivityContext activity = ActivityContext.lookupContext(context);
    LauncherAppState appState = LauncherAppState.getInstance(context);
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        LauncherActivityInfo activityInfo = context.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
        outObj[0] = activityInfo;
        return activityInfo == null ? null : LauncherAppState.getInstance(context).getIconProvider().getIcon(activityInfo, activity.getDeviceProfile().inv.fillResIconDpi);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        if (info instanceof PendingAddShortcutInfo) {
            ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
            outObj[0] = activityInfo;
            return activityInfo.getFullResIcon(appState.getIconCache());
        }
        List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(context).query(ShortcutRequest.ALL);
        if (si.isEmpty()) {
            return null;
        } else {
            outObj[0] = si.get(0);
            return ShortcutCachingLogic.getIcon(context, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
        }
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(activity, info.id, new Point(width, height));
        if (icon == null) {
            return null;
        }
        outObj[0] = icon;
        return icon;
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SEARCH_ACTION && info instanceof SearchActionItemInfo) {
        return new AdaptiveIconDrawable(new FastBitmapDrawable(((SearchActionItemInfo) info).bitmap), null);
    } else {
        return null;
    }
}
Also used : ActivityContext(com.android.launcher3.views.ActivityContext) FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) Point(android.graphics.Point) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable)

Example 23 with ShortcutConfigActivityInfo

use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project android_packages_apps_Launcher3 by AOSPA.

the class DatabaseWidgetPreviewLoader method generateShortcutPreview.

private Bitmap generateShortcutPreview(ShortcutConfigActivityInfo info, int maxWidth, int maxHeight) {
    int iconSize = ActivityContext.lookupContext(mContext).getDeviceProfile().allAppsIconSizePx;
    int padding = mContext.getResources().getDimensionPixelSize(R.dimen.widget_preview_shortcut_padding);
    int size = iconSize + 2 * padding;
    if (maxHeight < size || maxWidth < size) {
        throw new RuntimeException("Max size is too small for preview");
    }
    return BitmapRenderer.createHardwareBitmap(size, size, c -> {
        drawBoxWithShadow(c, size, size);
        LauncherIcons li = LauncherIcons.obtain(mContext);
        Drawable icon = li.createBadgedIconBitmap(mutateOnMainThread(info.getFullResIcon(LauncherAppState.getInstance(mContext).getIconCache())), Process.myUserHandle(), 0).newIcon(mContext);
        li.recycle();
        icon.setBounds(padding, padding, padding + iconSize, padding + iconSize);
        icon.draw(c);
    });
}
Also used : LauncherIcons(com.android.launcher3.icons.LauncherIcons) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint)

Aggregations

ShortcutConfigActivityInfo (com.android.launcher3.pm.ShortcutConfigActivityInfo)12 ArrayList (java.util.ArrayList)10 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)8 PackageManager (android.content.pm.PackageManager)8 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)8 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)7 Context (android.content.Context)7 Paint (android.graphics.Paint)7 Point (android.graphics.Point)7 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)7 FolderAdaptiveIcon (com.android.launcher3.dragndrop.FolderAdaptiveIcon)7 LauncherIcons (com.android.launcher3.icons.LauncherIcons)7 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)7 List (java.util.List)7 LauncherApps (android.content.pm.LauncherApps)6 ComponentWithLabelAndIcon (com.android.launcher3.icons.ComponentWithLabelAndIcon)6 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)6 Drawable (android.graphics.drawable.Drawable)5 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)5 AdaptiveIconDrawable (android.graphics.drawable.AdaptiveIconDrawable)4