Search in sources :

Example 46 with BubbleTextView

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

the class FolderPagedView method createNewView.

@SuppressLint("InflateParams")
public View createNewView(WorkspaceItemInfo item) {
    if (item == null) {
        return null;
    }
    int layout = mFolder.isInAppDrawer() ? R.layout.all_apps_folder_application : R.layout.folder_application;
    final BubbleTextView textView = mViewCache.getView(layout, getContext(), null);
    textView.applyFromWorkspaceItem(item);
    textView.setOnClickListener(ItemClickHandler.INSTANCE);
    textView.setOnLongClickListener(mFolder);
    textView.setOnFocusChangeListener(mFocusIndicatorHelper);
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) textView.getLayoutParams();
    if (lp == null) {
        textView.setLayoutParams(new CellLayout.LayoutParams(item.cellX, item.cellY, item.spanX, item.spanY));
    } else {
        lp.cellX = item.cellX;
        lp.cellY = item.cellY;
        lp.cellHSpan = lp.cellVSpan = 1;
    }
    return textView;
}
Also used : CellLayout(com.android.launcher3.CellLayout) BubbleTextView(com.android.launcher3.BubbleTextView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 47 with BubbleTextView

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

the class FolderPagedView method verifyVisibleHighResIcons.

/**
 * Ensures that all the icons on the given page are of high-res
 */
public void verifyVisibleHighResIcons(int pageNo) {
    CellLayout page = getPageAt(pageNo);
    if (page != null) {
        ShortcutAndWidgetContainer parent = page.getShortcutsAndWidgets();
        for (int i = parent.getChildCount() - 1; i >= 0; i--) {
            BubbleTextView icon = ((BubbleTextView) parent.getChildAt(i));
            icon.verifyHighRes();
            // Set the callback back to the actual icon, in case
            // it was captured by the FolderIcon
            Drawable d = icon.getCompoundDrawables()[1];
            if (d != null) {
                d.setCallback(icon);
            }
        }
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) Drawable(android.graphics.drawable.Drawable) BubbleTextView(com.android.launcher3.BubbleTextView) SuppressLint(android.annotation.SuppressLint)

Example 48 with BubbleTextView

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

the class DragPreviewProvider method createDragBitmap.

/**
 * Returns a new bitmap to show when the {@link #mView} is being dragged around.
 * Responsibility for the bitmap is transferred to the caller.
 */
public Bitmap createDragBitmap() {
    int width = mView.getWidth();
    int height = mView.getHeight();
    if (mView instanceof BubbleTextView) {
        Drawable d = ((BubbleTextView) mView).getIcon();
        Rect bounds = getDrawableBounds(d);
        width = bounds.width();
        height = bounds.height();
    } else if (mView instanceof LauncherAppWidgetHostView) {
        float scale = ((LauncherAppWidgetHostView) mView).getScaleToFit();
        width = (int) (mView.getWidth() * scale);
        height = (int) (mView.getHeight() * scale);
        if (mView instanceof PendingAppWidgetHostView) {
            // Use hardware renderer as the icon for the pending app widget may be a hw bitmap
            return BitmapRenderer.createHardwareBitmap(width + blurSizeOutline, height + blurSizeOutline, (c) -> drawDragView(c, scale));
        } else {
            // Use software renderer for widgets as we know that they already work
            return BitmapRenderer.createSoftwareBitmap(width + blurSizeOutline, height + blurSizeOutline, (c) -> drawDragView(c, scale));
        }
    }
    return BitmapRenderer.createHardwareBitmap(width + blurSizeOutline, height + blurSizeOutline, (c) -> drawDragView(c, 1));
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Launcher(com.android.launcher3.Launcher) BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) UI_HELPER_EXECUTOR(com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR) BlurMaskFilter(android.graphics.BlurMaskFilter) FolderIcon(com.android.launcher3.folder.FolderIcon) FeatureFlags(com.android.launcher3.config.FeatureFlags) PorterDuff(android.graphics.PorterDuff) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Drawable(android.graphics.drawable.Drawable) BubbleTextView(com.android.launcher3.BubbleTextView) ByteBuffer(java.nio.ByteBuffer) PorterDuffXfermode(android.graphics.PorterDuffXfermode) R(com.android.launcher3.R) Bitmap(android.graphics.Bitmap) View(android.view.View) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) BubbleTextView(com.android.launcher3.BubbleTextView) Paint(android.graphics.Paint)

Example 49 with BubbleTextView

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

the class DragPreviewProvider method drawDragView.

/**
 * Draws the {@link #mView} into the given {@param destCanvas}.
 */
protected void drawDragView(Canvas destCanvas, float scale) {
    destCanvas.save();
    destCanvas.scale(scale, scale);
    if (mView instanceof BubbleTextView) {
        Drawable d = ((BubbleTextView) mView).getIcon();
        Rect bounds = getDrawableBounds(d);
        destCanvas.translate(blurSizeOutline / 2 - bounds.left, blurSizeOutline / 2 - bounds.top);
        if (d instanceof FastBitmapDrawable) {
            ((FastBitmapDrawable) d).setScale(1);
        }
        d.draw(destCanvas);
    } else {
        final Rect clipRect = mTempRect;
        mView.getDrawingRect(clipRect);
        boolean textVisible = false;
        if (mView instanceof FolderIcon) {
            // hide the text completely (which can't be achieved by clipping).
            if (((FolderIcon) mView).getTextVisible()) {
                ((FolderIcon) mView).setTextVisible(false);
                textVisible = true;
            }
        }
        destCanvas.translate(-mView.getScrollX() + blurSizeOutline / 2, -mView.getScrollY() + blurSizeOutline / 2);
        destCanvas.clipRect(clipRect);
        mView.draw(destCanvas);
        // Restore text visibility of FolderIcon if necessary
        if (textVisible) {
            ((FolderIcon) mView).setTextVisible(true);
        }
    }
    destCanvas.restore();
}
Also used : FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) Rect(android.graphics.Rect) FolderIcon(com.android.launcher3.folder.FolderIcon) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.FastBitmapDrawable) BubbleTextView(com.android.launcher3.BubbleTextView)

Example 50 with BubbleTextView

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

the class PopupContainerWithArrow method populateAndShow.

@TargetApi(Build.VERSION_CODES.P)
protected void populateAndShow(final BubbleTextView originalIcon, int shortcutCount, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) {
    mNumNotifications = notificationKeys.size();
    mOriginalIcon = originalIcon;
    // Add views
    if (mNumNotifications > 0) {
        // Add notification entries
        View.inflate(getContext(), R.layout.notification_content, this);
        mNotificationItemView = new NotificationItemView(this);
        if (mNumNotifications == 1) {
            mNotificationItemView.removeFooter();
        }
        updateNotificationHeader();
    }
    int viewsToFlip = getChildCount();
    mSystemShortcutContainer = this;
    if (shortcutCount > 0) {
        if (mNotificationItemView != null) {
            mNotificationItemView.addGutter();
        }
        for (int i = shortcutCount; i > 0; i--) {
            mShortcuts.add(inflateAndAdd(R.layout.deep_shortcut, this));
        }
        updateHiddenShortcuts();
        if (!systemShortcuts.isEmpty()) {
            mSystemShortcutContainer = inflateAndAdd(R.layout.system_shortcut_icons, this);
            for (SystemShortcut shortcut : systemShortcuts) {
                initializeSystemShortcut(R.layout.system_shortcut_icon_only, mSystemShortcutContainer, shortcut);
            }
        }
    } else if (!systemShortcuts.isEmpty()) {
        if (mNotificationItemView != null) {
            mNotificationItemView.addGutter();
        }
        for (SystemShortcut shortcut : systemShortcuts) {
            initializeSystemShortcut(R.layout.system_shortcut, this, shortcut);
        }
    }
    reorderAndShow(viewsToFlip);
    ItemInfo originalItemInfo = (ItemInfo) originalIcon.getTag();
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        setAccessibilityPaneTitle(getTitleForAccessibility());
    }
    mLauncher.getDragController().addDragListener(this);
    mOriginalIcon.setForceHideDot(true);
    // All views are added. Animate layout from now on.
    setLayoutTransition(new LayoutTransition());
    // Load the shortcuts on a background thread and update the container as it animates.
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(PopupPopulator.createUpdateRunnable(mLauncher, originalItemInfo, new Handler(Looper.getMainLooper()), this, mShortcuts, notificationKeys));
}
Also used : ItemInfo(com.android.launcher3.ItemInfo) NotificationItemView(com.android.launcher3.notification.NotificationItemView) Handler(android.os.Handler) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) LayoutTransition(android.animation.LayoutTransition) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

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