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();
}
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]);
}
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();
}
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);
}
}
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;
}
Aggregations