android / android/architecture-samples
[main] User input for add/edit screen is lost across process death
- Dominant language
- Kotlin
- Stars
- 45.8k
- Forks
- 11.9k
- PR merge metrics
- No merged PRs in 30d
Description
Similarly to older issues that have since been either closed or fixed such as https://github.com/android/architecture-samples/issues/370 and https://github.com/android/architecture-samples/issues/123 and https://github.com/android/architecture-samples/issues/731 and https://github.com/android/architecture-samples/issues/663
This bug seems to have been long-standing, but with `MutableStateFlow(UiState)` it still persists - as on this screen, SavedStateHandle is used only for transferring screen arguments to the ViewModel, but is not actually used to preserve user inputs across process death.
https://github.com/android/architecture-samples/blob/7e9d96d808a0d25a689d14099ecf0eb3ea7d5b1f/app/src/main/java/com/example/android/architecture/blueprints/todoapp/addedittask/AddEditTaskViewModel.kt#L39-L40
----
On the other hand, TasksViewModel correctly persists the current filter state using `savedStateHandle.getStateFlow`.
https://github.com/android/architecture-samples/blob/7e9d96d808a0d25a689d14099ecf0eb3ea7d5b1f/app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksViewModel.kt#L64-L65
Filtering state on the tasks screen was originally fixed by setting it on the SavedStateHandle in this commit: https://github.com/android/architecture-samples/commit/cfb5ac6ea6a5c888b171d88d7ea4287a33af5cb9#diff-631edb6efa01767b52856a0e498dc3987e8a2f0e8ba02837377dfbc5684af0cfR111
----
Therefore, AddEdit screen should also correctly save/restore user inputs across process death.
Contributor guide
Research direction
Start with app/src/main/java/com/example/android/architecture/blueprints/todoapp/addedittask/AddEditTaskViewModel.kt, especially the SavedStateHandle usage cited in the issue, and compare it with TasksViewModel.kt's saved filter state. Verify that the AddEdit screen's user inputs survive process death and that the restored state is reflected when the screen returns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100