Added option to show inline images by default

This commit is contained in:
M66B 2019-07-02 10:54:09 +02:00
parent b4a8bc1568
commit 25a19ad0c1
5 changed files with 50 additions and 5 deletions

View File

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

View File

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

View File

@ -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" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swInline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_images_inline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMonospaced"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvInlineHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_inline_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swInline" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swImages"
android:layout_width="match_parent"
@ -213,7 +241,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_images"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMonospaced"
app:layout_constraintTop_toBottomOf="@id/tvInlineHint"
app:switchPadding="12dp" />
<TextView
@ -233,6 +261,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_actionbar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvImagesHint"

View File

@ -169,6 +169,7 @@
<string name="title_advanced_addresses">Adresgegevens standaard weergeven</string>
<string name="title_advanced_attachments_alt">Bijlagen weergeven na de berichttekst</string>
<string name="title_advanced_monospaced">Gebruik vaste breedte lettertype voor berichttekst</string>
<string name="title_advanced_images_inline">Automatisch inline afbeeldingen weergeven</string>
<string name="title_advanced_images">Automatisch afbeeldingen weergeven voor bekende contacten</string>
<string name="title_advanced_actionbar">Actiebalk gesprek</string>
<string name="title_advanced_pull_refresh">Omlaag schuiven om te verversen</string>
@ -216,6 +217,7 @@
<string name="title_advanced_threading_hint">Groepeer gerelateerde berichten</string>
<string name="title_advanced_name_email_hint">Indien uitgeschakeld, worden alleen namen weergegeven als deze beschikbaar zijn</string>
<string name="title_advanced_preview_hint">Alleen beschikbaar wanneer de berichttekst werd gedownload</string>
<string name="title_advanced_inline_hint">Inline afbeeldingen zijn afbeeldingen opgenomen in het bericht</string>
<string name="title_advanced_autoexpand_hint">Bericht automatisch openen als er slechts één bericht of slechts één ongelezen bericht in een gesprek is</string>
<string name="title_advanced_autocollapse_hint">Meerdere uitgeklapte berichten worden altijd gesloten bij \'terug\'</string>
<string name="title_advanced_autoclose_hint">Gesprekken automatisch sluiten wanneer alle berichten zijn gearchiveerd, verzonden of weggegooid</string>

View File

@ -103,7 +103,7 @@
<string name="title_setup">Settings</string>
<string name="title_setup_help">Help</string>
<string name="title_setup_welcome">
<string name="title_setup_welcome" translatable="false">
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 @@
<string name="title_advanced_addresses">Show address details by default</string>
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
<string name="title_advanced_monospaced">Use monospaced font for message text</string>
<string name="title_advanced_images_inline">Automatically show inline images</string>
<string name="title_advanced_images">Automatically show images for known contacts</string>
<string name="title_advanced_actionbar">Conversation action bar</string>
@ -263,6 +264,7 @@
<string name="title_advanced_threading_hint">Group messages related to each other</string>
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>
<string name="title_advanced_preview_hint">Only available when message text was downloaded</string>
<string name="title_advanced_inline_hint">Inline images are images included in the message</string>
<string name="title_advanced_autoexpand_hint">Automatically open message when there is just one message or just one unread message in a conversation</string>
<string name="title_advanced_autocollapse_hint">Multiple expanded messages will always be closed on \'back\'</string>