Search in sources :

Example 51 with BubbleTextView

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

the class FloatingIconView method getFloatingIconView.

/**
 * Creates a floating icon view for {@param originalView}.
 * @param originalView The view to copy
 * @param hideOriginal If true, it will hide {@param originalView} while this view is visible.
 *                     Else, we will not draw anything in this view.
 * @param positionOut Rect that will hold the size and position of v.
 * @param isOpening True if this view replaces the icon for app open animation.
 */
public static FloatingIconView getFloatingIconView(Launcher launcher, View originalView, boolean hideOriginal, RectF positionOut, boolean isOpening) {
    final DragLayer dragLayer = launcher.getDragLayer();
    ViewGroup parent = (ViewGroup) dragLayer.getParent();
    FloatingIconView view = launcher.getViewCache().getView(R.layout.floating_icon_view, launcher, parent);
    view.recycle();
    // Get the drawable on the background thread
    boolean shouldLoadIcon = originalView.getTag() instanceof ItemInfo && hideOriginal;
    if (shouldLoadIcon) {
        if (sIconLoadResult != null && sIconLoadResult.itemInfo == originalView.getTag()) {
            view.mIconLoadResult = sIconLoadResult;
        } else {
            view.mIconLoadResult = fetchIcon(launcher, originalView, (ItemInfo) originalView.getTag(), isOpening);
        }
    }
    sIconLoadResult = null;
    view.mIsVerticalBarLayout = launcher.getDeviceProfile().isVerticalBarLayout();
    view.mIsOpening = isOpening;
    view.mOriginalIcon = originalView;
    view.mPositionOut = positionOut;
    // Match the position of the original view.
    view.matchPositionOf(launcher, originalView, isOpening, positionOut);
    // We need to add it to the overlay, but keep it invisible until animation starts..
    view.setVisibility(INVISIBLE);
    parent.addView(view);
    dragLayer.addView(view.mListenerView);
    view.mListenerView.setListener(view::fastFinish);
    view.mEndRunnable = () -> {
        view.mEndRunnable = null;
        if (hideOriginal) {
            if (isOpening) {
                if (originalView instanceof BubbleTextView) {
                    ((BubbleTextView) originalView).setIconVisible(true);
                    ((BubbleTextView) originalView).setForceHideDot(false);
                } else {
                    originalView.setVisibility(VISIBLE);
                }
                view.finish(dragLayer);
            } else {
                view.mFadeAnimatorSet = view.createFadeAnimation(originalView, dragLayer);
                view.mFadeAnimatorSet.start();
            }
        } else {
            view.finish(dragLayer);
        }
    };
    // the icon is not left in a hidden state.
    if (shouldLoadIcon) {
        view.checkIconResult(originalView);
    }
    return view;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) ItemInfo(com.android.launcher3.ItemInfo) ViewGroup(android.view.ViewGroup) BubbleTextView(com.android.launcher3.BubbleTextView)

Example 52 with BubbleTextView

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

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, IconLoadResult iconLoadResult) {
    Drawable drawable = null;
    Drawable badge = null;
    boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
    Drawable btvIcon = originalView instanceof BubbleTextView ? ((BubbleTextView) originalView).getIcon() : 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 {
        boolean isFolderIcon = originalView instanceof FolderIcon;
        int width = isFolderIcon ? originalView.getWidth() : (int) pos.width();
        int height = isFolderIcon ? originalView.getHeight() : (int) pos.height();
        if (supportsAdaptiveIcons) {
            drawable = getFullDrawable(l, info, width, height, false, 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, false, sTmpObjArray);
            }
        }
    }
    drawable = drawable == null ? null : drawable.getConstantState().newDrawable();
    int iconOffset = getOffsetForIconBounds(l, drawable, pos);
    synchronized (iconLoadResult) {
        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) FolderIcon(com.android.launcher3.folder.FolderIcon) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ShiftedBitmapDrawable(com.android.launcher3.graphics.ShiftedBitmapDrawable) Utilities.getFullDrawable(com.android.launcher3.Utilities.getFullDrawable) ImageView(android.widget.ImageView) BubbleTextView(com.android.launcher3.BubbleTextView) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) WorkerThread(androidx.annotation.WorkerThread)

Example 53 with BubbleTextView

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

the class FloatingIconView method getLocationBoundsForView.

/**
 * Gets the location bounds of a view and returns the overall rotation.
 * - For DeepShortcutView, we return the bounds of the icon view.
 * - For BubbleTextView, we return the icon bounds.
 */
private static float getLocationBoundsForView(Launcher launcher, View v, boolean isOpening, RectF outRect) {
    boolean ignoreTransform = !isOpening;
    if (v instanceof DeepShortcutView) {
        v = ((DeepShortcutView) v).getBubbleText();
        ignoreTransform = false;
    } else if (v.getParent() instanceof DeepShortcutView) {
        v = ((DeepShortcutView) v.getParent()).getIconView();
        ignoreTransform = false;
    }
    if (v == null) {
        return 0;
    }
    Rect iconBounds = new Rect();
    if (v instanceof BubbleTextView) {
        ((BubbleTextView) v).getIconBounds(iconBounds);
    } else if (v instanceof FolderIcon) {
        ((FolderIcon) v).getPreviewBounds(iconBounds);
    } else {
        iconBounds.set(0, 0, v.getWidth(), v.getHeight());
    }
    float[] points = new float[] { iconBounds.left, iconBounds.top, iconBounds.right, iconBounds.bottom };
    float[] rotation = new float[] { 0 };
    Utilities.getDescendantCoordRelativeToAncestor(v, launcher.getDragLayer(), points, false, ignoreTransform, rotation);
    outRect.set(Math.min(points[0], points[2]), Math.min(points[1], points[3]), Math.max(points[0], points[2]), Math.max(points[1], points[3]));
    return rotation[0];
}
Also used : Rect(android.graphics.Rect) FolderIcon(com.android.launcher3.folder.FolderIcon) BubbleTextView(com.android.launcher3.BubbleTextView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Example 54 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskbarPopupController method showForIcon.

/**
 * Shows the notifications and deep shortcuts associated with a Taskbar {@param icon}.
 * @return the container if shown or null.
 */
public PopupContainerWithArrow<TaskbarActivityContext> showForIcon(BubbleTextView icon) {
    TaskbarActivityContext context = ActivityContext.lookupContext(icon.getContext());
    if (PopupContainerWithArrow.getOpen(context) != null) {
        // There is already an items container open, so don't open this one.
        icon.clearFocus();
        return null;
    }
    ItemInfo item = (ItemInfo) icon.getTag();
    if (!PopupContainerWithArrow.canShow(icon, item)) {
        return null;
    }
    final PopupContainerWithArrow<TaskbarActivityContext> container = (PopupContainerWithArrow) context.getLayoutInflater().inflate(R.layout.popup_container, context.getDragLayer(), false);
    // TODO (b/198438631): configure for taskbar/context
    container.populateAndShow(icon, mPopupDataProvider.getShortcutCountForItem(item), mPopupDataProvider.getNotificationKeysForItem(item), // TODO (b/198438631): add support for INSTALL shortcut factory
    Stream.of(APP_INFO).map(s -> s.getShortcut(context, item)).filter(Objects::nonNull).collect(Collectors.toList()));
    container.requestFocus();
    return container;
}
Also used : PopupDataProvider(com.android.launcher3.popup.PopupDataProvider) ActivityContext(com.android.launcher3.views.ActivityContext) NonNull(androidx.annotation.NonNull) ItemInfo(com.android.launcher3.model.data.ItemInfo) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) BubbleTextView(com.android.launcher3.BubbleTextView) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) Objects(java.util.Objects) Stream(java.util.stream.Stream) R(com.android.launcher3.R) ComponentKey(com.android.launcher3.util.ComponentKey) SystemShortcut(com.android.launcher3.popup.SystemShortcut) ItemInfo(com.android.launcher3.model.data.ItemInfo) Objects(java.util.Objects) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow)

Example 55 with BubbleTextView

use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by ArrowOS.

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 : 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) Log(android.util.Log) WallpaperOffsetInterpolator(com.android.launcher3.util.WallpaperOffsetInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) OverlayEdgeEffect(com.android.launcher3.util.OverlayEdgeEffect) Nullable(androidx.annotation.Nullable) 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) InstanceId(com.android.launcher3.logging.InstanceId) 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) FeatureFlags(com.android.launcher3.config.FeatureFlags) IntSet(com.android.launcher3.util.IntSet) 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) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) LauncherBindableItemsContainer(com.android.launcher3.util.LauncherBindableItemsContainer) 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) Iterator(java.util.Iterator) LayoutInflater(android.view.LayoutInflater) PackageUserKey(com.android.launcher3.util.PackageUserKey) Point(android.graphics.Point) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) Consumer(java.util.function.Consumer) 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) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageUserKey(com.android.launcher3.util.PackageUserKey) FolderDotInfo(com.android.launcher3.dot.FolderDotInfo) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

BubbleTextView (com.android.launcher3.BubbleTextView)157 View (android.view.View)82 Rect (android.graphics.Rect)62 Point (android.graphics.Point)61 Drawable (android.graphics.drawable.Drawable)60 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)57 ItemInfo (com.android.launcher3.model.data.ItemInfo)56 SuppressLint (android.annotation.SuppressLint)48 ArrayList (java.util.ArrayList)43 CellLayout (com.android.launcher3.CellLayout)39 Animator (android.animation.Animator)36 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 DragView (com.android.launcher3.dragndrop.DragView)34 FolderIcon (com.android.launcher3.folder.FolderIcon)34 Handler (android.os.Handler)33 ViewGroup (android.view.ViewGroup)30 DraggableView (com.android.launcher3.dragndrop.DraggableView)30 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)30 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)28 Folder (com.android.launcher3.folder.Folder)28