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