mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Merge remote-tracking branch 'loki/dev' into profile-pic-placeholder
This commit is contained in:
commit
18c4358d7d
@ -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
|
||||
|
@ -3,13 +3,11 @@
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
android:tint="?android:colorControlNormal">
|
||||
<path
|
||||
android:strokeWidth="1.5"
|
||||
android:pathData="M 9.1799478,2.9655 7.4596583,4.844265 H 4.4799837 c -1.0339942,0 -1.8800277,0.8454653 -1.8800277,1.878765 v 11.273221 c 0,1.033342 0.8460019,1.878765 1.8800277,1.878765 H 19.520416 c 1.033994,0 1.880028,-0.845465 1.880028,-1.878765 V 6.72303 c 0,-1.0333418 -0.846002,-1.878765 -1.880028,-1.878765 H 16.540742 L 14.820452,2.9655 Z"
|
||||
android:strokeColor="@android:color/white"/>
|
||||
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"/>
|
||||
<path
|
||||
android:strokeWidth="1.5"
|
||||
android:pathData="m 11.99999,16.70635 c -2.3447128,0 -4.2454779,-1.900765 -4.2454782,-4.245478 -3e-7,-2.344713 1.9007652,-4.2454787 4.2454782,-4.2454789 2.344713,-2e-7 4.245479,1.9007659 4.245479,4.2454789 0,2.344713 -1.900766,4.245478 -4.245479,4.245478 z"
|
||||
android:strokeColor="@android:color/white"/>
|
||||
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"/>
|
||||
</vector>
|
||||
|
@ -1862,4 +1862,7 @@
|
||||
|
||||
<string name="activity_conversation_menu_copy_session_id">Copy Session ID</string>
|
||||
|
||||
<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();
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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,32 @@ 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 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
|
||||
|
@ -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()) {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user