From c1bc1bf6a9fb0f356c1766da07006840fc124339 Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Thu, 31 Oct 2019 08:16:47 -0700 Subject: [PATCH] [Mangadex] Remove eu/eu2 image server options and update strings to match current website options (#1680) [Mangadex] Remove eu/eu2 image server options and update strings to match current website options --- src/all/mangadex/build.gradle | 2 +- .../tachiyomi/extension/all/mangadex/Mangadex.kt | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index 71ca6b1b7..dc4486c59 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangadexFactory' - extVersionCode = 69 + extVersionCode = 70 libVersion = '1.2' } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt index 4b7e5cecc..8eb0948e1 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/Mangadex.kt @@ -584,8 +584,8 @@ abstract class Mangadex( val serverPref = ListPreference(screen.context).apply { key = SERVER_PREF_Title title = SERVER_PREF_Title - entries = arrayOf("Auto", "North America", "North America 2", "Europe", "Europe 2", "Rest of the World") - entryValues = arrayOf("0", "na", "na2", "eu", "eu2", "row") + entries = SERVER_PREF_ENTRIES + entryValues = SERVER_PREF_ENTRY_VALUES summary = "%s" setOnPreferenceChangeListener { _, newValue -> @@ -603,7 +603,11 @@ abstract class Mangadex( private fun getShowR18(): Int = preferences.getInt(SHOW_R18_PREF, 0) private fun getShowThumbnail(): Int = preferences.getInt(SHOW_THUMBNAIL_PREF, 0) - private fun getServer(): String = preferences.getString(SERVER_PREF, "0") + private fun getServer(): String { + val default = SERVER_PREF_ENTRY_VALUES.first() + return preferences.getString(SERVER_PREF, default).takeIf { it in SERVER_PREF_ENTRY_VALUES } + ?: default + } private class TextField(name: String, val key: String) : Filter.Text(name) private class Tag(val id: String, name: String) : Filter.TriState(name) @@ -765,6 +769,8 @@ abstract class Mangadex( private const val SERVER_PREF_Title = "Image server" private const val SERVER_PREF = "imageServer" + private val SERVER_PREF_ENTRIES = arrayOf("Automatic", "NA/EU 1", "NA/EU 2", "Rest of the world") + private val SERVER_PREF_ENTRY_VALUES = arrayOf("0", "na", "na2", "row") private const val API_MANGA = "/api/manga/" private const val API_CHAPTER = "/api/chapter/"