Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,4 @@ object GroundApplicationModule {
@Singleton
fun provideWorkManager(@ApplicationContext context: Context): WorkManager =
WorkManager.getInstance(context)

@Provides
@UnifyCaptureLocationTask
@Suppress("FunctionOnlyReturningConstant")
fun provideUnifyCaptureLocationTask(): Boolean = false
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import org.groundplatform.android.UnifyCaptureLocationTask
import org.groundplatform.android.coroutines.ApplicationScope
import org.groundplatform.android.coroutines.IoDispatcher
import org.groundplatform.android.data.local.room.converter.SubmissionDeltasConverter
Expand Down Expand Up @@ -69,7 +68,6 @@ internal constructor(
private val popups: Provider<EphemeralPopups>,
private val viewModelFactory: ViewModelFactory,
private val dataCollectionInitializer: DataCollectionInitializer,
@UnifyCaptureLocationTask private val unifyCaptureLocationTask: Boolean,
) : AbstractViewModel() {

private val _uiState = MutableStateFlow<DataCollectionUiState>(DataCollectionUiState.Loading)
Expand Down Expand Up @@ -199,7 +197,7 @@ internal constructor(

val viewModel =
try {
viewModelFactory.create(getViewModelClass(task.type, unifyCaptureLocationTask))
viewModelFactory.create(getViewModelClass(task.type))
} catch (e: Exception) {
Timber.e(e, "Ignoring task with invalid type: ${task.type}")
null
Expand Down Expand Up @@ -361,10 +359,7 @@ internal constructor(
private const val TASK_DRAFT_VALUES = "draftValues"
private const val TASK_SHOULD_LOAD_FROM_DRAFT = "shouldLoadFromDraft"

fun getViewModelClass(
taskType: Task.Type,
unifyCaptureLocationTask: Boolean = false,
): Class<out AbstractTaskViewModel> =
fun getViewModelClass(taskType: Task.Type): Class<out AbstractTaskViewModel> =
when (taskType) {
Task.Type.TEXT -> TextTaskViewModel::class.java
Task.Type.MULTIPLE_CHOICE -> MultipleChoiceTaskViewModel::class.java
Expand All @@ -374,9 +369,7 @@ internal constructor(
Task.Type.TIME -> TimeTaskViewModel::class.java
Task.Type.DROP_PIN -> DropPinTaskViewModel::class.java
Task.Type.DRAW_AREA -> DrawAreaTaskViewModel::class.java
Task.Type.CAPTURE_LOCATION ->
if (unifyCaptureLocationTask) DropPinTaskViewModel::class.java
else CaptureLocationTaskViewModel::class.java
Task.Type.CAPTURE_LOCATION -> CaptureLocationTaskViewModel::class.java
Task.Type.INSTRUCTIONS -> InstructionTaskViewModel::class.java
Task.Type.UNKNOWN -> throw IllegalArgumentException("Unsupported task type: $taskType")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import javax.inject.Provider
import org.groundplatform.android.UnifyCaptureLocationTask
import org.groundplatform.android.model.task.Task
import org.groundplatform.android.ui.datacollection.tasks.date.DateTaskFragment
import org.groundplatform.android.ui.datacollection.tasks.instruction.InstructionTaskFragment
Expand All @@ -42,7 +41,6 @@ constructor(
private val drawAreaTaskFragmentProvider: Provider<DrawAreaTaskFragment>,
private val captureLocationTaskFragmentProvider: Provider<CaptureLocationTaskFragment>,
private val dropPinTaskFragmentProvider: Provider<DropPinTaskFragment>,
@UnifyCaptureLocationTask private val unifyCaptureLocationTask: Boolean,
@Assisted fragment: Fragment,
@Assisted val tasks: List<Task>,
) : FragmentStateAdapter(fragment) {
Expand All @@ -61,12 +59,7 @@ constructor(
Task.Type.NUMBER -> NumberTaskFragment()
Task.Type.DATE -> DateTaskFragment()
Task.Type.TIME -> TimeTaskFragment()
Task.Type.CAPTURE_LOCATION ->
if (unifyCaptureLocationTask) {
dropPinTaskFragmentProvider.get()
} else {
captureLocationTaskFragmentProvider.get()
}
Task.Type.CAPTURE_LOCATION -> captureLocationTaskFragmentProvider.get()
Task.Type.INSTRUCTIONS -> InstructionTaskFragment()
Task.Type.UNKNOWN ->
throw UnsupportedOperationException("Unsupported task type: ${task.type}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ class DropPinTaskMapFragment @Inject constructor() :
override fun onMapReady(map: MapFragment) {
super.onMapReady(map)

if (taskViewModel.unifyCaptureLocationTask) {
viewLifecycleOwner.lifecycleScope.launch {
taskViewModel.initLocationUpdates(getMapViewModel())
}
}

// Disable pan/zoom gestures if a marker has been placed on the map.
lifecycleScope.launch {
taskViewModel.features.asFlow().collect { features ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import javax.inject.Inject
import kotlinx.coroutines.launch
import org.groundplatform.android.UnifyCaptureLocationTask
import org.groundplatform.android.data.local.LocalValueStore
import org.groundplatform.android.data.uuid.OfflineUuidGenerator
import org.groundplatform.android.model.geometry.Point
Expand All @@ -36,7 +35,6 @@ class DropPinTaskViewModel
constructor(
private val uuidGenerator: OfflineUuidGenerator,
private val localValueStore: LocalValueStore,
@UnifyCaptureLocationTask val unifyCaptureLocationTask: Boolean,
) : AbstractMapTaskViewModel() {

private var pinColor: Int = 0
Expand All @@ -49,10 +47,6 @@ constructor(
super.initialize(job, task, taskData)
pinColor = job.getDefaultColor()

if (unifyCaptureLocationTask) {
captureLocation = task.type == Task.Type.CAPTURE_LOCATION
}

// Drop a marker for current value
(taskData as? DropPinTaskData)?.let { dropMarker(it.location) }
}
Expand Down