Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 4f38de6f authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #7205 from thundernest/change_recipients_prefix

Change `message_view_recipient_prefix` string to not require a trailing space
parents b5ac09c3 da0134cf
Loading
Loading
Loading
Loading
+9 −21
Original line number Diff line number Diff line
package com.fsck.k9.ui.messageview

import android.text.SpannableStringBuilder

private const val LIST_SEPARATOR = ", "

/**
@@ -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,
) {
@@ -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,
            )
        }
@@ -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
@@ -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}",
        )
    }
+1 −1
Original line number Diff line number Diff line
@@ -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),
        )
+2 −2
Original line number Diff line number Diff line
@@ -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".-->
+2 −2
Original line number Diff line number Diff line
@@ -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".-->
+1 −1
Original line number Diff line number Diff line
@@ -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-->
Loading