From 8540f07165815b9087deb0001c4451252565c864 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 19 Dec 2019 23:06:53 -0800 Subject: [PATCH] Version 0.9.35 Fixed crash when disabling all sources in a language before disabling any sources Added back MangaDex Extension Preferences --- README.md | 2 +- app/build.gradle | 4 +- .../data/preference/PreferencesHelper.kt | 2 +- .../extension/ExtensionDetailsController.kt | 99 +++++++++++++++---- .../ui/setting/SettingsSourcesController.kt | 2 +- app/src/main/res/raw/changelog_release.xml | 6 ++ 6 files changed, 93 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 095c6816cf..32117404fa 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tachiyomi is a free and open source manga reader for Android. ![screenshots of app](./.github/readme-images/theming-screenshots.gif) ## Newest Release -[v0.9.3](https://github.com/Jays2Kings/tachiyomi/releases) +[v0.9.35](https://github.com/Jays2Kings/tachiyomi/releases) ## Features diff --git a/app/build.gradle b/app/build.gradle index efdfa26707..cd430a40a8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,8 +38,8 @@ android { minSdkVersion 21 targetSdkVersion 29 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - versionCode 45 - versionName '0.9.3' + versionCode 46 + versionName '0.9.35' buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\"" buildConfigField "String", "COMMIT_SHA", "\"${getGitSha()}\"" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 79f16009fe..fe1269c6f9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -164,7 +164,7 @@ class PreferencesHelper(val context: Context) { fun automaticUpdates() = prefs.getBoolean(Keys.automaticUpdates, false) - fun hiddenCatalogues() = rxPrefs.getStringSet("hidden_catalogues", emptySet()) + fun hiddenCatalogues() = rxPrefs.getStringSet("hidden_catalogues", mutableSetOf()) fun downloadNew() = rxPrefs.getBoolean(Keys.downloadNew, false) 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 6d606fdab4..07236a3629 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,17 +2,25 @@ package eu.kanade.tachiyomi.ui.extension import android.annotation.SuppressLint import android.content.Context +import android.content.SharedPreferences import android.os.Bundle -import androidx.preference.* -import androidx.preference.MultiSelectListPreference -import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.DividerItemDecoration.VERTICAL -import androidx.recyclerview.widget.LinearLayoutManager import android.util.TypedValue import android.view.ContextThemeWrapper import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.preference.DialogPreference +import androidx.preference.EditTextPreference +import androidx.preference.EditTextPreferenceDialogController +import androidx.preference.ListPreference +import androidx.preference.ListPreferenceDialogController +import androidx.preference.MultiSelectListPreference +import androidx.preference.MultiSelectListPreferenceDialogController +import androidx.preference.Preference +import androidx.preference.PreferenceGroupAdapter +import androidx.preference.PreferenceManager +import androidx.preference.PreferenceScreen +import androidx.recyclerview.widget.DividerItemDecoration.VERTICAL import com.jakewharton.rxbinding.view.clicks import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.EmptyPreferenceDataStore @@ -21,7 +29,6 @@ import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.online.LoginSource import eu.kanade.tachiyomi.ui.base.controller.NucleusController -import eu.kanade.tachiyomi.ui.setting.preference import eu.kanade.tachiyomi.ui.setting.preferenceCategory import eu.kanade.tachiyomi.util.LocaleHelper import eu.kanade.tachiyomi.util.RecyclerWindowInsetsListener @@ -76,16 +83,16 @@ class ExtensionDetailsController(bundle: Bundle? = null) : val manager = PreferenceManager(themedContext) manager.preferenceDataStore = EmptyPreferenceDataStore() manager.onDisplayPreferenceDialogListener = this - val screen = manager.createPreferenceScreen(themedContext) + val screen = manager.createPreferenceScreen(context) preferenceScreen = screen val multiSource = extension.sources.size > 1 - /*for (source in extension.sources) { + for (source in extension.sources) { if (source is ConfigurableSource) { addPreferencesForSource(screen, source, multiSource) } - }*/ + } manager.setPreferences(screen) @@ -123,7 +130,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) : private fun addPreferencesForSource(screen: PreferenceScreen, source: Source, multiSource: Boolean) { val context = screen.context - // TODO + // TODO val dataStore = SharedPreferencesDataStore(/*if (source is HttpSource) { source.preferences } else {*/ @@ -137,18 +144,76 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } } - val newScreen = screen.preferenceManager.createPreferenceScreen(context) - source.setupPreferenceScreen(newScreen) + //val newScreen = screen.preferenceManager.createPreferenceScreen(context) + if (source.name == "MangaDex") { + val prefs = setupMangaDex("source_${source + .id}", context.getSharedPreferences("source_${source + .id}", Context.MODE_PRIVATE)) - for (i in 0 until newScreen.preferenceCount) { - val pref = newScreen.getPreference(i) - pref.preferenceDataStore = dataStore - pref.order = Int.MAX_VALUE // reset to default order - screen.addPreference(pref) + for (pref in prefs) { + pref.preferenceDataStore = dataStore + pref.order = Int.MAX_VALUE // reset to default order + 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/setting/SettingsSourcesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt index 150e19ee35..69f6aa7bd0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesController.kt @@ -101,7 +101,7 @@ class SettingsSourcesController : SettingsController(), onChange { newValue -> val checked = newValue as Boolean - val current = preferences.hiddenCatalogues().getOrDefault() + val current = preferences.hiddenCatalogues().get() ?: mutableSetOf() if (checked) current.removeAll(sources.map { it.id.toString() }) else diff --git a/app/src/main/res/raw/changelog_release.xml b/app/src/main/res/raw/changelog_release.xml index 44fa174c6a..f81d520c5d 100644 --- a/app/src/main/res/raw/changelog_release.xml +++ b/app/src/main/res/raw/changelog_release.xml @@ -1,5 +1,11 @@ + + Fixed crash when disabling all sources in a language before disabling any + sources + Added back MangaDex Extension Preferences + + Lock Tachiyomi using your fingerprint/Biometrics Added search/sorting/mass enable/disable to catalouge sources