-
Notifications
You must be signed in to change notification settings - Fork 49
centralize filepath creation #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Extracted the filename and output directory generation logic from the `LocalMediaRepository`, `PostCaptureViewModel`, and `CameraCoreUtil` into a new `FilenameGenerator` interface. This change makes the project friendlier to forks by allowing developers to provide their own implementation of `FilenameGenerator` to customize file naming and save locations without modifying the core application logic. Key changes: - Created `FilenameGenerator` interface in `core:common`. - Implemented `JcaFilenameGenerator` in the `app` module as the default implementation. - Injected `FilenameGenerator` into `LocalMediaRepository`. - Updated tests to provide a `FakeFilenameGenerator` and adjusted mock stubs.
ac3f09c to
d43da09
Compare
|
/gemini summary |
|
/gemini review |
Summary of ChangesThis pull request refactors the application's media file path and name generation logic by extracting it into a dedicated Highlights
Changelog
Activity
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request does a great job of centralizing the file path and name generation logic into a new FilePathGenerator interface, which improves modularity and makes the system more extensible. The dependency is correctly injected where needed, and the tests have been updated with a fake implementation, which is a solid approach.
I've found one high-severity issue where a previously used suffix for video filenames is now missing, which could impact debugging. I've also left a few medium-severity comments related to improving documentation and adhering to Kotlin's idiomatic style, as suggested by the repository's style guide.
core/camera/src/main/java/com/google/jetpackcamera/core/camera/CameraSession.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/jetpackcamera/JcaFilePathGenerator.kt
Outdated
Show resolved
Hide resolved
core/common/src/main/java/com/google/jetpackcamera/core/common/FakeFilePathGenerator.kt
Outdated
Show resolved
Hide resolved
core/common/src/main/java/com/google/jetpackcamera/core/common/FilePathGenerator.kt
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request does a great job of centralizing the filepath creation logic by introducing the FilePathGenerator interface. This is a solid architectural improvement that enhances modularity and makes the code easier to customize. The changes are well-integrated across the various modules, and the tests have been updated accordingly.
I've identified a critical issue related to a potential NullPointerException when generating video paths on older Android versions. Additionally, there are opportunities to improve code quality by adhering to the DRY principle in the new generator classes and simplifying some of the new Dagger provider code. Addressing these points will make the implementation more robust and maintainable.
core/common/src/main/java/com/google/jetpackcamera/core/common/FakeFilePathGenerator.kt
Show resolved
Hide resolved
data/media/src/main/kotlin/com/google/jetpackcamera/data/media/LocalMediaRepository.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/jetpackcamera/JcaFilePathGenerator.kt
Outdated
Show resolved
Hide resolved
core/common/src/main/java/com/google/jetpackcamera/core/common/FakeFilePathGenerator.kt
Outdated
Show resolved
Hide resolved
1f47da0 to
e0d0793
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively centralizes the filepath and filename generation logic by introducing a FilePathGenerator interface. This is a solid architectural improvement that removes duplicated code from various classes like LocalMediaRepository and PostCaptureViewModel, enhancing modularity and making the system more extensible for forks. The use of dependency injection for the new service and the addition of a FakeFilePathGenerator for tests are well-implemented. My review includes one suggestion to further reduce code duplication between the concrete FilePathGenerator implementations to improve maintainability.
core/common/src/main/java/com/google/jetpackcamera/core/common/FakeFilePathGenerator.kt
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is an excellent refactoring that successfully centralizes the file path and directory generation logic into a new FilePathGenerator interface. This improves modularity and makes the system more extensible, which aligns perfectly with the stated goal of making the project friendlier to forks. The introduction of a FakeFilePathGenerator for testing is also a great addition that follows best practices.
I have two points of feedback:
- A high-severity concern regarding a change in the default
SaveModeinAppModule.kt, which alters core application behavior and seems unrelated to the PR's main objective. - A medium-severity suggestion to fix a minor typo in the KDoc for the new
FilePathGenerator.ktinterface to improve documentation clarity.
core/common/src/main/java/com/google/jetpackcamera/core/common/FilePathGenerator.kt
Outdated
Show resolved
Hide resolved
4bf7542 to
c46e67a
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request does a great job of centralizing the filepath and filename generation logic by introducing a new FilePathGenerator interface. This is a solid refactoring that improves modularity, testability, and makes it easier for forks to customize file handling, adhering to the project's architectural principles.
The implementation is well-executed across the board, from the new interface and its default implementation to the updates in the camera and data layers. The use of a FakeFilePathGenerator in tests is also a great example of following the testing guidelines.
I have one minor suggestion in JcaFilePathGenerator.kt to reduce a small amount of code duplication, in line with the DRY principle mentioned in the style guide.
app/src/main/java/com/google/jetpackcamera/JcaFilePathGenerator.kt
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request does a great job of centralizing the filepath generation logic by introducing the FilePathGenerator interface. This is a solid architectural improvement that increases modularity and makes the system more extensible, as described in the PR description. The dependency injection setup is clean, and the removal of the scattered logic from various components simplifies them significantly.
I have one suggestion regarding a DRY principle violation between JcaFilePathGenerator and FakeFilePathGenerator to further improve the code structure.
Extracted the filename and output directory generation logic from the
LocalMediaRepository,PostCaptureViewModel, andCameraCoreUtilinto a newFilePathGeneratorinterface.This change makes the project friendlier to forks by allowing developers to provide their own implementation of
FilePathGeneratorto customize file naming and save locations without modifying the core application logic.Key changes:
FilePathGeneratorinterface incore:common.JcaFilePathGeneratorin theappmodule as the default implementation.FilePathGeneratorintoLocalMediaRepositoryandCameraXCameraSystem.FakeFilePathGeneratorand adjusted mock stubs.