summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author AndrĂ¡s Kurucz <kurucz@google.com> 2022-09-09 13:57:31 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-09-09 13:57:31 +0000
commitcd96d0009b7fc70b78aeaf6a51a8a44531aa992c (patch)
treec03f41a56aa5fac84c46c90f8c358c129afc7780
parent049c894fdc8de13ef10d5fab3113459ba9063a23 (diff)
parentf1bf56b71c66c4b5e5d1fac5faad2968afbc5f1d (diff)
Merge "Fix alpha fading of NotificationShelf in LS" into tm-qpr-dev am: f1bf56b71c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19867435 Change-Id: Idcb2f3da0a7dfe23d5c10b6d723e94a1540b6fb6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java14
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt83
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt64
3 files changed, 138 insertions, 23 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index cea3debe6379..41c0367772b5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar;
+import static com.android.keyguard.BouncerPanelExpansionCalculator.aboutToShowBouncerProgress;
+
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -90,6 +92,12 @@ public class NotificationShelf extends ActivatableNotificationView implements
super(context, attrs);
}
+ @VisibleForTesting
+ public NotificationShelf(Context context, AttributeSet attrs, boolean showNotificationShelf) {
+ super(context, attrs);
+ mShowNotificationShelf = showNotificationShelf;
+ }
+
@Override
@VisibleForTesting
public void onFinishInflate() {
@@ -175,7 +183,11 @@ public class NotificationShelf extends ActivatableNotificationView implements
if (ambientState.isExpansionChanging() && !ambientState.isOnKeyguard()) {
float expansion = ambientState.getExpansionFraction();
- viewState.alpha = ShadeInterpolation.getContentAlpha(expansion);
+ if (ambientState.isBouncerInTransit()) {
+ viewState.alpha = aboutToShowBouncerProgress(expansion);
+ } else {
+ viewState.alpha = ShadeInterpolation.getContentAlpha(expansion);
+ }
} else {
viewState.alpha = 1f - ambientState.getHideAmount();
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
index 3f190367f284..77418138158b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
@@ -3,15 +3,22 @@ package com.android.systemui.statusbar.notification.stack
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
+import com.android.keyguard.BouncerPanelExpansionCalculator.aboutToShowBouncerProgress
import com.android.systemui.SysuiTestCase
+import com.android.systemui.animation.ShadeInterpolation
import com.android.systemui.statusbar.NotificationShelf
import com.android.systemui.statusbar.StatusBarIconView
+import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
-import junit.framework.Assert.*
+import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.StackScrollAlgorithmState
+import com.android.systemui.util.mockito.mock
+import junit.framework.Assert.assertEquals
+import junit.framework.Assert.assertFalse
+import junit.framework.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.mockito.Mockito.*
+import org.mockito.Mockito.mock
import org.mockito.Mockito.`when` as whenever
/**
@@ -22,13 +29,18 @@ import org.mockito.Mockito.`when` as whenever
@RunWithLooper
class NotificationShelfTest : SysuiTestCase() {
- private val shelf = NotificationShelf(context, /* attrs */ null)
+ private val shelf = NotificationShelf(
+ context,
+ /* attrs */ null,
+ /* showNotificationShelf */true
+ )
private val shelfState = shelf.viewState as NotificationShelf.ShelfState
private val ambientState = mock(AmbientState::class.java)
+ private val hostLayoutController: NotificationStackScrollLayoutController = mock()
@Before
fun setUp() {
- shelf.bind(ambientState, /* hostLayoutController */ null)
+ shelf.bind(ambientState, /* hostLayoutController */ hostLayoutController)
shelf.layout(/* left */ 0, /* top */ 0, /* right */ 30, /* bottom */5)
}
@@ -37,7 +49,7 @@ class NotificationShelfTest : SysuiTestCase() {
setFractionToShade(0f)
setOnLockscreen(true)
- shelf.updateActualWidth(/* fractionToShade */ 0f, /* shortestWidth */ 10f);
+ shelf.updateActualWidth(/* fractionToShade */ 0f, /* shortestWidth */ 10f)
assertTrue(shelf.actualWidth == 10)
shelf.updateActualWidth(/* fractionToShade */ 0.5f, /* shortestWidth */ 10f)
@@ -155,7 +167,7 @@ class NotificationShelfTest : SysuiTestCase() {
whenever(expandableView.actualHeight).thenReturn(20)
whenever(expandableView.minHeight).thenReturn(20)
- whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
+ whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
whenever(expandableView.isInShelf).thenReturn(true)
whenever(ambientState.isOnKeyguard).thenReturn(true)
@@ -182,7 +194,7 @@ class NotificationShelfTest : SysuiTestCase() {
whenever(expandableView.actualHeight).thenReturn(20)
whenever(expandableView.minHeight).thenReturn(20)
- whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
+ whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
whenever(expandableView.isInShelf).thenReturn(true)
whenever(ambientState.isOnKeyguard).thenReturn(true)
@@ -209,7 +221,7 @@ class NotificationShelfTest : SysuiTestCase() {
whenever(expandableView.actualHeight).thenReturn(25)
whenever(expandableView.minHeight).thenReturn(25)
- whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
+ whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
whenever(expandableView.isInShelf).thenReturn(true)
whenever(ambientState.isOnKeyguard).thenReturn(true)
@@ -236,7 +248,7 @@ class NotificationShelfTest : SysuiTestCase() {
whenever(expandableView.actualHeight).thenReturn(10)
whenever(expandableView.minHeight).thenReturn(10)
- whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
+ whenever(expandableView.shelfTransformationTarget).thenReturn(null) // use translationY
whenever(expandableView.isInShelf).thenReturn(false)
whenever(ambientState.isExpansionChanging).thenReturn(false)
@@ -251,6 +263,42 @@ class NotificationShelfTest : SysuiTestCase() {
assertEquals(0f, amountInShelf)
}
+ @Test
+ fun updateState_expansionChanging_shelfTransparent() {
+ updateState_expansionChanging_shelfAlphaUpdated(
+ expansionFraction = 0.25f,
+ expectedAlpha = 0.0f
+ )
+ }
+
+ @Test
+ fun updateState_expansionChangingWhileBouncerInTransit_shelfTransparent() {
+ whenever(ambientState.isBouncerInTransit).thenReturn(true)
+
+ updateState_expansionChanging_shelfAlphaUpdated(
+ expansionFraction = 0.85f,
+ expectedAlpha = 0.0f
+ )
+ }
+
+ @Test
+ fun updateState_expansionChanging_shelfAlphaUpdated() {
+ updateState_expansionChanging_shelfAlphaUpdated(
+ expansionFraction = 0.6f,
+ expectedAlpha = ShadeInterpolation.getContentAlpha(0.6f)
+ )
+ }
+
+ @Test
+ fun updateState_expansionChangingWhileBouncerInTransit_shelfAlphaUpdated() {
+ whenever(ambientState.isBouncerInTransit).thenReturn(true)
+
+ updateState_expansionChanging_shelfAlphaUpdated(
+ expansionFraction = 0.95f,
+ expectedAlpha = aboutToShowBouncerProgress(0.95f)
+ )
+ }
+
private fun setFractionToShade(fraction: Float) {
whenever(ambientState.fractionToShade).thenReturn(fraction)
}
@@ -258,4 +306,19 @@ class NotificationShelfTest : SysuiTestCase() {
private fun setOnLockscreen(isOnLockscreen: Boolean) {
whenever(ambientState.isOnKeyguard).thenReturn(isOnLockscreen)
}
-} \ No newline at end of file
+
+ private fun updateState_expansionChanging_shelfAlphaUpdated(
+ expansionFraction: Float,
+ expectedAlpha: Float
+ ) {
+ whenever(ambientState.lastVisibleBackgroundChild)
+ .thenReturn(ExpandableNotificationRow(mContext, null))
+ whenever(ambientState.isExpansionChanging).thenReturn(true)
+ whenever(ambientState.expansionFraction).thenReturn(expansionFraction)
+ whenever(hostLayoutController.speedBumpIndex).thenReturn(0)
+
+ shelf.updateState(StackScrollAlgorithmState(), ambientState)
+
+ assertEquals(expectedAlpha, shelf.viewState.alpha)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
index 24eff5ff1162..40aec82f5a85 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
@@ -20,7 +20,10 @@ import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import org.junit.Before
import org.junit.Test
+import org.mockito.Mockito.any
+import org.mockito.Mockito.eq
import org.mockito.Mockito.mock
+import org.mockito.Mockito.verify
import org.mockito.Mockito.`when` as whenever
@SmallTest
@@ -35,7 +38,6 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
private val emptyShadeView = EmptyShadeView(context, /* attrs= */ null).apply {
layout(/* l= */ 0, /* t= */ 0, /* r= */ 100, /* b= */ 100)
}
-
private val ambientState = AmbientState(
context,
dumpManager,
@@ -115,29 +117,54 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
}
@Test
- fun resetViewStates_isExpansionChanging_viewBecomesTransparent() {
+ fun resetViewStates_expansionChanging_notificationBecomesTransparent() {
whenever(mStatusBarKeyguardViewManager.isBouncerInTransit).thenReturn(false)
- ambientState.isExpansionChanging = true
- ambientState.expansionFraction = 0.25f
- stackScrollAlgorithm.initView(context)
+ resetViewStates_expansionChanging_notificationAlphaUpdated(
+ expansionFraction = 0.25f,
+ expectedAlpha = 0.0f
+ )
+ }
- stackScrollAlgorithm.resetViewStates(ambientState, /* speedBumpIndex= */ 0)
+ @Test
+ fun resetViewStates_expansionChangingWhileBouncerInTransit_viewBecomesTransparent() {
+ whenever(mStatusBarKeyguardViewManager.isBouncerInTransit).thenReturn(true)
+ resetViewStates_expansionChanging_notificationAlphaUpdated(
+ expansionFraction = 0.85f,
+ expectedAlpha = 0.0f
+ )
+ }
- val expected = getContentAlpha(0.25f)
- assertThat(notificationRow.viewState.alpha).isEqualTo(expected)
+ @Test
+ fun resetViewStates_expansionChanging_notificationAlphaUpdated() {
+ whenever(mStatusBarKeyguardViewManager.isBouncerInTransit).thenReturn(false)
+ resetViewStates_expansionChanging_notificationAlphaUpdated(
+ expansionFraction = 0.6f,
+ expectedAlpha = getContentAlpha(0.6f)
+ )
}
@Test
- fun resetViewStates_isExpansionChangingWhileBouncerInTransit_viewBecomesTransparent() {
+ fun resetViewStates_expansionChangingWhileBouncerInTransit_notificationAlphaUpdated() {
whenever(mStatusBarKeyguardViewManager.isBouncerInTransit).thenReturn(true)
+ resetViewStates_expansionChanging_notificationAlphaUpdated(
+ expansionFraction = 0.95f,
+ expectedAlpha = aboutToShowBouncerProgress(0.95f)
+ )
+ }
+
+ @Test
+ fun resetViewStates_expansionChanging_shelfUpdated() {
+ ambientState.shelf = notificationShelf
ambientState.isExpansionChanging = true
- ambientState.expansionFraction = 0.25f
+ ambientState.expansionFraction = 0.6f
stackScrollAlgorithm.initView(context)
stackScrollAlgorithm.resetViewStates(ambientState, /* speedBumpIndex= */ 0)
- val expected = aboutToShowBouncerProgress(0.25f)
- assertThat(notificationRow.viewState.alpha).isEqualTo(expected)
+ verify(notificationShelf).updateState(
+ /* algorithmState= */any(),
+ /* ambientState= */eq(ambientState)
+ )
}
@Test
@@ -479,6 +506,19 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
/* originalCornerRoundness= */ 1f)
assertEquals(1f, currentRoundness)
}
+
+ private fun resetViewStates_expansionChanging_notificationAlphaUpdated(
+ expansionFraction: Float,
+ expectedAlpha: Float
+ ) {
+ ambientState.isExpansionChanging = true
+ ambientState.expansionFraction = expansionFraction
+ stackScrollAlgorithm.initView(context)
+
+ stackScrollAlgorithm.resetViewStates(ambientState, /* speedBumpIndex= */ 0)
+
+ assertThat(notificationRow.viewState.alpha).isEqualTo(expectedAlpha)
+ }
}
private fun mockExpandableNotificationRow(): ExpandableNotificationRow {