Search in sources :

Example 51 with ItemInfoWithIcon

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

the class PendingAppWidgetHostView method reapplyItemInfo.

@Override
public void reapplyItemInfo(ItemInfoWithIcon info) {
    DrawableFactory drawableFactory = DrawableFactory.INSTANCE.get(getContext());
    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 = drawableFactory.newIcon(getContext(), info);
                disabledIcon.setIsDisabled(true);
                mCenterDrawable = disabledIcon;
            } else {
                widgetCategoryIcon.setColorFilter(FastBitmapDrawable.getDisabledFColorFilter(/* disabledAlpha= */
                1f));
                mCenterDrawable = widgetCategoryIcon;
            }
            mSettingIconDrawable = null;
        } else if (isReadyForClickSetup()) {
            mCenterDrawable = widgetCategoryIcon == null ? drawableFactory.newIcon(getContext(), info) : widgetCategoryIcon;
            mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
            updateSettingColor(info.bitmap.color);
        } else {
            mCenterDrawable = widgetCategoryIcon == null ? drawableFactory.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) DrawableFactory(com.android.launcher3.graphics.DrawableFactory)

Example 52 with ItemInfoWithIcon

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

the class DrawableFactory method newIcon.

/**
 * Returns a FastBitmapDrawable with the icon.
 */
public FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
    FastBitmapDrawable drawable = info.usingLowResIcon() ? new PlaceHolderIconDrawable(info.bitmap, context) : new FastBitmapDrawable(info.bitmap);
    drawable.setIsDisabled(info.isDisabled());
    return drawable;
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) PlaceHolderIconDrawable(com.android.launcher3.icons.PlaceHolderIconDrawable)

Example 53 with ItemInfoWithIcon

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

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) Intent(android.content.Intent) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 54 with ItemInfoWithIcon

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

the class PackageManagerHelper method startDetailsActivityForInfo.

/**
 * Starts the details activity for {@code info}
 */
public void startDetailsActivityForInfo(ItemInfo info, Rect sourceBounds, Bundle opts) {
    if (info instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) info).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) info;
        mContext.startActivity(new PackageManagerHelper(mContext).getMarketIntent(appInfo.getTargetComponent().getPackageName()));
        return;
    }
    ComponentName componentName = null;
    if (info instanceof AppInfo) {
        componentName = ((AppInfo) info).componentName;
    } else if (info instanceof WorkspaceItemInfo) {
        componentName = info.getTargetComponent();
    } else if (info instanceof PendingAddItemInfo) {
        componentName = ((PendingAddItemInfo) info).componentName;
    } else if (info instanceof LauncherAppWidgetInfo) {
        componentName = ((LauncherAppWidgetInfo) info).providerName;
    }
    if (componentName != null) {
        try {
            mLauncherApps.startAppDetailsActivity(componentName, info.user, sourceBounds, opts);
        } catch (SecurityException | ActivityNotFoundException e) {
            Toast.makeText(mContext, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
            Log.e(TAG, "Unable to launch settings", e);
        }
    }
}
Also used : PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) ComponentName(android.content.ComponentName) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 55 with ItemInfoWithIcon

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

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)

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