Search in sources :

Example 31 with FolderIcon

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

the class FolderInfo method getFolderIcon.

public Drawable getFolderIcon(Launcher launcher) {
    int iconSize = launcher.mDeviceProfile.iconSizePx;
    FrameLayout dummy = new FrameLayout(launcher, null);
    FolderIcon icon = FolderIcon.fromXml(R.layout.folder_icon, launcher, dummy, this);
    icon.isCustomIcon = false;
    icon.getFolderBackground().setStartOpacity(1f);
    Bitmap b = BitmapRenderer.createHardwareBitmap(iconSize, iconSize, out -> {
        out.translate(iconSize / 2f, 0);
        // TODO: make folder icons more visible in front of the bottom sheet
        // out.drawColor(Color.RED);
        icon.draw(out);
    });
    icon.unbind();
    return new BitmapDrawable(launcher.getResources(), b);
}
Also used : Bitmap(android.graphics.Bitmap) FolderIcon(com.android.launcher3.folder.FolderIcon) FrameLayout(android.widget.FrameLayout) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 32 with FolderIcon

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

the class Workspace method updateShortcuts.

void updateShortcuts(ArrayList<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 : WorkspaceAccessibilityHelper(com.android.launcher3.accessibility.WorkspaceAccessibilityHelper) Rect(android.graphics.Rect) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) TestProtocol(com.android.launcher3.testing.TestProtocol) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) Animator(android.animation.Animator) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Drawable(android.graphics.drawable.Drawable) ProviderChangedListener(com.android.launcher3.LauncherAppWidgetHost.ProviderChangedListener) WallpaperManager(android.app.WallpaperManager) IBinder(android.os.IBinder) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) LayoutTransition(android.animation.LayoutTransition) AttributeSet(android.util.AttributeSet) Interpolators(com.android.launcher3.anim.Interpolators) Handler(android.os.Handler) View(android.view.View) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) Canvas(android.graphics.Canvas) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) OmegaLauncher(com.saggitt.omega.OmegaLauncher) RotationMode(com.android.launcher3.graphics.RotationMode) Log(android.util.Log) ShortcutDragPreviewProvider(com.android.launcher3.shortcuts.ShortcutDragPreviewProvider) Predicate(java.util.function.Predicate) ObjectAnimator(android.animation.ObjectAnimator) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SPRING_LOADED_TRANSITION_MS(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS) SparseArray(android.util.SparseArray) AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) Message(android.os.Message) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) OVERVIEW_TRANSITION_MS(com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS) NORMAL(com.android.launcher3.LauncherState.NORMAL) ALPHA_INDEX_OVERLAY(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY) AccessibleDragListenerAdapter(com.android.launcher3.accessibility.AccessibleDragListenerAdapter) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) FolderIcon(com.android.launcher3.folder.FolderIcon) UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SpringLoadedDragController(com.android.launcher3.dragndrop.SpringLoadedDragController) ArrayList(java.util.ArrayList) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) PreviewBackground(com.android.launcher3.folder.PreviewBackground) AppWidgetHostView(android.appwidget.AppWidgetHostView) MotionEvent(android.view.MotionEvent) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) DragLayer(com.android.launcher3.dragndrop.DragLayer) Executors(com.android.launcher3.util.Executors) IntArray(com.android.launcher3.util.IntArray) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) Parcelable(android.os.Parcelable) Action(com.android.launcher3.userevent.nano.LauncherLogProto.Action) ContainerType(com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType) LayoutInflater(android.view.LayoutInflater) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig) DragController(com.android.launcher3.dragndrop.DragController) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) AppWidgetManagerCompat(com.android.launcher3.compat.AppWidgetManagerCompat) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) LauncherOverlay(com.android.launcher3.Launcher.LauncherOverlay) WorkspacePageIndicator(com.android.launcher3.pageindicators.WorkspacePageIndicator) ViewTreeObserver(android.view.ViewTreeObserver) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) Thunk(com.android.launcher3.util.Thunk) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) DragView(com.android.launcher3.dragndrop.DragView) OmegaBackgroundView(com.saggitt.omega.views.OmegaBackgroundView) ValueAnimator(android.animation.ValueAnimator) Resources(android.content.res.Resources) FolderIcon(com.android.launcher3.folder.FolderIcon) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) Folder(com.android.launcher3.folder.Folder) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) HashSet(java.util.HashSet)

Example 33 with FolderIcon

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

the class Workspace method manageFolderFeedback.

private void manageFolderFeedback(CellLayout targetLayout, int[] targetCell, float distance, DragObject dragObject) {
    if (distance > mMaxDistanceForFolderCreation) {
        if (mDragMode != DRAG_MODE_NONE) {
            setDragMode(DRAG_MODE_NONE);
        }
        return;
    }
    final View dragOverView = mDragTargetLayout.getChildAt(mTargetCell[0], mTargetCell[1]);
    ItemInfo info = dragObject.dragInfo;
    boolean userFolderPending = willCreateUserFolder(info, dragOverView, false);
    if (mDragMode == DRAG_MODE_NONE && userFolderPending && !mFolderCreationAlarm.alarmPending()) {
        FolderCreationAlarmListener listener = new FolderCreationAlarmListener(targetLayout, targetCell[0], targetCell[1]);
        if (!dragObject.accessibleDrag) {
            mFolderCreationAlarm.setOnAlarmListener(listener);
            mFolderCreationAlarm.setAlarm(FOLDER_CREATION_TIMEOUT);
        } else {
            listener.onAlarm(mFolderCreationAlarm);
        }
        if (dragObject.stateAnnouncer != null) {
            dragObject.stateAnnouncer.announce(WorkspaceAccessibilityHelper.getDescriptionForDropOver(dragOverView, getContext()));
        }
        return;
    }
    boolean willAddToFolder = willAddToExistingUserFolder(info, dragOverView);
    if (willAddToFolder && mDragMode == DRAG_MODE_NONE) {
        mDragOverFolderIcon = ((FolderIcon) dragOverView);
        mDragOverFolderIcon.onDragEnter(info);
        if (targetLayout != null) {
            targetLayout.clearDragOutlines();
        }
        setDragMode(DRAG_MODE_ADD_TO_FOLDER);
        if (dragObject.stateAnnouncer != null) {
            dragObject.stateAnnouncer.announce(WorkspaceAccessibilityHelper.getDescriptionForDropOver(dragOverView, getContext()));
        }
        return;
    }
    if (mDragMode == DRAG_MODE_ADD_TO_FOLDER && !willAddToFolder) {
        setDragMode(DRAG_MODE_NONE);
    }
    if (mDragMode == DRAG_MODE_CREATE_FOLDER && !userFolderPending) {
        setDragMode(DRAG_MODE_NONE);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) OmegaBackgroundView(com.saggitt.omega.views.OmegaBackgroundView)

Example 34 with FolderIcon

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

the class Workspace method beginDragShared.

public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) {
    if (TestProtocol.sDebugTracing) {
        Log.d(TestProtocol.NO_CONTEXT_MENU, "beginDragShared");
    }
    float iconScale = 1f;
    if (child instanceof BubbleTextView) {
        Drawable icon = ((BubbleTextView) child).getIcon();
        if (icon instanceof FastBitmapDrawable) {
            iconScale = ((FastBitmapDrawable) icon).getAnimatedScale();
        }
    }
    child.clearFocus();
    child.setPressed(false);
    mOutlineProvider = previewProvider;
    // The drag bitmap follows the touch point around on the screen
    final Bitmap b = previewProvider.createDragBitmap();
    int halfPadding = previewProvider.previewPadding / 2;
    float scale = previewProvider.getScaleAndPosition(b, mTempXY);
    int dragLayerX = mTempXY[0];
    int dragLayerY = mTempXY[1];
    DeviceProfile grid = mLauncher.getDeviceProfile();
    Point dragVisualizeOffset = null;
    Rect dragRect = null;
    if (child instanceof BubbleTextView) {
        dragRect = new Rect();
        BubbleTextView.getIconBounds(child, dragRect, grid.iconSizePx);
        dragLayerY += dragRect.top;
        // Note: The dragRect is used to calculate drag layer offsets, but the
        // dragVisualizeOffset in addition to the dragRect (the size) to position the outline.
        dragVisualizeOffset = new Point(-halfPadding, halfPadding);
    } else if (child instanceof FolderIcon) {
        int previewSize = grid.folderIconSizePx;
        dragVisualizeOffset = new Point(-halfPadding, halfPadding - child.getPaddingTop());
        dragRect = new Rect(0, child.getPaddingTop(), child.getWidth(), previewSize);
    } else if (previewProvider instanceof ShortcutDragPreviewProvider) {
        dragVisualizeOffset = new Point(-halfPadding, halfPadding);
    }
    // Clear the pressed state if necessary
    if (child instanceof BubbleTextView) {
        BubbleTextView icon = (BubbleTextView) child;
        icon.clearPressedBackground();
    }
    if (child.getParent() instanceof ShortcutAndWidgetContainer) {
        mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent();
    }
    if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) {
        PopupContainerWithArrow popupContainer = PopupContainerWithArrow.showForIcon((BubbleTextView) child);
        if (popupContainer != null) {
            dragOptions.preDragCondition = popupContainer.createPreDragCondition();
            mLauncher.getUserEventDispatcher().resetElapsedContainerMillis("dragging started");
        }
    }
    DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions);
    dv.setIntrinsicIconScaleFactor(dragOptions.intrinsicIconScaleFactor);
    return dv;
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) DragView(com.android.launcher3.dragndrop.DragView) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Bitmap(android.graphics.Bitmap) FolderIcon(com.android.launcher3.folder.FolderIcon) ShortcutDragPreviewProvider(com.android.launcher3.shortcuts.ShortcutDragPreviewProvider) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow)

Example 35 with FolderIcon

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

the class Workspace method updateNotificationDots.

public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
    final PackageUserKey packageUserKey = new PackageUserKey(null, null);
    Predicate<ItemInfo> matcher = info -> !packageUserKey.updateFromItemInfo(info) || updatedDots.test(packageUserKey);
    ItemOperator op = (info, v) -> {
        if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView) {
            if (matcher.test(info)) {
                ((BubbleTextView) v).applyDotState(info, true);
            }
        } else if (info instanceof FolderInfo && v instanceof FolderIcon) {
            FolderInfo fi = (FolderInfo) info;
            if (fi.contents.stream().anyMatch(matcher)) {
                FolderDotInfo folderDotInfo = new FolderDotInfo();
                for (WorkspaceItemInfo si : fi.contents) {
                    folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
                }
                ((FolderIcon) v).setDotInfo(folderDotInfo);
            }
        }
        // process all the shortcuts
        return false;
    };
    mapOverItems(op);
    Folder folder = Folder.getOpen(mLauncher);
    if (folder != null) {
        folder.iterateOverItems(op);
    }
}
Also used : WorkspaceAccessibilityHelper(com.android.launcher3.accessibility.WorkspaceAccessibilityHelper) Rect(android.graphics.Rect) SPRING_LOADED_EXIT_DELAY(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY) TestProtocol(com.android.launcher3.testing.TestProtocol) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) Animator(android.animation.Animator) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Drawable(android.graphics.drawable.Drawable) ProviderChangedListener(com.android.launcher3.LauncherAppWidgetHost.ProviderChangedListener) WallpaperManager(android.app.WallpaperManager) IBinder(android.os.IBinder) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) SPRING_LOADED(com.android.launcher3.LauncherState.SPRING_LOADED) LayoutTransition(android.animation.LayoutTransition) AttributeSet(android.util.AttributeSet) Interpolators(com.android.launcher3.anim.Interpolators) Handler(android.os.Handler) View(android.view.View) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) Canvas(android.graphics.Canvas) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) OmegaLauncher(com.saggitt.omega.OmegaLauncher) RotationMode(com.android.launcher3.graphics.RotationMode) Log(android.util.Log) ShortcutDragPreviewProvider(com.android.launcher3.shortcuts.ShortcutDragPreviewProvider) Predicate(java.util.function.Predicate) ObjectAnimator(android.animation.ObjectAnimator) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) SPRING_LOADED_TRANSITION_MS(com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS) SparseArray(android.util.SparseArray) AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) Message(android.os.Message) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) OVERVIEW_TRANSITION_MS(com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS) NORMAL(com.android.launcher3.LauncherState.NORMAL) ALPHA_INDEX_OVERLAY(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY) AccessibleDragListenerAdapter(com.android.launcher3.accessibility.AccessibleDragListenerAdapter) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) FolderIcon(com.android.launcher3.folder.FolderIcon) UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) ITEM_TYPE_APPLICATION(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) SpringLoadedDragController(com.android.launcher3.dragndrop.SpringLoadedDragController) ArrayList(java.util.ArrayList) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) PreviewBackground(com.android.launcher3.folder.PreviewBackground) AppWidgetHostView(android.appwidget.AppWidgetHostView) MotionEvent(android.view.MotionEvent) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) DragLayer(com.android.launcher3.dragndrop.DragLayer) Executors(com.android.launcher3.util.Executors) IntArray(com.android.launcher3.util.IntArray) ADAPTIVE_ICON_WINDOW_ANIM(com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM) Parcelable(android.os.Parcelable) Action(com.android.launcher3.userevent.nano.LauncherLogProto.Action) ContainerType(com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType) LayoutInflater(android.view.LayoutInflater) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig) DragController(com.android.launcher3.dragndrop.DragController) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) TextUtils(android.text.TextUtils) FeatureFlags(com.android.launcher3.config.FeatureFlags) AppWidgetManagerCompat(com.android.launcher3.compat.AppWidgetManagerCompat) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Bitmap(android.graphics.Bitmap) LauncherOverlay(com.android.launcher3.Launcher.LauncherOverlay) WorkspacePageIndicator(com.android.launcher3.pageindicators.WorkspacePageIndicator) ViewTreeObserver(android.view.ViewTreeObserver) WorkspaceTouchListener(com.android.launcher3.touch.WorkspaceTouchListener) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) Thunk(com.android.launcher3.util.Thunk) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) DragView(com.android.launcher3.dragndrop.DragView) OmegaBackgroundView(com.saggitt.omega.views.OmegaBackgroundView) ValueAnimator(android.animation.ValueAnimator) Resources(android.content.res.Resources) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageUserKey(com.android.launcher3.util.PackageUserKey) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) Folder(com.android.launcher3.folder.Folder)

Aggregations

FolderIcon (com.android.launcher3.folder.FolderIcon)124 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)82 View (android.view.View)81 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)70 AppWidgetHostView (android.appwidget.AppWidgetHostView)62 FolderInfo (com.android.launcher3.model.data.FolderInfo)58 DragView (com.android.launcher3.dragndrop.DragView)57 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)55 ItemInfo (com.android.launcher3.model.data.ItemInfo)48 SuppressLint (android.annotation.SuppressLint)42 BubbleTextView (com.android.launcher3.BubbleTextView)41 Folder (com.android.launcher3.folder.Folder)40 Point (android.graphics.Point)37 Rect (android.graphics.Rect)37 DraggableView (com.android.launcher3.dragndrop.DraggableView)35 Drawable (android.graphics.drawable.Drawable)33 PreviewBackground (com.android.launcher3.folder.PreviewBackground)33 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 ArrayList (java.util.ArrayList)27 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)25