mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-17 21:47:28 +00:00
WIP clean
This commit is contained in:
parent
709727197c
commit
7ca8456383
@ -6,6 +6,7 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
|
||||||
public class MmsNotificationAttachment extends Attachment {
|
public class MmsNotificationAttachment extends Attachment {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
|||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentServer;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentServer;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.AudioSlide;
|
import org.thoughtcrime.securesms.mms.AudioSlide;
|
||||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
|
@ -10,7 +10,7 @@ import com.annimon.stream.function.Predicate
|
|||||||
import com.google.protobuf.ByteString
|
import com.google.protobuf.ByteString
|
||||||
import net.sqlcipher.database.SQLiteDatabase
|
import net.sqlcipher.database.SQLiteDatabase
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
||||||
import org.thoughtcrime.securesms.backup.BackupProtos.*
|
import org.thoughtcrime.securesms.backup.BackupProtos.*
|
||||||
import org.thoughtcrime.securesms.crypto.AttachmentSecret
|
import org.thoughtcrime.securesms.crypto.AttachmentSecret
|
||||||
import org.thoughtcrime.securesms.crypto.ClassicDecryptingPartInputStream
|
import org.thoughtcrime.securesms.crypto.ClassicDecryptingPartInputStream
|
||||||
|
@ -7,7 +7,7 @@ import android.net.Uri
|
|||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import net.sqlcipher.database.SQLiteDatabase
|
import net.sqlcipher.database.SQLiteDatabase
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
||||||
import org.thoughtcrime.securesms.backup.BackupProtos.*
|
import org.thoughtcrime.securesms.backup.BackupProtos.*
|
||||||
import org.thoughtcrime.securesms.crypto.AttachmentSecret
|
import org.thoughtcrime.securesms.crypto.AttachmentSecret
|
||||||
import org.thoughtcrime.securesms.crypto.ModernEncryptingPartOutputStream
|
import org.thoughtcrime.securesms.crypto.ModernEncryptingPartOutputStream
|
||||||
|
@ -12,7 +12,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.UiThread;
|
import androidx.annotation.UiThread;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||||
import org.thoughtcrime.securesms.mms.Slide;
|
import org.thoughtcrime.securesms.mms.Slide;
|
||||||
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
||||||
|
@ -21,7 +21,7 @@ import androidx.annotation.RequiresApi;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities;
|
import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities;
|
||||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||||
|
@ -16,7 +16,7 @@ import com.pnikosis.materialishprogress.ProgressWheel;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||||
import org.thoughtcrime.securesms.mms.Slide;
|
import org.thoughtcrime.securesms.mms.Slide;
|
||||||
|
@ -11,9 +11,9 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.UriAttachment;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.contactshare;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.session.libsignal.service.api.messages.shared.SharedContact;
|
import org.session.libsignal.service.api.messages.shared.SharedContact;
|
||||||
|
@ -61,7 +61,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
|||||||
import org.thoughtcrime.securesms.MessageDetailsActivity;
|
import org.thoughtcrime.securesms.MessageDetailsActivity;
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||||
import org.thoughtcrime.securesms.ShareActivity;
|
import org.thoughtcrime.securesms.ShareActivity;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.components.ConversationTypingView;
|
import org.thoughtcrime.securesms.components.ConversationTypingView;
|
||||||
import org.thoughtcrime.securesms.components.recyclerview.SmoothScrollingLinearLayoutManager;
|
import org.thoughtcrime.securesms.components.recyclerview.SmoothScrollingLinearLayoutManager;
|
||||||
import org.thoughtcrime.securesms.conversation.ConversationAdapter.HeaderViewHolder;
|
import org.thoughtcrime.securesms.conversation.ConversationAdapter.HeaderViewHolder;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.session.libsignal.libsignal.logging.Log;
|
||||||
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.util.LRUCache;
|
import org.thoughtcrime.securesms.util.LRUCache;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -37,11 +37,7 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
|
||||||
import org.thoughtcrime.securesms.attachments.MmsNotificationAttachment;
|
import org.thoughtcrime.securesms.attachments.MmsNotificationAttachment;
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
||||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||||
@ -52,21 +48,28 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
|
|||||||
import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord;
|
import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.Quote;
|
import org.thoughtcrime.securesms.database.model.Quote;
|
||||||
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
|
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
|
||||||
import org.thoughtcrime.securesms.mms.MmsException;
|
import org.thoughtcrime.securesms.mms.MmsException;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
|
||||||
import org.thoughtcrime.securesms.mms.QuoteModel;
|
|
||||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel;
|
||||||
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
import org.session.libsession.messaging.threads.recipients.RecipientFormattingException;
|
import org.session.libsession.messaging.threads.recipients.RecipientFormattingException;
|
||||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
import org.session.libsession.utilities.JsonUtils;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.session.libsession.utilities.Util;
|
||||||
|
|
||||||
|
import org.session.libsignal.libsignal.logging.Log;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@ -267,7 +270,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
if (Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX)))) {
|
if (Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX)))) {
|
||||||
Address theirAddress = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
Address theirAddress = Address.Companion.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
||||||
Address ourAddress = messageId.getAddress();
|
Address ourAddress = messageId.getAddress();
|
||||||
String columnName = deliveryReceipt ? DELIVERY_RECEIPT_COUNT : READ_RECEIPT_COUNT;
|
String columnName = deliveryReceipt ? DELIVERY_RECEIPT_COUNT : READ_RECEIPT_COUNT;
|
||||||
|
|
||||||
@ -332,7 +335,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
String fromString = notification.getFrom() != null && notification.getFrom().getTextString() != null
|
String fromString = notification.getFrom() != null && notification.getFrom().getTextString() != null
|
||||||
? Util.toIsoString(notification.getFrom().getTextString())
|
? Util.toIsoString(notification.getFrom().getTextString())
|
||||||
: "";
|
: "";
|
||||||
Recipient recipient = Recipient.from(context, Address.fromExternal(context, fromString), false);
|
Recipient recipient = Recipient.from(context, Address.Companion.fromExternal(context, fromString), false);
|
||||||
return DatabaseFactory.getThreadDatabase(context).getOrCreateThreadIdFor(recipient);
|
return DatabaseFactory.getThreadDatabase(context).getOrCreateThreadIdFor(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +502,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
while(cursor != null && cursor.moveToNext()) {
|
while(cursor != null && cursor.moveToNext()) {
|
||||||
if (Types.isSecureType(cursor.getLong(3))) {
|
if (Types.isSecureType(cursor.getLong(3))) {
|
||||||
SyncMessageId syncMessageId = new SyncMessageId(Address.fromSerialized(cursor.getString(1)), cursor.getLong(2));
|
SyncMessageId syncMessageId = new SyncMessageId(Address.Companion.fromSerialized(cursor.getString(1)), cursor.getLong(2));
|
||||||
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), true);
|
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), true);
|
||||||
|
|
||||||
result.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
result.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
||||||
@ -528,7 +531,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
cursor = database.query(TABLE_NAME, new String[] {ID, THREAD_ID, MESSAGE_BOX, EXPIRES_IN, EXPIRE_STARTED, ADDRESS}, DATE_SENT + " = ?", new String[] {String.valueOf(messageId.getTimetamp())}, null, null, null, null);
|
cursor = database.query(TABLE_NAME, new String[] {ID, THREAD_ID, MESSAGE_BOX, EXPIRES_IN, EXPIRE_STARTED, ADDRESS}, DATE_SENT + " = ?", new String[] {String.valueOf(messageId.getTimetamp())}, null, null, null, null);
|
||||||
|
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
Address theirAddress = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
Address theirAddress = Address.Companion.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
||||||
Address ourAddress = messageId.getAddress();
|
Address ourAddress = messageId.getAddress();
|
||||||
|
|
||||||
if (ourAddress.equals(theirAddress) || theirAddress.isGroup()) {
|
if (ourAddress.equals(theirAddress) || theirAddress.isGroup()) {
|
||||||
@ -641,13 +644,13 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
.filterNot(previewAttachments::contains)
|
.filterNot(previewAttachments::contains)
|
||||||
.map(a -> (Attachment)a).toList();
|
.map(a -> (Attachment)a).toList();
|
||||||
|
|
||||||
Recipient recipient = Recipient.from(context, Address.fromSerialized(address), false);
|
Recipient recipient = Recipient.from(context, Address.Companion.fromSerialized(address), false);
|
||||||
List<NetworkFailure> networkFailures = new LinkedList<>();
|
List<NetworkFailure> networkFailures = new LinkedList<>();
|
||||||
List<IdentityKeyMismatch> mismatches = new LinkedList<>();
|
List<IdentityKeyMismatch> mismatches = new LinkedList<>();
|
||||||
QuoteModel quote = null;
|
QuoteModel quote = null;
|
||||||
|
|
||||||
if (quoteId > 0 && (!TextUtils.isEmpty(quoteText) || !quoteAttachments.isEmpty())) {
|
if (quoteId > 0 && (!TextUtils.isEmpty(quoteText) || !quoteAttachments.isEmpty())) {
|
||||||
quote = new QuoteModel(quoteId, Address.fromSerialized(quoteAuthor), quoteText, quoteMissing, quoteAttachments);
|
quote = new QuoteModel(quoteId, Address.Companion.fromSerialized(quoteAuthor), quoteText, quoteMissing, quoteAttachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(mismatchDocument)) {
|
if (!TextUtils.isEmpty(mismatchDocument)) {
|
||||||
@ -711,7 +714,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
if (contact.getAvatar() != null && contact.getAvatar().getAttachmentId() != null) {
|
if (contact.getAvatar() != null && contact.getAvatar().getAttachmentId() != null) {
|
||||||
DatabaseAttachment attachment = attachmentIdMap.get(contact.getAvatar().getAttachmentId());
|
DatabaseAttachment attachment = attachmentIdMap.get(contact.getAvatar().getAttachmentId());
|
||||||
Avatar updatedAvatar = new Avatar(contact.getAvatar().getAttachmentId(),
|
Contact.Avatar updatedAvatar = new Contact.Avatar(contact.getAvatar().getAttachmentId(),
|
||||||
attachment,
|
attachment,
|
||||||
contact.getAvatar().isProfile());
|
contact.getAvatar().isProfile());
|
||||||
contacts.add(new Contact(contact, updatedAvatar));
|
contacts.add(new Contact(contact, updatedAvatar));
|
||||||
@ -940,7 +943,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
contentBuilder.add(MESSAGE_TYPE, notification.getMessageType());
|
contentBuilder.add(MESSAGE_TYPE, notification.getMessageType());
|
||||||
|
|
||||||
if (notification.getFrom() != null) {
|
if (notification.getFrom() != null) {
|
||||||
contentValues.put(ADDRESS, Address.fromExternal(context, Util.toIsoString(notification.getFrom().getTextString())).serialize());
|
contentValues.put(ADDRESS, Address.Companion.fromExternal(context, Util.toIsoString(notification.getFrom().getTextString())).serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
contentValues.put(MESSAGE_BOX, Types.BASE_INBOX_TYPE);
|
contentValues.put(MESSAGE_BOX, Types.BASE_INBOX_TYPE);
|
||||||
@ -1022,7 +1025,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
contentValues.put(QUOTE_ID, message.getOutgoingQuote().getId());
|
contentValues.put(QUOTE_ID, message.getOutgoingQuote().getId());
|
||||||
contentValues.put(QUOTE_AUTHOR, message.getOutgoingQuote().getAuthor().serialize());
|
contentValues.put(QUOTE_AUTHOR, message.getOutgoingQuote().getAuthor().serialize());
|
||||||
contentValues.put(QUOTE_BODY, message.getOutgoingQuote().getText());
|
contentValues.put(QUOTE_BODY, message.getOutgoingQuote().getText());
|
||||||
contentValues.put(QUOTE_MISSING, message.getOutgoingQuote().isOriginalMissing() ? 1 : 0);
|
contentValues.put(QUOTE_MISSING, message.getOutgoingQuote().getMissing() ? 1 : 0);
|
||||||
|
|
||||||
quoteAttachments.addAll(message.getOutgoingQuote().getAttachments());
|
quoteAttachments.addAll(message.getOutgoingQuote().getAttachments());
|
||||||
}
|
}
|
||||||
@ -1152,9 +1155,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
attachmentId = insertedAttachmentIds.get(contact.getAvatarAttachment());
|
attachmentId = insertedAttachmentIds.get(contact.getAvatarAttachment());
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar updatedAvatar = new Avatar(attachmentId,
|
Contact.Avatar updatedAvatar = new Contact.Avatar(attachmentId, contact.getAvatarAttachment(), contact.getAvatar() != null && contact.getAvatar().isProfile());
|
||||||
contact.getAvatarAttachment(),
|
|
||||||
contact.getAvatar() != null && contact.getAvatar().isProfile());
|
|
||||||
Contact updatedContact = new Contact(contact, updatedAvatar);
|
Contact updatedContact = new Contact(contact, updatedAvatar);
|
||||||
|
|
||||||
sharedContactJson.put(new JSONObject(updatedContact.serialize()));
|
sharedContactJson.put(new JSONObject(updatedContact.serialize()));
|
||||||
@ -1321,7 +1322,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
private final int subscriptionId;
|
private final int subscriptionId;
|
||||||
|
|
||||||
MmsNotificationInfo(@Nullable String from, String contentLocation, String transactionId, int subscriptionId) {
|
MmsNotificationInfo(@Nullable String from, String contentLocation, String transactionId, int subscriptionId) {
|
||||||
this.from = from == null ? null : Address.fromSerialized(from);
|
this.from = from == null ? null : Address.Companion.fromSerialized(from);
|
||||||
this.contentLocation = contentLocation;
|
this.contentLocation = contentLocation;
|
||||||
this.transactionId = transactionId;
|
this.transactionId = transactionId;
|
||||||
this.subscriptionId = subscriptionId;
|
this.subscriptionId = subscriptionId;
|
||||||
@ -1373,7 +1374,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
new Quote(message.getOutgoingQuote().getId(),
|
new Quote(message.getOutgoingQuote().getId(),
|
||||||
message.getOutgoingQuote().getAuthor(),
|
message.getOutgoingQuote().getAuthor(),
|
||||||
message.getOutgoingQuote().getText(),
|
message.getOutgoingQuote().getText(),
|
||||||
message.getOutgoingQuote().isOriginalMissing(),
|
message.getOutgoingQuote().getMissing(),
|
||||||
new SlideDeck(context, message.getOutgoingQuote().getAttachments())) :
|
new SlideDeck(context, message.getOutgoingQuote().getAttachments())) :
|
||||||
null,
|
null,
|
||||||
message.getSharedContacts(), message.getLinkPreviews(), false);
|
message.getSharedContacts(), message.getLinkPreviews(), false);
|
||||||
@ -1492,9 +1493,9 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
Address address;
|
Address address;
|
||||||
|
|
||||||
if (TextUtils.isEmpty(serialized) || "insert-address-token".equals(serialized)) {
|
if (TextUtils.isEmpty(serialized) || "insert-address-token".equals(serialized)) {
|
||||||
address = Address.UNKNOWN;
|
address = Address.Companion.getUNKNOWN();
|
||||||
} else {
|
} else {
|
||||||
address = Address.fromSerialized(serialized);
|
address = Address.Companion.fromSerialized(serialized);
|
||||||
|
|
||||||
}
|
}
|
||||||
return Recipient.from(context, address, true);
|
return Recipient.from(context, address, true);
|
||||||
@ -1541,7 +1542,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
|
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
|
||||||
|
|
||||||
if (quoteId > 0 && !TextUtils.isEmpty(quoteAuthor)) {
|
if (quoteId > 0 && !TextUtils.isEmpty(quoteAuthor)) {
|
||||||
return new Quote(quoteId, Address.fromExternal(context, quoteAuthor), quoteText, quoteMissing, quoteDeck);
|
return new Quote(quoteId, Address.Companion.fromExternal(context, quoteAuthor), quoteText, quoteMissing, quoteDeck);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import com.annimon.stream.Stream;
|
|||||||
import net.sqlcipher.database.SQLiteDatabase;
|
import net.sqlcipher.database.SQLiteDatabase;
|
||||||
import net.sqlcipher.database.SQLiteStatement;
|
import net.sqlcipher.database.SQLiteStatement;
|
||||||
|
|
||||||
|
import org.session.libsignal.libsignal.logging.Log;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
||||||
@ -37,13 +38,14 @@ import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
|||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||||
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
|
||||||
import org.thoughtcrime.securesms.sms.IncomingGroupMessage;
|
import org.thoughtcrime.securesms.sms.IncomingGroupMessage;
|
||||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
||||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
|
import org.session.libsession.utilities.JsonUtils;
|
||||||
|
import org.session.libsession.utilities.TextSecurePreferences;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -374,7 +376,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
if (Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(TYPE)))) {
|
if (Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(TYPE)))) {
|
||||||
Address theirAddress = messageId.getAddress();
|
Address theirAddress = messageId.getAddress();
|
||||||
Address ourAddress = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
Address ourAddress = Address.Companion.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
||||||
String columnName = deliveryReceipt ? DELIVERY_RECEIPT_COUNT : READ_RECEIPT_COUNT;
|
String columnName = deliveryReceipt ? DELIVERY_RECEIPT_COUNT : READ_RECEIPT_COUNT;
|
||||||
|
|
||||||
if (ourAddress.equals(theirAddress)) {
|
if (ourAddress.equals(theirAddress)) {
|
||||||
@ -415,7 +417,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
Address theirAddress = messageId.getAddress();
|
Address theirAddress = messageId.getAddress();
|
||||||
Address ourAddress = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
Address ourAddress = Address.Companion.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)));
|
||||||
|
|
||||||
if (ourAddress.equals(theirAddress)) {
|
if (ourAddress.equals(theirAddress)) {
|
||||||
long id = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
long id = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||||
@ -466,7 +468,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
if (Types.isSecureType(cursor.getLong(3))) {
|
if (Types.isSecureType(cursor.getLong(3))) {
|
||||||
SyncMessageId syncMessageId = new SyncMessageId(Address.fromSerialized(cursor.getString(1)), cursor.getLong(2));
|
SyncMessageId syncMessageId = new SyncMessageId(Address.Companion.fromSerialized(cursor.getString(1)), cursor.getLong(2));
|
||||||
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), false);
|
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), false);
|
||||||
|
|
||||||
results.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
results.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
||||||
@ -923,7 +925,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
public SmsMessageRecord getCurrent() {
|
public SmsMessageRecord getCurrent() {
|
||||||
long messageId = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.ID));
|
long messageId = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.ID));
|
||||||
Address address = Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS)));
|
Address address = Address.Companion.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS)));
|
||||||
int addressDeviceId = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS_DEVICE_ID));
|
int addressDeviceId = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS_DEVICE_ID));
|
||||||
long type = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.TYPE));
|
long type = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.TYPE));
|
||||||
long dateReceived = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.NORMALIZED_DATE_RECEIVED));
|
long dateReceived = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.NORMALIZED_DATE_RECEIVED));
|
||||||
|
@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.util.Pair;
|
import androidx.core.util.Pair;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||||
|
@ -22,12 +22,12 @@ import androidx.annotation.Nullable;
|
|||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.SmsDatabase.Status;
|
import org.thoughtcrime.securesms.database.SmsDatabase.Status;
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
|
||||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.database.model;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
|
||||||
public class Sticker {
|
public class Sticker {
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.events;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
|
||||||
public class PartProgressEvent {
|
public class PartProgressEvent {
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
|
@ -14,8 +14,8 @@ import org.session.libsignal.service.api.push.exceptions.NonSuccessfulResponseCo
|
|||||||
import org.session.libsignal.service.api.push.exceptions.PushNetworkException;
|
import org.session.libsignal.service.api.push.exceptions.PushNetworkException;
|
||||||
import org.session.libsignal.service.loki.utilities.DownloadUtilities;
|
import org.session.libsignal.service.loki.utilities.DownloadUtilities;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
@ -3,8 +3,8 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
|
@ -11,7 +11,7 @@ import com.google.android.mms.pdu_alt.PduPart;
|
|||||||
import com.google.android.mms.pdu_alt.RetrieveConf;
|
import com.google.android.mms.pdu_alt.RetrieveConf;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
|
@ -20,7 +20,7 @@ import com.google.android.mms.smil.SmilHelper;
|
|||||||
import com.klinker.android.send_message.Utils;
|
import com.klinker.android.send_message.Utils;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
|
@ -27,7 +27,7 @@ import org.session.libsignal.metadata.ProtocolUntrustedIdentityException;
|
|||||||
import org.session.libsignal.metadata.SelfSendException;
|
import org.session.libsignal.metadata.SelfSendException;
|
||||||
import org.session.libsignal.service.loki.api.crypto.SessionProtocol;
|
import org.session.libsignal.service.loki.api.crypto.SessionProtocol;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
||||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||||
|
@ -9,7 +9,7 @@ import com.annimon.stream.Collectors;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
|
@ -7,7 +7,7 @@ import androidx.annotation.WorkerThread;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
|
@ -11,7 +11,7 @@ import com.annimon.stream.Stream;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.TextSecureExpiredException;
|
import org.thoughtcrime.securesms.TextSecureExpiredException;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||||
import org.thoughtcrime.securesms.contactshare.ContactModelMapper;
|
import org.thoughtcrime.securesms.contactshare.ContactModelMapper;
|
||||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||||
|
@ -6,8 +6,8 @@ import androidx.annotation.Nullable;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
|
@ -13,7 +13,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|||||||
import com.google.android.gms.common.util.IOUtils;
|
import com.google.android.gms.common.util.IOUtils;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.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;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
|
@ -5,8 +5,8 @@ import android.os.Build
|
|||||||
import org.thoughtcrime.securesms.logging.Log
|
import org.thoughtcrime.securesms.logging.Log
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachmentAudioExtras
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachmentAudioExtras
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
import org.thoughtcrime.securesms.jobmanager.Data
|
||||||
|
@ -39,7 +39,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
|
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
|
||||||
import org.thoughtcrime.securesms.components.DocumentView;
|
import org.thoughtcrime.securesms.components.DocumentView;
|
||||||
import org.thoughtcrime.securesms.components.RemovableEditableMediaView;
|
import org.thoughtcrime.securesms.components.RemovableEditableMediaView;
|
||||||
|
@ -24,7 +24,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.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;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
@ -6,7 +6,7 @@ import android.net.Uri;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.util.ExternalStorageUtil;
|
import org.thoughtcrime.securesms.util.ExternalStorageUtil;
|
||||||
|
|
||||||
public class DocumentSlide extends Slide {
|
public class DocumentSlide extends Slide {
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
|
||||||
public class GifSlide extends ImageSlide {
|
public class GifSlide extends ImageSlide {
|
||||||
|
@ -24,7 +24,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
|
||||||
public class ImageSlide extends Slide {
|
public class ImageSlide extends Slide {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package org.thoughtcrime.securesms.mms;
|
package org.thoughtcrime.securesms.mms;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.PointerAttachment;
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
import org.session.libsession.utilities.GroupUtil;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.session.libsignal.service.api.messages.SignalServiceAttachment;
|
import org.session.libsignal.service.api.messages.SignalServiceAttachment;
|
||||||
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
||||||
@ -79,7 +79,7 @@ public class IncomingMediaMessage {
|
|||||||
this.quote = quote.orNull();
|
this.quote = quote.orNull();
|
||||||
this.unidentified = unidentified;
|
this.unidentified = unidentified;
|
||||||
|
|
||||||
if (group.isPresent()) this.groupId = Address.fromSerialized(GroupUtil.getEncodedId(group.get()));
|
if (group.isPresent()) this.groupId = Address.Companion.fromSerialized(GroupUtil.INSTANCE.getEncodedId(group.get()));
|
||||||
else this.groupId = null;
|
else this.groupId = null;
|
||||||
|
|
||||||
this.attachments.addAll(PointerAttachment.forPointers(attachments));
|
this.attachments.addAll(PointerAttachment.forPointers(attachments));
|
||||||
|
@ -7,7 +7,7 @@ import androidx.annotation.Nullable;
|
|||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||||
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||||
|
@ -4,7 +4,7 @@ package org.thoughtcrime.securesms.mms;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
|
||||||
public class MmsSlide extends ImageSlide {
|
public class MmsSlide extends ImageSlide {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.mms;
|
package org.thoughtcrime.securesms.mms;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
|
|
||||||
|
@ -3,12 +3,14 @@ package org.thoughtcrime.securesms.mms;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Base64;
|
import org.session.libsession.utilities.Base64;
|
||||||
|
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos.GroupContext;
|
import org.session.libsignal.service.internal.push.SignalServiceProtos.GroupContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -4,11 +4,12 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
|
||||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -3,9 +3,10 @@ package org.thoughtcrime.securesms.mms;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
import org.session.libsession.messaging.sending_receiving.contacts.Contact;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPreview;
|
||||||
|
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel;
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.mms;
|
|||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,7 +22,7 @@ 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 org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.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;
|
||||||
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
||||||
|
@ -22,7 +22,7 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import androidx.annotation.DrawableRes;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import android.net.Uri;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
|
||||||
public class TextSlide extends Slide {
|
public class TextSlide extends Slide {
|
||||||
|
@ -24,7 +24,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
import org.thoughtcrime.securesms.util.ResUtil;
|
import org.thoughtcrime.securesms.util.ResUtil;
|
||||||
|
|
||||||
|
@ -1,732 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Whisper Systems
|
|
||||||
* Copyright (C) 2013 - 2017 Open Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.recipients;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.annimon.stream.function.Consumer;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.GroupRecordContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.TransparentContactPhoto;
|
|
||||||
import org.session.libsession.messaging.threads.Address;
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
import org.thoughtcrime.securesms.loki.utilities.ProfilePictureModifiedEvent;
|
|
||||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
|
||||||
import org.session.libsession.messaging.threads.recipients.RecipientProvider.RecipientDetails;
|
|
||||||
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
|
||||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.WeakHashMap;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class Recipient implements RecipientModifiedListener {
|
|
||||||
|
|
||||||
private static final String TAG = Recipient.class.getSimpleName();
|
|
||||||
private static final RecipientProvider provider = new RecipientProvider();
|
|
||||||
|
|
||||||
private final Set<RecipientModifiedListener> listeners = Collections.newSetFromMap(new WeakHashMap<RecipientModifiedListener, Boolean>());
|
|
||||||
|
|
||||||
private final @NonNull Address address;
|
|
||||||
private final @NonNull List<Recipient> participants = new LinkedList<>();
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private @Nullable String name;
|
|
||||||
private @Nullable String customLabel;
|
|
||||||
private boolean resolving;
|
|
||||||
private boolean isLocalNumber;
|
|
||||||
|
|
||||||
private @Nullable Uri systemContactPhoto;
|
|
||||||
private @Nullable Long groupAvatarId;
|
|
||||||
private Uri contactUri;
|
|
||||||
private @Nullable Uri messageRingtone = null;
|
|
||||||
private @Nullable Uri callRingtone = null;
|
|
||||||
public long mutedUntil = 0;
|
|
||||||
private boolean blocked = false;
|
|
||||||
private VibrateState messageVibrate = VibrateState.DEFAULT;
|
|
||||||
private VibrateState callVibrate = VibrateState.DEFAULT;
|
|
||||||
private int expireMessages = 0;
|
|
||||||
private Optional<Integer> defaultSubscriptionId = Optional.absent();
|
|
||||||
private @NonNull RegisteredState registered = RegisteredState.UNKNOWN;
|
|
||||||
|
|
||||||
private @Nullable MaterialColor color;
|
|
||||||
private @Nullable byte[] profileKey;
|
|
||||||
private @Nullable String profileName;
|
|
||||||
private @Nullable String profileAvatar;
|
|
||||||
private boolean profileSharing;
|
|
||||||
private String notificationChannel;
|
|
||||||
private boolean forceSmsSelection;
|
|
||||||
|
|
||||||
private @NonNull UnidentifiedAccessMode unidentifiedAccessMode = UnidentifiedAccessMode.ENABLED;
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, boolean asynchronous) {
|
|
||||||
if (address == null) throw new AssertionError(address);
|
|
||||||
return provider.getRecipient(context, address, Optional.absent(), Optional.absent(), asynchronous);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, @NonNull Optional<RecipientSettings> settings, @NonNull Optional<GroupDatabase.GroupRecord> groupRecord, boolean asynchronous) {
|
|
||||||
if (address == null) throw new AssertionError(address);
|
|
||||||
return provider.getRecipient(context, address, settings, groupRecord, asynchronous);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyCached(@NonNull Address address, Consumer<Recipient> consumer) {
|
|
||||||
Optional<Recipient> recipient = provider.getCached(address);
|
|
||||||
if (recipient.isPresent()) consumer.accept(recipient.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean removeCached(@NonNull Address address) {
|
|
||||||
return provider.removeCached(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
Recipient(@NonNull Context context,
|
|
||||||
@NonNull Address address,
|
|
||||||
@Nullable Recipient stale,
|
|
||||||
@NonNull Optional<RecipientDetails> details,
|
|
||||||
@NonNull ListenableFutureTask<RecipientDetails> future)
|
|
||||||
{
|
|
||||||
this.context = context;
|
|
||||||
this.address = address;
|
|
||||||
this.color = null;
|
|
||||||
this.resolving = true;
|
|
||||||
|
|
||||||
if (stale != null) {
|
|
||||||
this.name = stale.name;
|
|
||||||
this.contactUri = stale.contactUri;
|
|
||||||
this.systemContactPhoto = stale.systemContactPhoto;
|
|
||||||
this.groupAvatarId = stale.groupAvatarId;
|
|
||||||
this.isLocalNumber = stale.isLocalNumber;
|
|
||||||
this.color = stale.color;
|
|
||||||
this.customLabel = stale.customLabel;
|
|
||||||
this.messageRingtone = stale.messageRingtone;
|
|
||||||
this.callRingtone = stale.callRingtone;
|
|
||||||
this.mutedUntil = stale.mutedUntil;
|
|
||||||
this.blocked = stale.blocked;
|
|
||||||
this.messageVibrate = stale.messageVibrate;
|
|
||||||
this.callVibrate = stale.callVibrate;
|
|
||||||
this.expireMessages = stale.expireMessages;
|
|
||||||
this.defaultSubscriptionId = stale.defaultSubscriptionId;
|
|
||||||
this.registered = stale.registered;
|
|
||||||
this.notificationChannel = stale.notificationChannel;
|
|
||||||
this.profileKey = stale.profileKey;
|
|
||||||
this.profileName = stale.profileName;
|
|
||||||
this.profileAvatar = stale.profileAvatar;
|
|
||||||
this.profileSharing = stale.profileSharing;
|
|
||||||
this.unidentifiedAccessMode = stale.unidentifiedAccessMode;
|
|
||||||
this.forceSmsSelection = stale.forceSmsSelection;
|
|
||||||
|
|
||||||
this.participants.clear();
|
|
||||||
this.participants.addAll(stale.participants);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (details.isPresent()) {
|
|
||||||
this.name = details.get().name;
|
|
||||||
this.systemContactPhoto = details.get().systemContactPhoto;
|
|
||||||
this.groupAvatarId = details.get().groupAvatarId;
|
|
||||||
this.isLocalNumber = details.get().isLocalNumber;
|
|
||||||
this.color = details.get().color;
|
|
||||||
this.messageRingtone = details.get().messageRingtone;
|
|
||||||
this.callRingtone = details.get().callRingtone;
|
|
||||||
this.mutedUntil = details.get().mutedUntil;
|
|
||||||
this.blocked = details.get().blocked;
|
|
||||||
this.messageVibrate = details.get().messageVibrateState;
|
|
||||||
this.callVibrate = details.get().callVibrateState;
|
|
||||||
this.expireMessages = details.get().expireMessages;
|
|
||||||
this.defaultSubscriptionId = details.get().defaultSubscriptionId;
|
|
||||||
this.registered = details.get().registered;
|
|
||||||
this.notificationChannel = details.get().notificationChannel;
|
|
||||||
this.profileKey = details.get().profileKey;
|
|
||||||
this.profileName = details.get().profileName;
|
|
||||||
this.profileAvatar = details.get().profileAvatar;
|
|
||||||
this.profileSharing = details.get().profileSharing;
|
|
||||||
this.unidentifiedAccessMode = details.get().unidentifiedAccessMode;
|
|
||||||
this.forceSmsSelection = details.get().forceSmsSelection;
|
|
||||||
|
|
||||||
this.participants.clear();
|
|
||||||
this.participants.addAll(details.get().participants);
|
|
||||||
}
|
|
||||||
|
|
||||||
future.addListener(new FutureTaskListener<RecipientDetails>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(RecipientDetails result) {
|
|
||||||
if (result != null) {
|
|
||||||
synchronized (Recipient.this) {
|
|
||||||
Recipient.this.name = result.name;
|
|
||||||
Recipient.this.contactUri = result.contactUri;
|
|
||||||
Recipient.this.systemContactPhoto = result.systemContactPhoto;
|
|
||||||
Recipient.this.groupAvatarId = result.groupAvatarId;
|
|
||||||
Recipient.this.isLocalNumber = result.isLocalNumber;
|
|
||||||
Recipient.this.color = result.color;
|
|
||||||
Recipient.this.customLabel = result.customLabel;
|
|
||||||
Recipient.this.messageRingtone = result.messageRingtone;
|
|
||||||
Recipient.this.callRingtone = result.callRingtone;
|
|
||||||
Recipient.this.mutedUntil = result.mutedUntil;
|
|
||||||
Recipient.this.blocked = result.blocked;
|
|
||||||
Recipient.this.messageVibrate = result.messageVibrateState;
|
|
||||||
Recipient.this.callVibrate = result.callVibrateState;
|
|
||||||
Recipient.this.expireMessages = result.expireMessages;
|
|
||||||
Recipient.this.defaultSubscriptionId = result.defaultSubscriptionId;
|
|
||||||
Recipient.this.registered = result.registered;
|
|
||||||
Recipient.this.notificationChannel = result.notificationChannel;
|
|
||||||
Recipient.this.profileKey = result.profileKey;
|
|
||||||
Recipient.this.profileName = result.profileName;
|
|
||||||
Recipient.this.profileAvatar = result.profileAvatar;
|
|
||||||
Recipient.this.profileSharing = result.profileSharing;
|
|
||||||
Recipient.this.unidentifiedAccessMode = result.unidentifiedAccessMode;
|
|
||||||
Recipient.this.forceSmsSelection = result.forceSmsSelection;
|
|
||||||
|
|
||||||
Recipient.this.participants.clear();
|
|
||||||
Recipient.this.participants.addAll(result.participants);
|
|
||||||
Recipient.this.resolving = false;
|
|
||||||
|
|
||||||
if (!listeners.isEmpty()) {
|
|
||||||
for (Recipient recipient : participants) recipient.addListener(Recipient.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Recipient.this.notifyAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(ExecutionException error) {
|
|
||||||
Log.w(TAG, error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Recipient(@NonNull Context context, @NonNull Address address, @NonNull RecipientDetails details) {
|
|
||||||
this.context = context;
|
|
||||||
this.address = address;
|
|
||||||
this.contactUri = details.contactUri;
|
|
||||||
this.name = details.name;
|
|
||||||
this.systemContactPhoto = details.systemContactPhoto;
|
|
||||||
this.groupAvatarId = details.groupAvatarId;
|
|
||||||
this.isLocalNumber = details.isLocalNumber;
|
|
||||||
this.color = details.color;
|
|
||||||
this.customLabel = details.customLabel;
|
|
||||||
this.messageRingtone = details.messageRingtone;
|
|
||||||
this.callRingtone = details.callRingtone;
|
|
||||||
this.mutedUntil = details.mutedUntil;
|
|
||||||
this.blocked = details.blocked;
|
|
||||||
this.messageVibrate = details.messageVibrateState;
|
|
||||||
this.callVibrate = details.callVibrateState;
|
|
||||||
this.expireMessages = details.expireMessages;
|
|
||||||
this.defaultSubscriptionId = details.defaultSubscriptionId;
|
|
||||||
this.registered = details.registered;
|
|
||||||
this.notificationChannel = details.notificationChannel;
|
|
||||||
this.profileKey = details.profileKey;
|
|
||||||
this.profileName = details.profileName;
|
|
||||||
this.profileAvatar = details.profileAvatar;
|
|
||||||
this.profileSharing = details.profileSharing;
|
|
||||||
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
|
|
||||||
this.forceSmsSelection = details.forceSmsSelection;
|
|
||||||
|
|
||||||
this.participants.addAll(details.participants);
|
|
||||||
this.resolving = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocalNumber() {
|
|
||||||
return isLocalNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUserMasterDevice() {
|
|
||||||
String userMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
|
||||||
return userMasterDevice != null && userMasterDevice.equals(getAddress().serialize());
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable Uri getContactUri() {
|
|
||||||
return this.contactUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContactUri(@Nullable Uri contactUri) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (!Util.equals(contactUri, this.contactUri)) {
|
|
||||||
this.contactUri = contactUri;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable String getName() {
|
|
||||||
String displayName = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(this.address.toString());
|
|
||||||
if (displayName != null) { return displayName; }
|
|
||||||
|
|
||||||
if (this.name == null && isMmsGroupRecipient()) {
|
|
||||||
List<String> names = new LinkedList<>();
|
|
||||||
|
|
||||||
for (Recipient recipient : participants) {
|
|
||||||
names.add(recipient.toShortString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Util.join(names, ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(@Nullable String name) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (!Util.equals(this.name, name)) {
|
|
||||||
this.name = name;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @NonNull MaterialColor getColor() {
|
|
||||||
if (isGroupRecipient()) return MaterialColor.GROUP;
|
|
||||||
else if (color != null) return color;
|
|
||||||
else if (name != null) return ContactColors.generateFor(name);
|
|
||||||
else return ContactColors.UNKNOWN_COLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(@NonNull MaterialColor color) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull Address getAddress() {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable String getCustomLabel() {
|
|
||||||
return customLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCustomLabel(@Nullable String customLabel) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (!Util.equals(customLabel, this.customLabel)) {
|
|
||||||
this.customLabel = customLabel;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized Optional<Integer> getDefaultSubscriptionId() {
|
|
||||||
return defaultSubscriptionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultSubscriptionId(Optional<Integer> defaultSubscriptionId) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.defaultSubscriptionId = defaultSubscriptionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable String getProfileName() {
|
|
||||||
return profileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfileName(@Nullable String profileName) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.profileName = profileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable String getProfileAvatar() {
|
|
||||||
return profileAvatar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfileAvatar(@Nullable String profileAvatar) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.profileAvatar = profileAvatar;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
EventBus.getDefault().post(new ProfilePictureModifiedEvent(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isProfileSharing() {
|
|
||||||
return profileSharing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfileSharing(boolean value) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.profileSharing = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGroupRecipient() {
|
|
||||||
return address.isGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOpenGroupRecipient() {
|
|
||||||
return address.isOpenGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMmsGroupRecipient() {
|
|
||||||
return address.isMmsGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPushGroupRecipient() {
|
|
||||||
return address.isGroup() && !address.isMmsGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull synchronized List<Recipient> getParticipants() {
|
|
||||||
return new LinkedList<>(participants);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParticipants(@NonNull List<Recipient> participants) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.participants.clear();
|
|
||||||
this.participants.addAll(participants);
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void addListener(RecipientModifiedListener listener) {
|
|
||||||
if (listeners.isEmpty()) {
|
|
||||||
for (Recipient recipient : participants) recipient.addListener(this);
|
|
||||||
}
|
|
||||||
listeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void removeListener(RecipientModifiedListener listener) {
|
|
||||||
listeners.remove(listener);
|
|
||||||
|
|
||||||
if (listeners.isEmpty()) {
|
|
||||||
for (Recipient recipient : participants) recipient.removeListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized String toShortString() {
|
|
||||||
String name = getName();
|
|
||||||
return (name != null ? name : address.serialize());
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
|
|
||||||
return getFallbackContactPhoto().asDrawable(context, getColor().toAvatarColor(context), inverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @NonNull FallbackContactPhoto getFallbackContactPhoto() {
|
|
||||||
// TODO: I believe this is now completely unused
|
|
||||||
if (isResolving()) return new TransparentContactPhoto();
|
|
||||||
else if (isGroupRecipient()) return new GeneratedContactPhoto(name, R.drawable.ic_profile_default);
|
|
||||||
else { return new TransparentContactPhoto(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable ContactPhoto getContactPhoto() {
|
|
||||||
if (isLocalNumber) return new ProfileContactPhoto(address, String.valueOf(TextSecurePreferences.getProfileAvatarId(context)));
|
|
||||||
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
|
|
||||||
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
|
||||||
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSystemContactPhoto(@Nullable Uri systemContactPhoto) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (!Util.equals(systemContactPhoto, this.systemContactPhoto)) {
|
|
||||||
this.systemContactPhoto = systemContactPhoto;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGroupAvatarId(@Nullable Long groupAvatarId) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (!Util.equals(this.groupAvatarId, groupAvatarId)) {
|
|
||||||
this.groupAvatarId = groupAvatarId;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public synchronized Long getGroupAvatarId() {
|
|
||||||
return groupAvatarId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable Uri getMessageRingtone() {
|
|
||||||
if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return messageRingtone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageRingtone(@Nullable Uri ringtone) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.messageRingtone = ringtone;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable Uri getCallRingtone() {
|
|
||||||
if (callRingtone != null && callRingtone.getScheme() != null && callRingtone.getScheme().startsWith("file")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return callRingtone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCallRingtone(@Nullable Uri ringtone) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.callRingtone = ringtone;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isMuted() {
|
|
||||||
return System.currentTimeMillis() <= mutedUntil;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMuted(long mutedUntil) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.mutedUntil = mutedUntil;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isBlocked() {
|
|
||||||
String masterPublicKey = MultiDeviceProtocol.shared.getMasterDevice(this.address.serialize());
|
|
||||||
if (masterPublicKey != null) {
|
|
||||||
return Recipient.from(context, Address.fromSerialized(masterPublicKey), false).blocked;
|
|
||||||
} else {
|
|
||||||
return blocked;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlocked(boolean blocked) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.blocked = blocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized VibrateState getMessageVibrate() {
|
|
||||||
return messageVibrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageVibrate(VibrateState vibrate) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.messageVibrate = vibrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized VibrateState getCallVibrate() {
|
|
||||||
return callVibrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCallVibrate(VibrateState vibrate) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.callVibrate = vibrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized int getExpireMessages() {
|
|
||||||
return expireMessages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpireMessages(int expireMessages) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.expireMessages = expireMessages;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized RegisteredState getRegistered() {
|
|
||||||
if (isPushGroupRecipient()) return RegisteredState.REGISTERED;
|
|
||||||
else if (isMmsGroupRecipient()) return RegisteredState.NOT_REGISTERED;
|
|
||||||
|
|
||||||
return registered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegistered(@NonNull RegisteredState value) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (this.registered != value) {
|
|
||||||
this.registered = value;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable String getNotificationChannel() {
|
|
||||||
return !NotificationChannels.supported() ? null : notificationChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotificationChannel(@Nullable String value) {
|
|
||||||
boolean notify = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (!Util.equals(this.notificationChannel, value)) {
|
|
||||||
this.notificationChannel = value;
|
|
||||||
notify = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isForceSmsSelection() {
|
|
||||||
return forceSmsSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setForceSmsSelection(boolean value) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.forceSmsSelection = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized @Nullable byte[] getProfileKey() {
|
|
||||||
return profileKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfileKey(@Nullable byte[] profileKey) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.profileKey = profileKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull synchronized UnidentifiedAccessMode getUnidentifiedAccessMode() {
|
|
||||||
return unidentifiedAccessMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnidentifiedAccessMode(@NonNull UnidentifiedAccessMode unidentifiedAccessMode) {
|
|
||||||
synchronized (this) {
|
|
||||||
this.unidentifiedAccessMode = unidentifiedAccessMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isSystemContact() {
|
|
||||||
return contactUri != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized Recipient resolve() {
|
|
||||||
while (resolving) Util.wait(this, 0);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || !(o instanceof Recipient)) return false;
|
|
||||||
|
|
||||||
Recipient that = (Recipient) o;
|
|
||||||
|
|
||||||
return this.address.equals(that.address);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return this.address.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyListeners() {
|
|
||||||
Set<RecipientModifiedListener> localListeners;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
localListeners = new HashSet<>(listeners);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (RecipientModifiedListener listener : localListeners)
|
|
||||||
listener.onModified(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onModified(Recipient recipient) {
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isResolving() {
|
|
||||||
return resolving;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.recipients;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import org.session.libsession.messaging.threads.Address;
|
|
||||||
|
|
||||||
import static android.content.Intent.ACTION_INSERT_OR_EDIT;
|
|
||||||
|
|
||||||
public final class RecipientExporter {
|
|
||||||
|
|
||||||
public static RecipientExporter export(Recipient recipient) {
|
|
||||||
return new RecipientExporter(recipient);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Recipient recipient;
|
|
||||||
|
|
||||||
private RecipientExporter(Recipient recipient) {
|
|
||||||
this.recipient = recipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Intent asAddContactIntent() {
|
|
||||||
Intent intent = new Intent(ACTION_INSERT_OR_EDIT);
|
|
||||||
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
|
||||||
addNameToIntent(intent, recipient.getProfileName());
|
|
||||||
addAddressToIntent(intent, recipient.getAddress());
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addNameToIntent(Intent intent, String profileName) {
|
|
||||||
if (!TextUtils.isEmpty(profileName)) {
|
|
||||||
intent.putExtra(ContactsContract.Intents.Insert.NAME, profileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addAddressToIntent(Intent intent, Address address) {
|
|
||||||
if (address.isPhone()) {
|
|
||||||
intent.putExtra(ContactsContract.Intents.Insert.PHONE, address.toPhoneString());
|
|
||||||
} else if (address.isEmail()) {
|
|
||||||
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, address.toEmailString());
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Cannot export Recipient with neither phone nor email");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2011 Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.recipients;
|
|
||||||
|
|
||||||
public class RecipientFormattingException extends Exception {
|
|
||||||
public RecipientFormattingException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecipientFormattingException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecipientFormattingException(String message, Throwable nested) {
|
|
||||||
super(message, nested);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecipientFormattingException(Throwable nested) {
|
|
||||||
super(nested);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.recipients;
|
|
||||||
|
|
||||||
|
|
||||||
public interface RecipientModifiedListener {
|
|
||||||
public void onModified(Recipient recipient);
|
|
||||||
}
|
|
@ -1,241 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.recipients;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
|
||||||
import org.session.libsession.messaging.threads.Address;
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
|
||||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
|
||||||
import org.thoughtcrime.securesms.util.SoftHashMap;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
|
|
||||||
class RecipientProvider {
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static final String TAG = RecipientProvider.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final RecipientCache recipientCache = new RecipientCache();
|
|
||||||
private static final ExecutorService asyncRecipientResolver = Util.newSingleThreadedLifoExecutor();
|
|
||||||
|
|
||||||
private static final Map<String, RecipientDetails> STATIC_DETAILS = new HashMap<String, RecipientDetails>() {{
|
|
||||||
put("262966", new RecipientDetails("Amazon", null, false, false, null, null));
|
|
||||||
}};
|
|
||||||
|
|
||||||
@NonNull Recipient getRecipient(@NonNull Context context, @NonNull Address address, @NonNull Optional<RecipientSettings> settings, @NonNull Optional<GroupRecord> groupRecord, boolean asynchronous) {
|
|
||||||
Recipient cachedRecipient = recipientCache.get(address);
|
|
||||||
|
|
||||||
if (cachedRecipient != null && (asynchronous || !cachedRecipient.isResolving()) && ((!groupRecord.isPresent() && !settings.isPresent()) || !cachedRecipient.isResolving() || cachedRecipient.getName() != null)) {
|
|
||||||
return cachedRecipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<RecipientDetails> prefetchedRecipientDetails = createPrefetchedRecipientDetails(context, address, settings, groupRecord);
|
|
||||||
|
|
||||||
if (asynchronous) {
|
|
||||||
cachedRecipient = new Recipient(context, address, cachedRecipient, prefetchedRecipientDetails, getRecipientDetailsAsync(context, address, settings, groupRecord));
|
|
||||||
} else {
|
|
||||||
cachedRecipient = new Recipient(context, address, getRecipientDetailsSync(context, address, settings, groupRecord, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
recipientCache.set(address, cachedRecipient);
|
|
||||||
return cachedRecipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull Optional<Recipient> getCached(@NonNull Address address) {
|
|
||||||
return Optional.fromNullable(recipientCache.get(address));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean removeCached(@NonNull Address address) {
|
|
||||||
return recipientCache.remove(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
private @NonNull Optional<RecipientDetails> createPrefetchedRecipientDetails(@NonNull Context context, @NonNull Address address,
|
|
||||||
@NonNull Optional<RecipientSettings> settings,
|
|
||||||
@NonNull Optional<GroupRecord> groupRecord)
|
|
||||||
{
|
|
||||||
if (address.isGroup() && settings.isPresent() && groupRecord.isPresent()) {
|
|
||||||
return Optional.of(getGroupRecipientDetails(context, address, groupRecord, settings, true));
|
|
||||||
} else if (!address.isGroup() && settings.isPresent()) {
|
|
||||||
boolean isLocalNumber = address.serialize().equals(TextSecurePreferences.getLocalNumber(context));
|
|
||||||
return Optional.of(new RecipientDetails(null, null, !TextUtils.isEmpty(settings.get().getSystemDisplayName()), isLocalNumber, settings.get(), null));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private @NonNull ListenableFutureTask<RecipientDetails> getRecipientDetailsAsync(final Context context, final @NonNull Address address, final @NonNull Optional<RecipientSettings> settings, final @NonNull Optional<GroupRecord> groupRecord)
|
|
||||||
{
|
|
||||||
Callable<RecipientDetails> task = () -> getRecipientDetailsSync(context, address, settings, groupRecord, true);
|
|
||||||
|
|
||||||
ListenableFutureTask<RecipientDetails> future = new ListenableFutureTask<>(task);
|
|
||||||
asyncRecipientResolver.submit(future);
|
|
||||||
return future;
|
|
||||||
}
|
|
||||||
|
|
||||||
private @NonNull RecipientDetails getRecipientDetailsSync(Context context, @NonNull Address address, Optional<RecipientSettings> settings, Optional<GroupRecord> groupRecord, boolean nestedAsynchronous) {
|
|
||||||
if (address.isGroup()) return getGroupRecipientDetails(context, address, groupRecord, settings, nestedAsynchronous);
|
|
||||||
else return getIndividualRecipientDetails(context, address, settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private @NonNull RecipientDetails getIndividualRecipientDetails(Context context, @NonNull Address address, Optional<RecipientSettings> settings) {
|
|
||||||
if (!settings.isPresent()) {
|
|
||||||
settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settings.isPresent() && STATIC_DETAILS.containsKey(address.serialize())) {
|
|
||||||
return STATIC_DETAILS.get(address.serialize());
|
|
||||||
} else {
|
|
||||||
boolean systemContact = settings.isPresent() && !TextUtils.isEmpty(settings.get().getSystemDisplayName());
|
|
||||||
boolean isLocalNumber = address.serialize().equals(TextSecurePreferences.getLocalNumber(context));
|
|
||||||
return new RecipientDetails(null, null, systemContact, isLocalNumber, settings.orNull(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, Address groupId, Optional<GroupRecord> groupRecord, Optional<RecipientSettings> settings, boolean asynchronous) {
|
|
||||||
|
|
||||||
if (!groupRecord.isPresent()) {
|
|
||||||
groupRecord = DatabaseFactory.getGroupDatabase(context).getGroup(groupId.toGroupString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settings.isPresent()) {
|
|
||||||
settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(groupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groupRecord.isPresent()) {
|
|
||||||
String title = groupRecord.get().getTitle();
|
|
||||||
List<Address> memberAddresses = groupRecord.get().getMembers();
|
|
||||||
List<Recipient> members = new LinkedList<>();
|
|
||||||
Long avatarId = null;
|
|
||||||
|
|
||||||
for (Address memberAddress : memberAddresses) {
|
|
||||||
members.add(getRecipient(context, memberAddress, Optional.absent(), Optional.absent(), asynchronous));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!groupId.isMmsGroup() && title == null) {
|
|
||||||
title = context.getString(R.string.RecipientProvider_unnamed_group);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groupRecord.get().getAvatar() != null && groupRecord.get().getAvatar().length > 0) {
|
|
||||||
avatarId = groupRecord.get().getAvatarId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RecipientDetails(title, avatarId, false, false, settings.orNull(), members);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), null, false, false, settings.orNull(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class RecipientDetails {
|
|
||||||
@Nullable final String name;
|
|
||||||
@Nullable final String customLabel;
|
|
||||||
@Nullable final Uri systemContactPhoto;
|
|
||||||
@Nullable final Uri contactUri;
|
|
||||||
@Nullable final Long groupAvatarId;
|
|
||||||
@Nullable final MaterialColor color;
|
|
||||||
@Nullable final Uri messageRingtone;
|
|
||||||
@Nullable final Uri callRingtone;
|
|
||||||
final long mutedUntil;
|
|
||||||
@Nullable final VibrateState messageVibrateState;
|
|
||||||
@Nullable final VibrateState callVibrateState;
|
|
||||||
final boolean blocked;
|
|
||||||
final int expireMessages;
|
|
||||||
@NonNull final List<Recipient> participants;
|
|
||||||
@Nullable final String profileName;
|
|
||||||
final Optional<Integer> defaultSubscriptionId;
|
|
||||||
@NonNull final RegisteredState registered;
|
|
||||||
@Nullable final byte[] profileKey;
|
|
||||||
@Nullable final String profileAvatar;
|
|
||||||
final boolean profileSharing;
|
|
||||||
final boolean systemContact;
|
|
||||||
final boolean isLocalNumber;
|
|
||||||
@Nullable final String notificationChannel;
|
|
||||||
@NonNull final UnidentifiedAccessMode unidentifiedAccessMode;
|
|
||||||
final boolean forceSmsSelection;
|
|
||||||
|
|
||||||
RecipientDetails(@Nullable String name, @Nullable Long groupAvatarId,
|
|
||||||
boolean systemContact, boolean isLocalNumber, @Nullable RecipientSettings settings,
|
|
||||||
@Nullable List<Recipient> participants)
|
|
||||||
{
|
|
||||||
this.groupAvatarId = groupAvatarId;
|
|
||||||
this.systemContactPhoto = settings != null ? Util.uri(settings.getSystemContactPhotoUri()) : null;
|
|
||||||
this.customLabel = settings != null ? settings.getSystemPhoneLabel() : null;
|
|
||||||
this.contactUri = settings != null ? Util.uri(settings.getSystemContactUri()) : null;
|
|
||||||
this.color = settings != null ? settings.getColor() : null;
|
|
||||||
this.messageRingtone = settings != null ? settings.getMessageRingtone() : null;
|
|
||||||
this.callRingtone = settings != null ? settings.getCallRingtone() : null;
|
|
||||||
this.mutedUntil = settings != null ? settings.getMuteUntil() : 0;
|
|
||||||
this.messageVibrateState = settings != null ? settings.getMessageVibrateState() : null;
|
|
||||||
this.callVibrateState = settings != null ? settings.getCallVibrateState() : null;
|
|
||||||
this.blocked = settings != null && settings.isBlocked();
|
|
||||||
this.expireMessages = settings != null ? settings.getExpireMessages() : 0;
|
|
||||||
this.participants = participants == null ? new LinkedList<>() : participants;
|
|
||||||
this.profileName = settings != null ? settings.getProfileName() : null;
|
|
||||||
this.defaultSubscriptionId = settings != null ? settings.getDefaultSubscriptionId() : Optional.absent();
|
|
||||||
this.registered = settings != null ? settings.getRegistered() : RegisteredState.UNKNOWN;
|
|
||||||
this.profileKey = settings != null ? settings.getProfileKey() : null;
|
|
||||||
this.profileAvatar = settings != null ? settings.getProfileAvatar() : null;
|
|
||||||
this.profileSharing = settings != null && settings.isProfileSharing();
|
|
||||||
this.systemContact = systemContact;
|
|
||||||
this.isLocalNumber = isLocalNumber;
|
|
||||||
this.notificationChannel = settings != null ? settings.getNotificationChannel() : null;
|
|
||||||
this.unidentifiedAccessMode = settings != null ? settings.getUnidentifiedAccessMode() : UnidentifiedAccessMode.DISABLED;
|
|
||||||
this.forceSmsSelection = settings != null && settings.isForceSmsSelection();
|
|
||||||
|
|
||||||
if (name == null && settings != null) this.name = settings.getSystemDisplayName();
|
|
||||||
else this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RecipientCache {
|
|
||||||
|
|
||||||
private final Map<Address,Recipient> cache = new SoftHashMap<>(1000);
|
|
||||||
|
|
||||||
public synchronized Recipient get(Address address) {
|
|
||||||
return cache.get(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void set(Address address, Recipient recipient) {
|
|
||||||
cache.put(address, recipient);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean remove(Address address) {
|
|
||||||
return cache.remove(address) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2011 Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.recipients;
|
|
||||||
|
|
||||||
import android.telephony.PhoneNumberUtils;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
public class RecipientsFormatter {
|
|
||||||
|
|
||||||
private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
|
|
||||||
int begin = recipient.indexOf('<');
|
|
||||||
int end = recipient.indexOf('>');
|
|
||||||
String value = recipient.substring(begin + 1, end);
|
|
||||||
|
|
||||||
if (PhoneNumberUtils.isWellFormedSmsAddress(value))
|
|
||||||
return value;
|
|
||||||
else
|
|
||||||
throw new RecipientFormattingException("Bracketed value: " + value + " is not valid.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String parseRecipient(String recipient) throws RecipientFormattingException {
|
|
||||||
recipient = recipient.trim();
|
|
||||||
|
|
||||||
if ((recipient.indexOf('<') != -1) && (recipient.indexOf('>') != -1))
|
|
||||||
return parseBracketedNumber(recipient);
|
|
||||||
|
|
||||||
if (PhoneNumberUtils.isWellFormedSmsAddress(recipient))
|
|
||||||
return recipient;
|
|
||||||
|
|
||||||
throw new RecipientFormattingException("Recipient: " + recipient + " is badly formatted.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getRecipients(String rawText) throws RecipientFormattingException {
|
|
||||||
ArrayList<String> results = new ArrayList<String>();
|
|
||||||
StringTokenizer tokenizer = new StringTokenizer(rawText, ",");
|
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
|
||||||
results.add(parseRecipient(tokenizer.nextToken()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatNameAndNumber(String name, String number) {
|
|
||||||
// Format like this: Mike Cleron <(650) 555-1234>
|
|
||||||
// Erick Tseng <(650) 555-1212>
|
|
||||||
// Tutankhamun <tutank1341@gmail.com>
|
|
||||||
// (408) 555-1289
|
|
||||||
String formattedNumber = PhoneNumberUtils.formatNumber(number);
|
|
||||||
if (!TextUtils.isEmpty(name) && !name.equals(number)) {
|
|
||||||
return name + " <" + formattedNumber + ">";
|
|
||||||
} else {
|
|
||||||
return formattedNumber;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -20,7 +20,7 @@ import android.content.Context;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.session.libsession.messaging.threads.Address;
|
import org.session.libsession.messaging.threads.Address;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
@ -15,7 +15,7 @@ import android.webkit.MimeTypeMap;
|
|||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
import com.bumptech.glide.load.resource.gif.GifDrawable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.AudioSlide;
|
import org.thoughtcrime.securesms.mms.AudioSlide;
|
||||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||||
|
@ -48,7 +48,7 @@ import com.google.android.exoplayer2.upstream.BandwidthMeter;
|
|||||||
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
|
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.AttachmentServer;
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentServer;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||||
import org.thoughtcrime.securesms.mms.VideoSlide;
|
import org.thoughtcrime.securesms.mms.VideoSlide;
|
||||||
|
@ -10,7 +10,7 @@ import com.google.android.exoplayer2.upstream.DataSource;
|
|||||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||||
import com.google.android.exoplayer2.upstream.TransferListener;
|
import com.google.android.exoplayer2.upstream.TransferListener;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.mms.PartUriParser;
|
import org.thoughtcrime.securesms.mms.PartUriParser;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.session.libsession.utilities
|
package org.session.libsession.utilities
|
||||||
|
|
||||||
|
import org.session.libsignal.service.api.messages.SignalServiceGroup
|
||||||
|
|
||||||
object GroupUtil {
|
object GroupUtil {
|
||||||
const val CLOSED_GROUP_PREFIX = "__textsecure_group__!"
|
const val CLOSED_GROUP_PREFIX = "__textsecure_group__!"
|
||||||
const val MMS_GROUP_PREFIX = "__signal_mms_group__!"
|
const val MMS_GROUP_PREFIX = "__signal_mms_group__!"
|
||||||
@ -29,6 +31,14 @@ object GroupUtil {
|
|||||||
return (MMS_GROUP_PREFIX + groupID).toByteArray()
|
return (MMS_GROUP_PREFIX + groupID).toByteArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getEncodedId(group: SignalServiceGroup): String? {
|
||||||
|
val groupId = group.groupId
|
||||||
|
if (group.groupType == SignalServiceGroup.GroupType.PUBLIC_CHAT) {
|
||||||
|
return getEncodedOpenGroupID(groupId.toString())
|
||||||
|
}
|
||||||
|
return getEncodedGroupID(groupId)
|
||||||
|
}
|
||||||
|
|
||||||
fun getEncodedGroupID(groupID: ByteArray): String {
|
fun getEncodedGroupID(groupID: ByteArray): String {
|
||||||
return groupID.toString()
|
return groupID.toString()
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package org.session.libsession.utilities
|
package org.session.libsession.utilities
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.provider.Telephony
|
||||||
import org.session.libsession.messaging.threads.Address
|
import org.session.libsession.messaging.threads.Address
|
||||||
import org.session.libsignal.libsignal.logging.Log
|
import org.session.libsignal.libsignal.logging.Log
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
import java.util.concurrent.ThreadPoolExecutor
|
import java.util.concurrent.ThreadPoolExecutor
|
||||||
@ -88,6 +91,11 @@ object Util {
|
|||||||
return executor
|
return executor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun join(list: Array<String?>, delimiter: String?): String {
|
||||||
|
return join(Arrays.asList(*list), delimiter)
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun join(list: Collection<String?>, delimiter: String?): String {
|
fun join(list: Collection<String?>, delimiter: String?): String {
|
||||||
val result = StringBuilder()
|
val result = StringBuilder()
|
||||||
@ -99,6 +107,16 @@ object Util {
|
|||||||
return result.toString()
|
return result.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun join(list: LongArray, delimeter: String?): String {
|
||||||
|
val sb = java.lang.StringBuilder()
|
||||||
|
for (j in list.indices) {
|
||||||
|
if (j != 0) sb.append(delimeter)
|
||||||
|
sb.append(list[j])
|
||||||
|
}
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun equals(a: Any?, b: Any?): Boolean {
|
fun equals(a: Any?, b: Any?): Boolean {
|
||||||
return a === b || a != null && a == b
|
return a === b || a != null && a == b
|
||||||
@ -160,4 +178,25 @@ object Util {
|
|||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun toIsoString(bytes: ByteArray?): String {
|
||||||
|
return String(bytes!!, StandardCharsets.ISO_8859_1)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun toIsoBytes(isoString: String): ByteArray {
|
||||||
|
return isoString.toByteArray(StandardCharsets.ISO_8859_1)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun toUtf8Bytes(utf8String: String): ByteArray {
|
||||||
|
return utf8String.toByteArray(StandardCharsets.UTF_8)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
fun isDefaultSmsProvider(context: Context): Boolean {
|
||||||
|
return context.packageName == Telephony.Sms.getDefaultSmsPackage(context)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user