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

Commit 9dd9090a authored by Hakan Seyalioglu's avatar Hakan Seyalioglu
Browse files

Use the measured height in the ResolverDrawer

This was done to eliminate some jank while the
service target are animating in due to some
inconsistent padding calculation. Tracking the root
cause there has been elusive, so we're temporarily
using the full height given we have bigger rewrites
we want of this component (e.g. migrating to
RecyclerView).

In the meanwhile this has the unwanted side effect of
letting the user maximize all drawers while pulling up.

bug: 34253328
Test: Manually verified behavior and lack of jank.

Change-Id: I3c5f52ed8180ac2da9e5c9f891879980e49728c0
parent ed4cd7a1
Loading
Loading
Loading
Loading
+6 −32
Original line number Diff line number Diff line
@@ -748,6 +748,10 @@ public class ResolverDrawerLayout extends ViewGroup {
        final int widthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
        final int heightSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
        final int widthPadding = getPaddingLeft() + getPaddingRight();

        // Currently we allot more height than is really needed so that the entirety of the
        // sheet may be pulled up.
        // TODO: Restrict the height here to be the right value.
        int heightUsed = getPaddingTop() + getPaddingBottom();

        // Measure always-show children first.
@@ -757,7 +761,7 @@ public class ResolverDrawerLayout extends ViewGroup {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp.alwaysShow && child.getVisibility() != GONE) {
                measureChildWithMargins(child, widthSpec, widthPadding, heightSpec, heightUsed);
                heightUsed += getHeightUsed(child);
                heightUsed += child.getMeasuredHeight();
            }
        }

@@ -769,7 +773,7 @@ public class ResolverDrawerLayout extends ViewGroup {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.alwaysShow && child.getVisibility() != GONE) {
                measureChildWithMargins(child, widthSpec, widthPadding, heightSpec, heightUsed);
                heightUsed += getHeightUsed(child);
                heightUsed += child.getMeasuredHeight();
            }
        }

@@ -785,36 +789,6 @@ public class ResolverDrawerLayout extends ViewGroup {
        setMeasuredDimension(sourceWidth, heightSize);
    }

    private int getHeightUsed(View child) {
        // This method exists because we're taking a fast path at measuring ListViews that
        // lets us get away with not doing the more expensive wrap_content measurement which
        // imposes double child view measurement costs. If we're looking at a ListView, we can
        // check against the lowest child view plus padding and margin instead of the actual
        // measured height of the ListView. This lets the ListView hang off the edge when
        // all of the content would fit on-screen.

        int heightUsed = child.getMeasuredHeight();
        if (child instanceof AbsListView) {
            final AbsListView lv = (AbsListView) child;
            final int lvPaddingBottom = lv.getPaddingBottom();

            int lowest = 0;
            for (int i = 0, N = lv.getChildCount(); i < N; i++) {
                final int bottom = lv.getChildAt(i).getBottom() + lvPaddingBottom;
                if (bottom > lowest) {
                    lowest = bottom;
                }
            }

            if (lowest < heightUsed) {
                heightUsed = lowest;
            }
        }

        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        return lp.topMargin + heightUsed + lp.bottomMargin;
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        final int width = getWidth();