mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 12:08:26 +00:00
Fix notifications for media messages without text.
They now read 'media message' in italics. Closes #2649
This commit is contained in:
parent
96896bf8f1
commit
2011391e65
@ -441,12 +441,14 @@
|
||||
<string name="MessageNotifier_d_new_messages">%d new messages</string>
|
||||
<string name="MessageNotifier_most_recent_from_s">Most recent from: %s</string>
|
||||
<string name="MessageNotifier_encrypted_message">Encrypted message...</string>
|
||||
<string name="MessageNotifier_media_message_with_text">Media message: %s</string>
|
||||
<string name="MessageNotifier_no_subject">(No subject)</string>
|
||||
<string name="MessageNotifier_message_delivery_failed">Message delivery failed.</string>
|
||||
<string name="MessageNotifier_failed_to_deliver_message">Failed to deliver message.</string>
|
||||
<string name="MessageNotifier_error_delivering_message">Error delivering message.</string>
|
||||
<string name="MessageNotifier_mark_all_as_read">Mark all as read</string>
|
||||
<string name="MessageNotifier_mark_as_read">Mark as read</string>
|
||||
<string name="MessageNotifier_media_message">Media message</string>
|
||||
|
||||
<!-- QuickResponseService -->
|
||||
<string name="QuickResponseService_sorry_quick_response_is_not_yet_supported_by_textsecure">Sorry, Quick Response is not yet supported by TextSecure!</string>
|
||||
|
@ -51,6 +51,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.SpanUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.textsecure.api.messages.TextSecureEnvelope;
|
||||
|
||||
@ -339,7 +340,7 @@ public class MessageNotifier {
|
||||
Recipient recipient = record.getIndividualRecipient();
|
||||
Recipients recipients = record.getRecipients();
|
||||
long threadId = record.getThreadId();
|
||||
SpannableString body = record.getDisplayBody();
|
||||
CharSequence body = record.getDisplayBody();
|
||||
Uri image = null;
|
||||
Recipients threadRecipients = null;
|
||||
|
||||
@ -348,8 +349,13 @@ public class MessageNotifier {
|
||||
}
|
||||
|
||||
if (SmsDatabase.Types.isDecryptInProgressType(record.getType()) || !record.getBody().isPlaintext()) {
|
||||
body = new SpannableString(context.getString(R.string.MessageNotifier_encrypted_message));
|
||||
body.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
body = SpanUtil.italic(context.getString(R.string.MessageNotifier_encrypted_message));
|
||||
} else if (record.isMms() && TextUtils.isEmpty(body)) {
|
||||
body = SpanUtil.italic(context.getString(R.string.MessageNotifier_media_message));
|
||||
} else if (record.isMms()) {
|
||||
String message = context.getString(R.string.MessageNotifier_media_message_with_text, body);
|
||||
int italicLength = message.length() - body.length();
|
||||
body = SpanUtil.italic(message, italicLength);
|
||||
}
|
||||
|
||||
notificationState.addNotification(new NotificationItem(recipient, recipients, threadRecipients, threadId, body, image));
|
||||
|
@ -10,8 +10,12 @@ import android.text.style.StyleSpan;
|
||||
public class SpanUtil {
|
||||
|
||||
public static CharSequence italic(CharSequence sequence) {
|
||||
return italic(sequence, sequence.length());
|
||||
}
|
||||
|
||||
public static CharSequence italic(CharSequence sequence, int length) {
|
||||
SpannableString spannable = new SpannableString(sequence);
|
||||
spannable.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
spannable.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return spannable;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user