mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 01:21:09 +00:00
committed by
Moxie Marlinspike
parent
761ccf4b3f
commit
073d019103
@@ -22,10 +22,6 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
import org.thoughtcrime.securesms.util.SmilUtil;
|
||||
import org.w3c.dom.smil.SMILDocument;
|
||||
import org.w3c.dom.smil.SMILMediaElement;
|
||||
import org.w3c.dom.smil.SMILRegionElement;
|
||||
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
import android.content.Context;
|
||||
@@ -55,16 +51,6 @@ public class AudioSlide extends Slide {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILRegionElement getSmilRegion(SMILDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILMediaElement getMediaElement(SMILDocument document) {
|
||||
return SmilUtil.createMediaElement("audio", document, new String(getPart().getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFutureTask<Pair<Drawable,Boolean>> getThumbnail(Context context) {
|
||||
return new ListenableFutureTask<>(new Pair<>(ResUtil.getDrawable(context, R.attr.conversation_icon_attach_audio), true));
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@@ -31,11 +30,6 @@ import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||
import org.thoughtcrime.securesms.util.LRUCache;
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
import org.thoughtcrime.securesms.util.SmilUtil;
|
||||
import org.w3c.dom.smil.SMILDocument;
|
||||
import org.w3c.dom.smil.SMILMediaElement;
|
||||
import org.w3c.dom.smil.SMILRegionElement;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -131,23 +125,6 @@ public class ImageSlide extends Slide {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILRegionElement getSmilRegion(SMILDocument document) {
|
||||
SMILRegionElement region = (SMILRegionElement) document.createElement("region");
|
||||
region.setId("Image");
|
||||
region.setLeft(0);
|
||||
region.setTop(0);
|
||||
region.setWidth(SmilUtil.ROOT_WIDTH);
|
||||
region.setHeight(SmilUtil.ROOT_HEIGHT);
|
||||
region.setFit("meet");
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILMediaElement getMediaElement(SMILDocument document) {
|
||||
return SmilUtil.createMediaElement("img", document, new String(getPart().getName()));
|
||||
}
|
||||
|
||||
private static PduPart constructPartFromUri(Uri uri)
|
||||
throws IOException, BitmapDecodingException
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import ws.com.google.android.mms.ContentType;
|
||||
import ws.com.google.android.mms.pdu.CharacterSets;
|
||||
import ws.com.google.android.mms.pdu.PduBody;
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
|
||||
public class PartParser {
|
||||
public static String getMessageText(PduBody body) {
|
||||
@@ -45,7 +46,7 @@ public class PartParser {
|
||||
PduBody stripped = new PduBody();
|
||||
|
||||
for (int i=0;i<body.getPartsNum();i++) {
|
||||
if (isDisplayableMedia(Util.toIsoString(body.getPart(i).getContentType()))) {
|
||||
if (isDisplayableMedia(body.getPart(i))) {
|
||||
stripped.addPart(body.getPart(i));
|
||||
}
|
||||
}
|
||||
@@ -57,9 +58,7 @@ public class PartParser {
|
||||
int partCount = 0;
|
||||
|
||||
for (int i=0;i<body.getPartsNum();i++) {
|
||||
String contentType = Util.toIsoString(body.getPart(i).getContentType());
|
||||
|
||||
if (isDisplayableMedia(contentType)) {
|
||||
if (isDisplayableMedia(body.getPart(i))) {
|
||||
partCount++;
|
||||
}
|
||||
}
|
||||
@@ -67,9 +66,23 @@ public class PartParser {
|
||||
return partCount;
|
||||
}
|
||||
|
||||
private static boolean isDisplayableMedia(String contentType) {
|
||||
return ContentType.isImageType(contentType) ||
|
||||
ContentType.isAudioType(contentType) ||
|
||||
ContentType.isVideoType(contentType);
|
||||
public static boolean isImage(PduPart part) {
|
||||
return ContentType.isImageType(Util.toIsoString(part.getContentType()));
|
||||
}
|
||||
|
||||
public static boolean isAudio(PduPart part) {
|
||||
return ContentType.isAudioType(Util.toIsoString(part.getContentType()));
|
||||
}
|
||||
|
||||
public static boolean isVideo(PduPart part) {
|
||||
return ContentType.isVideoType(Util.toIsoString(part.getContentType()));
|
||||
}
|
||||
|
||||
public static boolean isText(PduPart part) {
|
||||
return ContentType.isTextType(Util.toIsoString(part.getContentType()));
|
||||
}
|
||||
|
||||
public static boolean isDisplayableMedia(PduPart part) {
|
||||
return isImage(part) || isAudio(part) || isVideo(part);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@ import java.io.InputStream;
|
||||
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.w3c.dom.smil.SMILDocument;
|
||||
import org.w3c.dom.smil.SMILMediaElement;
|
||||
import org.w3c.dom.smil.SMILRegionElement;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -103,10 +100,6 @@ public abstract class Slide {
|
||||
return part;
|
||||
}
|
||||
|
||||
public abstract SMILRegionElement getSmilRegion(SMILDocument document);
|
||||
|
||||
public abstract SMILMediaElement getMediaElement(SMILDocument document);
|
||||
|
||||
protected static void assertMediaSize(Context context, Uri uri)
|
||||
throws MediaTooLargeException, IOException
|
||||
{
|
||||
|
||||
@@ -68,15 +68,6 @@ public class SlideDeck {
|
||||
body.addPart(slide.getPart());
|
||||
}
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
SmilXmlSerializer.serialize(SmilUtil.createSmilDocument(this), out);
|
||||
PduPart smilPart = new PduPart();
|
||||
smilPart.setContentId("smil".getBytes());
|
||||
smilPart.setContentLocation("smil.xml".getBytes());
|
||||
smilPart.setContentType(ContentType.APP_SMIL.getBytes());
|
||||
smilPart.setData(out.toByteArray());
|
||||
body.addPart(0, smilPart);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,23 +80,6 @@ public class TextSlide extends Slide {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILRegionElement getSmilRegion(SMILDocument document) {
|
||||
SMILRegionElement region = (SMILRegionElement) document.createElement("region");
|
||||
region.setId("Text");
|
||||
region.setLeft(0);
|
||||
region.setTop(SmilUtil.ROOT_HEIGHT);
|
||||
region.setWidth(SmilUtil.ROOT_WIDTH);
|
||||
region.setHeight(50);
|
||||
region.setFit("meet");
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILMediaElement getMediaElement(SMILDocument document) {
|
||||
return SmilUtil.createMediaElement("text", document, new String(getPart().getName()));
|
||||
}
|
||||
|
||||
private static PduPart getPartForMessage(String message) {
|
||||
PduPart part = new PduPart();
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
import org.thoughtcrime.securesms.util.SmilUtil;
|
||||
import org.w3c.dom.smil.SMILDocument;
|
||||
import org.w3c.dom.smil.SMILMediaElement;
|
||||
import org.w3c.dom.smil.SMILRegionElement;
|
||||
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
import android.content.ContentResolver;
|
||||
@@ -62,23 +58,6 @@ public class VideoSlide extends Slide {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILRegionElement getSmilRegion(SMILDocument document) {
|
||||
SMILRegionElement region = (SMILRegionElement) document.createElement("region");
|
||||
region.setId("Image");
|
||||
region.setLeft(0);
|
||||
region.setTop(0);
|
||||
region.setWidth(SmilUtil.ROOT_WIDTH);
|
||||
region.setHeight(SmilUtil.ROOT_HEIGHT);
|
||||
region.setFit("meet");
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SMILMediaElement getMediaElement(SMILDocument document) {
|
||||
return SmilUtil.createMediaElement("video", document, new String(getPart().getName()));
|
||||
}
|
||||
|
||||
private static PduPart constructPartFromUri(Context context, Uri uri)
|
||||
throws IOException, MediaTooLargeException
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user