Search in sources :

Example 6 with DecryptableUri

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

the class ScribbleView method getRenderedImage.

@NonNull
public ListenableFuture<Bitmap> getRenderedImage() {
    final SettableFuture<Bitmap> future = new SettableFuture<>();
    final Context context = getContext();
    final boolean isLowMemory = Util.isLowMemory(context);
    if (imageUri == null || masterSecret == 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 Glide.with(context).load(new DecryptableUri(masterSecret, imageUri)).asBitmap().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);
        }
    }.execute();
    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)

Example 7 with DecryptableUri

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

the class ZoomingImageView method setImageViewUri.

private void setImageViewUri(MasterSecret masterSecret, Uri uri) {
    subsamplingImageView.setVisibility(View.GONE);
    imageView.setVisibility(View.VISIBLE);
    Glide.with(getContext()).load(new DecryptableUri(masterSecret, uri)).diskCacheStrategy(DiskCacheStrategy.NONE).dontTransform().dontAnimate().into(new GlideDrawableImageViewTarget(imageView) {

        @Override
        protected void setResource(GlideDrawable resource) {
            super.setResource(resource);
            imageViewAttacher.update();
        }
    });
}
Also used : GlideDrawableImageViewTarget(com.bumptech.glide.request.target.GlideDrawableImageViewTarget) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 8 with DecryptableUri

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

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 9 with DecryptableUri

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

the class QuoteView method setQuoteAttachment.

private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull SlideDeck slideDeck) {
    Slide imageVideoSlide = slideDeck.getSlides().stream().filter(s -> s.hasImage() || s.hasVideo() || s.hasSticker()).findFirst().orElse(null);
    Slide documentSlide = slideDeck.getSlides().stream().filter(Slide::hasDocument).findFirst().orElse(null);
    Slide viewOnceSlide = slideDeck.getSlides().stream().filter(Slide::hasViewOnce).findFirst().orElse(null);
    attachmentVideoOverlayView.setVisibility(GONE);
    if (viewOnceSlide != null) {
        thumbnailView.setVisibility(GONE);
        attachmentContainerView.setVisibility(GONE);
    } else if (imageVideoSlide != null && imageVideoSlide.getUri() != null) {
        thumbnailView.setVisibility(VISIBLE);
        attachmentContainerView.setVisibility(GONE);
        dismissView.setBackgroundResource(R.drawable.dismiss_background);
        if (imageVideoSlide.hasVideo() && !imageVideoSlide.isVideoGif()) {
            attachmentVideoOverlayView.setVisibility(VISIBLE);
        }
        glideRequests.load(new DecryptableUri(imageVideoSlide.getUri())).centerCrop().override(getContext().getResources().getDimensionPixelSize(R.dimen.quote_thumb_size)).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(thumbnailView);
    } else if (documentSlide != null) {
        thumbnailView.setVisibility(GONE);
        attachmentContainerView.setVisibility(VISIBLE);
        attachmentNameView.setText(documentSlide.getFileName().or(""));
    } else {
        thumbnailView.setVisibility(GONE);
        attachmentContainerView.setVisibility(GONE);
        dismissView.setBackgroundDrawable(null);
    }
    if (ThemeUtil.isDarkTheme(getContext())) {
        dismissView.setBackgroundResource(R.drawable.circle_alpha);
    }
}
Also used : Slide(org.thoughtcrime.securesms.mms.Slide) DecryptableUri(org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri)

Example 10 with DecryptableUri

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

the class Camera1Fragment 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