Update dependency io.coil-kt.coil3:coil-bom to v3.0.0-alpha04 (#677)
* Update dependency io.coil-kt.coil3:coil-bom to v3.0.0-alpha04 * Revert "Fix delayed application of HTTP engine changes" This reverts commitc82de0b779. * Revert "No longer need restart to switch HC" This reverts commit7e8b0a58--------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FooIbar <118464521+FooIbar@users.noreply.github.com>
This commit is contained in:
1 parent
8da3546558
commit
e9f615819f
8 files changed
+9
-49
No files matched your search
@@ -54,12 +54,10 @@ import com.hippo.ehviewer.util.Crash
|
||||
import com.hippo.ehviewer.util.FavouriteStatusRouter
|
||||
import com.hippo.ehviewer.util.FileUtils
|
||||
import com.hippo.ehviewer.util.ReadableTime
|
||||
import com.hippo.ehviewer.util.delegateLazy
|
||||
import com.hippo.ehviewer.util.isAtLeastP
|
||||
import com.hippo.ehviewer.util.isAtLeastQ
|
||||
import com.hippo.ehviewer.util.isAtLeastS
|
||||
import com.hippo.ehviewer.util.isCronetAvailable
|
||||
import com.hippo.ehviewer.util.resettableLazy
|
||||
import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
@@ -185,7 +183,7 @@ class EhApplication : Application(), SingletonImageLoader.Factory {
|
||||
override fun newImageLoader(context: Context) = context.imageLoader {
|
||||
components {
|
||||
serviceLoaderEnabled(false)
|
||||
add(KtorNetworkFetcherFactory(delegateLazy { ktorClient }))
|
||||
add(KtorNetworkFetcherFactory { ktorClient })
|
||||
add(MergeInterceptor)
|
||||
add(DownloadThumbInterceptor)
|
||||
if (isAtLeastP) {
|
||||
@@ -202,7 +200,7 @@ class EhApplication : Application(), SingletonImageLoader.Factory {
|
||||
}
|
||||
|
||||
companion object {
|
||||
var ktorClient by resettableLazy {
|
||||
val ktorClient by lazy {
|
||||
if (Settings.enableCronet && isCronetAvailable) {
|
||||
HttpClient(CronetEngine) {
|
||||
install(HttpCookies) {
|
||||
@@ -226,7 +224,7 @@ class EhApplication : Application(), SingletonImageLoader.Factory {
|
||||
}
|
||||
}
|
||||
|
||||
var noRedirectKtorClient by resettableLazy {
|
||||
val noRedirectKtorClient by lazy {
|
||||
HttpClient(ktorClient.engine) {
|
||||
followRedirects = false
|
||||
install(HttpCookies) {
|
||||
|
||||
@@ -149,7 +149,7 @@ object Settings : DataStorePreferences(null) {
|
||||
var harmonizeCategoryColor by boolPref("harmonize_category_color", true)
|
||||
var preloadThumbAggressively by boolPref("preload_thumb_aggressively", false)
|
||||
var downloadOriginImage by boolPref("download_origin_image", false)
|
||||
var enableCronet by boolPref("enable_cronet", true).observed { updateWhenEnableCronetChanges() }
|
||||
var enableCronet by boolPref("enable_cronet", true)
|
||||
var recentFavCat by intPref("recent_fav_cat", FavListUrlBuilder.FAV_CAT_LOCAL)
|
||||
var defaultFavSlot by intPref("default_favorite_slot", -2)
|
||||
var securityDelay by intPref("require_unlock_delay", 0)
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.hippo.ehviewer
|
||||
import android.app.UiModeManager
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import com.hippo.ehviewer.EhApplication.Companion.ktorClient
|
||||
import com.hippo.ehviewer.EhApplication.Companion.noRedirectKtorClient
|
||||
import com.hippo.ehviewer.client.EhCookieStore
|
||||
import com.hippo.ehviewer.client.EhEngine
|
||||
import com.hippo.ehviewer.client.EhTagDatabase
|
||||
@@ -45,13 +43,6 @@ fun updateWhenKeepMediaStatusChanges() {
|
||||
}
|
||||
}
|
||||
|
||||
fun updateWhenEnableCronetChanges() {
|
||||
collectScope.launchIO {
|
||||
ktorClient = ktorClient.apply { close() }
|
||||
noRedirectKtorClient = noRedirectKtorClient.apply { close() }
|
||||
}
|
||||
}
|
||||
|
||||
fun updateWhenThemeChanges() {
|
||||
collectScope.launch {
|
||||
delay(100) // Avoid recompose being cancelled
|
||||
|
||||
@@ -153,18 +153,14 @@ fun AdvancedScreen(navigator: DestinationsNavigator) {
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.align(Alignment.Center)) {
|
||||
SegmentedButton(
|
||||
selected = !enableCronet,
|
||||
onClick = {
|
||||
enableCronet = false
|
||||
},
|
||||
onClick = { enableCronet = false },
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2),
|
||||
) {
|
||||
Text("OkHttp")
|
||||
}
|
||||
SegmentedButton(
|
||||
selected = enableCronet,
|
||||
onClick = {
|
||||
enableCronet = true
|
||||
},
|
||||
onClick = { enableCronet = true },
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2),
|
||||
enabled = isCronetAvailable,
|
||||
) {
|
||||
|
||||
@@ -6,36 +6,11 @@ import kotlin.reflect.KMutableProperty0
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
fun <T> unsafeLazy(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer)
|
||||
fun <T> resettableLazy(initializer: () -> T) = ResettableLazy(initializer)
|
||||
fun <T> delegateLazy(initializer: () -> T) = object : kotlin.Lazy<T> {
|
||||
override val value: T
|
||||
get() = initializer()
|
||||
|
||||
override fun isInitialized() = true
|
||||
}
|
||||
|
||||
interface Lazy<T> {
|
||||
var value: T
|
||||
}
|
||||
|
||||
class ResettableLazy<T>(private val initializer: () -> T) {
|
||||
|
||||
private var value: T? = null
|
||||
|
||||
operator fun getValue(thisRef: Any?, prop: KProperty<*>): T {
|
||||
return value ?: initializer().apply { value = this }
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: T) {
|
||||
check(this.value == value) { "New values aren't accepted to reset this delegated property" }
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun invalidate() {
|
||||
value = null
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> lazyMut(init: () -> KMutableProperty0<T>) = object : Lazy<T> {
|
||||
private val lazy by lazy { init() }
|
||||
override var value
|
||||
|
||||
@@ -355,7 +355,7 @@
|
||||
<string name="settings_advanced_dump_logcat_to">已保存日志至 %s</string>
|
||||
<string name="settings_advanced_read_cache_size">阅读缓存大小</string>
|
||||
<string name="settings_advanced_app_language_title">App 界面语言</string>
|
||||
<string name="settings_advanced_http_engine">Http 引擎</string>
|
||||
<string name="settings_advanced_http_engine">Http 引擎(重启生效)</string>
|
||||
<string name="settings_advanced_touch_slop">[实验性] 触摸溢出系数</string>
|
||||
<string name="settings_advanced_touch_slop_summary">增大此项将降低滑动手势敏感度</string>
|
||||
<string name="settings_advanced_export_data">导出数据</string>
|
||||
|
||||
@@ -399,7 +399,7 @@
|
||||
<string name="settings_advanced_dump_logcat_to">Logcat dumped to %s</string>
|
||||
<string name="settings_advanced_read_cache_size">Read cache size</string>
|
||||
<string name="settings_advanced_app_language_title">App language</string>
|
||||
<string name="settings_advanced_http_engine">Http Engine</string>
|
||||
<string name="settings_advanced_http_engine">Http Engine (Restart required)</string>
|
||||
<string name="settings_advanced_touch_slop">[Experimental] Touch slop factor</string>
|
||||
<string name="settings_advanced_touch_slop_summary">Increasing this will reduce swipe gesture sensitivity</string>
|
||||
<string name="settings_advanced_export_data">Export data</string>
|
||||
|
||||
@@ -16,7 +16,7 @@ androidx-recyclerview = "1.3.2"
|
||||
androidx-room = "2.6.1"
|
||||
androidx-work = "2.9.0"
|
||||
arrow = "1.2.1"
|
||||
coil = "3.0.0-alpha03"
|
||||
coil = "3.0.0-alpha04"
|
||||
compose-bom = "2024.01.00-alpha03"
|
||||
compose-compiler = "1.5.9-dev-k2.0.0-Beta3-7c5ec6895a0"
|
||||
compose-destinations = "1.10.0"
|
||||
|
||||
Reference in new issue
Block a user