Skip to content

Restore datastore-proto module and decouple via SettingsDataSource#534

Open
temcguir wants to merge 12 commits into
mainfrom
temcguir/restore-proto-datastore-module
Open

Restore datastore-proto module and decouple via SettingsDataSource#534
temcguir wants to merge 12 commits into
mainfrom
temcguir/restore-proto-datastore-module

Conversation

@temcguir

@temcguir temcguir commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

This PR restores the datastore-proto module that was removed in PR #525. It brings back the .proto files, mappers, and serializers, but in a separate module under :data:settings:datastore-proto.

Key architectural changes:

  • Introduces SettingsDataSource to abstract away the datastore implementation details from LocalSettingsRepository.
  • The datastore-proto module encapsulates DataStoreFactory.create() so androidx.datastore is no longer exposed to :app.
  • The datastore-proto module is completely Hilt-free.
  • Updates :app's AppSettingsModule to manually provide the ProtoDataStoreSettingsDataSource.
  • Aligned proto enums with proto3 zero-value best practices by adding an <ENUM_NAME>_UNSPECIFIED = 0 element to all proto enums, mapping them to safe defaults in the mappers.
  • Renamed .toDomain() to .toModel() in the proto mappers for semantic consistency.
  • Updated the local .gemini/styleguide.md with a rule to enforce proto3 zero-value best practices.
  • Addressed code review feedback (KDocs, unused TAGs, test teardowns, and explicitly defaulting values like targetFrameRate and lowLightBoostPriority).

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a new :data:settings:datastore-proto module to encapsulate Proto DataStore settings, refactors LocalSettingsRepository to use a new SettingsDataSource interface, and migrates snackbar/toast testing from custom test tags to string resources. Feedback focuses on a critical channel competition and deadlock bug in PreviewViewModel, missing Dispatchers.resetMain() in test teardown, and several style guide violations regarding missing @RunWith annotations, missing KDoc documentation, and insufficiently restrictive visibility modifiers.

@temcguir temcguir force-pushed the temcguir/restore-proto-datastore-module branch from cf954d8 to 4fe8a7f Compare June 29, 2026 19:55
This PR restores the `datastore-proto` module that was removed in PR #525. It brings back the `.proto` files, mappers, and serializers, but in a separate module under `:core:settings:datastore-proto`.

Key architectural changes:
- The `datastore-proto` module encapsulates `DataStoreFactory.create()` so `androidx.datastore` is no longer exposed to `:app`.
- The `datastore-proto` module is completely Hilt-free.
- Updates `:app`'s `AppSettingsModule` to manually provide the `ProtoDataStoreSettingsDataSource`.
@temcguir temcguir force-pushed the temcguir/restore-proto-datastore-module branch from 4fe8a7f to 190c006 Compare June 29, 2026 20:03
@temcguir temcguir force-pushed the temcguir/restore-proto-datastore-module branch from a3a5cf3 to 6004e3f Compare June 29, 2026 20:55
@temcguir

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a proto-based DataStore settings implementation across new modules (datastore-proto, model-proto, and settings-proto) and configures the app to use it. Feedback highlights a critical architectural issue where the new ProtoDataStoreSettingsDataSource is set as the primary settings provider but lacks support for concurrentCameraMode, which would cause a silent functional regression. Additionally, the reviewer noted that :app still directly depends on androidx.datastore (violating encapsulation), unused dead code was introduced in concurrent_camera_mode.proto, and several style guide violations exist regarding missing @RunWith annotations on test classes and missing KDoc documentation on public APIs.

Comment thread app/src/main/java/com/google/jetpackcamera/AppSettingsModule.kt Outdated
@temcguir temcguir force-pushed the temcguir/restore-proto-datastore-module branch 2 times, most recently from f85a242 to b219771 Compare June 29, 2026 22:23
@temcguir temcguir force-pushed the temcguir/restore-proto-datastore-module branch from b219771 to 97f9e98 Compare June 29, 2026 22:33
@temcguir

Copy link
Copy Markdown
Collaborator Author

@gemini-code-assist We have addressed the architectural and functional issues!

  1. Added concurrentCameraMode support to ProtoDataStoreSettingsDataSource, camera_app_settings.proto, and the corresponding domain mappers to prevent the functional regression.
  2. Removed the direct androidx.datastore dependency from :app to maintain encapsulation.
  3. Restored concurrent_camera_mode.proto and properly utilized it within the app settings proto.

For the KDoc comments on the simple mapping functions, I left inline comments asking if they are strictly necessary. Let us know if anything else is needed!

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Great work on addressing these architectural concerns and restoring the functionality! Decoupling the DataStore implementation from the :app module is a significant improvement.

Regarding your question about the KDoc comments on the mapping functions: While they might seem simple, I recommend keeping them. They serve as useful documentation for other developers, provide helpful context in IDE tooltips, and ensure consistency across the codebase. Even for straightforward mappings, documenting the intent—especially if there are default values or specific mapping logic—is a good practice for long-term maintainability.

@temcguir

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request migrates the application settings from Preferences DataStore to Proto DataStore by introducing the core:model-proto, core:settings:settings-proto, and core:settings:datastore-proto modules, along with corresponding data mappers and tests. Feedback on the changes includes ensuring that all default values (such as targetFrameRate and lowLightBoostPriority) are explicitly defined in the serializer, documenting public create functions with KDoc, removing an unused TAG constant, and properly resetting the main dispatcher in tests to avoid test pollution.

temcguir added 4 commits June 29, 2026 23:30
Added <ENUM_NAME>_UNSPECIFIED = 0 to all proto enums to comply with official proto3 style guide requirements. Updated ModelMappers.kt to handle the new UNSPECIFIED values and safely fallback to defaults. Also added a rule enforcing this to the local styleguide.
- Set targetFrameRate and lowLightBoostPriority explicitly in ProtoCameraAppSettingsSerializer's defaultValue.
- Added KDoc for create() in ProtoDataStoreSettingsDataSource and PrefsDataStoreSettingsDataSource.
- Removed unused TAG from ProtoDataStoreSettingsDataSource.
- Added Dispatchers.resetMain() to tearDown in ProtoDataStoreSettingsDataSourceTest.
@temcguir temcguir requested a review from davidjiagoogle June 29, 2026 23:45
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.

2 participants