Skip to content

Comments

Refactor: Decouple DataStore from Settings Module#476

Open
Kimblebee wants to merge 2 commits intomainfrom
kim/refactor/datastore-module
Open

Refactor: Decouple DataStore from Settings Module#476
Kimblebee wants to merge 2 commits intomainfrom
kim/refactor/datastore-module

Conversation

@Kimblebee
Copy link
Collaborator

Extracted Proto DataStore implementation into a new :data:settings-datastore module. This improves modularity and separation of concerns by isolating the persistence layer.

:data:settings now solely defines interfaces and handles constraints.

  Extracted Proto DataStore implementation into a new :data:settings-datastore module. This improves modularity and separation of concerns by isolating the persistence layer. :data:settings now solely defines interfaces and handles constraints.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Kimblebee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the application's settings management by extracting the Proto DataStore implementation into a dedicated :data:settings-datastore module. This change significantly improves modularity and separation of concerns, as the persistence layer is now isolated. Consequently, the original :data:settings module is streamlined to solely define interfaces and handle constraints, leading to a cleaner and more maintainable architecture.

Highlights

  • New Module Creation: A new Android library module, :data:settings-datastore, has been created to encapsulate the Proto DataStore implementation for application settings.
  • DataStore Migration: All files related to the DataStore implementation, including serializers, Dagger modules, and the LocalSettingsRepository, have been moved from the original :data:settings module to the newly created :data:settings-datastore module.
  • Module Specialization: The original :data:settings module has been refactored to remove DataStore dependencies and now focuses exclusively on defining settings interfaces and managing constraints, enhancing its role as a contract module.
  • Build Configuration Updates: Build files (build.gradle.kts) across affected modules have been updated to reflect the new module structure, including adding the new module to settings.gradle.kts and adjusting dependencies.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • data/settings-datastore/.gitignore
    • Added a .gitignore file to the new module.
  • data/settings-datastore/build.gradle.kts
    • Added a new Gradle build file, configuring it as an Android library with Kotlin, Protobuf, Hilt, and DataStore dependencies.
  • data/settings-datastore/proguard-rules.pro
    • Added ProGuard rules for the new module.
  • data/settings-datastore/src/androidTest/java/com/google/jetpackcamera/data/settings_datastore/DataStoreModuleTest.kt
    • Renamed and moved the DataStore module test file to the new module, updating its package and imports.
  • data/settings-datastore/src/androidTest/java/com/google/jetpackcamera/data/settings_datastore/LocalSettingsRepositoryInstrumentedTest.kt
    • Renamed and moved the local settings repository instrumented test file to the new module, updating its package and imports.
  • data/settings-datastore/src/main/AndroidManifest.xml
    • Added an Android manifest file for the new module.
  • data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/DataStoreModule.kt
    • Renamed and moved the DataStore module implementation to the new module, updating its package and copyright year.
  • data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/JcaSettingsSerializer.kt
    • Renamed and moved the JcaSettings serializer to the new module, updating its package and copyright year.
  • data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/LocalSettingsRepository.kt
    • Renamed and moved the LocalSettingsRepository implementation to the new module, updating its package, copyright year, and imports.
  • data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/SettingsModule.kt
    • Added a new Dagger Hilt module to bind LocalSettingsRepository to SettingsRepository.
  • data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/test/FakeDataStoreModule.kt
    • Renamed and moved the fake DataStore module to the new module, updating its package.
  • data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/test/FakeJcaSettingsSerializer.kt
    • Renamed and moved the fake JcaSettings serializer to the new module, updating its package, copyright year, and imports.
  • data/settings-datastore/src/main/proto/com/google/jetpackcamera/settings/jca_settings.proto
    • Renamed and moved the Protobuf settings definition file to the new module.
  • data/settings/build.gradle.kts
    • Modified the build file to remove Protobuf and DataStore related plugins and dependencies.
  • data/settings/src/main/java/com/google/jetpackcamera/settings/ConstraintsModule.kt
    • Renamed the original SettingsModule.kt to ConstraintsModule.kt and removed the SettingsRepository binding, retaining only constraint-related bindings.
  • data/settings/src/test/java/com/google/jetpackcamera/settings/ProtoConversionTest.kt
    • Removed the ProtoConversionTest file.
  • feature/preview/build.gradle.kts
    • Updated the build file to include the new :data:settings-datastore module as a dependency.
  • settings.gradle.kts
    • Included the newly created :data:settings-datastore module in the project.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

The refactoring to decouple DataStore from the Settings module is a positive architectural improvement. However, several issues were identified during the review, including package name inconsistencies in the new module, missing test coverage for proto conversions that were deleted, and some deviations from the project's dependency management and Java version standards. Addressing these will ensure the new module is robust and maintainable.

I am having trouble creating individual review comments. Click here to see my feedback.

data/settings/src/test/java/com/google/jetpackcamera/settings/ProtoConversionTest.kt (1-110)

high

This test file was deleted, but the conversion logic it verified (mapping between Protos and Models) is still present in LocalSettingsRepository.kt. These tests should be moved to the new :data:settings-datastore module to maintain coverage.

data/settings-datastore/build.gradle.kts (25)

medium

Avoid hardcoding the compileSdk version. Use the version catalog (libs.toml) to maintain consistency across the project.

    compileSdk = libs.versions.compileSdk.get().toInt()

data/settings-datastore/build.gradle.kts (28)

medium

Avoid hardcoding the minSdk version. Use the version catalog (libs.toml) to maintain consistency across the project.

        minSdk = libs.versions.minSdk.get().toInt()

data/settings-datastore/build.gradle.kts (44-48)

medium

The project appears to be using Java 17 (as seen in other modules). This new module should align with that standard instead of using Java 11.

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"
    }

data/settings-datastore/build.gradle.kts (54-55)

medium

These UI-related dependencies (appcompat and material) seem unnecessary for a data module focused on DataStore persistence. Consider removing them to keep the module lightweight.

data/settings-datastore/build.gradle.kts (81)

medium

Avoid hardcoding the protobuf version. This should be managed via the version catalog (libs.toml).

data/settings-datastore/src/main/java/com/google/jetpackcamera/data/settingsdatastore/SettingsModule.kt (32)

medium

The SettingsRepository binding should typically be a @Singleton to ensure a single instance is used throughout the application, consistent with how the DataStore itself is provided.

    @Binds
    @Singleton
    fun bindsSettingsRepository(

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.

1 participant