From 6c93e88fafbf673897ed09f95528bd8e26b1a0cb Mon Sep 17 00:00:00 2001 From: samcackett Date: Mon, 26 Feb 2024 16:21:12 +0000 Subject: [PATCH] Set max height on TaskMenuView and scroll if too many elements Video of functionality: http://shortn/_pz6qhz5yxM Fixes: 210466650 Test: Manual Flag: NONE Change-Id: I8b7873cf03857ee3be047ab30388e679f7a95bfd --- quickstep/res/layout/task_menu.xml | 16 +++++++++---- .../android/quickstep/views/TaskMenuView.java | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/quickstep/res/layout/task_menu.xml b/quickstep/res/layout/task_menu.xml index 622edfeba0..b6d87866f7 100644 --- a/quickstep/res/layout/task_menu.xml +++ b/quickstep/res/layout/task_menu.xml @@ -35,11 +35,17 @@ android:paddingBottom="@dimen/task_menu_edge_padding" android:textSize="16sp"/> - + android:layout_height="wrap_content"> + + + + \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index a5e89896ac..2826a8f62e 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -136,6 +136,17 @@ public class TaskMenuView extends AbstractFloatingView { }; } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (!enableOverviewIconMenu()) { + int maxMenuHeight = calculateMaxHeight(); + if (MeasureSpec.getSize(heightMeasureSpec) > maxMenuHeight) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxMenuHeight, MeasureSpec.AT_MOST); + } + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + public void onRotationChanged() { if (mOpenCloseAnimator != null && mOpenCloseAnimator.isRunning()) { mOpenCloseAnimator.end(); @@ -393,6 +404,18 @@ public class TaskMenuView extends AbstractFloatingView { return new RoundedRectRevealOutlineProvider(radius, radius, fromRect, toRect); } + /** + * Calculates max height based on how much space we have available. + * If not enough space then the view will scroll. The maximum menu size will sit inside the task + * with a margin on the top and bottom. + */ + private int calculateMaxHeight() { + float taskBottom = mTaskView.getHeight() + mTaskView.getPersistentTranslationY(); + float taskInsetMargin = getResources().getDimension(R.dimen.task_card_margin); + + return (int) (taskBottom - taskInsetMargin - getTranslationY()); + } + private void setOnClosingStartCallback(Runnable onClosingStartCallback) { mOnClosingStartCallback = onClosingStartCallback; }