From dfd154f18df53eff5349edfd0c98d4ecdd057f52 Mon Sep 17 00:00:00 2001 From: Abhilasha Chahal Date: Sun, 27 Feb 2022 09:58:49 +0000 Subject: [PATCH] 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 --- src/com/android/launcher3/Launcher.java | 2 +- .../allapps/AlphabeticalAppsList.java | 19 ++++++++++--------- .../launcher3/allapps/BaseAllAppsAdapter.java | 8 ++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 2f9b563073..1cead11cbf 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -651,7 +651,7 @@ public class Launcher extends StatefulActivity implements Launche mDragLayer.onOneHandedModeStateChanged(activated); } - private void initDeviceProfile(InvariantDeviceProfile idp) { + protected void initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile mDeviceProfile = idp.getDeviceProfile(this); if (isInMultiWindowMode()) { diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 16264dae31..7687fea85d 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -84,7 +84,7 @@ public class AlphabeticalAppsList implement private final ArrayList mSearchResults = new ArrayList<>(); private BaseAllAppsAdapter 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 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 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 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 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 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; } diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java index 1d1960d6e2..976284d947 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java @@ -163,10 +163,10 @@ public abstract class BaseAllAppsAdapter ex protected String mEmptySearchMessage; protected int mAppsPerRow; - private final LayoutInflater mLayoutInflater; - private final OnClickListener mOnIconClickListener; - private OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS; - private OnFocusChangeListener mIconFocusListener; + protected final LayoutInflater mLayoutInflater; + protected final OnClickListener mOnIconClickListener; + protected OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS; + protected OnFocusChangeListener mIconFocusListener; // The click listener to send off to the market app, updated each time the search query changes. private OnClickListener mMarketSearchClickListener; private final int mExtraHeight;