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

Commit 8feb5edc authored by William Xiao's avatar William Xiao
Browse files

Transition away notifications when entering glanceable hub

This change fades away the lockscreen notifications when entering the
glanceable hub. It also allows top edge swipes on the glanceable hub to
open the notification shade.

Bug: 315205216
Bug: 315207481
Test: atest KeyguardRootViewModelTest GlanceableHubContainerControllerTest SharedNotificationContainerViewModelTest
Flag: ACONFIG com.android.systemui.communal_hub DEVELOPMENT
Change-Id: Ic35a4aa8b6bef9a41213f3ef816745575bec4d6a
parent ceda1701
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -25,10 +25,14 @@ import androidx.test.filters.SmallTest
import com.android.systemui.Flags as AConfigFlags
import com.android.systemui.Flags.FLAG_NEW_AOD_TRANSITION
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.communalRepository
import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
@@ -43,6 +47,7 @@ import com.android.systemui.util.ui.stopAnimating
import com.android.systemui.util.ui.value
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -55,7 +60,9 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    private val keyguardInteractor = kosmos.keyguardInteractor
    private val keyguardRepository = kosmos.fakeKeyguardRepository
    private val communalRepository = kosmos.communalRepository
    private val screenOffAnimationController = kosmos.screenOffAnimationController
    private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository
    private val notificationsKeyguardInteractor = kosmos.notificationsKeyguardInteractor
@@ -220,7 +227,25 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
        }

    @Test
    fun alpha_glanceableHubOpen_isZero() =
    fun alpha_idleOnHub_isZero() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.alpha)

            // Hub transition state is idle with hub open.
            communalRepository.setTransitionState(
                flowOf(ObservableCommunalTransitionState.Idle(CommunalSceneKey.Communal))
            )
            runCurrent()

            // Set keyguard alpha to 1.0f.
            keyguardInteractor.setAlpha(1.0f)

            // Alpha property remains 0 regardless.
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    fun alpha_transitionToHub_isZero() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.alpha)

@@ -234,7 +259,7 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
        }

    @Test
    fun alpha_glanceableHubClosed_isOne() =
    fun alpha_transitionFromHubToLockscreen_isOne() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.alpha)

+4 −0
Original line number Diff line number Diff line
@@ -1728,6 +1728,10 @@
    <dimen name="communal_grid_height">630dp</dimen>
    <!-- Number of columns for each communal card -->
    <integer name="communal_grid_columns_per_card">6</integer>
    <!-- Width of area on right edge of screen in which swipes will open the communal hub -->
    <dimen name="communal_right_edge_swipe_region_width">16dp</dimen>
    <!-- Height of area at top of communal hub where swipes should open the notification shade -->
    <dimen name="communal_top_edge_swipe_region_height">32dp</dimen>

    <dimen name="drag_and_drop_icon_size">70dp</dimen>

+2 −1
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ constructor(

    companion object {
        const val TAG = "FromGlanceableHubTransitionInteractor"
        val DEFAULT_DURATION = 500.milliseconds
        val DEFAULT_DURATION = 400.milliseconds
        val TO_LOCKSCREEN_DURATION = DEFAULT_DURATION
    }
}
+13 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.keyguard.ui.viewmodel

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.FromLockscreenTransitionInteractor
import com.android.systemui.keyguard.domain.interactor.FromGlanceableHubTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.ui.KeyguardTransitionAnimationFlow
import javax.inject.Inject
@@ -37,7 +37,7 @@ constructor(
) {
    private val transitionAnimation =
        animationFlow.setup(
            duration = FromLockscreenTransitionInteractor.TO_GLANCEABLE_HUB_DURATION,
            duration = FromGlanceableHubTransitionInteractor.TO_LOCKSCREEN_DURATION,
            from = KeyguardState.GLANCEABLE_HUB,
            to = KeyguardState.LOCKSCREEN,
        )
@@ -45,10 +45,20 @@ constructor(
    // TODO(b/315205222): implement full animation spec instead of just a simple fade.
    val keyguardAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(
            duration = FromLockscreenTransitionInteractor.TO_GLANCEABLE_HUB_DURATION,
            duration = FromGlanceableHubTransitionInteractor.TO_LOCKSCREEN_DURATION,
            onStep = { it },
            onFinish = { 1f },
            onCancel = { 0f },
            name = "GLANCEABLE_HUB->LOCKSCREEN: keyguardAlpha",
        )

    // TODO(b/315205216): implement full animation spec instead of just a simple fade.
    val notificationAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(
            duration = FromGlanceableHubTransitionInteractor.TO_LOCKSCREEN_DURATION,
            onStep = { it },
            onFinish = { 1f },
            onCancel = { 0f },
            name = "GLANCEABLE_HUB->LOCKSCREEN: notificationAlpha",
        )
}
+19 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.graphics.Point
import android.view.View.VISIBLE
import com.android.systemui.Flags.newAodTransition
import com.android.systemui.common.shared.model.NotificationContainerBounds
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
@@ -56,6 +57,7 @@ constructor(
    private val deviceEntryInteractor: DeviceEntryInteractor,
    private val dozeParameters: DozeParameters,
    private val keyguardInteractor: KeyguardInteractor,
    communalInteractor: CommunalInteractor,
    keyguardTransitionInteractor: KeyguardTransitionInteractor,
    private val notificationsKeyguardInteractor: NotificationsKeyguardInteractor,
    aodToLockscreenTransitionViewModel: AodToLockscreenTransitionViewModel,
@@ -88,11 +90,23 @@ constructor(

    /** An observable for the alpha level for the entire keyguard root view. */
    val alpha: Flow<Float> =
        combine(
                communalInteractor.isIdleOnCommunal,
                merge(
                    aodAlphaViewModel.alpha,
                    lockscreenToGlanceableHubTransitionViewModel.keyguardAlpha,
                    glanceableHubToLockscreenTransitionViewModel.keyguardAlpha,
                )
            ) { isIdleOnCommunal, alpha ->
                if (isIdleOnCommunal) {
                    // Keyguard should not show while the communal hub is fully visible. This check
                    // is added since at the moment, closing the notification shade will cause the
                    // keyguard alpha to be set back to 1.
                    0f
                } else {
                    alpha
                }
            }
            .distinctUntilChanged()

    /** Specific alpha value for elements visible during [KeyguardState.LOCKSCREEN] */
Loading