Search in sources :

Example 21 with BubbleTextView

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

the class LauncherBindableItemsContainer method updateWorkspaceItems.

/**
 * Called to update workspace items as a result of
 * {@link com.android.launcher3.model.BgDataModel.Callbacks#bindWorkspaceItemsChanged(List)}
 */
default void updateWorkspaceItems(List<WorkspaceItemInfo> shortcuts, ActivityContext context) {
    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(context);
    if (openFolder != null) {
        openFolder.iterateOverItems(op);
    }
}
Also used : Folder(com.android.launcher3.folder.Folder) ActivityContext(com.android.launcher3.views.ActivityContext) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) Drawable(android.graphics.drawable.Drawable) BubbleTextView(com.android.launcher3.BubbleTextView) HashSet(java.util.HashSet) List(java.util.List) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) FolderIcon(com.android.launcher3.folder.FolderIcon) Drawable(android.graphics.drawable.Drawable) PreloadIconDrawable(com.android.launcher3.graphics.PreloadIconDrawable) BubbleTextView(com.android.launcher3.BubbleTextView) 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 22 with BubbleTextView

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

the class FloatingIconView method fetchIcon.

/**
 * Loads the icon drawable on a worker thread to reduce latency between swapping views.
 */
@UiThread
public static IconLoadResult fetchIcon(Launcher l, View v, ItemInfo info, boolean isOpening) {
    RectF position = new RectF();
    getLocationBoundsForView(l, v, isOpening, position);
    final FastBitmapDrawable btvIcon;
    if (v instanceof BubbleTextView) {
        BubbleTextView btv = (BubbleTextView) v;
        if (info instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) info).runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
            btvIcon = btv.makePreloadIcon();
        } else {
            btvIcon = btv.getIcon();
        }
    } else {
        btvIcon = null;
    }
    IconLoadResult result = new IconLoadResult(info, btvIcon == null ? false : btvIcon.isThemed());
    result.btvDrawable = btvIcon;
    final long fetchIconId = sFetchIconId++;
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
        if (fetchIconId < sRecycledFetchIconId) {
            return;
        }
        getIconResult(l, v, info, position, btvIcon, result);
    });
    sIconLoadResult = result;
    return result;
}
Also used : RectF(android.graphics.RectF) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) BubbleTextView(com.android.launcher3.BubbleTextView) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) UiThread(androidx.annotation.UiThread)

Example 23 with BubbleTextView

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

the class LauncherPreviewRenderer method inflateAndAddIcon.

private void inflateAndAddIcon(WorkspaceItemInfo info) {
    CellLayout screen = mWorkspaceScreens.get(info.screenId);
    BubbleTextView icon = (BubbleTextView) mHomeElementInflater.inflate(R.layout.app_icon, screen, false);
    icon.applyFromWorkspaceItem(info);
    addInScreenFromBind(icon, info);
}
Also used : CellLayout(com.android.launcher3.CellLayout) BubbleTextView(com.android.launcher3.BubbleTextView)

Example 24 with BubbleTextView

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

the class FolderPagedView method createNewView.

@SuppressLint("InflateParams")
public View createNewView(WorkspaceItemInfo item) {
    if (item == null) {
        return null;
    }
    final BubbleTextView textView = mViewCache.getView(R.layout.folder_application, 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)

Example 25 with BubbleTextView

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

the class FolderPagedView method arrangeChildren.

/**
 * Updates position and rank of all the children in the view.
 * It essentially removes all views from all the pages and then adds them again in appropriate
 * page.
 *
 * @param list the ordered list of children.
 */
@SuppressLint("RtlHardcoded")
public void arrangeChildren(List<View> list) {
    int itemCount = list.size();
    ArrayList<CellLayout> pages = new ArrayList<>();
    for (int i = 0; i < getChildCount(); i++) {
        CellLayout page = (CellLayout) getChildAt(i);
        page.removeAllViews();
        pages.add(page);
    }
    mOrganizer.setFolderInfo(mFolder.getInfo());
    setupContentDimensions(itemCount);
    Iterator<CellLayout> pageItr = pages.iterator();
    CellLayout currentPage = null;
    int position = 0;
    int rank = 0;
    for (int i = 0; i < itemCount; i++) {
        View v = list.size() > i ? list.get(i) : null;
        if (currentPage == null || position >= mOrganizer.getMaxItemsPerPage()) {
            // Next page
            if (pageItr.hasNext()) {
                currentPage = pageItr.next();
            } else {
                currentPage = createAndAddNewPage();
            }
            position = 0;
        }
        if (v != null) {
            CellLayout.LayoutParams lp = (CellLayout.LayoutParams) v.getLayoutParams();
            ItemInfo info = (ItemInfo) v.getTag();
            lp.setCellXY(mOrganizer.getPosForRank(rank));
            currentPage.addViewToCellLayout(v, -1, info.getViewId(), lp, true);
            if (mOrganizer.isItemInPreview(rank) && v instanceof BubbleTextView) {
                ((BubbleTextView) v).verifyHighRes();
            }
        }
        rank++;
        position++;
    }
    // Remove extra views.
    boolean removed = false;
    while (pageItr.hasNext()) {
        removeView(pageItr.next());
        removed = true;
    }
    if (removed) {
        setCurrentPage(0);
    }
    setEnableOverscroll(getPageCount() > 1);
    // Update footer
    mPageIndicator.setVisibility(getPageCount() > 1 ? View.VISIBLE : View.GONE);
    // Set the gravity as LEFT or RIGHT instead of START, as START depends on the actual text.
    mFolder.mFolderName.setGravity(getPageCount() > 1 ? (mIsRtl ? Gravity.RIGHT : Gravity.LEFT) : Gravity.CENTER_HORIZONTAL);
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrayList(java.util.ArrayList) BubbleTextView(com.android.launcher3.BubbleTextView) ClipPathView(com.android.launcher3.views.ClipPathView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Aggregations

BubbleTextView (com.android.launcher3.BubbleTextView)132 View (android.view.View)69 Rect (android.graphics.Rect)53 Point (android.graphics.Point)52 Drawable (android.graphics.drawable.Drawable)51 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)47 ItemInfo (com.android.launcher3.model.data.ItemInfo)46 SuppressLint (android.annotation.SuppressLint)42 ArrayList (java.util.ArrayList)38 CellLayout (com.android.launcher3.CellLayout)33 Animator (android.animation.Animator)32 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)32 FolderIcon (com.android.launcher3.folder.FolderIcon)30 Handler (android.os.Handler)29 DragView (com.android.launcher3.dragndrop.DragView)29 ViewGroup (android.view.ViewGroup)27 PreloadIconDrawable (com.android.launcher3.graphics.PreloadIconDrawable)26 DraggableView (com.android.launcher3.dragndrop.DraggableView)25 Folder (com.android.launcher3.folder.Folder)24 LayoutTransition (android.animation.LayoutTransition)23