mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 08:19:03 +00:00
committed by
Moxie Marlinspike
parent
daa98107c3
commit
c2e5f4e80a
@@ -43,7 +43,7 @@ public class ImageSlide extends Slide {
|
||||
|
||||
@Override
|
||||
public Uri getThumbnailUri() {
|
||||
if (!getPart().isPendingPush() && getPart().getDataUri() != null) {
|
||||
if (getPart().getDataUri() != null) {
|
||||
return isDraft()
|
||||
? getPart().getDataUri()
|
||||
: PartAuthority.getThumbnailUri(getPart().getPartId());
|
||||
|
||||
@@ -80,7 +80,7 @@ public class IncomingMediaMessage {
|
||||
media.setName(Util.toIsoBytes(relay.get()));
|
||||
}
|
||||
|
||||
media.setPendingPush(true);
|
||||
media.setInProgress(true);
|
||||
|
||||
this.body.addPart(media);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ public class OutgoingMediaMessage {
|
||||
media.setContentType(Util.toIsoBytes(attachment.getContentType()));
|
||||
media.setContentLocation(Util.toIsoBytes(String.valueOf(attachment.asPointer().getId())));
|
||||
media.setContentDisposition(Util.toIsoBytes(Base64.encodeBytes(encryptedKey)));
|
||||
media.setPendingPush(true);
|
||||
|
||||
body.addPart(media);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.content.res.Resources.Theme;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -75,6 +74,10 @@ public abstract class Slide {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInProgress() {
|
||||
return part.isInProgress();
|
||||
}
|
||||
|
||||
public @DrawableRes int getPlaceholderRes(Theme theme) {
|
||||
throw new AssertionError("getPlaceholderRes() called for non-drawable slide");
|
||||
}
|
||||
@@ -108,6 +111,7 @@ public abstract class Slide {
|
||||
this.hasImage() == that.hasImage() &&
|
||||
this.hasVideo() == that.hasVideo() &&
|
||||
this.isDraft() == that.isDraft() &&
|
||||
this.isInProgress() == that.isInProgress() &&
|
||||
Util.equals(this.getUri(), that.getUri()) &&
|
||||
Util.equals(this.getThumbnailUri(), that.getThumbnailUri());
|
||||
}
|
||||
|
||||
@@ -65,7 +65,8 @@ public class SlideDeck {
|
||||
PduBody body = new PduBody();
|
||||
|
||||
for (Slide slide : slides) {
|
||||
body.addPart(slide.getPart());
|
||||
PduPart part = slide.getPart();
|
||||
body.addPart(part);
|
||||
}
|
||||
|
||||
return body;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package org.thoughtcrime.securesms.mms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
||||
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
|
||||
|
||||
public class ThumbnailTransform extends BitmapTransformation {
|
||||
private static final String TAG = ThumbnailTransform.class.getSimpleName();
|
||||
|
||||
public ThumbnailTransform(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ThumbnailTransform(BitmapPool bitmapPool) {
|
||||
super(bitmapPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
|
||||
if (toTransform.getWidth() < (outWidth / 2) && toTransform.getHeight() < (outHeight / 2)) {
|
||||
return toTransform;
|
||||
}
|
||||
|
||||
final float inAspectRatio = (float) toTransform.getWidth() / toTransform.getHeight();
|
||||
final float outAspectRatio = (float) outWidth / outHeight;
|
||||
if (inAspectRatio < outAspectRatio) {
|
||||
outWidth = (int)(outHeight * inAspectRatio);
|
||||
}
|
||||
|
||||
final Bitmap toReuse = pool.get(outWidth, outHeight, toTransform.getConfig() != null
|
||||
? toTransform.getConfig()
|
||||
: Bitmap.Config.ARGB_8888);
|
||||
Bitmap transformed = TransformationUtils.centerCrop(toReuse, toTransform, outWidth, outHeight);
|
||||
if (toReuse != null && toReuse != transformed && !pool.put(toReuse)) {
|
||||
toReuse.recycle();
|
||||
}
|
||||
return transformed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ThumbnailTransform.class.getCanonicalName();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user