MangaLib: Show domain warning as toast (#7012)

* MangaLib: Show domain warning as toast

* MangaLib: Fix
This commit is contained in:
Blue cat 2021-05-14 14:03:06 +03:00 committed by GitHub
parent 9bbe025fd9
commit 35c574a9ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaLib'
pkgNameSuffix = 'ru.libmanga'
extClass = '.LibManga'
extVersionCode = 45
extVersionCode = 46
libVersion = '1.2'
}

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.extension.ru.libmanga
import android.app.Application
import android.content.SharedPreferences
import android.widget.Toast
import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen
import com.github.salomonbrys.kotson.array
@ -786,13 +787,20 @@ class LibManga : ConfigurableSource, HttpSource() {
val domainPref = ListPreference(screen.context).apply {
key = DOMAIN_PREF
title = DOMAIN_PREF_Title
entries = arrayOf("mangalib.me(Основной)", "mangalib.org(Зеркало)")
entries = arrayOf("Основной (mangalib.me)", "Зеркало (mangalib.org)")
entryValues = arrayOf(baseOrig, baseMirr)
summary = "Для смены домена необходимо перезапустить приложение с полной остановкой"
summary = "%s"
setDefaultValue(baseOrig)
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
preferences.edit().putString(DOMAIN_PREF, selected).commit()
try {
val res = preferences.edit().putString(DOMAIN_PREF, newValue as String).commit()
val warning = "Для смены домена необходимо перезапустить приложение с полной остановкой."
Toast.makeText(screen.context, warning, Toast.LENGTH_LONG).show()
res
} catch (e: Exception) {
e.printStackTrace()
false
}
}
}