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

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

The notification content now switches earlier

The notification content visible is now based on the intrinsic
height of the view and not just the actual height anymore.
This allows notifications to switch earlier when clicking on
the collapse button.

Change-Id: Icdf4ea50a7b1bbb78bd57a9f1c3eea25cf9c8d7c
parent c848c3a1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -551,8 +551,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    protected void onFinishInflate() {
        super.onFinishInflate();
        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
        mPublicLayout.setContainingNotification(this);
        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
        mPrivateLayout.setExpandClickListener(mExpandClickListener);
        mPrivateLayout.setContainingNotification(this);
        mPublicLayout.setExpandClickListener(mExpandClickListener);
        mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
        mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
@@ -860,6 +862,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    @Override
    public void notifyHeightChanged(boolean needsAnimation) {
        super.notifyHeightChanged(needsAnimation);
        getShowingLayout().requestSelectLayout(needsAnimation || isUserLocked());
    }

    public void setSensitive(boolean sensitive) {
        mSensitive = sensitive;
    }
+13 −3
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class NotificationContentView extends FrameLayout {
    private boolean mBeforeN;
    private boolean mExpandable;
    private boolean mClipToActualHeight = true;
    private ExpandableNotificationRow mContainingNotification;

    public NotificationContentView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -468,7 +469,8 @@ public class NotificationContentView extends FrameLayout {
    private int calculateVisibleType() {
        boolean noExpandedChild = mExpandedChild == null;

        if (!noExpandedChild && mContentHeight == mExpandedChild.getHeight()) {
        int viewHeight = Math.min(mContentHeight, mContainingNotification.getIntrinsicHeight());
        if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
            return VISIBLE_TYPE_EXPANDED;
        }
        if (mIsChildInGroup && !isGroupExpanded()) {
@@ -476,13 +478,13 @@ public class NotificationContentView extends FrameLayout {
        }

        if (mIsHeadsUp && mHeadsUpChild != null) {
            if (mContentHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
            if (viewHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
                return VISIBLE_TYPE_HEADSUP;
            } else {
                return VISIBLE_TYPE_EXPANDED;
            }
        } else {
            if (mContentHeight <= mContractedChild.getHeight() || noExpandedChild) {
            if (viewHeight <= mContractedChild.getHeight() || noExpandedChild) {
                return VISIBLE_TYPE_CONTRACTED;
            } else {
                return VISIBLE_TYPE_EXPANDED;
@@ -666,4 +668,12 @@ public class NotificationContentView extends FrameLayout {
        }
        return header;
    }

    public void setContainingNotification(ExpandableNotificationRow containingNotification) {
        mContainingNotification = containingNotification;
    }

    public void requestSelectLayout(boolean needsAnimation) {
        selectLayout(needsAnimation, false);
    }
}