Merge pull request #3936 from deltachat/adb/remove-awebp-dep

remove dependency for awebp, it is supported by Android
This commit is contained in:
adb
2025-10-09 15:01:38 +02:00
committed by GitHub
4 changed files with 0 additions and 144 deletions
-1
View File
@@ -174,7 +174,6 @@ dependencies {
implementation ('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false } // QR Code scanner
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.1' // used as JSON library
implementation 'com.github.Baseflow:PhotoView:2.3.0' // does the zooming on photos / media
implementation 'com.github.penfeizhou.android.animation:awebp:3.0.5' // animated webp support.
implementation 'com.caverock:androidsvg-aar:1.4' // SVG support.
implementation 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
@@ -1,44 +0,0 @@
package org.thoughtcrime.securesms.glide.webp;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.drawable.DrawableResource;
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
import com.github.penfeizhou.animation.webp.WebPDrawable;
import com.github.penfeizhou.animation.webp.decode.WebPDecoder;
public class WebpDrawableTranscoder implements ResourceTranscoder<WebPDecoder, Drawable> {
@Nullable
@Override
public Resource<Drawable> transcode(@NonNull Resource<WebPDecoder> toTranscode, @NonNull Options options) {
final WebPDrawable webPDrawable = new WebPDrawable(toTranscode.get());
webPDrawable.setAutoPlay(true);
return new DrawableResource<Drawable>(webPDrawable) {
@NonNull
@Override
public Class<Drawable> getResourceClass() {
return Drawable.class;
}
@Override
public int getSize() {
return webPDrawable.getMemorySize();
}
@Override
public void recycle() {
webPDrawable.stop();
}
@Override
public void initialize() {
super.initialize();
}
};
}
}
@@ -1,92 +0,0 @@
package org.thoughtcrime.securesms.glide.webp;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.github.penfeizhou.animation.io.StreamReader;
import com.github.penfeizhou.animation.loader.ByteBufferLoader;
import com.github.penfeizhou.animation.loader.Loader;
import com.github.penfeizhou.animation.webp.decode.WebPDecoder;
import com.github.penfeizhou.animation.webp.decode.WebPParser;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
public class WebpLoader implements ResourceDecoder<InputStream, WebPDecoder> {
@Override
public boolean handles(@NonNull InputStream source, @NonNull Options options) {
return WebPParser.isAWebP(new StreamReader(source));
}
@Nullable
@Override
public Resource<WebPDecoder> decode(@NonNull final InputStream source, int width, int height, @NonNull Options options) throws IOException {
byte[] data = inputStreamToBytes(source);
if (data == null) {
return null;
}
ByteBuffer byteBuffer = ByteBuffer.wrap(data);
Loader loader = new ByteBufferLoader() {
@Override
public ByteBuffer getByteBuffer() {
byteBuffer.position(0);
return byteBuffer;
}
};
return new WebPDecoderResource(new WebPDecoder(loader, null), byteBuffer.limit());
}
private static byte[] inputStreamToBytes(InputStream is) {
final int bufferSize = 16384;
ByteArrayOutputStream buffer = new ByteArrayOutputStream(bufferSize);
try {
int nRead;
byte[] data = new byte[bufferSize];
while ((nRead = is.read(data)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
} catch (IOException e) {
return null;
}
return buffer.toByteArray();
}
private static class WebPDecoderResource implements Resource<WebPDecoder> {
private final WebPDecoder decoder;
private final int size;
WebPDecoderResource(WebPDecoder decoder, int size) {
this.decoder = decoder;
this.size = size;
}
@NonNull
@Override
public Class<WebPDecoder> getResourceClass() {
return WebPDecoder.class;
}
@NonNull
@Override
public WebPDecoder get() {
return this.decoder;
}
@Override
public int getSize() {
return this.size;
}
@Override
public void recycle() {
this.decoder.stop();
}
}
}
@@ -12,12 +12,9 @@ import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.model.UnitModelLoader;
import com.bumptech.glide.module.AppGlideModule;
import com.github.penfeizhou.animation.webp.decode.WebPDecoder;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
import org.thoughtcrime.securesms.glide.ContactPhotoLoader;
import org.thoughtcrime.securesms.glide.webp.WebpDrawableTranscoder;
import org.thoughtcrime.securesms.glide.webp.WebpLoader;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import java.io.File;
@@ -53,9 +50,5 @@ public class SignalGlideModule extends AppGlideModule {
registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context));
registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context));
//registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
registry
.prepend(InputStream.class, WebPDecoder.class, new WebpLoader())
.register(WebPDecoder.class, Drawable.class, new WebpDrawableTranscoder());
}
}