Search in sources :

Example 36 with ItemInfoWithIcon

use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

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 37 with ItemInfoWithIcon

use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

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 38 with ItemInfoWithIcon

use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

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());
    result.btvDrawable = btvIcon;
    final long fetchIconId = sFetchIconId++;
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
        if (fetchIconId < sRecycledFetchIconId) {
            return;
        }
        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)

Example 39 with ItemInfoWithIcon

use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

the class BubbleTextView method applyIconAndLabel.

@UiThread
protected void applyIconAndLabel(ItemInfoWithIcon info) {
    boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER || mDisplay == DISPLAY_TASKBAR;
    FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme);
    mDotParams.color = IconPalette.getMutedColor(iconDrawable.getIconColor(), 0.54f);
    setIcon(iconDrawable);
    applyLabel(info);
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) UiThread(androidx.annotation.UiThread)

Example 40 with ItemInfoWithIcon

use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_Launcher3 by ProtonAOSP.

the class IconCache method getTitlesAndIconsInBulk.

/**
 * Load and fill icons requested in iconRequestInfos using a single bulk sql query.
 */
public synchronized <T extends ItemInfoWithIcon> void getTitlesAndIconsInBulk(List<IconRequestInfo<T>> iconRequestInfos) {
    Map<Pair<UserHandle, Boolean>, List<IconRequestInfo<T>>> iconLoadSubsectionsMap = iconRequestInfos.stream().collect(groupingBy(iconRequest -> Pair.create(iconRequest.itemInfo.user, iconRequest.useLowResIcon)));
    Trace.beginSection("loadIconsInBulk");
    iconLoadSubsectionsMap.forEach((sectionKey, filteredList) -> {
        Map<ComponentName, List<IconRequestInfo<T>>> duplicateIconRequestsMap = filteredList.stream().collect(groupingBy(iconRequest -> iconRequest.itemInfo.getTargetComponent()));
        Trace.beginSection("loadIconSubsectionInBulk");
        try (Cursor c = createBulkQueryCursor(filteredList, /* user = */
        sectionKey.first, /* useLowResIcons = */
        sectionKey.second)) {
            int componentNameColumnIndex = c.getColumnIndexOrThrow(IconDB.COLUMN_COMPONENT);
            while (c.moveToNext()) {
                ComponentName cn = ComponentName.unflattenFromString(c.getString(componentNameColumnIndex));
                List<IconRequestInfo<T>> duplicateIconRequests = duplicateIconRequestsMap.get(cn);
                if (cn != null) {
                    CacheEntry entry = cacheLocked(cn, /* user = */
                    sectionKey.first, () -> duplicateIconRequests.get(0).launcherActivityInfo, mLauncherActivityInfoCachingLogic, c, /* usePackageIcon= */
                    false, /* useLowResIcons = */
                    sectionKey.second);
                    for (IconRequestInfo<T> iconRequest : duplicateIconRequests) {
                        applyCacheEntry(entry, iconRequest.itemInfo);
                    }
                }
            }
        } catch (SQLiteException e) {
            Log.d(TAG, "Error reading icon cache", e);
        } finally {
            Trace.endSection();
        }
    });
    Trace.endSection();
}
Also used : Trace(android.os.Trace) IconRequestInfo(com.android.launcher3.model.data.IconRequestInfo) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) Preconditions(com.android.launcher3.util.Preconditions) Drawable(android.graphics.drawable.Drawable) Process(android.os.Process) LauncherFiles(com.android.launcher3.LauncherFiles) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) SQLiteException(android.database.sqlite.SQLiteException) Map(java.util.Map) MAIN_EXECUTOR(com.android.launcher3.util.Executors.MAIN_EXECUTOR) WidgetSection(com.android.launcher3.widget.WidgetSections.WidgetSection) Log(android.util.Log) Utilities(com.android.launcher3.Utilities) Predicate(java.util.function.Predicate) InstantAppResolver(com.android.launcher3.util.InstantAppResolver) UserCache(com.android.launcher3.pm.UserCache) LauncherApps(android.content.pm.LauncherApps) ComponentCachingLogic(com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic) Objects(java.util.Objects) PackageInstaller(android.content.pm.PackageInstaller) List(java.util.List) Stream(java.util.stream.Stream) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) WidgetSections(com.android.launcher3.widget.WidgetSections) ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Context(android.content.Context) MODEL_EXECUTOR(com.android.launcher3.util.Executors.MODEL_EXECUTOR) NO_CATEGORY(com.android.launcher3.widget.WidgetSections.NO_CATEGORY) AppInfo(com.android.launcher3.model.data.AppInfo) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Pair(android.util.Pair) Intent(android.content.Intent) PackageInfo(android.content.pm.PackageInfo) Supplier(java.util.function.Supplier) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) CachingLogic(com.android.launcher3.icons.cache.CachingLogic) Cursor(android.database.Cursor) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) PackageUserKey(com.android.launcher3.util.PackageUserKey) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) HandlerRunnable(com.android.launcher3.icons.cache.HandlerRunnable) Collections(java.util.Collections) BaseIconCache(com.android.launcher3.icons.cache.BaseIconCache) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) IconRequestInfo(com.android.launcher3.model.data.IconRequestInfo) Cursor(android.database.Cursor) SQLiteException(android.database.sqlite.SQLiteException) List(java.util.List) ComponentName(android.content.ComponentName) Pair(android.util.Pair)

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