mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 01:21:09 +00:00
@@ -30,6 +30,7 @@ import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -61,8 +62,8 @@ public class AttachmentManager {
|
||||
attachmentListener.onAttachmentChanged();
|
||||
}
|
||||
|
||||
public void setImage(Uri image) throws IOException, BitmapDecodingException {
|
||||
setMedia(new ImageSlide(context, image), 345, 261);
|
||||
public void setImage(MasterSecret masterSecret, Uri image) throws IOException, BitmapDecodingException {
|
||||
setMedia(new ImageSlide(context, masterSecret, image), 345, 261);
|
||||
}
|
||||
|
||||
public void setVideo(Uri video) throws IOException, MediaTooLargeException {
|
||||
|
||||
@@ -60,8 +60,8 @@ public class ImageSlide extends Slide {
|
||||
super(context, masterSecret, part);
|
||||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri) throws IOException, BitmapDecodingException {
|
||||
super(context, constructPartFromUri(context, uri));
|
||||
public ImageSlide(Context context, MasterSecret masterSecret, Uri uri) throws IOException, BitmapDecodingException {
|
||||
super(context, constructPartFromUri(context, masterSecret, uri));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,11 +77,9 @@ public class ImageSlide extends Slide {
|
||||
}
|
||||
|
||||
try {
|
||||
InputStream measureStream = getPartDataInputStream();
|
||||
InputStream dataStream = getPartDataInputStream();
|
||||
|
||||
thumbnail = new BitmapDrawable(context.getResources(), BitmapUtil.createScaledBitmap(measureStream, dataStream, maxWidth, maxHeight));
|
||||
thumbnailCache.put(part.getDataUri(), new SoftReference<Drawable>(thumbnail));
|
||||
thumbnail = new BitmapDrawable(context.getResources(),
|
||||
BitmapUtil.createScaledBitmap(context, masterSecret, getUri(), maxWidth, maxHeight));
|
||||
thumbnailCache.put(part.getDataUri(), new SoftReference<>(thumbnail));
|
||||
|
||||
return thumbnail;
|
||||
} catch (FileNotFoundException e) {
|
||||
@@ -183,11 +181,11 @@ public class ImageSlide extends Slide {
|
||||
return SmilUtil.createMediaElement("img", document, new String(getPart().getName()));
|
||||
}
|
||||
|
||||
private static PduPart constructPartFromUri(Context context, Uri uri)
|
||||
private static PduPart constructPartFromUri(Context context, MasterSecret masterSecret, Uri uri)
|
||||
throws IOException, BitmapDecodingException
|
||||
{
|
||||
PduPart part = new PduPart();
|
||||
byte[] data = BitmapUtil.createScaledBytes(context, uri, 1280, 1280, MAX_MESSAGE_SIZE);
|
||||
byte[] data = BitmapUtil.createScaledBytes(context, masterSecret, uri, 1280, 1280, MAX_MESSAGE_SIZE);
|
||||
|
||||
part.setData(data);
|
||||
part.setDataUri(uri);
|
||||
|
||||
Reference in New Issue
Block a user