use of com.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns 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.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns 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.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns in project Neo-Launcher by NeoApplications.
the class ConfigBuilder method getViewBounds.
private static Columns getViewBounds(final View view) {
final Columns a = new Columns();
a.iconDistance = view.getWidth();
a.height = view.getHeight();
final int[] array = new int[2];
view.getLocationInWindow(array);
a.edgeMargin = array[0];
a.innerMargin = array[1];
return a;
}
use of com.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns in project Neo-Launcher by NeoApplications.
the class ConfigBuilder method createSearchTemplate.
private void createSearchTemplate() {
mNano.searchTemplate = "search_box_template";
mBundle.putParcelable(mNano.searchTemplate, searchQsbTemplate());
mNano.gIcon = R.id.g_icon;
mNano.micIcon = mQsbLayout.mMicIconView.getVisibility() == View.VISIBLE ? R.id.mic_icon : 0;
final Columns viewBounds = getViewBounds(mActivity.getDragLayer());
final int topShift = mNano.apps.innerMargin + (co ? 0 : mNano.apps.height);
viewBounds.innerMargin += topShift;
viewBounds.height -= topShift;
mNano.viewBounds = viewBounds;
if (viewBounds.iconDistance > 0 && viewBounds.height > 0) {
Bitmap bitmap = BitmapRenderer.createHardwareBitmap(viewBounds.iconDistance, viewBounds.height, out -> a(topShift, out));
mBundle.putParcelable(mNano.view, bitmap);
} else {
String stringBuilder = "Invalid preview bitmap size. width: " + viewBounds.iconDistance + "hight: " + viewBounds.height + " top shift: " + topShift;
Log.e("ConfigBuilder", stringBuilder);
viewBounds.height = 0;
viewBounds.edgeMargin = 0;
viewBounds.innerMargin = 0;
viewBounds.iconDistance = 0;
Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
bitmap.setPixel(0, 0, 0);
mBundle.putParcelable(mNano.view, bitmap);
}
}
use of com.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns in project Neo-Launcher by NeoApplications.
the class ConfigBuilder method updateHotseatSearchDimens.
private void updateHotseatSearchDimens() {
if (mNano.appsView != null) {
return;
}
final Columns apps = mNano.apps;
final Columns appsView = new Columns();
appsView.edgeMargin = apps.edgeMargin;
appsView.innerMargin = apps.innerMargin + apps.height;
appsView.height = apps.height;
appsView.iconDistance = apps.iconDistance;
mNano.appsView = appsView;
}
Aggregations