mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
Merge "Set max height on TaskMenuView and scroll if too many elements" into main
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user