Minor refactors

This commit is contained in:
Jobobby04
2025-05-15 13:38:03 -04:00
parent 129841d5c2
commit 9b6c5effc9
44 changed files with 316 additions and 378 deletions
@@ -8,19 +8,19 @@ import exh.log.maybeInjectEHLogger
import exh.log.xLogD
import exh.source.EH_SOURCE_ID
import exh.source.EXH_SOURCE_ID
import exh.source.ExhPreferences
import okhttp3.FormBody
import okhttp3.OkHttpClient
import okhttp3.Request
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.domain.UnsortedPreferences
import tachiyomi.domain.source.service.SourceManager
import tachiyomi.i18n.sy.SYMR
import uy.kohesive.injekt.injectLazy
import java.util.Locale
class EHConfigurator(val context: Context) {
private val prefs: UnsortedPreferences by injectLazy()
private val sources: SourceManager by injectLazy()
private val exhPreferences: ExhPreferences by injectLazy()
private val sourceManager: SourceManager by injectLazy()
private val configuratorClient = OkHttpClient.Builder()
.maybeInjectEHLogger()
@@ -52,8 +52,8 @@ class EHConfigurator(val context: Context) {
private val EHentai.uconfigUrl get() = baseUrl + UCONFIG_URL
suspend fun configureAll() {
val ehSource = sources.get(EH_SOURCE_ID) as EHentai
val exhSource = sources.get(EXH_SOURCE_ID) as EHentai
val ehSource = sourceManager.get(EH_SOURCE_ID) as EHentai
val exhSource = sourceManager.get(EXH_SOURCE_ID) as EHentai
// Get hath perks
val perksPage = configuratorClient.newCall(
@@ -146,13 +146,13 @@ class EHConfigurator(val context: Context) {
}?.removePrefix("hath_perks=")?.substringBefore(';')
if (keyCookie != null) {
prefs.exhSettingsKey().set(keyCookie)
exhPreferences.exhSettingsKey().set(keyCookie)
}
if (sessionCookie != null) {
prefs.exhSessionCookie().set(sessionCookie)
exhPreferences.exhSessionCookie().set(sessionCookie)
}
if (hathPerksCookie != null) {
prefs.exhHathPerksCookies().set(hathPerksCookie)
exhPreferences.exhHathPerksCookies().set(hathPerksCookie)
}
}
@@ -1,18 +1,18 @@
package exh.uconfig
import exh.source.ExhPreferences
import okhttp3.FormBody
import tachiyomi.domain.UnsortedPreferences
import uy.kohesive.injekt.injectLazy
import java.util.Locale
class EhUConfigBuilder {
private val preferences: UnsortedPreferences by injectLazy()
private val exhPreferences: ExhPreferences by injectLazy()
fun build(hathPerks: EHHathPerksResponse): FormBody {
val configItems = mutableListOf<ConfigItem>()
configItems += when (
preferences.imageQuality()
exhPreferences.imageQuality()
.get()
.lowercase(Locale.getDefault())
) {
@@ -25,19 +25,19 @@ class EhUConfigBuilder {
else -> Entry.ImageSize.AUTO
}
configItems += when (preferences.useHentaiAtHome().get()) {
configItems += when (exhPreferences.useHentaiAtHome().get()) {
2 -> Entry.UseHentaiAtHome.NO
1 -> Entry.UseHentaiAtHome.DEFAULTONLY
else -> Entry.UseHentaiAtHome.ANY
}
configItems += if (preferences.useJapaneseTitle().get()) {
configItems += if (exhPreferences.useJapaneseTitle().get()) {
Entry.TitleDisplayLanguage.JAPANESE
} else {
Entry.TitleDisplayLanguage.DEFAULT
}
configItems += if (preferences.exhUseOriginalImages().get()) {
configItems += if (exhPreferences.exhUseOriginalImages().get()) {
Entry.UseOriginalImages.YES
} else {
Entry.UseOriginalImages.NO
@@ -61,13 +61,13 @@ class EhUConfigBuilder {
configItems += Entry.UseMPV()
configItems += Entry.ShowPopularRightNowPane()
configItems += Entry.TagFilteringThreshold(preferences.ehTagFilterValue().get())
configItems += Entry.TagWatchingThreshold(preferences.ehTagWatchingValue().get())
configItems += Entry.TagFilteringThreshold(exhPreferences.ehTagFilterValue().get())
configItems += Entry.TagWatchingThreshold(exhPreferences.ehTagWatchingValue().get())
configItems += Entry.LanguageSystem().getLanguages(preferences.exhSettingsLanguages().get().split("\n"))
configItems += Entry.LanguageSystem().getLanguages(exhPreferences.exhSettingsLanguages().get().split("\n"))
configItems += Entry.Categories().categoryConfigs(
preferences.exhEnabledCategories().get().split(",").map {
exhPreferences.exhEnabledCategories().get().split(",").map {
it.toBoolean()
},
)