Proxy authenticaton support #376
parent
661e502003
commit
548c41fbf9
@ -0,0 +1,22 @@
|
|||||||
|
package org.koitharu.kotatsu.core.network
|
||||||
|
|
||||||
|
import okhttp3.Authenticator
|
||||||
|
import okhttp3.Credentials
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import okhttp3.Route
|
||||||
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
|
|
||||||
|
class ProxyAuthenticator(
|
||||||
|
private val settings: AppSettings,
|
||||||
|
) : Authenticator {
|
||||||
|
|
||||||
|
override fun authenticate(route: Route?, response: Response): Request? {
|
||||||
|
val login = settings.proxyLogin ?: return null
|
||||||
|
val password = settings.proxyPassword ?: return null
|
||||||
|
val credential = Credentials.basic(login, password)
|
||||||
|
return response.request.newBuilder()
|
||||||
|
.header(CommonHeaders.PROXY_AUTHORIZATION, credential)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package org.koitharu.kotatsu.settings.utils
|
||||||
|
|
||||||
|
import android.text.TextUtils
|
||||||
|
import androidx.preference.EditTextPreference
|
||||||
|
import androidx.preference.Preference
|
||||||
|
|
||||||
|
class PasswordSummaryProvider() : Preference.SummaryProvider<EditTextPreference> {
|
||||||
|
|
||||||
|
private val delegate = EditTextPreference.SimpleSummaryProvider.getInstance()
|
||||||
|
|
||||||
|
override fun provideSummary(preference: EditTextPreference): CharSequence? {
|
||||||
|
val summary = delegate.provideSummary(preference)
|
||||||
|
return if (summary != null && !TextUtils.isEmpty(preference.text)) {
|
||||||
|
String(CharArray(summary.length) { '\u2022' })
|
||||||
|
} else {
|
||||||
|
summary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue