-
Notifications
You must be signed in to change notification settings - Fork 3
introduces localization-aware networking to the app and refactors locale management for improved clarity and extensibility. #14
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
…oAcceptLanguageHeader
…oAcceptLanguageHeader
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.
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.
app/src/main/java/com/hoc081098/jetpackcomposelocalization/data/NetworkServiceLocator.kt
Outdated
Show resolved
Hide resolved
…oAcceptLanguageHeader
…s on locale changes
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.
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.
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:
AcceptedLanguageInterceptor,ApiService, andNetworkServiceLocatorto inject the current app locale into theAccept-LanguageHTTP header for all outgoing requests using OkHttp and Retrofit. [1] [2] [3]MyApplicationclass to initialize network services. [1] [2]Locale management refactor:
AppLocaleManagerand related UI to use a sealedAppLocaletype (withFollowSystemand specificLanguagevariants), replacing previous language string handling. This improves type safety and extensibility for locale selection. [1] [2] [3] [4] [5] [6]Networking demo UI:
DemoAcceptLanguageHeadercomposable and its view model to demonstrate fetching data fromhttpbin.org/getand displaying the result or errors, showing how the Accept-Language header is used. [1] [2]Build configuration and dependencies:
build.gradle.ktsto 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:
.idea/vcs.xmlfor improved commit quality in development.