Search in sources :

Example 6 with ItemInfoWithIcon

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

the class BubbleTextView method applyProgressLevel.

/**
 * Applies the given progress level to the this icon's progress bar.
 */
@Nullable
public PreloadIconDrawable applyProgressLevel() {
    if (!(getTag() instanceof ItemInfoWithIcon)) {
        return null;
    }
    ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
    int progressLevel = info.getProgressLevel();
    if (progressLevel >= 100) {
        setContentDescription(info.contentDescription != null ? info.contentDescription : "");
    } else if (progressLevel > 0) {
        setDownloadStateContentDescription(info, progressLevel);
    } else {
        setContentDescription(getContext().getString(R.string.app_waiting_download_title, info.title));
    }
    if (mIcon != null) {
        PreloadIconDrawable preloadIconDrawable;
        if (mIcon instanceof PreloadIconDrawable) {
            preloadIconDrawable = (PreloadIconDrawable) mIcon;
            preloadIconDrawable.setLevel(progressLevel);
            preloadIconDrawable.setIsDisabled(!info.isAppStartable());
        } else {
            preloadIconDrawable = makePreloadIcon();
            setIcon(preloadIconDrawable);
        }
        return preloadIconDrawable;
    }
    return null;
}
Also used : ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) Paint(android.graphics.Paint) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Nullable(androidx.annotation.Nullable)

Example 7 with ItemInfoWithIcon

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

the class BubbleTextView method applyIconAndLabel.

@UiThread
protected void applyIconAndLabel(ItemInfoWithIcon info) {
    boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER;
    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 8 with ItemInfoWithIcon

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

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    TrustDatabaseHelper db = TrustDatabaseHelper.getInstance(launcher);
    ComponentName cn = item.getTargetComponent();
    boolean isProtected = cn != null && db.isPackageProtected(cn.getPackageName());
    if (isProtected) {
        launcher.startActivitySafelyAuth(v, intent, item);
    } else {
        launcher.startActivitySafely(v, intent, item);
    }
}
Also used : TrustDatabaseHelper(com.android.launcher3.lineage.trust.db.TrustDatabaseHelper) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ComponentName(android.content.ComponentName) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 9 with ItemInfoWithIcon

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

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
        if ((si.options & WorkspaceItemInfo.FLAG_START_FOR_RESULT) != 0) {
            launcher.startActivityForResult(item.getIntent(), 0);
            InstanceId instanceId = new InstanceIdSequence().newInstanceId();
            launcher.logAppLaunch(launcher.getStatsLogManager(), item, instanceId);
            return;
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    launcher.startActivitySafely(v, intent, item);
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 10 with ItemInfoWithIcon

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

the class PopupContainerWithArrow method updateNotificationHeader.

private void updateNotificationHeader() {
    ItemInfoWithIcon itemInfo = (ItemInfoWithIcon) mOriginalIcon.getTag();
    DotInfo dotInfo = mActivityContext.getDotInfoForItem(itemInfo);
    if (mNotificationContainer != null && dotInfo != null) {
        mNotificationContainer.updateHeader(dotInfo.getNotificationCount());
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) 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