Skip to content

Migrate PhotoTaskFragment to use TaskScreen Component#3654

Merged
shobhitagarwal1612 merged 20 commits intomasterfrom
photo-task-compose-2
Apr 9, 2026
Merged

Migrate PhotoTaskFragment to use TaskScreen Component#3654
shobhitagarwal1612 merged 20 commits intomasterfrom
photo-task-compose-2

Conversation

@shobhitagarwal1612
Copy link
Copy Markdown
Member

@shobhitagarwal1612 shobhitagarwal1612 commented Apr 3, 2026

Towards #3630

  • Introduce PhotoTaskScreen Composable to handle the UI.
  • Update PhotoTaskFragment to use createComposeView and render the new PhotoTaskScreen.
  • Move all state logic to PhotoTaskScreen
  • Replace PhotoTaskFragmentTest with PhotoTaskScreenTest and add more coverage
  • Also removed one extra call to copy the image data from URI.
  • Also adds new message strings for unhandled error states.
Screen_recording_20260403_161428.webm

@andreia-ferreira PTAL?

- Introduce `PhotoTaskScreen` to manage the UI state and layout for photo tasks, integrating the new `TaskScreen` component.
- Move `PhotoTaskContent` and `CaptureButton` into `PhotoTaskScreen.kt`.
- Add `PhotoTaskScreenTest` to verify UI components, action button states, and permission dialog visibility.
…ling and state management

- Replace `MutableSharedFlow` with `Channel` for photo task events to ensure reliable event delivery.
- Convert the `uri` property from a `Flow` to a `StateFlow` using `stateIn`.
- Update `PhotoTaskScreen` to collect events using `flowWithLifecycle` for better lifecycle awareness.
- Replace `File` object storage with `tempPhotoFilePath` string in `PhotoTaskViewModel` to handle process death and persistence more effectively.
- Ensure `isAwaitingPhotoCapture` is correctly reset to `false` when photo capture permissions are denied.
- Use `rememberUpdatedState` for the `onAwaitingPhotoCapture` callback in `PhotoTaskScreen`.
- Update unit tests to reflect the change to `Channel` for events and ensure proper file path handling.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 78.98551% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.80%. Comparing base (4a28818) to head (654ac0d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...d/ui/datacollection/tasks/photo/PhotoTaskScreen.kt 75.34% 15 Missing and 3 partials ⚠️
...ui/datacollection/tasks/photo/PhotoTaskFragment.kt 0.00% 6 Missing ⚠️
...i/datacollection/tasks/photo/PhotoTaskViewModel.kt 89.58% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3654      +/-   ##
============================================
+ Coverage     66.70%   66.80%   +0.10%     
+ Complexity     1628     1608      -20     
============================================
  Files           362      363       +1     
  Lines          8944     8980      +36     
  Branches       1154     1159       +5     
============================================
+ Hits           5966     5999      +33     
- Misses         2326     2332       +6     
+ Partials        652      649       -3     
Files with missing lines Coverage Δ
...droid/ui/datacollection/DataCollectionViewModel.kt 73.29% <100.00%> (-0.39%) ⬇️
...id/ui/datacollection/tasks/AbstractTaskFragment.kt 78.40% <ø> (-1.82%) ⬇️
...d/ui/datacollection/tasks/AbstractTaskViewModel.kt 89.58% <100.00%> (+0.45%) ⬆️
...asks/multiplechoice/MultipleChoiceTaskViewModel.kt 80.32% <100.00%> (ø)
...id/ui/datacollection/tasks/photo/PhotoTaskEvent.kt 100.00% <100.00%> (ø)
...datacollection/tasks/point/DropPinTaskViewModel.kt 90.00% <100.00%> (ø)
...acollection/tasks/polygon/DrawAreaTaskViewModel.kt 80.68% <100.00%> (ø)
...i/datacollection/tasks/photo/PhotoTaskViewModel.kt 91.07% <89.58%> (+0.44%) ⬆️
...ui/datacollection/tasks/photo/PhotoTaskFragment.kt 0.00% <0.00%> (-58.19%) ⬇️
...d/ui/datacollection/tasks/photo/PhotoTaskScreen.kt 75.34% <75.34%> (ø)

... 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.

@shobhitagarwal1612
Copy link
Copy Markdown
Member Author

@andreia-ferreira Can you PTAL?

Copy link
Copy Markdown
Collaborator

@andreia-ferreira andreia-ferreira left a comment

Choose a reason for hiding this comment

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

Screen_recording_20260407_105318.webm

cancelling the camera intent (by clicking back for example) should not be treated as an error I believe. Also both the error state and taking a picture seem to cause the progress bar to have a wrong position bellow the footer buttons.

Tested on a pixel 9 pro fold, API 36.1

@shobhitagarwal1612
Copy link
Copy Markdown
Member Author

Not sure why the test is failing on CI?
@andreia-ferreira any ideas? I'm unable to run these tests locally.

@andreia-ferreira
Copy link
Copy Markdown
Collaborator

andreia-ferreira commented Apr 9, 2026

the tests passed locally for me, so probably the failure was because of a corrupted Gradle cache in the CI. The cache wasn't reused in this latest run (possibly due to invalidation), and the tests are now passing. But if it happens again we can try to delete that cache under actions -> caches

@shobhitagarwal1612 shobhitagarwal1612 merged commit a43360d into master Apr 9, 2026
9 checks passed
@shobhitagarwal1612 shobhitagarwal1612 deleted the photo-task-compose-2 branch April 9, 2026 14:11
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