mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Disable mass APNG animation on low-memory devices.
This commit is contained in:
@@ -20,7 +20,11 @@ public class ApngBufferCacheDecoder implements ResourceDecoder<ByteBuffer, APNGD
|
||||
|
||||
@Override
|
||||
public boolean handles(@NonNull ByteBuffer source, @NonNull Options options) {
|
||||
return APNGParser.isAPNG(new ByteBufferReader(source));
|
||||
if (options.get(ApngOptions.ANIMATE)) {
|
||||
return APNGParser.isAPNG(new ByteBufferReader(source));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
20
app/src/main/java/org/thoughtcrime/securesms/glide/cache/ApngOptions.java
vendored
Normal file
20
app/src/main/java/org/thoughtcrime/securesms/glide/cache/ApngOptions.java
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.thoughtcrime.securesms.glide.cache;
|
||||
|
||||
import com.bumptech.glide.load.Option;
|
||||
|
||||
import org.signal.core.util.Conversions;
|
||||
|
||||
/**
|
||||
* Holds options that can be used to alter how APNGs are decoded in Glide.
|
||||
*/
|
||||
public final class ApngOptions {
|
||||
|
||||
private static final String KEY = "org.signal.skip_apng";
|
||||
|
||||
public static Option<Boolean> ANIMATE = Option.disk(KEY, true, (keyBytes, value, messageDigest) -> {
|
||||
messageDigest.update(keyBytes);
|
||||
messageDigest.update(Conversions.intToByteArray(value ? 1 : 0));
|
||||
});
|
||||
|
||||
private ApngOptions() {}
|
||||
}
|
||||
@@ -26,7 +26,11 @@ public class ApngStreamCacheDecoder implements ResourceDecoder<InputStream, APNG
|
||||
|
||||
@Override
|
||||
public boolean handles(@NonNull InputStream source, @NonNull Options options) {
|
||||
return APNGParser.isAPNG(new StreamReader(source));
|
||||
if (options.get(ApngOptions.ANIMATE)) {
|
||||
return APNGParser.isAPNG(new StreamReader(source));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user