From 5e111da58b35d4bc11fc463597b730121fad7d43 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 15 Jun 2022 17:14:47 +0200 Subject: [PATCH] Get WebView version --- .../main/java/eu/faircode/email/WebViewEx.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/WebViewEx.java b/app/src/main/java/eu/faircode/email/WebViewEx.java index 99e46e7683..feab0addfe 100644 --- a/app/src/main/java/eu/faircode/email/WebViewEx.java +++ b/app/src/main/java/eu/faircode/email/WebViewEx.java @@ -21,6 +21,7 @@ package eu.faircode.email; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.PackageInfo; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Color; @@ -39,6 +40,7 @@ import android.webkit.WebViewClient; import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; import androidx.webkit.WebSettingsCompat; +import androidx.webkit.WebViewCompat; import androidx.webkit.WebViewFeature; public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener { @@ -401,6 +403,19 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC return (large ? "Mozilla/5.0" : "Mozilla/5.0 (Mobile)"); } + static int getVersionCode(Context context) { + try { + // version / 100000 > 5005 + PackageInfo pkg = WebViewCompat.getCurrentWebViewPackage(context); + if (pkg == null) + return -1; + return pkg.versionCode; + } catch (Throwable ex) { + Log.e(ex); + return -1; + } + } + interface IWebView { void onSizeChanged(int w, int h, int ow, int oh);