Search in sources :

Example 1 with PreloadIconDrawable

use of com.android.launcher3.graphics.PreloadIconDrawable in project android_packages_apps_Launcher3 by crdroidandroid.

the class BubbleTextView method makePreloadIcon.

/**
 * Creates a PreloadIconDrawable with the appropriate progress level without mutating this
 * object.
 */
@Nullable
public PreloadIconDrawable makePreloadIcon() {
    if (!(getTag() instanceof ItemInfoWithIcon)) {
        return null;
    }
    ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
    int progressLevel = info.getProgressLevel();
    final PreloadIconDrawable preloadDrawable = newPendingIcon(getContext(), info);
    preloadDrawable.setLevel(progressLevel);
    preloadDrawable.setIsDisabled(!info.isAppStartable());
    return preloadDrawable;
}
Also used : ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) Paint(android.graphics.Paint) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Nullable(androidx.annotation.Nullable)

Example 2 with PreloadIconDrawable

use of com.android.launcher3.graphics.PreloadIconDrawable 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 3 with PreloadIconDrawable

use of com.android.launcher3.graphics.PreloadIconDrawable in project android_packages_apps_Launcher3 by crdroidandroid.

the class PreviewItemManager method setDrawable.

private void setDrawable(PreviewItemDrawingParams p, WorkspaceItemInfo item) {
    if (item.hasPromiseIconUi() || (item.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
        PreloadIconDrawable drawable = newPendingIcon(mContext, item);
        drawable.setLevel(item.getProgressLevel());
        p.drawable = drawable;
    } else {
        p.drawable = item.newIcon(mContext, true);
    }
    p.drawable.setBounds(0, 0, mIconSize, mIconSize);
    p.item = item;
    // Set the callback to FolderIcon as it is responsible to drawing the icon. The
    // callback will be released when the folder is opened.
    p.drawable.setCallback(mIcon);
}
Also used : PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable)

Example 4 with PreloadIconDrawable

use of com.android.launcher3.graphics.PreloadIconDrawable in project android_packages_apps_Launcher3 by crdroidandroid.

the class Workspace method updateShortcuts.

void updateShortcuts(List<WorkspaceItemInfo> shortcuts) {
    final HashSet<WorkspaceItemInfo> updates = new HashSet<>(shortcuts);
    ItemOperator op = (info, v) -> {
        if (v instanceof BubbleTextView && updates.contains(info)) {
            WorkspaceItemInfo si = (WorkspaceItemInfo) info;
            BubbleTextView shortcut = (BubbleTextView) v;
            Drawable oldIcon = shortcut.getIcon();
            boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable) && ((PreloadIconDrawable) oldIcon).hasNotCompleted();
            shortcut.applyFromWorkspaceItem(si, si.isPromise() != oldPromiseState);
        } else if (info instanceof FolderInfo && v instanceof FolderIcon) {
            ((FolderIcon) v).updatePreviewItems(updates::contains);
        }
        // Iterate all items
        return false;
    };
    mapOverItems(op);
    Folder openFolder = Folder.getOpen(mLauncher);
    if (openFolder != null) {
        openFolder.iterateOverItems(op);
    }
}
Also used : BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) LAUNCHER_SWIPELEFT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPELEFT) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Drawable(android.graphics.drawable.Drawable) DraggableView(com.android.launcher3.dragndrop.DraggableView) WallpaperManager(android.app.WallpaperManager) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) LayoutTransition(android.animation.LayoutTransition) Interpolators(com.android.launcher3.anim.Interpolators) LauncherAtom(com.android.launcher3.logger.LauncherAtom) Handler(android.os.Handler) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Log(android.util.Log) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) OverlayEdgeEffect(com.android.launcher3.util.OverlayEdgeEffect) Message(android.os.Message) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) NORMAL(com.android.launcher3.LauncherState.NORMAL) AccessibleDragListenerAdapter(com.android.launcher3.accessibility.AccessibleDragListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) AppWidgetHostViewDragListener(com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SpringLoadedDragController(com.android.launcher3.dragndrop.SpringLoadedDragController) ArrayList(java.util.ArrayList) FLAG_MULTI_PAGE(com.android.launcher3.LauncherState.FLAG_MULTI_PAGE) PreviewBackground(com.android.launcher3.folder.PreviewBackground) AppWidgetHostView(android.appwidget.AppWidgetHostView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimatorListeners.forSuccessCallback(com.android.launcher3.anim.AnimatorListeners.forSuccessCallback) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) IntArray(com.android.launcher3.util.IntArray) ProviderChangedListener(com.android.launcher3.widget.LauncherAppWidgetHost.ProviderChangedListener) Parcelable(android.os.Parcelable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) DragController(com.android.launcher3.dragndrop.DragController) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) StateManager(com.android.launcher3.statemanager.StateManager) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) LauncherAppWidgetHost(com.android.launcher3.widget.LauncherAppWidgetHost) LAUNCHER_SWIPERIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPERIGHT) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) RunnableList(com.android.launcher3.util.RunnableList) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) ValueAnimator(android.animation.ValueAnimator) WorkspaceAccessibilityHelper(com.android.launcher3.accessibility.WorkspaceAccessibilityHelper) Rect(android.graphics.Rect) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) Animator(android.animation.Animator) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) FLAG_WORKSPACE_INACCESSIBLE(com.android.launcher3.LauncherState.FLAG_WORKSPACE_INACCESSIBLE) AttributeSet(android.util.AttributeSet) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) LauncherEvent(com.android.launcher3.logging.StatsLogManager.LauncherEvent) Predicate(java.util.function.Predicate) EdgeEffectCompat(com.android.launcher3.util.EdgeEffectCompat) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SparseArray(android.util.SparseArray) WidgetSizes(com.android.launcher3.widget.util.WidgetSizes) List(java.util.List) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) LAUNCHER_STATE_HOME(com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) ALPHA_INDEX_OVERLAY(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AppInfo(com.android.launcher3.model.data.AppInfo) LauncherOverlay(com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED(com.android.launcher3.LauncherState.FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED) DragLayer(com.android.launcher3.dragndrop.DragLayer) Executors(com.android.launcher3.util.Executors) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) LayoutInflater(android.view.LayoutInflater) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) StatsLogManager(com.android.launcher3.logging.StatsLogManager) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) WorkspacePageIndicator(com.android.launcher3.pageindicators.WorkspacePageIndicator) StateHandler(com.android.launcher3.statemanager.StateManager.StateHandler) ViewTreeObserver(android.view.ViewTreeObserver) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) Thunk(com.android.launcher3.util.Thunk) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) Collections(java.util.Collections) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DragView(com.android.launcher3.dragndrop.DragView) Resources(android.content.res.Resources) FolderIcon(com.android.launcher3.folder.FolderIcon) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) HashSet(java.util.HashSet)

Example 5 with PreloadIconDrawable

use of com.android.launcher3.graphics.PreloadIconDrawable in project android_packages_apps_Launcher3 by crdroidandroid.

the class FloatingIconView method getIconResult.

/**
 * Loads the icon and saves the results to {@link #sIconLoadResult}.
 * Runs onIconLoaded callback (if any), which signifies that the FloatingIconView is
 * ready to display the icon. Otherwise, the FloatingIconView will grab the results when its
 * initialized.
 *
 * @param originalView The View that the FloatingIconView will replace.
 * @param info ItemInfo of the originalView
 * @param pos The position of the view.
 */
@WorkerThread
@SuppressWarnings("WrongThread")
private static void getIconResult(Launcher l, View originalView, ItemInfo info, RectF pos, Drawable btvIcon, IconLoadResult iconLoadResult) {
    Drawable drawable;
    boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get() && // Use original icon for disabled icons.
    !info.isDisabled();
    Drawable badge = null;
    if (info instanceof SystemShortcut) {
        if (originalView instanceof ImageView) {
            drawable = ((ImageView) originalView).getDrawable();
        } else if (originalView instanceof DeepShortcutView) {
            drawable = ((DeepShortcutView) originalView).getIconView().getBackground();
        } else {
            drawable = originalView.getBackground();
        }
    } else if (btvIcon instanceof PreloadIconDrawable) {
        // Force the progress bar to display.
        drawable = btvIcon;
    } else {
        int width = (int) pos.width();
        int height = (int) pos.height();
        if (supportsAdaptiveIcons) {
            drawable = getFullDrawable(l, info, width, height, sTmpObjArray);
            if (drawable instanceof AdaptiveIconDrawable) {
                badge = getBadge(l, info, sTmpObjArray[0]);
            } else {
                // The drawable we get back is not an adaptive icon, so we need to use the
                // BubbleTextView icon that is already legacy treated.
                drawable = btvIcon;
            }
        } else {
            if (originalView instanceof BubbleTextView) {
                // Similar to DragView, we simply use the BubbleTextView icon here.
                drawable = btvIcon;
            } else {
                drawable = getFullDrawable(l, info, width, height, sTmpObjArray);
            }
        }
    }
    drawable = drawable == null ? null : drawable.getConstantState().newDrawable();
    int iconOffset = getOffsetForIconBounds(l, drawable, pos);
    synchronized (iconLoadResult) {
        iconLoadResult.btvDrawable = btvIcon == null || drawable == btvIcon ? null : btvIcon.getConstantState().newDrawable();
        iconLoadResult.drawable = drawable;
        iconLoadResult.badge = badge;
        iconLoadResult.iconOffset = iconOffset;
        if (iconLoadResult.onIconLoaded != null) {
            l.getMainExecutor().execute(iconLoadResult.onIconLoaded);
            iconLoadResult.onIconLoaded = null;
        }
        iconLoadResult.isIconLoaded = true;
    }
}
Also used : SystemShortcut(com.android.launcher3.popup.SystemShortcut) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Utilities.getFullDrawable(com.android.launcher3.Utilities.getFullDrawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) ImageView(android.widget.ImageView) BubbleTextView(com.android.launcher3.BubbleTextView) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)5 Paint (android.graphics.Paint)2 Drawable (android.graphics.drawable.Drawable)2 Nullable (androidx.annotation.Nullable)2 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)2 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 LayoutTransition (android.animation.LayoutTransition)1 ValueAnimator (android.animation.ValueAnimator)1 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)1 SuppressLint (android.annotation.SuppressLint)1 WallpaperManager (android.app.WallpaperManager)1 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)1 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1