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