Skip to content

Refactor DateTaskFragment to use TaskScreen component#3643

Open
shobhitagarwal1612 wants to merge 12 commits intomasterfrom
tasks-compose-2
Open

Refactor DateTaskFragment to use TaskScreen component#3643
shobhitagarwal1612 wants to merge 12 commits intomasterfrom
tasks-compose-2

Conversation

@shobhitagarwal1612
Copy link
Copy Markdown
Member

@shobhitagarwal1612 shobhitagarwal1612 commented Mar 30, 2026

Towards #3630

Migrate DateTaskFragment to compose component.

  • Create DateTaskScreen to build the task UI rather than AbstractTaskFragment
  • Replace android based date picker with compose based date picker dialog
  • Replace DateTaskFragmentTest with DateTaskScreenTest

Once all screens are migrated to compose components, fragments can be removed entirely to make the data collection module compatible with KMP (except map based fragment, which will require some iOS based interface).

Before:

date-task-refactor-before.webm

After:

date-task-refactor-after.-.2.webm

@andreia-ferreira PTAL?

- Extract date task UI logic into `DateTaskScreen.kt`, including the `DateTaskContent` and date picker dialog handling.
- Update `TaskScreen` to provide default values for optional parameters.
- Add `saveFooterPosition` and `handleTaskScreenAction` to `AbstractTaskFragment` to facilitate the transition to Compose-based layouts.
- Make `AbstractTaskFragment.TaskBody` open instead of abstract to support incremental migration.
…e `ButtonActionStateChecker` helper

- Delete `DateTaskFragmentTest` and migrate its testing logic to the new `DateTaskScreenTest` using Compose-based testing APIs.
- Extract button state verification logic into a new reusable `ButtonActionStateChecker` utility class.
- Update `BaseTaskFragmentTest` to use `ButtonActionStateChecker` for consistent button assertions.
- Enhance test coverage for `DateTaskScreen`, including checks for hint text visibility, date formatting, and dialog interactions (select date, clear response).
- Simplify task screen initialization in tests by mocking `DataCollectionViewModel` and `TaskPositionInterface` directly.
@auto-assign auto-assign bot requested a review from hassan-nsubuga March 30, 2026 14:42
@shobhitagarwal1612 shobhitagarwal1612 requested review from andreia-ferreira and removed request for hassan-nsubuga March 30, 2026 14:42
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_20260331_123131.webm

when manually typing a date, the progress bar seems to move to the middle of the screen and stay there across tasks

@shobhitagarwal1612
Copy link
Copy Markdown
Member Author

I'm unable to reproduce it locally.

@andreia-ferreira
Copy link
Copy Markdown
Collaborator

sorry should have added that the issue above only happens on smaller devices. I reproduced using the 'Small Phone API 29' emulator in Android Studio

@shobhitagarwal1612
Copy link
Copy Markdown
Member Author

Attaching a screen recording of the same on small phone API 29.

Screen_recording_20260331_231226.webm

Could you please check what I'm missing in the repro steps?

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 79.71014% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.83%. Comparing base (6eb304a) to head (29559c8).

Files with missing lines Patch % Lines
...oid/ui/datacollection/tasks/date/DateTaskScreen.kt 88.88% 0 Missing and 6 partials ⚠️
...d/ui/datacollection/tasks/date/DateTaskFragment.kt 0.00% 5 Missing ⚠️
...id/ui/datacollection/tasks/AbstractTaskFragment.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3643      +/-   ##
============================================
- Coverage     66.85%   66.83%   -0.03%     
+ Complexity     1655     1644      -11     
============================================
  Files           357      358       +1     
  Lines          8802     8835      +33     
  Branches       1120     1130      +10     
============================================
+ Hits           5885     5905      +20     
- Misses         2278     2288      +10     
- Partials        639      642       +3     
Files with missing lines Coverage Δ
...form/android/ui/datacollection/tasks/TaskScreen.kt 93.93% <100.00%> (+1.34%) ⬆️
.../ui/datacollection/tasks/date/DateTaskViewModel.kt 100.00% <100.00%> (ø)
...id/ui/datacollection/tasks/AbstractTaskFragment.kt 83.51% <0.00%> (-2.85%) ⬇️
...d/ui/datacollection/tasks/date/DateTaskFragment.kt 0.00% <0.00%> (-88.89%) ⬇️
...oid/ui/datacollection/tasks/date/DateTaskScreen.kt 88.88% <88.88%> (ø)

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

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