mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 23:49:16 +01:00
[CI SKIP] More consistent "WebView" wording
This commit is contained in:
parent
dff239141d
commit
96618e9517
@ -75,7 +75,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
|
|
||||||
var challengeFound = false
|
var challengeFound = false
|
||||||
var cloudflareBypassed = false
|
var cloudflareBypassed = false
|
||||||
var isWebviewOutdated = false
|
var isWebViewOutdated = false
|
||||||
|
|
||||||
val origRequestUrl = request.url.toString()
|
val origRequestUrl = request.url.toString()
|
||||||
val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
||||||
@ -139,7 +139,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
|
|
||||||
handler.post {
|
handler.post {
|
||||||
if (!cloudflareBypassed) {
|
if (!cloudflareBypassed) {
|
||||||
isWebviewOutdated = webView?.isOutdated() == true
|
isWebViewOutdated = webView?.isOutdated() == true
|
||||||
}
|
}
|
||||||
|
|
||||||
webView?.stopLoading()
|
webView?.stopLoading()
|
||||||
@ -149,7 +149,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
// Throw exception if we failed to bypass Cloudflare
|
// Throw exception if we failed to bypass Cloudflare
|
||||||
if (!cloudflareBypassed) {
|
if (!cloudflareBypassed) {
|
||||||
// Prompt user to update WebView if it seems too outdated
|
// Prompt user to update WebView if it seems too outdated
|
||||||
if (isWebviewOutdated) {
|
if (isWebViewOutdated) {
|
||||||
context.toast(R.string.information_webview_outdated, Toast.LENGTH_LONG)
|
context.toast(R.string.information_webview_outdated, Toast.LENGTH_LONG)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import eu.kanade.tachiyomi.ui.source.SourceController
|
|||||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||||
import eu.kanade.tachiyomi.util.lang.launchInUI
|
import eu.kanade.tachiyomi.util.lang.launchInUI
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.WebviewUtil
|
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@ -66,8 +66,8 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||||||
|
|
||||||
binding = MainActivityBinding.inflate(layoutInflater)
|
binding = MainActivityBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
// Enforce Webview availability
|
// Enforce WebView availability
|
||||||
if (!WebviewUtil.supportsWebview(this)) {
|
if (!WebViewUtil.supportsWebView(this)) {
|
||||||
toast(R.string.information_webview_required, Toast.LENGTH_LONG)
|
toast(R.string.information_webview_required, Toast.LENGTH_LONG)
|
||||||
finishAndRemoveTask()
|
finishAndRemoveTask()
|
||||||
}
|
}
|
||||||
|
@ -4,30 +4,30 @@ import android.content.Context
|
|||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
|
|
||||||
object WebviewUtil {
|
object WebViewUtil {
|
||||||
val WEBVIEW_UA_VERSION_REGEX by lazy {
|
val WEBVIEW_UA_VERSION_REGEX by lazy {
|
||||||
Regex(""".*Chrome/(\d+)\..*""")
|
Regex(""".*Chrome/(\d+)\..*""")
|
||||||
}
|
}
|
||||||
|
|
||||||
const val MINIMUM_WEBVIEW_VERSION = 79
|
const val MINIMUM_WEBVIEW_VERSION = 79
|
||||||
|
|
||||||
fun supportsWebview(context: Context): Boolean {
|
fun supportsWebView(context: Context): Boolean {
|
||||||
return context.packageManager.hasSystemFeature(PackageManager.FEATURE_WEBVIEW)
|
return context.packageManager.hasSystemFeature(PackageManager.FEATURE_WEBVIEW)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun WebView.isOutdated(): Boolean {
|
fun WebView.isOutdated(): Boolean {
|
||||||
return getWebviewMajorVersion(this) < WebviewUtil.MINIMUM_WEBVIEW_VERSION
|
return getWebViewMajorVersion(this) < WebViewUtil.MINIMUM_WEBVIEW_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based on https://stackoverflow.com/a/29218966
|
// Based on https://stackoverflow.com/a/29218966
|
||||||
private fun getWebviewMajorVersion(webview: WebView): Int {
|
private fun getWebViewMajorVersion(webview: WebView): Int {
|
||||||
val originalUA: String = webview.settings.userAgentString
|
val originalUA: String = webview.settings.userAgentString
|
||||||
|
|
||||||
// Next call to getUserAgentString() will get us the default
|
// Next call to getUserAgentString() will get us the default
|
||||||
webview.settings.userAgentString = null
|
webview.settings.userAgentString = null
|
||||||
|
|
||||||
val uaRegexMatch = WebviewUtil.WEBVIEW_UA_VERSION_REGEX.matchEntire(webview.settings.userAgentString)
|
val uaRegexMatch = WebViewUtil.WEBVIEW_UA_VERSION_REGEX.matchEntire(webview.settings.userAgentString)
|
||||||
val webViewVersion: Int = if (uaRegexMatch != null && uaRegexMatch.groupValues.size > 1) {
|
val webViewVersion: Int = if (uaRegexMatch != null && uaRegexMatch.groupValues.size > 1) {
|
||||||
uaRegexMatch.groupValues[1].toInt()
|
uaRegexMatch.groupValues[1].toInt()
|
||||||
} else {
|
} else {
|
@ -593,7 +593,7 @@
|
|||||||
<string name="information_empty_library">Your library is empty, add series to your library from the sources.</string>
|
<string name="information_empty_library">Your library is empty, add series to your library from the sources.</string>
|
||||||
<string name="information_empty_category">You have no categories. Hit the plus button to create one for organizing your library.</string>
|
<string name="information_empty_category">You have no categories. Hit the plus button to create one for organizing your library.</string>
|
||||||
<string name="information_cloudflare_bypass_failure">Failed to bypass Cloudflare</string>
|
<string name="information_cloudflare_bypass_failure">Failed to bypass Cloudflare</string>
|
||||||
<string name="information_webview_required">Webview is required for Tachiyomi</string>
|
<string name="information_webview_required">WebView is required for Tachiyomi</string>
|
||||||
<string name="information_webview_outdated">Please update the WebView app for better compatibility</string>
|
<string name="information_webview_outdated">Please update the WebView app for better compatibility</string>
|
||||||
|
|
||||||
<!-- Download Notification -->
|
<!-- Download Notification -->
|
||||||
|
Loading…
Reference in New Issue
Block a user