From 434180ce5155f0c405080698031f05e9eab3dd4c Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 13 Feb 2017 11:29:42 -0800 Subject: [PATCH] Fix notification shelf icon showing on top of snooze leave behind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixes an issue where the guts closed listener would always call onHeightChanged because the notification isn’t marked as removed until after the listener gets called. Fixes: 34866027 Test: Manual - have one notification, snooze it Change-Id: Ic67bdb353b8bb5df8bdaaf6d3e71ade7da05ee46 --- .../plugins/statusbar/NotificationMenuRowProvider.java | 2 ++ .../systemui/statusbar/ExpandableNotificationRow.java | 3 +++ .../com/android/systemui/statusbar/NotificationGuts.java | 4 ++++ .../com/android/systemui/statusbar/NotificationInfo.java | 5 +++++ .../com/android/systemui/statusbar/NotificationShelf.java | 7 ++++--- .../com/android/systemui/statusbar/NotificationSnooze.java | 7 +++++++ .../com/android/systemui/statusbar/phone/StatusBar.java | 2 +- 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowProvider.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowProvider.java index 41a0907c32285..f2069b8280de2 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowProvider.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowProvider.java @@ -40,6 +40,8 @@ public interface NotificationMenuRowProvider extends Plugin { public View getContentView(); public boolean handleCloseControls(boolean save); + + public boolean willBeRemoved(); } public interface SnoozeGutsContent extends GutsContent { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 2e9c7fd85e420..a2b0de52cca53 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -879,6 +879,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { * @return whether the notification is currently showing a view with an icon. */ public boolean isShowingIcon() { + if (areGutsExposed()) { + return false; + } if (mIsSummaryWithChildren) { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java index b36cfdca1a469..fd1317e614367 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java @@ -244,6 +244,10 @@ public class NotificationGuts extends FrameLayout } } + public boolean willBeRemoved() { + return mGutsContent != null ? mGutsContent.willBeRemoved() : false; + } + public boolean isExposed() { return mExposed; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java index 5d13e61327ae8..970323523904b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java @@ -273,6 +273,11 @@ public class NotificationInfo extends LinearLayout implements GutsContent { mGutsInteractionListener = listener; } + @Override + public boolean willBeRemoved() { + return !mChannelEnabledSwitch.isChecked(); + } + @Override public View getContentView() { return this; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 2425076a44428..61574a642e779 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -379,11 +379,12 @@ public class NotificationShelf extends ActivatableNotificationView { : 0.0f; row.setContentTransformationAmount(contentTransformationAmount, isLastChild); setIconTransformationAmount(row, transitionAmount, iconTransformDistance, - clampedAmount != transitionAmount); + clampedAmount != transitionAmount, isLastChild); } private void setIconTransformationAmount(ExpandableNotificationRow row, - float transitionAmount, float iconTransformDistance, boolean usingLinearInterpolation) { + float transitionAmount, float iconTransformDistance, boolean usingLinearInterpolation, + boolean isLastChild) { StatusBarIconView icon = row.getEntry().expandedIcon; NotificationIconContainer.IconState iconState = getIconState(icon); @@ -435,7 +436,7 @@ public class NotificationShelf extends ActivatableNotificationView { iconState.scaleY = 1.0f; iconState.hidden = false; } - if (row.isAboveShelf()) { + if (row.isAboveShelf() || (!row.isInShelf() && isLastChild && row.areGutsExposed())) { iconState.hidden = true; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSnooze.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSnooze.java index 0657dc1e86f73..6b1e62d9ad713 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSnooze.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSnooze.java @@ -56,6 +56,7 @@ public class NotificationSnooze extends LinearLayout private TextView mUndoButton; private ViewGroup mSnoozeOptionView; private List mSnoozeOptions; + private boolean mSnoozing; private SnoozeOption mSelectedOption; @@ -174,6 +175,11 @@ public class NotificationSnooze extends LinearLayout mGutsInteractionListener.closeGuts(this); } + @Override + public boolean willBeRemoved() { + return mSnoozing; + } + @Override public View getContentView() { return this; @@ -199,6 +205,7 @@ public class NotificationSnooze extends LinearLayout // When snooze is closed (i.e. there was interaction outside of the notification) // then we commit the snooze action. if (mSnoozeListener != null && mSelectedOption != null) { + mSnoozing = true; mSnoozeListener.snoozeNotification(mSbn, mSelectedOption); return true; } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index bc43663ba2613..9d969218408c8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -5753,7 +5753,7 @@ public class StatusBar extends SystemUI implements DemoMode, row.setTag(sbn.getPackageName()); final NotificationGuts guts = row.getGuts(); guts.setClosedListener((NotificationGuts g) -> { - if (!row.isRemoved()) { + if (!g.willBeRemoved() && !row.isRemoved()) { mStackScroller.onHeightChanged(row, !isPanelFullyCollapsed() /* needsAnimation */); } mNotificationGutsExposed = null;