diff --git a/app/src/main/java/org/thoughtcrime/securesms/MessageDetailsActivity.java b/app/src/main/java/org/thoughtcrime/securesms/MessageDetailsActivity.java index 07abcc8c76..27526e9485 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MessageDetailsActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/MessageDetailsActivity.java @@ -187,8 +187,6 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity transportText = "-"; } else if (messageRecord.isPending()) { transportText = getString(R.string.ConversationFragment_pending); - } else if (messageRecord.isPush()) { - transportText = getString(R.string.ConversationFragment_push); } else if (messageRecord.isMms()) { transportText = getString(R.string.ConversationFragment_mms); } else { @@ -252,9 +250,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity private void updateRecipients(MessageRecord messageRecord, Recipient recipient, List recipients) { final int toFromRes; - if (messageRecord.isMms() && !messageRecord.isPush() && !messageRecord.isOutgoing()) { - toFromRes = R.string.message_details_header__with; - } else if (messageRecord.isOutgoing()) { + if (messageRecord.isOutgoing()) { toFromRes = R.string.message_details_header__to; } else { toFromRes = R.string.message_details_header__from; @@ -360,7 +356,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity List recipients = new LinkedList<>(); if (!messageRecord.getRecipient().isGroupRecipient()) { - recipients.add(new RecipientDeliveryStatus(messageRecord.getRecipient(), getStatusFor(messageRecord.getDeliveryReceiptCount(), messageRecord.getReadReceiptCount(), messageRecord.isPending()), messageRecord.isUnidentified(), -1)); + recipients.add(new RecipientDeliveryStatus(messageRecord.getRecipient(), getStatusFor(messageRecord.getDeliveryReceiptCount(), messageRecord.getReadReceiptCount(), messageRecord.isPending()), true, -1)); } else { List receiptInfoList = DatabaseFactory.getGroupReceiptDatabase(context).getGroupReceiptInfo(messageRecord.getId()); @@ -394,7 +390,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity updateRecipients(messageRecord, messageRecord.getRecipient(), recipients); boolean isGroupNetworkFailure = messageRecord.isFailed() && !messageRecord.getNetworkFailures().isEmpty(); - boolean isIndividualNetworkFailure = messageRecord.isFailed() && !isPushGroup && messageRecord.getIdentityKeyMismatches().isEmpty(); + boolean isIndividualNetworkFailure = messageRecord.isFailed() && !isPushGroup; LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(getContext()); String errorMessage = lokiMessageDatabase.getErrorMessage(messageRecord.id); diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java b/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java index c8942b0298..ac5ee5004c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java @@ -130,7 +130,7 @@ public class ConversationItemFooter extends LinearLayout { } private void presentInsecureIndicator(@NonNull MessageRecord messageRecord) { - insecureIndicatorView.setVisibility(messageRecord.isSecure() ? View.GONE : View.VISIBLE); + insecureIndicatorView.setVisibility(View.GONE); } private void presentDeliveryStatus(@NonNull MessageRecord messageRecord) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java index 7f86e69002..1953568d6e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -351,9 +351,7 @@ public class ConversationFragment extends Fragment } for (MessageRecord messageRecord : messageRecords) { - if (messageRecord.isCallLog() || messageRecord.isExpirationTimerUpdate() || - messageRecord.isIdentityUpdate() || messageRecord.isIdentityVerified() || - messageRecord.isIdentityDefault()) + if (messageRecord.isCallLog() || messageRecord.isExpirationTimerUpdate()) { actionMessage = true; } @@ -384,8 +382,7 @@ public class ConversationFragment extends Fragment menu.findItem(R.id.menu_context_reply).setVisible(!actionMessage && !messageRecord.isPending() && - !messageRecord.isFailed() && - messageRecord.isSecure()); + !messageRecord.isFailed()); } menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && hasText); @@ -625,7 +622,7 @@ public class ConversationFragment extends Fragment intent.putExtra(MessageDetailsActivity.THREAD_ID_EXTRA, threadId); intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, message.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT); intent.putExtra(MessageDetailsActivity.ADDRESS_EXTRA, recipient.getAddress()); - intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, recipient.isGroupRecipient() && message.isPush()); + intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, recipient.isGroupRecipient()); startActivity(intent); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java index 67324c8584..aa60603074 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -857,7 +857,7 @@ public class ConversationItem extends LinearLayout boolean differentTimestamps = next.isPresent() && !DateUtils.isSameExtendedRelativeTimestamp(context, locale, next.get().getTimestamp(), current.getTimestamp()); - if (current.getExpiresIn() > 0 || !current.isSecure() || current.isPending() || + if (current.getExpiresIn() > 0 || current.isPending() || current.isFailed() || differentTimestamps || isEndOfMessageCluster(current, next, isGroupThread)) { ConversationItemFooter activeFooter = getActiveFooter(current); @@ -879,9 +879,7 @@ public class ConversationItem extends LinearLayout } private boolean shouldInterceptClicks(MessageRecord messageRecord) { - return batchSelected.isEmpty() && - ((messageRecord.isFailed() && !messageRecord.isMmsNotification()) || - messageRecord.isBundleKeyExchange()); + return batchSelected.isEmpty() && (messageRecord.isFailed() && !messageRecord.isMmsNotification()); } @SuppressLint("SetTextI18n") @@ -1196,7 +1194,7 @@ public class ConversationItem extends LinearLayout intent.putExtra(MessageDetailsActivity.MESSAGE_ID_EXTRA, messageRecord.getId()); intent.putExtra(MessageDetailsActivity.THREAD_ID_EXTRA, messageRecord.getThreadId()); intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT); - intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, groupThread && messageRecord.isPush()); + intent.putExtra(MessageDetailsActivity.IS_PUSH_GROUP_EXTRA, groupThread); intent.putExtra(MessageDetailsActivity.ADDRESS_EXTRA, conversationRecipient.getAddress()); context.startActivity(intent); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java index 4dd5a96c04..6dfd2fa887 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java @@ -1,7 +1,6 @@ package org.thoughtcrime.securesms.conversation; import android.content.Context; -import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.util.AttributeSet; @@ -15,17 +14,16 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage; +import org.session.libsession.utilities.ExpirationUtil; +import org.session.libsession.utilities.Util; +import org.session.libsession.utilities.recipients.Recipient; +import org.session.libsession.utilities.recipients.RecipientModifiedListener; +import org.session.libsignal.utilities.guava.Optional; import org.thoughtcrime.securesms.BindableConversationItem; import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.loki.utilities.GeneralUtilitiesKt; import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.util.DateUtils; -import org.session.libsignal.utilities.guava.Optional; - -import org.session.libsession.utilities.recipients.Recipient; -import org.session.libsession.utilities.recipients.RecipientModifiedListener; -import org.session.libsession.utilities.ExpirationUtil; -import org.session.libsession.utilities.Util; import java.util.Locale; import java.util.Set; @@ -105,9 +103,6 @@ public class ConversationUpdateItem extends LinearLayout else if (messageRecord.isExpirationTimerUpdate()) setTimerRecord(messageRecord); else if (messageRecord.isScreenshotNotification()) setDataExtractionRecord(messageRecord, DataExtractionNotificationInfoMessage.Kind.SCREENSHOT); else if (messageRecord.isMediaSavedNotification()) setDataExtractionRecord(messageRecord, DataExtractionNotificationInfoMessage.Kind.MEDIA_SAVED); - else if (messageRecord.isIdentityUpdate()) setIdentityRecord(messageRecord); - else if (messageRecord.isIdentityVerified() || - messageRecord.isIdentityDefault()) setIdentityVerifyUpdate(messageRecord); else throw new AssertionError("Neither group nor log nor joined."); if (batchSelected.contains(messageRecord)) setSelected(true); @@ -161,58 +156,6 @@ public class ConversationUpdateItem extends LinearLayout date.setVisibility(GONE); } - private void setIdentityRecord(final MessageRecord messageRecord) { - icon.setImageResource(R.drawable.ic_security_white_24dp); - icon.setColorFilter(new PorterDuffColorFilter(Color.parseColor("#757575"), PorterDuff.Mode.MULTIPLY)); - body.setText(messageRecord.getDisplayBody(getContext())); - - title.setVisibility(GONE); - body.setVisibility(VISIBLE); - date.setVisibility(GONE); - } - - private void setIdentityVerifyUpdate(final MessageRecord messageRecord) { - if (messageRecord.isIdentityVerified()) icon.setImageResource(R.drawable.ic_check_white_24dp); - else icon.setImageResource(R.drawable.ic_info_outline_white_24dp); - - icon.setColorFilter(new PorterDuffColorFilter(Color.parseColor("#757575"), PorterDuff.Mode.MULTIPLY)); - body.setText(messageRecord.getDisplayBody(getContext())); - - title.setVisibility(GONE); - body.setVisibility(VISIBLE); - date.setVisibility(GONE); - } - - private void setGroupRecord(MessageRecord messageRecord) { - icon.setImageResource(R.drawable.ic_group_grey600_24dp); - icon.clearColorFilter(); - body.setText(messageRecord.getDisplayBody(getContext())); - - title.setVisibility(GONE); - body.setVisibility(VISIBLE); - date.setVisibility(GONE); - } - - private void setJoinedRecord(MessageRecord messageRecord) { - icon.setImageResource(R.drawable.ic_favorite_grey600_24dp); - icon.clearColorFilter(); - body.setText(messageRecord.getDisplayBody(getContext())); - - title.setVisibility(GONE); - body.setVisibility(VISIBLE); - date.setVisibility(GONE); - } - - private void setEndSessionRecord(MessageRecord messageRecord) { - icon.setImageResource(R.drawable.ic_refresh_white_24dp); - icon.setColorFilter(new PorterDuffColorFilter(Color.parseColor("#757575"), PorterDuff.Mode.MULTIPLY)); - body.setText(messageRecord.getDisplayBody(getContext())); - - title.setVisibility(GONE); - body.setVisibility(VISIBLE); - date.setVisibility(GONE); - } - private void setTextMessageRecord(MessageRecord messageRecord) { body.setText(messageRecord.getDisplayBody(getContext())); @@ -249,36 +192,7 @@ public class ConversationUpdateItem extends LinearLayout @Override public void onClick(View v) { - if ((!messageRecord.isIdentityUpdate() && - !messageRecord.isIdentityDefault() && - !messageRecord.isIdentityVerified()) || - !batchSelected.isEmpty()) - { - if (parent != null) parent.onClick(v); - return; - } - final Recipient sender = ConversationUpdateItem.this.sender; - -// IdentityUtil.getRemoteIdentityKey(getContext(), sender).addListener(new ListenableFuture.Listener>() { -// @Override -// public void onSuccess(Optional result) { -// if (result.isPresent()) { -// Intent intent = new Intent(getContext(), VerifyIdentityActivity.class); -// intent.putExtra(VerifyIdentityActivity.ADDRESS_EXTRA, sender.getAddress()); -// intent.putExtra(VerifyIdentityActivity.IDENTITY_EXTRA, new IdentityKeyParcelable(result.get().getIdentityKey())); -// intent.putExtra(VerifyIdentityActivity.VERIFIED_EXTRA, result.get().getVerifiedStatus() == IdentityDatabase.VerifiedStatus.VERIFIED); -// -// getContext().startActivity(intent); -// } -// } -// -// @Override -// public void onFailure(ExecutionException e) { -// Log.w(TAG, e); -// } -// }); } } - } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/SmsDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/SmsDatabase.java index dfbc39f156..d241db9862 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/SmsDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/SmsDatabase.java @@ -28,23 +28,21 @@ import com.annimon.stream.Stream; import net.sqlcipher.database.SQLiteDatabase; import net.sqlcipher.database.SQLiteStatement; -import org.session.libsignal.utilities.Log; -import org.thoughtcrime.securesms.ApplicationContext; -import org.session.libsession.utilities.IdentityKeyMismatch; -import org.session.libsession.utilities.IdentityKeyMismatchList; -import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.thoughtcrime.securesms.database.model.MessageRecord; -import org.thoughtcrime.securesms.database.model.SmsMessageRecord; import org.session.libsession.messaging.messages.signal.IncomingGroupMessage; import org.session.libsession.messaging.messages.signal.IncomingTextMessage; import org.session.libsession.messaging.messages.signal.OutgoingTextMessage; - import org.session.libsession.utilities.Address; -import org.session.libsession.utilities.recipients.Recipient; -import org.session.libsignal.utilities.JsonUtil; +import org.session.libsession.utilities.IdentityKeyMismatch; +import org.session.libsession.utilities.IdentityKeyMismatchList; import org.session.libsession.utilities.TextSecurePreferences; import org.session.libsession.utilities.Util; +import org.session.libsession.utilities.recipients.Recipient; +import org.session.libsignal.utilities.JsonUtil; +import org.session.libsignal.utilities.Log; import org.session.libsignal.utilities.guava.Optional; +import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; +import org.thoughtcrime.securesms.database.model.MessageRecord; +import org.thoughtcrime.securesms.database.model.SmsMessageRecord; import java.io.IOException; import java.security.SecureRandom; @@ -641,10 +639,10 @@ public class SmsDatabase extends MessagingDatabase { public MessageRecord getCurrent() { return new SmsMessageRecord(id, message.getMessageBody(), message.getRecipient(), message.getRecipient(), - 1, System.currentTimeMillis(), System.currentTimeMillis(), + System.currentTimeMillis(), System.currentTimeMillis(), 0, message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(), threadId, 0, new LinkedList(), - message.getSubscriptionId(), message.getExpiresIn(), + message.getExpiresIn(), System.currentTimeMillis(), 0, false); } } @@ -696,9 +694,8 @@ public class SmsDatabase extends MessagingDatabase { return new SmsMessageRecord(messageId, body, recipient, recipient, - addressDeviceId, dateSent, dateReceived, deliveryReceiptCount, type, - threadId, status, mismatches, subscriptionId, + threadId, status, mismatches, expiresIn, expireStarted, readReceiptCount, unidentified); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java b/app/src/main/java/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java index 97b7329bc4..fa03a101b5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java @@ -17,22 +17,24 @@ package org.thoughtcrime.securesms.database.model; import android.content.Context; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.text.SpannableString; -import network.loki.messenger.R; -import org.session.libsession.utilities.Contact; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview; -import org.thoughtcrime.securesms.database.MmsDatabase; -import org.thoughtcrime.securesms.database.SmsDatabase.Status; +import org.session.libsession.utilities.Contact; import org.session.libsession.utilities.IdentityKeyMismatch; import org.session.libsession.utilities.NetworkFailure; -import org.thoughtcrime.securesms.mms.SlideDeck; import org.session.libsession.utilities.recipients.Recipient; +import org.thoughtcrime.securesms.database.MmsDatabase; +import org.thoughtcrime.securesms.database.SmsDatabase.Status; +import org.thoughtcrime.securesms.mms.SlideDeck; import java.util.List; +import network.loki.messenger.R; + /** * Represents the message record model for MMS messages that contain * media (ie: they've been downloaded). @@ -58,9 +60,9 @@ public class MediaMmsMessageRecord extends MmsMessageRecord { @Nullable Quote quote, @NonNull List contacts, @NonNull List linkPreviews, boolean unidentified) { - super(id, body, conversationRecipient, individualRecipient, recipientDeviceId, dateSent, + super(id, body, conversationRecipient, individualRecipient, dateSent, dateReceived, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox, mismatches, failures, - subscriptionId, expiresIn, expireStarted, slideDeck, readReceiptCount, quote, contacts, + expiresIn, expireStarted, slideDeck, readReceiptCount, quote, contacts, linkPreviews, unidentified); this.partCount = partCount; } @@ -82,8 +84,6 @@ public class MediaMmsMessageRecord extends MmsMessageRecord { return emphasisAdded(context.getString(R.string.SmsMessageRecord_duplicate_message)); } else if (MmsDatabase.Types.isNoRemoteSessionType(type)) { return emphasisAdded(context.getString(R.string.MmsMessageRecord_mms_message_encrypted_for_non_existing_session)); - } else if (isLegacyMessage()) { - return emphasisAdded(context.getString(R.string.MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported)); } return super.getDisplayBody(context); diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/model/MessageRecord.java b/app/src/main/java/org/thoughtcrime/securesms/database/model/MessageRecord.java index 8aa4d804e1..ebbd1ea8de 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/model/MessageRecord.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/model/MessageRecord.java @@ -30,8 +30,6 @@ import org.session.libsession.messaging.utilities.UpdateMessageData; import org.session.libsession.utilities.IdentityKeyMismatch; import org.session.libsession.utilities.NetworkFailure; import org.session.libsession.utilities.recipients.Recipient; -import org.thoughtcrime.securesms.database.MmsSmsColumns; -import org.thoughtcrime.securesms.database.SmsDatabase; import java.util.List; @@ -44,48 +42,62 @@ import java.util.List; * */ public abstract class MessageRecord extends DisplayRecord { - private final Recipient individualRecipient; - private final int recipientDeviceId; - public final long id; private final List mismatches; private final List networkFailures; - private final int subscriptionId; private final long expiresIn; private final long expireStarted; private final boolean unidentified; + public final long id; + + public abstract boolean isMms(); + public abstract boolean isMmsNotification(); MessageRecord(long id, String body, Recipient conversationRecipient, - Recipient individualRecipient, int recipientDeviceId, - long dateSent, long dateReceived, long threadId, - int deliveryStatus, int deliveryReceiptCount, long type, - List mismatches, - List networkFailures, - int subscriptionId, long expiresIn, long expireStarted, - int readReceiptCount, boolean unidentified) + Recipient individualRecipient, + long dateSent, long dateReceived, long threadId, + int deliveryStatus, int deliveryReceiptCount, long type, + List mismatches, + List networkFailures, + long expiresIn, long expireStarted, + int readReceiptCount, boolean unidentified) { super(body, conversationRecipient, dateSent, dateReceived, - threadId, deliveryStatus, deliveryReceiptCount, type, readReceiptCount); + threadId, deliveryStatus, deliveryReceiptCount, type, readReceiptCount); this.id = id; this.individualRecipient = individualRecipient; - this.recipientDeviceId = recipientDeviceId; this.mismatches = mismatches; this.networkFailures = networkFailures; - this.subscriptionId = subscriptionId; this.expiresIn = expiresIn; this.expireStarted = expireStarted; this.unidentified = unidentified; } - public abstract boolean isMms(); - public abstract boolean isMmsNotification(); - - public boolean isSecure() { - return MmsSmsColumns.Types.isSecureType(type); + public long getId() { + return id; + } + public long getTimestamp() { + return getDateSent(); + } + public Recipient getIndividualRecipient() { + return individualRecipient; + } + public long getType() { + return type; + } + public List getNetworkFailures() { + return networkFailures; + } + public long getExpiresIn() { + return expiresIn; + } + public long getExpireStarted() { return expireStarted; } + public boolean isMediaPending() { + return false; } - public boolean isLegacyMessage() { - return MmsSmsColumns.Types.isLegacyType(type); + public boolean isUpdate() { + return isExpirationTimerUpdate() || isCallLog() || isDataExtractionNotification(); } @Override @@ -104,77 +116,6 @@ public abstract class MessageRecord extends DisplayRecord { return new SpannableString(getBody()); } - public long getId() { - return id; - } - - public boolean isPush() { - return SmsDatabase.Types.isPushType(type) && !SmsDatabase.Types.isForcedSms(type); - } - - public long getTimestamp() { - if (getRecipient().getAddress().isOpenGroup()) { - return getDateReceived(); - } - if (isPush() && getDateSent() < getDateReceived()) { - return getDateSent(); - } - return getDateReceived(); - } - - public boolean isForcedSms() { - return SmsDatabase.Types.isForcedSms(type); - } - - public boolean isIdentityVerified() { - return SmsDatabase.Types.isIdentityVerified(type); - } - - public boolean isIdentityDefault() { - return SmsDatabase.Types.isIdentityDefault(type); - } - - public boolean isBundleKeyExchange() { - return SmsDatabase.Types.isBundleKeyExchange(type); - } - - public boolean isIdentityUpdate() { - return SmsDatabase.Types.isIdentityUpdate(type); - } - - public boolean isCorruptedKeyExchange() { - return SmsDatabase.Types.isCorruptedKeyExchange(type); - } - - public boolean isInvalidVersionKeyExchange() { - return SmsDatabase.Types.isInvalidVersionKeyExchange(type); - } - - public boolean isUpdate() { - return isExpirationTimerUpdate() || isCallLog() || isDataExtractionNotification() || - isIdentityUpdate() || isIdentityVerified() || isIdentityDefault(); - } - - public boolean isMediaPending() { - return false; - } - - public Recipient getIndividualRecipient() { - return individualRecipient; - } - - public long getType() { - return type; - } - - public List getIdentityKeyMismatches() { - return mismatches; - } - - public List getNetworkFailures() { - return networkFailures; - } - protected SpannableString emphasisAdded(String sequence) { SpannableString spannable = new SpannableString(sequence); spannable.setSpan(new RelativeSizeSpan(0.9f), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -184,25 +125,12 @@ public abstract class MessageRecord extends DisplayRecord { } public boolean equals(Object other) { - return other != null && - other instanceof MessageRecord && - ((MessageRecord) other).getId() == getId() && - ((MessageRecord) other).isMms() == isMms(); + return other instanceof MessageRecord + && ((MessageRecord) other).getId() == getId() + && ((MessageRecord) other).isMms() == isMms(); } public int hashCode() { return (int)getId(); } - - public long getExpiresIn() { - return expiresIn; - } - - public long getExpireStarted() { - return expireStarted; - } - - public boolean isUnidentified() { - return unidentified; - } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java b/app/src/main/java/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java index 528720547c..29e01fff2a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java @@ -25,15 +25,15 @@ public abstract class MmsMessageRecord extends MessageRecord { private final @NonNull List linkPreviews = new LinkedList<>(); MmsMessageRecord(long id, String body, Recipient conversationRecipient, - Recipient individualRecipient, int recipientDeviceId, long dateSent, + Recipient individualRecipient, long dateSent, long dateReceived, long threadId, int deliveryStatus, int deliveryReceiptCount, long type, List mismatches, - List networkFailures, int subscriptionId, long expiresIn, + List networkFailures, long expiresIn, long expireStarted, @NonNull SlideDeck slideDeck, int readReceiptCount, @Nullable Quote quote, @NonNull List contacts, @NonNull List linkPreviews, boolean unidentified) { - super(id, body, conversationRecipient, individualRecipient, recipientDeviceId, dateSent, dateReceived, threadId, deliveryStatus, deliveryReceiptCount, type, mismatches, networkFailures, subscriptionId, expiresIn, expireStarted, readReceiptCount, unidentified); + super(id, body, conversationRecipient, individualRecipient, dateSent, dateReceived, threadId, deliveryStatus, deliveryReceiptCount, type, mismatches, networkFailures, expiresIn, expireStarted, readReceiptCount, unidentified); this.slideDeck = slideDeck; this.quote = quote; diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java b/app/src/main/java/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java index 361be34d39..ee6e75647b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java @@ -17,20 +17,22 @@ package org.thoughtcrime.securesms.database.model; import android.content.Context; -import androidx.annotation.NonNull; import android.text.SpannableString; -import network.loki.messenger.R; -import org.thoughtcrime.securesms.database.MmsDatabase; -import org.thoughtcrime.securesms.database.SmsDatabase.Status; +import androidx.annotation.NonNull; + import org.session.libsession.utilities.IdentityKeyMismatch; import org.session.libsession.utilities.NetworkFailure; -import org.thoughtcrime.securesms.mms.SlideDeck; import org.session.libsession.utilities.recipients.Recipient; +import org.thoughtcrime.securesms.database.MmsDatabase; +import org.thoughtcrime.securesms.database.SmsDatabase.Status; +import org.thoughtcrime.securesms.mms.SlideDeck; import java.util.Collections; import java.util.LinkedList; +import network.loki.messenger.R; + /** * Represents the message record model for MMS messages that are * notifications (ie: they're pointers to undownloaded media). @@ -54,9 +56,9 @@ public class NotificationMmsMessageRecord extends MmsMessageRecord { long expiry, int status, byte[] transactionId, long mailbox, int subscriptionId, SlideDeck slideDeck, int readReceiptCount) { - super(id, "", conversationRecipient, individualRecipient, recipientDeviceId, + super(id, "", conversationRecipient, individualRecipient, dateSent, dateReceived, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox, - new LinkedList(), new LinkedList(), subscriptionId, + new LinkedList(), new LinkedList(), 0, 0, slideDeck, readReceiptCount, null, Collections.emptyList(), Collections.emptyList(), false); this.contentLocation = contentLocation; @@ -91,11 +93,6 @@ public class NotificationMmsMessageRecord extends MmsMessageRecord { return false; } - @Override - public boolean isSecure() { - return false; - } - @Override public boolean isPending() { return false; diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java b/app/src/main/java/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java index 07d8bc818d..f757d96fac 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java @@ -22,10 +22,9 @@ import android.text.SpannableString; import androidx.annotation.NonNull; -import org.thoughtcrime.securesms.database.MmsSmsColumns; -import org.thoughtcrime.securesms.database.SmsDatabase; import org.session.libsession.utilities.IdentityKeyMismatch; import org.session.libsession.utilities.recipients.Recipient; +import org.thoughtcrime.securesms.database.SmsDatabase; import java.util.LinkedList; import java.util.List; @@ -43,17 +42,16 @@ public class SmsMessageRecord extends MessageRecord { public SmsMessageRecord(long id, String body, Recipient recipient, Recipient individualRecipient, - int recipientDeviceId, long dateSent, long dateReceived, int deliveryReceiptCount, long type, long threadId, int status, List mismatches, - int subscriptionId, long expiresIn, long expireStarted, + long expiresIn, long expireStarted, int readReceiptCount, boolean unidentified) { - super(id, body, recipient, individualRecipient, recipientDeviceId, + super(id, body, recipient, individualRecipient, dateSent, dateReceived, threadId, status, deliveryReceiptCount, type, - mismatches, new LinkedList<>(), subscriptionId, + mismatches, new LinkedList<>(), expiresIn, expireStarted, readReceiptCount, unidentified); } @@ -63,17 +61,8 @@ public class SmsMessageRecord extends MessageRecord { @Override public SpannableString getDisplayBody(@NonNull Context context) { - Recipient recipient = getRecipient(); if (SmsDatabase.Types.isFailedDecryptType(type)) { return emphasisAdded(context.getString(R.string.MessageDisplayHelper_bad_encrypted_message)); - } else if (isCorruptedKeyExchange()) { - return emphasisAdded(context.getString(R.string.SmsMessageRecord_received_corrupted_key_exchange_message)); - } else if (isInvalidVersionKeyExchange()) { - return emphasisAdded(context.getString(R.string.SmsMessageRecord_received_key_exchange_message_for_invalid_protocol_version)); - } else if (MmsSmsColumns.Types.isLegacyType(type)) { - return emphasisAdded(context.getString(R.string.MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported)); - } else if (isBundleKeyExchange()) { - return emphasisAdded(context.getString(R.string.SmsMessageRecord_received_message_with_new_safety_number_tap_to_process)); } else if (SmsDatabase.Types.isDuplicateMessageType(type)) { return emphasisAdded(context.getString(R.string.SmsMessageRecord_duplicate_message)); } else if (SmsDatabase.Types.isNoRemoteSessionType(type)) {