Search in sources :

Example 1 with EncryptedGifDrawableResourceEncoder

use of org.thoughtcrime.securesms.glide.cache.EncryptedGifDrawableResourceEncoder in project Signal-Android by WhisperSystems.

the class SignalGlideComponents method registerComponents.

@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
    AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
    byte[] secret = attachmentSecret.getModernKey();
    registry.prepend(File.class, File.class, UnitModelLoader.Factory.getInstance());
    registry.prepend(InputStream.class, new EncryptedCacheEncoder(secret, glide.getArrayPool()));
    registry.prepend(Bitmap.class, new EncryptedBitmapResourceEncoder(secret));
    registry.prepend(File.class, Bitmap.class, new EncryptedCacheDecoder<>(secret, new StreamBitmapDecoder(new Downsampler(registry.getImageHeaderParsers(), context.getResources().getDisplayMetrics(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool())));
    registry.prepend(GifDrawable.class, new EncryptedGifDrawableResourceEncoder(secret));
    registry.prepend(File.class, GifDrawable.class, new EncryptedCacheDecoder<>(secret, new StreamGifDecoder(registry.getImageHeaderParsers(), new ByteBufferGifDecoder(context, registry.getImageHeaderParsers(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool())));
    ApngBufferCacheDecoder apngBufferCacheDecoder = new ApngBufferCacheDecoder();
    ApngStreamCacheDecoder apngStreamCacheDecoder = new ApngStreamCacheDecoder(apngBufferCacheDecoder);
    registry.prepend(InputStream.class, APNGDecoder.class, apngStreamCacheDecoder);
    registry.prepend(ByteBuffer.class, APNGDecoder.class, apngBufferCacheDecoder);
    registry.prepend(APNGDecoder.class, new EncryptedApngCacheEncoder(secret));
    registry.prepend(File.class, APNGDecoder.class, new EncryptedCacheDecoder<>(secret, apngStreamCacheDecoder));
    registry.register(APNGDecoder.class, Drawable.class, new ApngFrameDrawableTranscoder());
    registry.prepend(BlurHash.class, Bitmap.class, new BlurHashResourceDecoder());
    registry.append(ConversationShortcutPhoto.class, Bitmap.class, new ConversationShortcutPhoto.Loader.Factory(context));
    registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context));
    registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context));
    registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
    registry.append(ChunkedImageUrl.class, InputStream.class, new ChunkedImageUrlLoader.Factory());
    registry.append(StickerRemoteUri.class, InputStream.class, new StickerRemoteUriLoader.Factory());
    registry.append(BlurHash.class, BlurHash.class, new BlurHashModelLoader.Factory());
    registry.append(Badge.class, InputStream.class, BadgeLoader.createFactory());
    registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
Also used : OkHttpUrlLoader(org.thoughtcrime.securesms.glide.OkHttpUrlLoader) BlurHashModelLoader(org.thoughtcrime.securesms.blurhash.BlurHashModelLoader) ApngStreamCacheDecoder(org.thoughtcrime.securesms.glide.cache.ApngStreamCacheDecoder) Downsampler(com.bumptech.glide.load.resource.bitmap.Downsampler) BadgeLoader(org.thoughtcrime.securesms.glide.BadgeLoader) ChunkedImageUrlLoader(org.thoughtcrime.securesms.glide.ChunkedImageUrlLoader) ContactPhotoLoader(org.thoughtcrime.securesms.glide.ContactPhotoLoader) StickerRemoteUriLoader(org.thoughtcrime.securesms.stickers.StickerRemoteUriLoader) UnitModelLoader(com.bumptech.glide.load.model.UnitModelLoader) OkHttpUrlLoader(org.thoughtcrime.securesms.glide.OkHttpUrlLoader) BlurHashModelLoader(org.thoughtcrime.securesms.blurhash.BlurHashModelLoader) StreamGifDecoder(com.bumptech.glide.load.resource.gif.StreamGifDecoder) EncryptedApngCacheEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedApngCacheEncoder) EncryptedCacheEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedCacheEncoder) StreamBitmapDecoder(com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder) ChunkedImageUrlLoader(org.thoughtcrime.securesms.glide.ChunkedImageUrlLoader) ApngBufferCacheDecoder(org.thoughtcrime.securesms.glide.cache.ApngBufferCacheDecoder) ApngFrameDrawableTranscoder(org.thoughtcrime.securesms.glide.cache.ApngFrameDrawableTranscoder) ByteBufferGifDecoder(com.bumptech.glide.load.resource.gif.ByteBufferGifDecoder) StickerRemoteUriLoader(org.thoughtcrime.securesms.stickers.StickerRemoteUriLoader) EncryptedBitmapResourceEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedBitmapResourceEncoder) EncryptedGifDrawableResourceEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedGifDrawableResourceEncoder) BlurHashResourceDecoder(org.thoughtcrime.securesms.blurhash.BlurHashResourceDecoder) ContactPhotoLoader(org.thoughtcrime.securesms.glide.ContactPhotoLoader) AttachmentSecret(org.thoughtcrime.securesms.crypto.AttachmentSecret)

Example 2 with EncryptedGifDrawableResourceEncoder

use of org.thoughtcrime.securesms.glide.cache.EncryptedGifDrawableResourceEncoder in project Signal-Android by signalapp.

the class SignalGlideComponents method registerComponents.

@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
    AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
    byte[] secret = attachmentSecret.getModernKey();
    registry.prepend(File.class, File.class, UnitModelLoader.Factory.getInstance());
    registry.prepend(InputStream.class, new EncryptedCacheEncoder(secret, glide.getArrayPool()));
    registry.prepend(Bitmap.class, new EncryptedBitmapResourceEncoder(secret));
    registry.prepend(File.class, Bitmap.class, new EncryptedCacheDecoder<>(secret, new StreamBitmapDecoder(new Downsampler(registry.getImageHeaderParsers(), context.getResources().getDisplayMetrics(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool())));
    registry.prepend(GifDrawable.class, new EncryptedGifDrawableResourceEncoder(secret));
    registry.prepend(File.class, GifDrawable.class, new EncryptedCacheDecoder<>(secret, new StreamGifDecoder(registry.getImageHeaderParsers(), new ByteBufferGifDecoder(context, registry.getImageHeaderParsers(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool())));
    ApngBufferCacheDecoder apngBufferCacheDecoder = new ApngBufferCacheDecoder();
    ApngStreamCacheDecoder apngStreamCacheDecoder = new ApngStreamCacheDecoder(apngBufferCacheDecoder);
    registry.prepend(InputStream.class, APNGDecoder.class, apngStreamCacheDecoder);
    registry.prepend(ByteBuffer.class, APNGDecoder.class, apngBufferCacheDecoder);
    registry.prepend(APNGDecoder.class, new EncryptedApngCacheEncoder(secret));
    registry.prepend(File.class, APNGDecoder.class, new EncryptedCacheDecoder<>(secret, apngStreamCacheDecoder));
    registry.register(APNGDecoder.class, Drawable.class, new ApngFrameDrawableTranscoder());
    registry.prepend(BlurHash.class, Bitmap.class, new BlurHashResourceDecoder());
    registry.append(ConversationShortcutPhoto.class, Bitmap.class, new ConversationShortcutPhoto.Loader.Factory(context));
    registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context));
    registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context));
    registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
    registry.append(ChunkedImageUrl.class, InputStream.class, new ChunkedImageUrlLoader.Factory());
    registry.append(StickerRemoteUri.class, InputStream.class, new StickerRemoteUriLoader.Factory());
    registry.append(BlurHash.class, BlurHash.class, new BlurHashModelLoader.Factory());
    registry.append(Badge.class, InputStream.class, BadgeLoader.createFactory());
    registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
Also used : OkHttpUrlLoader(org.thoughtcrime.securesms.glide.OkHttpUrlLoader) BlurHashModelLoader(org.thoughtcrime.securesms.blurhash.BlurHashModelLoader) ApngStreamCacheDecoder(org.thoughtcrime.securesms.glide.cache.ApngStreamCacheDecoder) Downsampler(com.bumptech.glide.load.resource.bitmap.Downsampler) BadgeLoader(org.thoughtcrime.securesms.glide.BadgeLoader) ChunkedImageUrlLoader(org.thoughtcrime.securesms.glide.ChunkedImageUrlLoader) ContactPhotoLoader(org.thoughtcrime.securesms.glide.ContactPhotoLoader) StickerRemoteUriLoader(org.thoughtcrime.securesms.stickers.StickerRemoteUriLoader) UnitModelLoader(com.bumptech.glide.load.model.UnitModelLoader) OkHttpUrlLoader(org.thoughtcrime.securesms.glide.OkHttpUrlLoader) BlurHashModelLoader(org.thoughtcrime.securesms.blurhash.BlurHashModelLoader) StreamGifDecoder(com.bumptech.glide.load.resource.gif.StreamGifDecoder) EncryptedApngCacheEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedApngCacheEncoder) EncryptedCacheEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedCacheEncoder) StreamBitmapDecoder(com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder) ChunkedImageUrlLoader(org.thoughtcrime.securesms.glide.ChunkedImageUrlLoader) ApngBufferCacheDecoder(org.thoughtcrime.securesms.glide.cache.ApngBufferCacheDecoder) ApngFrameDrawableTranscoder(org.thoughtcrime.securesms.glide.cache.ApngFrameDrawableTranscoder) ByteBufferGifDecoder(com.bumptech.glide.load.resource.gif.ByteBufferGifDecoder) StickerRemoteUriLoader(org.thoughtcrime.securesms.stickers.StickerRemoteUriLoader) EncryptedBitmapResourceEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedBitmapResourceEncoder) EncryptedGifDrawableResourceEncoder(org.thoughtcrime.securesms.glide.cache.EncryptedGifDrawableResourceEncoder) BlurHashResourceDecoder(org.thoughtcrime.securesms.blurhash.BlurHashResourceDecoder) ContactPhotoLoader(org.thoughtcrime.securesms.glide.ContactPhotoLoader) AttachmentSecret(org.thoughtcrime.securesms.crypto.AttachmentSecret)

Aggregations

UnitModelLoader (com.bumptech.glide.load.model.UnitModelLoader)2 Downsampler (com.bumptech.glide.load.resource.bitmap.Downsampler)2 StreamBitmapDecoder (com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder)2 ByteBufferGifDecoder (com.bumptech.glide.load.resource.gif.ByteBufferGifDecoder)2 StreamGifDecoder (com.bumptech.glide.load.resource.gif.StreamGifDecoder)2 BlurHashModelLoader (org.thoughtcrime.securesms.blurhash.BlurHashModelLoader)2 BlurHashResourceDecoder (org.thoughtcrime.securesms.blurhash.BlurHashResourceDecoder)2 AttachmentSecret (org.thoughtcrime.securesms.crypto.AttachmentSecret)2 BadgeLoader (org.thoughtcrime.securesms.glide.BadgeLoader)2 ChunkedImageUrlLoader (org.thoughtcrime.securesms.glide.ChunkedImageUrlLoader)2 ContactPhotoLoader (org.thoughtcrime.securesms.glide.ContactPhotoLoader)2 OkHttpUrlLoader (org.thoughtcrime.securesms.glide.OkHttpUrlLoader)2 ApngBufferCacheDecoder (org.thoughtcrime.securesms.glide.cache.ApngBufferCacheDecoder)2 ApngFrameDrawableTranscoder (org.thoughtcrime.securesms.glide.cache.ApngFrameDrawableTranscoder)2 ApngStreamCacheDecoder (org.thoughtcrime.securesms.glide.cache.ApngStreamCacheDecoder)2 EncryptedApngCacheEncoder (org.thoughtcrime.securesms.glide.cache.EncryptedApngCacheEncoder)2 EncryptedBitmapResourceEncoder (org.thoughtcrime.securesms.glide.cache.EncryptedBitmapResourceEncoder)2 EncryptedCacheEncoder (org.thoughtcrime.securesms.glide.cache.EncryptedCacheEncoder)2 EncryptedGifDrawableResourceEncoder (org.thoughtcrime.securesms.glide.cache.EncryptedGifDrawableResourceEncoder)2 StickerRemoteUriLoader (org.thoughtcrime.securesms.stickers.StickerRemoteUriLoader)2