diff --git a/app/src/main/java/eu/faircode/email/AdapterImage.java b/app/src/main/java/eu/faircode/email/AdapterImage.java index 657db9fcca..820e029f99 100644 --- a/app/src/main/java/eu/faircode/email/AdapterImage.java +++ b/app/src/main/java/eu/faircode/email/AdapterImage.java @@ -25,7 +25,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.drawable.AnimatedImageDrawable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.pdf.PdfRenderer; @@ -185,9 +184,7 @@ public class AdapterImage extends RecyclerView.Adapter else ivImage.setImageDrawable(image); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && - image instanceof AnimatedImageDrawable) - ((AnimatedImageDrawable) image).start(); + ImageHelper.animate(context, image); StringBuilder sb = new StringBuilder(); diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index b2bc50e3de..78aaf2f7f0 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -45,7 +45,6 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Typeface; -import android.graphics.drawable.AnimatedImageDrawable; import android.graphics.drawable.Drawable; import android.graphics.text.LineBreaker; import android.net.Uri; @@ -3253,15 +3252,8 @@ public class AdapterMessage extends RecyclerView.Adapter= Build.VERSION_CODES.P) { - if (drawable instanceof AnimatedImageDrawable) - ((AnimatedImageDrawable) drawable).start(); - } - - return drawable; } }, null); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index a3b4a80f21..108705700e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -213,6 +213,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swNativeArc; private EditText etNativeArcWhitelist; private SwitchCompat swWebp; + private SwitchCompat swAnimate; private SwitchCompat swEasyCorrect; private SwitchCompat swInfra; private SwitchCompat swTldFlags; @@ -282,7 +283,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "max_backoff_power", "logarithmic_backoff", "exact_alarms", "native_dkim", "native_arc", "native_arc_whitelist", - "webp", "easy_correct", "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", + "webp", "animate_images", + "easy_correct", "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", "app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape", "delete_confirmation", "global_keywords", "test_iab" }; @@ -447,6 +449,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swNativeArc = view.findViewById(R.id.swNativeArc); etNativeArcWhitelist = view.findViewById(R.id.etNativeArcWhitelist); swWebp = view.findViewById(R.id.swWebp); + swAnimate = view.findViewById(R.id.swAnimate); swEasyCorrect = view.findViewById(R.id.swEasyCorrect); swInfra = view.findViewById(R.id.swInfra); swTldFlags = view.findViewById(R.id.swTldFlags); @@ -1530,6 +1533,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swAnimate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("animate_images", checked).apply(); + } + }); + swEasyCorrect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -2351,6 +2361,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc etNativeArcWhitelist.setEnabled(swNativeDkim.isEnabled() && swNativeDkim.isChecked()); etNativeArcWhitelist.setText(prefs.getString("native_arc_whitelist", null)); swWebp.setChecked(prefs.getBoolean("webp", true)); + swAnimate.setChecked(prefs.getBoolean("animate_images", true)); swEasyCorrect.setChecked(prefs.getBoolean("easy_correct", false)); swInfra.setChecked(prefs.getBoolean("infra", false)); swTldFlags.setChecked(prefs.getBoolean("tld_flags", false)); diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index 4038e191b6..0fab6a347d 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -302,7 +302,8 @@ class ImageHelper { } static Drawable decodeImage(final Context context, final long id, String source, boolean show, int zoom, final float scale, final TextView view) { - return decodeImage(context, id, source, 0, 0, false, show, zoom, scale, view); + Drawable d = decodeImage(context, id, source, 0, 0, false, show, zoom, scale, view); + return animate(context, d); } static Drawable decodeImage(final Context context, final long id, Element img, boolean show, int zoom, final float scale, final TextView view) { @@ -310,7 +311,8 @@ class ImageHelper { Integer w = Helper.parseInt(img.attr("width")); Integer h = Helper.parseInt(img.attr("height")); boolean tracking = !TextUtils.isEmpty(img.attr("x-tracking")); - return decodeImage(context, id, source, w == null ? 0 : w, h == null ? 0 : h, tracking, show, zoom, scale, view); + Drawable d = decodeImage(context, id, source, w == null ? 0 : w, h == null ? 0 : h, tracking, show, zoom, scale, view); + return animate(context, d); } private static Drawable decodeImage(final Context context, final long id, @@ -528,10 +530,7 @@ class ImageHelper { lld.setBounds(0, 0, bounds.width(), bounds.height()); lld.setLevel(0); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - if (d instanceof AnimatedImageDrawable) - ((AnimatedImageDrawable) d).start(); - } + animate(context, d); view.setText(view.getText()); @@ -869,6 +868,20 @@ class ImageHelper { return bm; } + static Drawable animate(Context context, Drawable drawable) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) + return drawable; + + if (drawable instanceof AnimatedImageDrawable) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean animate_images = prefs.getBoolean("animate_images", true); + if (animate_images) + ((AnimatedImageDrawable) drawable).start(); + } + + return drawable; + } + static Matrix getImageRotation(File file) { try { ExifInterface exif = new ExifInterface(file); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 07ac1578c9..8f4db07f52 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -1568,6 +1568,17 @@ app:layout_constraintTop_toBottomOf="@id/etNativeArcWhitelist" app:switchPadding="12dp" /> + + Native DKIM verification Native ARC verification WebP + Animate images (GIF, etc.) Easy correct Show infrastructure Show TLD flags