mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Added option to disable image placeholders
This commit is contained in:
parent
ef2f2ca99e
commit
3e9b60d433
5 changed files with 52 additions and 8 deletions
|
@ -87,7 +87,8 @@ public class FragmentOptions extends FragmentBase {
|
|||
"message_zoom", "overview_mode", "addresses", "attachments_alt", "thumbnails",
|
||||
"contrast", "monospaced", "monospaced_pre",
|
||||
"text_color", "text_size", "text_font", "text_align", "text_separators",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
|
||||
"collapse_quotes", "image_placeholders", "inline_images",
|
||||
"seekbar", "actionbar", "actionbar_color", "navbar_colorize",
|
||||
"autoscroll", "swipenav", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose",
|
||||
"language_detection",
|
||||
"quick_filter", "quick_scroll",
|
||||
|
|
|
@ -126,6 +126,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private SwitchCompat swTextAlign;
|
||||
private SwitchCompat swTextSeparators;
|
||||
private SwitchCompat swCollapseQuotes;
|
||||
private SwitchCompat swImagesPlaceholders;
|
||||
private SwitchCompat swImagesInline;
|
||||
private SwitchCompat swAttachmentsAlt;
|
||||
private SwitchCompat swThumbnails;
|
||||
|
@ -145,7 +146,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
"addresses",
|
||||
"message_zoom", "overview_mode", "contrast", "monospaced", "monospaced_pre",
|
||||
"text_color", "text_size", "text_font", "text_align", "text_separators",
|
||||
"inline_images", "collapse_quotes", "attachments_alt", "thumbnails",
|
||||
"collapse_quotes", "image_placeholders", "inline_images", "attachments_alt", "thumbnails",
|
||||
"parse_classes", "authentication"
|
||||
};
|
||||
|
||||
|
@ -221,6 +222,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swTextAlign = view.findViewById(R.id.swTextAlign);
|
||||
swTextSeparators = view.findViewById(R.id.swTextSeparators);
|
||||
swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes);
|
||||
swImagesPlaceholders = view.findViewById(R.id.swImagesPlaceholders);
|
||||
swImagesInline = view.findViewById(R.id.swImagesInline);
|
||||
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
|
||||
swThumbnails = view.findViewById(R.id.swThumbnails);
|
||||
|
@ -770,6 +772,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swImagesPlaceholders.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("image_placeholders", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swImagesInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -968,6 +977,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swTextAlign.setChecked(prefs.getBoolean("text_align", true));
|
||||
swTextSeparators.setChecked(prefs.getBoolean("text_separators", false));
|
||||
swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false));
|
||||
swImagesPlaceholders.setChecked(prefs.getBoolean("image_placeholders", true));
|
||||
swImagesInline.setChecked(prefs.getBoolean("inline_images", false));
|
||||
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
||||
swThumbnails.setChecked(prefs.getBoolean("thumbnails", true));
|
||||
|
|
|
@ -370,6 +370,7 @@ public class HtmlHelper {
|
|||
boolean parse_classes = prefs.getBoolean("parse_classes", true);
|
||||
boolean inline_images = prefs.getBoolean("inline_images", false);
|
||||
boolean text_separators = prefs.getBoolean("text_separators", false);
|
||||
boolean image_placeholders = prefs.getBoolean("image_placeholders", true);
|
||||
|
||||
int textColorPrimary = Helper.resolveColor(context, android.R.attr.textColorPrimary);
|
||||
|
||||
|
@ -959,6 +960,10 @@ public class HtmlHelper {
|
|||
img.remove();
|
||||
continue;
|
||||
}
|
||||
if (!show_images && !image_placeholders) {
|
||||
img.removeAttr("src");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (alt.length() > MAX_ALT)
|
||||
alt = alt.substring(0, MAX_ALT) + "…";
|
||||
|
@ -2288,11 +2293,13 @@ public class HtmlHelper {
|
|||
break;
|
||||
case "img":
|
||||
String src = element.attr("src");
|
||||
Drawable d = (imageGetter == null
|
||||
? context.getDrawable(R.drawable.twotone_broken_image_24)
|
||||
: imageGetter.getDrawable(src));
|
||||
ssb.insert(start, "\uFFFC"); // Object replacement character
|
||||
setSpan(ssb, new ImageSpan(d, src), start, start + 1);
|
||||
if (!TextUtils.isEmpty(src)) {
|
||||
Drawable d = (imageGetter == null
|
||||
? context.getDrawable(R.drawable.twotone_broken_image_24)
|
||||
: imageGetter.getDrawable(src));
|
||||
ssb.insert(start, "\uFFFC"); // Object replacement character
|
||||
setSpan(ssb, new ImageSpan(d, src), start, start + 1);
|
||||
}
|
||||
break;
|
||||
case "li":
|
||||
if (start == 0 || ssb.charAt(start - 1) != '\n')
|
||||
|
|
|
@ -1007,6 +1007,30 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swTextSeparators"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swImagesPlaceholders"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_advanced_image_placeholders"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swCollapseQuotes"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvImagesPlaceholdersHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_placeholders_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/swImagesPlaceholders" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swImagesInline"
|
||||
android:layout_width="0dp"
|
||||
|
@ -1015,7 +1039,7 @@
|
|||
android:text="@string/title_advanced_images_inline"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swCollapseQuotes"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvImagesPlaceholdersHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
|
|
@ -396,6 +396,7 @@
|
|||
<string name="title_advanced_text_align">Use text alignment</string>
|
||||
<string name="title_advanced_text_separators">Use separator lines</string>
|
||||
<string name="title_advanced_collapse_quotes">Collapse quoted text</string>
|
||||
<string name="title_advanced_image_placeholders">Show image placeholders</string>
|
||||
<string name="title_advanced_images_inline">Automatically show inline images</string>
|
||||
<string name="title_advanced_seekbar">Show relative conversation position with a dot</string>
|
||||
<string name="title_advanced_actionbar">Show conversation action bar</string>
|
||||
|
@ -572,6 +573,7 @@
|
|||
<string name="title_advanced_preview_hint">Only available when message text has been downloaded</string>
|
||||
<string name="title_advanced_preview_issue">Scrolling can be slow due to a bug in some Android versions when the number of lines is more than one</string>
|
||||
<string name="title_advanced_overview_mode_hint">This can result in very small fonts</string>
|
||||
<string name="title_advanced_placeholders_hint">This applies to reformatted messages only</string>
|
||||
<string name="title_advanced_inline_hint">Inline images are images included in the message</string>
|
||||
<string name="title_advanced_parse_classes_hint">This will more accurately display messages, but possibly with a delay</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue