mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 07:32:19 +00:00
Make DisplayRecord take context as argument, so locale is more likely to be correct.
This commit is contained in:
@@ -1291,7 +1291,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
public MessageRecord getCurrent() {
|
||||
SlideDeck slideDeck = new SlideDeck(context, message.getAttachments());
|
||||
|
||||
return new MediaMmsMessageRecord(context, id, message.getRecipient(), message.getRecipient(),
|
||||
return new MediaMmsMessageRecord(id, message.getRecipient(), message.getRecipient(),
|
||||
1, System.currentTimeMillis(), System.currentTimeMillis(),
|
||||
0, threadId, message.getBody(),
|
||||
slideDeck, slideDeck.getSlides().size(),
|
||||
@@ -1372,7 +1372,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
SlideDeck slideDeck = new SlideDeck(context, new MmsNotificationAttachment(status, messageSize));
|
||||
|
||||
|
||||
return new NotificationMmsMessageRecord(context, id, recipient, recipient,
|
||||
return new NotificationMmsMessageRecord(id, recipient, recipient,
|
||||
addressDeviceId, dateSent, dateReceived, deliveryReceiptCount, threadId,
|
||||
contentLocationBytes, messageSize, expiry, status,
|
||||
transactionIdBytes, mailbox, subscriptionId, slideDeck,
|
||||
@@ -1413,7 +1413,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
SlideDeck slideDeck = getSlideDeck(Stream.of(attachments).filterNot(contactAttachments::contains).filterNot(previewAttachments::contains).toList());
|
||||
Quote quote = getQuote(cursor);
|
||||
|
||||
return new MediaMmsMessageRecord(context, id, recipient, recipient,
|
||||
return new MediaMmsMessageRecord(id, recipient, recipient,
|
||||
addressDeviceId, dateSent, dateReceived, deliveryReceiptCount,
|
||||
threadId, body, slideDeck, partCount, box, mismatches,
|
||||
networkFailures, subscriptionId, expiresIn, expireStarted,
|
||||
|
||||
@@ -828,7 +828,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
}
|
||||
|
||||
public MessageRecord getCurrent() {
|
||||
return new SmsMessageRecord(context, id, message.getMessageBody(),
|
||||
return new SmsMessageRecord(id, message.getMessageBody(),
|
||||
message.getRecipient(), message.getRecipient(),
|
||||
1, System.currentTimeMillis(), System.currentTimeMillis(),
|
||||
0, message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(),
|
||||
@@ -883,7 +883,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
List<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument);
|
||||
Recipient recipient = Recipient.from(context, address, true);
|
||||
|
||||
return new SmsMessageRecord(context, messageId, body, recipient,
|
||||
return new SmsMessageRecord(messageId, body, recipient,
|
||||
recipient,
|
||||
addressDeviceId,
|
||||
dateSent, dateReceived, deliveryReceiptCount, type,
|
||||
|
||||
@@ -687,7 +687,7 @@ public class ThreadDatabase extends Database {
|
||||
readReceiptCount = 0;
|
||||
}
|
||||
|
||||
return new ThreadRecord(context, body, snippetUri, recipient, date, count,
|
||||
return new ThreadRecord(body, snippetUri, recipient, date, count,
|
||||
unreadCount, threadId, deliveryReceiptCount, status, type,
|
||||
distributionType, archived, expiresIn, lastSeen, readReceiptCount);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
public abstract class DisplayRecord {
|
||||
|
||||
protected final Context context;
|
||||
protected final long type;
|
||||
|
||||
private final Recipient recipient;
|
||||
@@ -46,11 +45,10 @@ public abstract class DisplayRecord {
|
||||
private final int deliveryReceiptCount;
|
||||
private final int readReceiptCount;
|
||||
|
||||
DisplayRecord(Context context, String body, Recipient recipient, long dateSent,
|
||||
DisplayRecord(String body, Recipient recipient, long dateSent,
|
||||
long dateReceived, long threadId, int deliveryStatus, int deliveryReceiptCount,
|
||||
long type, int readReceiptCount)
|
||||
{
|
||||
this.context = context.getApplicationContext();
|
||||
this.threadId = threadId;
|
||||
this.recipient = recipient;
|
||||
this.dateSent = dateSent;
|
||||
@@ -83,7 +81,7 @@ public abstract class DisplayRecord {
|
||||
return MmsSmsColumns.Types.isOutgoingMessageType(type);
|
||||
}
|
||||
|
||||
public abstract SpannableString getDisplayBody();
|
||||
public abstract SpannableString getDisplayBody(@NonNull Context context);
|
||||
|
||||
public Recipient getRecipient() {
|
||||
return recipient;
|
||||
|
||||
@@ -44,10 +44,9 @@ import java.util.List;
|
||||
public class MediaMmsMessageRecord extends MmsMessageRecord {
|
||||
private final static String TAG = MediaMmsMessageRecord.class.getSimpleName();
|
||||
|
||||
private final Context context;
|
||||
private final int partCount;
|
||||
|
||||
public MediaMmsMessageRecord(Context context, long id, Recipient conversationRecipient,
|
||||
public MediaMmsMessageRecord(long id, Recipient conversationRecipient,
|
||||
Recipient individualRecipient, int recipientDeviceId,
|
||||
long dateSent, long dateReceived, int deliveryReceiptCount,
|
||||
long threadId, String body,
|
||||
@@ -59,12 +58,10 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
||||
@Nullable Quote quote, @Nullable List<Contact> contacts,
|
||||
@Nullable List<LinkPreview> linkPreviews, boolean unidentified)
|
||||
{
|
||||
super(context, id, body, conversationRecipient, individualRecipient, recipientDeviceId, dateSent,
|
||||
super(id, body, conversationRecipient, individualRecipient, recipientDeviceId, dateSent,
|
||||
dateReceived, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox, mismatches, failures,
|
||||
subscriptionId, expiresIn, expireStarted, slideDeck, readReceiptCount, quote, contacts,
|
||||
linkPreviews, unidentified);
|
||||
|
||||
this.context = context.getApplicationContext();
|
||||
this.partCount = partCount;
|
||||
}
|
||||
|
||||
@@ -78,7 +75,7 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpannableString getDisplayBody() {
|
||||
public SpannableString getDisplayBody(@NonNull Context context) {
|
||||
if (MmsDatabase.Types.isFailedDecryptType(type)) {
|
||||
return emphasisAdded(context.getString(R.string.MmsMessageRecord_bad_encrypted_mms_message));
|
||||
} else if (MmsDatabase.Types.isDuplicateMessageType(type)) {
|
||||
@@ -89,6 +86,6 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
||||
return emphasisAdded(context.getString(R.string.MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported));
|
||||
}
|
||||
|
||||
return super.getDisplayBody();
|
||||
return super.getDisplayBody(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
@@ -53,7 +54,7 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
private final long expireStarted;
|
||||
private final boolean unidentified;
|
||||
|
||||
MessageRecord(Context context, long id, String body, Recipient conversationRecipient,
|
||||
MessageRecord(long id, String body, Recipient conversationRecipient,
|
||||
Recipient individualRecipient, int recipientDeviceId,
|
||||
long dateSent, long dateReceived, long threadId,
|
||||
int deliveryStatus, int deliveryReceiptCount, long type,
|
||||
@@ -62,7 +63,7 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
int subscriptionId, long expiresIn, long expireStarted,
|
||||
int readReceiptCount, boolean unidentified)
|
||||
{
|
||||
super(context, body, conversationRecipient, dateSent, dateReceived,
|
||||
super(body, conversationRecipient, dateSent, dateReceived,
|
||||
threadId, deliveryStatus, deliveryReceiptCount, type, readReceiptCount);
|
||||
this.id = id;
|
||||
this.individualRecipient = individualRecipient;
|
||||
@@ -87,7 +88,7 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpannableString getDisplayBody() {
|
||||
public SpannableString getDisplayBody(@NonNull Context context) {
|
||||
if (isGroupUpdate() && isOutgoing()) {
|
||||
return new SpannableString(context.getString(R.string.MessageRecord_you_updated_group));
|
||||
} else if (isGroupUpdate()) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class MmsMessageRecord extends MessageRecord {
|
||||
private final @NonNull List<Contact> contacts = new LinkedList<>();
|
||||
private final @NonNull List<LinkPreview> linkPreviews = new LinkedList<>();
|
||||
|
||||
MmsMessageRecord(Context context, long id, String body, Recipient conversationRecipient,
|
||||
MmsMessageRecord(long id, String body, Recipient conversationRecipient,
|
||||
Recipient individualRecipient, int recipientDeviceId, long dateSent,
|
||||
long dateReceived, long threadId, int deliveryStatus, int deliveryReceiptCount,
|
||||
long type, List<IdentityKeyMismatch> mismatches,
|
||||
@@ -32,7 +32,7 @@ public abstract class MmsMessageRecord extends MessageRecord {
|
||||
@Nullable Quote quote, @NonNull List<Contact> contacts,
|
||||
@NonNull List<LinkPreview> linkPreviews, boolean unidentified)
|
||||
{
|
||||
super(context, id, body, conversationRecipient, individualRecipient, recipientDeviceId, dateSent, dateReceived, threadId, deliveryStatus, deliveryReceiptCount, type, mismatches, networkFailures, subscriptionId, expiresIn, expireStarted, readReceiptCount, unidentified);
|
||||
super(id, body, conversationRecipient, individualRecipient, recipientDeviceId, dateSent, dateReceived, threadId, deliveryStatus, deliveryReceiptCount, type, mismatches, networkFailures, subscriptionId, expiresIn, expireStarted, readReceiptCount, unidentified);
|
||||
|
||||
this.slideDeck = slideDeck;
|
||||
this.quote = quote;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.SpannableString;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -46,14 +47,14 @@ public class NotificationMmsMessageRecord extends MmsMessageRecord {
|
||||
private final int status;
|
||||
private final byte[] transactionId;
|
||||
|
||||
public NotificationMmsMessageRecord(Context context, long id, Recipient conversationRecipient,
|
||||
public NotificationMmsMessageRecord(long id, Recipient conversationRecipient,
|
||||
Recipient individualRecipient, int recipientDeviceId,
|
||||
long dateSent, long dateReceived, int deliveryReceiptCount,
|
||||
long threadId, byte[] contentLocation, long messageSize,
|
||||
long expiry, int status, byte[] transactionId, long mailbox,
|
||||
int subscriptionId, SlideDeck slideDeck, int readReceiptCount)
|
||||
{
|
||||
super(context, id, "", conversationRecipient, individualRecipient, recipientDeviceId,
|
||||
super(id, "", conversationRecipient, individualRecipient, recipientDeviceId,
|
||||
dateSent, dateReceived, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox,
|
||||
new LinkedList<IdentityKeyMismatch>(), new LinkedList<NetworkFailure>(), subscriptionId,
|
||||
0, 0, slideDeck, readReceiptCount, null, Collections.emptyList(), Collections.emptyList(), false);
|
||||
@@ -111,7 +112,7 @@ public class NotificationMmsMessageRecord extends MmsMessageRecord {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpannableString getDisplayBody() {
|
||||
public SpannableString getDisplayBody(@NonNull Context context) {
|
||||
if (status == MmsDatabase.Status.DOWNLOAD_INITIALIZED) {
|
||||
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_multimedia_message));
|
||||
} else if (status == MmsDatabase.Status.DOWNLOAD_CONNECTING) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.SpannableString;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -38,7 +39,7 @@ import java.util.List;
|
||||
|
||||
public class SmsMessageRecord extends MessageRecord {
|
||||
|
||||
public SmsMessageRecord(Context context, long id,
|
||||
public SmsMessageRecord(long id,
|
||||
String body, Recipient recipient,
|
||||
Recipient individualRecipient,
|
||||
int recipientDeviceId,
|
||||
@@ -49,7 +50,7 @@ public class SmsMessageRecord extends MessageRecord {
|
||||
int subscriptionId, long expiresIn, long expireStarted,
|
||||
int readReceiptCount, boolean unidentified)
|
||||
{
|
||||
super(context, id, body, recipient, individualRecipient, recipientDeviceId,
|
||||
super(id, body, recipient, individualRecipient, recipientDeviceId,
|
||||
dateSent, dateReceived, threadId, status, deliveryReceiptCount, type,
|
||||
mismatches, new LinkedList<>(), subscriptionId,
|
||||
expiresIn, expireStarted, readReceiptCount, unidentified);
|
||||
@@ -60,7 +61,7 @@ public class SmsMessageRecord extends MessageRecord {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpannableString getDisplayBody() {
|
||||
public SpannableString getDisplayBody(@NonNull Context context) {
|
||||
if (SmsDatabase.Types.isFailedDecryptType(type)) {
|
||||
return emphasisAdded(context.getString(R.string.MessageDisplayHelper_bad_encrypted_message));
|
||||
} else if (isCorruptedKeyExchange()) {
|
||||
@@ -84,7 +85,7 @@ public class SmsMessageRecord extends MessageRecord {
|
||||
} else if (isEndSession()) {
|
||||
return emphasisAdded(context.getString(R.string.SmsMessageRecord_secure_session_reset_s, getIndividualRecipient().toShortString()));
|
||||
} else {
|
||||
return super.getDisplayBody();
|
||||
return super.getDisplayBody(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.thoughtcrime.securesms.util.ExpirationUtil;
|
||||
*/
|
||||
public class ThreadRecord extends DisplayRecord {
|
||||
|
||||
private @NonNull final Context context;
|
||||
private @Nullable final Uri snippetUri;
|
||||
private final long count;
|
||||
private final int unreadCount;
|
||||
@@ -49,14 +48,13 @@ public class ThreadRecord extends DisplayRecord {
|
||||
private final long expiresIn;
|
||||
private final long lastSeen;
|
||||
|
||||
public ThreadRecord(@NonNull Context context, @NonNull String body, @Nullable Uri snippetUri,
|
||||
public ThreadRecord(@NonNull String body, @Nullable Uri snippetUri,
|
||||
@NonNull Recipient recipient, long date, long count, int unreadCount,
|
||||
long threadId, int deliveryReceiptCount, int status, long snippetType,
|
||||
int distributionType, boolean archived, long expiresIn, long lastSeen,
|
||||
int readReceiptCount)
|
||||
{
|
||||
super(context, body, recipient, date, date, threadId, status, deliveryReceiptCount, snippetType, readReceiptCount);
|
||||
this.context = context.getApplicationContext();
|
||||
super(body, recipient, date, date, threadId, status, deliveryReceiptCount, snippetType, readReceiptCount);
|
||||
this.snippetUri = snippetUri;
|
||||
this.count = count;
|
||||
this.unreadCount = unreadCount;
|
||||
@@ -71,7 +69,7 @@ public class ThreadRecord extends DisplayRecord {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpannableString getDisplayBody() {
|
||||
public SpannableString getDisplayBody(@NonNull Context context) {
|
||||
if (isGroupUpdate()) {
|
||||
return emphasisAdded(context.getString(R.string.ThreadRecord_group_updated));
|
||||
} else if (isGroupQuit()) {
|
||||
|
||||
Reference in New Issue
Block a user