Removed Hardcoded mangadex pref

This commit is contained in:
Jay 2020-01-05 10:19:59 -08:00
parent b5963c3651
commit 5168f28f80
4 changed files with 13 additions and 68 deletions

View File

@ -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

View File

@ -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,75 +143,20 @@ 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) {
// 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<Preference> {
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<Preference>()
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()

View File

@ -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)

View File

@ -9,6 +9,8 @@
<changelogtext>(From dev) Auto attempt a login refresh once if MAL returns http 400</changelogtext>
<changelogtext>(From dev) Increase default text size of the transition chapter page</changelogtext>
<changelogtext>(From dev) Add .nomedia file in each chapter download folder</changelogtext>
<changelogtext>Hard coded Mangadex extension removed, please update your
extensions to access their preferences</changelogtext>
</changelogversion>
<changelogversion versionName="v0.9.41" changeDate="">