Merge branch 'master' into devel
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
versionCode 545
|
versionCode 546
|
||||||
versionName '5.1.1'
|
versionName '5.1.2'
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependency
|
||||||
implementation('com.github.KotatsuApp:kotatsu-parsers:cae7073f87') {
|
implementation('com.github.KotatsuApp:kotatsu-parsers:ebcc6391d6') {
|
||||||
exclude group: 'org.json', module: 'json'
|
exclude group: 'org.json', module: 'json'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.koitharu.kotatsu.settings
|
||||||
|
|
||||||
|
import okhttp3.Headers
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.core.network.CommonHeaders
|
||||||
|
import org.koitharu.kotatsu.core.util.EditTextValidator
|
||||||
|
|
||||||
|
class HeaderValidator : EditTextValidator() {
|
||||||
|
|
||||||
|
private val headers = Headers.Builder()
|
||||||
|
|
||||||
|
override fun validate(text: String): ValidationResult {
|
||||||
|
val trimmed = text.trim()
|
||||||
|
if (trimmed.isEmpty()) {
|
||||||
|
return ValidationResult.Success
|
||||||
|
}
|
||||||
|
return if (!validateImpl(trimmed)) {
|
||||||
|
ValidationResult.Failed(context.getString(R.string.invalid_value_message))
|
||||||
|
} else {
|
||||||
|
ValidationResult.Success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun validateImpl(value: String): Boolean = runCatching {
|
||||||
|
headers[CommonHeaders.USER_AGENT] = value
|
||||||
|
}.isSuccess
|
||||||
|
}
|
||||||
@@ -44,7 +44,7 @@ fun PreferenceFragmentCompat.addPreferencesFromRepository(repository: RemoteMang
|
|||||||
EditTextBindListener(
|
EditTextBindListener(
|
||||||
inputType = EditorInfo.TYPE_CLASS_TEXT,
|
inputType = EditorInfo.TYPE_CLASS_TEXT,
|
||||||
hint = key.defaultValue,
|
hint = key.defaultValue,
|
||||||
validator = null,
|
validator = HeaderValidator(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
setTitle(R.string.user_agent)
|
setTitle(R.string.user_agent)
|
||||||
|
|||||||
@@ -423,4 +423,5 @@
|
|||||||
<string name="address">Address</string>
|
<string name="address">Address</string>
|
||||||
<string name="port">Port</string>
|
<string name="port">Port</string>
|
||||||
<string name="proxy">Proxy</string>
|
<string name="proxy">Proxy</string>
|
||||||
|
<string name="invalid_value_message">Invalid value</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user