Remove desktop site option
This commit is contained in:
1 parent
f4c7320bb5
commit
9edb52c909
4 files changed
+7
-17
No files matched your search
@@ -210,9 +210,6 @@ 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 {
|
||||
@@ -254,6 +251,3 @@ 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"
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.hippo.ehviewer.ktor
|
||||
|
||||
import com.hippo.ehviewer.Settings.userAgent
|
||||
import com.hippo.ehviewer.BuildConfig
|
||||
import com.hippo.ehviewer.client.EhCookieStore
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.HttpClientEngineConfig
|
||||
@@ -12,8 +12,9 @@ import io.ktor.client.plugins.defaultRequest
|
||||
import io.ktor.client.request.header
|
||||
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"
|
||||
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_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.7"
|
||||
private const val CHROME_ACCEPT_LANGUAGE = "en-US,en;q=0.9"
|
||||
|
||||
fun <T : HttpClientEngineConfig> HttpClientConfig<T>.configureCommon(redirect: Boolean = true) = apply {
|
||||
install(HttpCookies) {
|
||||
@@ -23,7 +24,7 @@ fun <T : HttpClientEngineConfig> HttpClientConfig<T>.configureCommon(redirect: B
|
||||
requestTimeoutMillis = 10_000
|
||||
}
|
||||
install(UserAgent) {
|
||||
agent = userAgent
|
||||
agent = CHROME_USER_AGENT
|
||||
}
|
||||
defaultRequest {
|
||||
header(HttpHeaders.Accept, CHROME_ACCEPT)
|
||||
|
||||
@@ -203,11 +203,6 @@ fun AdvancedScreen(navigator: DestinationsNavigator) {
|
||||
title = stringResource(id = R.string.animate_items),
|
||||
summary = stringResource(id = R.string.animate_items_summary),
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(id = R.string.desktop_site),
|
||||
summary = stringResource(id = R.string.desktop_site_summary),
|
||||
value = Settings::desktopSite,
|
||||
)
|
||||
val exportFailed = stringResource(id = R.string.settings_advanced_export_data_failed)
|
||||
LauncherPreference(
|
||||
title = stringResource(id = R.string.settings_advanced_export_data),
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.hippo.ehviewer.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.webkit.WebView
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.ktor.CHROME_USER_AGENT
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
fun WebView.setDefaultSettings() = with(settings) {
|
||||
builtInZoomControls = true
|
||||
displayZoomControls = false
|
||||
javaScriptEnabled = true
|
||||
userAgentString = Settings.userAgent
|
||||
userAgentString = CHROME_USER_AGENT
|
||||
}
|
||||
Reference in new issue
Block a user