Search in sources :

Example 1 with DecryptableUri

use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by signalapp.

the class ScribbleView method getRenderedImage.

@SuppressLint("StaticFieldLeak")
@NonNull
public ListenableFuture<Bitmap> getRenderedImage(@NonNull GlideRequests glideRequests) {
    final SettableFuture<Bitmap> future = new SettableFuture<>();
    final Context context = getContext();
    final boolean isLowMemory = Util.isLowMemory(context);
    if (imageUri == null) {
        future.set(null);
        return future;
    }
    new AsyncTask<Void, Void, Bitmap>() {

        @Override
        @Nullable
        protected Bitmap doInBackground(Void... params) {
            try {
                int width = Target.SIZE_ORIGINAL;
                int height = Target.SIZE_ORIGINAL;
                if (isLowMemory) {
                    width = 768;
                    height = 768;
                }
                return glideRequests.asBitmap().load(new DecryptableUri(imageUri)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(width, height).get();
            } catch (InterruptedException | ExecutionException e) {
                Log.w(TAG, e);
                return null;
            }
        }

        @Override
        protected void onPostExecute(@Nullable Bitmap bitmap) {
            if (bitmap == null) {
                future.set(null);
                return;
            }
            Canvas canvas = new Canvas(bitmap);
            motionView.render(canvas);
            canvasView.render(canvas);
            future.set(bitmap);
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) Context(android.content.Context) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri) Nullable(android.support.annotation.Nullable) NonNull(android.support.annotation.NonNull) SuppressLint(android.annotation.SuppressLint)

Example 2 with DecryptableUri

use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.

the class ThumbnailView method buildThumbnailGlideRequest.

private GlideRequest buildThumbnailGlideRequest(@NonNull GlideRequests glideRequests, @NonNull Slide slide) {
    GlideRequest request = applySizing(glideRequests.load(new DecryptableUri(slide.getUri())).diskCacheStrategy(DiskCacheStrategy.RESOURCE).transition(withCrossFade()), fit);
    boolean doNotShowMissingThumbnailImage = Build.VERSION.SDK_INT < 23;
    if (slide.isInProgress() || doNotShowMissingThumbnailImage)
        return request;
    else
        return request.apply(RequestOptions.errorOf(R.drawable.ic_missing_thumbnail_picture));
}
Also used : GlideRequest(org.thoughtcrime.securesms.mms.GlideRequest) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri)

Example 3 with DecryptableUri

use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.

the class ThumbnailView method setImageResource.

public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri, int width, int height) {
    SettableFuture<Boolean> future = new SettableFuture<>();
    if (transferControls.isPresent())
        getTransferControls().setVisibility(View.GONE);
    GlideRequest request = glideRequests.load(new DecryptableUri(uri)).diskCacheStrategy(DiskCacheStrategy.NONE).transition(withCrossFade());
    if (width > 0 && height > 0) {
        request = request.override(width, height);
    }
    if (radius > 0) {
        request = request.transforms(new CenterCrop(), new RoundedCorners(radius));
    } else {
        request = request.transforms(new CenterCrop());
    }
    request.into(new GlideDrawableListeningTarget(image, future));
    blurhash.setImageDrawable(null);
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) GlideRequest(org.thoughtcrime.securesms.mms.GlideRequest) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri) CenterCrop(com.bumptech.glide.load.resource.bitmap.CenterCrop) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 4 with DecryptableUri

use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.

the class ZoomingImageView method setImageViewUri.

private void setImageViewUri(@NonNull GlideRequests glideRequests, @NonNull Uri uri) {
    photoView.setVisibility(View.VISIBLE);
    subsamplingImageView.setVisibility(View.GONE);
    glideRequests.load(new DecryptableUri(uri)).diskCacheStrategy(DiskCacheStrategy.NONE).dontTransform().override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).into(photoView);
}
Also used : DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri)

Example 5 with DecryptableUri

use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.

the class CameraXFragment method presentRecentItemThumbnail.

private void presentRecentItemThumbnail(Optional<Media> media) {
    if (media == null) {
        return;
    }
    ImageView thumbnail = controlsContainer.findViewById(R.id.camera_gallery_button);
    if (media.isPresent()) {
        thumbnail.setVisibility(View.VISIBLE);
        Glide.with(this).load(new DecryptableUri(media.get().getUri())).centerCrop().into(thumbnail);
    } else {
        thumbnail.setVisibility(View.GONE);
        thumbnail.setImageResource(0);
    }
}
Also used : DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri) ImageView(android.widget.ImageView)

Aggregations

DecryptableUri (org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri)11 Bitmap (android.graphics.Bitmap)3 SettableFuture (org.thoughtcrime.securesms.util.concurrent.SettableFuture)3 Context (android.content.Context)2 Canvas (android.graphics.Canvas)2 NonNull (android.support.annotation.NonNull)2 Nullable (android.support.annotation.Nullable)2 ImageView (android.widget.ImageView)2 GlideRequest (org.thoughtcrime.securesms.mms.GlideRequest)2 SuppressLint (android.annotation.SuppressLint)1 Pair (android.util.Pair)1 WorkerThread (androidx.annotation.WorkerThread)1 ExifInterface (androidx.exifinterface.media.ExifInterface)1 CenterCrop (com.bumptech.glide.load.resource.bitmap.CenterCrop)1 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)1 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)1 GifDrawable (com.bumptech.glide.load.resource.gif.GifDrawable)1 GlideDrawableImageViewTarget (com.bumptech.glide.request.target.GlideDrawableImageViewTarget)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1