Search in sources :

Example 21 with ItemInfoWithIcon

use of com.android.launcher3.model.data.ItemInfoWithIcon in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionRowView method fillInLogContainerData.

@Override
public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, ArrayList<LauncherLogProto.Target> parents) {
    for (int i = 0; i < mPredictedApps.size(); i++) {
        ItemInfoWithIcon appInfo = mPredictedApps.get(i);
        if (appInfo == childInfo) {
            child.predictedRank = i;
            break;
        }
    }
    parents.add(newContainerTarget(LauncherLogProto.ContainerType.PREDICTION));
    // include where the prediction is coming this used to be Launcher#modifyUserEvent
    LauncherLogProto.Target parent = newTarget(LauncherLogProto.Target.Type.CONTAINER);
    LauncherState state = mLauncher.getStateManager().getState();
    if (state == LauncherState.ALL_APPS) {
        parent.containerType = LauncherLogProto.ContainerType.ALLAPPS;
    } else if (state == OVERVIEW) {
        parent.containerType = LauncherLogProto.ContainerType.TASKSWITCHER;
    }
    parents.add(parent);
}
Also used : LauncherState(com.android.launcher3.LauncherState) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 22 with ItemInfoWithIcon

use of com.android.launcher3.model.data.ItemInfoWithIcon in project android_packages_apps_Trebuchet by LineageOS.

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.bitmap.color);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 23 with ItemInfoWithIcon

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

the class CustomBottomSheet method populateAndShow.

@Override
public void populateAndShow(ItemInfo itemInfo) {
    super.populateAndShow(itemInfo);
    mItemInfo = itemInfo;
    mInfoProvider = CustomInfoProvider.Companion.forItem(getContext(), mItemInfo);
    TextView title = findViewById(R.id.title);
    title.setText(itemInfo.title);
    ((PrefsFragment) mFragmentManager.findFragmentById(R.id.sheet_prefs)).loadForApp(itemInfo, this::setForceOpen, this::unsetForceOpen, this::reopen);
    boolean allowTitleEdit = true;
    if (itemInfo instanceof ItemInfoWithIcon || mInfoProvider.supportsIcon()) {
        ImageView icon = findViewById(R.id.icon);
        if (itemInfo instanceof WorkspaceItemInfo && ((WorkspaceItemInfo) itemInfo).customIcon != null) {
            icon.setImageBitmap(((WorkspaceItemInfo) itemInfo).customIcon);
        } else if (itemInfo instanceof ItemInfoWithIcon) {
            icon.setImageBitmap(((ItemInfoWithIcon) itemInfo).iconBitmap);
        } else if (itemInfo instanceof FolderInfo) {
            FolderInfo folderInfo = (FolderInfo) itemInfo;
            icon.setImageDrawable(folderInfo.getIcon(mLauncher));
            // Drawer folder
            if (folderInfo.container == ItemInfo.NO_ID) {
                // TODO: Allow editing title for drawer folder & sync with group backend
                allowTitleEdit = false;
            }
        }
        if (mInfoProvider != null) {
            OmegaLauncher launcher = OmegaLauncher.getLauncher(getContext());
            icon.setOnClickListener(v -> {
                ItemInfo editItem;
                if (mItemInfo instanceof FolderInfo && ((FolderInfo) mItemInfo).isCoverMode()) {
                    editItem = ((FolderInfo) mItemInfo).getCoverInfo();
                } else {
                    editItem = mItemInfo;
                }
                CustomInfoProvider editProvider = CustomInfoProvider.Companion.forItem(getContext(), editItem);
                if (editProvider != null) {
                    launcher.startEditIcon(editItem, editProvider);
                }
            });
        }
    }
    if (mInfoProvider != null && allowTitleEdit) {
        mPreviousTitle = mInfoProvider.getCustomTitle(mItemInfo);
        if (mPreviousTitle == null)
            mPreviousTitle = "";
        mEditTitle = findViewById(R.id.edit_title);
        mEditTitle.setHint(mInfoProvider.getDefaultTitle(mItemInfo));
        mEditTitle.setText(mPreviousTitle);
        mEditTitle.setVisibility(VISIBLE);
        title.setVisibility(View.GONE);
    }
}
Also used : OmegaLauncher(com.saggitt.omega.OmegaLauncher) CustomInfoProvider(com.saggitt.omega.override.CustomInfoProvider) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon) FolderInfo(com.android.launcher3.FolderInfo) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Example 24 with ItemInfoWithIcon

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

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(Launcher launcher, ItemInfo info, Object obj) {
    LauncherAppState appState = LauncherAppState.getInstance(launcher);
    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;
        LauncherIcons li = LauncherIcons.obtain(appState.getContext());
        Bitmap badge = li.getShortcutInfoBadge(si, appState.getIconCache()).iconBitmap;
        li.recycle();
        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 launcher.getPackageManager().getUserBadgedIcon(new FixedSizeEmptyDrawable(iconSize), info.user);
    }
}
Also used : Bitmap(android.graphics.Bitmap) ShortcutInfo(android.content.pm.ShortcutInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) LauncherIcons(com.android.launcher3.icons.LauncherIcons) InsetDrawable(android.graphics.drawable.InsetDrawable) Paint(android.graphics.Paint) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 25 with ItemInfoWithIcon

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

the class DrawableFactory method newIcon.

public FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
    FastBitmapDrawable drawable = info.usingLowResIcon() ? new PlaceHolderIconDrawable(info, getShapePath(), context) : new FastBitmapDrawable(info);
    drawable.setIsDisabled(info.isDisabled());
    return drawable;
}
Also used : FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable)

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