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
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 2f9b563..1cead11 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -651,7 +651,7 @@
         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 16264da..7687fea 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -84,7 +84,7 @@
     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 @@
         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 @@
 
             }
         }
-        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 @@
             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 @@
                     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 @@
                     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 1d1960d..976284d 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
@@ -163,10 +163,10 @@
     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;