Minor refactors
This commit is contained in:
@@ -13,7 +13,7 @@ import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
import tachiyomi.domain.history.interactor.GetHistoryByMangaId
|
||||
import tachiyomi.domain.history.interactor.GetHistory
|
||||
import tachiyomi.domain.history.interactor.RemoveHistory
|
||||
import tachiyomi.domain.history.interactor.UpsertHistory
|
||||
import tachiyomi.domain.history.model.History
|
||||
@@ -43,7 +43,7 @@ class EHentaiUpdateHelper(context: Context) {
|
||||
private val chapterRepository: ChapterRepository by injectLazy()
|
||||
private val upsertHistory: UpsertHistory by injectLazy()
|
||||
private val removeHistory: RemoveHistory by injectLazy()
|
||||
private val getHistoryByMangaId: GetHistoryByMangaId by injectLazy()
|
||||
private val getHistoryByMangaId: GetHistory by injectLazy()
|
||||
private val insertFavoriteEntryAlternative: InsertFavoriteEntryAlternative by injectLazy()
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,14 +27,13 @@ import exh.debug.DebugToggles
|
||||
import exh.eh.EHentaiUpdateWorkerConstants.UPDATES_PER_ITERATION
|
||||
import exh.log.xLog
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.source.ExhPreferences
|
||||
import exh.util.cancellable
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import tachiyomi.core.common.preference.getAndSet
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
@@ -53,7 +52,7 @@ import kotlin.time.Duration.Companion.days
|
||||
|
||||
class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerParameters) :
|
||||
CoroutineWorker(context, workerParams) {
|
||||
private val preferences: UnsortedPreferences by injectLazy()
|
||||
private val exhPreferences: ExhPreferences by injectLazy()
|
||||
private val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
private val updateHelper: EHentaiUpdateHelper by injectLazy()
|
||||
@@ -70,7 +69,7 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
return try {
|
||||
if (requiresWifiConnection(preferences) && !context.isConnectedToWifi()) {
|
||||
if (requiresWifiConnection(exhPreferences) && !context.isConnectedToWifi()) {
|
||||
Result.success() // retry again later
|
||||
} else {
|
||||
setForegroundSafely()
|
||||
@@ -215,7 +214,7 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
updatedThisIteration++
|
||||
}
|
||||
} finally {
|
||||
preferences.exhAutoUpdateStats().set(
|
||||
exhPreferences.exhAutoUpdateStats().set(
|
||||
Json.encodeToString(
|
||||
EHentaiUpdaterStats(
|
||||
startTime,
|
||||
@@ -279,10 +278,10 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
}
|
||||
|
||||
fun scheduleBackground(context: Context, prefInterval: Int? = null, prefRestrictions: Set<String>? = null) {
|
||||
val preferences = Injekt.get<UnsortedPreferences>()
|
||||
val interval = prefInterval ?: preferences.exhAutoUpdateFrequency().get()
|
||||
val exhPreferences = Injekt.get<ExhPreferences>()
|
||||
val interval = prefInterval ?: exhPreferences.exhAutoUpdateFrequency().get()
|
||||
if (interval > 0) {
|
||||
val restrictions = prefRestrictions ?: preferences.exhAutoUpdateRequirements().get()
|
||||
val restrictions = prefRestrictions ?: exhPreferences.exhAutoUpdateRequirements().get()
|
||||
val acRestriction = DEVICE_CHARGING in restrictions
|
||||
|
||||
val constraints = Constraints.Builder()
|
||||
@@ -312,8 +311,8 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
|
||||
}
|
||||
}
|
||||
|
||||
fun requiresWifiConnection(preferences: UnsortedPreferences): Boolean {
|
||||
val restrictions = preferences.exhAutoUpdateRequirements().get()
|
||||
fun requiresWifiConnection(exhPreferences: ExhPreferences): Boolean {
|
||||
val restrictions = exhPreferences.exhAutoUpdateRequirements().get()
|
||||
return DEVICE_ONLY_ON_WIFI in restrictions
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import exh.eh.EHentaiUpdateWorker
|
||||
import exh.log.xLog
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.ExhPreferences
|
||||
import exh.source.isEhBasedManga
|
||||
import exh.util.ThrottleManager
|
||||
import exh.util.createPartialWakeLock
|
||||
@@ -29,7 +30,6 @@ import okhttp3.Request
|
||||
import tachiyomi.core.common.i18n.stringResource
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.core.common.util.lang.withUIContext
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.category.interactor.CreateCategoryWithName
|
||||
import tachiyomi.domain.category.interactor.GetCategories
|
||||
import tachiyomi.domain.category.interactor.SetMangaCategories
|
||||
@@ -57,7 +57,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
private val createCategoryWithName: CreateCategoryWithName by injectLazy()
|
||||
private val updateCategory: UpdateCategory by injectLazy()
|
||||
|
||||
private val prefs: UnsortedPreferences by injectLazy()
|
||||
private val exhPreferences: ExhPreferences by injectLazy()
|
||||
|
||||
private val exh by lazy {
|
||||
Injekt.get<SourceManager>().get(EXH_SOURCE_ID) as? EHentai
|
||||
@@ -90,7 +90,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
|
||||
private suspend fun beginSync() {
|
||||
// Check if logged in
|
||||
if (!prefs.enableExhentai().get()) {
|
||||
if (!exhPreferences.enableExhentai().get()) {
|
||||
status.value = FavoritesSyncStatus.SyncError.NotLoggedInSyncError
|
||||
return
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
|
||||
status.value = FavoritesSyncStatus.Processing.CalculatingRemoteChanges
|
||||
val remoteChanges = storage.getChangedRemoteEntries(favorites.first)
|
||||
val localChanges = if (prefs.exhReadOnlySync().get()) {
|
||||
val localChanges = if (exhPreferences.exhReadOnlySync().get()) {
|
||||
null // Do not build local changes if they are not going to be applied
|
||||
} else {
|
||||
status.value = FavoritesSyncStatus.Processing.CalculatingLocalChanges
|
||||
@@ -238,7 +238,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
gallery.gid,
|
||||
)
|
||||
|
||||
if (prefs.exhLenientSync().get()) {
|
||||
if (exhPreferences.exhLenientSync().get()) {
|
||||
errorList += error
|
||||
} else {
|
||||
status.value = error
|
||||
@@ -289,7 +289,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
)
|
||||
|
||||
if (!explicitlyRetryExhRequest(10, request)) {
|
||||
if (prefs.exhLenientSync().get()) {
|
||||
if (exhPreferences.exhLenientSync().get()) {
|
||||
errorList += FavoritesSyncStatus.SyncError.GallerySyncError.UnableToDeleteFromRemote
|
||||
} else {
|
||||
status.value = FavoritesSyncStatus.SyncError.GallerySyncError.UnableToDeleteFromRemote
|
||||
@@ -392,7 +392,7 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
)
|
||||
}
|
||||
|
||||
if (prefs.exhLenientSync().get()) {
|
||||
if (exhPreferences.exhLenientSync().get()) {
|
||||
errorList += error
|
||||
} else {
|
||||
status.value = error
|
||||
|
||||
@@ -16,14 +16,16 @@ class MangaDexLoginActivity : BaseOAuthLoginActivity() {
|
||||
val code = data?.getQueryParameter("code")
|
||||
if (code != null) {
|
||||
lifecycleScope.launchIO {
|
||||
Injekt.get<SourceManager>().isInitialized.first { it }
|
||||
MdUtil.getEnabledMangaDex(Injekt.get())?.login(code)
|
||||
val sourceManager = Injekt.get<SourceManager>()
|
||||
sourceManager.isInitialized.first { it }
|
||||
MdUtil.getEnabledMangaDex(sourceManager = sourceManager)?.login(code)
|
||||
returnToSettings()
|
||||
}
|
||||
} else {
|
||||
lifecycleScope.launchIO {
|
||||
Injekt.get<SourceManager>().isInitialized.first { it }
|
||||
MdUtil.getEnabledMangaDex(Injekt.get())?.logout()
|
||||
val sourceManager = Injekt.get<SourceManager>()
|
||||
sourceManager.isInitialized.first { it }
|
||||
MdUtil.getEnabledMangaDex(sourceManager = sourceManager)?.logout()
|
||||
returnToSettings()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.browse.BrowseSourceContent
|
||||
import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar
|
||||
import eu.kanade.presentation.browse.components.RemoveMangaDialog
|
||||
@@ -26,7 +27,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||
import exh.ui.ifSourcesLoaded
|
||||
import mihon.presentation.core.util.collectAsLazyPagingItems
|
||||
import tachiyomi.core.common.util.lang.launchIO
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.i18n.sy.SYMR
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
@@ -109,7 +109,7 @@ class MangaDexFollowsScreen(private val sourceId: Long) : Screen() {
|
||||
onOpenManga = { navigator.push(MangaScreen(it.id)) },
|
||||
onMigrate = {
|
||||
PreMigrationScreen.navigateToMigration(
|
||||
Injekt.get<UnsortedPreferences>().skipPreMigration().get(),
|
||||
Injekt.get<SourcePreferences>().skipPreMigration().get(),
|
||||
navigator,
|
||||
it.id,
|
||||
dialog.manga.id,
|
||||
|
||||
@@ -17,7 +17,6 @@ import exh.source.getMainSource
|
||||
import exh.util.dropBlank
|
||||
import exh.util.floor
|
||||
import exh.util.nullIfZero
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
@@ -26,7 +25,6 @@ import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import org.jsoup.parser.Parser
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@@ -232,9 +230,9 @@ class MdUtil {
|
||||
return codeVerifier ?: PkceUtil.generateCodeVerifier().also { codeVerifier = it }
|
||||
}
|
||||
|
||||
fun getEnabledMangaDex(preferences: UnsortedPreferences, sourcePreferences: SourcePreferences = Injekt.get(), sourceManager: SourceManager = Injekt.get()): MangaDex? {
|
||||
fun getEnabledMangaDex(sourcePreferences: SourcePreferences = Injekt.get(), sourceManager: SourceManager = Injekt.get()): MangaDex? {
|
||||
return getEnabledMangaDexs(sourcePreferences, sourceManager).let { mangadexs ->
|
||||
preferences.preferredMangaDexId().get().toLongOrNull()?.nullIfZero()
|
||||
sourcePreferences.preferredMangaDexId().get().toLongOrNull()?.nullIfZero()
|
||||
?.let { preferredMangaDexId ->
|
||||
mangadexs.firstOrNull { it.id == preferredMangaDexId }
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.components.AdaptiveSheet
|
||||
import eu.kanade.tachiyomi.databinding.RecommendationSearchBottomSheetBinding
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@Composable
|
||||
@@ -30,7 +30,7 @@ fun RecommendationSearchBottomSheetDialog(
|
||||
}
|
||||
|
||||
class RecommendationSearchBottomSheetDialogState(private val onSearchRequest: () -> Unit) {
|
||||
private val preferences: UnsortedPreferences by injectLazy()
|
||||
private val preferences: SourcePreferences by injectLazy()
|
||||
|
||||
fun initPreferences(binding: RecommendationSearchBottomSheetBinding) {
|
||||
val flags = preferences.recommendationSearchFlags().get()
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.os.PowerManager
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.net.toUri
|
||||
import eu.kanade.domain.manga.model.toSManga
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import exh.log.xLog
|
||||
@@ -27,7 +28,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import mihon.domain.manga.model.toDomainManga
|
||||
import tachiyomi.data.source.NoResultsException
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.interactor.GetLibraryManga
|
||||
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
||||
@@ -47,7 +47,7 @@ class RecommendationSearchHelper(val context: Context) {
|
||||
private val getTracks: GetTracks by injectLazy()
|
||||
private val networkToLocalManga: NetworkToLocalManga by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
private val prefs: UnsortedPreferences by injectLazy()
|
||||
private val preferences: SourcePreferences by injectLazy()
|
||||
|
||||
private var wifiLock: WifiManager.WifiLock? = null
|
||||
private var wakeLock: PowerManager.WakeLock? = null
|
||||
@@ -70,7 +70,7 @@ class RecommendationSearchHelper(val context: Context) {
|
||||
}
|
||||
|
||||
private suspend fun beginSearch(mangaList: List<Manga>) {
|
||||
val flags = prefs.recommendationSearchFlags().get()
|
||||
val flags = preferences.recommendationSearchFlags().get()
|
||||
val libraryManga = getLibraryManga.await()
|
||||
val tracks = getTracks.await()
|
||||
|
||||
@@ -192,7 +192,7 @@ class RecommendationSearchHelper(val context: Context) {
|
||||
libraryManga: List<LibraryManga>,
|
||||
tracks: List<Track>,
|
||||
): List<SManga> {
|
||||
val flags = prefs.recommendationSearchFlags().get()
|
||||
val flags = preferences.recommendationSearchFlags().get()
|
||||
|
||||
if (!SearchFlags.hasHideLibraryResults(flags)) {
|
||||
return this
|
||||
|
||||
@@ -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()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import exh.GalleryAddEvent
|
||||
import exh.GalleryAdder
|
||||
import exh.log.xLogE
|
||||
import exh.source.ExhPreferences
|
||||
import exh.util.trimOrNull
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -14,13 +15,12 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import tachiyomi.core.common.i18n.stringResource
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.i18n.sy.SYMR
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class BatchAddScreenModel(
|
||||
private val unsortedPreferences: UnsortedPreferences = Injekt.get(),
|
||||
private val exhPreferences: ExhPreferences = Injekt.get(),
|
||||
) : StateScreenModel<BatchAddState>(BatchAddState()) {
|
||||
private val galleryAdder by lazy { GalleryAdder() }
|
||||
|
||||
@@ -37,7 +37,7 @@ class BatchAddScreenModel(
|
||||
|
||||
private fun addGalleries(context: Context, galleries: String) {
|
||||
val splitGalleries = if (ehVisitedRegex.containsMatchIn(galleries)) {
|
||||
val url = if (unsortedPreferences.enableExhentai().get()) {
|
||||
val url = if (exhPreferences.enableExhentai().get()) {
|
||||
"https://exhentai.org/g/"
|
||||
} else {
|
||||
"https://e-hentai.org/g/"
|
||||
|
||||
@@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.setComposeContent
|
||||
import exh.log.xLogD
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import exh.source.ExhPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.net.HttpCookie
|
||||
@@ -31,7 +31,7 @@ import java.util.Locale
|
||||
* LoginController
|
||||
*/
|
||||
class EhLoginActivity : BaseActivity() {
|
||||
private val preferenceManager: UnsortedPreferences by injectLazy()
|
||||
private val exhPreferences: ExhPreferences by injectLazy()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
@@ -106,7 +106,7 @@ class EhLoginActivity : BaseActivity() {
|
||||
} else if (parsedUrl.host.equals("exhentai.org", ignoreCase = true)) {
|
||||
// At ExHentai, check that everything worked out...
|
||||
if (applyExHentaiCookies(url, customIgneous)) {
|
||||
preferenceManager.enableExhentai().set(true)
|
||||
exhPreferences.enableExhentai().set(true)
|
||||
setResult(RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
@@ -155,9 +155,9 @@ class EhLoginActivity : BaseActivity() {
|
||||
if (memberId == null || passHash == null || igneous == null) return false
|
||||
|
||||
// Update prefs
|
||||
preferenceManager.memberIdVal().set(memberId!!)
|
||||
preferenceManager.passHashVal().set(passHash!!)
|
||||
preferenceManager.igneousVal().set(igneous!!)
|
||||
exhPreferences.memberIdVal().set(memberId!!)
|
||||
exhPreferences.passHashVal().set(passHash!!)
|
||||
exhPreferences.igneousVal().set(igneous!!)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user