Merge "Avoid activity positioned on top of always-on-top activities" into sc-v2-dev

This commit is contained in:
Louis Chang
2021-06-16 11:14:07 +00:00
committed by Android (Google) Code Review

View File

@@ -2418,17 +2418,16 @@ class Task extends TaskFragment {
// Figure-out min/max possible position depending on if child can show for current user. // Figure-out min/max possible position depending on if child can show for current user.
int minPosition = (canShowChild) ? computeMinUserPosition(0, size) : 0; int minPosition = (canShowChild) ? computeMinUserPosition(0, size) : 0;
int maxPosition = (canShowChild) ? size - 1 : computeMaxUserPosition(size - 1); int maxPosition = minPosition;
if (!hasChild(wc)) { if (size > 0) {
// Increase the maxPosition because children size will grow once wc is added. maxPosition = (canShowChild) ? size - 1 : computeMaxUserPosition(size - 1);
++maxPosition;
} }
// Factor in always-on-top children in max possible position. // Factor in always-on-top children in max possible position.
if (!wc.isAlwaysOnTop()) { if (!wc.isAlwaysOnTop()) {
// We want to place all non-always-on-top containers below always-on-top ones. // We want to place all non-always-on-top containers below always-on-top ones.
while (maxPosition > minPosition) { while (maxPosition > minPosition) {
if (!mChildren.get(maxPosition - 1).isAlwaysOnTop()) break; if (!mChildren.get(maxPosition).isAlwaysOnTop()) break;
--maxPosition; --maxPosition;
} }
} }
@@ -2439,6 +2438,12 @@ class Task extends TaskFragment {
} else if (suggestedPosition == POSITION_TOP && maxPosition >= (size - 1)) { } else if (suggestedPosition == POSITION_TOP && maxPosition >= (size - 1)) {
return POSITION_TOP; return POSITION_TOP;
} }
// Increase the maxPosition because children size will grow once wc is added.
if (!hasChild(wc)) {
++maxPosition;
}
// Reset position based on minimum/maximum possible positions. // Reset position based on minimum/maximum possible positions.
return Math.min(Math.max(suggestedPosition, minPosition), maxPosition); return Math.min(Math.max(suggestedPosition, minPosition), maxPosition);
} }