From 25a19ad0c1cee91098e217174ea181ad885fe374 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 2 Jul 2019 10:54:09 +0200 Subject: [PATCH] Added option to show inline images by default --- .../email/FragmentOptionsDisplay.java | 12 ++++++- .../java/eu/faircode/email/HtmlHelper.java | 6 ++-- .../res/layout/fragment_options_display.xml | 31 ++++++++++++++++++- app/src/main/res/values-nl-rNL/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 4 ++- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index b40919f306..e593e6cd0b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -55,12 +55,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swAddresses; private SwitchCompat swAttachmentsAlt; private SwitchCompat swMonospaced; + private SwitchCompat swInline; private SwitchCompat swImages; private SwitchCompat swActionbar; private final static String[] RESET_OPTIONS = new String[]{ "theme", "startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", - "flags", "preview", "addresses", "attachments_alt", "monospaced", "autoimages", "actionbar", + "flags", "preview", "addresses", "attachments_alt", "monospaced", "inline_images", "autoimages", "actionbar", }; @Override @@ -87,6 +88,7 @@ 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); + swInline = view.findViewById(R.id.swInline); swImages = view.findViewById(R.id.swImages); swActionbar = view.findViewById(R.id.swActionbar); @@ -203,6 +205,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + swInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("inline_images", checked).apply(); + } + }); + swImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -283,6 +292,7 @@ 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)); + swInline.setChecked(prefs.getBoolean("inline_images", false)); swImages.setChecked(prefs.getBoolean("autoimages", false)); swActionbar.setChecked(prefs.getBoolean("actionbar", true)); } diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 4a64917171..5ca1c86882 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -318,6 +318,7 @@ public class HtmlHelper { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(view.getContext()); boolean compact = prefs.getBoolean("compact", false); int zoom = prefs.getInt("zoom", compact ? 0 : 1); + boolean inline = prefs.getBoolean("inline_images", false); final int px = Helper.dp2pixels(view.getContext(), (zoom + 1) * 24); @@ -334,9 +335,10 @@ public class HtmlHelper { boolean data = source.startsWith("data:"); if (BuildConfig.DEBUG) - Log.i("Image show=" + show + " embedded=" + embedded + " data=" + data + " source=" + source); + Log.i("Image show=" + show + " inline=" + inline + + " embedded=" + embedded + " data=" + data + " source=" + source); - if (!show) { + if (!(show || (inline && (embedded || data)))) { // Show placeholder icon int resid = (embedded || data ? R.drawable.baseline_photo_library_24 : R.drawable.baseline_image_24); Drawable d = res.getDrawable(resid, theme); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index 9e486a4896..55347f1d19 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -55,6 +55,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_date_header" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/spStartup" @@ -65,6 +66,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_threading" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swDate" @@ -87,6 +89,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_avatars" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvThreadingHint" @@ -107,6 +110,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_circular" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swIdenticons" @@ -139,6 +143,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_subject_italic" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvNameEmailHint" @@ -149,6 +154,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_flags" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swSubjectItalic" @@ -206,6 +212,28 @@ app:layout_constraintTop_toBottomOf="@id/swAttachmentsAlt" app:switchPadding="12dp" /> + + + + Adresgegevens standaard weergeven Bijlagen weergeven na de berichttekst Gebruik vaste breedte lettertype voor berichttekst + Automatisch inline afbeeldingen weergeven Automatisch afbeeldingen weergeven voor bekende contacten Actiebalk gesprek Omlaag schuiven om te verversen @@ -216,6 +217,7 @@ Groepeer gerelateerde berichten Indien uitgeschakeld, worden alleen namen weergegeven als deze beschikbaar zijn Alleen beschikbaar wanneer de berichttekst werd gedownload + Inline afbeeldingen zijn afbeeldingen opgenomen in het bericht Bericht automatisch openen als er slechts één bericht of slechts één ongelezen bericht in een gesprek is Meerdere uitgeklapte berichten worden altijd gesloten bij \'terug\' Gesprekken automatisch sluiten wanneer alle berichten zijn gearchiveerd, verzonden of weggegooid diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 494487e0eb..3664602cfa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -103,7 +103,7 @@ Settings Help - + To receive and send messages you\'ll need to setup an account and identity. This is not easier or not more difficult than in any other email app, although some providers make this not very easy. @@ -207,6 +207,7 @@ Show address details by default Show attachments after the message text Use monospaced font for message text + Automatically show inline images Automatically show images for known contacts Conversation action bar @@ -263,6 +264,7 @@ Group messages related to each other When disabled only names will be shown when available Only available when message text was downloaded + Inline images are images included in the message Automatically open message when there is just one message or just one unread message in a conversation Multiple expanded messages will always be closed on \'back\'