use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.
the class FolderAdaptiveIcon method createDrawableOnUiThread.
private static FolderAdaptiveIcon createDrawableOnUiThread(FolderIcon icon, Point dragViewSize) {
Preconditions.assertUIThread();
icon.getPreviewBounds(sTmpRect);
PreviewBackground bg = icon.getFolderBackground();
// assume square
assert (dragViewSize.x == dragViewSize.y);
final int previewSize = sTmpRect.width();
final int margin = (dragViewSize.x - previewSize) / 2;
final float previewShiftX = -sTmpRect.left + margin;
final float previewShiftY = -sTmpRect.top + margin;
// Initialize badge, which consists of the outline stroke, shadow and dot; these
// must be rendered above the foreground
Bitmap badgeBmp = BitmapRenderer.createHardwareBitmap(dragViewSize.x, dragViewSize.y, (canvas) -> {
canvas.save();
canvas.translate(previewShiftX, previewShiftY);
bg.drawShadow(canvas);
bg.drawBackgroundStroke(canvas);
icon.drawDot(canvas);
canvas.restore();
});
// Initialize mask
Path mask = new Path();
Matrix m = new Matrix();
m.setTranslate(previewShiftX, previewShiftY);
bg.getClipPath().transform(m, mask);
Bitmap previewBitmap = BitmapRenderer.createHardwareBitmap(dragViewSize.x, dragViewSize.y, (canvas) -> {
canvas.save();
canvas.translate(previewShiftX, previewShiftY);
icon.getPreviewItemManager().draw(canvas);
canvas.restore();
});
ShiftedBitmapDrawable badge = new ShiftedBitmapDrawable(badgeBmp, 0, 0);
ShiftedBitmapDrawable foreground = new ShiftedBitmapDrawable(previewBitmap, 0, 0);
return new FolderAdaptiveIcon(new ColorDrawable(bg.getBgColor()), foreground, badge, mask);
}
use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.
the class Folder method shouldUseHardwareLayerForAnimation.
private boolean shouldUseHardwareLayerForAnimation(CellLayout currentCellLayout) {
if (ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS.get())
return true;
int folderCount = 0;
final ShortcutAndWidgetContainer container = currentCellLayout.getShortcutsAndWidgets();
for (int i = container.getChildCount() - 1; i >= 0; --i) {
final View child = container.getChildAt(i);
if (child instanceof AppWidgetHostView)
return false;
if (child instanceof FolderIcon)
++folderCount;
}
return folderCount >= MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION;
}
use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.
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);
}
}
}
}
use of com.android.launcher3.tapl.FolderIcon in project android_packages_apps_Trebuchet by LineageOS.
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 BubbleTextView method shouldTextBeVisible.
public boolean shouldTextBeVisible() {
// Text should be visible everywhere but the hotseat.
Object tag = getParent() instanceof FolderIcon ? ((View) getParent()).getTag() : getTag();
ItemInfo info = tag instanceof ItemInfo ? (ItemInfo) tag : null;
return info == null || info.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT;
}
Aggregations