Skip to content

Commit

Permalink
Merge pull request #7205 from thundernest/change_recipients_prefix
Browse files Browse the repository at this point in the history
Change `message_view_recipient_prefix` string to not require a trailing space
  • Loading branch information
cketti authored Sep 29, 2023
2 parents b5ac09c + da0134c commit 4f38de6
Show file tree
Hide file tree
Showing 52 changed files with 92 additions and 104 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.fsck.k9.ui.messageview

import android.text.SpannableStringBuilder

private const val LIST_SEPARATOR = ", "

/**
Expand All @@ -19,7 +17,7 @@ private const val LIST_SEPARATOR = ", "
internal class RecipientLayoutCreator(
private val textMeasure: TextMeasure,
private val maxNumberOfRecipientNames: Int,
private val recipientsPrefix: String,
private val recipientsFormat: String,
private val additionalRecipientSpacing: Int,
private val additionalRecipientsPrefix: String,
) {
Expand All @@ -30,14 +28,9 @@ internal class RecipientLayoutCreator(
): RecipientLayoutData {
require(recipientNames.isNotEmpty())

val displayRecipientsBuilder = SpannableStringBuilder()

if (recipientNames.size == 1) {
displayRecipientsBuilder.append(recipientsPrefix)
displayRecipientsBuilder.append(recipientNames.first())

return RecipientLayoutData(
recipientNames = displayRecipientsBuilder,
recipientNames = recipientsFormat.format(recipientNames.first()),
additionalRecipients = null,
)
}
Expand All @@ -46,12 +39,11 @@ internal class RecipientLayoutCreator(

val maxRecipientNames = recipientNames.size.coerceAtMost(maxNumberOfRecipientNames)
for (numberOfDisplayRecipients in maxRecipientNames downTo 2) {
displayRecipientsBuilder.clear()
displayRecipientsBuilder.append(recipientsPrefix)

recipientNames.asSequence()
val recipientNamesString = recipientNames.asSequence()
.take(numberOfDisplayRecipients)
.joinTo(displayRecipientsBuilder, separator = LIST_SEPARATOR)
.joinToString(separator = LIST_SEPARATOR)

val displayRecipients = recipientsFormat.format(recipientNamesString)

additionalRecipientsBuilder.setLength(0)
val numberOfAdditionalRecipients = totalNumberOfRecipients - numberOfDisplayRecipients
Expand All @@ -60,20 +52,16 @@ internal class RecipientLayoutCreator(
additionalRecipientsBuilder.append(numberOfAdditionalRecipients)
}

if (doesTextFitAvailableWidth(displayRecipientsBuilder, additionalRecipientsBuilder, availableWidth)) {
if (doesTextFitAvailableWidth(displayRecipients, additionalRecipientsBuilder, availableWidth)) {
return RecipientLayoutData(
recipientNames = displayRecipientsBuilder,
recipientNames = displayRecipients,
additionalRecipients = additionalRecipientsBuilder.toStringOrNull(),
)
}
}

displayRecipientsBuilder.clear()
displayRecipientsBuilder.append(recipientsPrefix)
displayRecipientsBuilder.append(recipientNames.first())

return RecipientLayoutData(
recipientNames = displayRecipientsBuilder,
recipientNames = recipientsFormat.format(recipientNames.first()),
additionalRecipients = "$additionalRecipientsPrefix${totalNumberOfRecipients - 1}",
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RecipientNamesView(context: Context, attrs: AttributeSet?) : ViewGroup(con
recipientLayoutCreator = RecipientLayoutCreator(
textMeasure = textMeasure,
maxNumberOfRecipientNames = MAX_NUMBER_OF_RECIPIENT_NAMES,
recipientsPrefix = context.getString(R.string.message_view_recipient_prefix),
recipientsFormat = context.getString(R.string.message_view_recipients_format),
additionalRecipientSpacing = additionRecipientSpacing,
additionalRecipientsPrefix = context.getString(R.string.message_view_additional_recipient_prefix),
)
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@
<string name="message_view_cc_label">نسخة كربونية :</string>
<string name="message_view_bcc_label">نسخة مخفية:</string>
<string name="message_view_status_attachment_not_saved">غير قادر على حفظ المُرفَق.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">إلي</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">إلي <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@
<string name="message_view_cc_label">Копія:</string>
<string name="message_view_bcc_label">Схаваная копія:</string>
<string name="message_view_status_attachment_not_saved">Немагчыма захаваць далучаныя файлы.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"да "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">да <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
2 changes: 1 addition & 1 deletion app/ui/legacy/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<string name="message_view_cc_label">Копие:</string>
<string name="message_view_bcc_label">Bcc:</string>
<string name="message_view_status_attachment_not_saved">Не може да запази прикачения файл.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<!--Used to display the recipient list in the message view screen.-->
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
<!--Text of the button that is displayed below the message header when the message body references one or more remote images-->
Expand Down
2 changes: 1 addition & 1 deletion app/ui/legacy/src/main/res/values-br/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<string name="message_view_cc_label">Cc:</string>
<string name="message_view_bcc_label">Bcc:</string>
<string name="message_view_status_attachment_not_saved">N\'haller ket enrollañ ar stagadenn.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<!--Used to display the recipient list in the message view screen.-->
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
<!--Text of the button that is displayed below the message header when the message body references one or more remote images-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
<string name="message_view_cc_label">A/c:</string>
<string name="message_view_bcc_label">Bcc:</string>
<string name="message_view_status_attachment_not_saved">No s\'ha pogut desar l\'adjunt.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"a "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">a <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@
<string name="message_view_cc_label">Kopie:</string>
<string name="message_view_bcc_label">Skrytá kopie (Bcc):</string>
<string name="message_view_status_attachment_not_saved">Přílohu se nedaří uložit.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"komu "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">komu <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
2 changes: 1 addition & 1 deletion app/ui/legacy/src/main/res/values-cy/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<string name="message_view_cc_label">Cc:</string>
<string name="message_view_bcc_label">Bcc:</string>
<string name="message_view_status_attachment_not_saved">Methu â chadw\'r atodiad.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<!--Used to display the recipient list in the message view screen.-->
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
<!--Text of the button that is displayed below the message header when the message body references one or more remote images-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
<string name="message_view_cc_label">Cc:</string>
<string name="message_view_bcc_label">Bcc:</string>
<string name="message_view_status_attachment_not_saved">Kunne ikke gemme vedhæftning.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"til "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">til <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
<string name="message_view_cc_label">CC:</string>
<string name="message_view_bcc_label">BCC:</string>
<string name="message_view_status_attachment_not_saved">Anhang konnte nicht gespeichert werden.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"an "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">an <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
<string name="message_view_cc_label">Κοιν:</string>
<string name="message_view_bcc_label">Κρυφή κοιν:</string>
<string name="message_view_status_attachment_not_saved">Αδυναμία αποθήκευσης συνημμένου.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">σε</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">σε <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
2 changes: 1 addition & 1 deletion app/ui/legacy/src/main/res/values-en-rGB/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!--Shown in place of the subject when a message has no subject. Showing this in parentheses is customary.-->
<!--Title of an error notification that is displayed when creating a notification for a new message has failed-->
<!--Body of an error notification that is displayed when creating a notification for a new message has failed-->
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<!--Used to display the recipient list in the message view screen.-->
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
<!--Text of the button that is displayed below the message header when the message body references one or more remote images-->
Expand Down
2 changes: 1 addition & 1 deletion app/ui/legacy/src/main/res/values-eo/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
<string name="message_view_cc_label">Kopio:</string>
<string name="message_view_bcc_label">Kaŝkopio:</string>
<string name="message_view_status_attachment_not_saved">Ne povis konservi kunsendaĵon.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<!--Used to display the recipient list in the message view screen.-->
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
<!--Text of the button that is displayed below the message header when the message body references one or more remote images-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@
<string name="message_view_cc_label">Cc:</string>
<string name="message_view_bcc_label">Cco:</string>
<string name="message_view_status_attachment_not_saved">No se puede guardar el adjunto.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"para "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">para <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
<string name="message_view_cc_label">Koopia:</string>
<string name="message_view_bcc_label">Pimekoopia:</string>
<string name="message_view_status_attachment_not_saved">Manuse salvestamine ebaõnnestus</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"saajaks "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">saajaks <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
<string name="message_view_cc_label">Cc:</string>
<string name="message_view_bcc_label">Bcc:</string>
<string name="message_view_status_attachment_not_saved">Ezin izan da eranskina gorde.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"honi: "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">honi: <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
<string name="message_view_cc_label">رونوشت به:</string>
<string name="message_view_bcc_label">مخفیانه به:</string>
<string name="message_view_status_attachment_not_saved">نمی‌توان پیوست را ذخیره کرد.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">به </string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">به <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
4 changes: 2 additions & 2 deletions app/ui/legacy/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
<string name="message_view_cc_label">Kopio:</string>
<string name="message_view_bcc_label">Piilokopio:</string>
<string name="message_view_status_attachment_not_saved">Liitteen tallentaminen epäonnistui.</string>
<!--Displayed in the message view screen in front of the recipient list. For most languages this should end with a space.-->
<string name="message_view_recipient_prefix">"vastaanottaja "</string>
<!--Used to display the recipient list in the message view screen.-->
<string name="message_view_recipients_format">vastaanottaja <xliff:g id="recipients">%s</xliff:g></string>
<!--Displayed in the message view screen in front of the number of additional recipients (the ones that are not displayed).-->
<string name="message_view_additional_recipient_prefix">+</string>
<!--Displayed in the message view screen if the message was addressed to the user. Make sure this works with 'message_view_recipient_prefix'. In English it's "to me".-->
Expand Down
Loading

0 comments on commit 4f38de6

Please sign in to comment.