Use strings.xml to manage plural for pageCount
This commit is contained in:
@@ -414,7 +414,7 @@ fun CameraScreenFooter(
|
|||||||
horizontalArrangement = Arrangement.SpaceBetween
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "$pageCount pages",
|
text = pageCountText(pageCount),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
modifier = Modifier.clickable(onClick = onPageCountClick)
|
modifier = Modifier.clickable(onClick = onPageCountClick)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ fun PdfGenerationBottomSheet(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val formattedFileSize = formatFileSize(pdf.sizeInBytes, context)
|
val formattedFileSize = formatFileSize(pdf.sizeInBytes, context)
|
||||||
Text(
|
Text(
|
||||||
text = "${pdf.pageCount} pages · $formattedFileSize",
|
text = "${pageCountText(pdf.pageCount)} · $formattedFileSize",
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||||
)
|
)
|
||||||
@@ -267,7 +267,7 @@ fun PreviewPdfGenerationDialogDuringGeneration() {
|
|||||||
fun PreviewPdfGenerationDialogAfterGeneration() {
|
fun PreviewPdfGenerationDialogAfterGeneration() {
|
||||||
PreviewToCustomize(
|
PreviewToCustomize(
|
||||||
uiState = PdfGenerationUiState(
|
uiState = PdfGenerationUiState(
|
||||||
generatedPdf = GeneratedPdf("file://fake.pdf".toUri(), 442897L, 3)
|
generatedPdf = GeneratedPdf("file://fake.pdf".toUri(), 442897L, 1)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
25
app/src/main/java/org/mydomain/myscan/view/Strings.kt
Normal file
25
app/src/main/java/org/mydomain/myscan/view/Strings.kt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 Pierre-Yves Nicolas
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.mydomain.myscan.view
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import org.mydomain.myscan.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun pageCountText(quantity: Int): String {
|
||||||
|
val context = LocalContext.current
|
||||||
|
return context.resources.getQuantityString(R.plurals.page_count, quantity, quantity)
|
||||||
|
}
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">MyScan</string>
|
<string name="app_name">MyScan</string>
|
||||||
</resources>
|
<plurals name="page_count">
|
||||||
|
<item quantity="one">%d page</item>
|
||||||
|
<item quantity="other">%d pages</item>
|
||||||
|
</plurals>
|
||||||
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user