mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 13:58:25 +00:00
e UpdateMessageBuilder to generate data extraction message
This commit is contained in:
parent
66e811ed75
commit
3bfef2d0cd
@ -27,6 +27,7 @@ import network.loki.messenger.R;
|
||||
|
||||
import org.session.libsession.messaging.utilities.UpdateMessageBuilder;
|
||||
import org.session.libsession.messaging.utilities.UpdateMessageData;
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.session.libsession.database.documents.IdentityKeyMismatch;
|
||||
@ -97,6 +98,9 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
} else if (isExpirationTimerUpdate()) {
|
||||
int seconds = (int) (getExpiresIn() / 1000);
|
||||
return new SpannableString(UpdateMessageBuilder.INSTANCE.buildExpirationTimerMessage(context, seconds, getIndividualRecipient().getAddress().serialize(), isOutgoing()));
|
||||
} else if (isDataExtraction()) {
|
||||
if (isScreenshotExtraction()) return new SpannableString((UpdateMessageBuilder.INSTANCE.buildDataExtractionMessage(context, SignalServiceProtos.DataExtractionNotification.Type.SCREENSHOT, getIndividualRecipient().getAddress().serialize())));
|
||||
else if (isMediaSavedExtraction()) return new SpannableString((UpdateMessageBuilder.INSTANCE.buildDataExtractionMessage(context, SignalServiceProtos.DataExtractionNotification.Type.MEDIA_SAVED, getIndividualRecipient().getAddress().serialize())));
|
||||
}
|
||||
// TODO below lines are left here for compatibility with older group update messages, it can be deleted later on
|
||||
else if (isGroupUpdate() && isOutgoing()) {
|
||||
|
@ -440,6 +440,8 @@
|
||||
<string name="MessageRecord_s_disabled_disappearing_messages">%1$s a désactivé les messages éphémères.</string>
|
||||
<string name="MessageRecord_you_set_disappearing_message_time_to_s">Vous avez défini l’expiration des messages éphémères à %1$s.</string>
|
||||
<string name="MessageRecord_s_set_disappearing_message_time_to_s">%1$s a défini l’expiration des messages éphémères à %2$s.</string>
|
||||
<string name="MessageRecord_s_took_a_screenshot">%1$s a pris une capture d’écran.</string>
|
||||
<string name="MessageRecord_media_saved_by_s">%1$s a sauvegardé un media.</string>
|
||||
<string name="MessageRecord_your_safety_number_with_s_has_changed">Votre numéro de sécurité avec %s a changé.</string>
|
||||
<string name="MessageRecord_you_marked_your_safety_number_with_s_verified">Vous avez marqué votre numéro de sécurité avec %s comme vérifié</string>
|
||||
<string name="MessageRecord_you_marked_your_safety_number_with_s_verified_from_another_device">Vous avez marqué votre numéro de sécurité avec %s comme vérifié à partir d’un autre appareil</string>
|
||||
|
@ -5,6 +5,7 @@ import org.session.libsession.R
|
||||
import org.session.libsession.messaging.MessagingConfiguration
|
||||
import org.session.libsession.utilities.ExpirationUtil
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
|
||||
object UpdateMessageBuilder {
|
||||
|
||||
@ -82,7 +83,7 @@ object UpdateMessageBuilder {
|
||||
if (!isOutgoing && sender == null) return ""
|
||||
val senderName: String? = if (!isOutgoing) {
|
||||
MessagingConfiguration.shared.storage.getDisplayNameForRecipient(sender!!) ?: sender
|
||||
} else { sender }
|
||||
} else { context.getString(R.string.MessageRecord_you) }
|
||||
return if (duration <= 0) {
|
||||
if (isOutgoing) context.getString(R.string.MessageRecord_you_disabled_disappearing_messages)
|
||||
else context.getString(R.string.MessageRecord_s_disabled_disappearing_messages, senderName)
|
||||
@ -93,8 +94,13 @@ object UpdateMessageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO do this when the current update is merged
|
||||
fun buildDataExtractionMessage(): String {
|
||||
return ""
|
||||
fun buildDataExtractionMessage(context: Context, kind: SignalServiceProtos.DataExtractionNotification.Type, sender: String? = null): String {
|
||||
val senderName = MessagingConfiguration.shared.storage.getDisplayNameForRecipient(sender!!) ?: sender
|
||||
return when (kind) {
|
||||
SignalServiceProtos.DataExtractionNotification.Type.SCREENSHOT ->
|
||||
context.getString(R.string.MessageRecord_s_took_a_screenshot, senderName)
|
||||
SignalServiceProtos.DataExtractionNotification.Type.MEDIA_SAVED ->
|
||||
context.getString(R.string.MessageRecord_media_saved_by_s, senderName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -509,6 +509,8 @@
|
||||
<string name="MessageRecord_s_disabled_disappearing_messages">%1$s disabled disappearing messages.</string>
|
||||
<string name="MessageRecord_you_set_disappearing_message_time_to_s">You set the disappearing message timer to %1$s</string>
|
||||
<string name="MessageRecord_s_set_disappearing_message_time_to_s">%1$s set the disappearing message timer to %2$s</string>
|
||||
<string name="MessageRecord_s_took_a_screenshot">%1$s took a screenshot.</string>
|
||||
<string name="MessageRecord_media_saved_by_s">Media saved by %1$s.</string>
|
||||
<string name="MessageRecord_your_safety_number_with_s_has_changed">Your safety number with %s has changed.</string>
|
||||
<string name="MessageRecord_you_marked_your_safety_number_with_s_verified">You marked your safety number with %s verified</string>
|
||||
<string name="MessageRecord_you_marked_your_safety_number_with_s_verified_from_another_device">You marked your safety number with %s verified from another device</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user