From 96618e95174c8dc202ddeeeb584411f981e05fcc Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 19 Apr 2020 20:53:31 -0400 Subject: [PATCH] [CI SKIP] More consistent "WebView" wording --- .../kanade/tachiyomi/network/CloudflareInterceptor.kt | 6 +++--- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 6 +++--- .../util/system/{WebviewUtil.kt => WebViewUtil.kt} | 10 +++++----- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) rename app/src/main/java/eu/kanade/tachiyomi/util/system/{WebviewUtil.kt => WebViewUtil.kt} (78%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index 919f110d9..eabaa087a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -75,7 +75,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { var challengeFound = false var cloudflareBypassed = false - var isWebviewOutdated = false + var isWebViewOutdated = false val origRequestUrl = request.url.toString() val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" } @@ -139,7 +139,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { handler.post { if (!cloudflareBypassed) { - isWebviewOutdated = webView?.isOutdated() == true + isWebViewOutdated = webView?.isOutdated() == true } webView?.stopLoading() @@ -149,7 +149,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { // Throw exception if we failed to bypass Cloudflare if (!cloudflareBypassed) { // Prompt user to update WebView if it seems too outdated - if (isWebviewOutdated) { + if (isWebViewOutdated) { context.toast(R.string.information_webview_outdated, Toast.LENGTH_LONG) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 22f7f4a8c..e5a247c4a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -32,7 +32,7 @@ import eu.kanade.tachiyomi.ui.source.SourceController import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.util.lang.launchInUI 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 java.util.Date import java.util.concurrent.TimeUnit @@ -66,8 +66,8 @@ class MainActivity : BaseActivity() { binding = MainActivityBinding.inflate(layoutInflater) - // Enforce Webview availability - if (!WebviewUtil.supportsWebview(this)) { + // Enforce WebView availability + if (!WebViewUtil.supportsWebView(this)) { toast(R.string.information_webview_required, Toast.LENGTH_LONG) finishAndRemoveTask() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebviewUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt similarity index 78% rename from app/src/main/java/eu/kanade/tachiyomi/util/system/WebviewUtil.kt rename to app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt index 7f63f766d..3eeb60bc3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebviewUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt @@ -4,30 +4,30 @@ import android.content.Context import android.content.pm.PackageManager import android.webkit.WebView -object WebviewUtil { +object WebViewUtil { val WEBVIEW_UA_VERSION_REGEX by lazy { Regex(""".*Chrome/(\d+)\..*""") } const val MINIMUM_WEBVIEW_VERSION = 79 - fun supportsWebview(context: Context): Boolean { + fun supportsWebView(context: Context): Boolean { return context.packageManager.hasSystemFeature(PackageManager.FEATURE_WEBVIEW) } } 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 -private fun getWebviewMajorVersion(webview: WebView): Int { +private fun getWebViewMajorVersion(webview: WebView): Int { val originalUA: String = webview.settings.userAgentString // Next call to getUserAgentString() will get us the default 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) { uaRegexMatch.groupValues[1].toInt() } else { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f2d4de119..46548af6a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -593,7 +593,7 @@ Your library is empty, add series to your library from the sources. You have no categories. Hit the plus button to create one for organizing your library. Failed to bypass Cloudflare - Webview is required for Tachiyomi + WebView is required for Tachiyomi Please update the WebView app for better compatibility