updated/fixed custom domain preference setting
This commit is contained in:
parent
62071cc84b
commit
90314f5768
1 changed files with 14 additions and 7 deletions
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.animeextension.en.nineanime
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.webkit.URLUtil
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
|
@ -516,20 +517,26 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
EditTextPreference(screen.context).apply {
|
EditTextPreference(screen.context).apply {
|
||||||
key = PREF_CUSTOM_DOMAIN_KEY
|
key = PREF_CUSTOM_DOMAIN_KEY
|
||||||
title = "Preferred domain"
|
title = "Custom domain"
|
||||||
setDefaultValue(null)
|
setDefaultValue(null)
|
||||||
val currentValue = preferences.getString(PREF_CUSTOM_DOMAIN_KEY, null)
|
val currentValue = preferences.getString(PREF_CUSTOM_DOMAIN_KEY, null)
|
||||||
if (currentValue.isNullOrBlank()) {
|
summary = if (currentValue.isNullOrBlank()) {
|
||||||
summary = "Domain of your choosing. \nLeave blank to disable. Overrides any domain preferences!"
|
"Custom domain of your choosing"
|
||||||
} else {
|
} else {
|
||||||
summary = "Domain: \"$currentValue\". \nLeave blank to disable. Overrides any domain preferences!"
|
"Domain: \"$currentValue\". \nLeave blank to disable. Overrides any domain preferences!"
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
val newDomain = newValue as String
|
val newDomain = newValue as String
|
||||||
summary = "Restart to apply changes. \nLeave blank to disable. Overrides any domain preferences!"
|
if (newDomain.isBlank() || URLUtil.isValidUrl(newDomain)) {
|
||||||
Toast.makeText(screen.context, "Restart Aniyomi to apply changes", Toast.LENGTH_LONG).show()
|
summary = "Restart to apply changes"
|
||||||
preferences.edit().putString(key, newDomain).commit()
|
Toast.makeText(screen.context, "Restart Aniyomi to apply changes", Toast.LENGTH_LONG).show()
|
||||||
|
preferences.edit().putString(key, newDomain).apply()
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
Toast.makeText(screen.context, "Invalid url. Url example: https://aniwave.to", Toast.LENGTH_LONG).show()
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.also(screen::addPreference)
|
}.also(screen::addPreference)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue