Merge "Set max height on TaskMenuView and scroll if too many elements" into main

This commit is contained in:
Sam Cackett
2024-02-27 17:02:51 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 5 deletions

View File

@@ -35,11 +35,17 @@
android:paddingBottom="@dimen/task_menu_edge_padding"
android:textSize="16sp"/>
<LinearLayout
android:id="@+id/menu_option_layout"
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:showDividers="middle" />
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/menu_option_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:showDividers="middle" />
</ScrollView>
</com.android.quickstep.views.TaskMenuView>

View File

@@ -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;
}