mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Add dialog for when you hit edit message limit.
This commit is contained in:
@@ -285,6 +285,7 @@ import org.thoughtcrime.securesms.util.DrawableUtil
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.FullscreenHelper
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.MessageConstraintsUtil
|
||||
import org.thoughtcrime.securesms.util.MessageConstraintsUtil.getEditMessageThresholdHours
|
||||
import org.thoughtcrime.securesms.util.MessageConstraintsUtil.isValidEditMessageSend
|
||||
import org.thoughtcrime.securesms.util.PlayStoreUtil
|
||||
@@ -1407,6 +1408,12 @@ class ConversationFragment :
|
||||
return
|
||||
}
|
||||
|
||||
if (!MessageConstraintsUtil.isWithinMaxEdits(editMessage)) {
|
||||
Log.i(TAG, "Too many edits to the message")
|
||||
Dialogs.showAlertDialog(requireContext(), null, resources.getQuantityString(R.plurals.ConversationActivity_edit_message_too_many_edits, MessageConstraintsUtil.MAX_EDIT_COUNT, MessageConstraintsUtil.MAX_EDIT_COUNT))
|
||||
return
|
||||
}
|
||||
|
||||
if (!isValidEditMessageSend(editMessage, System.currentTimeMillis())) {
|
||||
Log.i(TAG, "Edit message no longer valid")
|
||||
val editDurationHours = getEditMessageThresholdHours()
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
* Helpers for determining if a message send/receive is valid for those that
|
||||
@@ -15,7 +15,7 @@ object MessageConstraintsUtil {
|
||||
private val RECEIVE_THRESHOLD = TimeUnit.DAYS.toMillis(1)
|
||||
private val SEND_THRESHOLD = TimeUnit.HOURS.toMillis(3)
|
||||
|
||||
private val MAX_EDIT_COUNT = 10
|
||||
const val MAX_EDIT_COUNT = 10
|
||||
|
||||
@JvmStatic
|
||||
fun isValidRemoteDeleteReceive(targetMessage: MessageRecord, deleteSenderId: RecipientId, deleteServerTimestamp: Long): Boolean {
|
||||
@@ -42,9 +42,14 @@ object MessageConstraintsUtil {
|
||||
return targetMessages.all { isValidRemoteDeleteSend(it, currentTime) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isWithinMaxEdits(targetMessage: MessageRecord): Boolean {
|
||||
return targetMessage.revisionNumber < MAX_EDIT_COUNT
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEditMessageThresholdHours(): Int {
|
||||
return SEND_THRESHOLD.hours.inWholeHours.toInt()
|
||||
return SEND_THRESHOLD.milliseconds.inWholeHours.toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -343,6 +343,11 @@
|
||||
<item quantity="one">Edits can only be applied within %1$d hour from the time you sent this message.</item>
|
||||
<item quantity="other">Edits can only be applied within %1$d hours from the time you sent this message.</item>
|
||||
</plurals>
|
||||
<!-- Warning dialog text shown to user if they try to edit a message too many times. Where %1$d is replaced with the number of edits -->
|
||||
<plurals name="ConversationActivity_edit_message_too_many_edits">
|
||||
<item quantity="one">Only %1$d edit can be applied to this message.</item>
|
||||
<item quantity="other">Only %1$d edits can be applied to this message.</item>
|
||||
</plurals>
|
||||
|
||||
<string name="ConversationActivity_invalid_recipient">Invalid recipient!</string>
|
||||
<string name="ConversationActivity_added_to_home_screen">Added to home screen</string>
|
||||
|
||||
Reference in New Issue
Block a user