Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
alansley committed Aug 28, 2024
1 parent 114066a commit ce8efd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ fun Context.createThemedComposeView(content: @Composable () -> Unit): ComposeVie
setThemedContent(content)
}

fun Context.getSubbedString(stringId: Int, vararg substitutionPairs: Pair<String, String>): CharSequence {
fun Context.getSubbedCharSequence(stringId: Int, vararg substitutionPairs: Pair<String, String>): 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, String>): String {
return getSubbedCharSequence(stringId, *substitutionPairs).toString()
}

fun ComposeView.setThemedContent(content: @Composable () -> Unit) = setContent {
SessionMaterialTheme {
content()
Expand Down

0 comments on commit ce8efd7

Please sign in to comment.