Convert EH settings to FlowPrefrences
This commit is contained in:
parent
60a0303d7f
commit
6e1da22353
@ -7,12 +7,16 @@ import com.google.gson.Gson
|
|||||||
import com.jakewharton.disklrucache.DiskLruCache
|
import com.jakewharton.disklrucache.DiskLruCache
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
import eu.kanade.tachiyomi.util.storage.saveTo
|
import eu.kanade.tachiyomi.util.storage.saveTo
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
import okio.sink
|
import okio.sink
|
||||||
@ -41,6 +45,8 @@ class ChapterCache(private val context: Context) {
|
|||||||
const val PARAMETER_VALUE_COUNT = 1
|
const val PARAMETER_VALUE_COUNT = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
|
|
||||||
/** Google Json class used for parsing JSON files. */
|
/** Google Json class used for parsing JSON files. */
|
||||||
private val gson: Gson by injectLazy()
|
private val gson: Gson by injectLazy()
|
||||||
|
|
||||||
@ -50,15 +56,17 @@ class ChapterCache(private val context: Context) {
|
|||||||
|
|
||||||
/** Cache class used for cache management. */
|
/** Cache class used for cache management. */
|
||||||
// --> EH
|
// --> EH
|
||||||
private var diskCache = setupDiskCache(prefs.eh_cacheSize().getOrDefault().toLong())
|
private var diskCache = setupDiskCache(prefs.eh_cacheSize().get().toLong())
|
||||||
|
|
||||||
init {
|
init {
|
||||||
prefs.eh_cacheSize().asObservable().skip(1).subscribe {
|
prefs.eh_cacheSize().asFlow()
|
||||||
// Save old cache for destruction later
|
.onEach {
|
||||||
val oldCache = diskCache
|
// Save old cache for destruction later
|
||||||
diskCache = setupDiskCache(it.toLong())
|
val oldCache = diskCache
|
||||||
oldCache.close()
|
diskCache = setupDiskCache(it.toLong())
|
||||||
}
|
oldCache.close()
|
||||||
|
}
|
||||||
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
// <-- EH
|
// <-- EH
|
||||||
|
|
||||||
|
@ -240,16 +240,16 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun migrationSources() = flowPrefs.getString("migrate_sources", "")
|
fun migrationSources() = flowPrefs.getString("migrate_sources", "")
|
||||||
|
|
||||||
fun smartMigration() = rxPrefs.getBoolean("smart_migrate", false)
|
fun smartMigration() = flowPrefs.getBoolean("smart_migrate", false)
|
||||||
|
|
||||||
fun useSourceWithMost() = rxPrefs.getBoolean("use_source_with_most", false)
|
fun useSourceWithMost() = flowPrefs.getBoolean("use_source_with_most", false)
|
||||||
|
|
||||||
fun skipPreMigration() = flowPrefs.getBoolean(Keys.skipPreMigration, false)
|
fun skipPreMigration() = flowPrefs.getBoolean(Keys.skipPreMigration, false)
|
||||||
|
|
||||||
fun upgradeFilters() {
|
fun upgradeFilters() {
|
||||||
val filterDl = rxPrefs.getBoolean(Keys.filterDownloaded, false).getOrDefault()
|
val filterDl = flowPrefs.getBoolean(Keys.filterDownloaded, false).get()
|
||||||
val filterUn = rxPrefs.getBoolean(Keys.filterUnread, false).getOrDefault()
|
val filterUn = flowPrefs.getBoolean(Keys.filterUnread, false).get()
|
||||||
val filterCm = rxPrefs.getBoolean(Keys.filterCompleted, false).getOrDefault()
|
val filterCm = flowPrefs.getBoolean(Keys.filterCompleted, false).get()
|
||||||
filterDownloaded().set(if (filterDl) 1 else 0)
|
filterDownloaded().set(if (filterDl) 1 else 0)
|
||||||
filterUnread().set(if (filterUn) 1 else 0)
|
filterUnread().set(if (filterUn) 1 else 0)
|
||||||
filterCompleted().set(if (filterCm) 1 else 0)
|
filterCompleted().set(if (filterCm) 1 else 0)
|
||||||
@ -258,91 +258,80 @@ class PreferencesHelper(val context: Context) {
|
|||||||
// <--
|
// <--
|
||||||
|
|
||||||
// --> EH
|
// --> EH
|
||||||
fun enableExhentai() = rxPrefs.getBoolean(Keys.eh_enableExHentai, false)
|
fun enableExhentai() = flowPrefs.getBoolean(Keys.eh_enableExHentai, false)
|
||||||
|
|
||||||
fun secureEXH() = rxPrefs.getBoolean("secure_exh", true)
|
fun secureEXH() = flowPrefs.getBoolean("secure_exh", true)
|
||||||
|
|
||||||
fun imageQuality() = rxPrefs.getString("ehentai_quality", "auto")
|
fun imageQuality() = flowPrefs.getString("ehentai_quality", "auto")
|
||||||
|
|
||||||
fun useHentaiAtHome() = rxPrefs.getBoolean("enable_hah", true)
|
fun useHentaiAtHome() = flowPrefs.getBoolean("enable_hah", true)
|
||||||
|
|
||||||
fun useJapaneseTitle() = rxPrefs.getBoolean("use_jp_title", false)
|
fun useJapaneseTitle() = flowPrefs.getBoolean("use_jp_title", false)
|
||||||
|
|
||||||
fun eh_useOriginalImages() = rxPrefs.getBoolean(Keys.eh_useOrigImages, false)
|
fun eh_useOriginalImages() = flowPrefs.getBoolean(Keys.eh_useOrigImages, false)
|
||||||
|
|
||||||
fun ehSearchSize() = rxPrefs.getString("ex_search_size", "rc_0")
|
fun ehSearchSize() = flowPrefs.getString("ex_search_size", "rc_0")
|
||||||
|
|
||||||
fun thumbnailRows() = rxPrefs.getString("ex_thumb_rows", "tr_2")
|
fun thumbnailRows() = flowPrefs.getString("ex_thumb_rows", "tr_2")
|
||||||
|
|
||||||
fun hasPerformedURLMigration() = rxPrefs.getBoolean("performed_url_migration", false)
|
fun hasPerformedURLMigration() = flowPrefs.getBoolean("performed_url_migration", false)
|
||||||
|
|
||||||
// EH Cookies
|
// EH Cookies
|
||||||
fun memberIdVal() = rxPrefs.getString("eh_ipb_member_id", "")
|
fun memberIdVal() = flowPrefs.getString("eh_ipb_member_id", "")
|
||||||
|
|
||||||
fun passHashVal() = rxPrefs.getString("eh_ipb_pass_hash", "")
|
fun passHashVal() = flowPrefs.getString("eh_ipb_pass_hash", "")
|
||||||
fun igneousVal() = rxPrefs.getString("eh_igneous", "")
|
fun igneousVal() = flowPrefs.getString("eh_igneous", "")
|
||||||
fun eh_ehSettingsProfile() = rxPrefs.getInteger(Keys.eh_ehSettingsProfile, -1)
|
fun eh_ehSettingsProfile() = flowPrefs.getInt(Keys.eh_ehSettingsProfile, -1)
|
||||||
fun eh_exhSettingsProfile() = rxPrefs.getInteger(Keys.eh_exhSettingsProfile, -1)
|
fun eh_exhSettingsProfile() = flowPrefs.getInt(Keys.eh_exhSettingsProfile, -1)
|
||||||
fun eh_settingsKey() = rxPrefs.getString(Keys.eh_settingsKey, "")
|
fun eh_settingsKey() = flowPrefs.getString(Keys.eh_settingsKey, "")
|
||||||
fun eh_sessionCookie() = rxPrefs.getString(Keys.eh_sessionCookie, "")
|
fun eh_sessionCookie() = flowPrefs.getString(Keys.eh_sessionCookie, "")
|
||||||
fun eh_hathPerksCookies() = rxPrefs.getString(Keys.eh_hathPerksCookie, "")
|
fun eh_hathPerksCookies() = flowPrefs.getString(Keys.eh_hathPerksCookie, "")
|
||||||
|
|
||||||
// Lock
|
fun eh_nh_useHighQualityThumbs() = flowPrefs.getBoolean(Keys.eh_nh_useHighQualityThumbs, false)
|
||||||
fun eh_lockHash() = rxPrefs.getString(Keys.eh_lock_hash, null)
|
|
||||||
|
|
||||||
fun eh_lockSalt() = rxPrefs.getString(Keys.eh_lock_salt, null)
|
|
||||||
|
|
||||||
fun eh_lockLength() = rxPrefs.getInteger(Keys.eh_lock_length, -1)
|
|
||||||
|
|
||||||
fun eh_lockUseFingerprint() = rxPrefs.getBoolean(Keys.eh_lock_finger, false)
|
|
||||||
|
|
||||||
fun eh_lockManually() = rxPrefs.getBoolean(Keys.eh_lock_manually, false)
|
|
||||||
|
|
||||||
fun eh_nh_useHighQualityThumbs() = rxPrefs.getBoolean(Keys.eh_nh_useHighQualityThumbs, false)
|
|
||||||
|
|
||||||
fun eh_showSyncIntro() = flowPrefs.getBoolean(Keys.eh_showSyncIntro, true)
|
fun eh_showSyncIntro() = flowPrefs.getBoolean(Keys.eh_showSyncIntro, true)
|
||||||
|
|
||||||
fun eh_readOnlySync() = rxPrefs.getBoolean(Keys.eh_readOnlySync, false)
|
fun eh_readOnlySync() = flowPrefs.getBoolean(Keys.eh_readOnlySync, false)
|
||||||
|
|
||||||
fun eh_lenientSync() = rxPrefs.getBoolean(Keys.eh_lenientSync, false)
|
fun eh_lenientSync() = flowPrefs.getBoolean(Keys.eh_lenientSync, false)
|
||||||
|
|
||||||
fun eh_ts_aspNetCookie() = rxPrefs.getString(Keys.eh_ts_aspNetCookie, "")
|
fun eh_ts_aspNetCookie() = flowPrefs.getString(Keys.eh_ts_aspNetCookie, "")
|
||||||
|
|
||||||
fun eh_showSettingsUploadWarning() = flowPrefs.getBoolean(Keys.eh_showSettingsUploadWarning, true)
|
fun eh_showSettingsUploadWarning() = flowPrefs.getBoolean(Keys.eh_showSettingsUploadWarning, true)
|
||||||
|
|
||||||
fun eh_expandFilters() = rxPrefs.getBoolean(Keys.eh_expandFilters, false)
|
fun eh_expandFilters() = flowPrefs.getBoolean(Keys.eh_expandFilters, false)
|
||||||
|
|
||||||
fun eh_readerThreads() = rxPrefs.getInteger(Keys.eh_readerThreads, 2)
|
fun eh_readerThreads() = flowPrefs.getInt(Keys.eh_readerThreads, 2)
|
||||||
|
|
||||||
fun eh_readerInstantRetry() = rxPrefs.getBoolean(Keys.eh_readerInstantRetry, true)
|
fun eh_readerInstantRetry() = flowPrefs.getBoolean(Keys.eh_readerInstantRetry, true)
|
||||||
|
|
||||||
fun eh_utilAutoscrollInterval() = flowPrefs.getFloat(Keys.eh_utilAutoscrollInterval, 3f)
|
fun eh_utilAutoscrollInterval() = flowPrefs.getFloat(Keys.eh_utilAutoscrollInterval, 3f)
|
||||||
|
|
||||||
fun eh_cacheSize() = rxPrefs.getString(Keys.eh_cacheSize, "75")
|
fun eh_cacheSize() = flowPrefs.getString(Keys.eh_cacheSize, "75")
|
||||||
|
|
||||||
fun eh_preserveReadingPosition() = flowPrefs.getBoolean(Keys.eh_preserveReadingPosition, false)
|
fun eh_preserveReadingPosition() = flowPrefs.getBoolean(Keys.eh_preserveReadingPosition, false)
|
||||||
|
|
||||||
fun eh_autoSolveCaptchas() = rxPrefs.getBoolean(Keys.eh_autoSolveCaptchas, false)
|
fun eh_autoSolveCaptchas() = flowPrefs.getBoolean(Keys.eh_autoSolveCaptchas, false)
|
||||||
|
|
||||||
fun eh_delegateSources() = rxPrefs.getBoolean(Keys.eh_delegateSources, true)
|
fun eh_delegateSources() = flowPrefs.getBoolean(Keys.eh_delegateSources, true)
|
||||||
|
|
||||||
fun eh_lastVersionCode() = rxPrefs.getInteger("eh_last_version_code", 0)
|
fun eh_lastVersionCode() = flowPrefs.getInt("eh_last_version_code", 0)
|
||||||
|
|
||||||
fun eh_savedSearches() = rxPrefs.getStringSet("eh_saved_searches", emptySet())
|
fun eh_savedSearches() = flowPrefs.getStringSet("eh_saved_searches", emptySet())
|
||||||
|
|
||||||
fun eh_logLevel() = rxPrefs.getInteger(Keys.eh_logLevel, 0)
|
fun eh_logLevel() = flowPrefs.getInt(Keys.eh_logLevel, 0)
|
||||||
|
|
||||||
fun eh_enableSourceBlacklist() = flowPrefs.getBoolean(Keys.eh_enableSourceBlacklist, true)
|
fun eh_enableSourceBlacklist() = flowPrefs.getBoolean(Keys.eh_enableSourceBlacklist, true)
|
||||||
|
|
||||||
fun eh_autoUpdateFrequency() = rxPrefs.getInteger(Keys.eh_autoUpdateFrequency, 1)
|
fun eh_autoUpdateFrequency() = flowPrefs.getInt(Keys.eh_autoUpdateFrequency, 1)
|
||||||
|
|
||||||
fun eh_autoUpdateRequirements() = prefs.getStringSet(Keys.eh_autoUpdateRestrictions, emptySet())
|
fun eh_autoUpdateRequirements() = prefs.getStringSet(Keys.eh_autoUpdateRestrictions, emptySet())
|
||||||
|
|
||||||
fun eh_autoUpdateStats() = rxPrefs.getString(Keys.eh_autoUpdateStats, "")
|
fun eh_autoUpdateStats() = flowPrefs.getString(Keys.eh_autoUpdateStats, "")
|
||||||
|
|
||||||
fun eh_aggressivePageLoading() = rxPrefs.getBoolean(Keys.eh_aggressivePageLoading, false)
|
fun eh_aggressivePageLoading() = flowPrefs.getBoolean(Keys.eh_aggressivePageLoading, false)
|
||||||
|
|
||||||
fun eh_hl_useHighQualityThumbs() = rxPrefs.getBoolean(Keys.eh_hl_useHighQualityThumbs, false)
|
fun eh_hl_useHighQualityThumbs() = flowPrefs.getBoolean(Keys.eh_hl_useHighQualityThumbs, false)
|
||||||
|
|
||||||
fun eh_preload_size() = rxPrefs.getInteger(Keys.eh_preload_size, 4)
|
fun eh_preload_size() = flowPrefs.getInt(Keys.eh_preload_size, 4)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||||||
import com.elvishew.xlog.XLog
|
import com.elvishew.xlog.XLog
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
@ -28,6 +27,11 @@ import exh.source.BlacklistedSources
|
|||||||
import exh.source.DelegatedHttpSource
|
import exh.source.DelegatedHttpSource
|
||||||
import exh.source.EnhancedHttpSource
|
import exh.source.EnhancedHttpSource
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
@ -39,22 +43,15 @@ open class SourceManager(private val context: Context) {
|
|||||||
|
|
||||||
private val stubSourcesMap = mutableMapOf<Long, StubSource>()
|
private val stubSourcesMap = mutableMapOf<Long, StubSource>()
|
||||||
|
|
||||||
|
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
createInternalSources().forEach { registerSource(it) }
|
createInternalSources().forEach { registerSource(it) }
|
||||||
|
|
||||||
// Recreate sources when they change
|
// Recreate sources when they change
|
||||||
val prefEntries = arrayOf(
|
prefs.enableExhentai().asFlow().onEach {
|
||||||
prefs.enableExhentai(),
|
|
||||||
prefs.imageQuality(),
|
|
||||||
prefs.useHentaiAtHome(),
|
|
||||||
prefs.useJapaneseTitle(),
|
|
||||||
prefs.ehSearchSize(),
|
|
||||||
prefs.thumbnailRows()
|
|
||||||
).map { it.asObservable() }
|
|
||||||
|
|
||||||
Observable.merge(prefEntries).skip(prefEntries.size - 1).subscribe {
|
|
||||||
createEHSources().forEach { registerSource(it) }
|
createEHSources().forEach { registerSource(it) }
|
||||||
}
|
}.launchIn(scope)
|
||||||
|
|
||||||
registerSource(MergedSource())
|
registerSource(MergedSource())
|
||||||
}
|
}
|
||||||
@ -112,7 +109,7 @@ open class SourceManager(private val context: Context) {
|
|||||||
val exSrcs = mutableListOf<HttpSource>(
|
val exSrcs = mutableListOf<HttpSource>(
|
||||||
EHentai(EH_SOURCE_ID, false, context)
|
EHentai(EH_SOURCE_ID, false, context)
|
||||||
)
|
)
|
||||||
if (prefs.enableExhentai().getOrDefault()) {
|
if (prefs.enableExhentai().get()) {
|
||||||
exSrcs += EHentai(EXH_SOURCE_ID, true, context)
|
exSrcs += EHentai(EXH_SOURCE_ID, true, context)
|
||||||
}
|
}
|
||||||
exSrcs += PervEden(PERV_EDEN_EN_SOURCE_ID, PervEdenLang.en)
|
exSrcs += PervEden(PERV_EDEN_EN_SOURCE_ID, PervEdenLang.en)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.source.online
|
package eu.kanade.tachiyomi.source.online
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
@ -377,7 +376,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
|
|
||||||
// EXH -->
|
// EXH -->
|
||||||
private var delegate: DelegatedHttpSource? = null
|
private var delegate: DelegatedHttpSource? = null
|
||||||
get() = if (Injekt.get<PreferencesHelper>().eh_delegateSources().getOrDefault()) {
|
get() = if (Injekt.get<PreferencesHelper>().eh_delegateSources().get()) {
|
||||||
field
|
field
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
@ -14,7 +14,6 @@ import com.google.gson.JsonObject
|
|||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
@ -73,7 +72,7 @@ class EHentai(
|
|||||||
override val metaClass = EHentaiSearchMetadata::class
|
override val metaClass = EHentaiSearchMetadata::class
|
||||||
|
|
||||||
val schema: String
|
val schema: String
|
||||||
get() = if (prefs.secureEXH().getOrDefault()) {
|
get() = if (prefs.secureEXH().get()) {
|
||||||
"https"
|
"https"
|
||||||
} else {
|
} else {
|
||||||
"http"
|
"http"
|
||||||
@ -567,23 +566,23 @@ class EHentai(
|
|||||||
|
|
||||||
fun rawCookies(sp: Int): Map<String, String> {
|
fun rawCookies(sp: Int): Map<String, String> {
|
||||||
val cookies: MutableMap<String, String> = mutableMapOf()
|
val cookies: MutableMap<String, String> = mutableMapOf()
|
||||||
if (prefs.enableExhentai().getOrDefault()) {
|
if (prefs.enableExhentai().get()) {
|
||||||
cookies[LoginController.MEMBER_ID_COOKIE] = prefs.memberIdVal().get()!!
|
cookies[LoginController.MEMBER_ID_COOKIE] = prefs.memberIdVal().get()!!
|
||||||
cookies[LoginController.PASS_HASH_COOKIE] = prefs.passHashVal().get()!!
|
cookies[LoginController.PASS_HASH_COOKIE] = prefs.passHashVal().get()!!
|
||||||
cookies[LoginController.IGNEOUS_COOKIE] = prefs.igneousVal().get()!!
|
cookies[LoginController.IGNEOUS_COOKIE] = prefs.igneousVal().get()!!
|
||||||
cookies["sp"] = sp.toString()
|
cookies["sp"] = sp.toString()
|
||||||
|
|
||||||
val sessionKey = prefs.eh_settingsKey().getOrDefault()
|
val sessionKey = prefs.eh_settingsKey().get()
|
||||||
if (sessionKey != null) {
|
if (sessionKey != null) {
|
||||||
cookies["sk"] = sessionKey
|
cookies["sk"] = sessionKey
|
||||||
}
|
}
|
||||||
|
|
||||||
val sessionCookie = prefs.eh_sessionCookie().getOrDefault()
|
val sessionCookie = prefs.eh_sessionCookie().get()
|
||||||
if (sessionCookie != null) {
|
if (sessionCookie != null) {
|
||||||
cookies["s"] = sessionCookie
|
cookies["s"] = sessionCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
val hathPerksCookie = prefs.eh_hathPerksCookies().getOrDefault()
|
val hathPerksCookie = prefs.eh_hathPerksCookies().get()
|
||||||
if (hathPerksCookie != null) {
|
if (hathPerksCookie != null) {
|
||||||
cookies["hath_perks"] = hathPerksCookie
|
cookies["hath_perks"] = hathPerksCookie
|
||||||
}
|
}
|
||||||
@ -598,7 +597,7 @@ class EHentai(
|
|||||||
return cookies
|
return cookies
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cookiesHeader(sp: Int = spPref().getOrDefault()) = buildCookies(rawCookies(sp))
|
fun cookiesHeader(sp: Int = spPref().get()) = buildCookies(rawCookies(sp))
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
override fun headersBuilder() = super.headersBuilder().add("Cookie", cookiesHeader())
|
override fun headersBuilder() = super.headersBuilder().add("Cookie", cookiesHeader())
|
||||||
|
@ -7,7 +7,6 @@ import com.github.salomonbrys.kotson.get
|
|||||||
import com.github.salomonbrys.kotson.string
|
import com.github.salomonbrys.kotson.string
|
||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
@ -303,7 +302,7 @@ class Hitomi : HttpSource(), LewdSource<HitomiSearchMetadata, Document>, UrlImpo
|
|||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
val titleElement = doc.selectFirst("h1")
|
val titleElement = doc.selectFirst("h1")
|
||||||
title = titleElement.text()
|
title = titleElement.text()
|
||||||
thumbnail_url = "https:" + if (prefs.eh_hl_useHighQualityThumbs().getOrDefault()) {
|
thumbnail_url = "https:" + if (prefs.eh_hl_useHighQualityThumbs().get()) {
|
||||||
doc.selectFirst("img").attr("data-srcset").substringBefore(' ')
|
doc.selectFirst("img").attr("data-srcset").substringBefore(' ')
|
||||||
} else {
|
} else {
|
||||||
doc.selectFirst("img").attr("data-src")
|
doc.selectFirst("img").attr("data-src")
|
||||||
|
@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
@ -413,7 +412,7 @@ open class BrowseSourcePresenter(
|
|||||||
// EXH -->
|
// EXH -->
|
||||||
private val filterSerializer = FilterSerializer()
|
private val filterSerializer = FilterSerializer()
|
||||||
fun saveSearches(searches: List<EXHSavedSearch>) {
|
fun saveSearches(searches: List<EXHSavedSearch>) {
|
||||||
val otherSerialized = prefs.eh_savedSearches().getOrDefault().filter {
|
val otherSerialized = prefs.eh_savedSearches().get().filter {
|
||||||
!it.startsWith("${source.id}:")
|
!it.startsWith("${source.id}:")
|
||||||
}
|
}
|
||||||
val newSerialized = searches.map {
|
val newSerialized = searches.map {
|
||||||
@ -427,7 +426,7 @@ open class BrowseSourcePresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun loadSearches(): List<EXHSavedSearch> {
|
fun loadSearches(): List<EXHSavedSearch> {
|
||||||
val loaded = prefs.eh_savedSearches().getOrDefault()
|
val loaded = prefs.eh_savedSearches().get()
|
||||||
return loaded.map {
|
return loaded.map {
|
||||||
try {
|
try {
|
||||||
val id = it.substringBefore(':').toLong()
|
val id = it.substringBefore(':').toLong()
|
||||||
|
@ -11,7 +11,6 @@ import eu.davidea.flexibleadapter.items.ISectionable
|
|||||||
import eu.davidea.viewholders.ExpandableViewHolder
|
import eu.davidea.viewholders.ExpandableViewHolder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -21,7 +20,7 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
// --> EH
|
// --> EH
|
||||||
isExpanded = Injekt.get<PreferencesHelper>().eh_expandFilters().getOrDefault()
|
isExpanded = Injekt.get<PreferencesHelper>().eh_expandFilters().get()
|
||||||
// <-- EH
|
// <-- EH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import com.google.android.material.behavior.HideBottomViewOnScrollBehavior
|
|||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.databinding.MainActivityBinding
|
import eu.kanade.tachiyomi.databinding.MainActivityBinding
|
||||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||||
@ -181,7 +180,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||||||
|
|
||||||
initWhenIdle {
|
initWhenIdle {
|
||||||
// Upload settings
|
// Upload settings
|
||||||
if (preferences.enableExhentai().getOrDefault() &&
|
if (preferences.enableExhentai().get() &&
|
||||||
preferences.eh_showSettingsUploadWarning().get()
|
preferences.eh_showSettingsUploadWarning().get()
|
||||||
) {
|
) {
|
||||||
WarnConfigureDialogController.uploadSettings(router)
|
WarnConfigureDialogController.uploadSettings(router)
|
||||||
|
@ -9,11 +9,10 @@ import android.widget.RadioButton
|
|||||||
import android.widget.RadioGroup
|
import android.widget.RadioGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.f2prateek.rx.preferences.Preference
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
import com.tfcporciuncula.flow.Preference
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
@ -122,7 +121,7 @@ class MigrationBottomSheetDialog(
|
|||||||
* Binds a checkbox or switch view with a boolean preference.
|
* Binds a checkbox or switch view with a boolean preference.
|
||||||
*/
|
*/
|
||||||
private fun CompoundButton.bindToPreference(pref: Preference<Boolean>) {
|
private fun CompoundButton.bindToPreference(pref: Preference<Boolean>) {
|
||||||
isChecked = pref.getOrDefault()
|
isChecked = pref.get()
|
||||||
setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) }
|
setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +129,7 @@ class MigrationBottomSheetDialog(
|
|||||||
* Binds a radio group with a boolean preference.
|
* Binds a radio group with a boolean preference.
|
||||||
*/
|
*/
|
||||||
private fun RadioGroup.bindToPreference(pref: Preference<Boolean>) {
|
private fun RadioGroup.bindToPreference(pref: Preference<Boolean>) {
|
||||||
(getChildAt(pref.getOrDefault().toInt()) as RadioButton).isChecked = true
|
(getChildAt(pref.get().toInt()) as RadioButton).isChecked = true
|
||||||
setOnCheckedChangeListener { _, value ->
|
setOnCheckedChangeListener { _, value ->
|
||||||
val index = indexOfChild(findViewById(value))
|
val index = indexOfChild(findViewById(value))
|
||||||
pref.set(index == 1)
|
pref.set(index == 1)
|
||||||
|
@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
|
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
@ -125,8 +124,8 @@ class MigrationListController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun runMigrations(mangas: List<MigratingManga>) {
|
private suspend fun runMigrations(mangas: List<MigratingManga>) {
|
||||||
val useSourceWithMost = preferences.useSourceWithMost().getOrDefault()
|
val useSourceWithMost = preferences.useSourceWithMost().get()
|
||||||
val useSmartSearch = preferences.smartMigration().getOrDefault()
|
val useSmartSearch = preferences.smartMigration().get()
|
||||||
|
|
||||||
val sources = preferences.migrationSources().get().split("/").mapNotNull {
|
val sources = preferences.migrationSources().get().split("/").mapNotNull {
|
||||||
val value = it.toLongOrNull() ?: return
|
val value = it.toLongOrNull() ?: return
|
||||||
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.loader
|
|||||||
|
|
||||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
@ -46,11 +45,11 @@ class HttpPageLoader(
|
|||||||
*/
|
*/
|
||||||
private val subscriptions = CompositeSubscription()
|
private val subscriptions = CompositeSubscription()
|
||||||
|
|
||||||
private val preloadSize = prefs.eh_preload_size().getOrDefault()
|
private val preloadSize = prefs.eh_preload_size().get()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// EXH -->
|
// EXH -->
|
||||||
repeat(prefs.eh_readerThreads().getOrDefault()) {
|
repeat(prefs.eh_readerThreads().get()) {
|
||||||
// EXH <--
|
// EXH <--
|
||||||
subscriptions += Observable.defer { Observable.just(queue.take().page) }
|
subscriptions += Observable.defer { Observable.just(queue.take().page) }
|
||||||
.filter { it.status == Page.QUEUE }
|
.filter { it.status == Page.QUEUE }
|
||||||
@ -107,7 +106,7 @@ class HttpPageLoader(
|
|||||||
// Don't trust sources and use our own indexing
|
// Don't trust sources and use our own indexing
|
||||||
ReaderPage(index, page.url, page.imageUrl)
|
ReaderPage(index, page.url, page.imageUrl)
|
||||||
}
|
}
|
||||||
if (prefs.eh_aggressivePageLoading().getOrDefault()) {
|
if (prefs.eh_aggressivePageLoading().get()) {
|
||||||
rp.mapNotNull {
|
rp.mapNotNull {
|
||||||
if (it.status == Page.QUEUE) {
|
if (it.status == Page.QUEUE) {
|
||||||
PriorityPage(it, 0)
|
PriorityPage(it, 0)
|
||||||
@ -189,7 +188,7 @@ class HttpPageLoader(
|
|||||||
page.imageUrl = null
|
page.imageUrl = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.eh_readerInstantRetry().getOrDefault()) // EXH <--
|
if (prefs.eh_readerInstantRetry().get()) // EXH <--
|
||||||
{
|
{
|
||||||
boostPage(page)
|
boostPage(page)
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,16 +6,15 @@ import androidx.preference.PreferenceScreen
|
|||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||||
import com.f2prateek.rx.preferences.Preference
|
|
||||||
import com.github.salomonbrys.kotson.fromJson
|
import com.github.salomonbrys.kotson.fromJson
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.kizitonwose.time.Interval
|
import com.kizitonwose.time.Interval
|
||||||
import com.kizitonwose.time.days
|
import com.kizitonwose.time.days
|
||||||
import com.kizitonwose.time.hours
|
import com.kizitonwose.time.hours
|
||||||
|
import com.tfcporciuncula.flow.Preference
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||||
@ -46,10 +45,11 @@ import humanize.Humanize
|
|||||||
import java.util.Date
|
import java.util.Date
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
import kotlinx.coroutines.flow.take
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
|
||||||
import rx.schedulers.Schedulers
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,14 +62,13 @@ class SettingsEhController : SettingsController() {
|
|||||||
|
|
||||||
private fun Preference<*>.reconfigure(): Boolean {
|
private fun Preference<*>.reconfigure(): Boolean {
|
||||||
// Listen for change commit
|
// Listen for change commit
|
||||||
asObservable()
|
asFlow()
|
||||||
.skip(1) // Skip first as it is emitted immediately
|
|
||||||
.take(1) // Only listen for first commit
|
.take(1) // Only listen for first commit
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.onEach {
|
||||||
.subscribeUntilDestroy {
|
|
||||||
// Only listen for first change commit
|
// Only listen for first change commit
|
||||||
WarnConfigureDialogController.uploadSettings(router)
|
WarnConfigureDialogController.uploadSettings(router)
|
||||||
}
|
}
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
// Always return true to save changes
|
// Always return true to save changes
|
||||||
return true
|
return true
|
||||||
@ -85,12 +84,11 @@ class SettingsEhController : SettingsController() {
|
|||||||
isPersistent = false
|
isPersistent = false
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.enableExhentai()
|
preferences.enableExhentai()
|
||||||
.asObservable()
|
.asFlow()
|
||||||
.subscribeOn(Schedulers.io())
|
.onEach {
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribeUntilDestroy {
|
|
||||||
isChecked = it
|
isChecked = it
|
||||||
}
|
}
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
onChange { newVal ->
|
onChange { newVal ->
|
||||||
newVal as Boolean
|
newVal as Boolean
|
||||||
@ -243,8 +241,8 @@ class SettingsEhController : SettingsController() {
|
|||||||
entryValues = arrayOf("0", "1", "2", "3", "6", "12", "24", "48")
|
entryValues = arrayOf("0", "1", "2", "3", "6", "12", "24", "48")
|
||||||
defaultValue = "0"
|
defaultValue = "0"
|
||||||
|
|
||||||
preferences.eh_autoUpdateFrequency().asObservable()
|
preferences.eh_autoUpdateFrequency().asFlow()
|
||||||
.subscribeUntilDestroy { newVal ->
|
.onEach { newVal ->
|
||||||
summary = if (newVal == 0) {
|
summary = if (newVal == 0) {
|
||||||
"${context.getString(R.string.app_name)} will currently never check galleries in your library for updates."
|
"${context.getString(R.string.app_name)} will currently never check galleries in your library for updates."
|
||||||
} else {
|
} else {
|
||||||
@ -253,6 +251,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
" wait $newVal hour(s), check ${EHentaiUpdateWorkerConstants.UPDATES_PER_ITERATION} and so on..."
|
" wait $newVal hour(s), check ${EHentaiUpdateWorkerConstants.UPDATES_PER_ITERATION} and so on..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
val interval = (newValue as String).toInt()
|
val interval = (newValue as String).toInt()
|
||||||
@ -268,8 +267,9 @@ class SettingsEhController : SettingsController() {
|
|||||||
entryValues = arrayOf("wifi", "ac")
|
entryValues = arrayOf("wifi", "ac")
|
||||||
summaryRes = R.string.pref_library_update_restriction_summary
|
summaryRes = R.string.pref_library_update_restriction_summary
|
||||||
|
|
||||||
preferences.eh_autoUpdateFrequency().asObservable()
|
preferences.eh_autoUpdateFrequency().asFlow()
|
||||||
.subscribeUntilDestroy { isVisible = it > 0 }
|
.onEach { isVisible = it > 0 }
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
// Post to event looper to allow the preference to be updated.
|
// Post to event looper to allow the preference to be updated.
|
||||||
@ -290,7 +290,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
val updateInfo = try {
|
val updateInfo = try {
|
||||||
val stats =
|
val stats =
|
||||||
preferences.eh_autoUpdateStats().getOrDefault().nullIfBlank()?.let {
|
preferences.eh_autoUpdateStats().get().nullIfBlank()?.let {
|
||||||
gson.fromJson<EHentaiUpdaterStats>(it)
|
gson.fromJson<EHentaiUpdaterStats>(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
import exh.source.BlacklistedSources
|
import exh.source.BlacklistedSources
|
||||||
@ -33,7 +32,7 @@ object EXHMigrations {
|
|||||||
*/
|
*/
|
||||||
fun upgrade(preferences: PreferencesHelper): Boolean {
|
fun upgrade(preferences: PreferencesHelper): Boolean {
|
||||||
val context = preferences.context
|
val context = preferences.context
|
||||||
val oldVersion = preferences.eh_lastVersionCode().getOrDefault()
|
val oldVersion = preferences.eh_lastVersionCode().get()
|
||||||
try {
|
try {
|
||||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||||
// Fresh install
|
// Fresh install
|
||||||
|
@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
@ -350,7 +349,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
|
|||||||
cancelBackground(context)
|
cancelBackground(context)
|
||||||
|
|
||||||
val preferences = Injekt.get<PreferencesHelper>()
|
val preferences = Injekt.get<PreferencesHelper>()
|
||||||
val interval = prefInterval ?: preferences.eh_autoUpdateFrequency().getOrDefault()
|
val interval = prefInterval ?: preferences.eh_autoUpdateFrequency().get()
|
||||||
if (interval > 0) {
|
if (interval > 0) {
|
||||||
val restrictions = preferences.eh_autoUpdateRequirements()!!
|
val restrictions = preferences.eh_autoUpdateRequirements()!!
|
||||||
val acRestriction = "ac" in restrictions
|
val acRestriction = "ac" in restrictions
|
||||||
|
@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
@ -68,7 +67,7 @@ class FavoritesSyncHelper(val context: Context) {
|
|||||||
|
|
||||||
private fun beginSync() {
|
private fun beginSync() {
|
||||||
// Check if logged in
|
// Check if logged in
|
||||||
if (!prefs.enableExhentai().getOrDefault()) {
|
if (!prefs.enableExhentai().get()) {
|
||||||
status.onNext(FavoritesSyncStatus.Error("Please log in!"))
|
status.onNext(FavoritesSyncStatus.Error("Please log in!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -130,7 +129,7 @@ class FavoritesSyncHelper(val context: Context) {
|
|||||||
db.inTransaction {
|
db.inTransaction {
|
||||||
status.onNext(FavoritesSyncStatus.Processing("Calculating remote changes"))
|
status.onNext(FavoritesSyncStatus.Processing("Calculating remote changes"))
|
||||||
val remoteChanges = storage.getChangedRemoteEntries(realm, favorites.first)
|
val remoteChanges = storage.getChangedRemoteEntries(realm, favorites.first)
|
||||||
val localChanges = if (prefs.eh_readOnlySync().getOrDefault()) {
|
val localChanges = if (prefs.eh_readOnlySync().get()) {
|
||||||
null // Do not build local changes if they are not going to be applied
|
null // Do not build local changes if they are not going to be applied
|
||||||
} else {
|
} else {
|
||||||
status.onNext(FavoritesSyncStatus.Processing("Calculating local changes"))
|
status.onNext(FavoritesSyncStatus.Processing("Calculating local changes"))
|
||||||
@ -248,7 +247,7 @@ class FavoritesSyncHelper(val context: Context) {
|
|||||||
if (!explicitlyRetryExhRequest(10, request)) {
|
if (!explicitlyRetryExhRequest(10, request)) {
|
||||||
val errorString = "Unable to add gallery to remote server: '${gallery.title}' (GID: ${gallery.gid})!"
|
val errorString = "Unable to add gallery to remote server: '${gallery.title}' (GID: ${gallery.gid})!"
|
||||||
|
|
||||||
if (prefs.eh_lenientSync().getOrDefault()) {
|
if (prefs.eh_lenientSync().get()) {
|
||||||
errorList += errorString
|
errorList += errorString
|
||||||
} else {
|
} else {
|
||||||
status.onNext(FavoritesSyncStatus.Error(errorString))
|
status.onNext(FavoritesSyncStatus.Error(errorString))
|
||||||
@ -298,7 +297,7 @@ class FavoritesSyncHelper(val context: Context) {
|
|||||||
if (!explicitlyRetryExhRequest(10, request)) {
|
if (!explicitlyRetryExhRequest(10, request)) {
|
||||||
val errorString = "Unable to delete galleries from the remote servers!"
|
val errorString = "Unable to delete galleries from the remote servers!"
|
||||||
|
|
||||||
if (prefs.eh_lenientSync().getOrDefault()) {
|
if (prefs.eh_lenientSync().get()) {
|
||||||
errorList += errorString
|
errorList += errorString
|
||||||
} else {
|
} else {
|
||||||
status.onNext(FavoritesSyncStatus.Error(errorString))
|
status.onNext(FavoritesSyncStatus.Error(errorString))
|
||||||
@ -386,7 +385,7 @@ class FavoritesSyncHelper(val context: Context) {
|
|||||||
is GalleryAddEvent.Fail.UnknownType -> "'${it.title}' (${result.galleryUrl}) is not a valid gallery!"
|
is GalleryAddEvent.Fail.UnknownType -> "'${it.title}' (${result.galleryUrl}) is not a valid gallery!"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.eh_lenientSync().getOrDefault()) {
|
if (prefs.eh_lenientSync().get()) {
|
||||||
errorList += errorString
|
errorList += errorString
|
||||||
} else {
|
} else {
|
||||||
status.onNext(FavoritesSyncStatus.Error(errorString))
|
status.onNext(FavoritesSyncStatus.Error(errorString))
|
||||||
|
@ -2,7 +2,6 @@ package exh.metadata.metadata
|
|||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import exh.metadata.EX_DATE_FORMAT
|
import exh.metadata.EX_DATE_FORMAT
|
||||||
import exh.metadata.ONGOING_SUFFIX
|
import exh.metadata.ONGOING_SUFFIX
|
||||||
@ -50,7 +49,7 @@ class EHentaiSearchMetadata : RaisedSearchMetadata() {
|
|||||||
thumbnailUrl?.let { manga.thumbnail_url = it }
|
thumbnailUrl?.let { manga.thumbnail_url = it }
|
||||||
|
|
||||||
// No title bug?
|
// No title bug?
|
||||||
val titleObj = if (Injekt.get<PreferencesHelper>().useJapaneseTitle().getOrDefault()) {
|
val titleObj = if (Injekt.get<PreferencesHelper>().useJapaneseTitle().get()) {
|
||||||
altTitle ?: title
|
altTitle ?: title
|
||||||
} else {
|
} else {
|
||||||
title
|
title
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package exh.metadata.metadata
|
package exh.metadata.metadata
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import exh.metadata.EX_DATE_FORMAT
|
import exh.metadata.EX_DATE_FORMAT
|
||||||
import exh.metadata.ONGOING_SUFFIX
|
import exh.metadata.ONGOING_SUFFIX
|
||||||
@ -42,7 +41,7 @@ class NHentaiSearchMetadata : RaisedSearchMetadata() {
|
|||||||
nhId?.let { manga.url = nhIdToPath(it) }
|
nhId?.let { manga.url = nhIdToPath(it) }
|
||||||
|
|
||||||
if (mediaId != null) {
|
if (mediaId != null) {
|
||||||
val hqThumbs = Injekt.get<PreferencesHelper>().eh_nh_useHighQualityThumbs().getOrDefault()
|
val hqThumbs = Injekt.get<PreferencesHelper>().eh_nh_useHighQualityThumbs().get()
|
||||||
typeToExtension(if (hqThumbs) coverImageType else thumbnailImageType)?.let {
|
typeToExtension(if (hqThumbs) coverImageType else thumbnailImageType)?.let {
|
||||||
manga.thumbnail_url = "https://t.nhentai.net/galleries/$mediaId/${if (hqThumbs) {
|
manga.thumbnail_url = "https://t.nhentai.net/galleries/$mediaId/${if (hqThumbs) {
|
||||||
"cover"
|
"cover"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package exh.source
|
package exh.source
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
@ -217,7 +216,7 @@ class EnhancedHttpSource(
|
|||||||
override fun getFilterList() = source().getFilterList()
|
override fun getFilterList() = source().getFilterList()
|
||||||
|
|
||||||
private fun source(): HttpSource {
|
private fun source(): HttpSource {
|
||||||
return if (prefs.eh_delegateSources().getOrDefault()) {
|
return if (prefs.eh_delegateSources().get()) {
|
||||||
enchancedSource
|
enchancedSource
|
||||||
} else {
|
} else {
|
||||||
originalSource
|
originalSource
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package exh.uconfig
|
package exh.uconfig
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ class EhUConfigBuilder {
|
|||||||
|
|
||||||
configItems += when (
|
configItems += when (
|
||||||
prefs.imageQuality()
|
prefs.imageQuality()
|
||||||
.getOrDefault()
|
.get()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
) {
|
) {
|
||||||
"ovrs_2400" -> Entry.ImageSize.`2400`
|
"ovrs_2400" -> Entry.ImageSize.`2400`
|
||||||
@ -25,19 +24,19 @@ class EhUConfigBuilder {
|
|||||||
else -> Entry.ImageSize.AUTO
|
else -> Entry.ImageSize.AUTO
|
||||||
}
|
}
|
||||||
|
|
||||||
configItems += if (prefs.useHentaiAtHome().getOrDefault()) {
|
configItems += if (prefs.useHentaiAtHome().get()) {
|
||||||
Entry.UseHentaiAtHome.YES
|
Entry.UseHentaiAtHome.YES
|
||||||
} else {
|
} else {
|
||||||
Entry.UseHentaiAtHome.NO
|
Entry.UseHentaiAtHome.NO
|
||||||
}
|
}
|
||||||
|
|
||||||
configItems += if (prefs.useJapaneseTitle().getOrDefault()) {
|
configItems += if (prefs.useJapaneseTitle().get()) {
|
||||||
Entry.TitleDisplayLanguage.JAPANESE
|
Entry.TitleDisplayLanguage.JAPANESE
|
||||||
} else {
|
} else {
|
||||||
Entry.TitleDisplayLanguage.DEFAULT
|
Entry.TitleDisplayLanguage.DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
configItems += if (prefs.eh_useOriginalImages().getOrDefault()) {
|
configItems += if (prefs.eh_useOriginalImages().get()) {
|
||||||
Entry.UseOriginalImages.YES
|
Entry.UseOriginalImages.YES
|
||||||
} else {
|
} else {
|
||||||
Entry.UseOriginalImages.NO
|
Entry.UseOriginalImages.NO
|
||||||
|
@ -16,7 +16,6 @@ import com.github.salomonbrys.kotson.get
|
|||||||
import com.github.salomonbrys.kotson.string
|
import com.github.salomonbrys.kotson.string
|
||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
@ -121,7 +120,7 @@ class BrowserActionActivity : AppCompatActivity() {
|
|||||||
// Wait for both inner scripts to be loaded
|
// Wait for both inner scripts to be loaded
|
||||||
if (loadedInners >= 2) {
|
if (loadedInners >= 2) {
|
||||||
// Attempt to autosolve captcha
|
// Attempt to autosolve captcha
|
||||||
if (preferencesHelper.eh_autoSolveCaptchas().getOrDefault()) {
|
if (preferencesHelper.eh_autoSolveCaptchas().get()) {
|
||||||
webview.post {
|
webview.post {
|
||||||
// 10 seconds to auto-solve captcha
|
// 10 seconds to auto-solve captcha
|
||||||
strictValidationStartTime = System.currentTimeMillis() + 1000 * 10
|
strictValidationStartTime = System.currentTimeMillis() + 1000 * 10
|
||||||
@ -140,7 +139,7 @@ class BrowserActionActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
webview.webViewClient = if (actionName == null && preferencesHelper.eh_autoSolveCaptchas().getOrDefault()) {
|
webview.webViewClient = if (actionName == null && preferencesHelper.eh_autoSolveCaptchas().get()) {
|
||||||
// Fetch auto-solve credentials early for speed
|
// Fetch auto-solve credentials early for speed
|
||||||
credentialsObservable = httpClient.newCall(
|
credentialsObservable = httpClient.newCall(
|
||||||
Request.Builder()
|
Request.Builder()
|
||||||
|
@ -161,9 +161,9 @@ class LoginController : NucleusController<EhActivityLoginBinding, LoginPresenter
|
|||||||
if (memberId == null || passHash == null || igneous == null) return false
|
if (memberId == null || passHash == null || igneous == null) return false
|
||||||
|
|
||||||
// Update prefs
|
// Update prefs
|
||||||
preferenceManager.memberIdVal().set(memberId)
|
preferenceManager.memberIdVal().set(memberId!!)
|
||||||
preferenceManager.passHashVal().set(passHash)
|
preferenceManager.passHashVal().set(passHash!!)
|
||||||
preferenceManager.igneousVal().set(igneous)
|
preferenceManager.igneousVal().set(igneous!!)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user