Search in sources :

Example 66 with ItemInfoWithIcon

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

the class PredictionRowView method fillInLogContainerData.

@Override
public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Target target, LauncherLogProto.Target targetParent) {
    for (int i = 0; i < mPredictedApps.size(); i++) {
        ItemInfoWithIcon appInfo = mPredictedApps.get(i);
        if (appInfo == info) {
            targetParent.containerType = LauncherLogProto.ContainerType.PREDICTION;
            target.predictedRank = i;
            break;
        }
    }
}
Also used : ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon)

Example 67 with ItemInfoWithIcon

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

the class PendingAppWidgetHostView method reapplyItemInfo.

@Override
public void reapplyItemInfo(ItemInfoWithIcon info) {
    if (mCenterDrawable != null) {
        mCenterDrawable.setCallback(null);
        mCenterDrawable = null;
    }
    if (info.iconBitmap != null) {
        // The view displays three modes,
        // 1) App icon in the center
        // 2) Preload icon in the center
        // 3) Setup icon in the center and app icon in the top right corner.
        DrawableFactory drawableFactory = DrawableFactory.INSTANCE.get(getContext());
        if (mDisabledForSafeMode) {
            FastBitmapDrawable disabledIcon = drawableFactory.newIcon(getContext(), info);
            disabledIcon.setIsDisabled(true);
            mCenterDrawable = disabledIcon;
            mSettingIconDrawable = null;
        } else if (isReadyForClickSetup()) {
            mCenterDrawable = drawableFactory.newIcon(getContext(), info);
            mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
            updateSettingColor(info.iconColor);
        } else {
            mCenterDrawable = DrawableFactory.INSTANCE.get(getContext()).newPendingIcon(getContext(), info);
            mSettingIconDrawable = null;
            applyState();
        }
        mCenterDrawable.setCallback(this);
        mDrawableSizeChanged = true;
    }
    invalidate();
}
Also used : FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) DrawableFactory(com.android.launcher3.graphics.DrawableFactory)

Example 68 with ItemInfoWithIcon

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

the class DrawableFactory method newIcon.

/**
 * Returns a FastBitmapDrawable with the icon.
 */
public FastBitmapDrawable newIcon(ItemInfoWithIcon info) {
    FastBitmapDrawable drawable = new FastBitmapDrawable(info);
    drawable.setIsDisabled(info.isDisabled());
    return drawable;
}
Also used : FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable)

Example 69 with ItemInfoWithIcon

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

the class PendingAppWidgetHostView method reapplyItemInfo.

@Override
public void reapplyItemInfo(ItemInfoWithIcon info) {
    if (mCenterDrawable != null) {
        mCenterDrawable.setCallback(null);
        mCenterDrawable = null;
    }
    if (info.bitmap.icon != null) {
        // 3) Setup icon in the center and app icon in the top right corner.
        if (mDisabledForSafeMode) {
            FastBitmapDrawable disabledIcon = newIcon(getContext(), info);
            disabledIcon.setIsDisabled(true);
            mCenterDrawable = disabledIcon;
            mSettingIconDrawable = null;
        } else if (isReadyForClickSetup()) {
            mCenterDrawable = newIcon(getContext(), info);
            mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
            updateSettingColor(info.bitmap.color);
        } else {
            mCenterDrawable = newPendingIcon(getContext(), info);
            mSettingIconDrawable = null;
            applyState();
        }
        mCenterDrawable.setCallback(this);
        mDrawableSizeChanged = true;
    }
    invalidate();
}
Also used : FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable)

Example 70 with ItemInfoWithIcon

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

the class PredictionRowView method processPredictedAppComponents.

private List<ItemInfoWithIcon> processPredictedAppComponents(List<ComponentKeyMapper> components) {
    if (getAppsStore().getApps().length == 0) {
        // Apps have not been bound yet.
        return Collections.emptyList();
    }
    List<ItemInfoWithIcon> predictedApps = new ArrayList<>();
    for (ComponentKeyMapper mapper : components) {
        ItemInfoWithIcon info = mapper.getApp(getAppsStore());
        if (info != null) {
            ItemInfoWithIcon predictedApp = info.clone();
            predictedApp.container = LauncherSettings.Favorites.CONTAINER_PREDICTION;
            predictedApps.add(predictedApp);
        } else {
            if (FeatureFlags.IS_STUDIO_BUILD) {
                Log.e(TAG, "Predicted app not found: " + mapper);
            }
        }
        // Stop at the number of predicted apps
        if (predictedApps.size() == mNumPredictedAppsPerRow) {
            break;
        }
    }
    return predictedApps;
}
Also used : ArrayList(java.util.ArrayList) 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