mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:33:39 +00:00
Merge pull request #318 from RyanRory/attachment-in-conversation-preview
Show Attachments with Emojis in Conversation Previews
This commit is contained in:
commit
fe85236167
@ -1854,7 +1854,7 @@
|
||||
<string name="dialog_seed_disclaimer">*Please note that it is not possible to use the same Session ID on multiple devices simultaneously</string>
|
||||
|
||||
<string name="view_reset_secure_session_done_message">Secure session reset done</string>
|
||||
|
||||
|
||||
<string name="dialog_ui_mode_title">Theme</string>
|
||||
<string name="dialog_ui_mode_option_day">Day</string>
|
||||
<string name="dialog_ui_mode_option_night">Night</string>
|
||||
@ -1862,4 +1862,8 @@
|
||||
|
||||
<string name="activity_conversation_menu_copy_session_id">Copy Session ID</string>
|
||||
|
||||
<!-- Attachment message -->
|
||||
<string name="attachment">Attachment</string>
|
||||
<string name="attachment_type_voice_message">Voice Message</string>
|
||||
|
||||
</resources>
|
||||
|
@ -618,11 +618,20 @@ public class ThreadDatabase extends Database {
|
||||
}
|
||||
|
||||
private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) {
|
||||
if (messageRecord.isMms() && ((MmsMessageRecord) messageRecord).getSharedContacts().size() > 0) {
|
||||
Contact contact = ((MmsMessageRecord) messageRecord).getSharedContacts().get(0);
|
||||
return ContactUtil.getStringSummary(context, contact).toString();
|
||||
if (messageRecord.isMms()) {
|
||||
MmsMessageRecord record = (MmsMessageRecord) messageRecord;
|
||||
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,7 +22,6 @@ import android.net.Uri;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
@ -33,6 +32,8 @@ import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public abstract class Slide {
|
||||
|
||||
protected final Attachment attachment;
|
||||
@ -59,7 +60,31 @@ public abstract class Slide {
|
||||
|
||||
@NonNull
|
||||
public Optional<String> getBody() {
|
||||
return Optional.absent();
|
||||
String attachmentString = context.getString(R.string.attachment);
|
||||
|
||||
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()) {
|
||||
attachmentString = context.getString(R.string.attachment_type_voice_message);
|
||||
return Optional.fromNullable("🎤 " + attachmentString);
|
||||
}
|
||||
}
|
||||
return Optional.fromNullable(emojiForMimeType() + attachmentString);
|
||||
}
|
||||
|
||||
private String emojiForMimeType() {
|
||||
if (MediaUtil.isImage(attachment)) {
|
||||
return "📷 ";
|
||||
} else if (MediaUtil.isVideo(attachment)) {
|
||||
return "🎥 ";
|
||||
} else if (MediaUtil.isAudio(attachment)) {
|
||||
return "🎧 ";
|
||||
} else if (MediaUtil.isFile(attachment)) {
|
||||
return "📎 ";
|
||||
} else {
|
||||
return "🎡 ";
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -479,13 +479,13 @@ public class DefaultMessageNotifier implements MessageNotifier {
|
||||
body = SpanUtil.italic(context.getString(R.string.MessageNotifier_sticker));
|
||||
slideDeck = ((MmsMessageRecord) record).getSlideDeck();
|
||||
} else if (record.isMms() && TextUtils.isEmpty(body) && !((MmsMessageRecord) record).getSlideDeck().getSlides().isEmpty()) {
|
||||
body = SpanUtil.italic(context.getString(R.string.MessageNotifier_media_message));
|
||||
slideDeck = ((MediaMmsMessageRecord)record).getSlideDeck();
|
||||
body = SpanUtil.italic(slideDeck.getBody());
|
||||
} else if (record.isMms() && !record.isMmsNotification() && !((MmsMessageRecord) record).getSlideDeck().getSlides().isEmpty()) {
|
||||
String message = context.getString(R.string.MessageNotifier_media_message_with_text, body);
|
||||
slideDeck = ((MediaMmsMessageRecord)record).getSlideDeck();
|
||||
String message = slideDeck.getBody() + ": " + record.getBody();
|
||||
int italicLength = message.length() - body.length();
|
||||
body = SpanUtil.italic(message, italicLength);
|
||||
slideDeck = ((MediaMmsMessageRecord)record).getSlideDeck();
|
||||
}
|
||||
|
||||
if (threadRecipients == null || !threadRecipients.isMuted()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user