Use numAllAppsColumns to calculate height of all apps icons

Additionally opens up access of some fields to allow them to be overridden.

Test: Manually verified that Launcher3 layout does not change

Launcher3 APKs: https://drive.google.com/drive/folders/1hBcZU9xou4tZJxbTmkya_LyBbD2oYuwV?resourcekey=0-R0I1IQ2rSUIEfPjW8S_ppA&usp=sharing

Bug: 216150572

Change-Id: I4b97a7e9e15973fc5aa70a4b98f0b73dd5bf3c17
This commit is contained in:
Abhilasha Chahal
2022-02-27 09:58:49 +00:00
parent f3d81b0a1c
commit dfd154f18d
3 changed files with 15 additions and 14 deletions

View File

@@ -84,7 +84,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
private final ArrayList<AdapterItem> mSearchResults = new ArrayList<>();
private BaseAllAppsAdapter<T> mAdapter;
private AppInfoComparator mAppNameComparator;
private final int mNumAppsPerRow;
private final int mNumAppsPerRowAllApps;
private int mNumAppRowsInAdapter;
private ItemInfoMatcher mItemFilter;
@@ -94,7 +94,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
mActivityContext = ActivityContext.lookupContext(context);
mAppNameComparator = new AppInfoComparator(context);
mWorkAdapterProvider = adapterProvider;
mNumAppsPerRow = mActivityContext.getDeviceProfile().inv.numColumns;
mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
mAllAppsStore.addUpdateListener(this);
}
@@ -336,7 +336,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
}
}
if (mNumAppsPerRow != 0) {
if (mNumAppsPerRowAllApps != 0) {
// Update the number of rows in the adapter after we do all the merging (otherwise, we
// would have to shift the values again)
int numAppsInSection = 0;
@@ -344,10 +344,10 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
int rowIndex = -1;
for (AdapterItem item : mAdapterItems) {
item.rowIndex = 0;
if (AllAppsGridAdapter.isDividerViewType(item.viewType)) {
if (BaseAllAppsAdapter.isDividerViewType(item.viewType)) {
numAppsInSection = 0;
} else if (AllAppsGridAdapter.isIconViewType(item.viewType)) {
if (numAppsInSection % mNumAppsPerRow == 0) {
} else if (BaseAllAppsAdapter.isIconViewType(item.viewType)) {
if (numAppsInSection % mNumAppsPerRowAllApps == 0) {
numAppsInRow = 0;
rowIndex++;
}
@@ -365,12 +365,13 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
float rowFraction = 1f / mNumAppRowsInAdapter;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
float subRowFraction =
item.rowAppIndex * (rowFraction / mNumAppsPerRowAllApps);
info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
}
break;
@@ -379,7 +380,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
float cumulativeTouchFraction = 0f;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}