From ce8efd7def0a25515a06fea3b1dabf90cc4909c2 Mon Sep 17 00:00:00 2001 From: alansley Date: Wed, 28 Aug 2024 16:31:11 +1000 Subject: [PATCH] WIP --- .../conversation/ConversationActionBarView.kt | 6 +++--- .../main/java/org/thoughtcrime/securesms/ui/Util.kt | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt index b38599b14f..0504a4993e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt @@ -108,10 +108,10 @@ class ConversationActionBarView @JvmOverloads constructor( val durationAbbreviated = ExpirationUtil.getExpirationAbbreviatedDisplayValue(config.expiryMode.expirySeconds) // ..then substitute into the string.. - val subtitleTxt = context.getSubbedString(R.string.disappearingMessagesDisappear, + val subtitleTxt = context.getString(R.string.disappearingMessagesDisappear, DISAPPEARING_MESSAGES_TYPE_KEY to dmTypeString, TIME_KEY to durationAbbreviated - ).toString() + ) // .. and apply to the subtitle. settings += ConversationSetting( @@ -128,7 +128,7 @@ class ConversationActionBarView @JvmOverloads constructor( ?.let { val mutedDuration = (it - System.currentTimeMillis()).milliseconds val durationString = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit(context, mutedDuration) - context.getSubbedString(R.string.notificationsMuteFor, TIME_LARGE_KEY to durationString).toString() + context.getSubbedString(R.string.notificationsMuteFor, TIME_LARGE_KEY to durationString) } ?: context.getString(R.string.notificationsMuted), ConversationSettingType.NOTIFICATION, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt index 5d478c1628..fbe4850de8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt @@ -19,14 +19,16 @@ fun Context.createThemedComposeView(content: @Composable () -> Unit): ComposeVie setThemedContent(content) } -fun Context.getSubbedString(stringId: Int, vararg substitutionPairs: Pair): CharSequence { +fun Context.getSubbedCharSequence(stringId: Int, vararg substitutionPairs: Pair): CharSequence { val phrase = Phrase.from(this, stringId) - for ((key, value) in substitutionPairs) { - phrase.put(key, value) - } + for ((key, value) in substitutionPairs) { phrase.put(key, value) } return phrase.format() } +fun Context.getSubbedString(stringId: Int, vararg substitutionPairs: Pair): String { + return getSubbedCharSequence(stringId, *substitutionPairs).toString() +} + fun ComposeView.setThemedContent(content: @Composable () -> Unit) = setContent { SessionMaterialTheme { content()