Skip to content

Migrate AbstractTaskMapFragment to Jetpack Compose - #3928

Merged
shobhitagarwal1612 merged 5 commits into
masterfrom
map-task
Sep 10, 2026
Merged

Migrate AbstractTaskMapFragment to Jetpack Compose#3928
shobhitagarwal1612 merged 5 commits into
masterfrom
map-task

Conversation

@shobhitagarwal1612

@shobhitagarwal1612 shobhitagarwal1612 commented Sep 9, 2026

Copy link
Copy Markdown
Member

Towards #1795

Description

Migrates AbstractTaskMapFragment from legacy XML view binding (map_task_frag.xml) to pure Jetpack Compose.
The map overlay UI is decomposed into a screen-level composable (TaskMapScreen) and an extracted leaf component (LocationInfoCard) with dedicated unit and integration tests.

Changes

  • Compose UI:
    • Add TaskMapScreen to host center crosshairs, map type button, recenter button, location lock button, and location info card.
    • Extract LocationInfoCard and @Immutable data class LocationInfo into tasks/map/components/.
    • Apply Material 3 theme tokens and Compose API guideline conventions (parameter ordering, weights).
  • Fragment:
    • Update AbstractTaskMapFragment to inflate BasemapLayoutBinding and set Compose content with DisposeOnViewTreeLifecycleDestroyed.
    • Stream location updates in onViewCreated using viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED).
    • Guard against map drag race condition by only updating _locationInfo from GPS stream when locationLock is active.
    • Hoist DecimalFormat to a companion object constant and reset view state in onDestroyView.
  • Cleanup:
    • Remove obsolete map_task_frag.xml layout.
    • Remove dead assertInfoCardShown / assertInfoCardHidden methods from TaskFragmentRunner.
  • Tests:
    • Add LocationInfoCardTest testing coordinate display, good/bad accuracy thresholds, unknown accuracy, and null safety.
    • Add TaskMapScreenTest verifying center marker, map buttons, recenter toggling, and info card integration.

Verification

  • ./gradlew ktfmtCheck passed
  • ./gradlew detekt passed (0 issues)
  • ./gradlew testLocalDebugUnitTest jvmTest testAndroidHostTest passed (all tests green)

Before

Screen_recording_20260909_183305.webm

After

Screen_recording_20260909_183035.webm

@andreia-ferreira PTAL?

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.39130% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.73%. Comparing base (a047f34) to head (fdeb4d2).

Files with missing lines Patch % Lines
...ui/datacollection/tasks/AbstractTaskMapFragment.kt 52.17% 19 Missing and 3 partials ⚠️
...droid/ui/datacollection/tasks/map/TaskMapScreen.kt 66.66% 12 Missing and 1 partial ⚠️
...ollection/tasks/map/components/LocationInfoCard.kt 81.13% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3928      +/-   ##
============================================
- Coverage     69.74%   69.73%   -0.02%     
- Complexity     1999     2000       +1     
============================================
  Files           420      422       +2     
  Lines         11466    11556      +90     
  Branches       1492     1502      +10     
============================================
+ Hits           7997     8058      +61     
- Misses         2699     2729      +30     
+ Partials        770      769       -1     
Files with missing lines Coverage Δ
...ollection/tasks/map/components/LocationInfoCard.kt 81.13% <81.13%> (ø)
...droid/ui/datacollection/tasks/map/TaskMapScreen.kt 66.66% <66.66%> (ø)
...ui/datacollection/tasks/AbstractTaskMapFragment.kt 50.70% <52.17%> (-9.57%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Replace map_task_frag.xml with pure Compose TaskMapScreen
- Update AbstractTaskMapFragment to inflate BasemapLayoutBinding
- Drive center crosshair and location info via StateFlows
- Remove obsolete map_task_frag.xml layout
- Add unit tests for TaskMapScreen and remove dead methods from TaskFragmentRunner
…mponent

- Move TaskMapScreen into dedicated ui.datacollection.tasks.map package
- Extract LocationInfo and LocationInfoCard leaf component into tasks.map.components package
- Update AbstractTaskMapFragment with new package imports
- Mirror test structure with TaskMapScreenTest and LocationInfoCardTest in matching packages
- Fix race condition during map pan by guarding location.collect with locationLock check
- Fix Fragment coroutine lifecycle scoping with viewLifecycleOwner.repeatOnLifecycle in onViewCreated
- Reset location info and crosshairs state in onDestroyView
- Hoist DecimalFormat to companion object in AbstractTaskMapFragment
- Adopt Material 3 colorScheme tokens, weight(1f), and blank checks in LocationInfoCard
- Reorder modifier parameter and convert test tags to top-level const val in TaskMapScreen
- Add missing branch and edge-case unit tests in LocationInfoCardTest and TaskMapScreenTest

@andreia-ferreira andreia-ferreira left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@shobhitagarwal1612
shobhitagarwal1612 merged commit f91b7f5 into master Sep 10, 2026
19 checks passed
@shobhitagarwal1612
shobhitagarwal1612 deleted the map-task branch September 10, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants