diff --git a/build.gradle b/build.gradle
index 7cc758288b..ea141a6d88 100644
--- a/build.gradle
+++ b/build.gradle
@@ -182,7 +182,7 @@ dependencies {
implementation "com.opencsv:opencsv:4.6"
}
-def canonicalVersionCode = 83
+def canonicalVersionCode = 84
def canonicalVersionName = "1.5.0"
def postFixSize = 10
diff --git a/res/drawable/ic_outline_photo_camera_24.xml b/res/drawable/ic_outline_photo_camera_24.xml
index 58dee806f9..59e933eea1 100644
--- a/res/drawable/ic_outline_photo_camera_24.xml
+++ b/res/drawable/ic_outline_photo_camera_24.xml
@@ -3,13 +3,11 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
- android:tint="?attr/colorControlNormal">
+ android:tint="?android:colorControlNormal">
+ android:pathData="M8.8496,2.2148L8.627,2.459L7.1289,4.0938L4.4805,4.0938C3.0376,4.0938 1.8496,5.28 1.8496,6.7227L1.8496,17.9961C1.8496,19.4388 3.0376,20.625 4.4805,20.625L19.5195,20.625C20.9624,20.625 22.1504,19.4388 22.1504,17.9961L22.1504,6.7227C22.1504,5.28 20.9624,4.0938 19.5195,4.0938L16.8711,4.0938L15.1504,2.2148L8.8496,2.2148zM9.5098,3.7148L14.4902,3.7148L16.2109,5.5938L19.5195,5.5938C20.1447,5.5938 20.6504,6.0987 20.6504,6.7227L20.6504,17.9961C20.6504,18.6201 20.1447,19.125 19.5195,19.125L4.4805,19.125C3.8553,19.125 3.3496,18.62 3.3496,17.9961L3.3496,6.7227C3.3496,6.0987 3.8553,5.5938 4.4805,5.5938L7.7891,5.5938L9.5098,3.7148z"
+ android:fillColor="#000000"/>
+ android:pathData="M12,7.4648C9.2499,7.4648 7.0039,9.7109 7.0039,12.4609C7.0039,15.211 9.2499,17.457 12,17.457C14.7501,17.457 16.9961,15.211 16.9961,12.4609C16.9961,9.7109 14.7501,7.4648 12,7.4648zM12,8.9648C13.9394,8.9648 15.4961,10.5215 15.4961,12.4609C15.4961,14.4003 13.9394,15.957 12,15.957C10.0606,15.957 8.5039,14.4003 8.5039,12.4609C8.5039,10.5215 10.0606,8.9648 12,8.9648z"
+ android:fillColor="#000000"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 688bb6a81d..674ce114f2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1854,7 +1854,7 @@
*Please note that it is not possible to use the same Session ID on multiple devices simultaneously
Secure session reset done
-
+
Theme
Day
Night
@@ -1862,4 +1862,7 @@
Copy Session ID
+ Attachment
+ Voice Message
+
diff --git a/src/org/thoughtcrime/securesms/database/ThreadDatabase.java b/src/org/thoughtcrime/securesms/database/ThreadDatabase.java
index 1de021e206..41903ae23e 100644
--- a/src/org/thoughtcrime/securesms/database/ThreadDatabase.java
+++ b/src/org/thoughtcrime/securesms/database/ThreadDatabase.java
@@ -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();
}
diff --git a/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt b/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt
index 80b52c533e..147b01400c 100644
--- a/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt
+++ b/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt
@@ -186,6 +186,13 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh
}
fun processOutgoingMessage(message: PublicChatMessage) {
val messageServerID = message.serverID ?: return
+ val messageID = DatabaseFactory.getLokiMessageDatabase(context).getMessageID(messageServerID)
+ var isDuplicate = false
+ if (messageID != null) {
+ isDuplicate = DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(messageID) > 0
+ || DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageID) > 0
+ }
+ if (isDuplicate) { return }
if (message.body.isEmpty() && message.attachments.isEmpty() && message.quote == null) { return }
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
val dataMessage = getDataMessage(message)
diff --git a/src/org/thoughtcrime/securesms/mms/OutgoingMediaMessage.java b/src/org/thoughtcrime/securesms/mms/OutgoingMediaMessage.java
index 6a73726448..cb5252a657 100644
--- a/src/org/thoughtcrime/securesms/mms/OutgoingMediaMessage.java
+++ b/src/org/thoughtcrime/securesms/mms/OutgoingMediaMessage.java
@@ -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 "";
}
}
diff --git a/src/org/thoughtcrime/securesms/mms/Slide.java b/src/org/thoughtcrime/securesms/mms/Slide.java
index 2c5dc1cb16..cdf5ce5456 100644
--- a/src/org/thoughtcrime/securesms/mms/Slide.java
+++ b/src/org/thoughtcrime/securesms/mms/Slide.java
@@ -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,32 @@ public abstract class Slide {
@NonNull
public Optional getBody() {
- return Optional.absent();
+ String attachmentString = context.getString(R.string.attachment);
+
+ if (MediaUtil.isAudio(attachment)) {
+ // A missing file name is the legacy way to determine if an audio attachment is
+ // a voice note vs. other arbitrary audio attachments.
+ if (attachment.isVoiceNote() || attachment.getFileName() == null ||
+ 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
diff --git a/src/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java
index 6945c05027..974667cb6f 100644
--- a/src/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java
+++ b/src/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java
@@ -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()) {
diff --git a/src/org/thoughtcrime/securesms/util/MediaUtil.java b/src/org/thoughtcrime/securesms/util/MediaUtil.java
index 6163ba16d6..6278073fd0 100644
--- a/src/org/thoughtcrime/securesms/util/MediaUtil.java
+++ b/src/org/thoughtcrime/securesms/util/MediaUtil.java
@@ -226,7 +226,9 @@ public class MediaUtil {
}
public static boolean isImageType(String contentType) {
- return (null != contentType) && contentType.startsWith("image/");
+ return (null != contentType)
+ && contentType.startsWith("image/")
+ && !contentType.contains("svg"); // Do not treat SVGs as regular images.
}
public static boolean isAudioType(String contentType) {