use of com.android.launcher3.tapl.FolderIcon in project Neo-Launcher by NeoApplications.
the class PreviewItemManager method onDrop.
/**
* Handles the case where items in the preview are either:
* - Moving into the preview
* - Moving into a new position
* - Moving out of the preview
*
* @param oldItems The list of items in the old preview.
* @param newItems The list of items in the new preview.
* @param dropped The item that was dropped onto the FolderIcon.
*/
public void onDrop(List<WorkspaceItemInfo> oldItems, List<WorkspaceItemInfo> newItems, WorkspaceItemInfo dropped) {
int numItems = newItems.size();
final ArrayList<PreviewItemDrawingParams> params = mFirstPageParams;
buildParamsForPage(0, params, false);
// New preview items for items that are moving in (except for the dropped item).
List<WorkspaceItemInfo> moveIn = new ArrayList<>();
for (WorkspaceItemInfo newItem : newItems) {
if (!oldItems.contains(newItem) && !newItem.equals(dropped)) {
moveIn.add(newItem);
}
}
for (int i = 0; i < moveIn.size(); ++i) {
int prevIndex = newItems.indexOf(moveIn.get(i));
PreviewItemDrawingParams p = params.get(prevIndex);
computePreviewItemDrawingParams(prevIndex, numItems, p);
updateTransitionParam(p, moveIn.get(i), ENTER_INDEX, newItems.indexOf(moveIn.get(i)), numItems);
}
// Items that are moving into new positions within the preview.
for (int newIndex = 0; newIndex < newItems.size(); ++newIndex) {
int oldIndex = oldItems.indexOf(newItems.get(newIndex));
if (oldIndex >= 0 && newIndex != oldIndex) {
PreviewItemDrawingParams p = params.get(newIndex);
updateTransitionParam(p, newItems.get(newIndex), oldIndex, newIndex, numItems);
}
}
// Old preview items that need to be moved out.
List<WorkspaceItemInfo> moveOut = new ArrayList<>(oldItems);
moveOut.removeAll(newItems);
for (int i = 0; i < moveOut.size(); ++i) {
WorkspaceItemInfo item = moveOut.get(i);
int oldIndex = oldItems.indexOf(item);
PreviewItemDrawingParams p = computePreviewItemDrawingParams(oldIndex, numItems, null);
updateTransitionParam(p, item, oldIndex, EXIT_INDEX, numItems);
// We want these items first so that they are on drawn last.
params.add(0, p);
}
for (int i = 0; i < params.size(); ++i) {
if (params.get(i).anim != null) {
params.get(i).anim.start();
}
}
}
use of com.android.launcher3.tapl.FolderIcon in project Neo-Launcher by NeoApplications.
the class PreviewItemManager method setDrawable.
private void setDrawable(PreviewItemDrawingParams p, WorkspaceItemInfo item) {
if (item.hasPromiseIconUi()) {
PreloadIconDrawable drawable = mDrawableFactory.newPendingIcon(mContext, item);
drawable.setLevel(item.getInstallProgress());
p.drawable = drawable;
} else {
p.drawable = mDrawableFactory.newIcon(mContext, item);
}
p.drawable.setBounds(0, 0, mIconSize, mIconSize);
p.item = item;
// Set the callback to FolderIcon as it is responsible to drawing the icon. The
// callback will be released when the folder is opened.
p.drawable.setCallback(mIcon);
}
use of com.android.launcher3.tapl.FolderIcon 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();
}
use of com.android.launcher3.tapl.FolderIcon 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;
}
}
use of com.android.launcher3.tapl.FolderIcon 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];
}
Aggregations