Consolidate location capture tasks and add location lock support#3341
Consolidate location capture tasks and add location lock support#3341anandwana001 wants to merge 20 commits intomasterfrom
Conversation
|
Please use a better issue title and update description to explain the changes being made and how are the changes verified. Thanks! |
|
Can you please attach a screen recording of the new changes? Also, I'm not able to follow the current PR description. Since the attached issue has a large thread, I would suggest adding the following details to the description.
|
…-location # Conflicts: # gradle/libs.versions.toml
shobhitagarwal1612
left a comment
There was a problem hiding this comment.
Can you please attach screen recordings?
- Legacy survey, once with capture location, then with drop a pin
- New survey, all combinations of
alllowMovingPointandallowManualOverridewith drop pin task
app/src/main/java/org/groundplatform/android/data/local/room/converter/ValueJsonConverter.kt
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/data/local/room/converter/ValueJsonConverter.kt
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/data/remote/firebase/schema/TaskConverter.kt
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/data/remote/firebase/schema/TaskConverter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/data/remote/firebase/schema/TaskConverter.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/org/groundplatform/android/ui/datacollection/tasks/point/DropPinTaskFragment.kt
Outdated
Show resolved
Hide resolved
…in-capture-location' into anandwana001/3148/combine-drop-pin-capture-location
|
Can you please attach the screen recordings as requested in previous comment? |
|
@gino-m Can you please take a pass at this PR too? |
gino-m
left a comment
There was a problem hiding this comment.
I made it half way through, but overall looking at the PR description I think it's clear this PR is trying to do too many things. Can it be split int two or three smaller targeted PRs please?
| val allowMovingPoint = getAllowMovingPoint(taskType, task) | ||
|
|
||
| // Determine if user can manually override location lock for draw area tasks | ||
| val allowManualOverride = getAllowManualOverride(taskType, task) |
There was a problem hiding this comment.
Iiuc, this splits the condition into two, allowManualOverride for area, allowMovingPoint for point. Since we're calling both cases "manual location override", can we merge these into one condition, allowManualOverride?
| * Whether the user can pan/zoom the map to place a point anywhere (true), or can only capture | ||
| * their GPS location (false). Only applies to DROP_PIN tasks. | ||
| */ | ||
| val allowMovingPoint: Boolean = true, |
| * - For other tasks: Defaults to true (allow moving). | ||
| */ | ||
| @Suppress("UnusedParameter") | ||
| private fun getAllowMovingPoint(taskType: Task.Type, task: TaskProto): Boolean = |
| } else { | ||
| // Mode: GPS location only | ||
| addButton(ButtonAction.CAPTURE_LOCATION) | ||
| .setOnClickListener { viewModel.captureLocation() } |
There was a problem hiding this comment.
The viewModel entry point and button label can be the same ("Add point" --> addPoint())
| } | ||
|
|
||
| if (!viewModel.task.allowMovingPoint) { | ||
| viewModel.enableLocationLock() |
There was a problem hiding this comment.
We always want to enable location lock to its previous state, even when manual override is allowed.
| /** The location lock was not already enabled. */ | ||
| NEEDS_ENABLE, | ||
|
|
||
| /** Trigger to enable the location lock. */ |
There was a problem hiding this comment.
Is this a state or an event? From the ktdoc comments here and above it seems like it might be mixing both?
| import org.groundplatform.android.ui.map.gms.getAltitudeOrNull | ||
| import org.groundplatform.android.ui.map.gms.toCoordinates | ||
|
|
||
| /** Location lock states relevant for attempting to enable it or not. */ |
There was a problem hiding this comment.
Can you please clarify what you mean here?
| when (taskData) { | ||
| is DropPinTaskData -> dropMarker(taskData.location) | ||
| is CaptureLocationTaskData -> dropMarker(taskData.location) | ||
| else -> {} |
There was a problem hiding this comment.
Does this represent an illegal state? If so should we log an error and exit?
|
Given the complexity and the number of touched files, I agree with the recommendation that we split this into smaller, incremental PRs to de-risk regressions. This PR currently covers a lot of ground, including:
Proposed Strategy: We can introduce a temporary config flag (e.g., Suggested Rollout Plan:
This allows us to review the logic changes in isolation without worrying about breaking the existing user flow immediately. WDYT? |
Fixes #3148 and #3149
This PR consolidates the CaptureLocationTask functionality into the existing DropPinTask and adds configurable location lock behavior for both point and area drawing tasks. This reduces code duplication and provides more flexible location capture options based on task configuration.
Key Changes
Merged CaptureLocationTask into DropPinTask
Removed 3 separate CaptureLocationTask files 260 lines of code
Extended DropPinTaskFragment, DropPinTaskViewModel, and DropPinTaskMapFragment to support both modes:
Free placement mode: User can pan/zoom map to drop pin anywhere
GPS-only mode: User can only capture their current device location
Mode is determined by the new allowMovingPoint property on the Task model
Appropriate UI buttons shown based on mode DROP_PIN vs CAPTURE_LOCATION
Different instruction dialogs shown for each mode
Added Location Lock Support for DrawAreaTask
Added allowManualOverride property to Task model for area drawing tasks
When allowManualOverride is false, location lock cannot be disengaged and map gestures are disabled
When allowManualOverride is true default, location lock starts enabled but can be turned off by panning
Added location permission dialog flow for enforced location lock scenarios
Updated Task Model & Conversion
Added two new boolean properties to Task:
allowMovingPoint: Controls whether user can freely place points applies to DROP_PIN tasks
allowManualOverride: Controls whether location lock can be overridden applies to DRAW_AREA tasks
Updated TaskConverter to read these properties from Firebase proto schema
Updated ValueJsonConverter for proper JSON serialization of new properties
Data Submission Updates
Modified SubmitDataUseCase to handle both DROP_PIN and legacy CAPTURE_LOCATION task types
Both task types now submit point geometry data appropriately
Removed Unused Resources
Cleaned up unused string resources across all localization files es, fr, pt, vi
Removed CaptureLocationTaskViewModel from ViewModelModule
Impact
Code reduction: Net reduction of 150 lines of code 456 insertions, 311 deletions
Improved maintainability: Single implementation for point-based location capture
Enhanced flexibility: Task behavior now configurable via proto schema
Backward compatibility: Legacy CAPTURE_LOCATION tasks still supported in data submission
Testing
Updated CaptureLocationTaskFragmentTest to work with consolidated implementation
Updated FakeData to include new task properties
@shobhitagarwal1612 PTAL?