mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add vCard support for received MMS.
This commit is contained in:
@@ -48,7 +48,8 @@ public class IncomingMediaMessage {
|
||||
long expiresIn,
|
||||
boolean expirationUpdate,
|
||||
boolean viewOnce,
|
||||
boolean unidentified)
|
||||
boolean unidentified,
|
||||
Optional<List<Contact>> sharedContacts)
|
||||
{
|
||||
this.from = from;
|
||||
this.groupId = groupId.orNull();
|
||||
@@ -64,6 +65,8 @@ public class IncomingMediaMessage {
|
||||
this.unidentified = unidentified;
|
||||
|
||||
this.attachments.addAll(attachments);
|
||||
this.sharedContacts.addAll(sharedContacts.or(Collections.emptyList()));
|
||||
|
||||
}
|
||||
|
||||
public IncomingMediaMessage(@NonNull RecipientId from,
|
||||
|
||||
@@ -9,17 +9,20 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PartParser {
|
||||
|
||||
private static final String TAG = Log.tag(PartParser.class);
|
||||
private static final String TAG = Log.tag(PartParser.class);
|
||||
private static final List<String> DOCUMENT_TYPES = Arrays.asList("text/vcard", "text/x-vcard");
|
||||
|
||||
public static String getMessageText(PduBody body) {
|
||||
String bodyText = null;
|
||||
|
||||
for (int i=0;i<body.getPartsNum();i++) {
|
||||
if (ContentType.isTextType(Util.toIsoString(body.getPart(i).getContentType()))) {
|
||||
if (isText(body.getPart(i)) && !isDocument(body.getPart(i))) {
|
||||
String partText;
|
||||
|
||||
try {
|
||||
@@ -49,7 +52,7 @@ public class PartParser {
|
||||
PduBody stripped = new PduBody();
|
||||
|
||||
for (int i=0;i<body.getPartsNum();i++) {
|
||||
if (isDisplayableMedia(body.getPart(i))) {
|
||||
if (isDisplayableMedia(body.getPart(i)) || isDocument(body.getPart(i))) {
|
||||
stripped.addPart(body.getPart(i));
|
||||
}
|
||||
}
|
||||
@@ -61,7 +64,7 @@ public class PartParser {
|
||||
int partCount = 0;
|
||||
|
||||
for (int i=0;i<body.getPartsNum();i++) {
|
||||
if (isDisplayableMedia(body.getPart(i))) {
|
||||
if (isDisplayableMedia(body.getPart(i)) || isDocument(body.getPart(i))) {
|
||||
partCount++;
|
||||
}
|
||||
}
|
||||
@@ -88,4 +91,8 @@ public class PartParser {
|
||||
public static boolean isDisplayableMedia(PduPart part) {
|
||||
return isImage(part) || isAudio(part) || isVideo(part);
|
||||
}
|
||||
|
||||
public static boolean isDocument(PduPart part) {
|
||||
return DOCUMENT_TYPES.contains(Util.toIsoString(part.getContentType()).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,10 @@ public abstract class Slide {
|
||||
Optional<String> fileName = getFileName();
|
||||
|
||||
if (fileName.isPresent()) {
|
||||
return Optional.of(getFileType(fileName));
|
||||
String fileType = getFileType(fileName);
|
||||
if (!fileType.isEmpty()) {
|
||||
return Optional.of(fileType);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.fromNullable(MediaUtil.getExtension(context, getUri()));
|
||||
|
||||
Reference in New Issue
Block a user