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

Commit 0f15f263 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge changes I49c77e90,Id68b00fb,I1eaa617a,I14914db5,I405fc27a, ... into main

* changes:
  [flexiglass] Adds long-press settings menu support to lockscreen scene.
  [flexiglass] Removes lock button click handling from lockscreen scene.
  [flexiglass] Start with the legacy UI always hidden.
  [flexiglass] Makes Gone scene empty.
  [flexiglass] Send signals to the Falsing system.
  [flexiglass] Falsing system changes.
parents 58f808ae f9ae30cb
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TextField
@@ -45,7 +44,6 @@ import androidx.compose.ui.unit.dp
import com.android.systemui.bouncer.ui.viewmodel.PasswordBouncerViewModel

/** UI for the input part of a password-requiring version of the bouncer. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun PasswordBouncer(
    viewModel: PasswordBouncerViewModel,
+33 −25
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@@ -199,6 +201,12 @@ internal fun PatternBouncer(
            .onSizeChanged { containerSize = it }
            .thenIf(isInputEnabled) {
                Modifier.pointerInput(Unit) {
                        awaitEachGesture {
                            awaitFirstDown()
                            viewModel.onDown()
                        }
                    }
                    .pointerInput(Unit) {
                        detectDragGestures(
                            onDragStart = { start ->
                                inputPosition = start
@@ -209,8 +217,8 @@ internal fun PatternBouncer(
                                if (isAnimationEnabled) {
                                    lineFadeOutAnimatables.values.forEach { animatable ->
                                        // Launch using the longer-lived scope because we want these
                                    // animations to proceed to completion even if the surrounding
                                    // scope is canceled.
                                        // animations to proceed to completion even if the
                                        // surrounding scope is canceled.
                                        scope.launch { animatable.animateTo(1f) }
                                    }
                                }
+9 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -76,7 +78,13 @@ internal fun PinBouncer(

    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = modifier,
        modifier =
            modifier.pointerInput(Unit) {
                awaitEachGesture {
                    awaitFirstDown()
                    viewModel.onDown()
                }
            }
    ) {
        PinInputDisplay(viewModel)
        Spacer(Modifier.height(100.dp))
+76 −16
Original line number Diff line number Diff line
@@ -14,20 +14,33 @@
 * limitations under the License.
 */

@file:OptIn(ExperimentalCoroutinesApi::class)
@file:OptIn(ExperimentalCoroutinesApi::class, ExperimentalFoundationApi::class)

package com.android.systemui.keyguard.ui.composable

import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.toComposeRect
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.view.isVisible
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.qualifiers.KeyguardRootView
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
import com.android.systemui.scene.shared.model.Direction
import com.android.systemui.scene.shared.model.SceneKey
@@ -67,8 +80,8 @@ constructor(
        modifier: Modifier,
    ) {
        LockscreenScene(
            viewModel = viewModel,
            viewProvider = viewProvider,
            longPressViewModel = viewModel.longPress,
            modifier = modifier,
        )
    }
@@ -85,23 +98,70 @@ constructor(

@Composable
private fun LockscreenScene(
    viewModel: LockscreenSceneViewModel,
    viewProvider: () -> View,
    longPressViewModel: KeyguardLongPressViewModel,
    modifier: Modifier = Modifier,
) {
    var settingsMenu: View? = null

    Box(
        modifier = modifier,
    ) {
        LongPressSurface(
            viewModel = longPressViewModel,
            isSettingsMenuVisible = { settingsMenu?.isVisible == true },
            settingsMenuBounds = {
                val bounds = android.graphics.Rect()
                settingsMenu?.getHitRect(bounds)
                bounds.toComposeRect()
            },
            modifier = Modifier.fillMaxSize(),
        )

        AndroidView(
            factory = { _ ->
                val keyguardRootView = viewProvider()
            // Remove the KeyguardRootView from any parent it might already have in legacy code just
            // in case (a view can't have two parents).
                // Remove the KeyguardRootView from any parent it might already have in legacy code
                // just in case (a view can't have two parents).
                (keyguardRootView.parent as? ViewGroup)?.removeView(keyguardRootView)
                settingsMenu = keyguardRootView.requireViewById(R.id.keyguard_settings_button)
                keyguardRootView
            },
            update = { keyguardRootView ->
            keyguardRootView.requireViewById<View>(R.id.lock_icon_view).setOnClickListener {
                viewModel.onLockButtonClicked()
                keyguardRootView.requireViewById<View>(R.id.lock_icon_view)
            },
            modifier = Modifier.fillMaxSize(),
        )
    }
}

@Composable
private fun LongPressSurface(
    viewModel: KeyguardLongPressViewModel,
    isSettingsMenuVisible: () -> Boolean,
    settingsMenuBounds: () -> Rect,
    modifier: Modifier = Modifier,
) {
    val isEnabled: Boolean by viewModel.isLongPressHandlingEnabled.collectAsState(initial = false)

    Box(
        modifier =
            modifier
                .combinedClickable(
                    enabled = isEnabled,
                    onLongClick = viewModel::onLongPress,
                    onClick = {},
                )
                .pointerInput(Unit) {
                    awaitEachGesture {
                        val pointerInputChange = awaitFirstDown()
                        if (
                            isSettingsMenuVisible() &&
                                !settingsMenuBounds().contains(pointerInputChange.position)
                        ) {
                            viewModel.onTouchedOutside()
                        }
                    }
                },
        modifier = modifier,
    )
}
+1 −16
Original line number Diff line number Diff line
@@ -17,11 +17,7 @@
package com.android.systemui.scene.ui.composable

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.dagger.SysUISingleton
@@ -54,17 +50,6 @@ class GoneScene @Inject constructor() : ComposableScene {
    override fun SceneScope.Content(
        modifier: Modifier,
    ) {
        /*
         * TODO(b/279501596): once we start testing with the real Content Dynamics Framework,
         *  replace this with an error to make sure it doesn't get rendered.
         */
        Box(modifier = modifier) {
            Column(
                horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.align(Alignment.Center)
            ) {
                Text("Gone", style = MaterialTheme.typography.headlineMedium)
            }
        }
        Box(modifier = modifier)
    }
}
Loading