From b0fa5acf7b053d89e119f90ea04e3ada6f139d27 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 12 Sep 2018 12:02:27 +0000 Subject: [PATCH] Check if webview exists --- app/src/main/java/eu/faircode/email/FragmentMessage.java | 1 + app/src/main/java/eu/faircode/email/Helper.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index a32c8baf..d3c0e38c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -557,6 +557,7 @@ public class FragmentMessage extends FragmentEx { menu.findItem(R.id.menu_show_headers).setChecked(headers); menu.findItem(R.id.menu_show_headers).setEnabled(message.uid != null); menu.findItem(R.id.menu_show_headers).setVisible(!free); + menu.findItem(R.id.menu_show_html).setEnabled(Helper.classExists("android.webkit.WebView")); menu.findItem(R.id.menu_reply_all).setVisible(!inOutbox); } diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index ee6c5b2d..6e88135c 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -124,6 +124,15 @@ public class Helper { return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); } + static boolean classExists(String className) { + try { + Class.forName(className); + return true; + } catch (ClassNotFoundException ignored) { + return false; + } + } + static Address myAddress() throws UnsupportedEncodingException { return new InternetAddress("marcel+fairemail@faircode.eu", "FairCode"); }