[CI SKIP] More consistent "WebView" wording

This commit is contained in:
arkon
2020-04-19 20:53:31 -04:00
parent dff239141d
commit 96618e9517
4 changed files with 12 additions and 12 deletions

View File

@@ -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 {