summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt2
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt15
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt23
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt15
5 files changed, 60 insertions, 4 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 d20154437e02..d3d8e4ed3523 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
@@ -172,7 +172,7 @@ private fun BoxScope.CommunalHubLazyGrid(
gridModifier =
gridModifier
.fillMaxSize()
- .dragContainer(dragDropState, beforeContentPadding(contentPadding))
+ .dragContainer(dragDropState, beforeContentPadding(contentPadding), viewModel)
.onGloballyPositioned { setGridCoordinates(it) }
// for widgets dropped from other activities
val dragAndDropTargetState =
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
index 1b40de4ef5df..113822167ca7 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
@@ -40,6 +40,7 @@ import androidx.compose.ui.unit.toOffset
import androidx.compose.ui.unit.toSize
import androidx.compose.ui.zIndex
import com.android.systemui.communal.ui.compose.extensions.plus
+import com.android.systemui.communal.ui.viewmodel.BaseCommunalViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
@@ -207,7 +208,8 @@ internal constructor(
fun Modifier.dragContainer(
dragDropState: GridDragDropState,
- beforeContentPadding: ContentPaddingInPx
+ beforeContentPadding: ContentPaddingInPx,
+ viewModel: BaseCommunalViewModel,
): Modifier {
return pointerInput(dragDropState, beforeContentPadding) {
detectDragGesturesAfterLongPress(
@@ -220,9 +222,16 @@ fun Modifier.dragContainer(
offset,
Offset(beforeContentPadding.startPadding, beforeContentPadding.topPadding)
)
+ viewModel.onReorderWidgetStart()
},
- onDragEnd = { dragDropState.onDragInterrupted() },
- onDragCancel = { dragDropState.onDragInterrupted() }
+ onDragEnd = {
+ dragDropState.onDragInterrupted()
+ viewModel.onReorderWidgetEnd()
+ },
+ onDragCancel = {
+ dragDropState.onDragInterrupted()
+ viewModel.onReorderWidgetCancel()
+ }
)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt
index c638e1ea89ee..ff6fd43745df 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt
@@ -26,6 +26,7 @@ import android.provider.Settings
import android.widget.RemoteViews
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository
import com.android.systemui.communal.data.repository.FakeCommunalRepository
@@ -33,6 +34,7 @@ import com.android.systemui.communal.data.repository.FakeCommunalTutorialReposit
import com.android.systemui.communal.data.repository.FakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.CommunalInteractorFactory
import com.android.systemui.communal.domain.model.CommunalContentModel
+import com.android.systemui.communal.shared.log.CommunalUiEvent
import com.android.systemui.communal.shared.model.CommunalWidgetContentModel
import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel
import com.android.systemui.coroutines.collectLastValue
@@ -54,6 +56,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito
+import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
@OptIn(ExperimentalCoroutinesApi::class)
@@ -64,6 +67,7 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {
@Mock private lateinit var shadeViewController: ShadeViewController
@Mock private lateinit var powerManager: PowerManager
@Mock private lateinit var appWidgetHost: AppWidgetHost
+ @Mock private lateinit var uiEventLogger: UiEventLogger
private val kosmos = testKosmos()
private val testScope = kosmos.testScope
@@ -96,6 +100,7 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {
Provider { shadeViewController },
powerManager,
mediaHost,
+ uiEventLogger,
)
}
@@ -203,4 +208,22 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {
val providerTwo = ComponentName("pkg.test", "testWidget2")
underTest.onAddWidget(componentName = providerTwo, priority = 0)
}
+
+ @Test
+ fun reorderWidget_uiEventLogging_start() {
+ underTest.onReorderWidgetStart()
+ verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_START)
+ }
+
+ @Test
+ fun reorderWidget_uiEventLogging_end() {
+ underTest.onReorderWidgetEnd()
+ verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_FINISH)
+ }
+
+ @Test
+ fun reorderWidget_uiEventLogging_cancel() {
+ underTest.onReorderWidgetCancel()
+ verify(uiEventLogger).log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_CANCEL)
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt
index 97e530ace9a7..4cb83a3b51dc 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt
@@ -116,4 +116,13 @@ abstract class BaseCommunalViewModel(
/** Gets the interaction handler used to handle taps on a remote view */
abstract fun getInteractionHandler(): RemoteViews.InteractionHandler
+
+ /** Called as the user starts dragging a widget to reorder. */
+ open fun onReorderWidgetStart() {}
+
+ /** Called as the user finishes dragging a widget to reorder. */
+ open fun onReorderWidgetEnd() {}
+
+ /** Called as the user cancels dragging a widget to reorder. */
+ open fun onReorderWidgetCancel() {}
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
index a03e6c1aee97..0cbf3f1312e2 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
@@ -25,8 +25,10 @@ import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.os.PowerManager
import android.widget.RemoteViews
+import com.android.internal.logging.UiEventLogger
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
+import com.android.systemui.communal.shared.log.CommunalUiEvent
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.media.controls.ui.MediaHost
import com.android.systemui.media.dagger.MediaModule
@@ -50,6 +52,7 @@ constructor(
shadeViewController: Provider<ShadeViewController>,
powerManager: PowerManager,
@Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
+ private val uiEventLogger: UiEventLogger,
) : BaseCommunalViewModel(communalInteractor, shadeViewController, powerManager, mediaHost) {
private companion object {
@@ -135,4 +138,16 @@ constructor(
pendingConfiguration?.complete(resultCode)
?: throw IllegalStateException("No widget pending configuration")
}
+
+ override fun onReorderWidgetStart() {
+ uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_START)
+ }
+
+ override fun onReorderWidgetEnd() {
+ uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_FINISH)
+ }
+
+ override fun onReorderWidgetCancel() {
+ uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_CANCEL)
+ }
}