From 12bd7ccf6a873c874b742caaebf554f62b0919c0 Mon Sep 17 00:00:00 2001 From: Jonas Kalderstam Date: Wed, 29 Nov 2023 16:30:24 +0100 Subject: [PATCH] Added leading zero to seconds formatting --- .../nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt | 8 ++++++-- .../feeder/ui/compose/feedarticle/ReaderView.kt | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt index e37566aba..611bae56f 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt @@ -303,10 +303,11 @@ fun RowScope.FeedItemText( } if (readTimeSecs > 0) { CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { + val seconds = "%02d".format(readTimeSecs % 60) val readTimeText = pluralStringResource(id = R.plurals.n_minutes, count = readTimeSecs / 60) .format( - "${readTimeSecs / 60}:${readTimeSecs % 60}", + "${readTimeSecs / 60}:$seconds", ) val wordCountText = pluralStringResource(id = R.plurals.n_words, count = item.wordCount) @@ -344,6 +345,7 @@ fun RowScope.FeedItemText( @Composable @ThemePreviews +@Suppress("ktlint:standard:max-line-length") private fun Preview() { FeederTheme { FeedItemCard( @@ -380,6 +382,7 @@ private fun Preview() { @Composable @ThemePreviews +@Suppress("ktlint:standard:max-line-length") private fun PreviewWithImageUnread() { FeederTheme { Box( @@ -420,6 +423,7 @@ private fun PreviewWithImageUnread() { @Composable @ThemePreviews +@Suppress("ktlint:standard:max-line-length") private fun PreviewWithImageRead() { FeederTheme { Box( @@ -440,7 +444,7 @@ private fun PreviewWithImageRead() { feedImageUrl = null, primarySortTime = Instant.EPOCH, rawPubDate = null, - wordCount = 950, + wordCount = 910, ), showThumbnail = true, onMarkAboveAsRead = {}, diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt index a3860284c..a700aa44c 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt @@ -204,10 +204,11 @@ fun ReaderView( imageVector = Icons.Outlined.Timelapse, contentDescription = null, ) + val seconds = "%02d".format(readTimeSecs % 60) val readTimeText = pluralStringResource(id = R.plurals.n_minutes, count = readTimeSecs / 60) .format( - "${readTimeSecs / 60}:${readTimeSecs % 60}", + "${readTimeSecs / 60}:$seconds", ) WithBidiDeterminedLayoutDirection(paragraph = readTimeText) { val interactionSource = @@ -331,7 +332,7 @@ private fun ReaderPreview() { Surface { ReaderView( screenType = ScreenType.SINGLE, - wordCount = 9831, + wordCount = 9700, onEnclosureClick = {}, onFeedTitleClick = {}, ) {}