Skip to content

Migrate Offline Area Screens to Compose - #3915

Open
shobhitagarwal1612 wants to merge 3 commits into
masterfrom
offline-selector
Open

Migrate Offline Area Screens to Compose#3915
shobhitagarwal1612 wants to merge 3 commits into
masterfrom
offline-selector

Conversation

@shobhitagarwal1612

@shobhitagarwal1612 shobhitagarwal1612 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Towards #1795

Migrates the offline area screens (selector screen, viewer screen & list offline areas screen) from XML to compose layout.

Before:

Screen_recording_20260901_144819.webm

After:

Screen_recording_20260901_144321.webm

@andreia-ferreira PTAL?

- Replace offline_area_selector_frag.xml with Compose OfflineAreaSelectorScreen
- Convert LiveData to StateFlow with OfflineAreaSelectorState and OfflineAreaSelectorEvent
- Inline and modernize DownloadProgressDialog inside OfflineAreaSelectorScreen
- Remove legacy viewport outline drawable
- Add comprehensive Compose UI and ViewModel unit tests
- Replace offline_area_viewer_frag.xml with Compose OfflineAreaViewerScreen
- Convert LiveData to StateFlow with OfflineAreaViewerState
- Modernize deletion flow and progress overlay in Compose
- Add comprehensive Compose UI and ViewModel unit tests
- Replace offline_areas_frag.xml with Compose OfflineAreasScreen
- Convert LiveData to StateFlow with OfflineAreasState
- Inline and modernize OfflineAreaListItem inside OfflineAreasScreen
- Clean up obsolete layouts, styles, and dimensions
- Add comprehensive Compose UI and ViewModel unit tests
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.49713% with 102 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.62%. Comparing base (94baf3c) to head (48b8173).

Files with missing lines Patch % Lines
...offlineareas/selector/OfflineAreaSelectorScreen.kt 77.77% 24 Missing and 10 partials ⚠️
...form/android/ui/offlineareas/OfflineAreasScreen.kt 79.48% 14 Missing and 10 partials ⚠️
.../ui/offlineareas/viewer/OfflineAreaViewerScreen.kt 74.71% 17 Missing and 5 partials ⚠️
...i/offlineareas/viewer/OfflineAreaViewerFragment.kt 61.11% 6 Missing and 1 partial ⚠️
.../offlineareas/viewer/OfflineAreaViewerViewModel.kt 77.77% 4 Missing and 2 partials ⚠️
...flineareas/selector/OfflineAreaSelectorFragment.kt 76.47% 2 Missing and 2 partials ⚠️
...rm/android/ui/offlineareas/OfflineAreasFragment.kt 86.36% 0 Missing and 3 partials ⚠️
...lineareas/selector/OfflineAreaSelectorViewModel.kt 95.74% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3915      +/-   ##
============================================
+ Coverage     69.36%   69.62%   +0.26%     
- Complexity     1963     1980      +17     
============================================
  Files           412      415       +3     
  Lines         11015    11330     +315     
  Branches       1453     1479      +26     
============================================
+ Hits           7641     7889     +248     
- Misses         2624     2677      +53     
- Partials        750      764      +14     
Files with missing lines Coverage Δ
...tform/android/ui/offlineareas/OfflineAreasState.kt 100.00% <100.00%> (ø)
...m/android/ui/offlineareas/OfflineAreasViewModel.kt 100.00% <100.00%> (+16.66%) ⬆️
.../offlineareas/selector/OfflineAreaSelectorEvent.kt 100.00% <ø> (ø)
.../offlineareas/selector/OfflineAreaSelectorState.kt 100.00% <100.00%> (ø)
...d/ui/offlineareas/viewer/OfflineAreaViewerState.kt 100.00% <100.00%> (ø)
...lineareas/selector/OfflineAreaSelectorViewModel.kt 94.11% <95.74%> (+5.69%) ⬆️
...rm/android/ui/offlineareas/OfflineAreasFragment.kt 88.46% <86.36%> (+1.50%) ⬆️
...flineareas/selector/OfflineAreaSelectorFragment.kt 71.79% <76.47%> (+0.36%) ⬆️
.../offlineareas/viewer/OfflineAreaViewerViewModel.kt 80.48% <77.77%> (-9.52%) ⬇️
...i/offlineareas/viewer/OfflineAreaViewerFragment.kt 74.19% <61.11%> (-6.76%) ⬇️
... and 3 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Box(modifier = modifier.fillMaxSize()) {
Column(modifier = Modifier.fillMaxSize()) {
Toolbar(
stringRes = R.string.offline_area_selector_title,

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.

nit: the title in the toolbar was previously centered and now it is left aligned

}

@Composable
fun DownloadProgressDialog(

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.

shouldn't this also be annotated with @VisibleForTesting?

offlineAreaRepository.removeFromDevice(deletedArea)
_uiState.update { it.copy(isProgressOverlayVisible = false, area = null) }
navigateUpChannel.send(Unit)
} catch (e: kotlinx.coroutines.CancellationException) {

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.

nit: import could be simplified

Comment on lines +111 to +112
Timber.e(e, "Failed to remove offline area")
_uiState.update { it.copy(isProgressOverlayVisible = false) }

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.

it's a nice improvement to have exception handling in this flow now. There is no user feedback in this error case though, maybe we can add an error toast with a generic string (eg. R.string.unexpected_error)?

modifier = modifier.fillMaxSize(),
topBar = {
Toolbar(
stringRes = R.string.offline_map_imagery,

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.

same comment here regarding centering the toolbar title

imageVector = ImageVector.vectorResource(id = R.drawable.ic_offline_pin),
contentDescription = stringResource(id = R.string.offline_area_list_item_icon),
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(24.dp),

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.

nit: consider extracting some reusable dimensions/paddings in these files to Size.kt

}

@Composable
private fun OfflineAreaSelectorButtons(

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.

i believe this component may be missing some inset paddings, in devices with a nav bar (screenshot from an API 24 emulator) the buttons get partially hidden behind it
Image

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