- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 16
Allow user to set custom user agent #663
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
a6fc5b3    to
    597e129      
    Compare
  
    597e129    to
    80ecbb2      
    Compare
  
    | @ArnyminerZ This is really a rushed minimal implementation. During the weekend please take a proper look and test everything well. I think it should work out, but I did for example not test the import/export. I would leave the extra microsoft user agent for a separate PR. | 
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.
        
          
                app/src/main/java/at/bitfire/icsdroid/model/SubscriptionSettingsUseCase.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                app/src/main/java/at/bitfire/icsdroid/ui/views/EnterUrlComposable.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
      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 enables users to set custom user agents per subscription to better handle servers that require specific user agent strings for access. This addresses the issue where the ktor-client default user agent was being sent instead of the intended custom one.
- Add custom user agent support to subscription data model and UI screens
- Switch from OkHttp interceptor to ktor UserAgent plugin for proper user agent handling
- Implement dependency injection factory pattern for AppHttpClient to support per-subscription configuration
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description | 
|---|---|
| strings.xml | Add UI strings for custom user agent input field | 
| SubscriptionSettingsComposable.kt | Add custom user agent text field to subscription settings | 
| EnterUrlComposable.kt | Add custom user agent input to URL entry form with advanced settings section | 
| EditSubscriptionScreen.kt | Pass custom user agent data through edit subscription flow | 
| AddSubscriptionScreen.kt | Pass custom user agent data through add subscription flow | 
| ValidationUseCase.kt | Update validation to use custom user agent via factory pattern | 
| SubscriptionSettingsUseCase.kt | Add custom user agent state management and validation logic | 
| EditSubscriptionModel.kt | Add custom user agent persistence for existing subscriptions | 
| AddSubscriptionModel.kt | Add custom user agent persistence for new subscriptions | 
| Subscription.kt | Add customUserAgent field to database entity and JSON serialization | 
| AppDatabase.kt | Bump database version for schema migration | 
| ProcessEventsTask.kt | Use factory to create HTTP client with subscription's custom user agent | 
| HttpUtils.kt | Refactor authentication check to general protocol validation | 
| AppHttpClient.kt | Convert to factory pattern with ktor UserAgent plugin instead of interceptor | 
Comments suppressed due to low confidence (1)
app/src/main/java/at/bitfire/icsdroid/ui/views/EnterUrlComposable.kt:316
- The parameter name supportsAuthenticationis misleading since it's being passedvalidUrlInput. Consider renaming the parameter to match its actual purpose or verify the correct value is being passed.
        error,
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Introduce `ToggleTextField` composable for toggling and setting custom user agent - Update strings for custom user agent title, description, and placeholder - Replace `ResourceInput` with `ToggleTextField` in `EnterUrlComposable`
| Please take a look. I incorporated the requested changes and: 
 | 
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.
        
          
                app/src/main/java/at/bitfire/icsdroid/model/SubscriptionSettingsUseCase.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                app/src/main/java/at/bitfire/icsdroid/ui/partials/ToggleTextField.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
      986a882    to
    f22737c      
    Compare
  
    | hmm yes. Makes absolute sense. Thank you for the thorough review 👍 | 
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.
Got to a quite big PR, but works well for me.



Purpose
Enable user to add custom user agent per subscription.
Short description
Note:
The network interceptor approach introduced with the switch to ktor would have never worked. Kind of nice we notice it before releasing that. When I checked the user agent string with the android studio network inspector it simply said ktor-client or similar. Now with the ktor user agent plugin it actually sends the right user agent.
Checklist