Fix task menu height calculation for bottom row handling.

Adjust the max height calculation logic in on measure to use a different translationY for the bottom row menus. The bottom row menu animates translating up to show more items. Thus, we use the min translationY accepted for the menu to calculate its max height size.

Fix: 326952853
Flag: com.android.launcher3.enable_overview_icon_menu
Test: OverviewMenuImageTest
Change-Id: I0b32c16e020033feccbfeef8f96c196d193ac0cb
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt
index 200fd52..7c762f4 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt
@@ -115,13 +115,9 @@
 
     override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
         var heightMeasure = heightMeasureSpec
-        if (!(enableOverviewIconMenu() && taskView.isOnGridBottomRow())) {
-            // TODO(b/326952853): Cap menu height for grid bottom row in a way that doesn't break
-            // additionalTranslationY.
-            val maxMenuHeight = calculateMaxHeight()
-            if (MeasureSpec.getSize(heightMeasure) > maxMenuHeight) {
-                heightMeasure = MeasureSpec.makeMeasureSpec(maxMenuHeight, MeasureSpec.AT_MOST)
-            }
+        val maxMenuHeight = calculateMaxHeight()
+        if (MeasureSpec.getSize(heightMeasure) > maxMenuHeight) {
+            heightMeasure = MeasureSpec.makeMeasureSpec(maxMenuHeight, MeasureSpec.AT_MOST)
         }
         super.onMeasure(widthMeasureSpec, heightMeasure)
     }
@@ -364,15 +360,20 @@
      * view will scroll. The maximum menu size will sit inside the task with a margin on the top and
      * bottom.
      */
-    private fun calculateMaxHeight(): Int {
-        val taskInsetMargin = resources.getDimension(R.dimen.task_card_margin)
-        return taskView.pagedOrientationHandler.getTaskMenuHeight(
-            taskInsetMargin,
-            recentsViewContainer.deviceProfile,
-            translationX,
-            translationY,
+    private fun calculateMaxHeight(): Int =
+        taskView.pagedOrientationHandler.getTaskMenuHeight(
+            taskInsetMargin = resources.getDimension(R.dimen.task_card_margin), // taskInsetMargin
+            deviceProfile = recentsViewContainer.deviceProfile,
+            taskMenuX = translationX,
+            taskMenuY =
+                when {
+                    !enableOverviewIconMenu() -> translationY
+                    // Bottom menu can translate up to show more options. So we use the min
+                    // translation allowed to calculate its max height.
+                    taskView.isOnGridBottomRow() -> minMenuTop
+                    else -> menuTranslationYBeforeOpen
+                },
         )
-    }
 
     private fun setOnClosingStartCallback(onClosingStartCallback: Runnable?) {
         this.onClosingStartCallback = onClosingStartCallback