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

Commit 388df6dd authored by Selim Cinek's avatar Selim Cinek
Browse files

Allow expanding notification groups by dragging down

Bug: 24866646
Change-Id: Ie7c5ee6753c2f246df04189bb92e08baf0242797
parent 83bc7833
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.media.AudioAttributes;
import android.os.Vibrator;
import android.util.Log;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
@@ -144,8 +142,8 @@ public class ExpandHelper implements Gefingerpoken {
        public float getHeight() {
            return mView.getActualHeight();
        }
        public int getNaturalHeight(int maximum) {
            return Math.min(maximum, mView.getMaxContentHeight());
        public int getNaturalHeight() {
            return mView.getMaxContentHeight();
        }
    }

@@ -194,7 +192,7 @@ public class ExpandHelper implements Gefingerpoken {

    private float clamp(float target) {
        float out = target;
        out = out < mSmallSize ? mSmallSize : (out > mLargeSize ? mLargeSize : out);
        out = out < mSmallSize ? mSmallSize : out;
        out = out > mNaturalHeight ? mNaturalHeight : out;
        return out;
    }
@@ -381,8 +379,8 @@ public class ExpandHelper implements Gefingerpoken {
    }

    private boolean isFullyExpanded(ExpandableView underFocus) {
        return underFocus.areChildrenExpanded() || underFocus.getIntrinsicHeight()
                - underFocus.getBottomDecorHeight() == underFocus.getMaxContentHeight();
        return underFocus.getIntrinsicHeight() == underFocus.getMaxContentHeight()
                && (!underFocus.isSummaryWithChildren() || underFocus.areChildrenExpanded());
    }

    @Override
@@ -452,9 +450,7 @@ public class ExpandHelper implements Gefingerpoken {
                    mScaler.setHeight(newHeight);
                    mLastMotionY = ev.getRawY();
                    if (isFinished) {
                        mCallback.setUserExpandedChild(mResizedView, expanded);
                        mCallback.expansionStateChanged(false);
                        return false;
                    } else {
                        mCallback.expansionStateChanged(true);
                    }
@@ -509,9 +505,11 @@ public class ExpandHelper implements Gefingerpoken {
        mScaler.setView(v);
        mOldHeight = mScaler.getHeight();
        mCurrentHeight = mOldHeight;
        if (mCallback.canChildBeExpanded(v)) {
        boolean canBeExpanded = mCallback.canChildBeExpanded(v);
        if (canBeExpanded) {
            if (DEBUG) Log.d(TAG, "working on an expandable child");
            mNaturalHeight = mScaler.getNaturalHeight(mLargeSize);
            mNaturalHeight = mScaler.getNaturalHeight();
            mSmallSize = v.getMinHeight();
        } else {
            if (DEBUG) Log.d(TAG, "working on a non-expandable child");
            mNaturalHeight = mOldHeight;
@@ -527,19 +525,22 @@ public class ExpandHelper implements Gefingerpoken {
        if (DEBUG) Log.d(TAG, "scale in finishing on view: " + mResizedView);

        float currentHeight = mScaler.getHeight();
        float targetHeight = mSmallSize;
        float h = mScaler.getHeight();
        final boolean wasClosed = (mOldHeight == mSmallSize);
        boolean nowExpanded;
        int naturalHeight = mScaler.getNaturalHeight();
        if (wasClosed) {
            targetHeight = (force || currentHeight > mSmallSize) ? mNaturalHeight : mSmallSize;
            nowExpanded = (force || currentHeight > mOldHeight);
        } else {
            targetHeight = (force || currentHeight < mNaturalHeight) ? mSmallSize : mNaturalHeight;
            nowExpanded = !force && currentHeight >= mOldHeight;
        }
        nowExpanded |= mNaturalHeight == mSmallSize;
        if (mScaleAnimation.isRunning()) {
            mScaleAnimation.cancel();
        }
        mCallback.setUserExpandedChild(mResizedView, targetHeight == mNaturalHeight);
        mCallback.setUserExpandedChild(mResizedView, nowExpanded);
        mCallback.expansionStateChanged(false);
        float targetHeight = nowExpanded ? naturalHeight : mSmallSize;
        if (targetHeight != currentHeight) {
            mScaleAnimation.setFloatValues(targetHeight);
            mScaleAnimation.setupStartValues();
+24 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private NotificationData.Entry mEntry;
    private boolean mShowNoBackground;
    private boolean mChildInGroup;
    private ExpandableNotificationRow mNotificationParent;

    public NotificationContentView getPrivateLayout() {
        return mPrivateLayout;
@@ -220,12 +221,17 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return mChildInGroup;
    }

    public ExpandableNotificationRow getNotificationParent() {
        return mNotificationParent;
    }

    /**
     * @param isChildInGroup Is this notification now in a group
     * @param parent the new parent notification
     */
    public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {
        mChildInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup;
        mNotificationParent = isChildInGroup ? parent : null;
        mShowNoBackground = mChildInGroup && hasSameBgColor(parent);
        mPrivateLayout.setIsChildInGroup(mShowNoBackground);
        updateBackground();
@@ -472,6 +478,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
            @Override
            public void onInflate(ViewStub stub, View inflated) {
                mChildrenContainer = (NotificationChildrenContainer) inflated;
                mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this);
            }
        });
        mVetoButton = findViewById(R.id.veto);
@@ -520,6 +527,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }

    public boolean isExpandable() {
        if (mIsSummaryWithChildren && !mShowingPublic) {
            return !mChildrenExpanded;
        }
        return mExpandable;
    }

@@ -544,7 +554,21 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
     * @param userExpanded whether the user wants this notification to be expanded
     */
    public void setUserExpanded(boolean userExpanded) {
        setUserExpanded(userExpanded, false /* allowChildExpansion */);
    }

    /**
     * Set this notification to be expanded by the user
     *
     * @param userExpanded whether the user wants this notification to be expanded
     * @param allowChildExpansion whether a call to this method allows expanding children
     */
    public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) {
        mFalsingManager.setNotificationExpanded();
        if (mIsSummaryWithChildren && !mShowingPublic && allowChildExpansion) {
            mGroupManager.setGroupExpanded(mStatusBarNotification, userExpanded);
            return;
        }
        if (userExpanded && !mExpandable) return;
        final boolean wasExpanded = isExpanded();
        mHasUserChangedExpansion = true;
+4 −0
Original line number Diff line number Diff line
@@ -452,6 +452,10 @@ public class NotificationChildrenContainer extends ViewGroup {
        mChildrenExpanded = childrenExpanded;
    }

    public void setNotificationParent(ExpandableNotificationRow parent) {
        mNotificationParent = parent;
    }

    public int getMaxContentHeight() {
        return getIntrinsicHeight(NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
    }
+9 −2
Original line number Diff line number Diff line
@@ -747,7 +747,8 @@ public class NotificationStackScrollLayout extends ViewGroup

    public void setUserExpandedChild(View v, boolean userExpanded) {
        if (v instanceof ExpandableNotificationRow) {
            ((ExpandableNotificationRow) v).setUserExpanded(userExpanded);
            ((ExpandableNotificationRow) v).setUserExpanded(userExpanded,
                    true /* allowChildrenExpansion */);
        }
    }

@@ -2344,7 +2345,13 @@ public class NotificationStackScrollLayout extends ViewGroup
            ExpandableNotificationRow row = (ExpandableNotificationRow) view;
            if (row.isUserLocked() && row != getFirstChildNotGone()) {
                // We are actually expanding this view
                float endPosition = row.getTranslationY() + row.getActualHeight();
                float endPosition;
                if (row.isChildInGroup()) {
                    ExpandableNotificationRow parent = row.getNotificationParent();
                    endPosition = parent.getTranslationY() + parent.getActualHeight();
                } else {
                    endPosition = row.getTranslationY() + row.getActualHeight();
                }
                int stackEnd = mMaxLayoutHeight - mBottomStackPeekSize -
                        mBottomStackSlowDownHeight + (int) mStackTranslation;
                if (endPosition > stackEnd) {