Merge "Do not blur when changing brightness" into sc-dev
This commit is contained in:
@@ -96,6 +96,15 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
var globalActionsSpring = DepthAnimation()
|
var globalActionsSpring = DepthAnimation()
|
||||||
var showingHomeControls: Boolean = false
|
var showingHomeControls: Boolean = false
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
var brightnessMirrorSpring = DepthAnimation()
|
||||||
|
var brightnessMirrorVisible: Boolean = false
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
brightnessMirrorSpring.animateTo(if (value) blurUtils.blurRadiusOfRatio(1f)
|
||||||
|
else 0)
|
||||||
|
}
|
||||||
|
|
||||||
var qsPanelExpansion = 0f
|
var qsPanelExpansion = 0f
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field == value) return
|
if (field == value) return
|
||||||
@@ -189,10 +198,13 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
if (scrimsVisible || !blurUtils.supportsBlursOnWindows()) {
|
if (scrimsVisible || !blurUtils.supportsBlursOnWindows()) {
|
||||||
blur = 0
|
blur = 0
|
||||||
}
|
}
|
||||||
|
val zoomOut = blurUtils.ratioOfBlurRadius(blur)
|
||||||
|
|
||||||
|
// Brightness slider removes blur, but doesn't affect zooms
|
||||||
|
blur = (blur * (1f - brightnessMirrorSpring.ratio)).toInt()
|
||||||
|
|
||||||
val opaque = scrimsVisible && !ignoreShadeBlurUntilHidden
|
val opaque = scrimsVisible && !ignoreShadeBlurUntilHidden
|
||||||
blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, opaque)
|
blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, opaque)
|
||||||
val zoomOut = blurUtils.ratioOfBlurRadius(blur)
|
|
||||||
try {
|
try {
|
||||||
if (root.isAttachedToWindow && root.windowToken != null) {
|
if (root.isAttachedToWindow && root.windowToken != null) {
|
||||||
wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
|
wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
|
||||||
@@ -260,6 +272,7 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
shadeSpring.finishIfRunning()
|
shadeSpring.finishIfRunning()
|
||||||
shadeAnimation.finishIfRunning()
|
shadeAnimation.finishIfRunning()
|
||||||
globalActionsSpring.finishIfRunning()
|
globalActionsSpring.finishIfRunning()
|
||||||
|
brightnessMirrorSpring.finishIfRunning()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,6 +438,7 @@ class NotificationShadeDepthController @Inject constructor(
|
|||||||
it.println("shadeRadius: ${shadeSpring.radius}")
|
it.println("shadeRadius: ${shadeSpring.radius}")
|
||||||
it.println("shadeAnimation: ${shadeAnimation.radius}")
|
it.println("shadeAnimation: ${shadeAnimation.radius}")
|
||||||
it.println("globalActionsRadius: ${globalActionsSpring.radius}")
|
it.println("globalActionsRadius: ${globalActionsSpring.radius}")
|
||||||
|
it.println("brightnessMirrorRadius: ${brightnessMirrorSpring.radius}")
|
||||||
it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius")
|
it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius")
|
||||||
it.println("ignoreShadeBlurUntilHidden: $ignoreShadeBlurUntilHidden")
|
it.println("ignoreShadeBlurUntilHidden: $ignoreShadeBlurUntilHidden")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,11 +74,13 @@ public class BrightnessMirrorController
|
|||||||
mBrightnessMirror.setVisibility(View.VISIBLE);
|
mBrightnessMirror.setVisibility(View.VISIBLE);
|
||||||
mVisibilityCallback.accept(true);
|
mVisibilityCallback.accept(true);
|
||||||
mNotificationPanel.setPanelAlpha(0, true /* animate */);
|
mNotificationPanel.setPanelAlpha(0, true /* animate */);
|
||||||
|
mDepthController.setBrightnessMirrorVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideMirror() {
|
public void hideMirror() {
|
||||||
mVisibilityCallback.accept(false);
|
mVisibilityCallback.accept(false);
|
||||||
mNotificationPanel.setPanelAlpha(255, true /* animate */);
|
mNotificationPanel.setPanelAlpha(255, true /* animate */);
|
||||||
|
mDepthController.setBrightnessMirrorVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
|||||||
@Mock private lateinit var shadeSpring: NotificationShadeDepthController.DepthAnimation
|
@Mock private lateinit var shadeSpring: NotificationShadeDepthController.DepthAnimation
|
||||||
@Mock private lateinit var shadeAnimation: NotificationShadeDepthController.DepthAnimation
|
@Mock private lateinit var shadeAnimation: NotificationShadeDepthController.DepthAnimation
|
||||||
@Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation
|
@Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation
|
||||||
|
@Mock private lateinit var brightnessSpring: NotificationShadeDepthController.DepthAnimation
|
||||||
@Mock private lateinit var listener: NotificationShadeDepthController.DepthListener
|
@Mock private lateinit var listener: NotificationShadeDepthController.DepthListener
|
||||||
@Mock private lateinit var dozeParameters: DozeParameters
|
@Mock private lateinit var dozeParameters: DozeParameters
|
||||||
@Captor private lateinit var scrimVisibilityCaptor: ArgumentCaptor<Consumer<Int>>
|
@Captor private lateinit var scrimVisibilityCaptor: ArgumentCaptor<Consumer<Int>>
|
||||||
@@ -91,6 +92,9 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
|||||||
`when`(blurUtils.blurRadiusOfRatio(anyFloat())).then { answer ->
|
`when`(blurUtils.blurRadiusOfRatio(anyFloat())).then { answer ->
|
||||||
(answer.arguments[0] as Float * maxBlur).toInt()
|
(answer.arguments[0] as Float * maxBlur).toInt()
|
||||||
}
|
}
|
||||||
|
`when`(blurUtils.ratioOfBlurRadius(anyInt())).then { answer ->
|
||||||
|
answer.arguments[0] as Int / maxBlur.toFloat()
|
||||||
|
}
|
||||||
`when`(blurUtils.supportsBlursOnWindows()).thenReturn(true)
|
`when`(blurUtils.supportsBlursOnWindows()).thenReturn(true)
|
||||||
`when`(blurUtils.maxBlurRadius).thenReturn(maxBlur)
|
`when`(blurUtils.maxBlurRadius).thenReturn(maxBlur)
|
||||||
`when`(blurUtils.maxBlurRadius).thenReturn(maxBlur)
|
`when`(blurUtils.maxBlurRadius).thenReturn(maxBlur)
|
||||||
@@ -101,6 +105,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
|||||||
notificationShadeWindowController, dozeParameters, dumpManager)
|
notificationShadeWindowController, dozeParameters, dumpManager)
|
||||||
notificationShadeDepthController.shadeSpring = shadeSpring
|
notificationShadeDepthController.shadeSpring = shadeSpring
|
||||||
notificationShadeDepthController.shadeAnimation = shadeAnimation
|
notificationShadeDepthController.shadeAnimation = shadeAnimation
|
||||||
|
notificationShadeDepthController.brightnessMirrorSpring = brightnessSpring
|
||||||
notificationShadeDepthController.globalActionsSpring = globalActionsSpring
|
notificationShadeDepthController.globalActionsSpring = globalActionsSpring
|
||||||
notificationShadeDepthController.root = root
|
notificationShadeDepthController.root = root
|
||||||
|
|
||||||
@@ -276,6 +281,32 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
|||||||
eq(notificationShadeDepthController.updateBlurCallback))
|
eq(notificationShadeDepthController.updateBlurCallback))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun brightnessMirrorVisible_whenVisible() {
|
||||||
|
notificationShadeDepthController.brightnessMirrorVisible = true
|
||||||
|
verify(brightnessSpring).animateTo(eq(maxBlur), any())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun brightnessMirrorVisible_whenHidden() {
|
||||||
|
notificationShadeDepthController.brightnessMirrorVisible = false
|
||||||
|
verify(brightnessSpring).animateTo(eq(0), any())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun brightnessMirror_hidesShadeBlur() {
|
||||||
|
// Brightness mirror is fully visible
|
||||||
|
`when`(brightnessSpring.ratio).thenReturn(1f)
|
||||||
|
// And shade is blurred
|
||||||
|
`when`(shadeSpring.radius).thenReturn(maxBlur)
|
||||||
|
`when`(shadeAnimation.radius).thenReturn(maxBlur)
|
||||||
|
|
||||||
|
notificationShadeDepthController.updateBlurCallback.doFrame(0)
|
||||||
|
verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
|
||||||
|
verify(wallpaperManager).setWallpaperZoomOut(any(), eq(1f))
|
||||||
|
verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun ignoreShadeBlurUntilHidden_whennNull_ignoresIfShadeHasNoBlur() {
|
fun ignoreShadeBlurUntilHidden_whennNull_ignoresIfShadeHasNoBlur() {
|
||||||
`when`(shadeSpring.radius).thenReturn(0)
|
`when`(shadeSpring.radius).thenReturn(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user