The comment screen send button must react to the draft state from the system observer. After a recent refactor, the screen started behaving unstably when reopened and after Activity recreation.
SendButtonController must receive updates only while the screen is active.EditText changes, the button must be enabled if the field contains at least one non-whitespace character.onStop(), the screen must not receive new callbacks from the observer.onStart() again, the button state must match the current text in the field.ComposeCommentActivity.Hello in the field and make sure the button is active.onStop() is called, then change the text externally via DraftStore.updateDraft(...).For manual verification, you can use this fragment in a test scenario:
val activity = ComposeCommentActivity()
activity.onCreate(null)
activity.onStart()
activity.findViewById<EditText>(R.id.commentInput).setText("Hello")
activity.onStop()
DraftStore.updateDraft(" ")
activity.onStart()
onStop(), the old screen must not continue receiving events from DraftStore.EditText, even if no new events from DraftStore occurred.1.7.0, Core KTX 1.13.1Activity without Compose and without ViewModelDraftStore observer works in process memory and invokes callbacks synchronously on the main threadEditText text is restored by the standard Android mechanism if the id is preservedUse line comments to explain the problem, its impact, the fix and how to test it.