Search in sources :

Example 56 with ItemInfoWithIcon

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

the class Utilities method getBadge.

/**
 * For apps icons and shortcut icons that have badges, this method creates a drawable that can
 * later on be rendered on top of the layers for the badges. For app icons, work profile badges
 * can only be applied. For deep shortcuts, when dragged from the pop up container, there's no
 * badge. When dragged from workspace or folder, it may contain app AND/OR work profile badge
 */
@TargetApi(Build.VERSION_CODES.O)
public static Drawable getBadge(Context context, ItemInfo info, Object obj) {
    LauncherAppState appState = LauncherAppState.getInstance(context);
    int iconSize = appState.getInvariantDeviceProfile().iconBitmapSize;
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        boolean iconBadged = (info instanceof ItemInfoWithIcon) && (((ItemInfoWithIcon) info).runtimeStatusFlags & FLAG_ICON_BADGED) > 0;
        if ((info.id == ItemInfo.NO_ID && !iconBadged) || !(obj instanceof ShortcutInfo)) {
            // The item is not yet added on home screen.
            return new FixedSizeEmptyDrawable(iconSize);
        }
        ShortcutInfo si = (ShortcutInfo) obj;
        Bitmap badge = LauncherAppState.getInstance(appState.getContext()).getIconCache().getShortcutInfoBadge(si).icon;
        float badgeSize = LauncherIcons.getBadgeSizeForIconSize(iconSize);
        float insetFraction = (iconSize - badgeSize) / iconSize;
        return new InsetDrawable(new FastBitmapDrawable(badge), insetFraction, insetFraction, 0, 0);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        return ((FolderAdaptiveIcon) obj).getBadge();
    } else {
        return context.getPackageManager().getUserBadgedIcon(new FixedSizeEmptyDrawable(iconSize), info.user);
    }
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Bitmap(android.graphics.Bitmap) ShortcutInfo(android.content.pm.ShortcutInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) InsetDrawable(android.graphics.drawable.InsetDrawable) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) Paint(android.graphics.Paint) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 57 with ItemInfoWithIcon

use of com.android.launcher3.model.data.ItemInfoWithIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class SecondaryDisplayLauncher method onIconClicked.

private void onIconClicked(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null)
        return;
    Object tag = v.getTag();
    if (tag instanceof ItemInfo) {
        ItemInfo item = (ItemInfo) tag;
        Intent intent;
        if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
            ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
            intent = appInfo.getMarketIntent(this);
        } else {
            intent = item.getIntent();
        }
        if (intent == null) {
            throw new IllegalArgumentException("Input must have a valid intent");
        }
        startActivitySafely(v, intent, item);
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Intent(android.content.Intent) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 58 with ItemInfoWithIcon

use of com.android.launcher3.model.data.ItemInfoWithIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListHeader method verifyHighRes.

/**
 * Verifies that the current icon is high-res otherwise posts a request to load the icon.
 */
public void verifyHighRes() {
    if (mIconLoadRequest != null) {
        mIconLoadRequest.cancel();
        mIconLoadRequest = null;
    }
    if (getTag() instanceof ItemInfoWithIcon) {
        ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
        if (info.usingLowResIcon()) {
            mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache().updateIconInBackground(this, info);
        }
    }
}
Also used : ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 59 with ItemInfoWithIcon

use of com.android.launcher3.model.data.ItemInfoWithIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class BubbleTextView method verifyHighRes.

/**
 * Verifies that the current icon is high-res otherwise posts a request to load the icon.
 */
public void verifyHighRes() {
    if (mIconLoadRequest != null) {
        mIconLoadRequest.cancel();
        mIconLoadRequest = null;
    }
    if (getTag() instanceof ItemInfoWithIcon) {
        ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
        if (info.usingLowResIcon()) {
            mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache().updateIconInBackground(BubbleTextView.this, info);
        }
    }
}
Also used : ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 60 with ItemInfoWithIcon

use of com.android.launcher3.model.data.ItemInfoWithIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class FloatingIconView method fetchIcon.

/**
 * Loads the icon drawable on a worker thread to reduce latency between swapping views.
 */
@UiThread
public static IconLoadResult fetchIcon(Launcher l, View v, ItemInfo info, boolean isOpening) {
    RectF position = new RectF();
    getLocationBoundsForView(l, v, isOpening, position);
    final FastBitmapDrawable btvIcon;
    if (v instanceof BubbleTextView) {
        BubbleTextView btv = (BubbleTextView) v;
        if (info instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) info).runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
            btvIcon = btv.makePreloadIcon();
        } else {
            btvIcon = btv.getIcon();
        }
    } else {
        btvIcon = null;
    }
    IconLoadResult result = new IconLoadResult(info, btvIcon == null ? false : btvIcon.isThemed());
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> getIconResult(l, v, info, position, btvIcon, result));
    sIconLoadResult = result;
    return result;
}
Also used : RectF(android.graphics.RectF) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) BubbleTextView(com.android.launcher3.BubbleTextView) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) UiThread(androidx.annotation.UiThread)

Aggregations

ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)67 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)22 Intent (android.content.Intent)17 Paint (android.graphics.Paint)17 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)16 ComponentName (android.content.ComponentName)13 ShortcutInfo (android.content.pm.ShortcutInfo)13 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)12 Drawable (android.graphics.drawable.Drawable)11 Nullable (androidx.annotation.Nullable)11 UiThread (androidx.annotation.UiThread)10 AppInfo (com.android.launcher3.model.data.AppInfo)10 Bitmap (android.graphics.Bitmap)8 TextPaint (android.text.TextPaint)8 TargetApi (android.annotation.TargetApi)7 Point (android.graphics.Point)7 InsetDrawable (android.graphics.drawable.InsetDrawable)7 DotInfo (com.android.launcher3.dot.DotInfo)7 AppWidgetHostView (android.appwidget.AppWidgetHostView)6 Context (android.content.Context)6