mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	[CI SKIP] More consistent "WebView" wording
This commit is contained in:
		| @@ -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) | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -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<MainActivityBinding>() { | ||||
|  | ||||
|         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() | ||||
|         } | ||||
|   | ||||
| @@ -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 { | ||||
		Reference in New Issue
	
	Block a user