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

Commit adad5c91 authored by Andrey Epin's avatar Andrey Epin Committed by Android (Google) Code Review
Browse files

Merge "Fix Resolver dragging animation" into tm-qpr-dev

parents 562d88f2 2e1805e8
Loading
Loading
Loading
Loading
+59 −1
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@

package com.android.internal.widget;

import static android.content.res.Resources.ID_NULL;

import android.annotation.IdRes;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -96,6 +99,8 @@ public class ResolverDrawerLayout extends ViewGroup {

    private int mTopOffset;
    private boolean mShowAtTop;
    @IdRes
    private int mIgnoreOffsetTopLimitViewId = ID_NULL;

    private boolean mIsDragging;
    private boolean mOpenOnClick;
@@ -156,6 +161,10 @@ public class ResolverDrawerLayout extends ViewGroup {
        mIsMaxCollapsedHeightSmallExplicit =
                a.hasValue(R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall);
        mShowAtTop = a.getBoolean(R.styleable.ResolverDrawerLayout_showAtTop, false);
        if (a.hasValue(R.styleable.ResolverDrawerLayout_ignoreOffsetTopLimit)) {
            mIgnoreOffsetTopLimitViewId = a.getResourceId(
                    R.styleable.ResolverDrawerLayout_ignoreOffsetTopLimit, ID_NULL);
        }
        a.recycle();

        mScrollIndicatorDrawable = mContext.getDrawable(R.drawable.scroll_indicator_material);
@@ -577,12 +586,32 @@ public class ResolverDrawerLayout extends ViewGroup {
                dy -= 1.0f;
            }

            boolean isIgnoreOffsetLimitSet = false;
            int ignoreOffsetLimit = 0;
            View ignoreOffsetLimitView = findIgnoreOffsetLimitView();
            if (ignoreOffsetLimitView != null) {
                LayoutParams lp = (LayoutParams) ignoreOffsetLimitView.getLayoutParams();
                ignoreOffsetLimit = ignoreOffsetLimitView.getBottom() + lp.bottomMargin;
                isIgnoreOffsetLimitSet = true;
            }
            final int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                final View child = getChildAt(i);
                if (child.getVisibility() == View.GONE) {
                    continue;
                }
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (!lp.ignoreOffset) {
                    child.offsetTopAndBottom((int) dy);
                } else if (isIgnoreOffsetLimitSet) {
                    int top = child.getTop();
                    int targetTop = Math.max(
                            (int) (ignoreOffsetLimit + lp.topMargin + dy),
                            lp.mFixedTop);
                    if (top != targetTop) {
                        child.offsetTopAndBottom(targetTop - top);
                    }
                    ignoreOffsetLimit = child.getBottom() + lp.bottomMargin;
                }
            }
            final boolean isCollapsedOld = mCollapseOffset != 0;
@@ -1024,6 +1053,8 @@ public class ResolverDrawerLayout extends ViewGroup {
        final int rightEdge = width - getPaddingRight();
        final int widthAvailable = rightEdge - leftEdge;

        boolean isIgnoreOffsetLimitSet = false;
        int ignoreOffsetLimit = 0;
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
@@ -1036,10 +1067,25 @@ public class ResolverDrawerLayout extends ViewGroup {
                continue;
            }

            if (mIgnoreOffsetTopLimitViewId != ID_NULL && !isIgnoreOffsetLimitSet) {
                if (mIgnoreOffsetTopLimitViewId == child.getId()) {
                    ignoreOffsetLimit = child.getBottom() + lp.bottomMargin;
                    isIgnoreOffsetLimitSet = true;
                }
            }

            int top = ypos + lp.topMargin;
            if (lp.ignoreOffset) {
                if (!isDragging()) {
                    lp.mFixedTop = (int) (top - mCollapseOffset);
                }
                if (isIgnoreOffsetLimitSet) {
                    top = Math.max(ignoreOffsetLimit + lp.topMargin, (int) (top - mCollapseOffset));
                    ignoreOffsetLimit = top + child.getMeasuredHeight() + lp.bottomMargin;
                } else {
                    top -= mCollapseOffset;
                }
            }
            final int bottom = top + child.getMeasuredHeight();

            final int childWidth = child.getMeasuredWidth();
@@ -1102,11 +1148,23 @@ public class ResolverDrawerLayout extends ViewGroup {
        mCollapsibleHeightReserved = ss.mCollapsibleHeightReserved;
    }

    private View findIgnoreOffsetLimitView() {
        if (mIgnoreOffsetTopLimitViewId == ID_NULL) {
            return null;
        }
        View v = findViewById(mIgnoreOffsetTopLimitViewId);
        if (v != null && v != this && v.getParent() == this && v.getVisibility() != View.GONE) {
            return v;
        }
        return null;
    }

    public static class LayoutParams extends MarginLayoutParams {
        public boolean alwaysShow;
        public boolean ignoreOffset;
        public boolean hasNestedScrollIndicator;
        public int maxHeight;
        int mFixedTop;

        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
    android:maxWidth="@dimen/resolver_max_width"
    android:maxCollapsedHeight="@dimen/resolver_max_collapsed_height"
    android:maxCollapsedHeightSmall="56dp"
    android:ignoreOffsetTopLimit="@id/title_container"
    android:id="@id/contentPanel">

    <RelativeLayout
+6 −0
Original line number Diff line number Diff line
@@ -9560,6 +9560,12 @@
        <attr name="maxCollapsedHeightSmall" format="dimension" />
        <!-- Whether the Drawer should be positioned at the top rather than at the bottom. -->
        <attr name="showAtTop" format="boolean" />
        <!-- By default `ResolverDrawerLayout`’s children views with `layout_ignoreOffset` property
             set to true have a fixed position in the layout that won’t be affected by the drawer’s
             movements. This property alternates that behavior. It specifies a child view’s id that
             will push all ignoreOffset siblings below it when the drawer is moved i.e. setting the
             top limit the ignoreOffset elements. -->
        <attr name="ignoreOffsetTopLimit" format="reference" />
    </declare-styleable>
    <declare-styleable name="MessagingLinearLayout">