Fix reading position not being saved when opening multi-versioned EH manga
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package exh.debug
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
enum class DebugToggles(val default: Boolean) {
|
||||
ENABLE_EXH_ROOT_REDIRECT(true),
|
||||
ENABLE_DEBUG_OVERLAY(true),
|
||||
PULL_TO_ROOT_WHEN_LOADING_EXH_MANGA_DETAILS(true);
|
||||
|
||||
val prefKey = "eh_debug_toggle_${name.toLowerCase()}"
|
||||
|
||||
var enabled: Boolean
|
||||
get() = prefs.rxPrefs.getBoolean(prefKey, default).get()!!
|
||||
set(value) {
|
||||
prefs.rxPrefs.getBoolean(prefKey).set(value)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val prefs: PreferencesHelper by injectLazy()
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,12 @@ package exh.debug
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.support.v7.preference.PreferenceScreen
|
||||
import android.text.Html
|
||||
import android.util.Log
|
||||
import android.widget.HorizontalScrollView
|
||||
import android.widget.TextView
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||
import eu.kanade.tachiyomi.ui.setting.onClick
|
||||
import eu.kanade.tachiyomi.ui.setting.preference
|
||||
import eu.kanade.tachiyomi.ui.setting.*
|
||||
import kotlin.reflect.KVisibility
|
||||
import kotlin.reflect.full.declaredFunctions
|
||||
|
||||
@@ -17,33 +16,55 @@ class SettingsDebugController : SettingsController() {
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
title = "DEBUG MENU"
|
||||
|
||||
DebugFunctions::class.declaredFunctions.filter {
|
||||
it.visibility == KVisibility.PUBLIC
|
||||
}.forEach {
|
||||
preference {
|
||||
title = it.name.replace(Regex("(.)(\\p{Upper})"), "$1 $2").toLowerCase().capitalize()
|
||||
isPersistent = false
|
||||
preferenceCategory {
|
||||
title = "Functions"
|
||||
|
||||
onClick {
|
||||
val view = TextView(context)
|
||||
view.setHorizontallyScrolling(true)
|
||||
view.setTextIsSelectable(true)
|
||||
DebugFunctions::class.declaredFunctions.filter {
|
||||
it.visibility == KVisibility.PUBLIC
|
||||
}.forEach {
|
||||
preference {
|
||||
title = it.name.replace(Regex("(.)(\\p{Upper})"), "$1 $2").toLowerCase().capitalize()
|
||||
isPersistent = false
|
||||
|
||||
val hView = HorizontalScrollView(context)
|
||||
hView.addView(view)
|
||||
onClick {
|
||||
val view = TextView(context)
|
||||
view.setHorizontallyScrolling(true)
|
||||
view.setTextIsSelectable(true)
|
||||
|
||||
try {
|
||||
val result = it.call(DebugFunctions)
|
||||
view.text = "Function returned result:\n\n$result"
|
||||
MaterialDialog.Builder(context)
|
||||
.customView(hView, true)
|
||||
} catch(t: Throwable) {
|
||||
view.text = "Function threw exception:\n\n${Log.getStackTraceString(t)}"
|
||||
MaterialDialog.Builder(context)
|
||||
.customView(hView, true)
|
||||
}.show()
|
||||
val hView = HorizontalScrollView(context)
|
||||
hView.addView(view)
|
||||
|
||||
try {
|
||||
val result = it.call(DebugFunctions)
|
||||
view.text = "Function returned result:\n\n$result"
|
||||
MaterialDialog.Builder(context)
|
||||
.customView(hView, true)
|
||||
} catch(t: Throwable) {
|
||||
view.text = "Function threw exception:\n\n${Log.getStackTraceString(t)}"
|
||||
MaterialDialog.Builder(context)
|
||||
.customView(hView, true)
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
title = "Toggles"
|
||||
|
||||
DebugToggles.values().forEach {
|
||||
switchPreference {
|
||||
title = it.name.replace('_', ' ').toLowerCase().capitalize()
|
||||
key = it.prefKey
|
||||
defaultValue = it.default
|
||||
summaryOn = if(it.default) "" else MODIFIED_TEXT
|
||||
summaryOff = if(it.default) MODIFIED_TEXT else ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val MODIFIED_TEXT = Html.fromHtml("<font color='red'>MODIFIED</font>")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user