diff options
| author | 2024-09-11 18:01:16 +0000 | |
|---|---|---|
| committer | 2024-09-11 18:01:16 +0000 | |
| commit | 5ceda28d2d7eed5b43c133e5de8587958fcd486c (patch) | |
| tree | 312fef7b093f67e7e7496f7171c0bde484ba0ec3 | |
| parent | 39466d9ba2495bfe7fa4e1a40eeeddaa8de4c3b3 (diff) | |
| parent | 987a983df81727d45951ee71d8ee131301084abc (diff) | |
Merge "Enabling swiping multiple umo" into main
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt index c63b29dd9051..efe0f2e815da 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt @@ -19,7 +19,9 @@ package com.android.systemui.communal.ui.compose import android.content.Context import android.content.res.Configuration import android.graphics.drawable.Icon +import android.os.SystemClock import android.util.SizeF +import android.view.MotionEvent import android.widget.FrameLayout import android.widget.RemoteViews import androidx.annotation.VisibleForTesting @@ -40,6 +42,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.focusable import androidx.compose.foundation.gestures.awaitFirstDown +import androidx.compose.foundation.gestures.detectHorizontalDragGestures import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -1389,17 +1392,35 @@ private fun TutorialContent(modifier: Modifier = Modifier) { @Composable private fun Umo(viewModel: BaseCommunalViewModel, modifier: Modifier = Modifier) { AndroidView( - modifier = modifier, - factory = { - viewModel.mediaHost.hostView.layoutParams = - FrameLayout.LayoutParams( - FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.MATCH_PARENT - ) + modifier = + modifier.pointerInput(Unit) { + detectHorizontalDragGestures { change, _ -> + change.consume() + val upTime = SystemClock.uptimeMillis() + val event = + MotionEvent.obtain( + upTime, + upTime, + MotionEvent.ACTION_MOVE, + change.position.x, + change.position.y, + 0 + ) + viewModel.mediaHost.hostView.dispatchTouchEvent(event) + event.recycle() + } + }, + factory = { _ -> + viewModel.mediaHost.hostView.apply { + layoutParams = + FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) + } viewModel.mediaHost.hostView }, - // For reusing composition in lazy lists. - onReset = {}, + onReset = {} ) } |