-
Couldn't load subscription status.
- Fork 554
feat: Add server configuration field for fDroid #2143
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
|
@iamareebjamal Koin module is not refreshing, event after opening the app again. |
|
See how it is done in Orga App |
In orga app, URL is directly set in |
val preference = Preference()
var url = preference.getString(API_URL)
override fun intercept(chain: Interceptor.Chain): Response {
val authorization = authHolder.getAuthorization()
val request = chain.request().newBuilder()
val httpUrl = url
if (httpUrl != null) {
request.url(httpUrl)
}
return if (authorization != null) {
request.header("Authorization", authorization)
chain.proceed(request.build())
} else
chain.proceed(request.build())
} |
|
We are using dagger there, so no difference. You have to implement it similarly, using Interceptor |
|
Updated. Working 👍 |
| override fun intercept(chain: Interceptor.Chain): Response { | ||
| var original = chain.request() | ||
| val httpUrl = preference.getString(API_URL)?.toHttpUrlOrNull() | ||
| if (httpUrl != null) { |
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.
This has a flaw which is in Orga App as well. This will replace every URL with API URL. We want only the API URL to be replaced
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.
I find this same solution: https://gist.github.com/swankjesse/8571a8207a5815cca1fb#file-hostselectioninterceptor-java-L19
One guy commenting that it will change all URLs: https://gist.github.com/swankjesse/8571a8207a5815cca1fb#gistcomment-2160202 and provide following solution for setting multiple API URLs using RetrofitUrlManager.getInstance().putDomain() : https://github.com/JessYanCoding/RetrofitUrlManager/blob/master/app/src/main/java/me/jessyan/retrofiturlmanager/demo/MainActivity.java
Can you please check it.
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.
You just have to add an if statement, if (BuildConfig.API_URL == incomingUrl)
proceed to change, else skip
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.
How? BuildConfig.API_URL is always the default URL, and incomingUrl will change according to user preference. If they are equal then no need to change. I think it should reverse.
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.
BuildConfig.API_URL will be the base URL. So incoming URL will be BuildConfig.API_URL if it is API call. In which case, we'll replace it with the URL in preference. If it is not BuildConfig.API_URL, then it may be for different domain, like google.com, in which case, we'll not replace it because it is not our API domain. Clear?
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.
BuildConfig.API_URL will be the base URL. So incoming URL will be BuildConfig.API_URL if it is API call. In which case, we'll replace it with the URL in preference. If it is not BuildConfig.API_URL, then it may be for different domain, like google.com, in which case, we'll not replace it because it is not our API domain. Clear?
Yes ✌️
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.
Updated
Fixes #2142