Enhance MediaRepository with reactive flow and update ImageWell animation#531
Open
temcguir wants to merge 13 commits into
Open
Enhance MediaRepository with reactive flow and update ImageWell animation#531temcguir wants to merge 13 commits into
temcguir wants to merge 13 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the media repository to expose the last captured media as a continuous StateFlow (lastCapturedMedia) instead of a suspend function, and updates the ImageWell UI component to observe this flow with smoother transition animations. It also enhances the testing infrastructure, including FakeContentProvider and LocalMediaRepositoryTest. The review feedback identifies a potential race condition in LocalMediaRepository due to unsynchronized cache access, suggests a more robust package ownership check on Android Q+, and recommends simplifying the flow implementation in FakeMediaRepository to prevent coroutine leaks.
…simplify fake repository
# Conflicts: # app/build.gradle.kts
- Added RELATIVE_PATH to MediaStore projection in LocalMediaRepository.isAppSpecificUri - Updated FakeContentProvider to support RELATIVE_PATH and OWNER_PACKAGE_NAME filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors the media data layer to support a reactive unidirectional data flow, enhances the capture UI with improved animations, and addresses b/522926012 by supporting dynamic file prefixes.
Core Changes:
LocalMediaRepositoryto expose alastCapturedMediaStateFlow. It now automatically initializes with the latest app-captured media and reacts to MediaStore changes.MutextoLocalMediaRepositoryto synchronize access to the media cache and prevent race conditions during concurrent MediaStore updates.prefixproperty inFilePathGenerator.LocalMediaRepositorynow uses this prefix dynamically when querying the MediaStore, allowing it to correctly identify app-captured media even when a custom generator (e.g., for Google Photos) is used.OWNER_PACKAGE_NAMEon Android Q+ for identifying app-specific media, falling back to the filename prefix only on older versions.AnimatedContenttransition that performs a "vertical push" animation whenever the last captured media updates.FakeMediaRepositoryto use a directStateFlow, avoiding unmanaged coroutine scopes and potential leaks in tests.Verified:
:data:mediaand:ui:components:capturesuccessfully.spotlessApply.