Search in sources :

Example 36 with BubbleTextView

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

the class ConfigBuilder method setAllAppsSearchView.

private void setAllAppsSearchView() {
    View view = null;
    AllAppsRecyclerView appsView = getAppsView();
    GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager) appsView.getLayoutManager()).getSpanSizeLookup();
    int allAppsCols = Math.min(mActivity.getDeviceProfile().inv.numColsDrawer, appsView.getChildCount());
    int childCount = appsView.getChildCount();
    BubbleTextView[] bubbleTextViewArr = new BubbleTextView[allAppsCols];
    int i4 = -1;
    for (int i = 0; i < childCount; i++) {
        RecyclerView.ViewHolder childViewHolder = appsView.getChildViewHolder(appsView.getChildAt(i));
        if (childViewHolder.itemView instanceof BubbleTextView) {
            int spanGroupIndex = spanSizeLookup.getSpanGroupIndex(childViewHolder.getLayoutPosition(), allAppsCols);
            if (spanGroupIndex >= 0) {
                if (i4 >= 0) {
                    if (spanGroupIndex != i4) {
                        view = childViewHolder.itemView;
                        break;
                    }
                }
                i4 = spanGroupIndex;
                int index = ((GridLayoutManager.LayoutParams) childViewHolder.itemView.getLayoutParams()).getSpanIndex();
                bubbleTextViewArr[index] = (BubbleTextView) childViewHolder.itemView;
            }
        }
    }
    if (bubbleTextViewArr.length == 0 || bubbleTextViewArr[0] == null) {
        Log.e("ConfigBuilder", "No icons rendered in all apps");
        setHotseatSearchView();
        return;
    }
    mBubbleTextView = bubbleTextViewArr[0];
    mNano.allAppsCols = allAppsCols;
    int iconCountOffset = 0;
    for (int i = 0; i < bubbleTextViewArr.length; i++) {
        if (bubbleTextViewArr[i] == null) {
            iconCountOffset = allAppsCols - i;
            allAppsCols = i;
            break;
        }
    }
    co = appsView.getChildViewHolder(bubbleTextViewArr[0]).getItemViewType() == 4;
    Columns lastColumn = getViewBounds(bubbleTextViewArr[allAppsCols - 1]);
    Columns firstColumn = getViewBounds(bubbleTextViewArr[0]);
    if (Utilities.isRtl(mActivity.getResources())) {
        Columns temp = lastColumn;
        lastColumn = firstColumn;
        firstColumn = temp;
    }
    int iconWidth = lastColumn.iconDistance;
    int totalIconDistance = lastColumn.edgeMargin - firstColumn.edgeMargin;
    int iconDistance = totalIconDistance / allAppsCols;
    firstColumn.iconDistance = iconWidth + totalIconDistance;
    if (Utilities.isRtl(mActivity.getResources())) {
        firstColumn.edgeMargin -= iconCountOffset * iconWidth;
        firstColumn.iconDistance += iconCountOffset * iconWidth;
    } else {
        firstColumn.iconDistance += iconCountOffset * (iconDistance + iconWidth);
    }
    mNano.apps = firstColumn;
    if (!this.co) {
        firstColumn.innerMargin -= firstColumn.height;
    } else if (view != null) {
        Columns viewBounds3 = getViewBounds(view);
        viewBounds3.iconDistance = firstColumn.iconDistance;
        mNano.appsView = viewBounds3;
    }
    updateHotseatSearchDimens();
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) AllAppsRecyclerView(com.android.launcher3.allapps.AllAppsRecyclerView) Columns(com.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns) RecyclerView(androidx.recyclerview.widget.RecyclerView) AllAppsRecyclerView(com.android.launcher3.allapps.AllAppsRecyclerView) BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) SearchView(com.google.android.apps.nexuslauncher.search.nano.SearchProto.SearchView) RecyclerView(androidx.recyclerview.widget.RecyclerView) AllAppsRecyclerView(com.android.launcher3.allapps.AllAppsRecyclerView) Point(android.graphics.Point)

Example 37 with BubbleTextView

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

the class ConfigBuilder method setHotseatSearchView.

private void setHotseatSearchView() {
    mNano.allAppsCols = mActivity.getDeviceProfile().inv.numColumns;
    final int width = mActivity.getHotseat().getWidth();
    final int dimensionPixelSize = mActivity.getResources().getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
    final Columns appCol = new Columns();
    appCol.edgeMargin = dimensionPixelSize;
    appCol.iconDistance = width - dimensionPixelSize - dimensionPixelSize;
    appCol.height = mActivity.getDeviceProfile().allAppsCellHeightPx;
    mNano.apps = appCol;
    updateHotseatSearchDimens();
    AlphabeticalAppsList apps = getAppsView().getApps();
    mBubbleTextView = (BubbleTextView) mActivity.getLayoutInflater().inflate(R.layout.all_apps_icon, getAppsView(), false);
    ViewGroup.LayoutParams layoutParams = mBubbleTextView.getLayoutParams();
    layoutParams.height = appCol.height;
    layoutParams.width = appCol.iconDistance / mNano.allAppsCols;
    if (!apps.getApps().isEmpty()) {
        mBubbleTextView.applyFromApplicationInfo(apps.getApps().get(0));
    }
    mBubbleTextView.measure(View.MeasureSpec.makeMeasureSpec(layoutParams.width, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(layoutParams.height, View.MeasureSpec.EXACTLY));
    mBubbleTextView.layout(0, 0, layoutParams.width, layoutParams.height);
    final ArrayList<AppIndex> list = new ArrayList<>(mNano.allAppsCols);
    mNano.index = list.toArray(new AppIndex[0]);
}
Also used : ViewGroup(android.view.ViewGroup) AlphabeticalAppsList(com.android.launcher3.allapps.AlphabeticalAppsList) ArrayList(java.util.ArrayList) Columns(com.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns) AppIndex(com.google.android.apps.nexuslauncher.search.nano.SearchProto.AppIndex) Point(android.graphics.Point)

Example 38 with BubbleTextView

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

the class IconPreview method applyPreviewIcons.

private void applyPreviewIcons() {
    for (int i = 0; i < 5; i++) {
        BubbleTextView icon = (BubbleTextView) mLauncher.getLayoutInflater().inflate(R.layout.all_apps_icon, this, false);
        LayoutParams lp = (LayoutParams) icon.getLayoutParams();
        lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
        lp.width = 0;
        lp.weight = 1;
        addView(icon);
    }
    for (int i = 0; i < 5; i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        icon.setVisibility(View.VISIBLE);
        icon.applyFromApplicationInfo((AppInfo) mPreviewApps.get(getRandomApp()));
        icon.setTextColor(mIconTextColor);
    }
    mLauncher.reapplyUi();
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView)

Example 39 with BubbleTextView

use of com.android.launcher3.BubbleTextView 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 40 with BubbleTextView

use of com.android.launcher3.BubbleTextView 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)

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