Unique string resource for "edited now".
This commit is contained in:
parent
67ef831681
commit
64457b0235
6 changed files with 30 additions and 9 deletions
|
@ -327,7 +327,11 @@ public class ConversationItemFooter extends ConstraintLayout {
|
|||
}
|
||||
String date = DateUtils.getDatelessRelativeTimeSpanString(getContext(), locale, timestamp);
|
||||
if (displayMode != ConversationItemDisplayMode.Detailed.INSTANCE && messageRecord.isEditMessage() && messageRecord.isLatestRevision()) {
|
||||
date = getContext().getString(R.string.ConversationItem_edited_timestamp_footer, date);
|
||||
if (DateUtils.isNow(timestamp)) {
|
||||
date = getContext().getString(R.string.ConversationItem_edited_now_timestamp_footer);
|
||||
} else {
|
||||
date = getContext().getString(R.string.ConversationItem_edited_timestamp_footer, date);
|
||||
}
|
||||
}
|
||||
dateView.setText(date);
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class ConversationMessage {
|
|||
}
|
||||
|
||||
public static @NonNull FormattedDate getFormattedDate(@NonNull Context context, @NonNull MessageRecord messageRecord) {
|
||||
return MessageRecordUtil.isScheduled(messageRecord) ? new FormattedDate(false, DateUtils.getOnlyTimeString(context, ((MmsMessageRecord) messageRecord).getScheduledDate()))
|
||||
return MessageRecordUtil.isScheduled(messageRecord) ? new FormattedDate(false, false, DateUtils.getOnlyTimeString(context, ((MmsMessageRecord) messageRecord).getScheduledDate()))
|
||||
: DateUtils.getDatelessRelativeTimeSpanFormattedDate(context, Locale.getDefault(), messageRecord.getTimestamp());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,5 +7,6 @@ package org.thoughtcrime.securesms.conversation.v2.computed
|
|||
|
||||
data class FormattedDate(
|
||||
val isRelative: Boolean,
|
||||
val isNow: Boolean,
|
||||
val value: String
|
||||
)
|
||||
|
|
|
@ -643,7 +643,11 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
|||
} else {
|
||||
var date = dateString
|
||||
if (conversationContext.displayMode != ConversationItemDisplayMode.Detailed && record is MmsMessageRecord && record.isEditMessage()) {
|
||||
date = getContext().getString(R.string.ConversationItem_edited_timestamp_footer, date)
|
||||
date = if (conversationMessage.computedProperties.formattedDate.isNow) {
|
||||
getContext().getString(R.string.ConversationItem_edited_now_timestamp_footer)
|
||||
} else {
|
||||
getContext().getString(R.string.ConversationItem_edited_timestamp_footer, date)
|
||||
}
|
||||
|
||||
binding.footerDate.setOnClickListener {
|
||||
conversationContext.clickListener.onEditedIndicatorClicked(record)
|
||||
|
|
|
@ -60,7 +60,7 @@ object DateUtils : android.text.format.DateUtils() {
|
|||
@JvmStatic
|
||||
fun getBriefRelativeTimeSpanString(c: Context, locale: Locale, timestamp: Long): String {
|
||||
return when {
|
||||
timestamp.isWithin(1.minutes) -> {
|
||||
isNow(timestamp) -> {
|
||||
c.getString(R.string.DateUtils_just_now)
|
||||
}
|
||||
timestamp.isWithin(1.hours) -> {
|
||||
|
@ -89,7 +89,7 @@ object DateUtils : android.text.format.DateUtils() {
|
|||
@JvmStatic
|
||||
fun getExtendedRelativeTimeSpanString(context: Context, locale: Locale, timestamp: Long): String {
|
||||
return when {
|
||||
timestamp.isWithin(1.minutes) -> {
|
||||
isNow(timestamp) -> {
|
||||
context.getString(R.string.DateUtils_just_now)
|
||||
}
|
||||
timestamp.isWithin(1.hours) -> {
|
||||
|
@ -130,15 +130,15 @@ object DateUtils : android.text.format.DateUtils() {
|
|||
@JvmStatic
|
||||
fun getDatelessRelativeTimeSpanFormattedDate(context: Context, locale: Locale, timestamp: Long): FormattedDate {
|
||||
return when {
|
||||
timestamp.isWithin(1.minutes) -> {
|
||||
FormattedDate(true, context.getString(R.string.DateUtils_just_now))
|
||||
isNow(timestamp) -> {
|
||||
FormattedDate(isRelative = true, isNow = true, value = context.getString(R.string.DateUtils_just_now))
|
||||
}
|
||||
timestamp.isWithin(1.hours) -> {
|
||||
val minutes = timestamp.convertDeltaTo(DurationUnit.MINUTES)
|
||||
FormattedDate(true, context.resources.getString(R.string.DateUtils_minutes_ago, minutes))
|
||||
FormattedDate(isRelative = true, isNow = false, value = context.resources.getString(R.string.DateUtils_minutes_ago, minutes))
|
||||
}
|
||||
else -> {
|
||||
FormattedDate(false, getOnlyTimeString(context, timestamp))
|
||||
FormattedDate(isRelative = false, isNow = false, value = getOnlyTimeString(context, timestamp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,6 +336,16 @@ object DateUtils : android.text.format.DateUtils() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This exposes "now" (defined here as a one minute window) to other classes.
|
||||
* This is because certain locales use different linguistic constructions for "modified n minutes ago" and "modified just now",
|
||||
* and therefore the caller will need to load different string resources in these situations.
|
||||
*
|
||||
* @param timestamp a Unix timestamp
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isNow(timestamp: Long) = timestamp.isWithin(1.minutes)
|
||||
|
||||
private fun Long.isWithin(duration: Duration): Boolean {
|
||||
return System.currentTimeMillis() - this <= duration.inWholeMilliseconds
|
||||
}
|
||||
|
|
|
@ -323,6 +323,8 @@
|
|||
<string name="ConversationItem_cant_download_image_you_will_need_to_send_it_again">Can\'t download image. You will need to send it again.</string>
|
||||
<!-- Dialog error message shown when user can\'t download a their own video message via a linked device due to a permanent failure (e.g., unable to decrypt) -->
|
||||
<string name="ConversationItem_cant_download_video_you_will_need_to_send_it_again">Can\'t download video. You will need to send it again.</string>
|
||||
<!-- Display as the timestamp footer in a message bubble in a conversation when a message has been edited. The timestamp represents a message that has been edited extremely recently. -->
|
||||
<string name="ConversationItem_edited_now_timestamp_footer">Edited\u2000Now</string>
|
||||
<!-- Display as the timestamp footer in a message bubble in a conversation when a message has been edited. The timestamp will go from \'11m\' to \'edited 11m\' -->
|
||||
<string name="ConversationItem_edited_timestamp_footer">Edited\u2000%1$s</string>
|
||||
<!-- Displayed if the link preview in the conversation item is for a call link call -->
|
||||
|
|
Loading…
Add table
Reference in a new issue