Skip to content

Move viewfinder to ViewModel - #715

Merged
thestinger merged 28 commits into
GrapheneOS:compose-prototypefrom
m4pl:task/709-viewfinder-to-viewmodel
Sep 22, 2026
Merged

thestinger merged 28 commits into
GrapheneOS:compose-prototypefrom
m4pl:task/709-viewfinder-to-viewmodel

Conversation

@m4pl

@m4pl m4pl commented Sep 15, 2026

Copy link
Copy Markdown

Closes #709

@m4pl
m4pl force-pushed the task/709-viewfinder-to-viewmodel branch 2 times, most recently from b99448b to 4781576 Compare September 15, 2026 19:53
@m4pl
m4pl marked this pull request as ready for review September 15, 2026 21:40
@m4pl
m4pl marked this pull request as draft September 16, 2026 22:10
@m4pl
m4pl marked this pull request as ready for review September 17, 2026 10:20
} else {
View.GONE
}
if (!mActivity.videoCapturer.includeAudio) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I can't reach this state to test, the settings toggle looks to be disabled when recording. But I guess this can just be a double-check.

@m4pl
m4pl force-pushed the task/709-viewfinder-to-viewmodel branch from 22521a0 to 493840f Compare September 17, 2026 20:57

isRecording = false

viewfinder.onAction(CaptureAction.RecordingStopped)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A destroyed Activity can overwrite the replacement Activity's recording state

  1. Activity A starts recording A.
  2. Configuration recreation calls onStop(), requesting A's recording to stop.
  3. Activity B attaches to the retained ViewModel and starts recording B.
  4. A's asynchronous Finalize callback reaches VideoCapturer.kt:227.
  5. The old capturer sends an unqualified RecordingStopped action into the shared ViewModel.
  6. B continues recording, but the UI is reset to “Start recording” and “Flip camera”; the video-only gallery button can also reappear.

Need to allow finalization and media cleanup to finish, but reject UI/state notifications from destroyed or detached Activity owners

scope.launch {
applicationScope.launch(defaultDispatcher) {
try {
capturedItemRepository.saveLastCapturedItem(item)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be single-threaded, otherwise an older one can overwrite a newer one.

@m4pl
m4pl force-pushed the task/709-viewfinder-to-viewmodel branch from 493840f to e442ee3 Compare September 22, 2026 18:29
@m4pl
m4pl force-pushed the task/709-viewfinder-to-viewmodel branch from e442ee3 to 5317f4d Compare September 22, 2026 18:42
@m4pl
m4pl force-pushed the task/709-viewfinder-to-viewmodel branch from 5317f4d to ef55f96 Compare September 22, 2026 18:47
@m4pl
m4pl requested a review from RankoR September 22, 2026 18:55
@thestinger
thestinger merged commit 68b9907 into GrapheneOS:compose-prototype Sep 22, 2026
2 checks passed
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.

4 participants