mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
show attachment emoji in conversation previews
This commit is contained in:
parent
4a740780ca
commit
f42855f43e
@ -620,13 +620,18 @@ public class ThreadDatabase extends Database {
|
||||
private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) {
|
||||
if (messageRecord.isMms()) {
|
||||
MmsMessageRecord record = (MmsMessageRecord) messageRecord;
|
||||
if (record.getSlideDeck().getBody())
|
||||
if (record.getSharedContacts().size() > 0) {
|
||||
Contact contact = ((MmsMessageRecord) messageRecord).getSharedContacts().get(0);
|
||||
return ContactUtil.getStringSummary(context, contact).toString();
|
||||
}
|
||||
String attachmentString = record.getSlideDeck().getBody();
|
||||
if (!attachmentString.isEmpty()) {
|
||||
if (!messageRecord.getBody().isEmpty()) {
|
||||
attachmentString = attachmentString + ": " + messageRecord.getBody();
|
||||
}
|
||||
return attachmentString;
|
||||
}
|
||||
}
|
||||
|
||||
return messageRecord.getBody();
|
||||
}
|
||||
|
||||
|
@ -146,13 +146,10 @@ public class OutgoingMediaMessage {
|
||||
}
|
||||
|
||||
private static String buildMessage(SlideDeck slideDeck, String message) {
|
||||
if (!TextUtils.isEmpty(message) && !TextUtils.isEmpty(slideDeck.getBody())) {
|
||||
return slideDeck.getBody() + "\n\n" + message;
|
||||
} else if (!TextUtils.isEmpty(message)) {
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
return message;
|
||||
} else {
|
||||
return slideDeck.getBody();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ import android.net.Uri;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
@ -64,7 +62,7 @@ public abstract class Slide {
|
||||
public Optional<String> getBody() {
|
||||
String attachmentString = context.getString(R.string.attachment);
|
||||
|
||||
if (MimeTypes.isAudio(attachment.getContentType())) {
|
||||
if (MediaUtil.isAudio(attachment)) {
|
||||
// a missing filename is the legacy way to determine if an audio attachment is
|
||||
// a voice note vs. other arbitrary audio attachments.
|
||||
if (attachment.isVoiceNote() || !attachment.getFileName().isEmpty()) {
|
||||
@ -72,20 +70,20 @@ public abstract class Slide {
|
||||
return Optional.fromNullable("🎤 " + attachmentString);
|
||||
}
|
||||
}
|
||||
return Optional.fromNullable(emojiForMimeType(attachment.getContentType()) + attachmentString);
|
||||
return Optional.fromNullable(emojiForMimeType() + attachmentString);
|
||||
}
|
||||
|
||||
private String emojiForMimeType(String contentType) {
|
||||
if (MimeTypes.isVideo(contentType)) {
|
||||
private String emojiForMimeType() {
|
||||
if (MediaUtil.isImage(attachment)) {
|
||||
return "📷 ";
|
||||
} else if (MimeTypes.isVideo(contentType)) {
|
||||
} else if (MediaUtil.isVideo(attachment)) {
|
||||
return "🎥 ";
|
||||
} else if (MimeTypes.isAudio(contentType)) {
|
||||
} else if (MediaUtil.isAudio(attachment)) {
|
||||
return "🎧 ";
|
||||
} else if (MimeTypes.is) {
|
||||
return "🎡 ";
|
||||
} else {
|
||||
} else if (MediaUtil.isFile(attachment)) {
|
||||
return "📎 ";
|
||||
} else {
|
||||
return "🎡 ";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user