diff options
2 files changed, 145 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 05d71967321f..24f27ecfcd5b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -111,6 +111,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationChildrenCon import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainerLogger; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.SwipeableView; +import com.android.systemui.statusbar.phone.ExpandHeadsUpOnInlineReply; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.InflatedSmartReplyState; @@ -354,6 +355,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView nowExpanded = !isExpanded(); setUserExpanded(nowExpanded); } + + if (ExpandHeadsUpOnInlineReply.isEnabled() && mExpandable) { + // it is triggered by the user. + // So, mHasUserChangedExpansion should be marked true. + mHasUserChangedExpansion = true; + } + notifyHeightChanged(/* needsAnimation= */ true); mOnExpandClickListener.onExpandClicked(mEntry, v, nowExpanded); mMetricsLogger.action(MetricsEvent.ACTION_NOTIFICATION_EXPANDER, nowExpanded); @@ -2845,9 +2853,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } public boolean isExpanded(boolean allowOnKeyguard) { + // System expanded should be ignored in heads up state + final boolean isHeadsUpState = ExpandHeadsUpOnInlineReply.isEnabled() + && canShowHeadsUp() && isHeadsUpState(); + // Heads Up Notification can be expanded when it is pinned. + final boolean isPinnedAndExpanded = + isHeadsUpState && isPinnedAndExpanded(); return (!shouldShowPublic()) && (!mOnKeyguard || allowOnKeyguard) - && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) - || isUserExpanded()); + && (!hasUserChangedExpansion() && !isHeadsUpState + && (isSystemExpanded() || isSystemChildExpanded()) + || isUserExpanded() || isPinnedAndExpanded); } private boolean isSystemChildExpanded() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index b8f802600b3b..164a06e68dc3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -71,6 +71,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableView.OnHeightCh import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper; import com.android.systemui.statusbar.notification.shared.NotificationContentAlphaOptimization; import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer; +import com.android.systemui.statusbar.phone.ExpandHeadsUpOnInlineReply; import com.android.systemui.statusbar.phone.KeyguardBypassController; import org.junit.Assert; @@ -860,6 +861,133 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { } @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_systemExpandedTrueForHeadsUp_notExpanded() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUp(true); + + // THEN + assertThat(row.isExpanded()).isFalse(); + } + + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_systemExpandedTrueForHeadsUpDisappearRunning_notExpanded() + throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUpAnimatingAway(true); + + // THEN + assertThat(row.isExpanded()).isFalse(); + } + + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_userExpandedTrueForHeadsUp_expanded() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUpAnimatingAway(true); + row.setUserExpanded(true); + + // THEN + assertThat(row.isExpanded()).isTrue(); + } + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_userExpandedTrueForHeadsUpDisappearRunning_expanded() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUpAnimatingAway(true); + row.setUserExpanded(true); + + // THEN + assertThat(row.isExpanded()).isTrue(); + } + + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_userExpandedFalseForHeadsUp_notExpanded() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUpAnimatingAway(true); + row.setUserExpanded(false); + + // THEN + assertThat(row.isExpanded()).isFalse(); + } + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_userExpandedFalseForHeadsUpDisappearRunning_notExpanded() + throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUpAnimatingAway(true); + row.setUserExpanded(false); + + // THEN + assertThat(row.isExpanded()).isFalse(); + } + + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_HUNexpandedWhenPinningTrue_expanded() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(true); + row.setHeadsUp(true); + row.setPinned(true); + + // WHEN + row.expandNotification(); + + // THEN + assertThat(row.isExpanded()).isTrue(); + } + + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void isExpanded_HUNexpandedWhenPinningFalse_notExpanded() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setOnKeyguard(false); + row.setSystemExpanded(false); + row.setHeadsUp(true); + row.setPinned(true); + + // THEN + assertThat(row.isExpanded()).isFalse(); + } + + @Test + @EnableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME) + public void hasUserChangedExpansion_expandPinned_returnTrue() throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setPinned(true); + + // WHEN + row.expandNotification(); + + // THEN + assertThat(row.hasUserChangedExpansion()).isTrue(); + } + + @Test public void onDisappearAnimationFinished_shouldSetFalse_headsUpAnimatingAway() throws Exception { final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); |