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

Commit 2a164283 authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Gerrit Code Review
Browse files

systemui: adjust position of clear recents button



If there is a statusbar then align to it. Otherwise aling to task views rather than top/right.
This patch fixed the position in tablets (align it with the search bar) and in landscape mode
(reducing the space between task views and the clear recents button), with is a more consistent
ui because the button is always properly aligned with the recent task views.

Change-Id: Ic867d5421cacba627c4b844db3d3715f20a4444c
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent 55d1ddee
Loading
Loading
Loading
Loading
+24 −9
Original line number Diff line number Diff line
@@ -270,8 +270,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
        int height = MeasureSpec.getSize(heightMeasureSpec);

        // Get the search bar bounds and measure the search bar layout
        if (mSearchBar != null) {
        Rect searchBarSpaceBounds = new Rect();
        if (mSearchBar != null) {
            mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
            mSearchBar.measure(
                    MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
@@ -282,17 +282,10 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
        mConfig.getTaskStackBounds(width, height, mConfig.systemInsets.top,
                mConfig.systemInsets.right, taskStackBounds);

        if (mClearRecents != null) {
            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)
                    mClearRecents.getLayoutParams();
            params.topMargin = taskStackBounds.top;
            params.rightMargin = width - taskStackBounds.right;
            mClearRecents.setLayoutParams(params);
        }

        // Measure each TaskStackView with the full width and height of the window since the 
        // transition view is a child of that stack view
        int childCount = getChildCount();
        int taskViewWidth = 0;
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (child != mSearchBar && child.getVisibility() != GONE) {
@@ -300,7 +293,29 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                // Set the insets to be the top/left inset + search bounds
                tsv.setStackInsetRect(taskStackBounds);
                tsv.measure(widthMeasureSpec, heightMeasureSpec);

                // Retrieve the max width of the task views
                int taskViewChildCount = tsv.getChildCount();
                for (int j = 0; j < taskViewChildCount; j++) {
                    View taskViewChild = tsv.getChildAt(j);
                    taskViewWidth = Math.max(taskViewChild.getMeasuredWidth(), taskViewWidth);
                }

            }
        }

        if (mClearRecents != null) {
            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)
                    mClearRecents.getLayoutParams();
            params.topMargin = taskStackBounds.top;
            if (mSearchBar != null && (searchBarSpaceBounds.width() > taskViewWidth)) {
                // Adjust to the search bar
                params.rightMargin = width - searchBarSpaceBounds.right;
            } else {
                // Adjust to task views
                params.rightMargin = (width / 2) - (taskViewWidth / 2);
            }
            mClearRecents.setLayoutParams(params);
        }

        setMeasuredDimension(width, height);