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

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

Merge changes from topic "flexiglass-long-press-rename" into main

* changes:
  [flexiglass] Renames KeyguardLongPress<*>
  [flexiglass] Wake up from AOD when lockscreen tapped.
parents 691986df fc066743
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -19,9 +19,10 @@
package com.android.systemui.keyguard.ui.composable

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.gestures.detectTapGestures
import androidx.compose.foundation.indication
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
@@ -33,12 +34,14 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.input.pointer.pointerInput
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel
import com.android.systemui.communal.ui.compose.extensions.detectLongPressGesture
import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel

/** Container for lockscreen content that handles long-press to bring up the settings menu. */
@Composable
// TODO(b/344879669): now that it's more generic than long-press, rename it.
fun LockscreenLongPress(
    viewModel: KeyguardLongPressViewModel,
    viewModel: KeyguardTouchHandlingViewModel,
    modifier: Modifier = Modifier,
    content: @Composable BoxScope.(onSettingsMenuPlaces: (coordinates: Rect?) -> Unit) -> Unit,
) {
@@ -50,14 +53,17 @@ fun LockscreenLongPress(
    Box(
        modifier =
            modifier
                .combinedClickable(
                    enabled = isEnabled,
                    onLongClick = viewModel::onLongPress,
                    onClick = {},
                    interactionSource = interactionSource,
                    // Passing null for the indication removes the ripple effect.
                    indication = null,
                .pointerInput(isEnabled) {
                    if (isEnabled) {
                        detectLongPressGesture { viewModel.onLongPress() }
                    }
                }
                .pointerInput(Unit) {
                    detectTapGestures(
                        onTap = { viewModel.onClick(it.x, it.y) },
                        onDoubleTap = { viewModel.onDoubleClick() },
                    )
                }
                .pointerInput(settingsMenuBounds) {
                    awaitEachGesture {
                        val pointerInputChange = awaitFirstDown()
@@ -65,7 +71,9 @@ fun LockscreenLongPress(
                            viewModel.onTouchedOutside()
                        }
                    }
                },
                }
                // Passing null for the indication removes the ripple effect.
                .indication(interactionSource, null)
    ) {
        content(setSettingsMenuBounds)
    }
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ constructor(
    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
        LockscreenLongPress(
            viewModel = viewModel.longPress,
            viewModel = viewModel.touchHandling,
            modifier = modifier,
        ) { _ ->
            Box(modifier.background(Color.Black)) {
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ constructor(
        val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()

        LockscreenLongPress(
            viewModel = viewModel.longPress,
            viewModel = viewModel.touchHandling,
            modifier = modifier,
        ) { onSettingsMenuPlaced ->
            Layout(
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ constructor(
        val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()

        LockscreenLongPress(
            viewModel = viewModel.longPress,
            viewModel = viewModel.touchHandling,
            modifier = modifier,
        ) { onSettingsMenuPlaced ->
            Layout(
+3 −3
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ import androidx.compose.ui.unit.toSize
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.view.isVisible
import com.android.systemui.keyguard.ui.binder.KeyguardSettingsViewBinder
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSettingsMenuViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.statusbar.VibratorHelper
@@ -42,7 +42,7 @@ class SettingsMenuSection
@Inject
constructor(
    private val viewModel: KeyguardSettingsMenuViewModel,
    private val longPressViewModel: KeyguardLongPressViewModel,
    private val touchHandlingViewModel: KeyguardTouchHandlingViewModel,
    private val vibratorHelper: VibratorHelper,
    private val activityStarter: ActivityStarter,
) {
@@ -69,7 +69,7 @@ constructor(
                            KeyguardSettingsViewBinder.bind(
                                view = this,
                                viewModel = viewModel,
                                longPressViewModel = longPressViewModel,
                                touchHandlingViewModel = touchHandlingViewModel,
                                rootViewModel = null,
                                vibratorHelper = vibratorHelper,
                                activityStarter = activityStarter,
Loading