diff --git a/res/values/strings.xml b/res/values/strings.xml index 9a021b1d11..09a782142b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1077,8 +1077,8 @@ Choose your contact entry from the contacts list. Change passphrase Change your passphrase - Enable passphrase - Lock Signal and message notifications with a passphrase + Enable passphrase screen lock + Lock screen and notifications with a passphrase Screen security Block screenshots in the recents list and inside the app Auto-lock Signal after a specified time interval of inactivity diff --git a/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java b/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java index 6fc9f7ec65..855310525a 100644 --- a/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java +++ b/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java @@ -169,8 +169,8 @@ public class ConfirmIdentityDialog extends AlertDialog { messageRecord.getIndividualRecipient().getAddress().toPhoneString(), messageRecord.getRecipientDeviceId(), "", messageRecord.getDateSent(), - legacy ? Base64.decode(messageRecord.getBody().getBody()) : null, - !legacy ? Base64.decode(messageRecord.getBody().getBody()) : null); + legacy ? Base64.decode(messageRecord.getBody()) : null, + !legacy ? Base64.decode(messageRecord.getBody()) : null); long pushId = pushDatabase.insert(envelope); diff --git a/src/org/thoughtcrime/securesms/ConversationUpdateItem.java b/src/org/thoughtcrime/securesms/ConversationUpdateItem.java index d4be4eba58..48f71a744b 100644 --- a/src/org/thoughtcrime/securesms/ConversationUpdateItem.java +++ b/src/org/thoughtcrime/securesms/ConversationUpdateItem.java @@ -146,7 +146,7 @@ public class ConversationUpdateItem extends LinearLayout icon.setImageResource(R.drawable.ic_group_grey600_24dp); icon.clearColorFilter(); - GroupUtil.getDescription(getContext(), messageRecord.getBody().getBody()).addListener(this); + GroupUtil.getDescription(getContext(), messageRecord.getBody()).addListener(this); body.setText(messageRecord.getDisplayBody()); date.setVisibility(View.GONE); diff --git a/src/org/thoughtcrime/securesms/database/MmsDatabase.java b/src/org/thoughtcrime/securesms/database/MmsDatabase.java index 34135bc01c..577a17acd8 100644 --- a/src/org/thoughtcrime/securesms/database/MmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MmsDatabase.java @@ -41,7 +41,6 @@ import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList; import org.thoughtcrime.securesms.database.documents.NetworkFailure; import org.thoughtcrime.securesms.database.documents.NetworkFailureList; import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.thoughtcrime.securesms.database.model.DisplayRecord; import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord; import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord; @@ -1011,7 +1010,7 @@ public class MmsDatabase extends MessagingDatabase { return new MediaMmsMessageRecord(context, id, message.getRecipient(), message.getRecipient(), 1, System.currentTimeMillis(), System.currentTimeMillis(), - 0, threadId, new DisplayRecord.Body(message.getBody(), true), + 0, threadId, message.getBody(), slideDeck, slideDeck.getSlides().size(), message.isSecure() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(), new LinkedList(), @@ -1099,7 +1098,7 @@ public class MmsDatabase extends MessagingDatabase { int addressDeviceId = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS_DEVICE_ID)); int deliveryReceiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.DELIVERY_RECEIPT_COUNT)); int readReceiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.READ_RECEIPT_COUNT)); - DisplayRecord.Body body = getBody(cursor); + String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY)); int partCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.PART_COUNT)); String mismatchDocument = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.MISMATCHED_IDENTITIES)); String networkDocument = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.NETWORK_FAILURE)); @@ -1159,11 +1158,6 @@ public class MmsDatabase extends MessagingDatabase { return new LinkedList<>(); } - private DisplayRecord.Body getBody(Cursor cursor) { - String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY)); - return new DisplayRecord.Body(body == null ? "" : body, true); - } - private SlideDeck getSlideDeck(@NonNull Cursor cursor) { Attachment attachment = DatabaseFactory.getAttachmentDatabase(context).getAttachment(cursor); return new SlideDeck(context, attachment); diff --git a/src/org/thoughtcrime/securesms/database/SmsDatabase.java b/src/org/thoughtcrime/securesms/database/SmsDatabase.java index e439339679..9d442abb6e 100644 --- a/src/org/thoughtcrime/securesms/database/SmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/SmsDatabase.java @@ -34,7 +34,6 @@ import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch; import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList; import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.thoughtcrime.securesms.database.model.DisplayRecord; import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.database.model.SmsMessageRecord; import org.thoughtcrime.securesms.jobs.TrimThreadJob; @@ -449,7 +448,7 @@ public class SmsDatabase extends MessagingDatabase { contentValues.put(DATE_SENT, record.getDateSent()); contentValues.put(PROTOCOL, 31337); contentValues.put(READ, 0); - contentValues.put(BODY, record.getBody().getBody()); + contentValues.put(BODY, record.getBody()); contentValues.put(THREAD_ID, record.getThreadId()); contentValues.put(EXPIRES_IN, record.getExpiresIn()); @@ -806,7 +805,7 @@ public class SmsDatabase extends MessagingDatabase { } public MessageRecord getCurrent() { - return new SmsMessageRecord(context, id, new DisplayRecord.Body(message.getMessageBody(), true), + return new SmsMessageRecord(context, id, message.getMessageBody(), message.getRecipient(), message.getRecipient(), 1, System.currentTimeMillis(), System.currentTimeMillis(), 0, message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(), @@ -851,6 +850,7 @@ public class SmsDatabase extends MessagingDatabase { int subscriptionId = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.SUBSCRIPTION_ID)); long expiresIn = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.EXPIRES_IN)); long expireStarted = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.EXPIRE_STARTED)); + String body = cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.BODY)); if (!TextSecurePreferences.isReadReceiptsEnabled(context)) { readReceiptCount = 0; @@ -858,7 +858,6 @@ public class SmsDatabase extends MessagingDatabase { List mismatches = getMismatches(mismatchDocument); Recipient recipient = Recipient.from(context, address, true); - DisplayRecord.Body body = getBody(cursor); return new SmsMessageRecord(context, messageId, body, recipient, recipient, @@ -880,10 +879,6 @@ public class SmsDatabase extends MessagingDatabase { return new LinkedList<>(); } - protected DisplayRecord.Body getBody(Cursor cursor) { - return new DisplayRecord.Body(cursor.getString(cursor.getColumnIndexOrThrow(BODY)), true); - } - public void close() { cursor.close(); } diff --git a/src/org/thoughtcrime/securesms/database/ThreadDatabase.java b/src/org/thoughtcrime/securesms/database/ThreadDatabase.java index 1155b9f338..d91922b54f 100644 --- a/src/org/thoughtcrime/securesms/database/ThreadDatabase.java +++ b/src/org/thoughtcrime/securesms/database/ThreadDatabase.java @@ -34,7 +34,6 @@ import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord; import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo; import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings; import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper; -import org.thoughtcrime.securesms.database.model.DisplayRecord; import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord; import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.database.model.ThreadRecord; @@ -567,7 +566,7 @@ public class ThreadDatabase extends Database { MessageRecord record; if (reader != null && (record = reader.getNext()) != null) { - updateThread(threadId, count, record.getBody().getBody(), getAttachmentUriFor(record), + updateThread(threadId, count, record.getBody(), getAttachmentUriFor(record), record.getTimestamp(), record.getDeliveryStatus(), record.getDeliveryReceiptCount(), record.getType(), unarchive, record.getExpiresIn(), record.getReadReceiptCount()); notifyConversationListListeners(); @@ -658,7 +657,7 @@ public class ThreadDatabase extends Database { } Recipient recipient = Recipient.from(context, address, settings, groupRecord, true); - DisplayRecord.Body body = getPlaintextBody(cursor); + String body = cursor.getString(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET)); long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE)); long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT)); int unreadCount = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.UNREAD_COUNT)); @@ -680,10 +679,6 @@ public class ThreadDatabase extends Database { distributionType, archived, expiresIn, lastSeen, readReceiptCount); } - private DisplayRecord.Body getPlaintextBody(Cursor cursor) { - return new DisplayRecord.Body(cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET)), true); - } - private @Nullable Uri getSnippetUri(Cursor cursor) { if (cursor.isNull(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_URI))) { return null; diff --git a/src/org/thoughtcrime/securesms/database/model/DisplayRecord.java b/src/org/thoughtcrime/securesms/database/model/DisplayRecord.java index d721bda09f..1b60cea5ae 100644 --- a/src/org/thoughtcrime/securesms/database/model/DisplayRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/DisplayRecord.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2012 Moxie Marlinspike * * This program is free software: you can redistribute it and/or modify @@ -40,14 +40,14 @@ public abstract class DisplayRecord { private final long dateSent; private final long dateReceived; private final long threadId; - private final Body body; + private final String body; private final int deliveryStatus; private final int deliveryReceiptCount; private final int readReceiptCount; - public DisplayRecord(Context context, Body body, Recipient recipient, long dateSent, - long dateReceived, long threadId, int deliveryStatus, int deliveryReceiptCount, - long type, int readReceiptCount) + DisplayRecord(Context context, 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; @@ -61,7 +61,7 @@ public abstract class DisplayRecord { this.deliveryStatus = deliveryStatus; } - public Body getBody() { + public String getBody() { return body; } @@ -172,22 +172,4 @@ public abstract class DisplayRecord { public boolean isPendingInsecureSmsFallback() { return SmsDatabase.Types.isPendingInsecureSmsFallbackType(type); } - - public static class Body { - private final String body; - private final boolean plaintext; - - public Body(String body, boolean plaintext) { - this.body = body; - this.plaintext = plaintext; - } - - public boolean isPlaintext() { - return plaintext; - } - - public String getBody() { - return body == null ? "" : body; - } - } } diff --git a/src/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java b/src/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java index 7462273f0a..b1128c91fd 100644 --- a/src/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/MediaMmsMessageRecord.java @@ -47,7 +47,7 @@ public class MediaMmsMessageRecord extends MmsMessageRecord { public MediaMmsMessageRecord(Context context, long id, Recipient conversationRecipient, Recipient individualRecipient, int recipientDeviceId, long dateSent, long dateReceived, int deliveryReceiptCount, - long threadId, Body body, + long threadId, String body, @NonNull SlideDeck slideDeck, int partCount, long mailbox, List mismatches, @@ -81,8 +81,6 @@ public class MediaMmsMessageRecord extends MmsMessageRecord { 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)); - } else if (!getBody().isPlaintext()) { - return emphasisAdded(context.getString(R.string.MessageNotifier_locked_message)); } return super.getDisplayBody(); diff --git a/src/org/thoughtcrime/securesms/database/model/MessageRecord.java b/src/org/thoughtcrime/securesms/database/model/MessageRecord.java index 979ad2299c..3992c5c7b8 100644 --- a/src/org/thoughtcrime/securesms/database/model/MessageRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/MessageRecord.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2012 Moxie Marlinpsike * * This program is free software: you can redistribute it and/or modify @@ -54,7 +54,7 @@ public abstract class MessageRecord extends DisplayRecord { private final long expiresIn; private final long expireStarted; - MessageRecord(Context context, long id, Body body, Recipient conversationRecipient, + MessageRecord(Context context, long id, String body, Recipient conversationRecipient, Recipient individualRecipient, int recipientDeviceId, long dateSent, long dateReceived, long threadId, int deliveryStatus, int deliveryReceiptCount, long type, @@ -91,7 +91,7 @@ public abstract class MessageRecord extends DisplayRecord { if (isGroupUpdate() && isOutgoing()) { return emphasisAdded(context.getString(R.string.MessageRecord_you_updated_group)); } else if (isGroupUpdate()) { - return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()).toString(getIndividualRecipient())); + return emphasisAdded(GroupUtil.getDescription(context, getBody()).toString(getIndividualRecipient())); } else if (isGroupQuit() && isOutgoing()) { return emphasisAdded(context.getString(R.string.MessageRecord_left_group)); } else if (isGroupQuit()) { @@ -116,11 +116,11 @@ public abstract class MessageRecord extends DisplayRecord { } else if (isIdentityDefault()) { if (isOutgoing()) return emphasisAdded(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified, getIndividualRecipient().toShortString())); else return emphasisAdded(context.getString(R.string.MessageRecord_you_marked_your_safety_number_with_s_unverified_from_another_device, getIndividualRecipient().toShortString())); - } else if (getBody().getBody().length() > MAX_DISPLAY_LENGTH) { - return new SpannableString(getBody().getBody().substring(0, MAX_DISPLAY_LENGTH)); + } else if (getBody().length() > MAX_DISPLAY_LENGTH) { + return new SpannableString(getBody().substring(0, MAX_DISPLAY_LENGTH)); } - return new SpannableString(getBody().getBody()); + return new SpannableString(getBody()); } public long getId() { diff --git a/src/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java b/src/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java index 94fccc3c1a..3b8e3032f4 100644 --- a/src/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/MmsMessageRecord.java @@ -16,7 +16,7 @@ public abstract class MmsMessageRecord extends MessageRecord { private final @NonNull SlideDeck slideDeck; - MmsMessageRecord(Context context, long id, Body body, Recipient conversationRecipient, + MmsMessageRecord(Context context, long id, String body, Recipient conversationRecipient, Recipient individualRecipient, int recipientDeviceId, long dateSent, long dateReceived, long threadId, int deliveryStatus, int deliveryReceiptCount, long type, List mismatches, diff --git a/src/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java b/src/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java index be67d3d297..e678811fb9 100644 --- a/src/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/NotificationMmsMessageRecord.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2012 Moxie Marlinspike * * This program is free software: you can redistribute it and/or modify @@ -52,7 +52,7 @@ public class NotificationMmsMessageRecord extends MmsMessageRecord { long expiry, int status, byte[] transactionId, long mailbox, int subscriptionId, SlideDeck slideDeck, int readReceiptCount) { - super(context, id, new Body("", true), conversationRecipient, individualRecipient, recipientDeviceId, + super(context, id, "", conversationRecipient, individualRecipient, recipientDeviceId, dateSent, dateReceived, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox, new LinkedList(), new LinkedList(), subscriptionId, 0, 0, slideDeck, readReceiptCount); diff --git a/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java b/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java index 4f31009121..00c092521c 100644 --- a/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2012 Moxie Marlinspike * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,6 @@ import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.database.MmsSmsColumns; import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch; -import org.thoughtcrime.securesms.database.documents.NetworkFailure; import org.thoughtcrime.securesms.recipients.Recipient; import java.util.LinkedList; @@ -40,7 +39,7 @@ import java.util.List; public class SmsMessageRecord extends MessageRecord { public SmsMessageRecord(Context context, long id, - Body body, Recipient recipient, + String body, Recipient recipient, Recipient individualRecipient, int recipientDeviceId, long dateSent, long dateReceived, @@ -52,7 +51,7 @@ public class SmsMessageRecord extends MessageRecord { { super(context, id, body, recipient, individualRecipient, recipientDeviceId, dateSent, dateReceived, threadId, status, deliveryReceiptCount, type, - mismatches, new LinkedList(), subscriptionId, + mismatches, new LinkedList<>(), subscriptionId, expiresIn, expireStarted, readReceiptCount); } @@ -80,8 +79,6 @@ public class SmsMessageRecord extends MessageRecord { return emphasisAdded(context.getString(R.string.SmsMessageRecord_duplicate_message)); } else if (SmsDatabase.Types.isNoRemoteSessionType(type)) { return emphasisAdded(context.getString(R.string.MessageDisplayHelper_message_encrypted_for_non_existing_session)); - } else if (!getBody().isPlaintext()) { - return emphasisAdded(context.getString(R.string.MessageNotifier_locked_message)); } else if (isEndSession() && isOutgoing()) { return emphasisAdded(context.getString(R.string.SmsMessageRecord_secure_session_reset)); } else if (isEndSession()) { diff --git a/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java b/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java index 4c82fcfba5..e0e1c6aa87 100644 --- a/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java @@ -49,7 +49,7 @@ public class ThreadRecord extends DisplayRecord { private final long expiresIn; private final long lastSeen; - public ThreadRecord(@NonNull Context context, @NonNull Body body, @Nullable Uri snippetUri, + public ThreadRecord(@NonNull Context context, @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, @@ -82,15 +82,13 @@ public class ThreadRecord extends DisplayRecord { return emphasisAdded(context.getString(R.string.MessageDisplayHelper_bad_encrypted_message)); } else if (SmsDatabase.Types.isNoRemoteSessionType(type)) { return emphasisAdded(context.getString(R.string.MessageDisplayHelper_message_encrypted_for_non_existing_session)); - } else if (!getBody().isPlaintext()) { - return emphasisAdded(context.getString(R.string.MessageNotifier_locked_message)); } else if (SmsDatabase.Types.isEndSessionType(type)) { return emphasisAdded(context.getString(R.string.ThreadRecord_secure_session_reset)); } 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 (MmsSmsColumns.Types.isDraftMessageType(type)) { String draftText = context.getString(R.string.ThreadRecord_draft); - return emphasisAdded(draftText + " " + getBody().getBody(), 0, draftText.length()); + return emphasisAdded(draftText + " " + getBody(), 0, draftText.length()); } else if (SmsDatabase.Types.isOutgoingCall(type)) { return emphasisAdded(context.getString(org.thoughtcrime.securesms.R.string.ThreadRecord_called)); } else if (SmsDatabase.Types.isIncomingCall(type)) { @@ -110,10 +108,10 @@ public class ThreadRecord extends DisplayRecord { } else if (SmsDatabase.Types.isIdentityDefault(type)) { return emphasisAdded(context.getString(R.string.ThreadRecord_you_marked_unverified)); } else { - if (TextUtils.isEmpty(getBody().getBody())) { + if (TextUtils.isEmpty(getBody())) { return new SpannableString(emphasisAdded(context.getString(R.string.ThreadRecord_media_message))); } else { - return new SpannableString(getBody().getBody()); + return new SpannableString(getBody()); } } } diff --git a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java index 5111975797..1b6f3e186d 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java @@ -102,7 +102,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType { Optional profileKey = getProfileKey(message.getIndividualRecipient()); SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder() .withTimestamp(message.getDateSent()) - .withBody(message.getBody().getBody()) + .withBody(message.getBody()) .withExpiration((int)(message.getExpiresIn() / 1000)) .withProfileKey(profileKey.orNull()) .asEndSessionMessage(message.isEndSession()) diff --git a/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java b/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java index e0d982e617..56d780c4a1 100644 --- a/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java @@ -93,7 +93,7 @@ public class SmsSendJob extends SendJob { throw new UndeliverableMessageException("Not a valid SMS destination! " + recipient); } - ArrayList messages = SmsManager.getDefault().divideMessage(message.getBody().getBody()); + ArrayList messages = SmsManager.getDefault().divideMessage(message.getBody()); ArrayList sentIntents = constructSentIntents(message.getId(), message.getType(), messages, false); ArrayList deliveredIntents = constructDeliveredIntents(message.getId(), message.getType(), messages); diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index eb43027f24..fba5fb0c43 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -42,7 +42,6 @@ import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo; import org.thoughtcrime.securesms.database.MmsSmsDatabase; -import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord; import org.thoughtcrime.securesms.database.model.MessageRecord; @@ -427,7 +426,7 @@ public class MessageNotifier { threadRecipients = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId); } - if (SmsDatabase.Types.isDecryptInProgressType(record.getType()) || !record.getBody().isPlaintext()) { + if (KeyCachingService.isLocked(context)) { body = SpanUtil.italic(context.getString(R.string.MessageNotifier_locked_message)); } else if (record.isMms() && TextUtils.isEmpty(body)) { body = SpanUtil.italic(context.getString(R.string.MessageNotifier_media_message)); diff --git a/src/org/thoughtcrime/securesms/service/KeyCachingService.java b/src/org/thoughtcrime/securesms/service/KeyCachingService.java index abc10d815a..6861f2b8a5 100644 --- a/src/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/src/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -78,6 +78,10 @@ public class KeyCachingService extends Service { public KeyCachingService() {} + public static synchronized boolean isLocked(Context context) { + return getMasterSecret(context) == null; + } + public static synchronized @Nullable MasterSecret getMasterSecret(Context context) { if (masterSecret == null && TextSecurePreferences.isPasswordDisabled(context)) { try { diff --git a/src/org/thoughtcrime/securesms/sms/OutgoingTextMessage.java b/src/org/thoughtcrime/securesms/sms/OutgoingTextMessage.java index 440b0afaa6..e74cb8ff99 100644 --- a/src/org/thoughtcrime/securesms/sms/OutgoingTextMessage.java +++ b/src/org/thoughtcrime/securesms/sms/OutgoingTextMessage.java @@ -70,13 +70,13 @@ public class OutgoingTextMessage { public static OutgoingTextMessage from(SmsMessageRecord record) { if (record.isSecure()) { - return new OutgoingEncryptedMessage(record.getRecipient(), record.getBody().getBody(), record.getExpiresIn()); + return new OutgoingEncryptedMessage(record.getRecipient(), record.getBody(), record.getExpiresIn()); } else if (record.isKeyExchange()) { - return new OutgoingKeyExchangeMessage(record.getRecipient(), record.getBody().getBody()); + return new OutgoingKeyExchangeMessage(record.getRecipient(), record.getBody()); } else if (record.isEndSession()) { - return new OutgoingEndSessionMessage(new OutgoingTextMessage(record.getRecipient(), record.getBody().getBody(), 0, -1)); + return new OutgoingEndSessionMessage(new OutgoingTextMessage(record.getRecipient(), record.getBody(), 0, -1)); } else { - return new OutgoingTextMessage(record.getRecipient(), record.getBody().getBody(), record.getExpiresIn(), record.getSubscriptionId()); + return new OutgoingTextMessage(record.getRecipient(), record.getBody(), record.getExpiresIn(), record.getSubscriptionId()); } }