From fa0a2d3d90fdde14784ec6351a0798bc21c2f126 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 14 Jan 2016 13:02:21 -0800 Subject: [PATCH] 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 --- .../statusbar/ExpandableNotificationRow.java | 8 ++++++++ .../statusbar/NotificationContentView.java | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 1c1ae26d18d4b..f80630b6317b6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -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; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java index 5da0e9ce7bc67..36cf906c4aa7c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java @@ -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); + } }