Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8acc233a authored by Louis Chang's avatar Louis Chang Committed by Automerger Merge Worker
Browse files

Merge "Avoid activity positioned on top of always-on-top activities" into...

Merge "Avoid activity positioned on top of always-on-top activities" into sc-v2-dev am: 74c8a710 am: a0ea6925

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14972762

Change-Id: I45dcb6b18fa80a7b5ea9ef15db60c9059bb0e7cb
parents 364cd8f4 a0ea6925
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -2418,17 +2418,16 @@ class Task extends TaskFragment {

        // Figure-out min/max possible position depending on if child can show for current user.
        int minPosition = (canShowChild) ? computeMinUserPosition(0, size) : 0;
        int maxPosition = (canShowChild) ? size - 1 : computeMaxUserPosition(size - 1);
        if (!hasChild(wc)) {
            // Increase the maxPosition because children size will grow once wc is added.
            ++maxPosition;
        int maxPosition = minPosition;
        if (size > 0) {
            maxPosition = (canShowChild) ? size - 1 : computeMaxUserPosition(size - 1);
        }

        // Factor in always-on-top children in max possible position.
        if (!wc.isAlwaysOnTop()) {
            // We want to place all non-always-on-top containers below always-on-top ones.
            while (maxPosition > minPosition) {
                if (!mChildren.get(maxPosition - 1).isAlwaysOnTop()) break;
                if (!mChildren.get(maxPosition).isAlwaysOnTop()) break;
                --maxPosition;
            }
        }
@@ -2439,6 +2438,12 @@ class Task extends TaskFragment {
        } else if (suggestedPosition == POSITION_TOP && maxPosition >= (size - 1)) {
            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.
        return Math.min(Math.max(suggestedPosition, minPosition), maxPosition);
    }