Skip to content

Conversation

@hoc081098
Copy link
Owner

This pull request introduces localization-aware networking to the app and refactors locale management for improved clarity and extensibility. It adds a new demo for showing how the Accept-Language header is sent in network requests, updates dependencies to support networking (Retrofit, Moshi, OkHttp), and refactors locale selection logic to work with full locale objects instead of language strings. The most significant changes are grouped below.

Localization-aware networking:

  • Added AcceptedLanguageInterceptor, ApiService, and NetworkServiceLocator to inject the current app locale into the Accept-Language HTTP header for all outgoing requests using OkHttp and Retrofit. [1] [2] [3]
  • Updated the manifest to request internet and network state permissions, and registered a custom MyApplication class to initialize network services. [1] [2]

Locale management refactor:

  • Refactored AppLocaleManager and related UI to use a sealed AppLocale type (with FollowSystem and specific Language variants), replacing previous language string handling. This improves type safety and extensibility for locale selection. [1] [2] [3] [4] [5] [6]

Networking demo UI:

  • Added DemoAcceptLanguageHeader composable and its view model to demonstrate fetching data from httpbin.org/get and displaying the result or errors, showing how the Accept-Language header is used. [1] [2]

Build configuration and dependencies:

  • Updated build.gradle.kts to add dependencies for Retrofit, Moshi, and OkHttp, and refactored locale configuration to use locale tags instead of language codes. [1] [2] [3] [4] [5]

IDE configuration:

  • Added commit message inspection profile to .idea/vcs.xml for improved commit quality in development.

@hoc081098 hoc081098 requested a review from Copilot October 8, 2025 10:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces localization-aware networking and refactors locale management to improve type safety and extensibility. It enables the app to automatically send Accept-Language headers with the current locale in HTTP requests and modernizes locale handling throughout the codebase.

  • Adds networking infrastructure with Retrofit, Moshi, and OkHttp for HTTP requests
  • Refactors locale management from string-based to type-safe sealed interface design
  • Introduces Accept-Language header injection for all outgoing network requests

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
gradle/libs.versions.toml Adds OkHttp dependency version definition
app/src/main/java/com/hoc081098/jetpackcomposelocalization/ui/locale/AppLocaleManager.kt Refactors locale management to use sealed AppLocale interface instead of strings
app/src/main/java/com/hoc081098/jetpackcomposelocalization/data/NetworkServiceLocator.kt Creates networking service locator with Accept-Language header injection
app/src/main/java/com/hoc081098/jetpackcomposelocalization/data/ApiService.kt Defines Retrofit API service interface for HTTP requests
app/src/main/java/com/hoc081098/jetpackcomposelocalization/data/AcceptedLanguageInterceptor.kt Implements OkHttp interceptor for automatic Accept-Language header injection
app/src/main/java/com/hoc081098/jetpackcomposelocalization/MyApplication.kt Adds application class to initialize network services
app/src/main/java/com/hoc081098/jetpackcomposelocalization/MainActivity.kt Updates UI to work with new AppLocale sealed interface
app/src/main/java/com/hoc081098/jetpackcomposelocalization/DemoAcceptLanguageHeader.kt Adds demo UI for testing Accept-Language header functionality
app/src/main/AndroidManifest.xml Adds internet permissions and registers MyApplication class
app/build.gradle.kts Updates dependencies and build configuration for networking libraries
Files not reviewed (1)
  • .idea/vcs.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • .idea/vcs.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hoc081098 hoc081098 merged commit b3a09ad into main Oct 8, 2025
1 check passed
@hoc081098 hoc081098 deleted the temp branch October 8, 2025 12:18
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