Pluralize some strings.

This commit is contained in:
Greyson Parrelli
2023-05-16 10:15:24 -04:00
parent 8df0248d4f
commit 5c5b88ebcc
4 changed files with 30 additions and 6 deletions

View File

@@ -281,7 +281,7 @@ object NotificationFactory {
setContentTitle(context.getString(R.string.app_name))
setContentIntent(NotificationPendingIntentHelper.getActivity(context, 0, MainActivity.clearTop(context), PendingIntentFlags.mutable()))
setGroupSummary(true)
setSubText(context.getString(R.string.MessageNotifier_d_new_messages_in_d_conversations, state.messageCount, state.threadCount))
setSubText(context.buildSummaryString(state.messageCount, state.threadCount))
setContentInfo(state.messageCount.toString())
setNumber(state.messageCount)
setSummaryContentText(state.mostRecentSender)
@@ -300,6 +300,12 @@ object NotificationFactory {
NotificationManagerCompat.from(context).safelyNotify(null, NotificationIds.MESSAGE_SUMMARY, builder.build())
}
private fun Context.buildSummaryString(messageCount: Int, threadCount: Int): String {
val messageString = resources.getQuantityString(R.plurals.MessageNotifier_d_messages, messageCount, messageCount)
val threadString = resources.getQuantityString(R.plurals.MessageNotifier_d_chats, threadCount, threadCount)
return getString(R.string.MessageNotifier_s_in_s, messageString, threadString)
}
private fun notifyInThread(context: Context, recipient: Recipient, lastAudibleNotification: Long) {
if (!SignalStore.settings().isMessageNotificationsInChatSoundsEnabled ||
ServiceUtil.getAudioManager(context).ringerMode != AudioManager.RINGER_MODE_NORMAL ||