1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-22 15:55:57 +00:00

Get WebView version

This commit is contained in:
M66B 2022-06-15 17:14:47 +02:00
parent 025803894d
commit 5e111da58b

View file

@ -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);