Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afb5f5e9 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge "Apply contentAlpha for brightness mirror to notifications" into main

parents 77c06015 9fea83c3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -151,6 +152,9 @@ private fun SceneScope.QuickSettingsScene(
            label = "alphaAnimationBrightnessMirrorContentHiding",
        )

    viewModel.notifications.setAlphaForBrightnessMirror(contentAlpha)
    DisposableEffect(Unit) { onDispose { viewModel.notifications.setAlphaForBrightnessMirror(1f) } }

    BrightnessMirror(
        viewModel = viewModel.brightnessMirrorViewModel,
        qsSceneAdapter = viewModel.qsSceneAdapter
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -341,6 +342,9 @@ private fun SceneScope.SplitShade(
            label = "alphaAnimationBrightnessMirrorContentHiding",
        )

    viewModel.notifications.setAlphaForBrightnessMirror(contentAlpha)
    DisposableEffect(Unit) { onDispose { viewModel.notifications.setAlphaForBrightnessMirror(1f) } }

    val brightnessMirrorShowingModifier = Modifier.graphicsLayer { alpha = contentAlpha }

    Box(
+21 −8
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
        }
    private val testScope = kosmos.testScope
    private val placeholderViewModel by lazy { kosmos.notificationsPlaceholderViewModel }
    private val appearanceViewModel by lazy { kosmos.notificationScrollViewModel }
    private val scrollViewModel by lazy { kosmos.notificationScrollViewModel }
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val fakeSceneDataSource by lazy { kosmos.fakeSceneDataSource }

@@ -67,7 +67,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
        testScope.runTest {
            val radius = MutableStateFlow(32)
            val leftOffset = MutableStateFlow(0)
            val shape by collectLastValue(appearanceViewModel.shadeScrimShape(radius, leftOffset))
            val shape by collectLastValue(scrollViewModel.shadeScrimShape(radius, leftOffset))

            placeholderViewModel.onScrimBoundsChanged(
                ShadeScrimBounds(left = 0f, top = 200f, right = 100f, bottom = 550f)
@@ -98,6 +98,19 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
                )
        }

    @Test
    fun brightnessMirrorAlpha_updatesViewModel() =
        testScope.runTest {
            val maxAlpha by collectLastValue(scrollViewModel.maxAlpha)
            assertThat(maxAlpha).isEqualTo(1f)
            placeholderViewModel.setAlphaForBrightnessMirror(0.33f)
            assertThat(maxAlpha).isEqualTo(0.33f)
            placeholderViewModel.setAlphaForBrightnessMirror(0f)
            assertThat(maxAlpha).isEqualTo(0f)
            placeholderViewModel.setAlphaForBrightnessMirror(1f)
            assertThat(maxAlpha).isEqualTo(1f)
        }

    @Test
    fun shadeExpansion_goneToShade() =
        testScope.runTest {
@@ -106,9 +119,9 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
                    ObservableTransitionState.Idle(currentScene = Scenes.Gone)
                )
            sceneInteractor.setTransitionState(transitionState)
            val expandFraction by collectLastValue(appearanceViewModel.expandFraction)
            val expandFraction by collectLastValue(scrollViewModel.expandFraction)
            assertThat(expandFraction).isEqualTo(0f)
            val isScrollable by collectLastValue(appearanceViewModel.isScrollable)
            val isScrollable by collectLastValue(scrollViewModel.isScrollable)
            assertThat(isScrollable).isFalse()

            fakeSceneDataSource.pause()
@@ -144,9 +157,9 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
                    ObservableTransitionState.Idle(currentScene = Scenes.Lockscreen)
                )
            sceneInteractor.setTransitionState(transitionState)
            val expandFraction by collectLastValue(appearanceViewModel.expandFraction)
            val expandFraction by collectLastValue(scrollViewModel.expandFraction)
            assertThat(expandFraction).isEqualTo(1f)
            val isScrollable by collectLastValue(appearanceViewModel.isScrollable)
            val isScrollable by collectLastValue(scrollViewModel.isScrollable)
            assertThat(isScrollable).isFalse()
        }

@@ -158,11 +171,11 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
                    ObservableTransitionState.Idle(currentScene = Scenes.Shade)
                )
            sceneInteractor.setTransitionState(transitionState)
            val expandFraction by collectLastValue(appearanceViewModel.expandFraction)
            val expandFraction by collectLastValue(scrollViewModel.expandFraction)
            assertThat(expandFraction).isEqualTo(1f)

            fakeSceneDataSource.changeScene(toScene = Scenes.Shade)
            val isScrollable by collectLastValue(appearanceViewModel.isScrollable)
            val isScrollable by collectLastValue(scrollViewModel.isScrollable)
            assertThat(isScrollable).isTrue()

            fakeSceneDataSource.pause()
+6 −0
Original line number Diff line number Diff line
@@ -1146,11 +1146,17 @@ public class NotificationStackScrollLayout
        }
    }

    @NonNull
    @Override
    public View asView() {
        return this;
    }

    @Override
    public void setMaxAlpha(float alpha) {
        mController.setMaxAlphaFromView(alpha);
    }

    @Override
    public void setScrolledToTop(boolean scrolledToTop) {
        mScrollViewFields.setScrolledToTop(scrolledToTop);
+8 −1
Original line number Diff line number Diff line
@@ -356,6 +356,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
    private float mMaxAlphaForKeyguard = 1.0f;
    private String mMaxAlphaForKeyguardSource = "constructor";
    private float mMaxAlphaForUnhide = 1.0f;
    private float mMaxAlphaFromView = 1.0f;

    /**
     * Maximum alpha when to and from or sitting idle on the glanceable hub. Will be 1.0f when the
@@ -1317,9 +1318,14 @@ public class NotificationStackScrollLayoutController implements Dumpable {
        updateAlpha();
    }

    void setMaxAlphaFromView(float alpha) {
        mMaxAlphaFromView = alpha;
        updateAlpha();
    }

    private void updateAlpha() {
        if (mView != null) {
            mView.setAlpha(Math.min(mMaxAlphaForKeyguard,
            mView.setAlpha(Math.min(Math.min(mMaxAlphaFromView, mMaxAlphaForKeyguard),
                    Math.min(mMaxAlphaForUnhide, mMaxAlphaForGlanceableHub)));
        }
    }
@@ -1789,6 +1795,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {

    @Override
    public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
        pw.println("mMaxAlphaFromView=" + mMaxAlphaFromView);
        pw.println("mMaxAlphaForUnhide=" + mMaxAlphaForUnhide);
        pw.println("mMaxAlphaForGlanceableHub=" + mMaxAlphaForGlanceableHub);
        pw.println("mMaxAlphaForKeyguard=" + mMaxAlphaForKeyguard);
Loading