Added setting to disable image animation

This commit is contained in:
M66B
2023-11-12 12:08:15 +01:00
parent a041d57814
commit b38fe9e4ff
6 changed files with 46 additions and 21 deletions

View File

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