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

Commit 1b0236f9 authored by Tianfan Zhang's avatar Tianfan Zhang Committed by Android (Google) Code Review
Browse files

Merge "Enable one tap action in SysUI." into main

parents d4cad392 8c92c4c7
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -44,6 +45,8 @@ import com.android.systemui.ambientcue.ui.viewmodel.ActionViewModel
import com.android.systemui.ambientcue.ui.viewmodel.AmbientCueViewModel
import com.android.systemui.ambientcue.ui.viewmodel.PillStyleViewModel
import com.android.systemui.lifecycle.rememberViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Composable
fun AmbientCueContainer(
@@ -196,6 +199,8 @@ private fun NavBarAmbientCue(
        if (windowWidthSizeClass == WindowWidthSizeClass.Compact) NAV_BAR_PILL_WIDTH_DP.dp
        else NAV_BAR_PILL_LARGE_WIDTH_DP.dp

    val scope = rememberCoroutineScope()

    LaunchedEffect(expanded) { onShouldInterceptTouches(expanded, null) }
    ActionList(
        actions = actions,
@@ -218,7 +223,16 @@ private fun NavBarAmbientCue(
        expanded = expanded,
        showEducation = viewModel.showFirstTimeEducation,
        modifier = modifier,
        onClick = { viewModel.expand() },
        onClick = {
            if (actions.size == 1 && actions[0].oneTapEnabled) {
                scope.launch {
                    delay(ONE_TAP_DELAY_MS)
                    actions[0].onClick()
                }
            } else {
                viewModel.expand()
            }
        },
        onCloseClick = { viewModel.hide() },
    )
}
@@ -232,3 +246,5 @@ private const val NAV_BAR_HEIGHT_DP = 24 // R.dimen.taskbar_stashed_size from La
private const val SHORT_PILL_ACTIONS_VERTICAL_PADDING = 38
private const val NAV_BAR_ACTIONS_PADDING = NAV_BAR_HEIGHT_DP + 16
private const val ACTIONS_HORIZONTAL_PADDING = 32

private const val ONE_TAP_DELAY_MS = 500L
+3 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ constructor(
                                val activityId =
                                    chip.extras?.getParcelable<ActivityId>(EXTRA_ACTIVITY_ID)
                                val actionType = chip.extras?.getString(EXTRA_ACTION_TYPE)
                                val oneTapEnabled = chip.extras?.getBoolean(EXTRA_ONE_TAP_ENABLED)
                                ActionModel(
                                    icon =
                                        IconModel(
@@ -228,6 +229,7 @@ constructor(
                                    },
                                    taskId = activityId?.taskId ?: INVALID_TASK_ID,
                                    actionType = actionType,
                                    oneTapEnabled = oneTapEnabled == true,
                                )
                            }
                    if (DEBUG) {
@@ -403,6 +405,7 @@ constructor(
        @VisibleForTesting
        const val EXTRA_ATTRIBUTION_DIALOG_PENDING_INTENT = "attributionDialogPendingIntent"
        @VisibleForTesting const val EXTRA_ACTION_TYPE = "actionType"
        private const val EXTRA_ONE_TAP_ENABLED = "oneTapEnabled"

        // Timeout to hide cuebar if it wasn't interacted with
        private const val TAG = "AmbientCueRepository"
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ data class ActionModel(
    val onPerformLongClick: () -> Unit,
    val taskId: Int = INVALID_TASK_ID,
    val actionType: String? = null,
    val oneTapEnabled: Boolean = false,
)

data class IconModel(val drawable: Drawable, val iconId: String)
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ data class ActionViewModel(
    val onClick: () -> Unit,
    val onLongClick: () -> Unit,
    val actionType: ActionType,
    val oneTapEnabled: Boolean = false,
)

enum class ActionType {
+1 −0
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ constructor(
                                    "mr" -> ActionType.MR
                                    else -> ActionType.Unknown
                                },
                            oneTapEnabled = action.oneTapEnabled,
                        )
                    }
                },