diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 1b78307d3c..419b3a79f1 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -76,7 +76,6 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; -import android.widget.ToggleButton; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -171,7 +170,6 @@ public class AdapterMessage extends RecyclerView.Adapter attachments) { @@ -1258,11 +1238,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0 ? View.VISIBLE : View.GONE); - boolean show_html = properties.getValue("html", message.id); - if (show_html) - onShowHtmlConfirmed(message); - else - showText(message); + showText(message); } private void onActionCalendar(TupleMessageEx message, int action) { @@ -1421,18 +1397,6 @@ public class AdapterMessage extends RecyclerView.Adapter() { - @Override - protected OriginalMessage onExecute(Context context, Bundle args) throws IOException { - long id = args.getLong("id"); - - DB db = DB.getInstance(context); - EntityMessage message = db.message().getMessage(id); - if (message == null || !message.content) - return null; - - File file = message.getFile(context); - if (!file.exists()) - return null; - - OriginalMessage original = new OriginalMessage(); - original.html = Helper.readText(file); - original.html = HtmlHelper.getHtmlEmbedded(context, id, original.html); - - Document doc = Jsoup.parse(original.html); - original.has_images = (doc.select("img").size() > 0); - - return original; - } - - @Override - protected void onExecuted(Bundle args, OriginalMessage original) { - if (original == null) - return; - - long id = args.getLong("id"); - properties.setHtml(id, original.html); - if (!original.has_images) - properties.setValue("images", id, true); - - TupleMessageEx amessage = getMessage(); - if (amessage == null || !amessage.id.equals(id)) - return; - - boolean expanded = properties.getValue("expanded", id); - if (!expanded) - return; - - boolean show_images = properties.getValue("images", id); - ibImages.setVisibility(original.has_images && !show_images ? View.VISIBLE : View.GONE); - ibFull.setVisibility(View.VISIBLE); - - webView.loadDataWithBaseURL("", themeHtml(original.html), "text/html", "UTF-8", null); - - pbBody.setVisibility(View.GONE); - } - - @Override - protected void onException(Bundle args, Throwable ex) { - Helper.unexpectedError(context, owner, ex); - } - }.execute(context, owner, args, "message:webview"); - } else { - Document doc = Jsoup.parse(html); - boolean has_images = (doc.select("img").size() > 0); - - ibImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE); - ibFull.setVisibility(View.VISIBLE); - - webView.loadDataWithBaseURL("", themeHtml(html), "text/html", "UTF-8", null); - webView.setVisibility(View.VISIBLE); - - pbBody.setVisibility(View.GONE); - } - } - - private void onHideHtml(TupleMessageEx message) { - properties.setValue("html", message.id, false); - - ibFull.setVisibility(View.GONE); - vwBody.setVisibility(View.GONE); - - Spanned body = properties.getBody(message.id); - tvBody.setText(body); - tvBody.setMovementMethod(null); - tvBody.setVisibility(View.VISIBLE); - - showText(message); - } - - private String themeHtml(String html) { - if (dark) { - String color = String.format("#%06X", (textColorSecondary & 0xFFFFFF)); - return "" + html; - } else - return html; - } - - private void onShowFull(TupleMessageEx message) { + private void onShowFullConfirmed(TupleMessageEx message) { Bundle args = new Bundle(); args.putLong("id", message.id); new SimpleTask() { @Override - protected String onExecute(Context context, Bundle args) { + protected String onExecute(Context context, Bundle args) throws Throwable { long id = args.getLong("id"); - String html = properties.getHtml(id); + DB db = DB.getInstance(context); + EntityMessage message = db.message().getMessage(id); + if (message == null || !message.content) + return null; + + File file = message.getFile(context); + if (!file.exists()) + return null; + + String html = HtmlHelper.getHtmlEmbedded(context, id, Helper.readText(file)); // Remove viewport limitations Document doc = Jsoup.parse(html); @@ -2068,11 +1888,7 @@ public class AdapterMessage extends RecyclerView.Adapter attachments); List getAttachments(long id); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 9dafb1764d..f34892075d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -182,7 +182,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. private boolean autoExpanded = true; private Map> values = new HashMap<>(); private LongSparseArray bodies = new LongSparseArray<>(); - private LongSparseArray html = new LongSparseArray<>(); private LongSparseArray> attachments = new LongSparseArray<>(); private LongSparseArray accountSwipes = new LongSparseArray<>(); @@ -906,19 +905,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. return bodies.get(id); } - @Override - public void setHtml(long id, String value) { - if (value == null) - html.remove(id); - else - html.put(id, value); - } - - @Override - public String getHtml(long id) { - return html.get(id); - } - @Override public void setAttchments(long id, List list) { attachments.put(id, list); @@ -2090,7 +2076,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. for (String key : values.keySet()) values.get(key).remove(id); bodies.remove(id); - html.remove(id); attachments.remove(id); } } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index fb1a9bc1fd..dfb625d4b7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -50,13 +50,12 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swAddresses; private SwitchCompat swAttachmentsAlt; private SwitchCompat swMonospaced; - private SwitchCompat swHtml; private SwitchCompat swImages; private SwitchCompat swActionbar; private final static String[] RESET_OPTIONS = new String[]{ "startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", - "flags", "preview", "addresses", "attachments_alt", "monospaced", "autohtml", "autoimages", "actionbar", + "flags", "preview", "addresses", "attachments_alt", "monospaced", "autoimages", "actionbar", }; @Override @@ -82,7 +81,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swAddresses = view.findViewById(R.id.swAddresses); swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt); swMonospaced = view.findViewById(R.id.swMonospaced); - swHtml = view.findViewById(R.id.swHtml); swImages = view.findViewById(R.id.swImages); swActionbar = view.findViewById(R.id.swActionbar); @@ -192,13 +190,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); - swHtml.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("autohtml", checked).apply(); - } - }); - swImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -279,7 +270,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swAddresses.setChecked(prefs.getBoolean("addresses", false)); swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false)); swMonospaced.setChecked(prefs.getBoolean("monospaced", false)); - swHtml.setChecked(prefs.getBoolean("autohtml", false)); swImages.setChecked(prefs.getBoolean("autoimages", false)); swActionbar.setChecked(prefs.getBoolean("actionbar", true)); } diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index dd81f4e7dc..bdd4f0c10b 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -194,28 +194,6 @@ app:layout_constraintTop_toBottomOf="@id/swAttachmentsAlt" app:switchPadding="12dp" /> - - - - - - + app:layout_constraintTop_toBottomOf="@id/tvBody" /> - -