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

Commit d84a5930 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed the redacted layout for groups

Also fixed a bug where the guts didn't have the
right size and in general cleaned up the intrinsic
height. The guts also animate nicely and the position
of their animation starts on the finger.

Change-Id: I62447dd77ace36161740dfdf3d18103524e2eb21
parent 624c02db
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@
        android:id="@+id/notification_guts_stub"
        android:inflatedId="@+id/notification_guts"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_height="wrap_content"
        />

</com.android.systemui.statusbar.ExpandableNotificationRow>
+38 −21
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.PreviewInflater;
import com.android.systemui.statusbar.policy.RemoteInputView;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;

import java.util.ArrayList;
import java.util.List;
@@ -988,9 +989,7 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected SwipeHelper.LongPressListener getNotificationLongClicker() {
        return new SwipeHelper.LongPressListener() {
            @Override
            public boolean onLongPress(View v, int x, int y) {
                dismissPopups();

            public boolean onLongPress(View v, final int x, final int y) {
                if (!(v instanceof ExpandableNotificationRow)) {
                    return false;
                }
@@ -1011,41 +1010,57 @@ public abstract class BaseStatusBar extends SystemUI implements

                // Already showing?
                if (guts.getVisibility() == View.VISIBLE) {
                    Log.e(TAG, "Trying to show notification guts, but already visible");
                    dismissPopups(x, y);
                    return false;
                }

                MetricsLogger.action(mContext, MetricsLogger.ACTION_NOTE_CONTROLS);
                guts.setVisibility(View.VISIBLE);

                // ensure that it's layouted but not visible until actually laid out
                guts.setVisibility(View.INVISIBLE);
                // Post to ensure the the guts are properly layed out.
                guts.post(new Runnable() {
                    public void run() {
                        dismissPopups();
                        guts.setVisibility(View.VISIBLE);
                        final double horz = Math.max(guts.getWidth() - x, x);
                final double vert = Math.max(guts.getActualHeight() - y, y);
                        final double vert = Math.max(guts.getHeight() - y, y);
                        final float r = (float) Math.hypot(horz, vert);
                        final Animator a
                                = ViewAnimationUtils.createCircularReveal(guts, x, y, 0, r);
                a.setDuration(400);
                        a.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
                        a.setInterpolator(mLinearOutSlowIn);
                        a.start();

                        guts.setExposed(true);
                        mStackScroller.onHeightChanged(null, true /* needsAnimation */);
                        mNotificationGutsExposed = guts;

                    }
                });
                return true;
            }
        };
    }

    public void dismissPopups() {
        dismissPopups(-1, -1);
    }

    private void dismissPopups(int x, int y) {
        if (mNotificationGutsExposed != null) {
            final NotificationGuts v = mNotificationGutsExposed;
            mNotificationGutsExposed = null;

            if (v.getWindowToken() == null) return;

            final int x = (v.getLeft() + v.getRight()) / 2;
            final int y = (v.getTop() + v.getActualHeight() / 2);
            if (x == -1 || y == -1) {
                x = (v.getLeft() + v.getRight()) / 2;
                y = (v.getTop() + v.getHeight() / 2);
            }
            final double horz = Math.max(v.getWidth() - x, x);
            final double vert = Math.max(v.getHeight() - y, y);
            final float r = (float) Math.hypot(horz, vert);
            final Animator a = ViewAnimationUtils.createCircularReveal(v,
                    x, y, x, 0);
            a.setDuration(200);
                    x, y, r, 0);
            a.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
            a.setInterpolator(mFastOutLinearIn);
            a.addListener(new AnimatorListenerAdapter() {
                @Override
@@ -1055,6 +1070,8 @@ public abstract class BaseStatusBar extends SystemUI implements
                }
            });
            a.start();
            v.setExposed(false);
            mStackScroller.onHeightChanged(null, true /* needsAnimation */);
        }
    }

+49 −42
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewStub;
@@ -49,7 +48,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {

    private static final int DEFAULT_DIVIDER_ALPHA = 0x29;
    private static final int COLORED_DIVIDER_ALPHA = 0x7B;
    private final LinearInterpolator mLinearInterpolator = new LinearInterpolator();
    private final int mNotificationMinHeightLegacy;
    private final int mMaxHeadsUpHeightLegacy;
    private final int mMaxHeadsUpHeight;
@@ -230,8 +228,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
                : mMaxHeadsUpHeight;
        mRowMinHeight = minHeight;
        mMaxViewHeight = mNotificationMaxHeight;
        mPrivateLayout.setHeights(mRowMinHeight, headsUpheight);
        mPublicLayout.setHeights(mRowMinHeight, headsUpheight);
        mPrivateLayout.setHeights(mRowMinHeight, headsUpheight, mNotificationMaxHeight);
        mPublicLayout.setHeights(mRowMinHeight, headsUpheight, mNotificationMaxHeight);
    }

    public StatusBarNotification getStatusBarNotification() {
@@ -555,12 +553,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }

    private void updateChildrenVisibility() {
        mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? VISIBLE
                : INVISIBLE);
        if (mChildrenContainer == null) {
            return;
        }
        mChildrenContainer.setVisibility(mIsSummaryWithChildren ? VISIBLE : INVISIBLE);
        mNotificationHeader.setVisibility(mIsSummaryWithChildren ? VISIBLE : INVISIBLE);
        mPrivateLayout.setVisibility(!mIsSummaryWithChildren ? VISIBLE : INVISIBLE);
        mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE
                : INVISIBLE);
        mNotificationHeader.setVisibility(!mShowingPublic && mIsSummaryWithChildren ? VISIBLE
                : INVISIBLE);
        // The limits might have changed if the view suddenly became a group or vice versa
        updateLimits();
    }
@@ -722,20 +723,24 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
            return getActualHeight();
        }
        boolean inExpansionState = isExpanded();
        if (mSensitive && mHideSensitiveForIntrinsicHeight) {
            return mRowMinHeight;
        if (mGuts != null && mGuts.areGutsExposed()) {
            return mGuts.getHeight();
        } else if ((isChildInGroup() && !isGroupExpanded())) {
            return mPrivateLayout.getMinHeight();
        } else if (mSensitive && mHideSensitiveForIntrinsicHeight) {
            return getMinHeight();
        } else if (mIsSummaryWithChildren && !mOnKeyguard) {
            return mChildrenContainer.getIntrinsicHeight();
        } else if (mIsHeadsUp) {
            if (inExpansionState) {
                return Math.max(mMaxExpandHeight, mHeadsUpHeight);
                return Math.max(getMaxExpandHeight(), mHeadsUpHeight);
            } else {
                return Math.max(mRowMinHeight, mHeadsUpHeight);
                return Math.max(getMinHeight(), mHeadsUpHeight);
            }
        } else if (!inExpansionState || (isChildInGroup() && !isGroupExpanded())) {
            return getMinHeight();
        } else {
        } else if (inExpansionState) {
            return getMaxExpandHeight();
        } else {
            return getMinHeight();
        }
    }

@@ -842,8 +847,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
            mPublicLayout.setAlpha(1f);
            mPrivateLayout.setAlpha(1f);
            mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
            mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? View.VISIBLE
                    : View.INVISIBLE);
            updateChildrenVisibility();
        } else {
            animateShowingPublic(delay, duration);
        }
@@ -854,28 +858,36 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }

    private void animateShowingPublic(long delay, long duration) {
        final View source = mShowingPublic ? mPrivateLayout : mPublicLayout;
        View target = mShowingPublic ? mPublicLayout : mPrivateLayout;
        source.setVisibility(View.VISIBLE);
        target.setVisibility(View.VISIBLE);
        target.setAlpha(0f);
        source.animate().cancel();
        target.animate().cancel();
        source.animate()
        View[] privateViews = mIsSummaryWithChildren ?
                new View[] {mChildrenContainer, mNotificationHeader}
                : new View[] {mPrivateLayout};
        View[] publicViews = new View[] {mPublicLayout};
        View[] hiddenChildren = mShowingPublic ? privateViews : publicViews;
        View[] shownChildren = mShowingPublic ? publicViews : privateViews;
        for (final View hiddenView : hiddenChildren) {
            hiddenView.setVisibility(View.VISIBLE);
            hiddenView.animate().cancel();
            hiddenView.animate()
                    .alpha(0f)
                    .setStartDelay(delay)
                    .setDuration(duration)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                        source.setVisibility(View.INVISIBLE);
                            hiddenView.setVisibility(View.INVISIBLE);
                        }
                    });
        target.animate()
        }
        for (View showView : shownChildren) {
            showView.setVisibility(View.VISIBLE);
            showView.setAlpha(0f);
            showView.animate().cancel();
            showView.animate()
                    .alpha(1f)
                    .setStartDelay(delay)
                    .setDuration(duration);
        }
    }

    private void updateVetoButton() {
        // public versions cannot be dismissed
@@ -965,11 +977,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return getMinHeight();
    }

    @Override
    protected boolean shouldLimitViewHeight() {
        return !mIsSummaryWithChildren;
    }

    @Override
    public void setClipTopAmount(int clipTopAmount) {
        super.setClipTopAmount(clipTopAmount);
+2 −7
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import android.content.Context;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.android.systemui.R;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;

@@ -54,9 +54,8 @@ public abstract class ExpandableView extends FrameLayout {

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        boolean limitViewHeight = shouldLimitViewHeight();
        final int givenSize = MeasureSpec.getSize(heightMeasureSpec);
        int ownMaxHeight = limitViewHeight ? mMaxViewHeight : Integer.MAX_VALUE;
        int ownMaxHeight = Integer.MAX_VALUE;
        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
        if (heightMode != MeasureSpec.UNSPECIFIED && givenSize != 0) {
            ownMaxHeight = Math.min(givenSize, ownMaxHeight);
@@ -100,10 +99,6 @@ public abstract class ExpandableView extends FrameLayout {
        setMeasuredDimension(width, ownHeight);
    }

    protected boolean shouldLimitViewHeight() {
        return true;
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
+8 −5
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class NotificationContentView extends FrameLayout {
    private boolean mIsChildInGroup;
    private int mSmallHeight;
    private int mHeadsUpHeight;
    private int mNotificationMaxHeight;
    private StatusBarNotification mStatusBarNotification;
    private NotificationGroupManager mGroupManager;
    private RemoteInputController mRemoteInputController;
@@ -115,9 +116,10 @@ public class NotificationContentView extends FrameLayout {
        setOutlineProvider(mOutlineProvider);
    }

    public void setHeights(int smallHeight, int headsUpMaxHeight) {
    public void setHeights(int smallHeight, int headsUpMaxHeight, int maxHeight) {
        mSmallHeight = smallHeight;
        mHeadsUpHeight = headsUpMaxHeight;
        mNotificationMaxHeight = maxHeight;
    }

    @Override
@@ -137,7 +139,7 @@ public class NotificationContentView extends FrameLayout {
            maxChildHeight = Math.max(maxChildHeight, mContractedChild.getMeasuredHeight());
        }
        if (mExpandedChild != null) {
            int size = maxSize;
            int size = Math.min(maxSize, mNotificationMaxHeight);
            ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams();
            if (layoutParams.height >= 0) {
                // An actual height is set
@@ -435,6 +437,9 @@ public class NotificationContentView extends FrameLayout {
        if (!noExpandedChild && mContentHeight == mExpandedChild.getHeight()) {
            return VISIBLE_TYPE_EXPANDED;
        }
        if (mIsChildInGroup && !isGroupExpanded()) {
            return VISIBLE_TYPE_SINGLELINE;
        }

        if (mIsHeadsUp && mHeadsUpChild != null) {
            if (mContentHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
@@ -443,9 +448,7 @@ public class NotificationContentView extends FrameLayout {
                return VISIBLE_TYPE_EXPANDED;
            }
        } else {
            if (mIsChildInGroup && !isGroupExpanded()) {
                return VISIBLE_TYPE_SINGLELINE;
            } else if (mContentHeight <= mSmallHeight || noExpandedChild) {
            if (mContentHeight <= mSmallHeight || noExpandedChild) {
                return VISIBLE_TYPE_CONTRACTED;
            } else {
                return VISIBLE_TYPE_EXPANDED;
Loading