Fix build
This commit is contained in:
1 parent
e6c4b32a47
commit
c6b3aec1af
3 files changed
+9
-6
No files matched your search
@@ -210,6 +210,9 @@ object Settings : DataStorePreferences(null) {
|
||||
val showNavigationOverlayOnStart = boolPref("reader_navigation_overlay_on_start", false)
|
||||
val stripExtraneousAds = boolPref("strip_extraneous_ads", false)
|
||||
|
||||
val userAgent
|
||||
get() = if (desktopSite) CHROME_USER_AGENT else CHROME_MOBILE_USER_AGENT
|
||||
|
||||
init {
|
||||
if ("CN" == Locale.getDefault().country) {
|
||||
edit {
|
||||
@@ -251,3 +254,6 @@ object Settings : DataStorePreferences(null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val CHROME_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${BuildConfig.CHROME_VERSION}.0.0.0 Safari/537.36"
|
||||
private const val CHROME_MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${BuildConfig.CHROME_VERSION}.0.0.0 Mobile Safari/537.36"
|
||||
@@ -18,9 +18,9 @@ fun ImageRequest.Builder.ehUrl(info: GalleryInfo) = apply {
|
||||
|
||||
fun ImageRequest.Builder.ehPreview(preview: GalleryPreview) = with(preview) {
|
||||
data(url)
|
||||
if (preview is V2GalleryPreview) size(Size.ORIGINAL)
|
||||
memoryCacheKey(imageKey)
|
||||
diskCacheKey(imageKey)
|
||||
if (preview is V2GalleryPreview) size(Size.ORIGINAL)
|
||||
}
|
||||
|
||||
fun ImageRequest.Builder.justDownload() = apply {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.hippo.ehviewer.ktor
|
||||
|
||||
import com.hippo.ehviewer.BuildConfig
|
||||
import com.hippo.ehviewer.Settings.desktopSite
|
||||
import com.hippo.ehviewer.Settings.userAgent
|
||||
import com.hippo.ehviewer.client.EhCookieStore
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.HttpClientEngineConfig
|
||||
@@ -14,8 +13,6 @@ import io.ktor.http.HttpHeaders
|
||||
|
||||
private const val CHROME_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
|
||||
private const val CHROME_ACCEPT_LANGUAGE = "en-US,en;q=0.5"
|
||||
private const val CHROME_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${BuildConfig.CHROME_VERSION}.0.0.0 Safari/537.36"
|
||||
private const val CHROME_MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${BuildConfig.CHROME_VERSION}.0.0.0 Mobile Safari/537.36"
|
||||
|
||||
fun <T : HttpClientEngineConfig> HttpClientConfig<T>.configureCommon() = apply {
|
||||
install(HttpCookies) {
|
||||
@@ -25,7 +22,7 @@ fun <T : HttpClientEngineConfig> HttpClientConfig<T>.configureCommon() = apply {
|
||||
requestTimeoutMillis = 10_000
|
||||
}
|
||||
install(UserAgent) {
|
||||
agent = if (desktopSite) CHROME_USER_AGENT else CHROME_MOBILE_USER_AGENT
|
||||
agent = userAgent
|
||||
}
|
||||
defaultRequest {
|
||||
header(HttpHeaders.Accept, CHROME_ACCEPT)
|
||||
|
||||
Reference in new issue
Block a user