diff --git a/ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/TaskConverter.kt b/ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/TaskConverter.kt index 3125cb6749..a959b77b7b 100644 --- a/ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/TaskConverter.kt +++ b/ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/TaskConverter.kt @@ -57,7 +57,7 @@ internal object TaskConverter { "draw_area" -> Task.Type.DRAW_AREA "number" -> Task.Type.NUMBER "date" -> Task.Type.DATE - "time" -> Task.Type.TIME + "date_time" -> Task.Type.TIME "capture_location" -> Task.Type.CAPTURE_LOCATION else -> Task.Type.UNKNOWN } diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/AbstractTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/AbstractTaskFragment.kt index bf8a4a829a..bdfa41b2fe 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/AbstractTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/AbstractTaskFragment.kt @@ -91,6 +91,13 @@ abstract class AbstractTaskFragment : AbstractFragmen } } + override fun setMenuVisibility(menuVisible: Boolean) { + super.setMenuVisibility(menuVisible) + if (menuVisible) { + onTaskVisibleToUser() + } + } + /** Creates the view for common task template with/without header. */ abstract fun onCreateTaskView(inflater: LayoutInflater): TaskView @@ -100,6 +107,9 @@ abstract class AbstractTaskFragment : AbstractFragmen /** Invoked after the task view gets attached to the fragment. */ open fun onTaskViewAttached() {} + /** Invoked when the task fragment is visible to the user. */ + open fun onTaskVisibleToUser() {} + /** Invoked when the fragment is ready to add buttons to the current [TaskView]. */ open fun onCreateActionButtons() { addSkipButton() diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt index 5b649309ed..c7c48ec257 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt @@ -96,7 +96,9 @@ class DrawAreaTaskFragment : AbstractTaskFragment() { viewLifecycleOwner.lifecycleScope.launch { viewModel.draftArea.collectLatest { onFeatureUpdated(it) } } + } + override fun onTaskVisibleToUser() { if (!viewModel.instructionsDialogShown) { showInstructionsDialog() } diff --git a/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragmentTest.kt b/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragmentTest.kt index 00e35211ea..1c666f088c 100644 --- a/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragmentTest.kt +++ b/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragmentTest.kt @@ -110,6 +110,7 @@ class DrawAreaTaskFragmentTest : @Test fun testDrawArea_incompleteWhenTaskIsOptional() = runWithTestDispatcher { setupTaskFragment(job, task.copy(isRequired = false)) + fragment.onTaskVisibleToUser() // Dismiss the instructions dialog ShadowDialog.getLatestDialog().dismiss() @@ -142,6 +143,7 @@ class DrawAreaTaskFragmentTest : @Test fun testDrawArea() = runWithTestDispatcher { setupTaskFragment(job, task.copy(isRequired = false)) + fragment.onTaskVisibleToUser() // Dismiss the instructions dialog ShadowDialog.getLatestDialog().dismiss() @@ -178,6 +180,7 @@ class DrawAreaTaskFragmentTest : @Test fun `Instructions dialog is shown`() = runWithTestDispatcher { setupTaskFragment(job, task) + fragment.onTaskVisibleToUser() assertThat(ShadowDialog.getLatestDialog()).isNotNull() }