From 5168f28f8073553104f2a2bada08a2a607ccb0b2 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 5 Jan 2020 10:19:59 -0800 Subject: [PATCH] Removed Hardcoded mangadex pref --- README.md | 1 - .../extension/ExtensionDetailsController.kt | 76 +++---------------- .../kanade/tachiyomi/ui/main/MainActivity.kt | 2 +- app/src/main/res/raw/changelog_release.xml | 2 + 4 files changed, 13 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 751d0cfe5f..2695d79456 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ Plus some new features in this fork such as: * Reader seekbar overrides switch app gesture in Android 10, so no more accidents for that * Option to hide manga titles in grid view * Filter out your library by searching for tags (ex. "Comedy" or "Slice of Life") or exclude mangas by a tag (ex. "-Shounen" or "-Romance"). Tapping on these tags also performs a local search. You can also search multiple tags (ex. "Romance, -Harem, Comedy") -* Android X Support (**Becasue of this change needed for Android 10 features, extension preferences are currently disabled for all extensions except Mangadex**) * Tri-State Filters on library * Filter extensions based on your locale * Webview Navigation diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt index 07236a3629..933673ac7f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionDetailsController.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.extension import android.annotation.SuppressLint import android.content.Context -import android.content.SharedPreferences import android.os.Bundle import android.util.TypedValue import android.view.ContextThemeWrapper @@ -144,76 +143,21 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } } - //val newScreen = screen.preferenceManager.createPreferenceScreen(context) - if (source.name == "MangaDex") { - val prefs = setupMangaDex("source_${source - .id}", context.getSharedPreferences("source_${source - .id}", Context.MODE_PRIVATE)) + val newScreen = screen.preferenceManager.createPreferenceScreen(context) + source.setupPreferenceScreen(newScreen) - for (pref in prefs) { - pref.preferenceDataStore = dataStore - pref.order = Int.MAX_VALUE // reset to default order - screen.addPreference(pref) - } + // Reparent the preferences + while (newScreen.preferenceCount != 0) { + val pref = newScreen.getPreference(0) + pref.preferenceDataStore = dataStore + pref.order = Int.MAX_VALUE // reset to default order + + newScreen.removePreference(pref) + screen.addPreference(pref) } } } - private fun setupMangaDex(id: String, preferences: SharedPreferences): List { - val showR18PrefTitle = "Default R18 Setting" - val showR18Pref = "showR18Default" - val showThumbnailPrefTitle = "Default thumbnail quality" - val showThumbnailPref = "showThumbnailDefault" - val serverPrefTitle = "Image server" - val serverPrefI = "imageServer" - val serverPrefEntries = arrayOf("Automatic", "NA/EU 1", "NA/EU 2", "Rest of the world") - val serverPrefEntriesValue = arrayOf("0", "na", "na2", "row") - var prefs = mutableListOf() - prefs.add(ListPreference(applicationContext).apply { - key = "$id.$showR18PrefTitle" - title = showR18Pref - - title = showR18PrefTitle - entries = arrayOf("Show No R18+", "Show All", "Show Only R18+") - entryValues = arrayOf("0", "1", "2") - summary = "%s" - - setOnPreferenceChangeListener { _, newValue -> - val selected = newValue as String - val index = this.findIndexOfValue(selected) - preferences.edit().putInt(showR18Pref, index).commit() - } - }) - prefs.add(ListPreference(applicationContext).apply { - key = "$id.$showThumbnailPrefTitle" - title = showThumbnailPrefTitle - entries = arrayOf("Show high quality", "Show low quality") - entryValues = arrayOf("0", "1") - summary = "%s" - - setOnPreferenceChangeListener { _, newValue -> - val selected = newValue as String - val index = this.findIndexOfValue(selected) - preferences.edit().putInt(showThumbnailPref, index).commit() - } - }) - prefs.add(ListPreference(applicationContext).apply { - key = "$id.$serverPrefTitle" - title = serverPrefTitle - entries = serverPrefEntries - entryValues = serverPrefEntriesValue - summary = "%s" - - setOnPreferenceChangeListener { _, newValue -> - val selected = newValue as String - val index = this.findIndexOfValue(selected) - val entry = entryValues[index] as String - preferences.edit().putString(serverPrefI, entry).commit() - } - }) - return prefs - } - private fun getPreferenceThemeContext(): Context { val tv = TypedValue() activity!!.theme.resolveAttribute(R.attr.preferenceTheme, tv, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index b787a69d3c..36cc42e67e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -349,7 +349,7 @@ class MainActivity : BaseActivity() { } } - private fun setSelectedDrawerItem(itemId: Int) { + fun setSelectedDrawerItem(itemId: Int) { if (!isFinishing) { nav_view.setCheckedItem(itemId) nav_view.menu.performIdentifierAction(itemId, 0) diff --git a/app/src/main/res/raw/changelog_release.xml b/app/src/main/res/raw/changelog_release.xml index 8be9f2e55a..28334282e2 100644 --- a/app/src/main/res/raw/changelog_release.xml +++ b/app/src/main/res/raw/changelog_release.xml @@ -9,6 +9,8 @@ (From dev) Auto attempt a login refresh once if MAL returns http 400 (From dev) Increase default text size of the transition chapter page (From dev) Add .nomedia file in each chapter download folder + Hard coded Mangadex extension removed, please update your + extensions to access their preferences