Search in sources :

Example 26 with ItemInfoWithIcon

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

the class LauncherIcons method createShortcutIcon.

public BitmapInfo createShortcutIcon(ShortcutInfo shortcutInfo, boolean badged, @Nullable Supplier<ItemInfoWithIcon> fallbackIconProvider) {
    Drawable unbadgedDrawable = DeepShortcutManager.getInstance(mContext).getShortcutIconDrawable(shortcutInfo, mFillResIconDpi);
    IconCache cache = LauncherAppState.getInstance(mContext).getIconCache();
    final Bitmap unbadgedBitmap;
    if (unbadgedDrawable != null) {
        unbadgedBitmap = createScaledBitmapWithoutShadow(unbadgedDrawable, 0);
    } else {
        if (fallbackIconProvider != null) {
            // Fallback icons are already badged and with appropriate shadow
            ItemInfoWithIcon fullIcon = fallbackIconProvider.get();
            if (fullIcon != null && fullIcon.iconBitmap != null) {
                BitmapInfo result = new BitmapInfo();
                result.icon = fullIcon.iconBitmap;
                result.color = fullIcon.iconColor;
                return result;
            }
        }
        unbadgedBitmap = cache.getDefaultIcon(Process.myUserHandle()).icon;
    }
    BitmapInfo result = new BitmapInfo();
    if (!badged) {
        result.color = Themes.getColorAccent(mContext);
        result.icon = unbadgedBitmap;
        return result;
    }
    final Bitmap unbadgedfinal = unbadgedBitmap;
    final ItemInfoWithIcon badge = getShortcutInfoBadge(shortcutInfo, cache);
    result.color = badge.iconColor;
    result.icon = BitmapRenderer.createHardwareBitmap(mIconBitmapSize, mIconBitmapSize, (c) -> {
        getShadowGenerator().recreateIcon(unbadgedfinal, c);
        badgeWithDrawable(c, new FastBitmapDrawable(badge));
    });
    return result;
}
Also used : Context(android.content.Context) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) LauncherAppState(com.android.launcher3.LauncherAppState) PackageItemInfo(com.android.launcher3.model.PackageItemInfo) Intent(android.content.Intent) IconShape(com.android.launcher3.graphics.IconShape) Drawable(android.graphics.drawable.Drawable) Supplier(java.util.function.Supplier) Process(android.os.Process) ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon) AppInfo(com.android.launcher3.AppInfo) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) Nullable(androidx.annotation.Nullable) R(com.android.launcher3.R) Bitmap(android.graphics.Bitmap) DeepShortcutManager(com.android.launcher3.shortcuts.DeepShortcutManager) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) Themes(com.android.launcher3.util.Themes) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) Bitmap(android.graphics.Bitmap) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon)

Example 27 with ItemInfoWithIcon

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

the class PopupContainerWithArrow method updateNotificationHeader.

private void updateNotificationHeader() {
    ItemInfoWithIcon itemInfo = (ItemInfoWithIcon) mOriginalIcon.getTag();
    DotInfo dotInfo = mLauncher.getDotInfoForItem(itemInfo);
    if (mNotificationItemView != null && dotInfo != null) {
        mNotificationItemView.updateHeader(dotInfo.getNotificationCount(), itemInfo.iconColor);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon)

Example 28 with ItemInfoWithIcon

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

the class SecondaryDropTarget method supportsAccessibilityDrop.

@Override
public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
    if (view instanceof AppWidgetHostView) {
        if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
            setupUi(RECONFIGURE);
            return true;
        }
        return false;
    } else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
        setupUi(DISMISS_PREDICTION);
        return true;
    }
    setupUi(UNINSTALL);
    Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
    if (uninstallDisabled == null) {
        UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
        Bundle restrictions = userManager.getUserRestrictions(info.user);
        uninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false);
        mUninstallDisabledCache.put(info.user, uninstallDisabled);
    }
    // Cancel any pending alarm and set cache expiry after some time
    mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
    mCacheExpireAlarm.setOnAlarmListener(this);
    if (uninstallDisabled) {
        return false;
    }
    if (info instanceof ItemInfoWithIcon) {
        ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
        if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
            return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
        }
    }
    return getUninstallTarget(info) != null;
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) UserManager(android.os.UserManager) Bundle(android.os.Bundle) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 29 with ItemInfoWithIcon

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

the class PendingAppWidgetHostView method reapplyItemInfo.

@Override
public void reapplyItemInfo(ItemInfoWithIcon info) {
    if (mCenterDrawable != null) {
        mCenterDrawable.setCallback(null);
        mCenterDrawable = null;
    }
    if (info.bitmap.icon != null) {
        Drawable widgetCategoryIcon = getWidgetCategoryIcon();
        // 3) App icon in the center with a setup icon on the top left corner.
        if (mDisabledForSafeMode) {
            if (widgetCategoryIcon == null) {
                FastBitmapDrawable disabledIcon = info.newIcon(getContext());
                disabledIcon.setIsDisabled(true);
                mCenterDrawable = disabledIcon;
            } else {
                widgetCategoryIcon.setColorFilter(FastBitmapDrawable.getDisabledFColorFilter(/* disabledAlpha= */
                1f));
                mCenterDrawable = widgetCategoryIcon;
            }
            mSettingIconDrawable = null;
        } else if (isReadyForClickSetup()) {
            mCenterDrawable = widgetCategoryIcon == null ? info.newIcon(getContext()) : widgetCategoryIcon;
            mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
            updateSettingColor(info.bitmap.color);
        } else {
            mCenterDrawable = widgetCategoryIcon == null ? newPendingIcon(getContext(), info) : widgetCategoryIcon;
            mSettingIconDrawable = null;
            applyState();
        }
        mCenterDrawable.setCallback(this);
        mDrawableSizeChanged = true;
    }
    invalidate();
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable)

Example 30 with ItemInfoWithIcon

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

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)

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