Skip to content

[REFACTOR] Structural Enhancement of AppPreference Implementation#98

Merged
doyoonkim3312 merged 11 commits into
developmentfrom
REFACTOR/1.7.1/KAN-111-AppPreference-Structural-Change
Mar 27, 2026
Merged

[REFACTOR] Structural Enhancement of AppPreference Implementation#98
doyoonkim3312 merged 11 commits into
developmentfrom
REFACTOR/1.7.1/KAN-111-AppPreference-Structural-Change

Conversation

@doyoonkim3312

@doyoonkim3312 doyoonkim3312 commented Mar 25, 2026

Copy link
Copy Markdown
Member

πŸ“ Summary (κ°œμš”)

  • Structural Enhancement of AppPreference.kt, a Repository of local SharedPreference.
  • Structural Enhancement of RemoteRepository (032626)

πŸ”— Related Issue (κ΄€λ ¨ 이슈)

  • Resolves (if applicable) #
  • Jira Ticket: KAN-111

πŸ›  Type of Change (λ³€κ²½ 사항)

  • FEAT: New feature (μƒˆλ‘œμš΄ κΈ°λŠ₯)
  • FIX: Bug fix (버그 μˆ˜μ •)
  • REFACTOR: Code refactoring (no functional change) (μ½”λ“œ λ¦¬νŒ©ν† λ§)
  • DESIGN: UI/UX changes (λ””μžμΈ λ³€κ²½)
  • !HOTFIX: Critical fix (치λͺ…적인 버그 μˆ˜μ •)
  • CHORE: Build/Config/CI (λΉŒλ“œ/μ„€μ •/CI)

✨ Key Changes (핡심 λ³€κ²½ 사항)

  • Refactor legacy AppPreference.kt to AppPreferenceRepository and its implementation to allow Dagger manage its dependency with proper scope (@Singleton)
  • Decentralize large RemoteRepositoryImpl into three separate repositories to ensure separation of concern. (RemoteContentRepository, RemotePreferenceRepository, RemoteTokenRepository)
  • Replace legacy AppPreference dependency to updated AppPreferenceRepository
  • (032626) Decentralize Monolithic AppPreferenceRepository to achieve strict Separation of Concern via Interface Segregation.
  • (032626) Enhance current implementation of RemoteContentRepositoryImpl and RemotePreferenceRepositoryImpl into more smaller implementation of each interface to ensure strict separation of concern, and isolating logic/implementation

πŸ“Έ Screenshots / Video (μŠ€ν¬λ¦°μƒ· λ˜λŠ” λ™μ˜μƒ)

  • Not Applicable.

πŸ§ͺ Test Plan (ν…ŒμŠ€νŠΈ κ³„νš)

  • Device: Android Emulator (Google Pixel 9 Pro, SDK 36)
  • Scenario: Launch application -> Check initial token validation logic is performed successfully via Logcat.
  • Scenario: Launch application -> Check process related to SubscriptionPreference are performed correctly.
  • Scenario: Launch application -> Check User Report is successfully submitted without error.

βœ… Checklist (체크리슀트)

  • My code follows the style guidelines of this project (μ½”λ“œ μŠ€νƒ€μΌμ„ μ€€μˆ˜ν–ˆμŠ΅λ‹ˆλ‹€).
  • I have performed a self-review of my own code (슀슀둜 μ½”λ“œλ₯Ό κ²€ν† ν–ˆμŠ΅λ‹ˆλ‹€).
  • I have commented my code, particularly in hard-to-understand areas (μ΄ν•΄ν•˜κΈ° μ–΄λ €μš΄ 뢀뢄에 주석을 μž‘μ„±ν–ˆμŠ΅λ‹ˆλ‹€).

  - Allow Dagger to manage Local AppPreferenceRepository as a Singleton instance, exposing its accessibility via interface in :domain module (Dependency Inversion)

    * Refactor AppPreference to AppPreferenceRepository and its Implementation.
    * Necessary Dependency has been provided via LocalPreferenceModule with @singleton Annotation.
  - Decentralize 'RemoteRepositoryImpl' into three independent Repositories.
    1. RemoteContentRepositoryImpl
    2. RemotePreferenceRepositoryImpl
    3. RemoteTokenRepositoryImpl

    * Necessary directory structure modification has been performed.
  - Provide dependency of AppPreferenceRepository instance as a Singleton.

    * Dependency is provided via Component-Dependency between AppComponent and each SceneComponents.
  - Replace legacy 'AppPreference' dependency to updated 'AppPreferenceRepository'
  - Add necessary library dependency (Kotlin Serialization)
@doyoonkim3312 doyoonkim3312 requested a review from jeongHunE March 25, 2026 08:00
@doyoonkim3312 doyoonkim3312 self-assigned this Mar 25, 2026
@doyoonkim3312 doyoonkim3312 added the Improvement Structural or Functional Improvement label Mar 25, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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 significantly enhances the application's architecture by refactoring how local preferences and remote data interactions are handled. It introduces a dedicated AppPreferenceRepository for managing local shared preferences, improving dependency injection and testability. Furthermore, it breaks down a large, multi-purpose remote repository into smaller, focused units, leading to a cleaner, more maintainable codebase with better separation of concerns for remote data operations.

Highlights

  • AppPreference Refactoring: Refactored the legacy AppPreference.kt into a new AppPreferenceRepository interface and its AppPreferenceRepositoryImpl implementation, enabling Dagger to manage its dependency with a proper @Singleton scope.
  • Remote Repository Decentralization: Decentralized the monolithic RemoteRepositoryImpl into three specialized repositories: RemoteContentRepositoryImpl, RemotePreferenceRepositoryImpl, and RemoteTokenRepositoryImpl, enhancing separation of concerns.
  • Dependency Updates: Updated all existing dependencies on the legacy AppPreference to utilize the new AppPreferenceRepository interface.
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.

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. ↩

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

Copy link
Copy Markdown

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 refactors the data layer by splitting the monolithic RemoteRepositoryImpl into more specialized RemoteContentRepositoryImpl, RemotePreferenceRepositoryImpl, and RemoteTokenRepositoryImpl. It also introduces an AppPreferenceRepository interface and its AppPreferenceRepositoryImpl implementation, moving the AppPreferences class and making it an interface. This involved updating numerous Dagger components and view models to use the new AppPreferenceRepository and LocalCacheProvider for dependency injection. Additionally, Kotlin Serialization plugin and dependency were added to the core/data module. The review comments suggest improving the TAG naming convention in the new remote repository implementations for better consistency and log filtering.

  - Update TAG variables to match with its class name.
  - Change the filename to ensure name consistency.
  - Made architectural improvement on AppPreferenceRepository to prevent potential technical debt caused by monolithic Repository implementation.

    * Decentralize Monolithic AppPreferenceRepository to achieve strict Separation of Concern via Interface Segregation.
    * Necessary Binding functions have been defined for Dependency Injection via Dagger 2.
  - Made architectural improvement on AppPreferenceRepository to prevent potential technical debt caused by monolithic Repository implementation.

    * Update Dagger Components to provide necessary AppPreferences' dependencies.
  - Made architectural improvement on AppPreferenceRepository to prevent potential technical debt caused by monolithic Repository implementation.

    * Replace legacy monolithic AppPreferenceRepository dependency to updated dependencies based on the context and operations.
  - Enhance current implementation of RemoteContentRepositoryImpl and RemotePreferenceRepositoryImpl into more smaller implementation of each interface to ensure strict separation of concern, and isolating logic/implementation

    * RemoteContentRepositoryImpl
      -> RemoteNoticeRepositoryImpl (Notice)
      -> RemoteTipRepositoryImpl (Tip)
    * RemotePreferenceRepositoryImpl
      -> RemoteSubscriptionRepositoryImpl (Major Subscriptions)
      -> RemoteUserReportRepositoryImpl (User Report Submission)
@doyoonkim3312

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

This pull request significantly refactors the application's architecture by enhancing how local preferences and remote data interactions are managed. It transforms previously monolithic components into a more modular, maintainable, and testable structure, aligning with principles of separation of concerns and interface segregation. These changes streamline dependency injection, improve code clarity, and prepare the codebase for future feature development and easier maintenance.

Highlights

  • Preference Repository Refactoring: The monolithic AppPreference class was decentralized into four distinct, specialized preference repositories: AppDatabasePreferenceRepository, AppSubscriptionPreferenceRepository, AppTokenPreferenceRepository, and AppWidgetPreferenceRepository. This adheres to the Interface Segregation Principle (ISP) for improved modularity and maintainability.
  • Remote Repository Decentralization: The large RemoteRepositoryImpl was broken down into five focused remote repositories: RemoteNoticeRepositoryImpl, RemoteTipRepositoryImpl, RemoteTokenRepositoryImpl, RemoteSubscriptionRepositoryImpl, and RemoteUserReportRepositoryImpl. This significantly enhances the separation of concerns for remote data interactions.
  • Dependency Injection Updates: Dagger dependency injection configurations across various components, including AppComponent, NotificationServiceComponent, SceneComponents, and WidgetComponent, were updated to integrate the new granular preference and remote repository interfaces.
  • Codebase Migration: All existing usages of the legacy AppPreferences and RemoteRepositoryImpl were migrated to their new, specialized counterparts, ensuring consistent application of the new architectural design throughout the application.
  • Kotlin Serialization Integration: Kotlin Serialization was introduced to the core/data module to support the new preference repository implementations, enabling efficient and type-safe data serialization and deserialization.
Changelog
  • app/src/main/java/com/doyoonkim/knutice/MainApplication.kt
    • Updated Dagger component creation to include additional appComponent instances.
  • app/src/main/java/com/doyoonkim/knutice/SplashActivity.kt
    • Added localPreferenceProvider to the DaggerSplashSceneComponent factory creation.
  • app/src/main/java/com/doyoonkim/knutice/WidgetConfigurationActivity.kt
    • Included localPreferenceProvider in the DaggerWidgetConfigSceneComponent factory creation.
  • app/src/main/java/com/doyoonkim/knutice/WidgetSyncObserver.kt
    • Replaced AppPreferences with AppSubscriptionPreferenceRepository and AppWidgetPreferenceRepository for preference access.
    • Updated method calls to use the new preference repositories.
  • app/src/main/java/com/doyoonkim/knutice/di/components/AppComponent.kt
    • Removed AppPreferences dependency.
    • Added LocalPreferenceModule to Dagger modules.
    • Added LocalCacheProvider and LocalPreferenceProvider interfaces to the component.
  • app/src/main/java/com/doyoonkim/knutice/di/components/NotificationServiceComponent.kt
    • Added LocalPreferenceProvider as a dependency and factory parameter for NotificationServiceComponent.
  • app/src/main/java/com/doyoonkim/knutice/di/components/SceneComponents.kt
    • Updated multiple scene components to include LocalCacheProvider and LocalPreferenceProvider in their dependencies and factories.
  • app/src/main/java/com/doyoonkim/knutice/di/components/WidgetComponent.kt
    • Added LocalPreferenceProvider as a dependency and factory parameter for WidgetComponent.
  • app/src/main/java/com/doyoonkim/knutice/di/util/DefaultSystemService.kt
    • Refactored preference-related interfaces by introducing LocalCacheProvider and LocalPreferenceProvider and moving relevant repository functions.
  • app/src/main/java/com/doyoonkim/knutice/navigation/MainServiceNavGraph.kt
    • Adjusted Dagger component creation in MainServiceNavGraph to incorporate new preference providers.
  • app/src/main/java/com/doyoonkim/knutice/navigation/bookmarkServiceGraph.kt
    • Modified DaggerBookmarkListSceneComponent factory creation to include localPreferenceProvider.
  • app/src/main/java/com/doyoonkim/knutice/navigation/campusServiceGraph.kt
    • Updated DaggerCarrelStatusSceneComponent factory creation to pass an additional appComponent parameter.
  • common/src/main/java/com/doyoonkim/common/di/AppPreferences.kt
    • Removed the legacy AppPreferences class.
  • core/data/build.gradle.kts
    • Added Kotlin Serialization plugin and dependency to the core/data module.
  • core/data/src/main/java/com/doyoonkim/data/di/LocalModules.kt
    • Introduced LocalPreferenceModule with Dagger bindings for new local preference repository interfaces and their implementations.
  • core/data/src/main/java/com/doyoonkim/data/di/RemoteModules.kt
    • Updated Dagger bindings to use new specialized remote repository implementations.
  • core/data/src/main/java/com/doyoonkim/data/repository/RemoteRepositoryImpl.kt
    • Removed the monolithic RemoteRepositoryImpl class.
  • core/data/src/main/java/com/doyoonkim/data/repository/local/AppDatabasePreferenceRepositoryImpl.kt
    • Added AppDatabasePreferenceRepositoryImpl for managing database synchronization preferences.
  • core/data/src/main/java/com/doyoonkim/data/repository/local/AppSubscriptionPreferenceRepositoryImpl.kt
    • Added AppSubscriptionPreferenceRepositoryImpl for managing major subscription preferences.
  • core/data/src/main/java/com/doyoonkim/data/repository/local/AppTokenPreferenceRepositoryImpl.kt
    • Added AppTokenPreferenceRepositoryImpl for managing device token preferences.
  • core/data/src/main/java/com/doyoonkim/data/repository/local/AppWidgetPreferenceRepositoryImpl.kt
    • Added AppWidgetPreferenceRepositoryImpl for managing widget configuration preferences.
  • core/data/src/main/java/com/doyoonkim/data/repository/local/LocalRepositoryImpl.kt
    • Renamed LocalRepositoryImpl and updated its package to local.
  • core/data/src/main/java/com/doyoonkim/data/repository/local/LocalWidgetCacheRepositoryImpl.kt
    • Renamed LocalWidgetCacheRepositoryImpl, updated its package, and modified its constructor to use AppWidgetPreferenceRepository.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/CampusRemoteRepository.kt
    • Renamed CampusRemoteRepository, updated its package, and modified its constructor and methods to use AppTokenPreferenceRepository.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/ImageRepositoryImpl.kt
    • Renamed ImageRepositoryImpl and updated its package to remote.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/RemoteNoticeRepositoryImpl.kt
    • Added RemoteNoticeRepositoryImpl for handling remote notice data operations.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/RemoteSubscriptionRepositoryImpl.kt
    • Added RemoteSubscriptionRepositoryImpl for handling remote topic subscription preferences.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/RemoteTipRepositoryImpl.kt
    • Added RemoteTipRepositoryImpl for handling remote tip data operations.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/RemoteTokenRepositoryImpl.kt
    • Added RemoteTokenRepositoryImpl for handling remote token validation and updates.
  • core/data/src/main/java/com/doyoonkim/data/repository/remote/RemoteUserReportRepositoryImpl.kt
    • Added RemoteUserReportRepositoryImpl for handling remote user report submissions.
  • core/domain/src/main/java/com/doyoonkim/domain/interfaces/AppDatabasePreferenceRepository.kt
    • Added AppDatabasePreferenceRepository interface for database synchronization preferences.
  • core/domain/src/main/java/com/doyoonkim/domain/interfaces/AppSubscriptionPreferenceRepository.kt
    • Added AppSubscriptionPreferenceRepository interface for major subscription preferences.
  • core/domain/src/main/java/com/doyoonkim/domain/interfaces/AppTokenPreferenceRepository.kt
    • Added AppTokenPreferenceRepository interface for device token preferences.
  • core/domain/src/main/java/com/doyoonkim/domain/interfaces/AppWidgetPreferenceRepository.kt
    • Added AppWidgetPreferenceRepository interface for widget configuration preferences.
  • core/network/src/main/kotlin/com/doyoonkim/network/KnuticeRemoteSource.kt
    • Removed direct AppPreferences dependency and updated remote API methods to accept token parameters.
  • core/notification/src/main/java/com/doyoonkim/notification/fcm/TokenHandler.kt
    • Replaced AppPreferences with AppTokenPreferenceRepository and added token comparison logging.
  • feature/bookmark/src/main/java/com/doyoonkim/bookmark/viewmodel/BookmarkListViewModel.kt
    • Replaced AppPreferences with AppDatabasePreferenceRepository in BookmarkListViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/CarrelStatusViewModel.kt
    • Replaced AppPreferences with AppTokenPreferenceRepository in CarrelStatusViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/CustomerServiceViewModel.kt
    • Removed AppPreferences dependency from CustomerServiceViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/HomeViewModel.kt
    • Replaced AppPreferences with AppSubscriptionPreferenceRepository and AppWidgetPreferenceRepository in HomeViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/NoticeByMajorViewModel.kt
    • Replaced AppPreferences with AppSubscriptionPreferenceRepository in NoticeByMajorViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/NotificationPreferencesViewModel.kt
    • Replaced AppPreferences with AppSubscriptionPreferenceRepository in NotificationPreferencesViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/SettingsViewModel.kt
    • Replaced AppPreferences with AppDatabasePreferenceRepository in SettingsViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/SplashViewModel.kt
    • Replaced AppPreferences with AppDatabasePreferenceRepository and simplified pre-process completion logic in SplashViewModel.
  • feature/main/src/main/java/com/doyoonkim/main/viewmodel/WidgetConfigViewModel.kt
    • Replaced AppPreferences with AppWidgetPreferenceRepository and AppSubscriptionPreferenceRepository in WidgetConfigViewModel.
  • feature/widget/src/main/java/com/doyoonkim/widget/worker/KnuticeWidgetSync.kt
    • Replaced AppPreferences with AppWidgetPreferenceRepository and AppSubscriptionPreferenceRepository in KnuticeWidgetSync.
Activity
  • gemini-code-assist[bot] provided an initial summary of the pull request.
  • gemini-code-assist[bot] suggested consistent TAG naming in the newly created remote repository implementations (RemoteContentRepositoryImpl, RemotePreferenceRepositoryImpl, RemoteTokenRepositoryImpl), which the author doyoonkim3312 subsequently resolved.
  • jeongHunE raised concerns regarding the RemoteContentRepositoryImpl and RemotePreferenceRepositoryImpl classes, noting that they appeared to violate the Single Responsibility Principle (SRP) by handling multiple distinct responsibilities.
  • jeongHunE also highlighted that the original AppPreferences class violated both the Interface Segregation Principle (ISP) and SRP, as it contained too many unrelated functionalities.
  • The author, doyoonkim3312, acknowledged and agreed with jeongHunE's feedback, indicating that the issues would be addressed, which this pull request successfully implements.

@KNUTICE KNUTICE deleted a comment from gemini-code-assist Bot Mar 26, 2026
@doyoonkim3312

Copy link
Copy Markdown
Member Author

Remove redundant comments

@doyoonkim3312 doyoonkim3312 requested a review from jeongHunE March 26, 2026 04:18

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

Copy link
Copy Markdown

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 refactors the application's preference management and dependency injection system. The monolithic AppPreferences class has been replaced by several granular preference repository interfaces (AppDatabasePreferenceRepository, AppSubscriptionPreferenceRepository, AppTokenPreferenceRepository, AppWidgetPreferenceRepository) and their implementations. The AppComponent and various scene-specific Dagger components have been updated to use these new interfaces, improving modularity and separation of concerns. Additionally, remote repository implementations have been split into more specific classes, and the KnuticeRemoteSource now receives tokens as arguments instead of directly depending on a preference class. Review comments suggest using named arguments for Dagger component factory methods to enhance readability and robustness, and address an argument order mismatch in one component creation.

Comment thread app/src/main/java/com/doyoonkim/knutice/MainApplication.kt Outdated
Comment thread app/src/main/java/com/doyoonkim/knutice/MainApplication.kt Outdated
Comment thread app/src/main/java/com/doyoonkim/knutice/navigation/MainServiceNavGraph.kt Outdated
  - Enhance Readability by using named Arguments and following function signature to provide arguments
@doyoonkim3312 doyoonkim3312 merged commit 08f0928 into development Mar 27, 2026
1 check passed
@doyoonkim3312 doyoonkim3312 deleted the REFACTOR/1.7.1/KAN-111-AppPreference-Structural-Change branch March 27, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement Structural or Functional Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants