Skip to content

Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.

feat: move the app's text into string resources so it can be translated (#18)

Josh16576a79e74a
diff --git a/README.md b/README.md
index b9979bd..6e6f516 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,7 @@ PdfCraft for Android is in beta.
| Export to Word, RTF, Excel, PowerPoint, JPEG and PNG | ✅ · Word 97 ⬜ |
| Recognize text | ✅ (the Latin alphabet without accents) |
| A customizable quick toolbar, upright and sideways layouts, light and dark themes | ✅ |
+| Translations: all of the app's text is ready to translate ([how](#translating)) | ✅ · languages besides English ⬜ |
| AI assistant, cloud storage, sharing for review | 🚫 PdfCraft is a local app |
<sub>✅ works today · 🚧 in progress · ⬜ not started · 🚫 not planned</sub>
@@ -246,6 +247,24 @@ Build time dependencies:
<br>
+## Translating
+
+All of PdfCraft's text is in one file:
+[`apps/pdfcraft-android/android/app/src/main/res/values/strings.xml`](apps/pdfcraft-android/android/app/src/main/res/values/strings.xml).
+To add a language:
+
+* copy it to a `values-<language>` folder beside it: `values-es/strings.xml` for Spanish, `values-pt-rBR/strings.xml` for Brazilian Portuguese
+* translate the text between the tags; keep each `name`, the placeholders (`%1$s`, `%2$d`, which you may move) and escapes such as `\'`
+* leave out anything you haven't translated yet: it shows in English
+* open a pull request
+
+The store listing is in `fastlane/metadata/android/en-US/`; a copy in a folder for your language (`es-ES`, `pt-BR`)
+translates it too. On Android 13 and newer, PdfCraft's language can be set on its own under Settings ▸ Apps ▸
+PdfCraft ▸ Language. A few messages from the PDF engine, such as some errors and the names in Undo, are English
+for now.
+
+<br>
+
## License
[MIT](LICENSE-MIT) OR [Apache-2.0](LICENSE-APACHE), at your option. PdfCraft for Android is not affiliated with Adobe;
diff --git a/apps/pdfcraft-android/android/app/build.gradle.kts b/apps/pdfcraft-android/android/app/build.gradle.kts
index c17bce6..93fb23c 100644
--- a/apps/pdfcraft-android/android/app/build.gradle.kts
+++ b/apps/pdfcraft-android/android/app/build.gradle.kts
@@ -257,6 +257,8 @@ android {
buildTypes {
debug {
applicationIdSuffix = ".debug"
+ // the pseudo-languages (English with accents, mirrored text) show any text not yet in strings.xml
+ isPseudoLocalesEnabled = true
}
release {
isMinifyEnabled = true
@@ -279,6 +281,11 @@ android {
buildFeatures {
compose = true
}
+ // the languages in res/values-* go into the manifest, so Android 13+ offers them under
+ // App languages in the system settings (res/resources.properties names the default)
+ androidResources {
+ generateLocaleConfig = true
+ }
}
androidComponents {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt
index c01ca1a..cc34b3f 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/MainActivity.kt
@@ -135,9 +135,9 @@ class MainActivity : ComponentActivity() {
try {
block()
} catch (e: ActivityNotFoundException) {
- vm.tell("No app on this phone can do that.")
+ vm.tell(getString(R.string.main_error_no_app))
} catch (e: SecurityException) {
- vm.tell("Android didn't allow that.")
+ vm.tell(getString(R.string.main_error_not_allowed))
}
}
@@ -188,7 +188,7 @@ class MainActivity : ComponentActivity() {
}
}
}
- runCatching { pm.print(name, adapter, null) }.onFailure { vm.tell("Printing isn't allowed for this document.") }
+ runCatching { pm.print(name, adapter, null) }.onFailure { vm.tell(getString(R.string.main_error_print_not_allowed)) }
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt
index 5746c6b..c263e87 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/PdfcraftApplication.kt
@@ -16,6 +16,11 @@ class PdfcraftApplication : Application() {
/** The engine, loaded once per process on a background thread and shared by the activities. */
val engine: Deferred<Result<Engine>> by lazy { scope.async { runCatching { Engine.open() } } }
+ override fun onCreate() {
+ super.onCreate()
+ initText(this)
+ }
+
@OptIn(ExperimentalCoroutinesApi::class)
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt
index 54b4ebe..9728659 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ReadAloudService.kt
@@ -36,7 +36,7 @@ class ReadAloudService : Service() {
override fun onCreate() {
super.onCreate()
val nm = getSystemService(NotificationManager::class.java)
- nm?.createNotificationChannel(NotificationChannel(CHANNEL, "Read aloud", NotificationManager.IMPORTANCE_LOW).apply { setShowBadge(false) })
+ nm?.createNotificationChannel(NotificationChannel(CHANNEL, getString(R.string.common_tool_read_aloud), NotificationManager.IMPORTANCE_LOW).apply { setShowBadge(false) })
session = MediaSession(this, "PdfCraft read aloud").apply {
setCallback(object : MediaSession.Callback() {
override fun onPlay() { controls?.play() }
@@ -94,14 +94,14 @@ class ReadAloudService : Service() {
return Notification.Builder(this, CHANNEL)
.setSmallIcon(R.drawable.ic_stat_read_aloud)
.setContentTitle(title)
- .setContentText(if (playing) "Reading aloud" else "Paused")
+ .setContentText(getString(if (playing) R.string.service_notification_reading else R.string.service_notification_paused))
.setContentIntent(open)
.setOngoing(playing)
.setDeleteIntent(PendingIntent.getService(this, 1, Intent(this, ReadAloudService::class.java).setAction(ACTION_STOP), PendingIntent.FLAG_IMMUTABLE))
- .addAction(action(android.R.drawable.ic_media_rew, "Back 15 seconds", ACTION_BACK))
- .addAction(if (playing) action(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE) else action(android.R.drawable.ic_media_play, "Play", ACTION_PLAY))
- .addAction(action(android.R.drawable.ic_media_ff, "Forward 15 seconds", ACTION_FORWARD))
- .addAction(action(android.R.drawable.ic_menu_close_clear_cancel, "Stop", ACTION_STOP))
+ .addAction(action(android.R.drawable.ic_media_rew, getString(R.string.service_action_back), ACTION_BACK))
+ .addAction(if (playing) action(android.R.drawable.ic_media_pause, getString(R.string.common_pause), ACTION_PAUSE) else action(android.R.drawable.ic_media_play, getString(R.string.common_play), ACTION_PLAY))
+ .addAction(action(android.R.drawable.ic_media_ff, getString(R.string.service_action_forward), ACTION_FORWARD))
+ .addAction(action(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.service_action_stop), ACTION_STOP))
.setStyle(Notification.MediaStyle().setMediaSession(session?.sessionToken).setShowActionsInCompactView(0, 1, 2))
.build()
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/Strings.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/Strings.kt
new file mode 100644
index 0000000..3e266cc
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/Strings.kt
@@ -0,0 +1,22 @@
+package io.github.artcraftandroid.pdfcraft
+
+import android.content.Context
+import androidx.annotation.PluralsRes
+import androidx.annotation.StringRes
+
+/**
+ * The app's text lives in `res/values/strings.xml` (a translation is a `values-<language>` copy
+ * of it). Composables read it with `stringResource`; code with no Context of its own (the view
+ * model, the engine's error messages) reads it here, in the language the app runs in.
+ */
+private lateinit var appContext: Context
+
+internal fun initText(context: Context) {
+ appContext = context.applicationContext
+}
+
+/** The string [id], formatted with [args]. */
+fun text(@StringRes id: Int, vararg args: Any): String = appContext.getString(id, *args)
+
+/** The plural string [id] for [count], formatted with [args]. */
+fun plural(@PluralsRes id: Int, count: Int, vararg args: Any): String = appContext.resources.getQuantityString(id, count, *args)
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt
index 4f450a0..7a97b60 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/DocumentFiles.kt
@@ -8,6 +8,7 @@ import android.provider.DocumentsContract
import android.provider.MediaStore
import android.provider.OpenableColumns
import androidx.core.content.FileProvider
+import io.github.artcraftandroid.pdfcraft.R
import java.io.File
import java.security.MessageDigest
@@ -31,7 +32,7 @@ class DocumentFiles(private val context: Context) {
/** The working copy of [uri]: copied in (again) unless it is a file the app already owns. */
fun workingCopy(uri: Uri): File {
if (uri.scheme == ContentResolver.SCHEME_FILE) {
- val f = File(requireNotNull(uri.path) { "The file has no path." })
+ val f = File(requireNotNull(uri.path) { context.getString(R.string.files_error_no_path) })
if (f.canonicalPath.startsWith(context.filesDir.canonicalPath)) return f
}
val name = displayName(uri)
@@ -39,7 +40,7 @@ class DocumentFiles(private val context: Context) {
val target = File(dir, name)
val tmp = File(dir, ".$name.part")
resolver.openInputStream(uri).use { input ->
- requireNotNull(input) { "The file couldn't be read." }
+ requireNotNull(input) { context.getString(R.string.common_file_unreadable) }
tmp.outputStream().use { input.copyTo(it) }
}
if (!tmp.renameTo(target)) {
@@ -108,7 +109,7 @@ class DocumentFiles(private val context: Context) {
/** Write [file] over [uri] (truncating it). */
fun writeBack(file: File, uri: Uri) {
- val out = resolver.openOutputStream(uri, "wt") ?: error("The file couldn't be written.")
+ val out = resolver.openOutputStream(uri, "wt") ?: error(context.getString(R.string.files_error_write))
out.use { o -> file.inputStream().use { it.copyTo(o) } }
}
@@ -160,10 +161,10 @@ class DocumentFiles(private val context: Context) {
put(android.provider.MediaStore.MediaColumns.IS_PENDING, 1)
}
val collection = android.provider.MediaStore.Downloads.EXTERNAL_CONTENT_URI
- val uri = resolver.insert(collection, values) ?: error("The file couldn't be saved to Downloads.")
+ val uri = resolver.insert(collection, values) ?: error(context.getString(R.string.files_error_save_downloads))
try {
resolver.openOutputStream(uri).use { out ->
- requireNotNull(out) { "The file couldn't be saved to Downloads." }
+ requireNotNull(out) { context.getString(R.string.files_error_save_downloads) }
file.inputStream().use { it.copyTo(out) }
}
resolver.update(uri, android.content.ContentValues().apply { put(android.provider.MediaStore.MediaColumns.IS_PENDING, 0) }, null, null)
@@ -181,9 +182,9 @@ class DocumentFiles(private val context: Context) {
put(android.provider.MediaStore.MediaColumns.MIME_TYPE, mime)
put(android.provider.MediaStore.MediaColumns.RELATIVE_PATH, android.os.Environment.DIRECTORY_PICTURES + "/PdfCraft")
}
- val uri = resolver.insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) ?: error("The image couldn't be saved.")
+ val uri = resolver.insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) ?: error(context.getString(R.string.files_error_save_image))
resolver.openOutputStream(uri).use { out ->
- requireNotNull(out) { "The image couldn't be saved." }
+ requireNotNull(out) { context.getString(R.string.files_error_save_image) }
file.inputStream().use { it.copyTo(out) }
}
return uri
@@ -191,14 +192,14 @@ class DocumentFiles(private val context: Context) {
/** Where [uri] is, as a person would say it: a folder path, or the app that provided it. */
fun displayLocation(uri: Uri): String = when (uri.scheme) {
- ContentResolver.SCHEME_FILE -> uri.path?.substringBeforeLast('/')?.replace("/storage/emulated/0", "Internal storage") ?: "This device"
+ ContentResolver.SCHEME_FILE -> uri.path?.substringBeforeLast('/')?.replace("/storage/emulated/0", context.getString(R.string.files_location_internal_storage)) ?: context.getString(R.string.files_location_this_device)
else -> {
val auth = uri.authority.orEmpty()
when {
- auth.contains("downloads") -> "Downloads"
- auth.contains("externalstorage") -> "Internal storage" + (Uri.decode(uri.lastPathSegment ?: "").substringAfter(':', "").substringBeforeLast('/', "").let { if (it.isEmpty()) "" else "/$it" })
- auth.contains("media") -> "Media"
- else -> context.packageManager.resolveContentProvider(auth, 0)?.loadLabel(context.packageManager)?.toString() ?: "Another app"
+ auth.contains("downloads") -> context.getString(R.string.files_location_downloads)
+ auth.contains("externalstorage") -> context.getString(R.string.files_location_internal_storage) + (Uri.decode(uri.lastPathSegment ?: "").substringAfter(':', "").substringBeforeLast('/', "").let { if (it.isEmpty()) "" else "/$it" })
+ auth.contains("media") -> context.getString(R.string.files_location_media)
+ else -> context.packageManager.resolveContentProvider(auth, 0)?.loadLabel(context.packageManager)?.toString() ?: context.getString(R.string.files_location_another_app)
}
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt
index 460d2df..4060537 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/Engine.kt
@@ -1,10 +1,12 @@
package io.github.artcraftandroid.pdfcraft.engine
import android.graphics.Bitmap
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.MobileException
import io.github.artcraftandroid.pdfcraft.core.MobileSession
import io.github.artcraftandroid.pdfcraft.core.RenderedImage
import io.github.artcraftandroid.pdfcraft.core.initLogging
+import io.github.artcraftandroid.pdfcraft.text
import java.nio.ByteBuffer
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
@@ -94,7 +96,7 @@ fun RenderedImage.toBitmap(): Bitmap {
/** The user-facing message of an engine failure. */
val Throwable.userMessage: String
get() = when (this) {
- is MobileException.NeedsPassword -> "This document is protected by a password."
- is MobileException.WrongPassword -> "The password is incorrect."
- else -> message?.takeIf { it.isNotBlank() } ?: "Something went wrong."
+ is MobileException.NeedsPassword -> text(R.string.files_error_needs_password)
+ is MobileException.WrongPassword -> text(R.string.common_wrong_password)
+ else -> message?.takeIf { it.isNotBlank() } ?: text(R.string.files_error_generic)
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt
index d05da44..482afd2 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/LocalFiles.kt
@@ -9,6 +9,7 @@ import android.content.ContentUris
import android.provider.DocumentsContract
import android.provider.MediaStore
import android.provider.OpenableColumns
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.fileThumbnail
import java.io.File
import java.security.MessageDigest
@@ -57,7 +58,7 @@ object LocalFiles {
context.contentResolver.query(doc, arrayOf(DocumentsContract.Document.COLUMN_DISPLAY_NAME), null, null, null)?.use { c ->
if (c.moveToFirst()) c.getString(0) else null
}
- }.getOrNull() ?: tree.lastPathSegment?.substringAfterLast(':')?.ifEmpty { null } ?: "Folder"
+ }.getOrNull() ?: tree.lastPathSegment?.substringAfterLast(':')?.ifEmpty { null } ?: context.getString(R.string.files_folder_unnamed)
fun scan(context: Context): List<LocalPdf> {
val resolver = context.contentResolver
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt
index 37f217e..18eb00f 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/engine/UserBookmarks.kt
@@ -1,6 +1,8 @@
package io.github.artcraftandroid.pdfcraft.engine
import androidx.compose.runtime.mutableStateMapOf
+import io.github.artcraftandroid.pdfcraft.R
+import io.github.artcraftandroid.pdfcraft.text
import java.io.File
import org.json.JSONArray
import org.json.JSONObject
@@ -24,7 +26,7 @@ class UserBookmarks(private val file: File) {
for (key in o.keys()) {
val a = o.getJSONArray(key)
byDoc[key] = (0 until a.length()).mapNotNull { i ->
- a.optJSONObject(i)?.let { UserBookmark(it.optString("name", "Page ${it.optInt("page") + 1}"), it.optInt("page")) }
+ a.optJSONObject(i)?.let { UserBookmark(it.optString("name", text(R.string.files_bookmark_page, it.optInt("page") + 1)), it.optInt("page")) }
}
}
}
@@ -44,7 +46,7 @@ class UserBookmarks(private val file: File) {
save()
existing to false
} else {
- val b = UserBookmark("Page ${page + 1}", page)
+ val b = UserBookmark(text(R.string.files_bookmark_page, page + 1), page)
byDoc[key] = list + b
save()
b to true
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt
index 51cf3c6..364dfc4 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppRoot.kt
@@ -45,6 +45,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontStyle
@@ -56,6 +57,7 @@ import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.home.HomeRoot
import io.github.artcraftandroid.pdfcraft.ui.home.SettingsScreen
import io.github.artcraftandroid.pdfcraft.ui.viewer.CertSignScreen
@@ -122,37 +124,37 @@ fun AppRoot(vm: AppViewModel, onBrowse: () -> Unit, onPickSignatureImage: () ->
if (vm.authorPrompt) {
var name by remember { mutableStateOf("") }
PdfDialog(
- onDismiss = { vm.authorPrompt = false }, title = "Your name on comments",
- confirm = "Save", onConfirm = { vm.toolPrefs.author = name.trim(); vm.authorPrompt = false; vm.prefsChanged++ },
- dismiss = "Skip",
+ onDismiss = { vm.authorPrompt = false }, title = stringResource(R.string.home_author_title),
+ confirm = stringResource(R.string.common_save), onConfirm = { vm.toolPrefs.author = name.trim(); vm.authorPrompt = false; vm.prefsChanged++ },
+ dismiss = stringResource(R.string.root_skip),
) {
- Text("Add a name to show who made each comment. You can change it later in Preferences.", color = c.text, fontSize = 14.sp)
+ Text(stringResource(R.string.root_author_prompt_body), color = c.text, fontSize = 14.sp)
Spacer(Modifier.height(14.dp))
- PdfField(name, { name = it }, "Your name")
+ PdfField(name, { name = it }, stringResource(R.string.common_your_name))
}
}
vm.readOnlyPrompt?.let { d ->
PdfDialog(
- onDismiss = { vm.answerReadOnly(null) }, title = "File is read-only",
- confirm = "Save a copy", onConfirm = { vm.answerReadOnly(true) },
- dismiss = "Discard", onDismissButton = { vm.answerReadOnly(false) },
- ) { Text("Your changes to ${d.name} can't be saved where the file is. Save a copy to keep them.", color = c.text, fontSize = 14.sp) }
+ onDismiss = { vm.answerReadOnly(null) }, title = stringResource(R.string.root_read_only_title),
+ confirm = stringResource(R.string.common_save_copy), onConfirm = { vm.answerReadOnly(true) },
+ dismiss = stringResource(R.string.root_discard), onDismissButton = { vm.answerReadOnly(false) },
+ ) { Text(stringResource(R.string.root_read_only_body, d.name), color = c.text, fontSize = 14.sp) }
}
vm.linkPrompt?.let { url ->
val shown = runCatching { android.net.Uri.parse(url).let { u -> "${u.scheme}://${u.host}${if (u.port > 0) ":${u.port}" else ""}" } }.getOrDefault(url)
- PdfDialog(onDismiss = { vm.answerLink(false) }, title = "Open web page", confirm = "Open", onConfirm = { vm.answerLink(true) }) {
- Text("Do you want to open the page at $shown?", color = c.text, fontSize = 14.sp)
+ PdfDialog(onDismiss = { vm.answerLink(false) }, title = stringResource(R.string.root_open_link_title), confirm = stringResource(R.string.common_open), onConfirm = { vm.answerLink(true) }) {
+ Text(stringResource(R.string.root_open_link_body, shown), color = c.text, fontSize = 14.sp)
}
}
vm.confirmDeleteAllBookmarks?.let { d ->
PdfDialog(
- onDismiss = { vm.confirmDeleteAllBookmarks = null }, title = "Delete all bookmarks?",
- confirm = "Delete all", onConfirm = { vm.confirmDeleteAllBookmarks = null; vm.deleteAllBookmarks(d) }, destructive = true,
- ) { Text("All of this document's bookmarks are removed.", color = c.text, fontSize = 14.sp) }
+ onDismiss = { vm.confirmDeleteAllBookmarks = null }, title = stringResource(R.string.root_delete_bookmarks_title),
+ confirm = stringResource(R.string.root_delete_all), onConfirm = { vm.confirmDeleteAllBookmarks = null; vm.deleteAllBookmarks(d) }, destructive = true,
+ ) { Text(stringResource(R.string.root_delete_bookmarks_body), color = c.text, fontSize = 14.sp) }
}
vm.readingModeBlocked?.let {
- PdfDialog(onDismiss = { vm.readingModeBlocked = null }, title = "Reading Mode", confirm = "OK", onConfirm = { vm.readingModeBlocked = null }, dismiss = null) {
- Text("Tools work on the page itself. Choose Continuous or Single page in View settings to use this one.", color = c.text, fontSize = 14.sp)
+ PdfDialog(onDismiss = { vm.readingModeBlocked = null }, title = stringResource(R.string.root_reading_mode_title), confirm = stringResource(R.string.common_ok), onConfirm = { vm.readingModeBlocked = null }, dismiss = null) {
+ Text(stringResource(R.string.root_reading_mode_body), color = c.text, fontSize = 14.sp)
}
}
vm.busy?.let { message ->
@@ -174,14 +176,22 @@ private fun PasswordDialog(vm: AppViewModel, req: PasswordRequest) {
var pw by remember(req) { mutableStateOf("") }
val focus = remember { FocusRequester() }
LaunchedEffect(req) { runCatching { focus.requestFocus() } }
- PdfDialog(onDismiss = { vm.answerPassword(null) }, title = "Enter password", confirm = "OK", onConfirm = { vm.answerPassword(pw) }) {
+ // the sentence with the file's name in italics where its %1$s is
+ val body = stringResource(R.string.root_password_body)
+ PdfDialog(onDismiss = { vm.answerPassword(null) }, title = stringResource(R.string.root_enter_password), confirm = stringResource(R.string.common_ok), onConfirm = { vm.answerPassword(pw) }) {
Text(buildAnnotatedString {
- withStyle(SpanStyle(fontStyle = FontStyle.Italic)) { append(req.file.name) }
- append(" is protected. Please enter the password to open the document.")
+ val at = body.indexOf("%1\$s")
+ if (at < 0) {
+ append(body)
+ } else {
+ append(body.substring(0, at))
+ withStyle(SpanStyle(fontStyle = FontStyle.Italic)) { append(req.file.name) }
+ append(body.substring(at + "%1\$s".length))
+ }
}, color = c.text, fontSize = 14.sp)
Spacer(Modifier.height(14.dp))
PdfField(
- pw, { pw = it }, "Password", error = req.wrong && pw.isEmpty(), password = true, focus = focus,
+ pw, { pw = it }, stringResource(R.string.common_password), error = req.wrong && pw.isEmpty(), password = true, focus = focus,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { if (pw.isNotEmpty()) vm.answerPassword(pw) }),
)
@@ -198,8 +208,8 @@ private fun LicencesScreen(vm: AppViewModel) {
val lucide = remember { runCatching { context.assets.open("licences/LICENSE-lucide.txt").bufferedReader().readText() }.getOrDefault("") }
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().navigationBarsPadding()) {
Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Back", { vm.showLicences = false }) }
- Text("Open-source licences", color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), { vm.showLicences = false }) }
+ Text(stringResource(R.string.home_licences), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
}
Column(Modifier.verticalScroll(rememberScrollState()).padding(horizontal = 20.dp)) {
@Composable
@@ -207,14 +217,14 @@ private fun LicencesScreen(vm: AppViewModel) {
Text(name, color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(top = 14.dp))
Text(licence, color = c.textSecondary, fontSize = 13.sp)
}
- entry("PdfCraft (engine and app)", "MIT OR Apache-2.0, by storytold and contributors")
+ entry(stringResource(R.string.root_licence_pdfcraft), stringResource(R.string.root_licence_pdfcraft_terms))
entry("UniFFI", "MPL-2.0, Mozilla")
entry("JNA", "Apache-2.0")
entry("AndroidX, Jetpack Compose, Kotlin coroutines", "Apache-2.0")
- entry("Lucide icons", "ISC, Lucide Contributors")
- entry("Inter typeface", "SIL Open Font License 1.1, The Inter Project Authors")
- entry("Text recognition models (ocrs)", "CC-BY-SA-4.0, Robert Knight; trained on HierText")
- entry("hayro, lopdf, boa and the engine's other Rust dependencies", "MIT, Apache-2.0 and compatible licences; see NOTICE in the source")
+ entry(stringResource(R.string.root_licence_lucide), "ISC, Lucide Contributors")
+ entry(stringResource(R.string.root_licence_inter), "SIL Open Font License 1.1, The Inter Project Authors")
+ entry(stringResource(R.string.root_licence_ocrs), stringResource(R.string.root_licence_ocrs_terms))
+ entry(stringResource(R.string.root_licence_rust), stringResource(R.string.root_licence_rust_terms))
Spacer(Modifier.height(20.dp))
Text(lucide, color = c.textSecondary, fontSize = 11.sp)
Spacer(Modifier.height(20.dp))
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt
index 7b81ffb..9539e07 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt
@@ -33,6 +33,9 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import io.github.artcraftandroid.pdfcraft.PdfcraftApplication
+import io.github.artcraftandroid.pdfcraft.R
+import io.github.artcraftandroid.pdfcraft.plural
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.core.MobileException
import io.github.artcraftandroid.pdfcraft.engine.DocumentFiles
import io.github.artcraftandroid.pdfcraft.engine.Engine
@@ -115,7 +118,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
settingsOpen = false
showLicences = false
viewModelScope.launch {
- val eng = engine ?: application.engine.await().getOrNull() ?: run { tell(engineProblem ?: "PdfCraft couldn't start."); return@launch }
+ val eng = engine ?: application.engine.await().getOrNull() ?: run { tell(engineProblem ?: text(R.string.msg_engine_not_started)); return@launch }
opening = true
try {
val file = withContext(Dispatchers.IO) {
@@ -127,7 +130,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
// moved or deleted since it was opened: it leaves Recent
withContext(Dispatchers.IO) { recents.remove(setOf(uri.toString())) }
refreshRecents()
- tell("This file has been moved or deleted.")
+ tell(text(R.string.msg_file_moved))
} catch (e: SecurityException) {
// A file another app lent for one visit (Files, Downloads: "Open with"): Android
// takes that access back later, so Recent can't read it again. PdfCraft's own copy
@@ -136,9 +139,9 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val copy = withContext(Dispatchers.IO) { files.existingCopy(uri) }
if (copy != null) {
openFile(eng, uri, copy, password)
- tell("Opened PdfCraft's copy. To change the original, open it again from the app it's in.")
+ tell(text(R.string.msg_opened_own_copy))
} else {
- tell("PdfCraft can't open this file any more. Open it again from the app it's in, or with Open file.")
+ tell(text(R.string.msg_file_access_lost))
}
} catch (e: Exception) {
tell(e.userMessage)
@@ -369,13 +372,13 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun undo(doc: OpenDocument) {
doc.localUndo?.let { it.undo(); return }
val label = doc.info.undo ?: return
- runTool(doc, "edit_undo") { tell("$label undone") }
+ runTool(doc, "edit_undo") { tell(text(R.string.msg_undone, label)) }
}
fun redo(doc: OpenDocument) {
doc.localUndo?.let { it.redo(); return }
val label = doc.info.redo ?: return
- runTool(doc, "edit_redo") { tell("$label redone") }
+ runTool(doc, "edit_redo") { tell(text(R.string.msg_redone, label)) }
}
/** Switch the viewer to [tool], unless the document forbids what it does. */
@@ -398,13 +401,13 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
ViewerTool.None -> false
}
if (blocked) {
- tell(info.readOnlyReason ?: "This tool is not available due to the document's security settings.")
+ tell(info.readOnlyReason ?: text(R.string.msg_tool_blocked_security))
return
}
if (ctl.tool != ViewerTool.None) leaveTool(doc)
doc.selection.clear()
ctl.switchTool(tool)
- if (tool == ViewerTool.Draw && toolPrefs.snapToShape && toolPrefs.takeSnapHint()) tell("Snap to shape on")
+ if (tool == ViewerTool.Draw && toolPrefs.snapToShape && toolPrefs.takeSnapHint()) tell(text(R.string.msg_snap_to_shape_on))
// the first time the reader comments without a name, ask for one (once)
if (tool in setOf(ViewerTool.Comment, ViewerTool.Markup, ViewerTool.Draw, ViewerTool.Text) && toolPrefs.author.isBlank() && !toolPrefs.authorAsked) {
toolPrefs.authorAsked = true
@@ -481,9 +484,9 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
runCatching { withContext(eng.commands) { eng.session.glyphCount(doc.id, p.toUInt()) } }.getOrDefault(1u) == 0u
}
if (textless) {
- tell("This file's words are pictures, so they can't be searched yet.", "Recognize text") { recognizeText(doc) }
+ tell(text(R.string.msg_search_image_only), text(R.string.common_tool_recognize_text)) { recognizeText(doc) }
} else {
- tell("No matches for “${doc.search.query}”")
+ tell(text(R.string.msg_search_no_matches, doc.search.query))
}
}
}
@@ -497,7 +500,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val send = Intent(Intent.ACTION_SEND)
.setType("application/pdf")
.putExtra(Intent.EXTRA_STREAM, uri)
- .putExtra(Intent.EXTRA_SUBJECT, "Emailing ${doc.title}")
+ .putExtra(Intent.EXTRA_SUBJECT, text(R.string.msg_share_subject, doc.title))
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
intents.trySend(Intent.createChooser(send, null))
}
@@ -532,7 +535,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
/** Print [doc] through Android's print framework. */
fun print(doc: OpenDocument) {
if (!doc.info.allowsPrinting) {
- tell("Print unavailable: the author has disabled printing for this document.")
+ tell(text(R.string.msg_print_disabled))
return
}
viewModelScope.launch {
@@ -585,7 +588,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
if (doc.info.dirty) engine?.tool("doc_save", mapOf("doc" to doc.id))
withContext(Dispatchers.IO) { files.writeBack(doc.file, target) }
refresh(doc)
- tell("Saved a copy")
+ tell(text(R.string.msg_saved_copy))
then?.invoke()
} catch (e: Exception) {
tell(e.userMessage)
@@ -623,7 +626,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun startReadAloud(doc: OpenDocument, fromSelection: Boolean = false) {
if (doc.info.encrypted) {
- tell("Read aloud isn't available for password-protected documents.")
+ tell(text(R.string.msg_read_aloud_encrypted))
return
}
readAloud?.stop()
@@ -638,7 +641,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val saved = ReadAloud.savedPosition(getApplication(), key)?.takeIf { it.first in 0 until doc.pageCount }
if (saved != null) {
readAloud = ReadAloud(getApplication(), eng, doc, viewModelScope, saved.first, { readAloud = null }, key, resumeAt = saved.second to saved.third)
- tell("Reading on from where you stopped", "Start over") {
+ tell(text(R.string.msg_read_aloud_resumed), text(R.string.msg_read_aloud_start_over)) {
ReadAloud.forgetPosition(getApplication(), key)
readAloud?.stop()
ReadAloud.forgetPosition(getApplication(), key)
@@ -696,7 +699,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
/** Add a bookmark on the current page, or remove the one there. */
fun toggleBookmark(doc: OpenDocument) {
val (b, added) = bookmarkStore.toggle(docKey(doc), doc.viewer.currentPage)
- tell("${b.name} bookmark ${if (added) "added" else "removed"}")
+ tell(text(if (added) R.string.msg_bookmark_added else R.string.msg_bookmark_removed, b.name))
}
/** Delete all bookmarks of a document: waiting for confirmation. */
@@ -704,7 +707,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun deleteAllBookmarks(doc: OpenDocument) {
bookmarks.clear(doc)
- tell("Bookmarks cleared")
+ tell(text(R.string.msg_bookmarks_cleared))
}
fun isStarred(doc: OpenDocument): Boolean = recentList.firstOrNull { it.uri == docKey(doc) }?.starred == true
@@ -899,7 +902,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun startVoice(doc: OpenDocument, at: PagePoint) {
val app = getApplication<Application>()
if (app.cacheDir.usableSpace < 60L * 1024 * 1024) {
- tell("Not enough free storage to record. Free up some space and try again.")
+ tell(text(R.string.msg_voice_no_storage))
return
}
val prompt = VoicePrompt(doc, at)
@@ -915,7 +918,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun onMicPermission(granted: Boolean) {
val p = pendingVoice
pendingVoice = null
- if (granted && p != null) voicePrompt = p else if (!granted) tell("Voice comments need access to the microphone.")
+ if (granted && p != null) voicePrompt = p else if (!granted) tell(text(R.string.msg_voice_no_mic))
}
fun dismissMicRationale(openSettings: Boolean) {
@@ -961,22 +964,23 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
/** Put [text] on the clipboard (Android 13 and later confirm it themselves). */
fun copyText(text: String) {
val cm = getApplication<Application>().getSystemService(android.content.ClipboardManager::class.java)
- cm?.setPrimaryClip(android.content.ClipData.newPlainText("Comment", text))
- if (android.os.Build.VERSION.SDK_INT < 33) tell("Copied")
+ // the parameter `text` hides the text() function here: called by its full name
+ cm?.setPrimaryClip(android.content.ClipData.newPlainText(io.github.artcraftandroid.pdfcraft.text(R.string.msg_clip_comment), text))
+ if (android.os.Build.VERSION.SDK_INT < 33) tell(io.github.artcraftandroid.pdfcraft.text(R.string.msg_copied))
}
/** Copy the selected text (when the document allows copying). */
fun copySelection(doc: OpenDocument) {
if (!doc.info.allowsCopying) {
- tell("This document doesn't allow copying its text.")
+ tell(text(R.string.msg_copy_not_allowed))
return
}
viewModelScope.launch {
val text = doc.selection.text() ?: return@launch
val cm = getApplication<Application>().getSystemService(android.content.ClipboardManager::class.java)
- cm?.setPrimaryClip(android.content.ClipData.newPlainText("PDF text", text))
+ cm?.setPrimaryClip(android.content.ClipData.newPlainText(io.github.artcraftandroid.pdfcraft.text(R.string.msg_clip_pdf_text), text))
doc.selection.clear()
- if (android.os.Build.VERSION.SDK_INT < 33) tell("Copied")
+ if (android.os.Build.VERSION.SDK_INT < 33) tell(io.github.artcraftandroid.pdfcraft.text(R.string.msg_copied))
}
}
@@ -1007,24 +1011,24 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun recognizeText(doc: OpenDocument) {
val eng = engine ?: return
viewModelScope.launch {
- busy = "Preparing text recognition…"
+ busy = text(R.string.msg_busy_preparing_ocr)
withContext(Dispatchers.IO) { runCatching { eng.prepareOcrModels(getApplication()) } }
busy = null
val status = runCatching { eng.tool("ocr_status") }.getOrNull()
if (status?.optBoolean("available", false) != true) {
- tell("Text recognition isn't installed in this build.")
+ tell(text(R.string.msg_ocr_not_installed))
return@launch
}
- busy = "Recognizing text…"
+ busy = text(R.string.msg_busy_recognizing)
try {
val r = eng.tool("ocr_recognize", mapOf("doc" to doc.id))
refresh(doc)
val pages = r.optJSONArray("pages")
val n = (0 until (pages?.length() ?: 0)).count { pages?.optJSONObject(it)?.has("skipped") == false }
if (n > 0) {
- success = SuccessBanner("Text recognized (English). It can now be selected, copied, searched and highlighted.") { undo(doc) }
+ success = SuccessBanner(text(R.string.msg_ocr_done)) { undo(doc) }
} else {
- tell("No pages needed recognizing")
+ tell(text(R.string.msg_ocr_nothing))
}
} catch (e: MobileException) {
tell(e.userMessage)
@@ -1121,7 +1125,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
"at" to listOf(at.x.toDouble(), at.y.toDouble()), "path" to target.absolutePath, "author" to author,
))
} else {
- tell("Tap where you want to place your ${if (pad.initials) "initials" else "signature"}")
+ tell(text(if (pad.initials) R.string.msg_place_initials else R.string.msg_place_signature))
}
}
}
@@ -1149,7 +1153,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
bmp
}.getOrNull()
}
- if (importedSignature == null) tell("That image couldn't be read.")
+ if (importedSignature == null) tell(text(R.string.msg_image_unreadable))
}
}
@@ -1186,7 +1190,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
/** Draw the box for a new digital signature on [doc], in Fill & Sign. */
fun startCertPlacing(doc: OpenDocument) {
if (!doc.info.readOnlyReason.isNullOrEmpty()) {
- tell("This document can't be changed, so it can't be signed.")
+ tell(text(R.string.msg_sign_read_only))
return
}
if (doc.controller.tool != ViewerTool.FillSign) enterTool(doc, ViewerTool.FillSign)
@@ -1233,18 +1237,18 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val problem = info.problem
if (problem != null) {
imp.file.delete()
- tell("This digital ID can't sign documents. $problem")
+ tell(text(R.string.msg_id_cannot_sign, problem))
return@launch
}
val id = withContext(Dispatchers.IO) { digitalIds.add(imp.file, info) }
imp.file.delete()
chosenId = id
- tell("Added ${id.name}'s digital ID")
+ tell(text(R.string.msg_id_added, id.name))
} catch (e: MobileException.WrongPassword) {
idImport = io.github.artcraftandroid.pdfcraft.ui.viewer.IdImport(imp.file, imp.name, wrong = true)
} catch (e: MobileException) {
imp.file.delete()
- tell("PdfCraft can't use this file as a digital ID: ${e.userMessage}")
+ tell(text(R.string.msg_id_unusable, e.userMessage))
}
}
}
@@ -1253,7 +1257,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun createDigitalId(name: String, email: String, organization: String, password: String) {
val eng = engine ?: return
viewModelScope.launch {
- busy = "Creating your digital ID…"
+ busy = text(R.string.msg_busy_creating_id)
val tmp = File(getApplication<Application>().cacheDir, "new-id-${System.nanoTime()}.p12")
try {
eng.tool("sign_id_create", mapOf(
@@ -1263,7 +1267,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val info = withContext(Dispatchers.IO) { io.github.artcraftandroid.pdfcraft.core.digitalIdInfo(tmp.absolutePath, password) }
chosenId = withContext(Dispatchers.IO) { digitalIds.add(tmp, info) }
idCreate = false
- tell("Digital ID created")
+ tell(text(R.string.msg_id_created))
} catch (e: MobileException) {
tell(toolMessage(e, "sign_id_create"))
} finally {
@@ -1293,7 +1297,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val eng = engine ?: return
val doc = t.doc
viewModelScope.launch {
- busy = "Signing…"
+ busy = text(R.string.msg_busy_signing)
try {
val args = mutableMapOf<String, Any?>(
"doc" to doc.id, "id" to id.file.absolutePath, "password" to password, "out" to doc.file.absolutePath,
@@ -1318,13 +1322,13 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
// the working copy is signed; the original gets it now, or a copy does
doc.notWrittenBack = true
if (save(doc, quiet = true)) {
- tell("Signed and saved")
+ tell(text(R.string.msg_signed_saved))
} else {
- tell("Signed, but ${doc.name} can't be changed where it is. Save a copy to keep the signed file.", "Save a copy") { saveCopyAs(doc) }
+ tell(text(R.string.msg_signed_not_saved, doc.name), text(R.string.common_save_copy)) { saveCopyAs(doc) }
}
} catch (e: MobileException) {
val m = toolMessage(e, "sign_document")
- certSignError = if (m.contains("password is incorrect", ignoreCase = true)) "The password is incorrect." else m
+ certSignError = if (m.contains("password is incorrect", ignoreCase = true)) text(R.string.common_wrong_password) else m
} finally {
busy = null
}
@@ -1333,7 +1337,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
/** A tool's refusal without the tool's name in front, as a sentence. */
private fun toolMessage(e: Throwable, tool: String): String =
- e.userMessage.removePrefix("$tool: ").replaceFirstChar { it.uppercase() }.let { if (it.endsWith(".")) it else "$it." }
+ e.userMessage.removePrefix("$tool: ").replaceFirstChar { it.uppercase() }.let { if (it.lastOrNull()?.isLetterOrDigit() == true) "$it." else it }
/** What the document's signatures say (only asked for when it has signatures or signature fields). */
private suspend fun loadSignatures(eng: Engine, doc: OpenDocument) {
@@ -1349,13 +1353,18 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val signed = doc.signatures.filter { it.signed }
if (signed.isEmpty()) return
val one = signed.singleOrNull()
+ // the local `text` hides the text() function here: called by its full name
val text = when {
- signed.any { it.status == "invalid" } -> if (one != null) "This document's signature is invalid." else "At least one signature in this document is invalid."
- signed.all { it.status == "valid" } -> if (one != null) "Signed by ${one.signer ?: "an unknown signer"}. The signature is valid." else "All ${signed.size} signatures are valid."
- one != null -> "Signed by ${one.signer ?: "an unknown signer"}. The document hasn't changed since, but the signer isn't verified."
- else -> "Signed. Some of the signers aren't verified."
+ signed.any { it.status == "invalid" } -> io.github.artcraftandroid.pdfcraft.text(if (one != null) R.string.msg_sig_invalid else R.string.msg_sig_some_invalid)
+ signed.all { it.status == "valid" } -> if (one != null) {
+ one.signer?.let { io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_valid, it) } ?: io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_valid_unknown)
+ } else {
+ plural(R.plurals.msg_sig_all_valid, signed.size, signed.size)
+ }
+ one != null -> one.signer?.let { io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_unverified, it) } ?: io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_unverified_unknown)
+ else -> io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_some_unverified)
}
- tell(text, "Details") { doc.controller.sheet = io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerSheet.Signatures }
+ tell(text, io.github.artcraftandroid.pdfcraft.text(R.string.msg_sig_details)) { doc.controller.sheet = io.github.artcraftandroid.pdfcraft.ui.viewer.ViewerSheet.Signatures }
}
/** Show signature [s] on its page, flashing its box. */
@@ -1381,7 +1390,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
withContext(Dispatchers.IO) { trustedCerts.add(der, sha) }
applyTrust(eng)
loadSignatures(eng, doc)
- tell("${s.signer ?: "This signer"} is trusted on this device")
+ tell(s.signer?.let { text(R.string.msg_signer_trusted, it) } ?: text(R.string.msg_signer_trusted_unknown))
} catch (e: MobileException) {
tell(e.userMessage)
}
@@ -1663,12 +1672,12 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val f = File(getApplication<Application>().cacheDir, "image-${System.nanoTime()}-${name}")
withContext(Dispatchers.IO) {
getApplication<Application>().contentResolver.openInputStream(uri).use { input ->
- requireNotNull(input) { "The picture couldn't be read." }
+ requireNotNull(input) { text(R.string.msg_picture_unreadable) }
f.outputStream().use { input.copyTo(it) }
}
}
if (name.lowercase().endsWith(".gif")) {
- tell("GIF images can't be added.")
+ tell(text(R.string.msg_gif_not_supported))
return@launch
}
val eng = engine ?: return@launch
@@ -1717,7 +1726,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
} ?: return false
if (w.readOnly) return true
if (!doc.info.allowsFormFilling) {
- tell("This tool is not available due to the document's security settings.")
+ tell(text(R.string.msg_tool_blocked_security))
return true
}
when (w.kind) {
@@ -1751,12 +1760,12 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
when {
act.has("reset") -> {
val names = act.optJSONArray("reset")?.let { a -> (0 until a.length()).map { a.optString(it) } }.orEmpty()
- runTool(doc, "form_reset", if (names.isEmpty()) emptyMap() else mapOf("fields" to names)) { tell("Form cleared") }
+ runTool(doc, "form_reset", if (names.isEmpty()) emptyMap() else mapOf("fields" to names)) { tell(text(R.string.msg_form_cleared)) }
}
act.has("url") -> linkPrompt = act.optString("url")
act.has("page") -> doc.viewer.goToPage((act.optInt("page") - 1).coerceIn(0, doc.pageCount - 1))
- act.has("submit") -> tell("This button sends the form online, which PdfCraft doesn't do.")
- act.has("javascript") -> tell("This button runs a script, which PdfCraft doesn't run.")
+ act.has("submit") -> tell(text(R.string.msg_button_submit))
+ act.has("javascript") -> tell(text(R.string.msg_button_script))
}
}
}
@@ -1825,7 +1834,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
FilePickKind.DigitalId -> viewModelScope.launch {
val uri = uris.first()
val picked = withContext(Dispatchers.IO) { runCatching { copyIn(uri) }.getOrNull() }
- if (picked == null) tell("That file couldn't be read.")
+ if (picked == null) tell(text(R.string.msg_that_file_unreadable))
else idImport = io.github.artcraftandroid.pdfcraft.ui.viewer.IdImport(picked, picked.name, wrong = false)
}
}
@@ -1841,7 +1850,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val dir = File(getApplication<Application>().cacheDir, "picked/${System.nanoTime()}").apply { mkdirs() }
val out = File(dir, files.displayNameRaw(uri))
getApplication<Application>().contentResolver.openInputStream(uri).use { input ->
- requireNotNull(input) { "${out.name} couldn't be read." }
+ requireNotNull(input) { text(R.string.msg_named_file_unreadable, out.name) }
out.outputStream().use { input.copyTo(it) }
}
return out
@@ -1866,9 +1875,9 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
private suspend fun deliver(file: File, name: String, mime: String = "application/pdf") {
val uri = withContext(Dispatchers.IO) { files.saveToDownloads(file, name, mime).also { file.delete() } }
val size = withContext(Dispatchers.IO) { files.size(uri) }
- val sizeText = size?.let { " (${io.github.artcraftandroid.pdfcraft.ui.viewer.formatSize(it)})" } ?: ""
- if (mime == "application/pdf") tell("Saved as $name in Downloads$sizeText", "Open") { open(uri) }
- else tell("Saved as $name in Downloads$sizeText", "Open") {
+ val saved = size?.let { text(R.string.msg_saved_downloads_size, name, io.github.artcraftandroid.pdfcraft.ui.viewer.formatSize(it)) } ?: text(R.string.msg_saved_downloads, name)
+ if (mime == "application/pdf") tell(saved, text(R.string.common_open)) { open(uri) }
+ else tell(saved, text(R.string.common_open)) {
intents.trySend(Intent.createChooser(Intent(Intent.ACTION_VIEW).setDataAndType(uri, mime).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null))
}
}
@@ -1876,7 +1885,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
private fun tempFile(ext: String) = File(getApplication<Application>().cacheDir, "out-${System.nanoTime()}.$ext")
/** Compress PDF at [level] (0 high, 1 medium, 2 low compression). */
- fun compress(doc: OpenDocument, level: Int) = job("Compressing…") { eng ->
+ fun compress(doc: OpenDocument, level: Int) = job(text(R.string.msg_busy_compressing)) { eng ->
val (ppi, above, quality) = when (level) {
0 -> Triple(72, 108, 40)
2 -> Triple(300, 450, 80)
@@ -1892,14 +1901,14 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
if (out.length() >= doc.info.fileSize.toLong()) {
// as the reference: nothing is saved when the file can't get any smaller
out.delete()
- tell("This file is already as small as it can be.")
+ tell(text(R.string.msg_compress_no_gain))
return@job
}
deliver(out, "${doc.title}_compressed.pdf")
}
/** Combine the gathered files, in order, into [name].pdf. */
- fun combine(name: String) = job("Combining…") { eng ->
+ fun combine(name: String) = job(text(R.string.msg_busy_combining)) { eng ->
val paths = withContext(Dispatchers.IO) { combineFiles.map { copyIn(it.uri).absolutePath } }
val out = tempFile("pdf")
eng.tool("doc_combine", mapOf("paths" to paths, "out" to out.absolutePath))
@@ -1912,7 +1921,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
* A protected copy of [doc] with [password] as its open password. The copy is made from a
* second, temporary engine document, so the open one keeps its file and history.
*/
- fun protect(doc: OpenDocument, password: String) = job("Setting password…") { eng ->
+ fun protect(doc: OpenDocument, password: String) = job(text(R.string.msg_busy_setting_password)) { eng ->
save(doc)
val out = tempFile("pdf")
val copy = eng.tool("doc_open", mapOf("path" to doc.file.absolutePath, "password" to doc.password)).optLong("doc")
@@ -1932,12 +1941,12 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
if (page != null) args["pages"] = listOf(page + 1)
runTool(doc, "page_set_box", args) {
toolScreen = null
- tell(if (page == null) "Every page is cropped." else "The page is cropped.")
+ tell(text(if (page == null) R.string.msg_crop_all else R.string.msg_crop_page))
}
}
/** Export [doc] as a Word, RTF, Excel or PowerPoint document. */
- fun exportDocument(doc: OpenDocument, ext: String) = job("Exporting to ${ext.uppercase()}…") { eng ->
+ fun exportDocument(doc: OpenDocument, ext: String) = job(text(R.string.msg_busy_exporting_to, ext.uppercase())) { eng ->
val out = tempFile(ext)
eng.tool("doc_export_office", mapOf("doc" to doc.id, "path" to out.absolutePath))
toolScreen = null
@@ -1968,11 +1977,11 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
}
/** Pictures of [pages] (0-based) at 200 dpi, saved to Pictures/PdfCraft or handed to the share sheet. */
- fun writeImages(doc: OpenDocument, ext: String, pages: List<Int>, share: Boolean) = job("Exporting images…") { eng ->
+ fun writeImages(doc: OpenDocument, ext: String, pages: List<Int>, share: Boolean) = job(text(R.string.msg_busy_exporting_images)) { eng ->
val mime = if (ext == "png") "image/png" else "image/jpeg"
val made = mutableListOf<Pair<File, String>>()
for ((n, i) in pages.withIndex()) {
- busy = "Exporting page ${n + 1} of ${pages.size}…"
+ busy = text(R.string.msg_busy_exporting_page, n + 1, pages.size)
val img = withContext(eng.renders) { eng.session.renderPage(doc.id, i.toUInt(), 200f / 72f, null) }
val out = tempFile(ext)
withContext(Dispatchers.IO) {
@@ -2006,26 +2015,26 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
f.delete()
}
}
- tell(if (made.size == 1) "1 image saved to Pictures/PdfCraft" else "${made.size} images saved to Pictures/PdfCraft")
+ tell(plural(R.plurals.msg_images_saved, made.size, made.size))
}
}
/** Create PDF from picked files (images, text, Office documents, PDFs), combined in order, then open it. */
- private fun createFrom(picked: List<Uri>) = job("Creating PDF…") { eng ->
+ private fun createFrom(picked: List<Uri>) = job(text(R.string.msg_busy_creating_pdf)) { eng ->
// at most 12 files at once, as the reference allows
- if (picked.size > MAX_CREATE_FILES) tell("Only the first $MAX_CREATE_FILES files were used.")
+ if (picked.size > MAX_CREATE_FILES) tell(plural(R.plurals.msg_create_first_files, MAX_CREATE_FILES, MAX_CREATE_FILES))
val uris = picked.take(MAX_CREATE_FILES)
val paths = withContext(Dispatchers.IO) { uris.map { copyIn(it).absolutePath } }
val out = tempFile("pdf")
eng.tool("doc_create_multiple", mapOf("paths" to paths, "out" to out.absolutePath, "mode" to "combine"))
val name = files.displayNameRaw(uris.first()).substringBeforeLast('.') + ".pdf"
val uri = withContext(Dispatchers.IO) { files.saveToDownloads(out, DocumentFiles.safeName(name)).also { out.delete() } }
- tell("Saved as $name in Downloads")
+ tell(text(R.string.msg_saved_downloads, name))
open(uri)
}
/** Pages [pages] (0-based) of [doc] as a new PDF in Downloads. */
- fun extractPages(doc: OpenDocument, pages: List<Int>) = job("Extracting…") { eng ->
+ fun extractPages(doc: OpenDocument, pages: List<Int>) = job(text(R.string.msg_busy_extracting)) { eng ->
val out = tempFile("pdf")
eng.tool("page_extract", mapOf("doc" to doc.id, "pages" to pages.map { it + 1 }, "out" to out.absolutePath))
deliver(out, "Pages from ${doc.title}.pdf")
@@ -2116,7 +2125,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
}
/** Save the scanned pages as a PDF with [filter]'s look (or insert them where Organize asked). */
- fun saveScan(filter: ScanFilter) = job("Saving scan…") { eng ->
+ fun saveScan(filter: ScanFilter) = job(text(R.string.msg_busy_saving_scan)) { eng ->
val pages = scanPages.toList()
val paths = pages.map { it.file.absolutePath }
val created = eng.tool("doc_create", mapOf("from" to "images", "paths" to paths, "name" to "Scan"))
@@ -2130,13 +2139,13 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val size = sizes?.optJSONObject(i) ?: continue
val (w, h) = size.optDouble("width") to size.optDouble("height")
val corners = page.corners.mapIndexed { k, v -> v * if (k % 2 == 0) w else h }
- busy = "Cleaning up page ${i + 1} of ${pages.size}…"
+ busy = text(R.string.msg_busy_cleaning_page, i + 1, pages.size)
runCatching { eng.tool("page_enhance_camera", mapOf("doc" to id, "page" to i + 1, "corners" to corners, "mode" to filter.mode, "level" to filter.level)) }
}
// the scan's words become text, searchable and selectable, when text recognition is installed
withContext(Dispatchers.IO) { runCatching { eng.prepareOcrModels(getApplication()) } }
if (runCatching { eng.tool("ocr_status") }.getOrNull()?.optBoolean("available", false) == true) {
- busy = "Recognizing text…"
+ busy = text(R.string.msg_busy_recognizing)
runCatching { eng.tool("ocr_recognize", mapOf("doc" to id)) }
}
val out = tempFile("pdf")
@@ -2154,7 +2163,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val stamp = java.text.SimpleDateFormat("yyyy-MM-dd HH.mm.ss", java.util.Locale.US).format(java.util.Date())
val name = DocumentFiles.safeName(chosen.ifEmpty { "Scan $stamp" })
val uri = withContext(Dispatchers.IO) { files.saveToDownloads(out, name).also { out.delete() } }
- tell("Saved as $name in Downloads")
+ tell(text(R.string.msg_saved_downloads, name))
open(uri)
}
} finally {
@@ -2290,7 +2299,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
return all.filter { q in it.name.lowercase() }.distinctBy { it.key }.distinctBy { sameFile(it.name, it.size) }
}
- private fun locationOf(uri: String): String = runCatching { files.displayLocation(Uri.parse(uri)) }.getOrDefault("This device")
+ private fun locationOf(uri: String): String = runCatching { files.displayLocation(Uri.parse(uri)) }.getOrDefault(text(R.string.files_location_this_device))
fun clearRecents() {
viewModelScope.launch {
@@ -2361,7 +2370,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun shareFiles(rows: List<io.github.artcraftandroid.pdfcraft.ui.home.FileRow>) {
viewModelScope.launch {
val local = rows.mapNotNull { r -> localFileOf(r)?.let { it to r.name } }
- if (local.isEmpty()) return@launch tell("The files couldn't be read.")
+ if (local.isEmpty()) return@launch tell(text(R.string.msg_files_unreadable))
val uris = withContext(Dispatchers.IO) { files.shareableAll(local) }
val send = if (uris.size == 1) Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_STREAM, uris.first())
else Intent(Intent.ACTION_SEND_MULTIPLE).putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(uris))
@@ -2385,7 +2394,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun shareFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
viewModelScope.launch {
- val f = localFileOf(row) ?: return@launch tell("The file couldn't be read.")
+ val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
val uri = withContext(Dispatchers.IO) { files.shareable(f, row.name) }
intents.trySend(Intent.createChooser(Intent(Intent.ACTION_SEND).setType("application/pdf").putExtra(Intent.EXTRA_STREAM, uri).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null))
}
@@ -2393,14 +2402,14 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun printFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
viewModelScope.launch {
- val f = localFileOf(row) ?: return@launch tell("The file couldn't be read.")
+ val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
prints.trySend(f to row.name)
}
}
fun openWith(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
viewModelScope.launch {
- val f = localFileOf(row) ?: return@launch tell("The file couldn't be read.")
+ val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
val uri = withContext(Dispatchers.IO) { files.shareable(f, row.name) }
intents.trySend(Intent.createChooser(Intent(Intent.ACTION_VIEW).setDataAndType(uri, "application/pdf").addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null))
}
@@ -2416,8 +2425,8 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
u.scheme == "file" -> {
val f = File(requireNotNull(u.path))
val target = File(f.parentFile, name)
- require(!target.exists()) { "A file named $name is already there." }
- require(f.renameTo(target)) { "The file couldn't be renamed." }
+ require(!target.exists()) { text(R.string.msg_rename_exists, name) }
+ require(f.renameTo(target)) { text(R.string.msg_rename_failed) }
recents.remove(setOf(row.key))
recents.touch(RecentFile(Uri.fromFile(target).toString(), name, System.currentTimeMillis(), 0, target.length()))
bookmarkStore.move(row.key, Uri.fromFile(target).toString())
@@ -2425,12 +2434,12 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
// what the tools saved to Downloads: MediaStore entries keep their address when renamed
u.authority == android.provider.MediaStore.AUTHORITY -> {
val values = android.content.ContentValues().apply { put(android.provider.MediaStore.MediaColumns.DISPLAY_NAME, name) }
- require(getApplication<Application>().contentResolver.update(u, values, null, null) > 0) { "This file can't be renamed here." }
+ require(getApplication<Application>().contentResolver.update(u, values, null, null) > 0) { text(R.string.msg_rename_not_here) }
recents.update(row.key) { it.copy(name = name) }
}
else -> {
val renamed = android.provider.DocumentsContract.renameDocument(getApplication<Application>().contentResolver, u, name)
- ?: error("This file can't be renamed here.")
+ ?: error(text(R.string.msg_rename_not_here))
recents.remove(setOf(row.key))
recents.touch(RecentFile(renamed.toString(), name, System.currentTimeMillis(), 0, files.size(renamed) ?: 0))
bookmarkStore.move(row.key, renamed.toString())
@@ -2446,11 +2455,11 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun duplicateFile(row: io.github.artcraftandroid.pdfcraft.ui.home.FileRow) {
viewModelScope.launch {
- val f = localFileOf(row) ?: return@launch tell("The file couldn't be read.")
+ val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
val copy = withContext(Dispatchers.IO) { File(getApplication<Application>().cacheDir, "dup-${System.nanoTime()}.pdf").also { f.copyTo(it, overwrite = true) } }
val base = row.name.removeSuffix(".pdf")
val uri = withContext(Dispatchers.IO) { files.saveToDownloads(copy, "$base copy.pdf").also { copy.delete() } }
- tell("Duplicated as $base copy.pdf in Downloads", "Open") { open(uri) }
+ tell(text(R.string.msg_duplicated, "$base copy.pdf"), text(R.string.common_open)) { open(uri) }
scanLocal(force = true)
}
}
@@ -2468,9 +2477,9 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
copyRow = null
if (target == null) return true
viewModelScope.launch {
- val f = localFileOf(row) ?: return@launch tell("The file couldn't be read.")
+ val f = localFileOf(row) ?: return@launch tell(text(R.string.common_file_unreadable))
runCatching { withContext(Dispatchers.IO) { files.writeBack(f, target) } }
- .onSuccess { tell("Saved a copy") }.onFailure { tell(it.userMessage) }
+ .onSuccess { tell(text(R.string.msg_saved_copy)) }.onFailure { tell(it.userMessage) }
}
return true
}
@@ -2481,15 +2490,15 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
val ok = withContext(Dispatchers.IO) {
runCatching {
when {
- u.scheme == "file" -> require(File(requireNotNull(u.path)).delete()) { "The file couldn't be deleted." }
+ u.scheme == "file" -> require(File(requireNotNull(u.path)).delete()) { text(R.string.msg_delete_failed) }
u.authority == android.provider.MediaStore.AUTHORITY ->
- require(getApplication<Application>().contentResolver.delete(u, null, null) > 0) { "The file couldn't be deleted." }
- else -> require(android.provider.DocumentsContract.deleteDocument(getApplication<Application>().contentResolver, u)) { "The file couldn't be deleted." }
+ require(getApplication<Application>().contentResolver.delete(u, null, null) > 0) { text(R.string.msg_delete_failed) }
+ else -> require(android.provider.DocumentsContract.deleteDocument(getApplication<Application>().contentResolver, u)) { text(R.string.msg_delete_failed) }
}
recents.remove(setOf(row.key))
}
}
- ok.onFailure { tell(it.userMessage) }.onSuccess { tell("${row.name} deleted") }
+ ok.onFailure { tell(it.userMessage) }.onSuccess { tell(text(R.string.msg_file_deleted, row.name)) }
refreshRecents()
scanLocal(force = true)
}
@@ -2531,7 +2540,7 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
fun clearFormSuggestions() {
appPrefs.edit().remove("suggestions").apply()
- tell("Suggestions cleared")
+ tell(text(R.string.msg_suggestions_cleared))
}
// ---- Selecting a comment ------------------------------------------------------------------
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt
index b5a8380..7ffc886 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/Components.kt
@@ -74,6 +74,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -83,6 +84,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import kotlin.math.roundToInt
import kotlinx.coroutines.launch
@@ -178,6 +180,7 @@ fun PdfSheet(
val scope = rememberCoroutineScope()
var drag by remember { mutableFloatStateOf(0f) }
var height by remember { mutableIntStateOf(0) }
+ val closeLabel = stringResource(R.string.ui_close_sheet)
Box(Modifier.fillMaxSize()) {
AnimatedVisibility(visible, enter = fadeIn(tween(PdfMotion.SHEET_IN_MS)), exit = fadeOut(tween(PdfMotion.SHEET_OUT_MS))) {
Box(
@@ -185,7 +188,7 @@ fun PdfSheet(
.fillMaxSize()
.background(if (dim) pdfColors.scrim else Color.Transparent)
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onDismiss)
- .semantics { contentDescription = "Close sheet" },
+ .semantics { contentDescription = closeLabel },
)
}
val density = LocalDensity.current
@@ -289,7 +292,7 @@ fun SheetRow(
@Composable
fun SheetBackHeader(title: String, onBack: () -> Unit, trailing: (@Composable RowScope.() -> Unit)? = null) {
Row(Modifier.fillMaxWidth().height(56.dp).padding(start = 4.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- BarIcon(LucideIcons.ChevronLeft, "Back", onBack)
+ BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.common_back), onBack)
Spacer(Modifier.width(6.dp))
Text(title, color = pdfColors.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)
if (trailing != null) trailing()
@@ -384,7 +387,7 @@ fun PdfDialog(
confirm: String?,
onConfirm: () -> Unit = {},
confirmEnabled: Boolean = true,
- dismiss: String? = "Cancel",
+ dismiss: String? = stringResource(R.string.common_cancel),
onDismissButton: () -> Unit = onDismiss,
destructive: Boolean = false,
/** A choice list's card: lighter grey, narrower, no padding of its own. */
@@ -469,7 +472,7 @@ fun PdfField(
.onFocusChanged { focused = it.isFocused }.semantics { contentDescription = placeholder },
)
}
- if (password) BarIcon(if (visible) LucideIcons.Eye else LucideIcons.EyeOff, if (visible) "Hide password" else "Show password", { visible = !visible }, size = 48.dp)
+ if (password) BarIcon(if (visible) LucideIcons.Eye else LucideIcons.EyeOff, stringResource(if (visible) R.string.ui_hide_password else R.string.ui_show_password), { visible = !visible }, size = 48.dp)
else Spacer(Modifier.width(12.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt
index 40862fb..bfef981 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/ToolScreens.kt
@@ -68,6 +68,8 @@ import androidx.compose.ui.graphics.drawscope.clipPath
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.pluralStringResource
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
@@ -78,6 +80,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.annotation.StringRes
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.engine.toBitmap
import io.github.artcraftandroid.pdfcraft.ui.viewer.formatSize
import kotlin.math.roundToInt
@@ -108,7 +112,7 @@ fun ToolScaffold(
),
verticalAlignment = Alignment.CenterVertically,
) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Back", onBack, iconSize = 27.dp) }
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), onBack, iconSize = 27.dp) }
Spacer(Modifier.width(16.dp))
Text(title, color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
trailing?.invoke()
@@ -172,7 +176,7 @@ fun ToolPage(
// the keyboard covers the pill rather than lifting it, as the reference's does
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().background(c.navBand).navigationBarsPadding().background(c.surface)) {
Row(Modifier.fillMaxWidth().height(io.github.artcraftandroid.pdfcraft.ui.viewer.TopBarHeight), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Back", onBack, iconSize = 27.dp) }
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), onBack, iconSize = 27.dp) }
Spacer(Modifier.weight(1f))
trailing?.invoke()
Spacer(Modifier.width(8.dp))
@@ -248,13 +252,13 @@ fun CompressScreen(vm: AppViewModel, doc: OpenDocument) {
val c = pdfColors
var level by remember { mutableStateOf(1) }
val levels = listOf(
- "High compression" to "Smallest file, images softer",
- "Medium compression" to "Balanced file size and quality",
- "Low compression" to "Bigger file, images sharpest",
+ stringResource(R.string.tools_compress_high) to stringResource(R.string.tools_compress_high_desc),
+ stringResource(R.string.tools_compress_medium) to stringResource(R.string.tools_compress_medium_desc),
+ stringResource(R.string.tools_compress_low) to stringResource(R.string.tools_compress_low_desc),
)
- ToolPage("Compress PDF", { vm.toolScreen = null }, "Compress", true, { vm.compress(doc, level) }) {
+ ToolPage(stringResource(R.string.common_tool_compress), { vm.toolScreen = null }, stringResource(R.string.tools_compress_action), true, { vm.compress(doc, level) }) {
OutlinedFileCard(vm, doc)
- Text("Compression level:", color = c.label, fontSize = 15.sp, modifier = Modifier.padding(start = 24.dp, top = 28.dp, bottom = 4.dp))
+ Text(stringResource(R.string.tools_compression_level), color = c.label, fontSize = 15.sp, modifier = Modifier.padding(start = 24.dp, top = 28.dp, bottom = 4.dp))
levels.forEachIndexed { i, (name, desc) -> ToolChoice(level == i, name, desc) { level = i } }
}
}
@@ -279,7 +283,7 @@ private fun PasswordField(label: String, value: String, onValue: (String) -> Uni
modifier = Modifier.weight(1f).then(if (focus != null) Modifier.focusRequester(focus) else Modifier)
.onFocusChanged { focused = it.isFocused }.semantics { contentDescription = label },
)
- BarIcon(if (visible) LucideIcons.Eye else LucideIcons.EyeOff, if (visible) "Hide password" else "Show password", { onToggle?.invoke() }, size = 44.dp)
+ BarIcon(if (visible) LucideIcons.Eye else LucideIcons.EyeOff, stringResource(if (visible) R.string.ui_hide_password else R.string.ui_show_password), { onToggle?.invoke() }, size = 44.dp)
}
}
@@ -295,19 +299,19 @@ fun ProtectScreen(vm: AppViewModel, doc: OpenDocument) {
LaunchedEffect(Unit) { runCatching { focus.requestFocus() } }
val bad = pw.isNotEmpty() && (pw.length !in 6..128 || pw.any { it < '!' || it > '~' })
val mismatch = confirm.isNotEmpty() && confirm != pw
- ToolPage("Set password", { vm.toolScreen = null }, "Set password", pw.isNotEmpty() && confirm.isNotEmpty() && !bad && !mismatch, { vm.protect(doc, pw) },
- trailing = { BarIcon(LucideIcons.Info, "About passwords", { info = true }) }) {
+ ToolPage(stringResource(R.string.common_tool_set_password), { vm.toolScreen = null }, stringResource(R.string.common_tool_set_password), pw.isNotEmpty() && confirm.isNotEmpty() && !bad && !mismatch, { vm.protect(doc, pw) },
+ trailing = { BarIcon(LucideIcons.Info, stringResource(R.string.tools_about_passwords), { info = true }) }) {
Column(Modifier.verticalScroll(rememberScrollState())) {
- Text("A protected copy of this file is saved.", color = c.label, fontSize = 16.sp, modifier = Modifier.padding(horizontal = 24.dp))
- PasswordField("New password *", pw, { pw = it }, visible, { visible = !visible }, bad, focus)
- if (bad) Text("Use 6 to 128 characters: letters, numbers and symbols, no spaces.", color = c.red, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp))
- PasswordField("Repeat the password *", confirm, { confirm = it }, visible, { visible = !visible }, mismatch)
- if (mismatch) Text("The passwords don't match.", color = c.red, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp))
+ Text(stringResource(R.string.tools_protect_intro), color = c.label, fontSize = 16.sp, modifier = Modifier.padding(horizontal = 24.dp))
+ PasswordField(stringResource(R.string.tools_new_password), pw, { pw = it }, visible, { visible = !visible }, bad, focus)
+ if (bad) Text(stringResource(R.string.tools_password_rule), color = c.red, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp))
+ PasswordField(stringResource(R.string.tools_repeat_password), confirm, { confirm = it }, visible, { visible = !visible }, mismatch)
+ if (mismatch) Text(stringResource(R.string.tools_password_mismatch), color = c.red, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp))
}
}
if (info) {
- PdfDialog(onDismiss = { info = false }, title = "About passwords", confirm = "OK", onConfirm = { info = false }, dismiss = null) {
- Text("The copy is encrypted with AES-256. Keep the password safe: it can't be recovered. To remove the password later, open the copy with it and choose Remove password.", color = c.text, fontSize = 14.sp)
+ PdfDialog(onDismiss = { info = false }, title = stringResource(R.string.tools_about_passwords), confirm = stringResource(R.string.common_ok), onConfirm = { info = false }, dismiss = null) {
+ Text(stringResource(R.string.tools_about_passwords_body), color = c.text, fontSize = 14.sp)
}
}
}
@@ -320,11 +324,14 @@ fun ExportScreen(vm: AppViewModel, doc: OpenDocument) {
// the image format used last time comes first chosen
var format by remember(tab) { mutableStateOf(if (tab == 1 && vm.lastImageFormat == "png") 1 else 0) }
val formats = if (tab == 0) {
- listOf("Word (docx)" to "docx", "Rich Text Format (rtf)" to "rtf", "Excel (xlsx)" to "xlsx", "PowerPoint (pptx)" to "pptx")
+ listOf(
+ stringResource(R.string.tools_format_word) to "docx", stringResource(R.string.tools_format_rtf) to "rtf",
+ stringResource(R.string.tools_format_excel) to "xlsx", stringResource(R.string.tools_format_powerpoint) to "pptx",
+ )
} else {
- listOf("JPEG (jpeg)" to "jpg", "PNG (png)" to "png")
+ listOf(stringResource(R.string.tools_format_jpeg) to "jpg", stringResource(R.string.tools_format_png) to "png")
}
- ToolPage("Export PDF", { vm.toolScreen = null }, "Export", true, {
+ ToolPage(stringResource(R.string.common_tool_export), { vm.toolScreen = null }, stringResource(R.string.tools_export_action), true, {
val ext = formats[format].second
if (tab == 0) vm.exportDocument(doc, ext) else vm.exportImages(doc, ext)
}) {
@@ -332,9 +339,9 @@ fun ExportScreen(vm: AppViewModel, doc: OpenDocument) {
Box(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
Box(Modifier.align(Alignment.BottomStart).fillMaxWidth().height(1.dp).background(c.divider))
Row {
- listOf("Document", "Image").forEachIndexed { i, label ->
+ listOf(R.string.tools_export_document, R.string.tools_export_image).forEachIndexed { i, label ->
Column(Modifier.clickable { tab = i }.padding(horizontal = 8.dp).width(androidx.compose.foundation.layout.IntrinsicSize.Max)) {
- Text(label, color = if (tab == i) c.label else c.text, fontSize = 16.sp, modifier = Modifier.padding(vertical = 12.dp))
+ Text(stringResource(label), color = if (tab == i) c.label else c.text, fontSize = 16.sp, modifier = Modifier.padding(vertical = 12.dp))
Box(Modifier.fillMaxWidth().height(2.dp).background(if (tab == i) c.label else Color.Transparent))
}
if (i == 0) Spacer(Modifier.width(14.dp))
@@ -343,7 +350,7 @@ fun ExportScreen(vm: AppViewModel, doc: OpenDocument) {
}
Spacer(Modifier.height(12.dp))
if (tab == 0 && doc.info.encrypted && !doc.info.allowsCopying) {
- Text("This document's security settings don't allow exporting its text. Export images of its pages instead.", color = c.red, fontSize = 14.sp, modifier = Modifier.padding(20.dp))
+ Text(stringResource(R.string.tools_export_not_allowed), color = c.red, fontSize = 14.sp, modifier = Modifier.padding(20.dp))
}
formats.forEachIndexed { i, (label, _) -> ToolChoice(format == i, label, null) { format = i } }
}
@@ -360,16 +367,16 @@ fun CreateSourcesScreen(vm: AppViewModel) {
BackHandler(onBack = back)
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().background(c.navBand).navigationBarsPadding().background(c.surface)) {
Row(Modifier.fillMaxWidth().height(io.github.artcraftandroid.pdfcraft.ui.viewer.TopBarHeight), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Back", back, iconSize = 27.dp) }
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), back, iconSize = 27.dp) }
Spacer(Modifier.width(4.dp))
- Text("Choose files to make a PDF", color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
+ Text(stringResource(R.string.tools_create_title), color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
}
Spacer(Modifier.height(8.dp))
- SourceRow(LucideIcons.Images, "Photos") { vm.toolScreen = null; vm.pickPhotosToPdf() }
- SourceRow(LucideIcons.FolderOpen, "Browse files") { vm.toolScreen = null; vm.pickFiles(FilePickKind.Create) }
- Text("Or make a new one", color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(start = 20.dp, top = 20.dp, bottom = 6.dp))
+ SourceRow(LucideIcons.Images, stringResource(R.string.home_photos)) { vm.toolScreen = null; vm.pickPhotosToPdf() }
+ SourceRow(LucideIcons.FolderOpen, stringResource(R.string.tools_browse_files)) { vm.toolScreen = null; vm.pickFiles(FilePickKind.Create) }
+ Text(stringResource(R.string.tools_or_make_new), color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(start = 20.dp, top = 20.dp, bottom = 6.dp))
Box(Modifier.padding(horizontal = 16.dp).fillMaxWidth().height(1.dp).background(c.divider))
- SourceRow(LucideIcons.Camera, "Scan a document") { vm.toolScreen = null; vm.startScan() }
+ SourceRow(LucideIcons.Camera, stringResource(R.string.tools_scan_document)) { vm.toolScreen = null; vm.startScan() }
}
}
@@ -415,6 +422,8 @@ fun CombineScreen(vm: AppViewModel) {
val rowPx = with(LocalDensity.current) { 58.dp.toPx() }
val ok = files.size in 2..12
val back = { vm.toolScreen = null; vm.combineFiles.clear() }
+ val dragLabel = stringResource(R.string.tools_drag_to_reorder)
+ val removedMessage = stringResource(R.string.tools_file_removed)
BackHandler(onBack = back)
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().background(c.navBand).navigationBarsPadding().background(c.surface)) {
Row(
@@ -422,19 +431,19 @@ fun CombineScreen(vm: AppViewModel) {
.drawBehind { drawRect(c.divider, Offset(0f, size.height - 1.dp.toPx()), Size(size.width, 1.dp.toPx())) },
verticalAlignment = Alignment.CenterVertically,
) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Back", back, iconSize = 27.dp) }
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), back, iconSize = 27.dp) }
Spacer(Modifier.width(4.dp))
Text(
- if (files.size > 1) "${files.size} files" else "Combine files",
+ if (files.size > 1) pluralStringResource(R.plurals.tools_file_count, files.size, files.size) else stringResource(R.string.common_tool_combine),
color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f),
)
Box(
Modifier.padding(end = 20.dp).height(36.dp).clip(RoundedCornerShape(18.dp)).border(2.dp, c.label, RoundedCornerShape(18.dp))
.clickable { vm.pickFiles(FilePickKind.Combine) }.padding(horizontal = 16.dp),
contentAlignment = Alignment.Center,
- ) { Text("Add files", color = c.label, fontSize = 16.sp, fontWeight = FontWeight.SemiBold) }
+ ) { Text(stringResource(R.string.tools_add_files), color = c.label, fontSize = 16.sp, fontWeight = FontWeight.SemiBold) }
}
- if (files.size > 12) Text("Remove some files: up to 12 can be combined.", color = c.red, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp))
+ if (files.size > 12) Text(stringResource(R.string.tools_combine_too_many), color = c.red, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp))
LazyColumn(Modifier.fillMaxWidth().weight(1f).padding(horizontal = 8.dp)) {
itemsIndexed(files, key = { _, f -> f.uri.toString() }) { i, f ->
Row(
@@ -462,14 +471,14 @@ fun CombineScreen(vm: AppViewModel) {
dragOffset -= (to - from) * rowPx
}
}
- }.semantics { contentDescription = "Drag to reorder" },
+ }.semantics { contentDescription = dragLabel },
contentAlignment = Alignment.Center,
) { Icon(LucideIcons.GripVertical, null, tint = c.icon, modifier = Modifier.size(20.dp)) }
Column(Modifier.weight(1f)) {
Text(f.name.substringBeforeLast('.'), color = c.label, fontSize = 17.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(listOfNotNull(f.name.substringAfterLast('.', "").uppercase(), f.size?.let { formatSize(it) }).joinToString(" • "), color = c.text, fontSize = 14.sp)
}
- BarIcon(LucideIcons.CircleMinus, "Remove ${f.name}", { files.remove(f); vm.tell("File removed") })
+ BarIcon(LucideIcons.CircleMinus, stringResource(R.string.tools_remove_file, f.name), { files.remove(f); vm.tell(removedMessage) })
}
}
}
@@ -477,15 +486,15 @@ fun CombineScreen(vm: AppViewModel) {
Modifier.fillMaxWidth().padding(horizontal = 10.dp, vertical = 12.dp).height(42.dp).clip(RoundedCornerShape(21.dp))
.background(if (ok) c.button else c.pressed).clickable(enabled = ok) { naming = true },
contentAlignment = Alignment.Center,
- ) { Text("Combine as PDF", color = if (ok) Color.White else c.textSecondary, fontSize = 17.sp, fontWeight = FontWeight.SemiBold) }
+ ) { Text(stringResource(R.string.tools_combine_as_pdf), color = if (ok) Color.White else c.textSecondary, fontSize = 17.sp, fontWeight = FontWeight.SemiBold) }
if (naming) {
var name by remember { mutableStateOf("Combine " + java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG).format(java.util.Date())) }
val focus = remember { androidx.compose.ui.focus.FocusRequester() }
PdfDialog(
- onDismiss = { naming = false }, title = "Name the combined file", confirm = "Save",
+ onDismiss = { naming = false }, title = stringResource(R.string.tools_combine_name_title), confirm = stringResource(R.string.common_save),
onConfirm = { naming = false; vm.combine(name.trim().ifEmpty { "Combine" }) },
confirmEnabled = name.isNotBlank(),
- ) { PdfField(name, { name = it }, "File name", focus = focus) }
+ ) { PdfField(name, { name = it }, stringResource(R.string.common_file_name), focus = focus) }
}
}
}
@@ -519,11 +528,11 @@ fun CropScreen(vm: AppViewModel, doc: OpenDocument) {
bitmap = runCatching { withContext(eng.thumbnails) { eng.session.renderPage(doc.id, page.toUInt(), scale, null).toBitmap().asImageBitmap() } }.getOrNull()
}
val changed = !(rect[0] == 0f && rect[1] == 0f && rect[2] == 1f && rect[3] == 1f)
- ToolScaffold(if (allPages) "All pages" else "Current page", { vm.toolScreen = null }, null, false, {},
+ ToolScaffold(stringResource(if (allPages) R.string.tools_all_pages else R.string.tools_current_page), { vm.toolScreen = null }, null, false, {},
viewerBands = true,
trailing = {
Text(
- "Save", color = if (changed) c.label else c.textSecondary.copy(alpha = 0.5f), fontSize = 17.sp,
+ stringResource(R.string.common_save), color = if (changed) c.label else c.textSecondary.copy(alpha = 0.5f), fontSize = 17.sp,
modifier = Modifier.clickable(enabled = changed) {
val info = p ?: return@clickable
vm.crop(doc, if (allPages) null else page, floatArrayOf(rect[0] * info.width, rect[1] * info.height, rect[2] * info.width, rect[3] * info.height))
@@ -626,19 +635,19 @@ fun CropScreen(vm: AppViewModel, doc: OpenDocument) {
}
// the page in a grey pill (with arrows to step through the pages when cropping them all)
Row(Modifier.fillMaxWidth().background(c.desk).height(88.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center) {
- if (allPages) BarIcon(LucideIcons.ChevronLeft, "Previous page", { page = (page - 1).coerceAtLeast(0) }, enabled = page > 0)
+ if (allPages) BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.tools_previous_page), { page = (page - 1).coerceAtLeast(0) }, enabled = page > 0)
Box(
Modifier.widthIn(min = 102.dp).height(32.dp).clip(RoundedCornerShape(16.dp)).background(Color(0xFFD1D1D1)).padding(horizontal = 16.dp),
contentAlignment = Alignment.Center,
- ) { Text("Page ${page + 1}", color = Color(0xFF2C2C2C), fontSize = 15.sp) }
- if (allPages) BarIcon(LucideIcons.ChevronRight, "Next page", { page = (page + 1).coerceAtMost(doc.pageCount - 1) }, enabled = page < doc.pageCount - 1)
+ ) { Text(stringResource(R.string.tools_page_number, page + 1), color = Color(0xFF2C2C2C), fontSize = 15.sp) }
+ if (allPages) BarIcon(LucideIcons.ChevronRight, stringResource(R.string.tools_next_page), { page = (page + 1).coerceAtMost(doc.pageCount - 1) }, enabled = page < doc.pageCount - 1)
}
Row(Modifier.fillMaxWidth().height(54.dp).background(c.surface).padding(start = 12.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) {
PdfSwitch(allPages, { allPages = it })
Spacer(Modifier.width(16.dp))
- Text("All pages", color = c.label, fontSize = 16.sp, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.tools_all_pages), color = c.label, fontSize = 16.sp, modifier = Modifier.weight(1f))
Text(
- "Reset", color = if (changed) c.label else c.textSecondary.copy(alpha = 0.5f), fontSize = 16.sp,
+ stringResource(R.string.tools_reset), color = if (changed) c.label else c.textSecondary.copy(alpha = 0.5f), fontSize = 16.sp,
modifier = Modifier.clickable(enabled = changed) { rect = floatArrayOf(0f, 0f, 1f, 1f) }.padding(horizontal = 12.dp, vertical = 12.dp),
)
}
@@ -658,12 +667,12 @@ data class ScanPage(val file: java.io.File, val thumb: ImageBitmap, val corners:
}
/** The looks a scan can have, and how the engine's camera clean-up gives each. */
-enum class ScanFilter(val label: String, val mode: String, val level: Int) {
- Original("Original", "original", 0),
- AutoColor("Auto colour", "colour", 50),
- Grayscale("Grayscale", "greyscale", 40),
- Whiteboard("Whiteboard", "colour", 85),
- LightText("Light text", "bw", 60),
+enum class ScanFilter(@StringRes val label: Int, val mode: String, val level: Int) {
+ Original(R.string.tools_filter_original, "original", 0),
+ AutoColor(R.string.tools_filter_auto_colour, "colour", 50),
+ Grayscale(R.string.tools_filter_grayscale, "greyscale", 40),
+ Whiteboard(R.string.tools_filter_whiteboard, "colour", 85),
+ LightText(R.string.tools_filter_light_text, "bw", 60),
}
/** Scan: pages taken with the camera, reviewed (name, retake, crop, delete, look), then saved as a PDF. */
@@ -687,15 +696,17 @@ fun ScanScreen(vm: AppViewModel) {
ScanCrop(pages[croppingAt], onDone = { pages[croppingAt] = pages[croppingAt].copy(corners = it); cropping = null }, onCancel = { cropping = null })
return
}
+ val addPageLabel = stringResource(R.string.tools_add_page)
ToolScaffold(
- if (pages.isEmpty()) "Scan" else "Page ${current.coerceAtMost(pages.lastIndex) + 1} of ${pages.size}",
+ if (pages.isEmpty()) stringResource(R.string.common_tool_scan) else stringResource(R.string.tools_page_of, current.coerceAtMost(pages.lastIndex) + 1, pages.size),
{ vm.discardScan() },
- "Save PDF", pages.isNotEmpty(), { vm.saveScan(filter) },
+ stringResource(R.string.tools_save_pdf), pages.isNotEmpty(), { vm.saveScan(filter) },
) {
// the new file's name, changeable before it's saved (not when the pages go into an open document)
if (vm.insertScanAt == null && vm.scanName.isNotBlank()) {
+ val nameLabel = stringResource(R.string.tools_scan_name_description, vm.scanName)
Row(
- Modifier.fillMaxWidth().clickable { naming = true }.padding(horizontal = 16.dp, vertical = 10.dp).semantics { contentDescription = "File name: ${vm.scanName}. Change" },
+ Modifier.fillMaxWidth().clickable { naming = true }.padding(horizontal = 16.dp, vertical = 10.dp).semantics { contentDescription = nameLabel },
verticalAlignment = Alignment.CenterVertically,
) {
Icon(LucideIcons.FileText, null, tint = c.icon, modifier = Modifier.size(20.dp))
@@ -710,38 +721,38 @@ fun ScanScreen(vm: AppViewModel) {
if (page != null) {
ScanPhoto(page.thumb, page.corners, Modifier.fillMaxSize())
} else {
- Text("Take a photo of each page", color = c.textSecondary)
+ Text(stringResource(R.string.tools_scan_empty), color = c.textSecondary)
}
}
Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
pages.forEachIndexed { i, p ->
- Image(p.thumb, "Page ${i + 1}", modifier = Modifier.size(56.dp, 72.dp).clip(RoundedCornerShape(4.dp)).border(2.dp, if (i == current) c.accent else Color.Transparent, RoundedCornerShape(4.dp)).clickable { current = i }, contentScale = ContentScale.Crop)
+ Image(p.thumb, stringResource(R.string.tools_page_number, i + 1), modifier = Modifier.size(56.dp, 72.dp).clip(RoundedCornerShape(4.dp)).border(2.dp, if (i == current) c.accent else Color.Transparent, RoundedCornerShape(4.dp)).clickable { current = i }, contentScale = ContentScale.Crop)
}
- Box(Modifier.size(56.dp, 72.dp).clip(RoundedCornerShape(4.dp)).background(c.surfaceRaised).clickable { vm.takeScanPhoto() }.semantics { contentDescription = "Add page" }, contentAlignment = Alignment.Center) {
+ Box(Modifier.size(56.dp, 72.dp).clip(RoundedCornerShape(4.dp)).background(c.surfaceRaised).clickable { vm.takeScanPhoto() }.semantics { contentDescription = addPageLabel }, contentAlignment = Alignment.Center) {
Icon(LucideIcons.Plus, null, tint = c.icon)
}
}
Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) {
ScanFilter.entries.forEach { f ->
Text(
- f.label, color = if (f == filter) c.accent else c.text, fontSize = 14.sp,
+ stringResource(f.label), color = if (f == filter) c.accent else c.text, fontSize = 14.sp,
modifier = Modifier.clip(CircleShape).background(if (f == filter) c.pressed else Color.Transparent).clickable { filter = f }.padding(horizontal = 14.dp, vertical = 8.dp),
)
}
}
Row(Modifier.fillMaxWidth().padding(8.dp), horizontalArrangement = Arrangement.SpaceEvenly) {
- TextButton(onClick = { vm.retakeScan(current) }, enabled = pages.isNotEmpty()) { Text("Retake", color = c.accent) }
- TextButton(onClick = { cropping = pages.getOrNull(current.coerceAtMost(pages.lastIndex))?.file }, enabled = pages.isNotEmpty()) { Text("Crop", color = c.accent) }
- TextButton(onClick = { if (pages.isNotEmpty()) { pages.removeAt(current.coerceAtMost(pages.lastIndex)); current = (current - 1).coerceAtLeast(0) } }, enabled = pages.isNotEmpty()) { Text("Delete", color = c.accent) }
+ TextButton(onClick = { vm.retakeScan(current) }, enabled = pages.isNotEmpty()) { Text(stringResource(R.string.tools_retake), color = c.accent) }
+ TextButton(onClick = { cropping = pages.getOrNull(current.coerceAtMost(pages.lastIndex))?.file }, enabled = pages.isNotEmpty()) { Text(stringResource(R.string.tools_crop), color = c.accent) }
+ TextButton(onClick = { if (pages.isNotEmpty()) { pages.removeAt(current.coerceAtMost(pages.lastIndex)); current = (current - 1).coerceAtLeast(0) } }, enabled = pages.isNotEmpty()) { Text(stringResource(R.string.common_delete), color = c.accent) }
}
}
if (naming) {
var name by remember { mutableStateOf(vm.scanName) }
PdfDialog(
- onDismiss = { naming = false }, title = "File name",
- confirm = "OK", confirmEnabled = name.isNotBlank(), onConfirm = { vm.scanName = name.trim(); naming = false },
+ onDismiss = { naming = false }, title = stringResource(R.string.common_file_name),
+ confirm = stringResource(R.string.common_ok), confirmEnabled = name.isNotBlank(), onConfirm = { vm.scanName = name.trim(); naming = false },
) {
- PdfField(name, { name = it }, "File name")
+ PdfField(name, { name = it }, stringResource(R.string.common_file_name))
}
}
}
@@ -754,13 +765,13 @@ fun ScanScreen(vm: AppViewModel) {
private fun ScanCrop(page: ScanPage, onDone: (FloatArray) -> Unit, onCancel: () -> Unit) {
val c = pdfColors
var corners by remember(page.file) { mutableStateOf(page.corners) }
- ToolScaffold("Crop", onCancel, "Done", true, { onDone(corners) }) {
+ ToolScaffold(stringResource(R.string.tools_crop), onCancel, stringResource(R.string.common_done), true, { onDone(corners) }) {
Box(Modifier.weight(1f).fillMaxWidth().background(c.desk)) {
ScanPhoto(page.thumb, corners, Modifier.fillMaxSize(), onMove = { corners = it })
}
Row(Modifier.fillMaxWidth().padding(8.dp), horizontalArrangement = Arrangement.SpaceEvenly) {
- TextButton(onClick = { page.found?.let { corners = it } }, enabled = page.found != null) { Text("Auto-detect", color = if (page.found != null) c.accent else c.textSecondary) }
- TextButton(onClick = { corners = ScanPage.WHOLE }) { Text("No crop", color = c.accent) }
+ TextButton(onClick = { page.found?.let { corners = it } }, enabled = page.found != null) { Text(stringResource(R.string.tools_auto_detect), color = if (page.found != null) c.accent else c.textSecondary) }
+ TextButton(onClick = { corners = ScanPage.WHOLE }) { Text(stringResource(R.string.tools_no_crop), color = c.accent) }
}
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt
index 3c4eb67..3680a6d 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/HomeScreen.kt
@@ -53,6 +53,8 @@ import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.res.pluralStringResource
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -61,7 +63,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.annotation.StringRes
import io.github.artcraftandroid.pdfcraft.R
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -79,7 +83,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
/** The tabs along the bottom of the app. */
-enum class HomeTab(val label: String) { Home("Home"), Files("Files"), Tools("Tools"), Search("Search") }
+enum class HomeTab(@StringRes val label: Int) { Home(R.string.home_tab_home), Files(R.string.home_tab_files), Tools(R.string.home_tab_tools), Search(R.string.home_tab_search) }
/** A file as the lists show it, wherever it comes from (recent, starred, on this device). */
data class FileRow(
@@ -126,14 +130,15 @@ private fun BottomNav(selected: HomeTab, onSelect: (HomeTab) -> Unit) {
HomeTab.Search -> LucideIcons.Search
}
val tint = if (t == selected) c.toolAccent else c.icon
+ val label = stringResource(t.label)
Column(
- Modifier.weight(1f).height(61.dp).clickable(role = Role.Tab) { onSelect(t) }.semantics { contentDescription = t.label },
+ Modifier.weight(1f).height(61.dp).clickable(role = Role.Tab) { onSelect(t) }.semantics { contentDescription = label },
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Icon(icon, null, tint = tint, modifier = Modifier.size(22.dp))
Spacer(Modifier.height(5.dp))
- Text(t.label, color = tint, fontSize = 11.sp)
+ Text(label, color = tint, fontSize = 11.sp)
}
}
}
@@ -156,45 +161,47 @@ private fun HomeTabScreen(vm: AppViewModel, onBrowse: () -> Unit) {
val rows = vm.selectedFiles.values.toList()
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
onDismiss = { confirmDeleteSelected = false },
- title = if (rows.size == 1) "Delete 1 file?" else "Delete ${rows.size} files?",
- confirm = "Delete", destructive = true,
+ title = pluralStringResource(R.plurals.home_delete_files_title, rows.size, rows.size),
+ confirm = stringResource(R.string.common_delete), destructive = true,
onConfirm = { confirmDeleteSelected = false; rows.forEach(vm::deleteFile); vm.selectedFiles.clear() },
- ) { Text("They are removed from this phone.", color = c.text, fontSize = 14.sp) }
+ ) { Text(stringResource(R.string.home_delete_files_body), color = c.text, fontSize = 14.sp) }
}
+ val settingsLabel = stringResource(R.string.home_settings)
+ val toolsLabel = stringResource(R.string.home_tab_tools)
Box(Modifier.fillMaxSize()) {
Column(Modifier.fillMaxSize().safeTopPadding()) {
if (vm.selectedFiles.isNotEmpty()) SelectionBar(vm, recent = tab == 0, onDelete = { confirmDeleteSelected = true }) else
Row(Modifier.fillMaxWidth().height(56.dp).padding(start = 16.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
Image(painterResource(R.drawable.ic_launcher_tile), null, modifier = Modifier.size(28.dp).clip(RoundedCornerShape(6.dp)))
Spacer(Modifier.width(10.dp))
- Text("PdfCraft", color = c.text, fontSize = 20.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.app_name), color = c.text, fontSize = 20.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
Box(
- Modifier.size(40.dp).clip(CircleShape).background(c.surfaceRaised).clickable { vm.settingsOpen = true }.semantics { contentDescription = "Settings" },
+ Modifier.size(40.dp).clip(CircleShape).background(c.surfaceRaised).clickable { vm.settingsOpen = true }.semantics { contentDescription = settingsLabel },
contentAlignment = Alignment.Center,
) { Icon(LucideIcons.UserRound, null, tint = c.icon, modifier = Modifier.size(22.dp)) }
}
LazyColumn(Modifier.weight(1f)) {
item {
- Text(if (vm.recentList.isEmpty()) "Welcome" else "Welcome back", color = c.text, fontSize = 24.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 16.dp, top = 8.dp, bottom = 16.dp))
- Text("Start with a tool", color = c.text, fontSize = 15.sp, lineHeight = 22.sp, fontWeight = FontWeight.Medium, modifier = Modifier.padding(start = 16.dp, bottom = 8.dp))
+ Text(stringResource(if (vm.recentList.isEmpty()) R.string.home_welcome else R.string.home_welcome_back), color = c.text, fontSize = 24.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 16.dp, top = 8.dp, bottom = 16.dp))
+ Text(stringResource(R.string.home_start_with_tool), color = c.text, fontSize = 15.sp, lineHeight = 22.sp, fontWeight = FontWeight.Medium, modifier = Modifier.padding(start = 16.dp, bottom = 8.dp))
ToolsCarousel(vm, onBrowse)
Spacer(Modifier.height(16.dp))
Row(Modifier.fillMaxWidth().padding(start = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- listOf("Recent", "Starred", "On device").forEachIndexed { i, label ->
+ listOf(R.string.home_list_recent, R.string.home_list_starred, R.string.home_list_on_device).forEachIndexed { i, label ->
Column(Modifier.clickable(role = Role.Tab) { tab = i }.padding(horizontal = 10.dp), horizontalAlignment = Alignment.CenterHorizontally) {
- Text(label, color = if (tab == i) c.text else c.textSecondary, fontSize = 15.sp, fontWeight = if (tab == i) FontWeight.SemiBold else FontWeight.Normal, modifier = Modifier.padding(vertical = 10.dp))
+ Text(stringResource(label), color = if (tab == i) c.text else c.textSecondary, fontSize = 15.sp, fontWeight = if (tab == i) FontWeight.SemiBold else FontWeight.Normal, modifier = Modifier.padding(vertical = 10.dp))
Box(Modifier.width(48.dp).height(2.dp).background(if (tab == i) c.text else Color.Transparent))
}
}
Spacer(Modifier.weight(1f))
Box {
- BarIcon(LucideIcons.EllipsisVertical, "More options", { menu = true })
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), { menu = true })
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- DropdownMenuItem(text = { Text(if (vm.gridView) "List view" else "Grid view") }, onClick = { menu = false; vm.gridView = !vm.gridView })
- if (tab == 0 && vm.recentList.isNotEmpty()) DropdownMenuItem(text = { Text("Clear recent") }, onClick = { menu = false; confirmClear = true })
+ DropdownMenuItem(text = { Text(stringResource(if (vm.gridView) R.string.home_list_view else R.string.home_grid_view)) }, onClick = { menu = false; vm.gridView = !vm.gridView })
+ if (tab == 0 && vm.recentList.isNotEmpty()) DropdownMenuItem(text = { Text(stringResource(R.string.home_clear_recent)) }, onClick = { menu = false; confirmClear = true })
if (tab == 1) {
- DropdownMenuItem(text = { Text("Sort by name") }, onClick = { menu = false; vm.starSort = 1 })
- DropdownMenuItem(text = { Text("Sort by date") }, onClick = { menu = false; vm.starSort = 0 })
+ DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_name)) }, onClick = { menu = false; vm.starSort = 1 })
+ DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_date)) }, onClick = { menu = false; vm.starSort = 0 })
}
}
}
@@ -209,10 +216,10 @@ private fun HomeTabScreen(vm: AppViewModel, onBrowse: () -> Unit) {
if (rows.isEmpty()) {
item {
when (tab) {
- 0 -> EmptyState(LucideIcons.Clock, "No recent files", "Files you open will appear here.", "Open file", onBrowse)
- 1 -> EmptyState(LucideIcons.Star, "No starred files", "Star a file from its menu to find it here quickly.")
- else -> if (!vm.hasFileAccess) EmptyState(LucideIcons.Smartphone, "Files on your device", "Choose folders to list PDFs from, such as Documents or a folder inside Download. Files you open from anywhere stay in Recent.", "Add a folder") { vm.requestFileAccess() }
- else EmptyState(LucideIcons.Smartphone, "No PDFs in your folders", "PDFs in the folders you added will appear here.", "Add a folder") { vm.requestFileAccess() }
+ 0 -> EmptyState(LucideIcons.Clock, stringResource(R.string.home_no_recent_title), stringResource(R.string.home_no_recent_body), stringResource(R.string.home_open_file), onBrowse)
+ 1 -> EmptyState(LucideIcons.Star, stringResource(R.string.home_no_starred_title), stringResource(R.string.home_no_starred_body))
+ else -> if (!vm.hasFileAccess) EmptyState(LucideIcons.Smartphone, stringResource(R.string.home_device_files_title), stringResource(R.string.home_device_files_body), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
+ else EmptyState(LucideIcons.Smartphone, stringResource(R.string.home_no_pdfs_title), stringResource(R.string.home_no_pdfs_body), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
}
}
} else if (vm.gridView) {
@@ -227,7 +234,7 @@ private fun HomeTabScreen(vm: AppViewModel, onBrowse: () -> Unit) {
}
if (tab == 2 && vm.localRows().size > 10) {
item {
- Text("Other files on this phone", color = c.accent, fontWeight = FontWeight.SemiBold, modifier = Modifier.fillMaxWidth().clickable { vm.homeTab = HomeTab.Files; vm.filesShowLocal = true }.padding(16.dp))
+ Text(stringResource(R.string.home_other_files), color = c.accent, fontWeight = FontWeight.SemiBold, modifier = Modifier.fillMaxWidth().clickable { vm.homeTab = HomeTab.Files; vm.filesShowLocal = true }.padding(16.dp))
}
}
item { Spacer(Modifier.height(88.dp)) }
@@ -238,25 +245,25 @@ private fun HomeTabScreen(vm: AppViewModel, onBrowse: () -> Unit) {
containerColor = c.button,
contentColor = Color.White,
shape = CircleShape,
- modifier = Modifier.align(Alignment.BottomEnd).padding(16.dp).semantics { contentDescription = "Tools" },
+ modifier = Modifier.align(Alignment.BottomEnd).padding(16.dp).semantics { contentDescription = toolsLabel },
) { Icon(LucideIcons.Plus, null, modifier = Modifier.size(26.dp)) }
}
if (fabMenu) {
PdfSheet(onDismiss = { fabMenu = false }, dim = true) {
- SheetRow(LucideIcons.FolderOpen, "Open file", { fabMenu = false; onBrowse() })
- SheetRow(LucideIcons.Camera, "New scan", { fabMenu = false; vm.startScan() })
+ SheetRow(LucideIcons.FolderOpen, stringResource(R.string.home_open_file), { fabMenu = false; onBrowse() })
+ SheetRow(LucideIcons.Camera, stringResource(R.string.home_new_scan), { fabMenu = false; vm.startScan() })
SheetDivider()
- SheetRow(LucideIcons.FilePenLine, "Edit PDF", { fabMenu = false; vm.toolForFile(FileTool.Edit) })
- SheetRow(LucideIcons.FilePlus2, "Create PDF", { fabMenu = false; vm.openCreate() })
- SheetRow(LucideIcons.Combine, "Combine files", { fabMenu = false; vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) })
+ SheetRow(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), { fabMenu = false; vm.toolForFile(FileTool.Edit) })
+ SheetRow(LucideIcons.FilePlus2, stringResource(R.string.common_tool_create_pdf), { fabMenu = false; vm.openCreate() })
+ SheetRow(LucideIcons.Combine, stringResource(R.string.common_tool_combine), { fabMenu = false; vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) })
Spacer(Modifier.height(12.dp))
}
}
if (confirmClear) {
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { confirmClear = false }, title = "Clear recent files?",
- confirm = "Clear", onConfirm = { confirmClear = false; vm.clearRecents() }, destructive = true,
- ) { Text("The list of recent files is cleared. The files themselves stay where they are.", color = c.text, fontSize = 14.sp) }
+ onDismiss = { confirmClear = false }, title = stringResource(R.string.home_clear_recent_title),
+ confirm = stringResource(R.string.common_clear), onConfirm = { confirmClear = false; vm.clearRecents() }, destructive = true,
+ ) { Text(stringResource(R.string.home_clear_recent_body), color = c.text, fontSize = 14.sp) }
}
}
@@ -267,16 +274,16 @@ enum class FileTool { Edit, ReadAloud, FillSign, Organize, Compress, Export, Pro
@Composable
private fun ToolsCarousel(vm: AppViewModel, onBrowse: () -> Unit) {
Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(16.dp)) {
- CarouselTile(LucideIcons.FolderOpen, "Open file", ToolHues.crop, onBrowse)
- CarouselTile(LucideIcons.FilePenLine, "Edit PDF", ToolHues.edit) { vm.toolForFile(FileTool.Edit) }
- CarouselTile(LucideIcons.Volume2, "Read aloud", ToolHues.read) { vm.toolForFile(FileTool.ReadAloud) }
- CarouselTile(LucideIcons.Signature, "Fill & Sign", ToolHues.sign) { vm.toolForFile(FileTool.FillSign) }
- CarouselTile(LucideIcons.FilePlus2, "Create PDF", ToolHues.create) { vm.openCreate() }
- CarouselTile(LucideIcons.LayoutGrid, "Organize pages", ToolHues.organize) { vm.toolForFile(FileTool.Organize) }
- CarouselTile(LucideIcons.Combine, "Combine files", ToolHues.combine) { vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) }
- CarouselTile(LucideIcons.FileArchive, "Compress PDF", ToolHues.compress) { vm.toolForFile(FileTool.Compress) }
- CarouselTile(LucideIcons.FileOutput, "Export PDF", ToolHues.export) { vm.toolForFile(FileTool.Export) }
- CarouselTile(LucideIcons.FileLock2, "Set password", ToolHues.protect) { vm.toolForFile(FileTool.Protect) }
+ CarouselTile(LucideIcons.FolderOpen, stringResource(R.string.home_open_file), ToolHues.crop, onBrowse)
+ CarouselTile(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), ToolHues.edit) { vm.toolForFile(FileTool.Edit) }
+ CarouselTile(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), ToolHues.read) { vm.toolForFile(FileTool.ReadAloud) }
+ CarouselTile(LucideIcons.Signature, stringResource(R.string.common_tool_fill_sign), ToolHues.sign) { vm.toolForFile(FileTool.FillSign) }
+ CarouselTile(LucideIcons.FilePlus2, stringResource(R.string.common_tool_create_pdf), ToolHues.create) { vm.openCreate() }
+ CarouselTile(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_organize), ToolHues.organize) { vm.toolForFile(FileTool.Organize) }
+ CarouselTile(LucideIcons.Combine, stringResource(R.string.common_tool_combine), ToolHues.combine) { vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) }
+ CarouselTile(LucideIcons.FileArchive, stringResource(R.string.common_tool_compress), ToolHues.compress) { vm.toolForFile(FileTool.Compress) }
+ CarouselTile(LucideIcons.FileOutput, stringResource(R.string.common_tool_export), ToolHues.export) { vm.toolForFile(FileTool.Export) }
+ CarouselTile(LucideIcons.FileLock2, stringResource(R.string.common_tool_set_password), ToolHues.protect) { vm.toolForFile(FileTool.Protect) }
}
}
@@ -318,13 +325,13 @@ fun EmptyState(icon: ImageVector, title: String, body: String, action: String? =
/** "Just now", the time if today, "Yesterday", else a medium date. */
fun whenLabel(t: Long): String {
val now = System.currentTimeMillis()
- if (now - t < 60_000) return "Just now"
+ if (now - t < 60_000) return text(R.string.home_just_now)
val cal = Calendar.getInstance().apply { timeInMillis = t }
val today = Calendar.getInstance()
val sameDay = cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)
if (sameDay) return DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(t))
today.add(Calendar.DAY_OF_YEAR, -1)
- if (cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) return "Yesterday"
+ if (cal.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cal.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) return text(R.string.common_yesterday)
return DateFormat.getDateInstance(DateFormat.MEDIUM).format(Date(t))
}
@@ -363,13 +370,13 @@ fun FileListRow(vm: AppViewModel, r: FileRow, recent: Boolean = false) {
Text(r.name.removeSuffix(".pdf").removeSuffix(".PDF"), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.Medium, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
if (r.starred) {
Spacer(Modifier.width(6.dp))
- Icon(LucideIcons.Star, "Starred", tint = Color(0xFFF5B800), modifier = Modifier.size(14.dp))
+ Icon(LucideIcons.Star, stringResource(R.string.home_starred_description), tint = Color(0xFFF5B800), modifier = Modifier.size(14.dp))
}
}
Spacer(Modifier.height(2.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
// where it is, then type, date and size: "PDF • Yesterday • 2.3 MB"
- Icon(LucideIcons.Smartphone, "Stored on ${r.location}", tint = c.textTertiary, modifier = Modifier.size(14.dp))
+ Icon(LucideIcons.Smartphone, stringResource(R.string.home_stored_on, r.location), tint = c.textTertiary, modifier = Modifier.size(14.dp))
Spacer(Modifier.width(6.dp))
Text(listOfNotNull("PDF", whenLabel(r.date), r.size.takeIf { it > 0 }?.let { formatSize(it) }).joinToString(" • "), color = c.textTertiary, fontSize = 13.sp, fontWeight = FontWeight.Medium, maxLines = 1)
}
@@ -377,7 +384,7 @@ fun FileListRow(vm: AppViewModel, r: FileRow, recent: Boolean = false) {
if (selecting) {
Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) { SelectBox(ticked) }
} else {
- BarIcon(LucideIcons.EllipsisVertical, "More options for ${r.name}", { vm.fileSheet = r to recent })
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.home_more_options_for, r.name), { vm.fileSheet = r to recent })
}
}
}
@@ -400,15 +407,15 @@ private fun SelectionBar(vm: AppViewModel, recent: Boolean, onDelete: () -> Unit
val rows = vm.selectedFiles.values.toList()
var menu by remember { mutableStateOf(false) }
Row(Modifier.fillMaxWidth().height(56.dp).padding(horizontal = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- BarIcon(LucideIcons.X, "Clear selection", { vm.selectedFiles.clear() })
- Text(if (rows.size == 1) "1 file selected" else "${rows.size} files selected", color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f).padding(start = 8.dp))
- BarIcon(LucideIcons.Share2, "Share", { vm.shareFiles(rows); vm.selectedFiles.clear() })
- if (rows.size >= 2) BarIcon(LucideIcons.Combine, "Combine files", { vm.combineSelected(rows); vm.selectedFiles.clear() })
+ BarIcon(LucideIcons.X, stringResource(R.string.home_clear_selection), { vm.selectedFiles.clear() })
+ Text(pluralStringResource(R.plurals.home_files_selected, rows.size, rows.size), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f).padding(start = 8.dp))
+ BarIcon(LucideIcons.Share2, stringResource(R.string.common_share), { vm.shareFiles(rows); vm.selectedFiles.clear() })
+ if (rows.size >= 2) BarIcon(LucideIcons.Combine, stringResource(R.string.common_tool_combine), { vm.combineSelected(rows); vm.selectedFiles.clear() })
Box {
- BarIcon(LucideIcons.EllipsisVertical, "More options", { menu = true })
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), { menu = true })
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- if (recent) DropdownMenuItem(text = { Text("Remove from recent") }, onClick = { menu = false; vm.removeRecents(rows); vm.selectedFiles.clear() })
- DropdownMenuItem(text = { Text("Delete", color = c.red) }, onClick = { menu = false; onDelete() })
+ if (recent) DropdownMenuItem(text = { Text(stringResource(R.string.home_remove_from_recent)) }, onClick = { menu = false; vm.removeRecents(rows); vm.selectedFiles.clear() })
+ DropdownMenuItem(text = { Text(stringResource(R.string.common_delete), color = c.red) }, onClick = { menu = false; onDelete() })
}
}
}
@@ -424,7 +431,7 @@ private fun FileGridCell(vm: AppViewModel, r: FileRow, modifier: Modifier, recen
Text(r.name.removeSuffix(".pdf"), color = c.text, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(whenLabel(r.date), color = c.textSecondary, fontSize = 12.sp)
}
- BarIcon(LucideIcons.EllipsisVertical, "More options for ${r.name}", { vm.fileSheet = r to recent }, size = 40.dp)
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.home_more_options_for, r.name), { vm.fileSheet = r to recent }, size = 40.dp)
}
}
}
@@ -450,36 +457,36 @@ fun FileSheet(vm: AppViewModel, r: FileRow, recent: Boolean, onDismiss: () -> Un
}
SheetDivider()
Column(Modifier.verticalScroll(rememberScrollState())) {
- SheetRow(LucideIcons.FilePenLine, "Edit PDF", { act { vm.openFor(r, FileTool.Edit) } })
- SheetRow(LucideIcons.Volume2, "Read aloud", { act { vm.openFor(r, FileTool.ReadAloud) } })
- SheetRow(LucideIcons.FileOutput, "Export as...", { act { vm.openFor(r, FileTool.Export) } })
- SheetRow(LucideIcons.FileArchive, "Compress PDF", { act { vm.openFor(r, FileTool.Compress) } })
- SheetRow(LucideIcons.FileLock2, "Set password", { act { vm.openFor(r, FileTool.Protect) } })
+ SheetRow(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), { act { vm.openFor(r, FileTool.Edit) } })
+ SheetRow(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), { act { vm.openFor(r, FileTool.ReadAloud) } })
+ SheetRow(LucideIcons.FileOutput, stringResource(R.string.home_export_as), { act { vm.openFor(r, FileTool.Export) } })
+ SheetRow(LucideIcons.FileArchive, stringResource(R.string.common_tool_compress), { act { vm.openFor(r, FileTool.Compress) } })
+ SheetRow(LucideIcons.FileLock2, stringResource(R.string.common_tool_set_password), { act { vm.openFor(r, FileTool.Protect) } })
SheetDivider()
- SheetRow(LucideIcons.Share2, "Share", { act { vm.shareFile(r) } })
- SheetRow(LucideIcons.Printer, "Print", { act { vm.printFile(r) } })
- SheetRow(LucideIcons.ExternalLink, "Open with", { act { vm.openWith(r) } })
- SheetRow(LucideIcons.Star, if (r.starred) "Unstar" else "Star", { act { vm.setStarred(r.key, !r.starred) } })
- SheetRow(LucideIcons.Pencil, "Rename", { renaming = true })
- SheetRow(LucideIcons.Copy, "Duplicate", { act { vm.duplicateFile(r) } })
- SheetRow(LucideIcons.FileDown, "Save a copy", { act { vm.saveFileCopy(r) } })
- if (recent) SheetRow(LucideIcons.X, "Remove from recent", { act { vm.removeRecent(r.key) } })
- SheetRow(LucideIcons.Trash2, "Delete", { deleting = true }, tint = c.red)
+ SheetRow(LucideIcons.Share2, stringResource(R.string.common_share), { act { vm.shareFile(r) } })
+ SheetRow(LucideIcons.Printer, stringResource(R.string.home_print), { act { vm.printFile(r) } })
+ SheetRow(LucideIcons.ExternalLink, stringResource(R.string.home_open_with), { act { vm.openWith(r) } })
+ SheetRow(LucideIcons.Star, stringResource(if (r.starred) R.string.home_unstar else R.string.home_star), { act { vm.setStarred(r.key, !r.starred) } })
+ SheetRow(LucideIcons.Pencil, stringResource(R.string.common_rename), { renaming = true })
+ SheetRow(LucideIcons.Copy, stringResource(R.string.home_duplicate), { act { vm.duplicateFile(r) } })
+ SheetRow(LucideIcons.FileDown, stringResource(R.string.common_save_copy), { act { vm.saveFileCopy(r) } })
+ if (recent) SheetRow(LucideIcons.X, stringResource(R.string.home_remove_from_recent), { act { vm.removeRecent(r.key) } })
+ SheetRow(LucideIcons.Trash2, stringResource(R.string.common_delete), { deleting = true }, tint = c.red)
Spacer(Modifier.height(8.dp))
}
}
if (renaming) {
var name by remember { mutableStateOf(r.name.removeSuffix(".pdf")) }
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { renaming = false }, title = "Rename",
- confirm = "Done", onConfirm = { renaming = false; onDismiss(); vm.renameFile(r, name) }, confirmEnabled = name.isNotBlank() && !name.startsWith("."),
- ) { io.github.artcraftandroid.pdfcraft.ui.PdfField(name, { name = it }, "Enter name") }
+ onDismiss = { renaming = false }, title = stringResource(R.string.common_rename),
+ confirm = stringResource(R.string.common_done), onConfirm = { renaming = false; onDismiss(); vm.renameFile(r, name) }, confirmEnabled = name.isNotBlank() && !name.startsWith("."),
+ ) { io.github.artcraftandroid.pdfcraft.ui.PdfField(name, { name = it }, stringResource(R.string.home_enter_name)) }
}
if (deleting) {
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { deleting = false }, title = "Delete file?",
- confirm = "Delete", onConfirm = { deleting = false; onDismiss(); vm.deleteFile(r) }, destructive = true,
- ) { Text("Are you sure you want to permanently delete '${r.name}'?", color = c.text, fontSize = 14.sp) }
+ onDismiss = { deleting = false }, title = stringResource(R.string.home_delete_file_title),
+ confirm = stringResource(R.string.common_delete), onConfirm = { deleting = false; onDismiss(); vm.deleteFile(r) }, destructive = true,
+ ) { Text(stringResource(R.string.home_delete_file_body, r.name), color = c.text, fontSize = 14.sp) }
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt
index 1046230..b237ccd 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt
@@ -54,6 +54,8 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalUriHandler
+import androidx.compose.ui.res.pluralStringResource
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -63,6 +65,8 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.annotation.StringRes
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.Inter
@@ -84,11 +88,11 @@ fun FilesTab(vm: AppViewModel, onBrowse: () -> Unit) {
Column(Modifier.fillMaxSize().safeTopPadding()) {
// a large title, as the expanded bar of the reference shows it
Box(Modifier.fillMaxWidth().height(128.dp), contentAlignment = Alignment.BottomStart) {
- Text("Files", color = c.label, fontSize = 24.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 16.dp, bottom = 40.dp))
+ Text(stringResource(R.string.home_tab_files), color = c.label, fontSize = 24.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 16.dp, bottom = 40.dp))
}
- LocationRow(LucideIcons.Smartphone, "On this device") { vm.filesShowLocal = true }
- LocationRow(LucideIcons.Image, "Photos") { vm.pickPhotosToPdf() }
- LocationRow(LucideIcons.FolderOpen, "Look in other folders", onBrowse)
+ LocationRow(LucideIcons.Smartphone, stringResource(R.string.home_on_this_device)) { vm.filesShowLocal = true }
+ LocationRow(LucideIcons.Image, stringResource(R.string.home_photos)) { vm.pickPhotosToPdf() }
+ LocationRow(LucideIcons.FolderOpen, stringResource(R.string.home_look_in_other_folders), onBrowse)
}
}
@@ -112,19 +116,19 @@ private fun OnThisDevice(vm: AppViewModel) {
var menu by remember { mutableStateOf(false) }
Column(Modifier.fillMaxSize().safeTopPadding()) {
Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Back", { vm.filesShowLocal = false }) }
- Text("On this device", color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
- BarIcon(LucideIcons.RotateCw, "Refresh", { vm.scanLocal(force = true) })
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), { vm.filesShowLocal = false }) }
+ Text(stringResource(R.string.home_on_this_device), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
+ BarIcon(LucideIcons.RotateCw, stringResource(R.string.home_refresh), { vm.scanLocal(force = true) })
Box {
- BarIcon(LucideIcons.EllipsisVertical, "More options", { menu = true })
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), { menu = true })
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- DropdownMenuItem(text = { Text("Sort by name") }, onClick = { sort = 1; menu = false }, trailingIcon = { if (sort == 1) Icon(LucideIcons.Check, null, tint = c.accent) })
- DropdownMenuItem(text = { Text("Sort by date") }, onClick = { sort = 0; menu = false }, trailingIcon = { if (sort == 0) Icon(LucideIcons.Check, null, tint = c.accent) })
+ DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_name)) }, onClick = { sort = 1; menu = false }, trailingIcon = { if (sort == 1) Icon(LucideIcons.Check, null, tint = c.accent) })
+ DropdownMenuItem(text = { Text(stringResource(R.string.home_sort_by_date)) }, onClick = { sort = 0; menu = false }, trailingIcon = { if (sort == 0) Icon(LucideIcons.Check, null, tint = c.accent) })
HorizontalDivider(color = c.divider)
- DropdownMenuItem(text = { Text("Add a folder") }, onClick = { menu = false; vm.requestFileAccess() }, leadingIcon = { Icon(LucideIcons.FolderPlus, null, tint = c.icon) })
+ DropdownMenuItem(text = { Text(stringResource(R.string.home_add_folder)) }, onClick = { menu = false; vm.requestFileAccess() }, leadingIcon = { Icon(LucideIcons.FolderPlus, null, tint = c.icon) })
// the folders listed here, each with a way to stop listing it
for ((tree, name) in vm.localFolders()) {
- DropdownMenuItem(text = { Text("Stop listing $name") }, onClick = { menu = false; vm.removeLocalFolder(tree) }, leadingIcon = { Icon(LucideIcons.Folder, null, tint = c.icon) })
+ DropdownMenuItem(text = { Text(stringResource(R.string.home_stop_listing, name)) }, onClick = { menu = false; vm.removeLocalFolder(tree) }, leadingIcon = { Icon(LucideIcons.Folder, null, tint = c.icon) })
}
}
}
@@ -132,19 +136,20 @@ private fun OnThisDevice(vm: AppViewModel) {
val rows = vm.localRows().let { if (sort == 1) it.sortedBy { r -> r.name.lowercase() } else it }
// what PdfCraft saved itself shows before any folder is added
if (!vm.hasFileAccess && rows.isEmpty()) {
- EmptyState(LucideIcons.Smartphone, "Files on your device", "Choose folders to list PDFs from, such as Documents or a folder inside Download (Android doesn't let apps list the whole Download folder). PdfCraft sees only the folders you choose, and files you open from anywhere stay in Recent.", "Add a folder") { vm.requestFileAccess() }
+ EmptyState(LucideIcons.Smartphone, stringResource(R.string.home_device_files_title), stringResource(R.string.home_device_files_body_long), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
return@Column
}
if (rows.isEmpty()) {
- if (vm.scanning) EmptyState(LucideIcons.FileText, "Looking for PDFs…", "")
- else EmptyState(LucideIcons.FileText, "No PDFs in your folders", "PDFs in the folders you added will appear here.", "Add a folder") { vm.requestFileAccess() }
+ if (vm.scanning) EmptyState(LucideIcons.FileText, stringResource(R.string.home_looking_for_pdfs), "")
+ else EmptyState(LucideIcons.FileText, stringResource(R.string.home_no_pdfs_title), stringResource(R.string.home_no_pdfs_body), stringResource(R.string.home_add_folder)) { vm.requestFileAccess() }
return@Column
}
LazyColumn(Modifier.weight(1f)) {
val groups = rows.groupBy { it.location }
for ((folder, list) in groups) {
item(key = "h-$folder") {
- Text(folder.uppercase().ifEmpty { "INTERNAL STORAGE" }, color = c.textSecondary, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 4.dp))
+ val internalStorage = stringResource(R.string.home_internal_storage)
+ Text(folder.uppercase().ifEmpty { internalStorage }, color = c.textSecondary, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 4.dp))
}
items(list, key = { it.key }) { r -> FileListRow(vm, r) }
}
@@ -153,8 +158,8 @@ private fun OnThisDevice(vm: AppViewModel) {
}
}
-/** A tool of the Tools tab: its tile, name and one line about it. */
-private class HubTool(val icon: ImageVector, val name: String, val about: String, val hue: Color, val categories: Set<String>, val go: () -> Unit)
+/** A tool of the Tools tab: its tile, name and one line about it ([name] is its key, [label] what is shown). */
+private class HubTool(val icon: ImageVector, val name: String, @StringRes val label: Int, @StringRes val about: Int, val hue: Color, val categories: Set<String>, val go: () -> Unit)
/** Where a category lists its tools in an order of its own (the rest keep the All order). */
private val CategoryOrder = mapOf(
@@ -166,31 +171,34 @@ private val CategoryOrder = mapOf(
@Composable
fun ToolsTab(vm: AppViewModel) {
val c = pdfColors
- val categories = listOf("All", "Read", "Create", "Edit", "Convert")
+ val categories = listOf(
+ "All" to R.string.home_category_all, "Read" to R.string.home_category_read, "Create" to R.string.home_category_create,
+ "Edit" to R.string.home_category_edit, "Convert" to R.string.home_category_convert,
+ )
var cat by remember { mutableStateOf("All") }
val tools = remember {
listOf(
- HubTool(LucideIcons.Signature, "Fill & Sign", "Fill in forms and sign them", ToolHues.sign, emptySet()) { vm.toolForFile(FileTool.FillSign) },
- HubTool(LucideIcons.MessageSquareText, "Add comment", "Comment, highlight and draw", ToolHues.comment, emptySet()) { vm.toolForFile(FileTool.Comment) },
- HubTool(LucideIcons.Volume2, "Read aloud", "Listen to a PDF", ToolHues.read, setOf("Read")) { vm.toolForFile(FileTool.ReadAloud) },
- HubTool(LucideIcons.FilePlus2, "Create PDF", "Turn images and text into PDFs", ToolHues.create, setOf("Create")) { vm.openCreate() },
- HubTool(LucideIcons.Camera, "New scan", "Scan paper with the camera", ToolHues.scan, setOf("Create")) { vm.startScan() },
- HubTool(LucideIcons.Combine, "Combine files", "Join several files into one PDF", ToolHues.combine, setOf("Create", "Edit")) { vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) },
- HubTool(LucideIcons.LayoutGrid, "Organize pages", "Reorder, rotate, delete and insert pages", ToolHues.organize, setOf("Edit")) { vm.toolForFile(FileTool.Organize) },
- HubTool(LucideIcons.Crop, "Crop pages", "Trim margins or change page size", ToolHues.crop, setOf("Edit")) { vm.toolForFile(FileTool.Crop) },
- HubTool(LucideIcons.FilePenLine, "Edit PDF", "Change the text and pictures", ToolHues.edit, setOf("Edit")) { vm.toolForFile(FileTool.Edit) },
- HubTool(LucideIcons.FileArchive, "Compress PDF", "Make a PDF smaller", ToolHues.compress, setOf("Convert")) { vm.toolForFile(FileTool.Compress) },
- HubTool(LucideIcons.FileOutput, "Export PDF", "Save a PDF as a document, spreadsheet, slides or images", ToolHues.export, setOf("Convert")) { vm.toolForFile(FileTool.Export) },
- HubTool(LucideIcons.FileLock2, "Set password", "Protect a PDF with a password", ToolHues.protect, setOf("Edit")) { vm.toolForFile(FileTool.Protect) },
+ HubTool(LucideIcons.Signature, "Fill & Sign", R.string.common_tool_fill_sign, R.string.home_about_fill_sign, ToolHues.sign, emptySet()) { vm.toolForFile(FileTool.FillSign) },
+ HubTool(LucideIcons.MessageSquareText, "Add comment", R.string.home_tool_add_comment, R.string.home_about_comment, ToolHues.comment, emptySet()) { vm.toolForFile(FileTool.Comment) },
+ HubTool(LucideIcons.Volume2, "Read aloud", R.string.common_tool_read_aloud, R.string.home_about_read_aloud, ToolHues.read, setOf("Read")) { vm.toolForFile(FileTool.ReadAloud) },
+ HubTool(LucideIcons.FilePlus2, "Create PDF", R.string.common_tool_create_pdf, R.string.home_about_create, ToolHues.create, setOf("Create")) { vm.openCreate() },
+ HubTool(LucideIcons.Camera, "New scan", R.string.home_new_scan, R.string.home_about_scan, ToolHues.scan, setOf("Create")) { vm.startScan() },
+ HubTool(LucideIcons.Combine, "Combine files", R.string.common_tool_combine, R.string.home_about_combine, ToolHues.combine, setOf("Create", "Edit")) { vm.pickFiles(io.github.artcraftandroid.pdfcraft.ui.FilePickKind.Combine) },
+ HubTool(LucideIcons.LayoutGrid, "Organize pages", R.string.common_tool_organize, R.string.home_about_organize, ToolHues.organize, setOf("Edit")) { vm.toolForFile(FileTool.Organize) },
+ HubTool(LucideIcons.Crop, "Crop pages", R.string.common_tool_crop, R.string.home_about_crop, ToolHues.crop, setOf("Edit")) { vm.toolForFile(FileTool.Crop) },
+ HubTool(LucideIcons.FilePenLine, "Edit PDF", R.string.common_tool_edit_pdf, R.string.home_about_edit, ToolHues.edit, setOf("Edit")) { vm.toolForFile(FileTool.Edit) },
+ HubTool(LucideIcons.FileArchive, "Compress PDF", R.string.common_tool_compress, R.string.home_about_compress, ToolHues.compress, setOf("Convert")) { vm.toolForFile(FileTool.Compress) },
+ HubTool(LucideIcons.FileOutput, "Export PDF", R.string.common_tool_export, R.string.home_about_export, ToolHues.export, setOf("Convert")) { vm.toolForFile(FileTool.Export) },
+ HubTool(LucideIcons.FileLock2, "Set password", R.string.common_tool_set_password, R.string.home_about_protect, ToolHues.protect, setOf("Edit")) { vm.toolForFile(FileTool.Protect) },
)
}
Column(Modifier.fillMaxSize().safeTopPadding()) {
- Text("Tools", color = c.label, fontSize = 27.sp, lineHeight = 35.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 16.dp, top = 12.dp, bottom = 12.dp))
+ Text(stringResource(R.string.home_tab_tools), color = c.label, fontSize = 27.sp, lineHeight = 35.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 16.dp, top = 12.dp, bottom = 12.dp))
// text tabs with a 2 dp underline under the chosen one
Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
- for (k in categories) {
+ for ((k, label) in categories) {
Column(Modifier.clickable(role = Role.Tab) { cat = k }.width(androidx.compose.foundation.layout.IntrinsicSize.Max)) {
- Text(k, color = if (k == cat) c.label else c.textTertiary, fontSize = 17.sp, lineHeight = 25.sp, fontWeight = if (k == cat) FontWeight.SemiBold else FontWeight.Normal)
+ Text(stringResource(label), color = if (k == cat) c.label else c.textTertiary, fontSize = 17.sp, lineHeight = 25.sp, fontWeight = if (k == cat) FontWeight.SemiBold else FontWeight.Normal)
Spacer(Modifier.height(14.dp))
Box(Modifier.fillMaxWidth().height(2.dp).background(if (k == cat) c.label else Color.Transparent))
}
@@ -202,16 +210,17 @@ fun ToolsTab(vm: AppViewModel) {
horizontalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
) {
items(tools.filter { cat == "All" || cat in it.categories }.sortedBy { t -> CategoryOrder[cat]?.indexOf(t.name)?.takeIf { it >= 0 } ?: Int.MAX_VALUE }) { t ->
+ val name = stringResource(t.label)
Column(
Modifier.fillMaxWidth().clip(RoundedCornerShape(12.dp)).background(c.surface)
- .border(1.dp, c.divider, RoundedCornerShape(12.dp)).clickable(onClick = t.go).padding(16.dp).semantics { contentDescription = t.name },
+ .border(1.dp, c.divider, RoundedCornerShape(12.dp)).clickable(onClick = t.go).padding(16.dp).semantics { contentDescription = name },
) {
Box(Modifier.size(64.dp).clip(RoundedCornerShape(5.dp)).background(tint(t.hue, c.dark)), contentAlignment = Alignment.Center) {
Icon(t.icon, null, tint = t.hue, modifier = Modifier.size(32.dp))
}
Spacer(Modifier.height(12.dp))
- Text(t.name, color = c.label, fontSize = 15.sp, lineHeight = 20.sp, fontWeight = FontWeight.SemiBold)
- Text(t.about, color = c.label, fontSize = 15.sp, lineHeight = 21.sp)
+ Text(name, color = c.label, fontSize = 15.sp, lineHeight = 20.sp, fontWeight = FontWeight.SemiBold)
+ Text(stringResource(t.about), color = c.label, fontSize = 15.sp, lineHeight = 21.sp)
}
}
item { Spacer(Modifier.height(8.dp)) }
@@ -227,6 +236,9 @@ fun SearchTab(vm: AppViewModel) {
var sort by remember { mutableStateOf(0) }
var menu by remember { mutableStateOf(false) }
LaunchedEffect(Unit) { vm.scanLocal() }
+ val searchHint = stringResource(R.string.home_search_your_files)
+ // the orders results can be sorted in, by [sort]
+ val sorts = listOf(R.string.home_sort_relevant, R.string.home_sort_name_az, R.string.home_sort_name_za, R.string.home_sort_oldest, R.string.home_sort_newest)
Column(Modifier.fillMaxSize().safeTopPadding()) {
Row(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp).clip(CircleShape).background(c.surfaceRaised).padding(horizontal = 14.dp, vertical = 10.dp), verticalAlignment = Alignment.CenterVertically) {
Icon(LucideIcons.Search, null, tint = c.textSecondary, modifier = Modifier.size(20.dp))
@@ -236,21 +248,21 @@ fun SearchTab(vm: AppViewModel) {
keyboardOptions = androidx.compose.foundation.text.KeyboardOptions(imeAction = androidx.compose.ui.text.input.ImeAction.Search),
keyboardActions = androidx.compose.foundation.text.KeyboardActions(onSearch = { vm.addRecentSearch(query) }),
textStyle = TextStyle(fontFamily = Inter, fontSize = 16.sp, color = c.text), cursorBrush = SolidColor(c.accent),
- modifier = Modifier.weight(1f).semantics { contentDescription = "Search your files" },
- decorationBox = { inner -> Box { if (query.isEmpty()) Text("Search your files", color = c.textSecondary, fontSize = 16.sp); inner() } },
+ modifier = Modifier.weight(1f).semantics { contentDescription = searchHint },
+ decorationBox = { inner -> Box { if (query.isEmpty()) Text(searchHint, color = c.textSecondary, fontSize = 16.sp); inner() } },
)
- if (query.isNotEmpty()) BarIcon(LucideIcons.X, "Clear", { query = "" }, size = 32.dp)
+ if (query.isNotEmpty()) BarIcon(LucideIcons.X, stringResource(R.string.common_clear), { query = "" }, size = 32.dp)
}
if (query.isBlank()) {
val recent = vm.recentSearches
if (recent.isEmpty()) {
- EmptyState(LucideIcons.Search, "Search your files", "Find PDFs on this phone by name.")
+ EmptyState(LucideIcons.Search, searchHint, stringResource(R.string.home_search_empty_body))
return@Column
}
// the last searches, to run again with a tap
Row(Modifier.fillMaxWidth().padding(start = 16.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- Text("Recent searches", color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
- Text("Clear", color = c.toolAccent, fontSize = 15.sp, modifier = Modifier.clickable { vm.clearRecentSearches() }.padding(12.dp))
+ Text(stringResource(R.string.home_recent_searches), color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.common_clear), color = c.toolAccent, fontSize = 15.sp, modifier = Modifier.clickable { vm.clearRecentSearches() }.padding(12.dp))
}
LazyColumn(Modifier.weight(1f)) {
items(recent, key = { it }) { q ->
@@ -258,7 +270,7 @@ fun SearchTab(vm: AppViewModel) {
Icon(LucideIcons.Clock, null, tint = c.icon, modifier = Modifier.size(22.dp))
Spacer(Modifier.width(16.dp))
Text(q, color = c.text, fontSize = 16.sp, maxLines = 1, modifier = Modifier.weight(1f))
- BarIcon(LucideIcons.X, "Remove $q", { vm.removeRecentSearch(q) }, size = 40.dp)
+ BarIcon(LucideIcons.X, stringResource(R.string.home_remove_search, q), { vm.removeRecentSearch(q) }, size = 40.dp)
}
}
}
@@ -280,22 +292,22 @@ fun SearchTab(vm: AppViewModel) {
}
}
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp), verticalAlignment = Alignment.CenterVertically) {
- Text("${results.size} ${if (results.size == 1) "result" else "results"} on this device", color = c.text, fontSize = 15.sp, modifier = Modifier.weight(1f))
+ Text(pluralStringResource(R.plurals.home_search_results, results.size, results.size), color = c.text, fontSize = 15.sp, modifier = Modifier.weight(1f))
Box {
Row(Modifier.clickable { menu = true }.padding(vertical = 10.dp), verticalAlignment = Alignment.CenterVertically) {
- Text(listOf("Most relevant", "Name A→Z", "Name Z→A", "Least recently modified", "Most recently modified")[sort], color = c.label, fontSize = 15.sp)
+ Text(stringResource(sorts[sort]), color = c.label, fontSize = 15.sp)
Spacer(Modifier.width(4.dp))
Icon(LucideIcons.ArrowUpDown, null, tint = c.icon, modifier = Modifier.size(18.dp))
}
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.surface) {
- listOf("Most relevant", "Name A→Z", "Name Z→A", "Least recently modified", "Most recently modified").forEachIndexed { i, s ->
- DropdownMenuItem(text = { Text(s) }, onClick = { sort = i; menu = false }, trailingIcon = { if (sort == i) Icon(LucideIcons.Check, null, tint = c.accent) })
+ sorts.forEachIndexed { i, s ->
+ DropdownMenuItem(text = { Text(stringResource(s)) }, onClick = { sort = i; menu = false }, trailingIcon = { if (sort == i) Icon(LucideIcons.Check, null, tint = c.accent) })
}
}
}
}
if (results.isEmpty()) {
- EmptyState(LucideIcons.FileSearch, "No results", "Check the spelling, or try a shorter name.")
+ EmptyState(LucideIcons.FileSearch, stringResource(R.string.home_no_results), stringResource(R.string.home_no_results_body))
} else {
LazyColumn(Modifier.weight(1f)) { items(results, key = { it.key }) { r -> FileListRow(vm, r) } }
}
@@ -311,28 +323,28 @@ fun SettingsScreen(vm: AppViewModel) {
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().navigationBarsPadding()) {
Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) {
- BarIcon(LucideIcons.ArrowLeft, "Back", { if (page == "root") vm.settingsOpen = false else page = "root" })
+ BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), { if (page == "root") vm.settingsOpen = false else page = "root" })
}
- Text(when (page) { "about" -> "About PdfCraft"; "prefs" -> "Preferences"; "help" -> "Help & Support"; else -> "Settings" }, color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
+ Text(stringResource(when (page) { "about" -> R.string.home_about_app; "prefs" -> R.string.home_preferences; "help" -> R.string.home_help_support; else -> R.string.home_settings }), color = c.text, fontSize = 18.sp, fontWeight = FontWeight.SemiBold)
}
Column(Modifier.verticalScroll(rememberScrollState())) {
when (page) {
"root" -> {
- SheetRow(LucideIcons.Info, "About PdfCraft", { page = "about" }, chevron = true)
- SheetRow(LucideIcons.Settings, "Preferences", { page = "prefs" }, chevron = true)
- SheetRow(LucideIcons.CircleHelp, "Help & Support", { page = "help" }, chevron = true)
+ SheetRow(LucideIcons.Info, stringResource(R.string.home_about_app), { page = "about" }, chevron = true)
+ SheetRow(LucideIcons.Settings, stringResource(R.string.home_preferences), { page = "prefs" }, chevron = true)
+ SheetRow(LucideIcons.CircleHelp, stringResource(R.string.home_help_support), { page = "help" }, chevron = true)
}
"prefs" -> Preferences(vm)
"about" -> About(vm)
"help" -> {
val uri = LocalUriHandler.current
var leaving by remember { mutableStateOf<String?>(null) }
- SheetRow(LucideIcons.CircleHelp, "Help", { leaving = "$APP_REPO#readme" })
- SheetRow(LucideIcons.MessageSquare, "Report a problem or request a feature", { leaving = "$APP_REPO/issues" })
+ SheetRow(LucideIcons.CircleHelp, stringResource(R.string.home_help), { leaving = "$APP_REPO#readme" })
+ SheetRow(LucideIcons.MessageSquare, stringResource(R.string.home_report_problem), { leaving = "$APP_REPO/issues" })
leaving?.let { url ->
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { leaving = null }, title = "Leaving PdfCraft", confirm = "Continue", onConfirm = { leaving = null; uri.openUri(url) },
- ) { Text("This opens a web page in your browser.", color = c.text, fontSize = 14.sp) }
+ onDismiss = { leaving = null }, title = stringResource(R.string.home_leaving_title), confirm = stringResource(R.string.home_continue), onConfirm = { leaving = null; uri.openUri(url) },
+ ) { Text(stringResource(R.string.home_leaving_body), color = c.text, fontSize = 14.sp) }
}
}
}
@@ -344,39 +356,40 @@ fun SettingsScreen(vm: AppViewModel) {
private fun Preferences(vm: AppViewModel) {
val c = pdfColors
var authorDialog by remember { mutableStateOf(false) }
- Section("Notifications")
- Text("PdfCraft doesn't send notifications.", color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp))
+ Section(stringResource(R.string.home_section_notifications))
+ Text(stringResource(R.string.home_no_notifications), color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 6.dp))
SheetDivider()
- Section("Auto-suggestions")
- SheetRow(null, "Offer words you used before when filling in forms", { vm.updateFormSuggestions(!vm.formSuggestions) }) {
+ Section(stringResource(R.string.home_section_suggestions))
+ SheetRow(null, stringResource(R.string.home_offer_suggestions), { vm.updateFormSuggestions(!vm.formSuggestions) }) {
PdfSwitch(vm.formSuggestions, { vm.updateFormSuggestions(it) })
}
- SheetRow(null, "Clear suggestions", { vm.clearFormSuggestions() })
+ SheetRow(null, stringResource(R.string.home_clear_suggestions), { vm.clearFormSuggestions() })
SheetDivider()
- Section("Your name on comments")
- SheetRow(null, vm.toolPrefs.author.ifBlank { "Tap to enter your name, to show on your comments" }, { authorDialog = true })
+ Section(stringResource(R.string.home_author_title))
+ val authorHint = stringResource(R.string.home_author_hint)
+ SheetRow(null, vm.toolPrefs.author.ifBlank { authorHint }, { authorDialog = true })
SheetDivider()
- Section("Screen setting")
- SheetRow(null, "Keep the screen on", { vm.updateKeepScreenOn(!vm.keepScreenOn) }) {
+ Section(stringResource(R.string.home_section_screen))
+ SheetRow(null, stringResource(R.string.home_keep_screen_on), { vm.updateKeepScreenOn(!vm.keepScreenOn) }) {
PdfSwitch(vm.keepScreenOn, { vm.updateKeepScreenOn(it) })
}
- Text("Keeps the screen on while you read, for up to 30 minutes without a touch.", color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))
+ Text(stringResource(R.string.home_keep_screen_on_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))
SheetDivider()
- Section("Keyboard")
- SheetRow(null, "Keyboard shortcuts", { vm.updateKeyboardShortcuts(!vm.keyboardShortcuts) }) {
+ Section(stringResource(R.string.home_section_keyboard))
+ SheetRow(null, stringResource(R.string.home_keyboard_shortcuts), { vm.updateKeyboardShortcuts(!vm.keyboardShortcuts) }) {
PdfSwitch(vm.keyboardShortcuts, { vm.updateKeyboardShortcuts(it) })
}
Text(
- "With a keyboard connected: N or Page Down for the next page, P or Page Up for the previous one, the arrow keys to scroll, Ctrl+P to print, Ctrl and + or − to zoom.",
+ stringResource(R.string.home_keyboard_shortcuts_body),
color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp),
)
Spacer(Modifier.height(24.dp))
if (authorDialog) {
var name by remember { mutableStateOf(vm.toolPrefs.author) }
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { authorDialog = false }, title = "Your name on comments",
- confirm = "OK", onConfirm = { vm.toolPrefs.author = name.trim(); authorDialog = false; vm.prefsChanged++ },
- ) { io.github.artcraftandroid.pdfcraft.ui.PdfField(name, { name = it }, "Your name") }
+ onDismiss = { authorDialog = false }, title = stringResource(R.string.home_author_title),
+ confirm = stringResource(R.string.common_ok), onConfirm = { vm.toolPrefs.author = name.trim(); authorDialog = false; vm.prefsChanged++ },
+ ) { io.github.artcraftandroid.pdfcraft.ui.PdfField(name, { name = it }, stringResource(R.string.common_your_name)) }
}
}
@@ -393,21 +406,22 @@ private fun About(vm: AppViewModel) {
val c = pdfColors
val clipboard = LocalClipboardManager.current
val uri = LocalUriHandler.current
- Section("About")
- val version = "Version ${vm.appVersion} (engine ${io.github.artcraftandroid.pdfcraft.core.engineVersion()})"
+ Section(stringResource(R.string.home_section_about))
+ val version = stringResource(R.string.home_version, vm.appVersion, io.github.artcraftandroid.pdfcraft.core.engineVersion())
+ val copied = stringResource(R.string.home_version_copied)
Text(
version, color = c.text, fontSize = 16.sp,
modifier = Modifier.fillMaxWidth()
- .pointerInput(version) { detectTapGestures(onLongPress = { clipboard.setText(AnnotatedString(version)); vm.tell("Version copied") }) }
+ .pointerInput(version) { detectTapGestures(onLongPress = { clipboard.setText(AnnotatedString(version)); vm.tell(copied) }) }
.padding(horizontal = 20.dp, vertical = 12.dp),
)
SheetDivider()
- Section("Legal")
- SheetRow(null, "Open-source licences", { vm.showLicences = true })
- SheetRow(null, "Source code", { uri.openUri(APP_REPO) })
- SheetRow(null, "PdfCraft engine", { uri.openUri("https://github.com/storytold/pdfcraft") })
+ Section(stringResource(R.string.home_section_legal))
+ SheetRow(null, stringResource(R.string.home_licences), { vm.showLicences = true })
+ SheetRow(null, stringResource(R.string.home_source_code), { uri.openUri(APP_REPO) })
+ SheetRow(null, stringResource(R.string.home_engine), { uri.openUri("https://github.com/storytold/pdfcraft") })
Text(
- "PdfCraft for Android is built on PdfCraft's Rust engine. MIT OR Apache-2.0. PdfCraft is not affiliated with Adobe; Acrobat is a trademark of Adobe Inc.",
+ stringResource(R.string.home_legal_notice),
color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(20.dp), overflow = TextOverflow.Visible,
)
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt
index 16c7bd0..92e9dd9 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentDrag.kt
@@ -19,10 +19,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.CommentInfo
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
import kotlin.math.roundToInt
@@ -56,6 +58,8 @@ fun CommentDragOverlay(
var shift by remember(c.page, c.index, c.rect) { mutableStateOf(Offset.Zero) }
var resized by remember(c.page, c.index, c.rect) { mutableStateOf<Rect?>(null) }
val ppp = doc.viewer.pixelsPerPoint(page).coerceAtLeast(0.01f)
+ val moveLabel = stringResource(R.string.comments_move)
+ val resizeLabel = stringResource(R.string.comments_resize)
// the frame where the comment will go
Canvas(Modifier.fillMaxSize()) {
@@ -80,7 +84,7 @@ fun CommentDragOverlay(
onDragCancel = { shift = Offset.Zero },
)
}
- .semantics { contentDescription = "Move comment" },
+ .semantics { contentDescription = moveLabel },
)
if (c.subtype !in Resizable) return
// corner handles: drag to resize, the opposite corner staying put
@@ -115,7 +119,7 @@ fun CommentDragOverlay(
onDragCancel = { resized = null },
)
}
- .semantics { contentDescription = "Resize comment" },
+ .semantics { contentDescription = resizeLabel },
) {
Canvas(Modifier.fillMaxSize()) {
drawCircle(Color.White, size.minDimension / 2.6f)
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt
index 6ea30ec..b6e32a1 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentList.kt
@@ -1,6 +1,7 @@
package io.github.artcraftandroid.pdfcraft.ui.viewer
import androidx.activity.compose.BackHandler
+import androidx.annotation.StringRes
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -47,6 +48,7 @@ import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.drawscope.clipPath
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -56,9 +58,11 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.CommentInfo
import io.github.artcraftandroid.pdfcraft.core.TileRect
import io.github.artcraftandroid.pdfcraft.engine.toBitmap
+import io.github.artcraftandroid.pdfcraft.plural
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -78,42 +82,39 @@ internal val LISTED = setOf(
/** The markups whose row shows a picture of the text they mark. */
private val SNIPPETS = setOf("Highlight", "Underline", "StrikeOut")
-/** What a comment did, in the list's italic line. */
-internal fun commentActionLabel(c: CommentInfo): String = when (c.subtype) {
- "Highlight" -> "Highlighted"
- "Underline" -> "Underlined"
- "StrikeOut" -> "Struck out text"
- "Ink" -> "Drew freehand"
- "Line" -> if (c.kind.contains("arrow", ignoreCase = true)) "Drew an arrow" else "Drew a line"
- "Square" -> "Drew a rectangle"
- "Circle" -> "Drew an oval"
- "Polygon" -> if (c.kind.contains("cloud", ignoreCase = true)) "Drew a cloud" else "Drew a polygon"
- "PolyLine" -> "Drew joined lines"
- "Stamp" -> "Stamped the page"
- "Text" -> "Added a note"
- "FreeText" -> if (c.kind.contains("callout", ignoreCase = true)) "Added a callout" else "Added a text box"
- "Caret" -> if (c.kind.contains("replace", ignoreCase = true)) "Suggested a replacement" else "Suggested an insertion"
- "Sound" -> "Recorded a voice note"
- else -> "Commented"
+/** What a comment did, in the list's italic line (a string resource). */
+@StringRes
+internal fun commentActionLabel(c: CommentInfo): Int = when (c.subtype) {
+ "Highlight" -> R.string.comments_action_highlighted
+ "Underline" -> R.string.comments_action_underlined
+ "StrikeOut" -> R.string.comments_action_struck_out
+ "Ink" -> R.string.comments_action_freehand
+ "Line" -> if (c.kind.contains("arrow", ignoreCase = true)) R.string.comments_action_arrow else R.string.comments_action_line
+ "Square" -> R.string.comments_action_rectangle
+ "Circle" -> R.string.comments_action_oval
+ "Polygon" -> if (c.kind.contains("cloud", ignoreCase = true)) R.string.comments_action_cloud else R.string.comments_action_polygon
+ "PolyLine" -> R.string.comments_action_joined_lines
+ "Stamp" -> R.string.comments_action_stamp
+ "Text" -> R.string.comments_action_note
+ "FreeText" -> if (c.kind.contains("callout", ignoreCase = true)) R.string.comments_action_callout else R.string.comments_action_text_box
+ "Caret" -> if (c.kind.contains("replace", ignoreCase = true)) R.string.comments_action_replacement else R.string.comments_action_insertion
+ "Sound" -> R.string.comments_action_voice
+ else -> R.string.comments_action_other
}
-/** When a comment was made: "Today", "Yesterday", else the date. */
-internal fun commentDateLabel(raw: String?, now: Long = System.currentTimeMillis()): String? {
+/** When a comment was made: [today] ("Today"), [yesterday] ("Yesterday"), else the date. */
+internal fun commentDateLabel(raw: String?, today: String, yesterday: String, now: Long = System.currentTimeMillis()): String? {
val t = pdfDateMillis(raw) ?: return null
fun day(ms: Long) = java.util.Calendar.getInstance().apply { timeInMillis = ms }.let { it.get(java.util.Calendar.YEAR) * 400 + it.get(java.util.Calendar.DAY_OF_YEAR) }
return when (day(t)) {
- day(now) -> "Today"
- day(now - 24L * 3600 * 1000) -> "Yesterday"
+ day(now) -> today
+ day(now - 24L * 3600 * 1000) -> yesterday
else -> java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM).format(java.util.Date(t))
}
}
-/** "N comment threads" (replies aren't threads of their own). */
-internal fun threadsTitle(n: Int): String = when (n) {
- 0 -> "No comments"
- 1 -> "1 comment thread"
- else -> "$n comment threads"
-}
+/** "N comment threads" (replies aren't threads of their own): [none] for none, else [count] of them. */
+internal fun threadsTitle(n: Int, none: String, count: (Int) -> String): String = if (n == 0) none else count(n)
/**
* Comment List, full screen as the reference's is on a phone: "N comment threads", the threads
@@ -150,10 +151,10 @@ fun CommentListScreen(vm: AppViewModel, doc: OpenDocument) {
verticalAlignment = Alignment.CenterVertically,
) {
Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) {
- BarIcon(LucideIcons.ArrowLeft, "Back", ::close, iconSize = 27.dp)
+ BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), ::close, iconSize = 27.dp)
}
Text(
- if (list == null) "Comments" else threadsTitle(threads.size),
+ if (list == null) stringResource(R.string.comments_title) else threadsTitle(threads.size, stringResource(R.string.comments_none)) { plural(R.plurals.comments_threads, it, it) },
color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold,
)
}
@@ -178,11 +179,11 @@ fun CommentListScreen(vm: AppViewModel, doc: OpenDocument) {
.padding(start = 16.dp, top = if (pageIndex == 0) 12.dp else 15.dp, end = 16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- Text("Page ${page + 1}", color = c.label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.sheet_page, page + 1), color = c.label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
// the chevron's 40 dp target overlaps the rows around it rather than spacing them
Box(Modifier.size(width = 40.dp, height = 22.dp), contentAlignment = Alignment.Center) {
Icon(
- LucideIcons.ChevronUp, if (isFolded) "Expand" else "Collapse", tint = c.icon,
+ LucideIcons.ChevronUp, stringResource(if (isFolded) R.string.comments_expand else R.string.comments_collapse), tint = c.icon,
modifier = Modifier.size(22.dp).rotate(if (isFolded) 180f else 0f),
)
}
@@ -222,19 +223,19 @@ fun CommentListScreen(vm: AppViewModel, doc: OpenDocument) {
PdfSheet(onDismiss = { menuFor = null }, dim = true) {
val text = cm.contents?.takeIf { it.isNotBlank() }
if (text != null) {
- SheetRow(LucideIcons.Copy, "Copy text", {
+ SheetRow(LucideIcons.Copy, stringResource(R.string.comments_copy_text), {
menuFor = null
vm.copyText(text)
})
}
if (text != null && !cm.locked) {
- SheetRow(LucideIcons.Pencil, "Edit comment", {
+ SheetRow(LucideIcons.Pencil, stringResource(R.string.comments_edit), {
menuFor = null
vm.selectedComment = doc to cm
})
}
if (!cm.locked) {
- SheetRow(LucideIcons.Trash2, "Delete", {
+ SheetRow(LucideIcons.Trash2, stringResource(R.string.common_delete), {
menuFor = null
vm.deleteComment(doc, cm)
})
@@ -284,13 +285,13 @@ internal fun CommentRow(
Row(Modifier.padding(top = 8.dp), verticalAlignment = Alignment.Top) {
Column(Modifier.weight(1f)) {
Text(
- cm.author?.takeIf { it.isNotBlank() } ?: "Guest", color = c.label, fontSize = 16.sp, fontWeight = FontWeight.SemiBold,
+ cm.author?.takeIf { it.isNotBlank() } ?: stringResource(R.string.comments_guest), color = c.label, fontSize = 16.sp, fontWeight = FontWeight.SemiBold,
maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.widthIn(max = 200.dp),
)
- commentDateLabel(cm.modified)?.let { Text(it, color = c.textTertiary, fontSize = 16.sp) }
+ commentDateLabel(cm.modified, stringResource(R.string.common_today), stringResource(R.string.common_yesterday))?.let { Text(it, color = c.textTertiary, fontSize = 16.sp) }
}
Box {
- BarIcon(LucideIcons.EllipsisVertical, "Comment options", onMenu, size = 40.dp)
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.comments_options), onMenu, size = 40.dp)
menu()
}
}
@@ -323,7 +324,7 @@ internal fun CommentRow(
}
if (actionLine) {
Text(
- commentActionLabel(cm), color = c.icon, fontSize = 14.5.sp, fontStyle = FontStyle.Italic,
+ stringResource(commentActionLabel(cm)), color = c.icon, fontSize = 14.5.sp, fontStyle = FontStyle.Italic,
modifier = Modifier.padding(top = if (hasSnippet) 8.dp else 12.dp),
)
}
@@ -334,7 +335,7 @@ internal fun CommentRow(
Spacer(Modifier.height(if (replyLink) 16.dp else if (lastOnPage) 12.dp else 8.dp))
if (replyLink) {
Text(
- "Reply", color = c.toolAccent, fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
+ stringResource(R.string.comments_reply), color = c.toolAccent, fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
modifier = Modifier.offset(x = (-8).dp).heightIn(min = 40.dp).clip(RoundedCornerShape(4.dp))
.clickable(role = Role.Button, onClick = onReply).padding(horizontal = 8.dp, vertical = 10.dp),
)
@@ -348,7 +349,8 @@ internal fun CommentRow(
/** The guest avatar: a lilac disc, its lower right a shade darker. */
@Composable
private fun Avatar(modifier: Modifier) {
- Canvas(modifier.size(32.dp).semantics { contentDescription = "Avatar" }) {
+ val description = stringResource(R.string.comments_avatar)
+ Canvas(modifier.size(32.dp).semantics { contentDescription = description }) {
val base = Color(0xFF9B80FF)
drawCircle(base)
val shade = Path().apply {
@@ -374,9 +376,9 @@ private fun EmptyComments() {
) {
Icon(LucideIcons.MessagesSquare, null, tint = c.textSecondary, modifier = Modifier.size(64.dp))
Spacer(Modifier.height(24.dp))
- Text("Get started", color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
+ Text(stringResource(R.string.comments_empty_title), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
Spacer(Modifier.height(8.dp))
- Text("Comments you add with the commenting tools show up here.", color = c.textSecondary, fontSize = 17.sp, textAlign = TextAlign.Center)
+ Text(stringResource(R.string.comments_empty_body), color = c.textSecondary, fontSize = 17.sp, textAlign = TextAlign.Center)
Spacer(Modifier.height(80.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt
index eee462f..408da35 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/CommentPanel.kt
@@ -37,10 +37,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.CommentInfo
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
@@ -101,15 +103,15 @@ fun CommentPanel(vm: AppViewModel, doc: OpenDocument, c: CommentInfo) {
// the navigator, and the colour button at the right
Box(Modifier.fillMaxWidth().height(40.dp)) {
Row(Modifier.align(Alignment.Center), verticalAlignment = Alignment.CenterVertically) {
- BarIcon(LucideIcons.ChevronLeft, "Previous comment", { threads.getOrNull(position - 1)?.let(::go) }, size = 40.dp, enabled = position > 0)
+ BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.comments_previous), { threads.getOrNull(position - 1)?.let(::go) }, size = 40.dp, enabled = position > 0)
Spacer(Modifier.width(2.dp))
Text(
- if (position >= 0) "${position + 1} of ${threads.size}" else "1 of ${threads.size + 1}",
+ if (position >= 0) stringResource(R.string.comments_position, position + 1, threads.size) else stringResource(R.string.comments_position, 1, threads.size + 1),
color = colors.navigatorText, fontSize = 15.sp, modifier = Modifier.widthIn(min = 42.dp),
textAlign = androidx.compose.ui.text.style.TextAlign.Center,
)
Spacer(Modifier.width(2.dp))
- BarIcon(LucideIcons.ChevronRight, "Next comment", { threads.getOrNull(position + 1)?.let(::go) }, size = 40.dp, enabled = position in 0 until threads.size - 1)
+ BarIcon(LucideIcons.ChevronRight, stringResource(R.string.comments_next), { threads.getOrNull(position + 1)?.let(::go) }, size = 40.dp, enabled = position in 0 until threads.size - 1)
}
// a note has no property buttons; other comments get their colour here
if (canEdit && c.color != null && c.subtype != "Text" && c.subtype != "Sound") {
@@ -136,11 +138,11 @@ fun CommentPanel(vm: AppViewModel, doc: OpenDocument, c: CommentInfo) {
kotlinx.coroutines.delay(300)
vm.styleComment(doc, c, mapOf("opacity" to opacity.toDouble()))
}
- Text("Opacity", color = colors.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 78.dp, top = 16.dp, bottom = 8.dp))
+ Text(stringResource(R.string.comments_opacity), color = colors.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 78.dp, top = 16.dp, bottom = 8.dp))
OpacitySlider(shown, opacity) { opacity = it }
}
if (c.width != null && c.subtype in LineComments) {
- Text("Line thickness", color = colors.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 16.dp, bottom = 8.dp))
+ Text(stringResource(R.string.comments_line_thickness), color = colors.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 16.dp, bottom = 8.dp))
InkWidthRow(shown, InkWidths.minByOrNull { kotlin.math.abs(it - (c.width ?: 0f)) }) { vm.styleComment(doc, c, mapOf("width" to it.toDouble())) }
}
Spacer(Modifier.height(8.dp))
@@ -156,8 +158,8 @@ fun CommentPanel(vm: AppViewModel, doc: OpenDocument, c: CommentInfo) {
)
Row {
Spacer(Modifier.weight(1f))
- TextButton(onClick = { editing = null }) { Text("Cancel", color = colors.toolAccent) }
- TextButton(onClick = { editing = null; vm.editCommentText(doc, cm, text) }) { Text("Save", color = colors.toolAccent, fontWeight = FontWeight.SemiBold) }
+ TextButton(onClick = { editing = null }) { Text(stringResource(R.string.common_cancel), color = colors.toolAccent) }
+ TextButton(onClick = { editing = null; vm.editCommentText(doc, cm, text) }) { Text(stringResource(R.string.common_save), color = colors.toolAccent, fontWeight = FontWeight.SemiBold) }
}
}
} else {
@@ -179,19 +181,19 @@ fun CommentPanel(vm: AppViewModel, doc: OpenDocument, c: CommentInfo) {
val text = cm.contents?.takeIf { it.isNotBlank() }
if (text != null) {
DropdownMenuItem(
- text = { Text("Copy text", color = colors.text) },
+ text = { Text(stringResource(R.string.comments_copy_text), color = colors.text) },
leadingIcon = { Icon(LucideIcons.Copy, null, tint = colors.icon) },
onClick = { menuFor = null; vm.copyText(text) },
)
}
if (!cm.locked && doc.info.allowsAnnotation) {
DropdownMenuItem(
- text = { Text(if (text == null && i == 0) "Add comment" else "Edit comment", color = colors.text) },
+ text = { Text(stringResource(if (text == null && i == 0) R.string.comments_add else R.string.comments_edit), color = colors.text) },
leadingIcon = { Icon(LucideIcons.Pencil, null, tint = colors.icon) },
onClick = { menuFor = null; editing = cm },
)
DropdownMenuItem(
- text = { Text("Delete", color = colors.text) },
+ text = { Text(stringResource(R.string.common_delete), color = colors.text) },
leadingIcon = { Icon(LucideIcons.Trash2, null, tint = colors.icon) },
onClick = { menuFor = null; vm.deleteComment(doc, cm) },
)
@@ -217,14 +219,14 @@ fun CommentPanel(vm: AppViewModel, doc: OpenDocument, c: CommentInfo) {
modifier = Modifier.weight(1f).padding(vertical = 10.dp),
decorationBox = { inner ->
Box {
- if (reply.isEmpty()) Text("Reply", color = colors.replyBorder, fontSize = 16.sp)
+ if (reply.isEmpty()) Text(stringResource(R.string.comments_reply_hint), color = colors.replyBorder, fontSize = 16.sp)
inner()
}
},
)
if (reply.isNotEmpty()) {
Box(Modifier.padding(horizontal = 4.dp).size(width = 1.dp, height = 21.dp).background(colors.divider))
- BarIcon(LucideIcons.Send, "Post", { vm.postReply(ReplyPrompt(doc, c), reply); reply = "" }, size = 40.dp, enabled = reply.isNotBlank(), tint = colors.toolAccent)
+ BarIcon(LucideIcons.Send, stringResource(R.string.common_post), { vm.postReply(ReplyPrompt(doc, c), reply); reply = "" }, size = 40.dp, enabled = reply.isNotBlank(), tint = colors.toolAccent)
}
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt
index ca99274..1568583 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/DigitalSign.kt
@@ -1,5 +1,6 @@
package io.github.artcraftandroid.pdfcraft.ui.viewer
+import androidx.annotation.StringRes
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -40,6 +41,7 @@ import androidx.compose.ui.graphics.PathEffect
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
@@ -47,7 +49,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.engine.DigitalId
+import io.github.artcraftandroid.pdfcraft.text as appText
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -132,17 +136,17 @@ fun parseSignatures(o: JSONObject): List<SignatureEntry> {
class CertTarget(val doc: OpenDocument, val field: String?, val page: Int, val rect: FloatArray?)
/** What a digital signature shows on the page beside the signer's details. */
-enum class CertLook(val label: String) { Name("Name only"), Typed("Typed name"), Drawn("My signature") }
+enum class CertLook(@StringRes val label: Int) { Name(R.string.sign_look_name), Typed(R.string.sign_look_typed), Drawn(R.string.sign_look_drawn) }
/** A digital ID file picked to add, waiting for its password ([wrong]: the last one didn't open it). */
class IdImport(val file: java.io.File, val name: String, val wrong: Boolean)
/** A signature's status in a few words, for the list and the message on opening. */
fun SignatureEntry.statusLabel(): String = when {
- !signed -> "Not signed yet"
- status == "valid" -> "Valid"
- status == "invalid" -> "Invalid"
- else -> "Signer not verified"
+ !signed -> appText(R.string.sign_status_unsigned)
+ status == "valid" -> appText(R.string.sign_status_valid)
+ status == "invalid" -> appText(R.string.sign_status_invalid)
+ else -> appText(R.string.sign_status_unknown)
}
private val ValidGreen = Color(0xFF12805C)
@@ -210,8 +214,8 @@ fun CertPlaceLayer(vm: AppViewModel, doc: OpenDocument) {
.clip(RoundedCornerShape(8.dp)).background(c.surface).padding(start = 16.dp, end = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- Text("Drag a box where the signature goes", color = c.text, fontSize = 14.sp, modifier = Modifier.weight(1f, fill = false))
- TextButton(onClick = { vm.certPlacing = null }) { Text("Cancel", color = c.accent) }
+ Text(stringResource(R.string.sign_place_hint), color = c.text, fontSize = 14.sp, modifier = Modifier.weight(1f, fill = false))
+ TextButton(onClick = { vm.certPlacing = null }) { Text(stringResource(R.string.common_cancel), color = c.accent) }
}
}
}
@@ -250,53 +254,53 @@ fun CertSignScreen(vm: AppViewModel, target: CertTarget) {
}
Column(Modifier.fillMaxSize().background(c.surface).pointerInput(Unit) { detectTapGestures() }.safeTopPadding().navigationBarsPadding().imePadding()) {
Row(Modifier.fillMaxWidth().height(56.dp).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- TextButton(onClick = { vm.certSign = null }) { Text("Cancel", color = c.accent) }
- Text("Sign with a digital ID", color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 17.sp, modifier = Modifier.weight(1f), textAlign = TextAlign.Center, maxLines = 1, overflow = TextOverflow.Ellipsis)
- TextButton(onClick = ::sign, enabled = canSign) { Text("Sign", color = if (canSign) c.accent else c.textSecondary, fontWeight = FontWeight.SemiBold) }
+ TextButton(onClick = { vm.certSign = null }) { Text(stringResource(R.string.common_cancel), color = c.accent) }
+ Text(stringResource(R.string.common_tool_sign_digital_id), color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 17.sp, modifier = Modifier.weight(1f), textAlign = TextAlign.Center, maxLines = 1, overflow = TextOverflow.Ellipsis)
+ TextButton(onClick = ::sign, enabled = canSign) { Text(stringResource(R.string.common_sign), color = if (canSign) c.accent else c.textSecondary, fontWeight = FontWeight.SemiBold) }
}
SheetDivider(inset = 0.dp)
Column(Modifier.weight(1f).verticalScroll(rememberScrollState()).padding(vertical = 8.dp)) {
- Section("Digital ID")
+ Section(stringResource(R.string.sign_section_id))
if (ids.isEmpty()) {
Text(
- "You don't have a digital ID yet. Add the .p12 or .pfx file you were given, or create one for yourself.",
+ stringResource(R.string.sign_no_id),
color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 4.dp),
)
}
for (id in ids) IdRow(vm, id, selected = id == chosen) { vm.chosenId = id }
- SheetRow(LucideIcons.FolderOpen, "Add a digital ID file", { vm.pickDigitalId() })
- SheetRow(LucideIcons.Plus, "Create a digital ID", { vm.idCreate = true })
+ SheetRow(LucideIcons.FolderOpen, stringResource(R.string.sign_add_id_file), { vm.pickDigitalId() })
+ SheetRow(LucideIcons.Plus, stringResource(R.string.sign_create_id), { vm.idCreate = true })
SheetDivider(vertical = 6.dp)
- Section("Appearance")
+ Section(stringResource(R.string.sign_section_appearance))
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
for (l in CertLook.entries) {
val enabled = l != CertLook.Drawn || hasDrawn
- Chip(l.label, look == l, enabled) { look = l }
+ Chip(stringResource(l.label), look == l, enabled) { look = l }
}
}
Text(
when (look) {
- CertLook.Name -> "Your name and the date in the box."
- CertLook.Typed -> "Your name in a script font, with your name and the date beside it."
- CertLook.Drawn -> if (hasDrawn) "Your saved Fill & Sign signature, with your name and the date beside it." else "Make a signature in Fill & Sign first."
+ CertLook.Name -> stringResource(R.string.sign_look_name_about)
+ CertLook.Typed -> stringResource(R.string.sign_look_typed_about)
+ CertLook.Drawn -> stringResource(if (hasDrawn) R.string.sign_look_drawn_about else R.string.sign_look_drawn_missing)
},
color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp),
)
SheetDivider(vertical = 6.dp)
- Section("Reason (optional)")
- Box(Modifier.padding(horizontal = 16.dp)) { PdfField(reason, { reason = it }, "For example: I approve this document", keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)) }
+ Section(stringResource(R.string.sign_section_reason))
+ Box(Modifier.padding(horizontal = 16.dp)) { PdfField(reason, { reason = it }, stringResource(R.string.sign_reason_hint), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)) }
Spacer(Modifier.height(12.dp))
- Section("Location (optional)")
- Box(Modifier.padding(horizontal = 16.dp)) { PdfField(location, { location = it }, "City or place", keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)) }
+ Section(stringResource(R.string.sign_section_location))
+ Box(Modifier.padding(horizontal = 16.dp)) { PdfField(location, { location = it }, stringResource(R.string.sign_location_hint), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)) }
Spacer(Modifier.height(12.dp))
if (chosen != null) {
- Section("Password for ${chosen.name}")
+ Section(stringResource(R.string.sign_section_password, chosen.name))
Box(Modifier.padding(horizontal = 16.dp)) {
PdfField(
- password, { password = it; vm.certSignError = null }, "Digital ID password", password = true, error = vm.certSignError != null,
+ password, { password = it; vm.certSignError = null }, stringResource(R.string.sign_id_password), password = true, error = vm.certSignError != null,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
keyboardActions = androidx.compose.foundation.text.KeyboardActions(onDone = { sign() }),
)
@@ -304,7 +308,7 @@ fun CertSignScreen(vm: AppViewModel, target: CertTarget) {
}
(vm.certSignError ?: unusable)?.let { Text(it, color = c.red, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp)) }
Text(
- "Signing saves the document. Anyone who opens it can check that it hasn't changed since; changes made after signing are listed with the signature.",
+ stringResource(R.string.sign_saves_note),
color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),
)
}
@@ -322,8 +326,8 @@ internal fun readableName(dn: String): String {
/** Why [id] can't sign now, if it can't. */
private fun idProblem(id: DigitalId): String? = when {
- id.expired() -> "This digital ID expired on ${shortDate(id.validTo * 1000)}."
- id.notYetValid() -> "This digital ID isn't valid until ${shortDate(id.validFrom * 1000)}."
+ id.expired() -> appText(R.string.sign_id_expired, shortDate(id.validTo * 1000))
+ id.notYetValid() -> appText(R.string.sign_id_not_yet_valid, shortDate(id.validFrom * 1000))
else -> null
}
@@ -365,17 +369,17 @@ private fun IdRow(vm: AppViewModel, id: DigitalId, selected: Boolean, onClick: (
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f).padding(vertical = 8.dp)) {
Text(id.name, color = c.text, fontSize = 16.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
- val by = if (id.selfSigned) "Self-signed" else "Issued by ${readableName(id.issuer)}"
- val until = idProblem(id) ?: "Valid until ${shortDate(id.validTo * 1000)}"
+ val by = if (id.selfSigned) stringResource(R.string.sign_id_self_signed) else stringResource(R.string.sign_id_issued_by, readableName(id.issuer))
+ val until = idProblem(id) ?: stringResource(R.string.sign_id_valid_until, shortDate(id.validTo * 1000))
Text("$by · $until", color = if (idProblem(id) != null) c.red else c.textSecondary, fontSize = 13.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
- BarIcon(LucideIcons.Trash2, "Remove ${id.name}'s digital ID", { confirm = true }, size = 40.dp)
+ BarIcon(LucideIcons.Trash2, stringResource(R.string.sign_remove_id_description, id.name), { confirm = true }, size = 40.dp)
}
if (confirm) {
PdfDialog(
- onDismiss = { confirm = false }, title = "Remove digital ID?", confirm = "Remove", destructive = true,
+ onDismiss = { confirm = false }, title = stringResource(R.string.sign_remove_id_title), confirm = stringResource(R.string.sign_remove), destructive = true,
onConfirm = { confirm = false; vm.removeDigitalId(id) },
- ) { Text("${id.name}'s digital ID is removed from PdfCraft. Documents already signed with it keep their signatures.", color = c.text, fontSize = 14.sp) }
+ ) { Text(stringResource(R.string.sign_remove_id_message, id.name), color = c.text, fontSize = 14.sp) }
}
}
@@ -386,15 +390,15 @@ fun IdPasswordDialog(vm: AppViewModel, imp: IdImport) {
var pw by remember(imp) { mutableStateOf("") }
val focus = remember { androidx.compose.ui.focus.FocusRequester() }
androidx.compose.runtime.LaunchedEffect(imp) { runCatching { focus.requestFocus() } }
- PdfDialog(onDismiss = { vm.answerIdImport(null) }, title = "Digital ID password", confirm = "Add", onConfirm = { vm.answerIdImport(pw) }) {
- Text("Enter the password that protects ${imp.name}.", color = c.text, fontSize = 14.sp)
+ PdfDialog(onDismiss = { vm.answerIdImport(null) }, title = stringResource(R.string.sign_id_password), confirm = stringResource(R.string.sign_add), onConfirm = { vm.answerIdImport(pw) }) {
+ Text(stringResource(R.string.sign_id_password_prompt, imp.name), color = c.text, fontSize = 14.sp)
Spacer(Modifier.height(14.dp))
PdfField(
- pw, { pw = it }, "Password", error = imp.wrong, password = true, focus = focus,
+ pw, { pw = it }, stringResource(R.string.common_password), error = imp.wrong, password = true, focus = focus,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done),
keyboardActions = androidx.compose.foundation.text.KeyboardActions(onDone = { vm.answerIdImport(pw) }),
)
- if (imp.wrong) Text("The password is incorrect.", color = c.red, fontSize = 13.sp, modifier = Modifier.padding(top = 8.dp))
+ if (imp.wrong) Text(stringResource(R.string.common_wrong_password), color = c.red, fontSize = 13.sp, modifier = Modifier.padding(top = 8.dp))
}
}
@@ -410,43 +414,42 @@ fun CreateIdScreen(vm: AppViewModel) {
var again by remember { mutableStateOf("") }
val problem = when {
name.isBlank() -> null
- password.isNotEmpty() && password.length < 6 -> "The password needs at least 6 characters."
- again.isNotEmpty() && again != password -> "The passwords don't match."
+ password.isNotEmpty() && password.length < 6 -> stringResource(R.string.sign_password_short)
+ again.isNotEmpty() && again != password -> stringResource(R.string.sign_password_mismatch)
else -> null
}
val ok = name.isNotBlank() && password.length >= 6 && again == password
Column(Modifier.fillMaxSize().background(c.surface).pointerInput(Unit) { detectTapGestures() }.safeTopPadding().navigationBarsPadding().imePadding()) {
Row(Modifier.fillMaxWidth().height(56.dp).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- TextButton(onClick = { vm.idCreate = false }) { Text("Cancel", color = c.accent) }
- Text("Create a digital ID", color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 17.sp, modifier = Modifier.weight(1f), textAlign = TextAlign.Center)
+ TextButton(onClick = { vm.idCreate = false }) { Text(stringResource(R.string.common_cancel), color = c.accent) }
+ Text(stringResource(R.string.sign_create_id), color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 17.sp, modifier = Modifier.weight(1f), textAlign = TextAlign.Center)
TextButton(onClick = { vm.createDigitalId(name, email, organization, password) }, enabled = ok) {
- Text("Create", color = if (ok) c.accent else c.textSecondary, fontWeight = FontWeight.SemiBold)
+ Text(stringResource(R.string.common_create), color = if (ok) c.accent else c.textSecondary, fontWeight = FontWeight.SemiBold)
}
}
SheetDivider(inset = 0.dp)
Column(Modifier.weight(1f).verticalScroll(rememberScrollState()).padding(vertical = 8.dp)) {
Text(
- "A digital ID made here is self-signed: a document you sign with it shows any change made after you signed, but nobody else vouches that it's you. " +
- "For that, use the ID file an organisation or a certificate authority gives you.",
+ stringResource(R.string.sign_create_about),
color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp),
)
- Section("Name")
- Box(Modifier.padding(horizontal = 16.dp)) { PdfField(name, { name = it }, "Your name") }
- Section("Email (optional)")
- Box(Modifier.padding(horizontal = 16.dp)) { PdfField(email, { email = it }, "[email protected]", keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email)) }
- Section("Organisation (optional)")
- Box(Modifier.padding(horizontal = 16.dp)) { PdfField(organization, { organization = it }, "Company or organisation") }
- Section("Password")
+ Section(stringResource(R.string.sign_section_name))
+ Box(Modifier.padding(horizontal = 16.dp)) { PdfField(name, { name = it }, stringResource(R.string.common_your_name)) }
+ Section(stringResource(R.string.sign_section_email))
+ Box(Modifier.padding(horizontal = 16.dp)) { PdfField(email, { email = it }, stringResource(R.string.sign_email_hint), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email)) }
+ Section(stringResource(R.string.sign_section_organisation))
+ Box(Modifier.padding(horizontal = 16.dp)) { PdfField(organization, { organization = it }, stringResource(R.string.sign_organisation_hint)) }
+ Section(stringResource(R.string.common_password))
Box(Modifier.padding(horizontal = 16.dp)) {
- PdfField(password, { password = it }, "At least 6 characters", password = true, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password))
+ PdfField(password, { password = it }, stringResource(R.string.sign_password_hint), password = true, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password))
}
Spacer(Modifier.height(10.dp))
Box(Modifier.padding(horizontal = 16.dp)) {
- PdfField(again, { again = it }, "The password again", password = true, error = again.isNotEmpty() && again != password, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done))
+ PdfField(again, { again = it }, stringResource(R.string.sign_password_again), password = true, error = again.isNotEmpty() && again != password, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Done))
}
problem?.let { Text(it, color = c.red, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp)) }
Text(
- "PdfCraft doesn't keep the password and can't recover it: you type it each time you sign.",
+ stringResource(R.string.sign_password_note),
color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),
)
}
@@ -457,8 +460,8 @@ fun CreateIdScreen(vm: AppViewModel) {
@Composable
fun SignFieldChoiceDialog(vm: AppViewModel, doc: OpenDocument, field: io.github.artcraftandroid.pdfcraft.core.WidgetInfo) {
PdfDialog(onDismiss = { vm.signFieldChoice = null }, title = null, confirm = null, dismiss = null, list = true) {
- SheetRow(LucideIcons.Signature, "Add your signature", { vm.signFieldChoice = null; vm.drawSignatureInField(doc, field) })
- SheetRow(LucideIcons.ShieldCheck, "Sign with a digital ID", { vm.signFieldChoice = null; vm.signFieldWithId(doc, field) })
+ SheetRow(LucideIcons.Signature, stringResource(R.string.sign_add_your_signature), { vm.signFieldChoice = null; vm.drawSignatureInField(doc, field) })
+ SheetRow(LucideIcons.ShieldCheck, stringResource(R.string.common_tool_sign_digital_id), { vm.signFieldChoice = null; vm.signFieldWithId(doc, field) })
}
}
@@ -478,11 +481,11 @@ fun SignaturesSheet(vm: AppViewModel, doc: OpenDocument) {
vm.trustedCerts.version
var open by remember { mutableStateOf<String?>(null) }
PdfSheet(onDismiss = ::close, maxHeightFraction = 0.85f) {
- SheetTitle("Signatures")
+ SheetTitle(stringResource(R.string.sign_signatures))
Column(Modifier.verticalScroll(rememberScrollState())) {
val list = doc.signatures
if (list.isEmpty()) {
- Text("This document has no signatures.", color = c.textSecondary, fontSize = 15.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp))
+ Text(stringResource(R.string.sign_none), color = c.textSecondary, fontSize = 15.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp))
}
for (s in list) {
val (icon, tint) = statusIcon(s)
@@ -493,12 +496,12 @@ fun SignaturesSheet(vm: AppViewModel, doc: OpenDocument) {
Icon(icon, null, tint = tint, modifier = Modifier.padding(top = 2.dp).size(24.dp))
Spacer(Modifier.width(12.dp))
Column(Modifier.weight(1f)) {
- Text(if (s.signed) s.signer ?: "Unknown signer" else "Empty signature field", color = c.text, fontSize = 16.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
+ Text(if (s.signed) s.signer ?: stringResource(R.string.sign_unknown_signer) else stringResource(R.string.sign_empty_field), color = c.text, fontSize = 16.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
val sub = listOfNotNull(
s.statusLabel(),
- if (s.certify != null && s.signed) "Certified" else null,
+ if (s.certify != null && s.signed) stringResource(R.string.sign_certified) else null,
pdfDateLabel(s.date),
- s.page?.let { "Page ${it + 1}" }.takeIf { !s.signed },
+ s.page?.let { stringResource(R.string.sheet_page, it + 1) }.takeIf { !s.signed },
).joinToString(" · ")
Text(sub, color = if (s.status == "invalid") c.red else c.textSecondary, fontSize = 13.sp)
if (open == s.field) SignatureDetails(vm, doc, s)
@@ -507,7 +510,7 @@ fun SignaturesSheet(vm: AppViewModel, doc: OpenDocument) {
}
SheetDivider()
}
- SheetRow(LucideIcons.ShieldCheck, "Add a digital signature", { close(); vm.startCertPlacing(doc) })
+ SheetRow(LucideIcons.ShieldCheck, stringResource(R.string.sign_add_signature), { close(); vm.startCertPlacing(doc) })
Spacer(Modifier.height(8.dp))
}
}
@@ -517,50 +520,64 @@ fun SignaturesSheet(vm: AppViewModel, doc: OpenDocument) {
private fun SignatureDetails(vm: AppViewModel, doc: OpenDocument, s: SignatureEntry) {
val c = pdfColors
@Composable
- fun line(label: String, value: String?) {
+ fun line(text: String) {
+ Text(text, color = c.text, fontSize = 14.sp, modifier = Modifier.padding(top = 6.dp))
+ }
+ /** The line [format] fills with [value], when there is a value. */
+ @Composable
+ fun detail(@StringRes format: Int, value: String?) {
if (value.isNullOrBlank()) return
- Text("$label: $value", color = c.text, fontSize = 14.sp, modifier = Modifier.padding(top = 6.dp))
+ line(stringResource(format, value))
}
Column(Modifier.padding(top = 4.dp)) {
if (s.signed) {
- line("Reason", s.reason)
- line("Location", s.location)
+ detail(R.string.sign_detail_reason, s.reason)
+ detail(R.string.sign_detail_location, s.location)
s.cert?.let { cert ->
- line("Certificate", if (cert.selfSigned) "self-signed" else "issued by ${readableName(cert.issuer)}")
- line("Valid until", pdfDateLabel(cert.validTo))
+ line(if (cert.selfSigned) stringResource(R.string.sign_detail_cert_self_signed) else stringResource(R.string.sign_detail_cert_issued_by, readableName(cert.issuer)))
+ detail(R.string.sign_detail_valid_until, pdfDateLabel(cert.validTo))
}
s.certify?.let {
- line("Certified", when (it) { 1 -> "no changes allowed"; 2 -> "form filling allowed"; else -> "form filling and comments allowed" })
+ line(
+ stringResource(
+ when (it) {
+ 1 -> R.string.sign_detail_certified_no_changes
+ 2 -> R.string.sign_detail_certified_forms
+ else -> R.string.sign_detail_certified_comments
+ },
+ ),
+ )
}
+ // the changes are the engine's own words, listed as it gives them
+ val changes = s.changes.joinToString("; ")
line(
- "Changes since signing",
when (s.modification) {
- "none" -> "none"
- "allowed" -> "allowed ones" + if (s.changes.isEmpty()) "" else " (${s.changes.joinToString("; ")})"
- else -> "some that aren't allowed" + if (s.changes.isEmpty()) "" else " (${s.changes.joinToString("; ")})"
+ "none" -> stringResource(R.string.sign_detail_changes_none)
+ "allowed" -> if (s.changes.isEmpty()) stringResource(R.string.sign_detail_changes_allowed) else stringResource(R.string.sign_detail_changes_allowed_list, changes)
+ else -> if (s.changes.isEmpty()) stringResource(R.string.sign_detail_changes_disallowed) else stringResource(R.string.sign_detail_changes_disallowed_list, changes)
},
)
for (d in s.details) Text("• $d", color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(top = 6.dp))
} else {
- Text("Nobody has signed this field yet.", color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(top = 6.dp))
+ Text(stringResource(R.string.sign_field_unsigned), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(top = 6.dp))
}
Row(Modifier.padding(top = 4.dp), horizontalArrangement = Arrangement.spacedBy(4.dp)) {
if (s.page != null && s.rect != null) {
- TextButton(onClick = { doc.controller.sheet = ViewerSheet.None; vm.showSignature(doc, s) }) { Text("Go to it", color = c.accent) }
+ TextButton(onClick = { doc.controller.sheet = ViewerSheet.None; vm.showSignature(doc, s) }) { Text(stringResource(R.string.sign_go_to), color = c.accent) }
}
val sha = s.cert?.sha256
if (s.signed && sha != null) {
if (vm.trustedCerts.contains(sha)) {
- TextButton(onClick = { vm.untrustSigner(doc, s) }) { Text("Stop trusting", color = c.accent) }
+ TextButton(onClick = { vm.untrustSigner(doc, s) }) { Text(stringResource(R.string.sign_stop_trusting), color = c.accent) }
} else if (s.status == "unknown") {
- TextButton(onClick = { vm.trustSigner(doc, s) }) { Text("Trust this signer", color = c.accent) }
+ TextButton(onClick = { vm.trustSigner(doc, s) }) { Text(stringResource(R.string.sign_trust), color = c.accent) }
}
}
if (!s.signed) {
TextButton(onClick = {
doc.controller.sheet = ViewerSheet.None
doc.widgets.firstOrNull { it.field == s.field }?.let { vm.signFieldWithId(doc, it) }
- }) { Text("Sign", color = c.accent) }
+ }) { Text(stringResource(R.string.common_sign), color = c.accent) }
}
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt
index 0f481ab..aa7a628 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Edit.kt
@@ -71,6 +71,8 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.compose.ui.res.stringResource
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
@@ -101,8 +103,9 @@ private val SelectionBlue = Color(0xFF448AFF)
/** The text colours Edit PDF offers, in the reference's order. */
private val EditColors = listOf(
- "#ff0000" to "Red", "#ffff00" to "Yellow", "#0000ff" to "Blue", "#00ff00" to "Light green", "#9900ff" to "Purple",
- "#00ffff" to "Cyan", "#009900" to "Green", "#ffffff" to "White", "#000000" to "Black",
+ "#ff0000" to R.string.prefs_color_red, "#ffff00" to R.string.prefs_color_yellow, "#0000ff" to R.string.prefs_color_blue,
+ "#00ff00" to R.string.prefs_color_light_green, "#9900ff" to R.string.prefs_color_purple, "#00ffff" to R.string.prefs_color_cyan,
+ "#009900" to R.string.prefs_color_green, "#ffffff" to R.string.prefs_color_white, "#000000" to R.string.prefs_color_black,
)
/** Which formatting panel is open over the bar. */
@@ -127,19 +130,21 @@ private fun EditToolsBar(vm: AppViewModel, doc: OpenDocument) {
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
- EditBarItem(LucideIcons.LayoutGrid, "Organize pages", false, 96.dp) {
+ val textHint = stringResource(R.string.edit_tap_for_text)
+ val imageHint = stringResource(R.string.edit_tap_for_image)
+ EditBarItem(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_organize), false, 96.dp) {
vm.organizing = true
doc.controller.pagesOpen = true
}
BarDividerLine()
- EditBarItem(LucideIcons.Type, "Add text", vm.editMode == EditMode.AddText, 70.dp) {
+ EditBarItem(LucideIcons.Type, stringResource(R.string.edit_add_text), vm.editMode == EditMode.AddText, 70.dp) {
vm.editMode = if (vm.editMode == EditMode.AddText) EditMode.Select else EditMode.AddText
- if (vm.editMode == EditMode.AddText) vm.tell("Tap the page where the text should go")
+ if (vm.editMode == EditMode.AddText) vm.tell(textHint)
}
// as Add text: a mode, then a tap places the picture there
- EditBarItem(LucideIcons.ImagePlus, "Add image", vm.editMode == EditMode.AddImage, 78.dp) {
+ EditBarItem(LucideIcons.ImagePlus, stringResource(R.string.edit_add_image), vm.editMode == EditMode.AddImage, 78.dp) {
vm.editMode = if (vm.editMode == EditMode.AddImage) EditMode.Select else EditMode.AddImage
- if (vm.editMode == EditMode.AddImage) vm.tell("Tap the page where the picture should go")
+ if (vm.editMode == EditMode.AddImage) vm.tell(imageHint)
}
}
}
@@ -192,19 +197,21 @@ private fun EditFormatBar(vm: AppViewModel, doc: OpenDocument, para: Paragraph)
) {
val underline = vm.editUnderline[para.page to para.number] == true
// the reference draws these as serif T's: heavy, slanted, underlined, and a small t beside a big one
- LetterButton("T", "Bold", para.bold, weight = FontWeight.Black) { vm.styleParagraph(doc, para, mapOf("bold" to !para.bold)) }
- LetterButton("T", "Italic", para.italic, italic = true) { vm.styleParagraph(doc, para, mapOf("italic" to !para.italic)) }
- LetterButton("T", "Underline", underline, underline = true) {
+ LetterButton("T", stringResource(R.string.edit_bold), para.bold, weight = FontWeight.Black) { vm.styleParagraph(doc, para, mapOf("bold" to !para.bold)) }
+ LetterButton("T", stringResource(R.string.edit_italic), para.italic, italic = true) { vm.styleParagraph(doc, para, mapOf("italic" to !para.italic)) }
+ LetterButton("T", stringResource(R.string.edit_underline), underline, underline = true) {
vm.editUnderline[para.page to para.number] = !underline
vm.styleParagraph(doc, para, mapOf("underline" to !underline))
}
- LetterButton("tT", "Text size", panel == FormatPanel.Size, small = true) { toggle(FormatPanel.Size) }
+ LetterButton("tT", stringResource(R.string.edit_text_size), panel == FormatPanel.Size, small = true) { toggle(FormatPanel.Size) }
+ val fontLabel = stringResource(R.string.edit_font)
Box(
- Modifier.size(44.dp).clickable(role = Role.Button) { toggle(FormatPanel.Font) }.semantics { contentDescription = "Font" },
+ Modifier.size(44.dp).clickable(role = Role.Button) { toggle(FormatPanel.Font) }.semantics { contentDescription = fontLabel },
contentAlignment = Alignment.Center,
) { Text("Ag", color = if (panel == FormatPanel.Font) c.toolAccent else c.icon, fontSize = 20.sp, fontFamily = FontFamily.Serif) }
+ val colourLabel = stringResource(R.string.edit_colour)
Box(
- Modifier.size(44.dp).clickable(role = Role.Button) { toggle(FormatPanel.Color) }.semantics { contentDescription = "Colour" },
+ Modifier.size(44.dp).clickable(role = Role.Button) { toggle(FormatPanel.Color) }.semantics { contentDescription = colourLabel },
contentAlignment = Alignment.Center,
) {
Box(
@@ -212,9 +219,9 @@ private fun EditFormatBar(vm: AppViewModel, doc: OpenDocument, para: Paragraph)
.then(if (panel == FormatPanel.Color) Modifier.drawBehind { drawCircle(c.toolAccent, size.minDimension / 2 + 3.dp.toPx(), style = Stroke(2.dp.toPx())) } else Modifier),
)
}
- FormatButton(alignIcon(vm.editAlign[para.page to para.number] ?: "left"), "Align text", true, tintSelected = panel == FormatPanel.Align || true) { toggle(FormatPanel.Align) }
+ FormatButton(alignIcon(vm.editAlign[para.page to para.number] ?: "left"), stringResource(R.string.edit_align_text), true, tintSelected = panel == FormatPanel.Align || true) { toggle(FormatPanel.Align) }
// bulleted and numbered lists, as the reference's phone toolbar offers
- FormatButton(LucideIcons.List, "List", true, tintSelected = true) { toggle(FormatPanel.List) }
+ FormatButton(LucideIcons.List, stringResource(R.string.edit_list), true, tintSelected = true) { toggle(FormatPanel.List) }
}
}
}
@@ -257,7 +264,7 @@ private fun SizePanel(para: Paragraph, onSize: (Float) -> Unit) {
val c = pdfColors
var size by remember(para.page, para.number, para.size) { mutableFloatStateOf(para.size.coerceIn(6f, 66f)) }
Column(Modifier.fillMaxWidth().barTopLine().padding(top = 10.dp, bottom = 6.dp)) {
- Text("Text size: ${size.roundToInt()} pt", color = c.label, fontSize = 15.sp, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth())
+ Text(stringResource(R.string.edit_text_size_pt, size.roundToInt()), color = c.label, fontSize = 15.sp, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth())
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 8.dp)) {
Text("A", color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 10.dp))
Slider(
@@ -275,7 +282,7 @@ private fun SizePanel(para: Paragraph, onSize: (Float) -> Unit) {
@Composable
private fun FontPanel(current: String?, onFont: (String) -> Unit) {
val c = pdfColors
- val faces = listOf(null to "Original font", "helvetica" to "Sans serif", "times" to "Serif", "courier" to "Monospace")
+ val faces = listOf(null to R.string.edit_font_original, "helvetica" to R.string.edit_font_sans, "times" to R.string.edit_font_serif, "courier" to R.string.edit_font_mono)
LazyColumn(Modifier.fillMaxWidth().heightIn(max = 240.dp).barTopLine().padding(horizontal = 24.dp, vertical = 4.dp)) {
items(faces.size) { i ->
val (key, name) = faces[i]
@@ -285,7 +292,7 @@ private fun FontPanel(current: String?, onFont: (String) -> Unit) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(
- name, color = if (key == null) c.textSecondary else c.label, fontSize = 17.sp, modifier = Modifier.weight(1f),
+ stringResource(name), color = if (key == null) c.textSecondary else c.label, fontSize = 17.sp, modifier = Modifier.weight(1f),
fontFamily = when (key) { "times" -> FontFamily.Serif; "courier" -> FontFamily.Monospace; else -> FontFamily.SansSerif },
)
if (chosen) Icon(LucideIcons.Check, null, tint = c.textSecondary, modifier = Modifier.size(22.dp))
@@ -300,8 +307,9 @@ private fun ColorPanel(current: String?, onColor: (String) -> Unit) {
Row(Modifier.fillMaxWidth().barTopLine().padding(horizontal = 12.dp, vertical = 12.dp)) {
for ((hex, name) in EditColors) {
val col = parseHex(hex)
+ val label = stringResource(name)
Box(
- Modifier.weight(1f).height(40.dp).background(col).clickable { onColor(hex) }.semantics { contentDescription = name },
+ Modifier.weight(1f).height(40.dp).background(col).clickable { onColor(hex) }.semantics { contentDescription = label },
contentAlignment = Alignment.Center,
) {
if (current.equals(hex, ignoreCase = true)) Icon(LucideIcons.Check, null, tint = if (hex == "#ffffff" || hex == "#ffff00" || hex == "#00ffff" || hex == "#00ff00") Color.Black else Color.White, modifier = Modifier.size(22.dp))
@@ -316,8 +324,9 @@ private fun ListPanel(current: ListStyle, onPick: (ListStyle) -> Unit) {
val c = pdfColors
Row(Modifier.fillMaxWidth().barTopLine().padding(vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(4.dp, Alignment.CenterHorizontally)) {
for (style in ListStyle.entries) {
+ val description = stringResource(listDescription(style))
Box(
- Modifier.height(40.dp).widthIn(min = 40.dp).clickable { onPick(style) }.padding(horizontal = 6.dp).semantics { contentDescription = "List ${style.name}" },
+ Modifier.height(40.dp).widthIn(min = 40.dp).clickable { onPick(style) }.padding(horizontal = 6.dp).semantics { contentDescription = description },
contentAlignment = Alignment.Center,
) { Text(style.label, color = if (style == current) c.toolAccent else c.icon, fontSize = 17.sp, fontWeight = if (style == current) FontWeight.SemiBold else FontWeight.Normal) }
}
@@ -329,8 +338,9 @@ private fun AlignPanel(current: String, onAlign: (String) -> Unit) {
val c = pdfColors
Row(Modifier.fillMaxWidth().barTopLine().padding(vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(4.dp, Alignment.CenterHorizontally)) {
for (a in listOf("left", "right", "center", "justify")) {
+ val description = stringResource(alignDescription(a))
Box(
- Modifier.size(40.dp).clickable { onAlign(a) }.semantics { contentDescription = "Align ${a}" },
+ Modifier.size(40.dp).clickable { onAlign(a) }.semantics { contentDescription = description },
contentAlignment = Alignment.Center,
) { Icon(alignIcon(a), null, tint = if (a == current) c.toolAccent else c.icon, modifier = Modifier.size(24.dp)) }
}
@@ -436,11 +446,11 @@ private fun BoxScope.SelectedParagraph(vm: AppViewModel, doc: OpenDocument, para
}
if (move == Offset.Zero && grow == 0f) {
FloatingMenu(a, b, doc.viewer.padTop) {
- MenuText("Edit text") { vm.startInlineEdit(para, selectAll = false) }
+ MenuText(stringResource(R.string.edit_edit_text)) { vm.startInlineEdit(para, selectAll = false) }
MenuSplit()
- MenuText("Select all") { vm.startInlineEdit(para, selectAll = true) }
+ MenuText(stringResource(R.string.edit_select_all)) { vm.startInlineEdit(para, selectAll = true) }
MenuSplit()
- MenuText("Delete") { vm.deleteParagraph(doc, para) }
+ MenuText(stringResource(R.string.common_delete)) { vm.deleteParagraph(doc, para) }
}
}
}
@@ -516,6 +526,7 @@ private fun BoxScope.InlineEditor(vm: AppViewModel, doc: OpenDocument, para: Par
}
var paper by remember(para) { mutableStateOf<Color?>(null) }
LaunchedEffect(para) { paper = vm.paperColor(doc, para) }
+ val paragraphLabel = stringResource(R.string.edit_paragraph_text)
val fontPx = para.size * ppp
val sp = with(density) { (fontPx / fontScale).toSp() }
val family = when (vm.editFont[para.page to para.number] ?: baseFont(para.font)) {
@@ -540,7 +551,7 @@ private fun BoxScope.InlineEditor(vm: AppViewModel, doc: OpenDocument, para: Par
),
cursorBrush = SolidColor(SelectionBlue),
onTextLayout = { layout = it },
- modifier = Modifier.fillMaxWidth().focusRequester(focus).semantics { contentDescription = "Paragraph text" }
+ modifier = Modifier.fillMaxWidth().focusRequester(focus).semantics { contentDescription = paragraphLabel }
.drawWithContent {
drawContent()
val l = layout ?: return@drawWithContent
@@ -658,13 +669,32 @@ private fun BoxScope.SelectedImage(vm: AppViewModel, doc: OpenDocument, img: Edi
}
if (move == Offset.Zero && scale == 1f) {
FloatingMenu(a, b, doc.viewer.padTop) {
- MenuIconButton(LucideIcons.RotateCcw, "Turn left") { vm.turnImage(doc, img, 3) }
- MenuIconButton(LucideIcons.RotateCw, "Turn right") { vm.turnImage(doc, img, 1) }
- MenuIconButton(LucideIcons.Trash2, "Delete") { vm.deleteImage(doc, img) }
+ MenuIconButton(LucideIcons.RotateCcw, stringResource(R.string.edit_turn_left)) { vm.turnImage(doc, img, 3) }
+ MenuIconButton(LucideIcons.RotateCw, stringResource(R.string.edit_turn_right)) { vm.turnImage(doc, img, 1) }
+ MenuIconButton(LucideIcons.Trash2, stringResource(R.string.common_delete)) { vm.deleteImage(doc, img) }
}
}
}
+/** What a screen reader says for each list style's button. */
+private fun listDescription(style: ListStyle): Int = when (style) {
+ ListStyle.None -> R.string.edit_list_desc_none
+ ListStyle.Bullet -> R.string.edit_list_desc_bullet
+ ListStyle.Dash -> R.string.edit_list_desc_dash
+ ListStyle.Number -> R.string.edit_list_desc_number
+ ListStyle.Lower -> R.string.edit_list_desc_lower
+ ListStyle.Upper -> R.string.edit_list_desc_upper
+ ListStyle.Roman -> R.string.edit_list_desc_roman
+}
+
+/** What a screen reader says for each alignment's button. */
+private fun alignDescription(a: String): Int = when (a) {
+ "center" -> R.string.edit_align_center
+ "right" -> R.string.edit_align_right
+ "justify" -> R.string.edit_align_justify
+ else -> R.string.edit_align_left
+}
+
private fun alignIcon(a: String) = when (a) {
"center" -> LucideIcons.AlignCenter
"right" -> LucideIcons.AlignRight
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt
index 1d57cd2..9598c1c 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/EditLists.kt
@@ -1,12 +1,15 @@
package io.github.artcraftandroid.pdfcraft.ui.viewer
+import io.github.artcraftandroid.pdfcraft.R
+import io.github.artcraftandroid.pdfcraft.text as appText
+
/**
* Bulleted and numbered lists in Edit PDF: each line of a paragraph (its hard line breaks) becomes
* an item with a marker in front. The markers are ones the standard PDF fonts carry (a bullet, an
* en dash, numbers, letters and small roman numerals), so any paragraph can take them.
*/
-enum class ListStyle(val label: String) {
- None("None"),
+enum class ListStyle(private val sample: String?) {
+ None(null),
Bullet("•"),
Dash("–"),
Number("1."),
@@ -14,6 +17,9 @@ enum class ListStyle(val label: String) {
Upper("A."),
Roman("i.");
+ /** What the list panel shows for the style: its first marker, or the word for no list. */
+ val label: String get() = sample ?: appText(R.string.lists_none)
+
/** The marker of item [n] (0-based). */
fun marker(n: Int): String = when (this) {
None -> ""
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt
index f80abbc..673403c 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/FillSign.kt
@@ -2,6 +2,7 @@ package io.github.artcraftandroid.pdfcraft.ui.viewer
import io.github.artcraftandroid.pdfcraft.ui.safeTopPadding
import android.graphics.Bitmap
+import androidx.annotation.StringRes
import android.graphics.BitmapFactory
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
@@ -53,6 +54,8 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.compose.ui.res.stringResource
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -65,15 +68,15 @@ import io.github.artcraftandroid.pdfcraft.ui.pdfColors
import java.io.File
/** What a tap places in Fill & Sign. */
-enum class FillElement(val engineType: String, val label: String) {
- Text("text", "Text"),
- Cross("cross", "Cross"),
- Check("check", "Checkmark"),
- Dot("dot", "Dot"),
- Box("box", "Rounded box"),
- Line("line", "Line"),
- Signature("signature", "Signature"),
- Initials("initials", "Initials"),
+enum class FillElement(val engineType: String, @StringRes val label: Int) {
+ Text("text", R.string.fill_element_text),
+ Cross("cross", R.string.fill_element_cross),
+ Check("check", R.string.fill_element_check),
+ Dot("dot", R.string.fill_element_dot),
+ Box("box", R.string.fill_element_box),
+ Line("line", R.string.fill_element_line),
+ Signature("signature", R.string.fill_element_signature),
+ Initials("initials", R.string.fill_element_initials),
}
/** The saved signature and initials (PNG with transparency), kept in the app's private files. */
@@ -131,14 +134,14 @@ fun FillSignToolbar(vm: AppViewModel, doc: OpenDocument) {
val sel = vm.fillElement
SubToolbar {
if (doc.info.fields == 0u) {
- SubTextField("Add text", sel == FillElement.Text) { vm.fillElement = FillElement.Text }
- SubTool(LucideIcons.X, "Add a cross", sel == FillElement.Cross, { vm.fillElement = FillElement.Cross })
- SubTool(LucideIcons.Check, "Add a checkmark", sel == FillElement.Check, { vm.fillElement = FillElement.Check })
- SubDot("Add a dot", sel == FillElement.Dot) { vm.fillElement = FillElement.Dot }
- SubTool(LucideIcons.RectangleHorizontal, "Add a rounded box", sel == FillElement.Box, { vm.fillElement = FillElement.Box })
- SubTool(LucideIcons.Minus, "Add a line", sel == FillElement.Line, { vm.fillElement = FillElement.Line })
+ SubTextField(stringResource(R.string.fill_add_text), sel == FillElement.Text) { vm.fillElement = FillElement.Text }
+ SubTool(LucideIcons.X, stringResource(R.string.fill_add_cross), sel == FillElement.Cross, { vm.fillElement = FillElement.Cross })
+ SubTool(LucideIcons.Check, stringResource(R.string.fill_add_check), sel == FillElement.Check, { vm.fillElement = FillElement.Check })
+ SubDot(stringResource(R.string.fill_add_dot), sel == FillElement.Dot) { vm.fillElement = FillElement.Dot }
+ SubTool(LucideIcons.RectangleHorizontal, stringResource(R.string.fill_add_box), sel == FillElement.Box, { vm.fillElement = FillElement.Box })
+ SubTool(LucideIcons.Minus, stringResource(R.string.fill_add_line), sel == FillElement.Line, { vm.fillElement = FillElement.Line })
}
- SubTool(LucideIcons.Signature, "Sign or add initials", sel == FillElement.Signature || sel == FillElement.Initials || doc.controller.signPanel, { doc.controller.signPanel = true })
+ SubTool(LucideIcons.Signature, stringResource(R.string.fill_sign_or_initials), sel == FillElement.Signature || sel == FillElement.Initials || doc.controller.signPanel, { doc.controller.signPanel = true })
}
}
@@ -152,14 +155,14 @@ fun SignPanel(vm: AppViewModel, doc: OpenDocument, onDismiss: () -> Unit) {
Spacer(Modifier.height(7.dp))
for (initials in listOf(false, true)) {
val file = vm.signatures.fileFor(initials)
- val label = if (initials) "initials" else "signature"
+ val placeHint = stringResource(if (initials) R.string.fill_tap_place_initials else R.string.fill_tap_place_signature)
if (!initials) Unit else Spacer(Modifier.height(18.dp))
SignBox(
onClick = {
if (file.isFile) {
vm.fillElement = if (initials) FillElement.Initials else FillElement.Signature
onDismiss()
- vm.tell("Tap where you want to place your $label")
+ vm.tell(placeHint)
} else {
onDismiss()
vm.signaturePad = SignaturePad(initials, doc, null)
@@ -168,17 +171,17 @@ fun SignPanel(vm: AppViewModel, doc: OpenDocument, onDismiss: () -> Unit) {
) {
if (file.isFile) {
val bmp = remember(file.lastModified(), version) { BitmapFactory.decodeFile(file.absolutePath) }
- if (bmp != null) Image(bmp.asImageBitmap(), "Your $label", modifier = Modifier.weight(1f).height(44.dp).padding(start = 12.dp), alignment = Alignment.CenterStart)
- BarIcon(LucideIcons.Trash2, "Clear saved $label", { file.delete(); vm.signaturesChanged++ }, size = 40.dp)
+ if (bmp != null) Image(bmp.asImageBitmap(), stringResource(if (initials) R.string.fill_your_initials else R.string.fill_your_signature), modifier = Modifier.weight(1f).height(44.dp).padding(start = 12.dp), alignment = Alignment.CenterStart)
+ BarIcon(LucideIcons.Trash2, stringResource(if (initials) R.string.fill_clear_initials else R.string.fill_clear_signature), { file.delete(); vm.signaturesChanged++ }, size = 40.dp)
} else {
- Text(if (initials) "Add initials" else "Add signature", color = pdfColors.text, fontSize = 16.sp, modifier = Modifier.weight(1f).padding(start = 22.dp))
+ Text(stringResource(if (initials) R.string.fill_add_initials else R.string.fill_add_signature), color = pdfColors.text, fontSize = 16.sp, modifier = Modifier.weight(1f).padding(start = 22.dp))
Icon(LucideIcons.Plus, null, tint = pdfColors.icon, modifier = Modifier.padding(end = 9.dp).size(24.dp))
}
}
}
Spacer(Modifier.height(14.dp))
// a certificate-based signature, which the reference's phone app doesn't have
- SheetRow(LucideIcons.ShieldCheck, "Sign with a digital ID", { onDismiss(); vm.startCertPlacing(doc) }, chevron = true)
+ SheetRow(LucideIcons.ShieldCheck, stringResource(R.string.common_tool_sign_digital_id), { onDismiss(); vm.startCertPlacing(doc) }, chevron = true)
Spacer(Modifier.height(10.dp))
}
}
@@ -220,24 +223,25 @@ fun SignaturePadScreen(vm: AppViewModel, pad: SignaturePad, onPickImage: () -> U
var save by remember { mutableStateOf(true) }
val ink = Color(vm.toolPrefs.fillColor)
val imported = vm.importedSignature
+ val drawFirst = stringResource(if (pad.initials) R.string.fill_draw_initials_first else R.string.fill_draw_signature_first)
Column(Modifier.fillMaxSize().background(c.surface).safeTopPadding().navigationBarsPadding()) {
Row(Modifier.fillMaxWidth().height(56.dp).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- TextButton(onClick = { vm.signaturePad = null; vm.importedSignature = null }) { Text("Cancel", color = c.accent) }
- Text(if (pad.initials) "Create initials" else "Create signature", color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 17.sp, modifier = Modifier.weight(1f), textAlign = androidx.compose.ui.text.style.TextAlign.Center)
+ TextButton(onClick = { vm.signaturePad = null; vm.importedSignature = null }) { Text(stringResource(R.string.common_cancel), color = c.accent) }
+ Text(stringResource(if (pad.initials) R.string.fill_create_initials else R.string.fill_create_signature), color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 17.sp, modifier = Modifier.weight(1f), textAlign = androidx.compose.ui.text.style.TextAlign.Center)
TextButton(
onClick = {
val bmp = imported ?: renderStrokes(strokes, size, ink)
if (bmp == null) {
- vm.tell(if (pad.initials) "Draw your initials first" else "Draw your signature first")
+ vm.tell(drawFirst)
} else {
vm.finishSignature(pad, bmp, save)
}
},
- ) { Text("Done", color = c.accent, fontWeight = FontWeight.SemiBold) }
+ ) { Text(stringResource(R.string.common_done), color = c.accent, fontWeight = FontWeight.SemiBold) }
}
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
- TabChip("Draw", imported == null) { vm.importedSignature = null }
- TabChip("Image", imported != null) { onPickImage() }
+ TabChip(stringResource(R.string.fill_tab_draw), imported == null) { vm.importedSignature = null }
+ TabChip(stringResource(R.string.fill_tab_image), imported != null) { onPickImage() }
}
Box(
Modifier.fillMaxWidth().weight(1f).padding(16.dp).clip(RoundedCornerShape(8.dp)).background(Color.White).border(1.dp, c.divider, RoundedCornerShape(8.dp))
@@ -266,13 +270,13 @@ fun SignaturePadScreen(vm: AppViewModel, pad: SignaturePad, onPickImage: () -> U
}
}
if (strokes.isEmpty()) {
- Text(if (pad.initials) "Draw your initials here" else "Draw your signature here", color = Color(0xFF8A8A8A), modifier = Modifier.align(Alignment.Center))
+ Text(stringResource(if (pad.initials) R.string.fill_draw_initials_here else R.string.fill_draw_signature_here), color = Color(0xFF8A8A8A), modifier = Modifier.align(Alignment.Center))
}
}
- Text("Clear", color = c.accent, modifier = Modifier.align(Alignment.TopEnd).clickable { strokes.clear(); vm.importedSignature = null }.padding(12.dp))
+ Text(stringResource(R.string.common_clear), color = c.accent, modifier = Modifier.align(Alignment.TopEnd).clickable { strokes.clear(); vm.importedSignature = null }.padding(12.dp))
}
Row(Modifier.fillMaxWidth().padding(horizontal = 20.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- Text("Save to device", color = c.text, fontSize = 15.sp, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.fill_save_to_device), color = c.text, fontSize = 15.sp, modifier = Modifier.weight(1f))
Switch(checked = save, onCheckedChange = { save = it }, colors = SwitchDefaults.colors(checkedTrackColor = c.accent))
}
Spacer(Modifier.height(8.dp))
@@ -343,10 +347,10 @@ fun androidx.compose.foundation.layout.BoxScope.FillElementMenu(vm: AppViewModel
Modifier.background(colors.surface, RoundedCornerShape(8.dp)).padding(horizontal = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- BarIcon(LucideIcons.AArrowDown, "Smaller", { vm.scaleFill(doc, c, 1f / 1.2f) })
- BarIcon(LucideIcons.AArrowUp, "Bigger", { vm.scaleFill(doc, c, 1.2f) })
- BarIcon(LucideIcons.Palette, "Colour", { palette = !palette }, selected = palette)
- BarIcon(LucideIcons.Trash2, "Delete", { vm.selectedFill = null; vm.deleteComment(doc, c) }, tint = colors.red)
+ BarIcon(LucideIcons.AArrowDown, stringResource(R.string.fill_smaller), { vm.scaleFill(doc, c, 1f / 1.2f) })
+ BarIcon(LucideIcons.AArrowUp, stringResource(R.string.fill_bigger), { vm.scaleFill(doc, c, 1.2f) })
+ BarIcon(LucideIcons.Palette, stringResource(R.string.fill_colour), { palette = !palette }, selected = palette)
+ BarIcon(LucideIcons.Trash2, stringResource(R.string.common_delete), { vm.selectedFill = null; vm.deleteComment(doc, c) }, tint = colors.red)
}
if (palette) {
Row(Modifier.padding(top = 6.dp).background(colors.surface, RoundedCornerShape(8.dp)).padding(8.dp)) {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt
index d6d0762..6109472 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Forms.kt
@@ -47,6 +47,8 @@ import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.compose.ui.res.stringResource
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.WidgetInfo
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
@@ -176,12 +178,12 @@ fun FieldTopBar(actions: FieldActions) {
},
verticalAlignment = Alignment.CenterVertically,
) {
- Text("Reset", color = c.label, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold,
+ Text(stringResource(R.string.forms_reset), color = c.label, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold,
modifier = Modifier.clickable { actions.reset() }.padding(horizontal = 28.dp, vertical = 14.dp))
Spacer(Modifier.weight(1f))
- BarIcon(LucideIcons.ChevronLeft, "Previous field", { actions.step(false) }, enabled = actions.canBack)
+ BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.forms_previous_field), { actions.step(false) }, enabled = actions.canBack)
Spacer(Modifier.width(4.dp))
- BarIcon(LucideIcons.ChevronRight, "Next field", { actions.step(true) }, enabled = actions.canForward)
+ BarIcon(LucideIcons.ChevronRight, stringResource(R.string.forms_next_field), { actions.step(true) }, enabled = actions.canForward)
Spacer(Modifier.width(16.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt
index 04358e8..6ef6888 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PageMenu.kt
@@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -38,6 +39,7 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
@@ -76,17 +78,17 @@ fun PageMenuView(vm: AppViewModel, menu: PageMenu) {
.pointerInput(Unit) { detectTapGestures { } },
) {
Row(Modifier.fillMaxWidth().height(61.dp), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically) {
- PageMenuIcon(LucideIcons.MessageSquarePlus, "Add comment", annotate) { close(); vm.notePrompt = NotePrompt(doc, menu.at) }
- PageMenuIcon(LucideIcons.Pencil, "Draw", annotate) { close(); vm.enterTool(doc, ViewerTool.Draw) }
- PageMenuIcon(LucideIcons.Type, "Add text", annotate) { close(); vm.textPrompt = TextPrompt(doc, menu.at) }
- if (fill) PageMenuIcon(LucideIcons.Signature, "Sign", true) { close(); vm.enterTool(doc, ViewerTool.FillSign) }
+ PageMenuIcon(LucideIcons.MessageSquarePlus, stringResource(R.string.page_menu_add_comment), annotate) { close(); vm.notePrompt = NotePrompt(doc, menu.at) }
+ PageMenuIcon(LucideIcons.Pencil, stringResource(R.string.common_tool_draw), annotate) { close(); vm.enterTool(doc, ViewerTool.Draw) }
+ PageMenuIcon(LucideIcons.Type, stringResource(R.string.page_menu_add_text), annotate) { close(); vm.textPrompt = TextPrompt(doc, menu.at) }
+ if (fill) PageMenuIcon(LucideIcons.Signature, stringResource(R.string.common_sign), true) { close(); vm.enterTool(doc, ViewerTool.FillSign) }
}
Box(Modifier.fillMaxWidth().padding(horizontal = 4.dp).height(1.dp).background(c.divider))
Spacer(Modifier.height(8.dp))
- if (!menu.pageHasText) PageMenuRow(LucideIcons.ScanText, "Recognize text") { close(); vm.recognizeText(doc) }
- PageMenuRow(LucideIcons.Crop, "Crop pages") { close(); vm.openCrop(doc) }
- PageMenuRow(LucideIcons.FilePenLine, "Edit PDF") { close(); vm.enterTool(doc, ViewerTool.Edit) }
- PageMenuRow(LucideIcons.ImagePlus, "Add image") { close(); vm.addImageAt(doc, menu.at) }
+ if (!menu.pageHasText) PageMenuRow(LucideIcons.ScanText, stringResource(R.string.common_tool_recognize_text)) { close(); vm.recognizeText(doc) }
+ PageMenuRow(LucideIcons.Crop, stringResource(R.string.common_tool_crop)) { close(); vm.openCrop(doc) }
+ PageMenuRow(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf)) { close(); vm.enterTool(doc, ViewerTool.Edit) }
+ PageMenuRow(LucideIcons.ImagePlus, stringResource(R.string.page_menu_add_image)) { close(); vm.addImageAt(doc, menu.at) }
Spacer(Modifier.height(8.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt
index 26e4bd4..b42d76e 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/PagesScreen.kt
@@ -51,12 +51,15 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.res.pluralStringResource
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.engine.toBitmap
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
@@ -124,13 +127,13 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
) {
Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) {
if (organizing) {
- BarIcon(LucideIcons.Check, if (picked.isEmpty()) "Done" else "Back", ::back, tint = c.toolAccent)
+ BarIcon(LucideIcons.Check, stringResource(if (picked.isEmpty()) R.string.common_done else R.string.common_back), ::back, tint = c.toolAccent)
} else {
- BarIcon(LucideIcons.ArrowLeft, "Back", ::back, iconSize = 27.dp)
+ BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), ::back, iconSize = 27.dp)
}
}
Text(
- if (organizing && picked.isNotEmpty()) "Selected ${picked.size}" else if (organizing) "Select pages" else "Pages",
+ if (organizing && picked.isNotEmpty()) pluralStringResource(R.plurals.pages_selected_count, picked.size, picked.size) else if (organizing) stringResource(R.string.pages_select) else stringResource(R.string.pages_title),
color = c.label, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f),
)
if (organizing && exporting == null) {
@@ -164,6 +167,7 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
val isSel = selected[i] == true
val isCurrent = !organizing && i == doc.viewer.currentPage
val highlighted = isSel || isCurrent || dragTo == i && dragFrom != i
+ val pageLabel = stringResource(R.string.pages_page, i + 1)
Column(
Modifier
.graphicsLayer { alpha = if (dragFrom == i) 0.4f else 1f }
@@ -214,7 +218,7 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
close()
}
}
- .semantics { contentDescription = "Page ${i + 1}" },
+ .semantics { contentDescription = pageLabel },
horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
@@ -255,23 +259,23 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
) {
if (exporting != null) {
// picking the pages to export: save them to the phone's pictures, or share them
- OrganizeItem(LucideIcons.Save, "Save", enabled) { vm.writeImages(doc, exporting, picked, share = false) }
- OrganizeItem(LucideIcons.Share2, "Share", enabled) { vm.writeImages(doc, exporting, picked, share = true) }
+ OrganizeItem(LucideIcons.Save, stringResource(R.string.common_save), enabled) { vm.writeImages(doc, exporting, picked, share = false) }
+ OrganizeItem(LucideIcons.Share2, stringResource(R.string.common_share), enabled) { vm.writeImages(doc, exporting, picked, share = true) }
} else if (organizing) {
- OrganizeItem(LucideIcons.FilePlus, "Insert Page", true) { insertMenu = true }
- OrganizeItem(LucideIcons.FileOutput, "Extract", enabled) { vm.extractPages(doc, picked) }
- OrganizeItem(LucideIcons.Trash2, "Delete", enabled && picked.size < doc.pageCount) {
+ OrganizeItem(LucideIcons.FilePlus, stringResource(R.string.pages_insert_page), true) { insertMenu = true }
+ OrganizeItem(LucideIcons.FileOutput, stringResource(R.string.pages_extract), enabled) { vm.extractPages(doc, picked) }
+ OrganizeItem(LucideIcons.Trash2, stringResource(R.string.common_delete), enabled && picked.size < doc.pageCount) {
vm.runTool(doc, "page_delete", mapOf("pages" to picked.map { it + 1 }))
selected.clear()
}
- OrganizeItem(LucideIcons.RotateCcw, "Left", enabled) { vm.runTool(doc, "page_rotate", mapOf("pages" to picked.map { it + 1 }, "degrees" to -90)) }
- OrganizeItem(LucideIcons.RotateCw, "Right", enabled) { vm.runTool(doc, "page_rotate", mapOf("pages" to picked.map { it + 1 }, "degrees" to 90)) }
+ OrganizeItem(LucideIcons.RotateCcw, stringResource(R.string.pages_rotate_left), enabled) { vm.runTool(doc, "page_rotate", mapOf("pages" to picked.map { it + 1 }, "degrees" to -90)) }
+ OrganizeItem(LucideIcons.RotateCw, stringResource(R.string.pages_rotate_right), enabled) { vm.runTool(doc, "page_rotate", mapOf("pages" to picked.map { it + 1 }, "degrees" to 90)) }
} else {
- OrganizeItem(LucideIcons.FilePenLine, "Edit PDF", true) {
+ OrganizeItem(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), true) {
close()
vm.enterTool(doc, ViewerTool.Edit)
}
- OrganizeItem(LucideIcons.Crop, "Crop pages", true) {
+ OrganizeItem(LucideIcons.Crop, stringResource(R.string.common_tool_crop), true) {
close()
vm.runQuickTool(doc, QuickTool.Crop)
}
@@ -289,13 +293,13 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
else -> first + 1
}
PdfSheet(onDismiss = { insertMenu = false }, dim = true) {
- SheetTitle("Insert")
+ SheetTitle(stringResource(R.string.pages_insert))
val c = pdfColors
for (option in listOf(false, true)) {
val label = when {
- first == null || last == null -> if (option) "At the end" else "At the start"
- option -> "After page ${last + 1}"
- else -> "Before page ${first + 1}"
+ first == null || last == null -> stringResource(if (option) R.string.pages_at_end else R.string.pages_at_start)
+ option -> stringResource(R.string.pages_after_page, last + 1)
+ else -> stringResource(R.string.pages_before_page, first + 1)
}
Row(
Modifier.fillMaxWidth().clickable(role = Role.RadioButton) { after = option }.padding(horizontal = 12.dp, vertical = 2.dp),
@@ -309,9 +313,9 @@ fun PagesScreen(vm: AppViewModel, doc: OpenDocument, onClose: () -> Unit) {
}
}
io.github.artcraftandroid.pdfcraft.ui.SheetDivider()
- SheetRow(LucideIcons.File, "Blank page", { insertMenu = false; vm.runTool(doc, "page_insert_blank", mapOf("at" to at)) })
- SheetRow(LucideIcons.FileStack, "From another file", { insertMenu = false; vm.pickInsertFile(doc, at) })
- SheetRow(LucideIcons.Camera, "From a scan", { insertMenu = false; vm.insertScanAt = doc to at; vm.startScan() })
+ SheetRow(LucideIcons.File, stringResource(R.string.pages_blank_page), { insertMenu = false; vm.runTool(doc, "page_insert_blank", mapOf("at" to at)) })
+ SheetRow(LucideIcons.FileStack, stringResource(R.string.pages_from_file), { insertMenu = false; vm.pickInsertFile(doc, at) })
+ SheetRow(LucideIcons.Camera, stringResource(R.string.pages_from_scan), { insertMenu = false; vm.insertScanAt = doc to at; vm.startScan() })
Spacer(Modifier.height(12.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt
index d09f9f3..b0b9539 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/QuickTools.kt
@@ -1,6 +1,7 @@
package io.github.artcraftandroid.pdfcraft.ui.viewer
import android.content.Context
+import androidx.annotation.StringRes
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
@@ -56,6 +57,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.compose.ui.res.pluralStringResource
+import androidx.compose.ui.res.stringResource
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -67,23 +71,23 @@ import kotlin.math.roundToInt
* A tool that can sit on the viewer's bottom toolbar or in More tools: [label] on the bar,
* [title] in More tools, [subTools] when it opens a row of sub-tools (the bar's corner mark).
*/
-enum class QuickTool(val id: String, val label: String, val title: String, val icon: ImageVector, val hue: Color, val subTools: Boolean = false) {
- Edit("edit", "Edit PDF", "Edit PDF", LucideIcons.FilePenLine, ToolHues.edit),
- Comment("comment", "Comment", "Comment", LucideIcons.MessageSquareText, ToolHues.comment, subTools = true),
- Highlight("highlight", "Highlight", "Highlight", LucideIcons.Highlighter, ToolHues.text, subTools = true),
- Draw("draw", "Draw", "Draw", LucideIcons.PenLine, ToolHues.sign),
- FillSign("fillsign", "Fill & Sign", "Fill & Sign", LucideIcons.Signature, ToolHues.sign, subTools = true),
- Export("export", "Export PDF", "Export PDF", LucideIcons.FileOutput, ToolHues.export),
- Combine("combine", "Combine", "Combine files", LucideIcons.Combine, ToolHues.combine),
- Compress("compress", "Compress", "Compress PDF", LucideIcons.FileArchive, ToolHues.compress),
- Protect("protect", "Password", "Set password", LucideIcons.FileLock2, ToolHues.protect),
- Organize("organize", "Organize", "Organize pages", LucideIcons.LayoutGrid, ToolHues.organize),
- Crop("crop", "Crop", "Crop pages", LucideIcons.Crop, ToolHues.crop),
- Ocr("ocr", "Recognize", "Recognize text", LucideIcons.ScanText, ToolHues.ocr),
- Create("create", "Create PDF", "Create PDF", LucideIcons.FilePlus2, ToolHues.create),
- Text("text", "Add text", "Text", LucideIcons.Type, ToolHues.text),
- Scan("scan", "Scan", "Scan", LucideIcons.Camera, ToolHues.scan),
- ReadAloud("readaloud", "Read aloud", "Read aloud", LucideIcons.Volume2, ToolHues.read);
+enum class QuickTool(val id: String, @StringRes val label: Int, @StringRes val title: Int, val icon: ImageVector, val hue: Color, val subTools: Boolean = false) {
+ Edit("edit", R.string.common_tool_edit_pdf, R.string.common_tool_edit_pdf, LucideIcons.FilePenLine, ToolHues.edit),
+ Comment("comment", R.string.common_tool_comment, R.string.common_tool_comment, LucideIcons.MessageSquareText, ToolHues.comment, subTools = true),
+ Highlight("highlight", R.string.common_tool_highlight, R.string.common_tool_highlight, LucideIcons.Highlighter, ToolHues.text, subTools = true),
+ Draw("draw", R.string.common_tool_draw, R.string.common_tool_draw, LucideIcons.PenLine, ToolHues.sign),
+ FillSign("fillsign", R.string.common_tool_fill_sign, R.string.common_tool_fill_sign, LucideIcons.Signature, ToolHues.sign, subTools = true),
+ Export("export", R.string.common_tool_export, R.string.common_tool_export, LucideIcons.FileOutput, ToolHues.export),
+ Combine("combine", R.string.toolbar_label_combine, R.string.common_tool_combine, LucideIcons.Combine, ToolHues.combine),
+ Compress("compress", R.string.toolbar_label_compress, R.string.common_tool_compress, LucideIcons.FileArchive, ToolHues.compress),
+ Protect("protect", R.string.toolbar_label_password, R.string.common_tool_set_password, LucideIcons.FileLock2, ToolHues.protect),
+ Organize("organize", R.string.toolbar_label_organize, R.string.common_tool_organize, LucideIcons.LayoutGrid, ToolHues.organize),
+ Crop("crop", R.string.toolbar_label_crop, R.string.common_tool_crop, LucideIcons.Crop, ToolHues.crop),
+ Ocr("ocr", R.string.toolbar_label_recognize, R.string.common_tool_recognize_text, LucideIcons.ScanText, ToolHues.ocr),
+ Create("create", R.string.common_tool_create_pdf, R.string.common_tool_create_pdf, LucideIcons.FilePlus2, ToolHues.create),
+ Text("text", R.string.toolbar_label_add_text, R.string.toolbar_tool_text, LucideIcons.Type, ToolHues.text),
+ Scan("scan", R.string.common_tool_scan, R.string.common_tool_scan, LucideIcons.Camera, ToolHues.scan),
+ ReadAloud("readaloud", R.string.common_tool_read_aloud, R.string.common_tool_read_aloud, LucideIcons.Volume2, ToolHues.read);
companion object {
/** The bar as it comes: the reference's default tools and order. */
@@ -204,6 +208,8 @@ fun CustomizeToolbar(vm: AppViewModel, onDone: () -> Unit) {
@Composable
fun Draggable(t: QuickTool, content: @Composable () -> Unit) {
+ val title = stringResource(t.title)
+ val description = if (t in bar) stringResource(R.string.toolbar_tool_on_bar, title) else stringResource(R.string.toolbar_tool_in_more_tools, title)
Box(
Modifier
.onGloballyPositioned { rects[t] = it.boundsInRoot() }
@@ -227,25 +233,25 @@ fun CustomizeToolbar(vm: AppViewModel, onDone: () -> Unit) {
)
}
.clickable(role = Role.Button) { if (t in bar) toGrid(t, 0) else toBar(t, bar.size) }
- .semantics { contentDescription = if (t in bar) "${t.title}, on the toolbar" else "${t.title}, in More tools" },
+ .semantics { contentDescription = description },
) { content() }
}
Box(Modifier.fillMaxWidth().onGloballyPositioned { origin = it.boundsInRoot().topLeft }) {
Column {
Row(Modifier.fillMaxWidth().padding(start = 20.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- Text("Customize toolbar", color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
- BarIcon(LucideIcons.X, "Cancel", onDone)
- BarIcon(LucideIcons.Check, "Save toolbar", {
+ Text(stringResource(R.string.toolbar_customize), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
+ BarIcon(LucideIcons.X, stringResource(R.string.common_cancel), onDone)
+ BarIcon(LucideIcons.Check, stringResource(R.string.toolbar_save), {
prefs.save(bar.toList(), grid.toList())
onDone()
}, tint = c.accent)
}
Text(
- "Drag tools between the toolbar and More tools. The toolbar holds $slots.",
+ pluralStringResource(R.plurals.toolbar_customize_hint, slots, slots),
color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp, vertical = 4.dp),
)
- Text("Toolbar", color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 12.dp, bottom = 6.dp))
+ Text(stringResource(R.string.toolbar_section_toolbar), color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 12.dp, bottom = 6.dp))
BoxWithConstraints(
Modifier.fillMaxWidth().padding(horizontal = 8.dp).clip(RoundedCornerShape(8.dp)).background(c.pressed)
.onGloballyPositioned { barRect = it.boundsInRoot() },
@@ -258,7 +264,7 @@ fun CustomizeToolbar(vm: AppViewModel, onDone: () -> Unit) {
Box(Modifier.alpha(0.5f)) { BarTool(null, itemW) }
}
}
- Text("More tools", color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 16.dp, bottom = 6.dp))
+ Text(stringResource(R.string.common_tool_more_tools), color = c.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 16.dp, bottom = 6.dp))
Column(Modifier.fillMaxWidth().padding(horizontal = 8.dp).heightIn(min = 96.dp).onGloballyPositioned { gridRect = it.boundsInRoot() }) {
grid.chunked(4).forEach { row ->
Row(Modifier.fillMaxWidth()) {
@@ -291,7 +297,7 @@ private fun BarTool(tool: QuickTool?, width: androidx.compose.ui.unit.Dp) {
Icon(tool?.icon ?: LucideIcons.LayoutGrid, null, tint = c.icon, modifier = Modifier.size(24.dp))
Spacer(Modifier.height(6.dp))
Text(
- tool?.label ?: "More tools", color = c.text, fontSize = 12.sp, lineHeight = 14.sp, maxLines = 2,
+ stringResource(tool?.label ?: R.string.common_tool_more_tools), color = c.text, fontSize = 12.sp, lineHeight = 14.sp, maxLines = 2,
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis, textAlign = TextAlign.Center,
)
}
@@ -306,6 +312,6 @@ private fun GridTool(tool: QuickTool) {
Icon(tool.icon, null, tint = tool.hue, modifier = Modifier.size(26.dp))
}
Spacer(Modifier.height(8.dp))
- Text(tool.title, color = c.text, fontSize = 13.sp, textAlign = TextAlign.Center, maxLines = 2, lineHeight = 16.sp)
+ Text(stringResource(tool.title), color = c.text, fontSize = 13.sp, textAlign = TextAlign.Center, maxLines = 2, lineHeight = 16.sp)
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt
index 2ec7a50..9a74a5a 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadAloud.kt
@@ -56,6 +56,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -65,10 +66,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupProperties
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.ReadingBlock
import io.github.artcraftandroid.pdfcraft.core.TextRange
import io.github.artcraftandroid.pdfcraft.engine.Engine
import io.github.artcraftandroid.pdfcraft.engine.toBitmap
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
import io.github.artcraftandroid.pdfcraft.ui.PdfSheet
@@ -146,7 +149,7 @@ class ReadAloud(
private val tts: TextToSpeech = TextToSpeech(context.applicationContext) { status ->
scope.launch {
if (status != TextToSpeech.SUCCESS) {
- problem = "Read aloud needs a text-to-speech voice on this phone."
+ problem = text(R.string.read_aloud_no_voice)
return@launch
}
ready = true
@@ -446,6 +449,7 @@ fun BoxScope.ReadAloudBar(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel
val c = pdfColors
var speeds by remember { mutableStateOf(false) }
var expanded by remember { mutableStateOf(false) }
+ val openPlayer = stringResource(R.string.read_aloud_open_player)
Column(Modifier.align(Alignment.BottomCenter).fillMaxWidth().background(c.surface)) {
ProgressTrack(r.progress, Modifier.fillMaxWidth().height(6.dp))
Box(Modifier.fillMaxWidth().height(0.5.dp).background(c.divider))
@@ -455,12 +459,12 @@ fun BoxScope.ReadAloudBar(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel
) {
Box(
Modifier.size(40.dp).clip(CircleShape).background(c.pageCard).clickable(role = Role.Button) { expanded = true }
- .semantics { contentDescription = "Open the player" },
+ .semantics { contentDescription = openPlayer },
contentAlignment = Alignment.Center,
) { Icon(LucideIcons.ChevronUp, null, tint = c.label, modifier = Modifier.size(24.dp)) }
Row(Modifier.weight(1f), horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.CenterHorizontally), verticalAlignment = Alignment.CenterVertically) {
SkipButton(back = true, size = 43.dp) { r.skip(false) }
- PlayerButton(if (r.playing) LucideIcons.Pause else LucideIcons.Play, if (r.playing) "Pause" else if (r.finished) "Read again" else "Play", 43.dp) {
+ PlayerButton(if (r.playing) LucideIcons.Pause else LucideIcons.Play, stringResource(if (r.playing) R.string.common_pause else if (r.finished) R.string.read_aloud_read_again else R.string.common_play), 43.dp) {
if (r.playing) r.pause() else r.play()
}
SkipButton(back = false, size = 43.dp) { r.skip(true) }
@@ -500,9 +504,10 @@ private fun PlayerButton(icon: ImageVector, description: String, size: androidx.
@Composable
private fun SkipButton(back: Boolean, size: androidx.compose.ui.unit.Dp, iconSize: androidx.compose.ui.unit.Dp = 26.dp, onClick: () -> Unit) {
val c = pdfColors
+ val label = stringResource(if (back) R.string.read_aloud_back_15 else R.string.read_aloud_forward_15)
Box(
Modifier.size(size).clip(CircleShape).clickable(role = Role.Button, onClick = onClick)
- .semantics { contentDescription = if (back) "Back 15 seconds" else "Forward 15 seconds" },
+ .semantics { contentDescription = label },
contentAlignment = Alignment.Center,
) {
Icon(if (back) LucideIcons.RotateCcw else LucideIcons.RotateCw, null, tint = c.label, modifier = Modifier.size(iconSize))
@@ -546,6 +551,7 @@ private fun ReadAloudFull(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel
var thumb by remember(r.page) { mutableStateOf<ImageBitmap?>(null) }
var speeds by remember { mutableStateOf(false) }
var voices by remember { mutableStateOf(false) }
+ val closePlayer = stringResource(R.string.read_aloud_close_player)
LaunchedEffect(r.page) {
val eng = vm.engine ?: return@LaunchedEffect
val size = doc.info.pages.getOrNull(r.page) ?: return@LaunchedEffect
@@ -559,7 +565,7 @@ private fun ReadAloudFull(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel
Box(Modifier.fillMaxWidth()) {
Box(
Modifier.size(40.dp).clip(CircleShape).background(c.pageCard).clickable(role = Role.Button, onClick = onClose)
- .semantics { contentDescription = "Close the player" },
+ .semantics { contentDescription = closePlayer },
contentAlignment = Alignment.Center,
) { Icon(LucideIcons.ChevronDown, null, tint = c.label, modifier = Modifier.size(22.dp)) }
}
@@ -580,7 +586,7 @@ private fun ReadAloudFull(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(24.dp)) {
SkipButton(back = true, size = 58.dp, iconSize = 32.dp) { r.skip(false) }
Box(Modifier.size(80.dp).clip(CircleShape).background(c.divider), contentAlignment = Alignment.Center) {
- PlayerButton(if (r.playing) LucideIcons.Pause else LucideIcons.Play, if (r.playing) "Pause" else "Play", 80.dp, iconSize = 40.dp) {
+ PlayerButton(if (r.playing) LucideIcons.Pause else LucideIcons.Play, stringResource(if (r.playing) R.string.common_pause else R.string.common_play), 80.dp, iconSize = 40.dp) {
if (r.playing) r.pause() else r.play()
}
}
@@ -593,7 +599,7 @@ private fun ReadAloudFull(vm: io.github.artcraftandroid.pdfcraft.ui.AppViewModel
horizontalAlignment = Alignment.CenterHorizontally,
) {
Icon(LucideIcons.AudioLines, null, tint = c.icon, modifier = Modifier.size(24.dp))
- Text("Voice", color = c.textSecondary, fontSize = 13.sp)
+ Text(stringResource(R.string.read_aloud_voice), color = c.textSecondary, fontSize = 13.sp)
}
Box {
Text(speedLabel(r.speed), color = c.textSecondary, fontSize = 16.sp, modifier = Modifier.clickable { speeds = true }.padding(8.dp))
@@ -618,14 +624,14 @@ private fun LanguageSheet(r: ReadAloud, onVoiceSettings: () -> Unit, onDismiss:
val current = remember(langs, r.language) { languageIndex(langs, r.language) }
val list = androidx.compose.foundation.lazy.rememberLazyListState(initialFirstVisibleItemIndex = (current - 2).coerceAtLeast(0))
io.github.artcraftandroid.pdfcraft.ui.PdfSheet(onDismiss = onDismiss, dim = true) {
- io.github.artcraftandroid.pdfcraft.ui.SheetTitle("Choose language")
+ io.github.artcraftandroid.pdfcraft.ui.SheetTitle(stringResource(R.string.read_aloud_choose_language))
androidx.compose.foundation.lazy.LazyColumn(Modifier.heightIn(max = 420.dp), state = list) {
items(langs.size) { i ->
val l = langs[i]
io.github.artcraftandroid.pdfcraft.ui.SheetRow(null, l.getDisplayName(Locale.getDefault()), { r.chooseLanguage(l); onDismiss() }, checked = i == current)
}
}
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Settings, "Voice settings", onVoiceSettings)
+ io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Settings, stringResource(R.string.read_aloud_voice_settings), onVoiceSettings)
Spacer(Modifier.height(8.dp))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt
index 7bbed22..62714a3 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ReadingMode.kt
@@ -33,10 +33,12 @@ import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.foundation.layout.Box
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
import io.github.artcraftandroid.pdfcraft.ui.pdfColors
@@ -58,9 +60,10 @@ fun ReadingModeContent(vm: AppViewModel, doc: OpenDocument, top: Dp, bottom: Dp,
val list = rememberLazyListState(initialFirstVisibleItemIndex = (vm.pendingPage ?: doc.viewer.currentPage).coerceIn(0, (doc.pageCount - 1).coerceAtLeast(0)))
var size by remember { mutableFloatStateOf(17f) }
var hint by remember { mutableStateOf<String?>(null) }
+ val pinchHint = stringResource(R.string.viewer_reading_hint)
LaunchedEffect(doc) {
delay(400)
- hint = "Pinch or double-tap to make the text bigger."
+ hint = pinchHint
delay(3000)
hint = null
}
@@ -129,7 +132,7 @@ fun ReadingModeContent(vm: AppViewModel, doc: OpenDocument, top: Dp, bottom: Dp,
Column(Modifier.fillMaxWidth().then(if (ps == null) Modifier.fillParentMaxHeight() else Modifier.heightIn(min = 120.dp)).background(paper).padding(horizontal = 20.dp, vertical = 16.dp)) {
when {
ps == null -> Unit
- ps.isEmpty() -> Text("No text on this page to reflow.", color = ink.copy(alpha = 0.6f), fontSize = size.sp)
+ ps.isEmpty() -> Text(stringResource(R.string.viewer_reading_no_text), color = ink.copy(alpha = 0.6f), fontSize = size.sp)
else -> {
val body = ps.map { it.size }.sorted().let { it[it.size / 2] }.coerceAtLeast(1f)
for ((i, p) in ps.withIndex()) {
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt
index 301e961..05d0851 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ToolPrefs.kt
@@ -8,15 +8,16 @@ import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
+import io.github.artcraftandroid.pdfcraft.R
/** The comment colours: 18 swatches in three rows of six (strong, light, greys), as measured on the reference. */
-val CommentPalette: List<Pair<Color, String>> = listOf(
- Color(0xFF0000FF) to "Blue", Color(0xFF6AD928) to "Green", Color(0xFFFFD100) to "Yellow",
- Color(0xFFFF7002) to "Orange", Color(0xFFE52237) to "Red", Color(0xFFA33086) to "Purple",
- Color(0xFF38E5FF) to "Light blue", Color(0xFFC5FB72) to "Light green", Color(0xFFFCF485) to "Light yellow",
- Color(0xFFFFC09E) to "Light orange", Color(0xFFFF809D) to "Pink", Color(0xFFFB88FF) to "Light purple",
- Color(0xFFFFFFFF) to "White", Color(0xFFCCCCCC) to "Pale grey", Color(0xFFAAAAAA) to "Light grey",
- Color(0xFF777777) to "Medium grey", Color(0xFF444444) to "Dark grey", Color(0xFF000000) to "Black",
+val CommentPalette: List<Pair<Color, Int>> = listOf(
+ Color(0xFF0000FF) to R.string.prefs_color_blue, Color(0xFF6AD928) to R.string.prefs_color_green, Color(0xFFFFD100) to R.string.prefs_color_yellow,
+ Color(0xFFFF7002) to R.string.prefs_color_orange, Color(0xFFE52237) to R.string.prefs_color_red, Color(0xFFA33086) to R.string.prefs_color_purple,
+ Color(0xFF38E5FF) to R.string.prefs_color_light_blue, Color(0xFFC5FB72) to R.string.prefs_color_light_green, Color(0xFFFCF485) to R.string.prefs_color_light_yellow,
+ Color(0xFFFFC09E) to R.string.prefs_color_light_orange, Color(0xFFFF809D) to R.string.prefs_color_pink, Color(0xFFFB88FF) to R.string.prefs_color_light_purple,
+ Color(0xFFFFFFFF) to R.string.prefs_color_white, Color(0xFFCCCCCC) to R.string.prefs_color_pale_grey, Color(0xFFAAAAAA) to R.string.prefs_color_light_grey,
+ Color(0xFF777777) to R.string.prefs_color_medium_grey, Color(0xFF444444) to R.string.prefs_color_dark_grey, Color(0xFF000000) to R.string.prefs_color_black,
)
/** The seven ink widths of the stroke picker, in points. */
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt
index f8eaadf..1987c03 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/Tools.kt
@@ -60,6 +60,9 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.compose.ui.res.stringResource
+import io.github.artcraftandroid.pdfcraft.R
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.core.TextRange
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -313,7 +316,7 @@ private fun MarkupLayer(vm: AppViewModel, doc: OpenDocument) {
scope.launch {
val n = withContext(eng.commands) { eng.session.glyphCount(doc.id, at.page.toUInt()) }
if (n == 0u) {
- vm.tell("This page has no text to mark. Recognize text first (More tools ▸ Recognize text).")
+ vm.tell(text(R.string.toolbar_no_text_to_mark))
return@launch
}
val g = withContext(eng.commands) { eng.session.nearestGlyph(doc.id, at.page.toUInt(), at.x, at.y) } ?: return@launch
@@ -367,31 +370,33 @@ fun ToolSubToolbar(vm: AppViewModel, doc: OpenDocument) {
}
when (ctl.tool) {
ViewerTool.Markup -> SubToolbar {
- SubTool(LucideIcons.Highlighter, "Highlight", ctl.markup == TextMarkup.Highlight, { ctl.markup = TextMarkup.Highlight })
- SubTool(LucideIcons.Underline, "Underline", ctl.markup == TextMarkup.Underline, { ctl.markup = TextMarkup.Underline })
- SubTool(LucideIcons.Strikethrough, "Strikethrough", ctl.markup == TextMarkup.Strikethrough, { ctl.markup = TextMarkup.Strikethrough })
+ SubTool(LucideIcons.Highlighter, stringResource(R.string.common_tool_highlight), ctl.markup == TextMarkup.Highlight, { ctl.markup = TextMarkup.Highlight })
+ SubTool(LucideIcons.Underline, stringResource(R.string.common_tool_underline), ctl.markup == TextMarkup.Underline, { ctl.markup = TextMarkup.Underline })
+ SubTool(LucideIcons.Strikethrough, stringResource(R.string.toolbar_strikethrough), ctl.markup == TextMarkup.Strikethrough, { ctl.markup = TextMarkup.Strikethrough })
SubDivider()
ColorDot(prefs.color(ctl.markup.styled), picker == Picker.Color) { toggle(Picker.Color) }
}
ViewerTool.Draw -> SubToolbar {
- SubTool(LucideIcons.PenLine, "Draw freeform", true, {})
+ val snapOn = stringResource(R.string.toolbar_snap_on)
+ val snapOff = stringResource(R.string.toolbar_snap_off)
+ SubTool(LucideIcons.PenLine, stringResource(R.string.toolbar_draw_freeform), true, {})
SubDivider()
- SubProperty(LucideIcons.Menu, "Line thickness", picker == Picker.Width, { toggle(Picker.Width) })
+ SubProperty(LucideIcons.Menu, stringResource(R.string.toolbar_line_thickness), picker == Picker.Width, { toggle(Picker.Width) })
ColorDot(prefs.color(StyledTool.Ink), picker == Picker.Color) { toggle(Picker.Color) }
SubDivider()
- SubTool(LucideIcons.Shapes, "Snap to shape", prefs.snapToShape, {
+ SubTool(LucideIcons.Shapes, stringResource(R.string.toolbar_snap_to_shape), prefs.snapToShape, {
prefs.updateSnapToShape(!prefs.snapToShape)
- vm.tell(if (prefs.snapToShape) "Snap to shape on" else "Snap to shape off")
+ vm.tell(if (prefs.snapToShape) snapOn else snapOff)
})
}
ViewerTool.Comment -> SubToolbar {
- SubTool(LucideIcons.MessageSquareText, "Text comment", ctl.commentMode == CommentMode.Text, { ctl.commentMode = CommentMode.Text })
- SubTool(LucideIcons.MicAudioLines, "Voice comment", ctl.commentMode == CommentMode.Voice, { ctl.commentMode = CommentMode.Voice })
+ SubTool(LucideIcons.MessageSquareText, stringResource(R.string.toolbar_text_comment), ctl.commentMode == CommentMode.Text, { ctl.commentMode = CommentMode.Text })
+ SubTool(LucideIcons.MicAudioLines, stringResource(R.string.toolbar_voice_comment), ctl.commentMode == CommentMode.Voice, { ctl.commentMode = CommentMode.Voice })
}
ViewerTool.Text -> SubToolbar {
- SubTool(LucideIcons.Type, "Text", true, {})
+ SubTool(LucideIcons.Type, stringResource(R.string.toolbar_tool_text), true, {})
SubDivider()
- SubProperty(LucideIcons.ALargeSmall, "Text size", picker == Picker.TextSize, { toggle(Picker.TextSize) })
+ SubProperty(LucideIcons.ALargeSmall, stringResource(R.string.toolbar_text_size), picker == Picker.TextSize, { toggle(Picker.TextSize) })
ColorDot(prefs.color(StyledTool.FreeText), picker == Picker.Color) { toggle(Picker.Color) }
}
ViewerTool.FillSign -> FillSignToolbar(vm, doc)
@@ -428,30 +433,32 @@ fun PropertyPicker(vm: AppViewModel, tool: StyledTool, picker: Picker, markup: T
PdfSheet(onDismiss = onDismiss, modifier = Modifier.padding(bottom = BottomBarHeight + 1.dp).navigationBarsPadding(), bottomBand = false) {
when (picker) {
Picker.Color -> {
- val title = when (tool) {
- StyledTool.Highlight -> "Highlight color"
- StyledTool.Underline -> "Underline color"
- StyledTool.Strikethrough -> "Strikethrough color"
- StyledTool.Ink -> "Drawing color"
- StyledTool.FreeText -> "Text color"
- StyledTool.Note -> "Comment color"
- }
+ val title = stringResource(
+ when (tool) {
+ StyledTool.Highlight -> R.string.toolbar_color_highlight
+ StyledTool.Underline -> R.string.toolbar_color_underline
+ StyledTool.Strikethrough -> R.string.toolbar_color_strikethrough
+ StyledTool.Ink -> R.string.toolbar_color_drawing
+ StyledTool.FreeText -> R.string.toolbar_color_text
+ StyledTool.Note -> R.string.toolbar_color_comment
+ },
+ )
Text(title, color = c.text, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, top = 3.dp, bottom = 18.dp))
ColorGrid(prefs.color(tool)) { prefs.setColor(tool, it) }
if (tool != StyledTool.FreeText) {
- Text("Opacity", color = c.text, fontSize = 15.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 78.dp, top = 20.dp, bottom = 8.dp))
+ Text(stringResource(R.string.toolbar_opacity), color = c.text, fontSize = 15.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 78.dp, top = 20.dp, bottom = 8.dp))
OpacitySlider(prefs.color(tool), prefs.opacity(tool)) { prefs.setOpacity(tool, it) }
}
Spacer(Modifier.height(30.dp))
}
Picker.Width -> {
- Text("Line thickness", color = c.text, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, bottom = 12.dp))
+ Text(stringResource(R.string.toolbar_line_thickness), color = c.text, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, bottom = 12.dp))
InkWidthRow(prefs.color(StyledTool.Ink), prefs.inkWidth) { prefs.updateInkWidth(it) }
}
Picker.TextSize -> {
- Text("Text size", color = c.text, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, bottom = 4.dp))
+ Text(stringResource(R.string.toolbar_text_size), color = c.text, fontSize = 17.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, modifier = Modifier.padding(start = 20.dp, bottom = 4.dp))
Row(Modifier.fillMaxWidth().padding(horizontal = 20.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- Text("${prefs.textSize.toInt()} pt", color = c.text, fontSize = 15.sp, modifier = Modifier.width(56.dp))
+ Text(stringResource(R.string.toolbar_text_size_pt, prefs.textSize.toInt()), color = c.text, fontSize = 15.sp, modifier = Modifier.width(56.dp))
Slider(
value = prefs.textSize,
onValueChange = { v -> prefs.updateTextSize((Math.round(v / 2f) * 2f).coerceIn(6f, 22f)) },
@@ -474,11 +481,12 @@ fun InkWidthRow(color: Color, selected: Float?, onPick: (Float) -> Unit) {
val c = pdfColors
Row(Modifier.fillMaxWidth().padding(bottom = 16.dp), horizontalArrangement = Arrangement.Center) {
InkWidths.forEachIndexed { i, w ->
+ val description = stringResource(R.string.toolbar_stroke_width, i + 1)
Box(
Modifier.size(48.dp)
.then(if (selected == w) Modifier.border(1.5.dp, c.accent, RoundedCornerShape(4.dp)) else Modifier)
.clickable(role = Role.RadioButton) { onPick(w) }
- .semantics { contentDescription = "Stroke width ${i + 1}" },
+ .semantics { contentDescription = description },
contentAlignment = Alignment.Center,
) {
Box(Modifier.width(28.dp).height((1 + i * 1.2f).dp).background(color))
@@ -496,6 +504,7 @@ fun ColorGrid(selected: Color, onPick: (Color) -> Unit) {
CommentPalette.chunked(6).forEach { row ->
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
row.forEach { (color, name) ->
+ val label = stringResource(name)
val isSel = color.toArgbInt() == selected.toArgbInt()
// only a swatch the colour of the sheet itself needs an outline to be seen
val outlined = kotlin.math.abs(color.luminance() - c.surface.luminance()) < 0.08f
@@ -515,7 +524,7 @@ fun ColorGrid(selected: Color, onPick: (Color) -> Unit) {
.background(color)
.then(if (outlined) Modifier.border(1.dp, c.divider, RoundedCornerShape(3.dp)) else Modifier)
.clickable(role = Role.RadioButton) { onPick(color) }
- .semantics { contentDescription = name },
+ .semantics { contentDescription = label },
contentAlignment = Alignment.Center,
) {
if (isSel) Icon(LucideIcons.Check, null, tint = if (color.luminance() > 0.5f) Color.Black else Color.White, modifier = Modifier.size(20.dp))
@@ -534,6 +543,7 @@ fun ColorGrid(selected: Color, onPick: (Color) -> Unit) {
fun OpacitySlider(color: Color, value: Float, onChange: (Float) -> Unit) {
val min = 0.25f
val sheet = pdfColors.surface
+ val description = stringResource(R.string.toolbar_opacity_percent, (value * 100).toInt())
Box(
Modifier.fillMaxWidth().padding(horizontal = 78.dp).height(35.dp)
.pointerInput(Unit) {
@@ -543,7 +553,7 @@ fun OpacitySlider(color: Color, value: Float, onChange: (Float) -> Unit) {
.pointerInput(Unit) {
detectHorizontalDragGestures { change, _ -> onChange((min + (change.position.x / size.width).coerceIn(0f, 1f) * (1f - min))) }
}
- .semantics { contentDescription = "Opacity ${(value * 100).toInt()}%" },
+ .semantics { contentDescription = description },
) {
Canvas(Modifier.fillMaxSize()) {
val sq = 12.dp.toPx()
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt
index 1c5ec60..88fb97c 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerBars.kt
@@ -46,6 +46,7 @@ import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -57,6 +58,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.ui.BarDivider
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.Inter
@@ -106,9 +108,9 @@ fun ViewerTopBar(
) {
Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) {
if (toolActive && doneIsCheck) {
- BarIcon(LucideIcons.Check, "Done", onBack, tint = c.toolAccent)
+ BarIcon(LucideIcons.Check, stringResource(R.string.common_done), onBack, tint = c.toolAccent)
} else {
- BarIcon(LucideIcons.ArrowLeft, "Back", onBack, iconSize = 27.dp)
+ BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.common_back), onBack, iconSize = 27.dp)
}
}
if (title != null) {
@@ -122,7 +124,7 @@ fun ViewerTopBar(
BarDivider(height = 24.dp)
Spacer(Modifier.width(14.dp))
// with something to undo the reference shrinks the switch to a plain speaker button
- if (canUndo && !readingAloud) BarIcon(LucideIcons.Volume2, "Read aloud", onReadAloud) else ReadAloudSwitch(readingAloud, onReadAloud)
+ if (canUndo && !readingAloud) BarIcon(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), onReadAloud) else ReadAloudSwitch(readingAloud, onReadAloud)
}
Spacer(Modifier.weight(1f))
// while reading aloud the bar holds only back and the switch, as the reference's
@@ -132,15 +134,15 @@ fun ViewerTopBar(
}
if (toolActive) {
if (canUndo || canRedo) {
- BarIcon(LucideIcons.Undo2, "Undo", onUndo, enabled = canUndo)
- BarIcon(LucideIcons.Redo2, "Redo", onRedo, enabled = canRedo)
+ BarIcon(LucideIcons.Undo2, stringResource(R.string.common_undo), onUndo, enabled = canUndo)
+ BarIcon(LucideIcons.Redo2, stringResource(R.string.common_redo), onRedo, enabled = canRedo)
}
} else if (canUndo) {
UndoMenuButton(canUndo, canRedo, onUndo, onRedo, undoLabel, redoLabel)
}
- if (onSearch != null) BarIcon(LucideIcons.Search, "Find in document", onSearch)
- BarIcon(LucideIcons.Share2, "Share", onShare)
- BarIcon(LucideIcons.EllipsisVertical, "More options", onMore, selected = moreOpen)
+ if (onSearch != null) BarIcon(LucideIcons.Search, stringResource(R.string.viewer_find_in_document), onSearch)
+ BarIcon(LucideIcons.Share2, stringResource(R.string.common_share), onShare)
+ BarIcon(LucideIcons.EllipsisVertical, stringResource(R.string.common_more_options), onMore, selected = moreOpen)
Spacer(Modifier.width(10.dp))
}
}
@@ -150,9 +152,10 @@ fun ViewerTopBar(
fun UndoMenuButton(canUndo: Boolean, canRedo: Boolean, onUndo: () -> Unit, onRedo: () -> Unit, undoLabel: String? = null, redoLabel: String? = null) {
val c = pdfColors
var open by androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf(false) }
+ val undoOrRedo = stringResource(R.string.viewer_undo_or_redo)
Box {
Box(
- Modifier.size(46.dp).clickable(enabled = canUndo || canRedo, role = Role.Button) { open = true }.semantics { contentDescription = "Undo or redo" },
+ Modifier.size(46.dp).clickable(enabled = canUndo || canRedo, role = Role.Button) { open = true }.semantics { contentDescription = undoOrRedo },
contentAlignment = Alignment.Center,
) {
val tint = if (canUndo || canRedo) c.icon else c.icon.copy(alpha = 0.38f)
@@ -164,11 +167,11 @@ fun UndoMenuButton(canUndo: Boolean, canRedo: Boolean, onUndo: () -> Unit, onRed
}
androidx.compose.material3.DropdownMenu(expanded = open, onDismissRequest = { open = false }, containerColor = c.menu) {
androidx.compose.material3.DropdownMenuItem(
- text = { Text(undoLabel?.let { "Undo $it" } ?: "Undo", color = c.text) }, enabled = canUndo,
+ text = { Text(undoLabel?.let { stringResource(R.string.viewer_undo_named, it) } ?: stringResource(R.string.common_undo), color = c.text) }, enabled = canUndo,
leadingIcon = { Icon(LucideIcons.Undo2, null, tint = c.icon) }, onClick = { open = false; onUndo() },
)
androidx.compose.material3.DropdownMenuItem(
- text = { Text(redoLabel?.let { "Redo $it" } ?: "Redo", color = c.text) }, enabled = canRedo,
+ text = { Text(redoLabel?.let { stringResource(R.string.viewer_redo_named, it) } ?: stringResource(R.string.common_redo), color = c.text) }, enabled = canRedo,
leadingIcon = { Icon(LucideIcons.Redo2, null, tint = c.icon) }, onClick = { open = false; onRedo() },
)
}
@@ -181,8 +184,9 @@ private fun ReadAloudSwitch(on: Boolean, onToggle: () -> Unit) {
val c = pdfColors
val knob by androidx.compose.animation.core.animateDpAsState(if (on) 22.dp else 2.dp, label = "knob")
val track by androidx.compose.animation.animateColorAsState(if (on) c.switchOn else c.switchOff, label = "track")
+ val readAloud = stringResource(R.string.common_tool_read_aloud)
Box(
- Modifier.size(width = 56.dp, height = 40.dp).clickable(role = Role.Switch, onClick = onToggle).semantics { contentDescription = "Read aloud" },
+ Modifier.size(width = 56.dp, height = 40.dp).clickable(role = Role.Switch, onClick = onToggle).semantics { contentDescription = readAloud },
contentAlignment = Alignment.CenterStart,
) {
Box(Modifier.size(width = 56.dp, height = 28.dp).background(track, androidx.compose.foundation.shape.RoundedCornerShape(14.dp))) {
@@ -214,6 +218,7 @@ fun SearchBar(
val c = pdfColors
val focus = remember { FocusRequester() }
val keyboard = LocalSoftwareKeyboardController.current
+ val findLabel = stringResource(R.string.viewer_find_in_document)
LaunchedEffect(Unit) { focus.requestFocus() }
Row(
Modifier.fillMaxWidth().height(TopBarHeight).background(c.surface).drawBehind {
@@ -222,7 +227,7 @@ fun SearchBar(
}.padding(bottom = 1.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, "Collapse", onClose, iconSize = 27.dp) }
+ Box(Modifier.width(56.dp), contentAlignment = Alignment.Center) { BarIcon(LucideIcons.ArrowLeft, stringResource(R.string.viewer_collapse), onClose, iconSize = 27.dp) }
Box(
Modifier.weight(1f).padding(horizontal = 8.dp).height(40.dp).drawBehind {
drawLine(c.textSecondary, Offset(0f, size.height - 1f), Offset(size.width, size.height - 1f), 1.5f)
@@ -240,18 +245,18 @@ fun SearchBar(
keyboard?.hide()
onSubmit()
}),
- modifier = Modifier.fillMaxWidth().focusRequester(focus).semantics { contentDescription = "Find in document" },
+ modifier = Modifier.fillMaxWidth().focusRequester(focus).semantics { contentDescription = findLabel },
decorationBox = { inner ->
Box(contentAlignment = Alignment.CenterStart) {
- if (query.isEmpty()) Text("Find in document", color = c.textSecondary, fontSize = 17.sp, fontStyle = FontStyle.Italic)
+ if (query.isEmpty()) Text(findLabel, color = c.textSecondary, fontSize = 17.sp, fontStyle = FontStyle.Italic)
inner()
}
},
)
}
- BarIcon(LucideIcons.X, "Clear", onClear, size = 40.dp, enabled = query.isNotEmpty())
- BarIcon(LucideIcons.ChevronLeft, "Previous", onPrev, enabled = canStep, size = 40.dp)
- BarIcon(LucideIcons.ChevronRight, "Next", onNext, enabled = canStep, size = 40.dp)
+ BarIcon(LucideIcons.X, stringResource(R.string.common_clear), onClear, size = 40.dp, enabled = query.isNotEmpty())
+ BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.viewer_find_previous), onPrev, enabled = canStep, size = 40.dp)
+ BarIcon(LucideIcons.ChevronRight, stringResource(R.string.viewer_find_next), onNext, enabled = canStep, size = 40.dp)
Spacer(Modifier.width(6.dp))
}
}
@@ -321,6 +326,7 @@ fun QuickToolbar(
) {
val c = pdfColors
var open by remember { androidx.compose.runtime.mutableStateOf(false) }
+ val handleLabel = stringResource(if (open) R.string.viewer_hide_shortcuts else R.string.viewer_show_shortcuts)
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxWidth().background(c.surface)) {
val slots = toolbarSlots(androidx.compose.ui.platform.LocalConfiguration.current.screenWidthDp)
val shown = tools.take(slots)
@@ -338,7 +344,7 @@ fun QuickToolbar(
Box(
Modifier.fillMaxWidth().height(QuickHandleHeight)
.clickable(enabled = chips.isNotEmpty(), role = Role.Button) { open = !open }
- .semantics { contentDescription = if (open) "Hide shortcuts" else "Show shortcuts" },
+ .semantics { contentDescription = handleLabel },
contentAlignment = Alignment.TopCenter,
) {
// measured on the dark bar; the light bar's grey is our own match
@@ -358,8 +364,8 @@ fun QuickToolbar(
.onSizeChanged { onExtraHeight((it.height - usual).coerceAtLeast(0)) },
horizontalArrangement = Arrangement.Center,
) {
- for (t in shown) QuickItem(t.icon, t.label, { onTool(t) }, subTools = t.subTools, width = itemW)
- QuickItem(LucideIcons.LayoutGrid, "More tools", onMoreTools, selected = moreToolsOpen, width = itemW)
+ for (t in shown) QuickItem(t.icon, stringResource(t.label), { onTool(t) }, subTools = t.subTools, width = itemW)
+ QuickItem(LucideIcons.LayoutGrid, stringResource(R.string.common_tool_more_tools), onMoreTools, selected = moreToolsOpen, width = itemW)
}
}
}
@@ -493,8 +499,9 @@ fun SubDivider() {
@Composable
fun ColorDot(color: androidx.compose.ui.graphics.Color, selected: Boolean, onClick: () -> Unit) {
val c = pdfColors
+ val colourLabel = stringResource(R.string.viewer_colour)
Box(
- Modifier.width(36.dp).height(54.dp).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = "Colour" },
+ Modifier.width(36.dp).height(54.dp).clickable(role = Role.Button, onClick = onClick).semantics { contentDescription = colourLabel },
contentAlignment = Alignment.Center,
) {
if (selected) Box(Modifier.requiredSize(40.dp).background(c.pressed, androidx.compose.foundation.shape.RoundedCornerShape(5.dp)))
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt
index 3d78eb7..73680eb 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerOverlays.kt
@@ -54,6 +54,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -63,6 +64,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.CommentInfo
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
@@ -99,6 +101,7 @@ fun BoxScope.Scrubber(doc: OpenDocument, visible: Boolean, top: Dp, bottom: Dp,
val fraction = (v.scrollY / maxScroll).coerceIn(0f, 1f)
val y = fraction * (track - pillH)
val label = "${v.currentPage + 1}"
+ val pageOf = stringResource(R.string.viewer_page_of, v.currentPage + 1, doc.pageCount)
Box(
Modifier
.align(Alignment.TopEnd)
@@ -122,7 +125,7 @@ fun BoxScope.Scrubber(doc: OpenDocument, visible: Boolean, top: Dp, bottom: Dp,
onDrag()
}
}
- .semantics { contentDescription = "Page ${v.currentPage + 1} of ${doc.pageCount}" },
+ .semantics { contentDescription = pageOf },
contentAlignment = Alignment.Center,
) {
Text(label, color = c.text, fontSize = 15.sp, modifier = Modifier.padding(start = 12.dp, end = 10.dp))
@@ -151,19 +154,19 @@ fun GoToPageDialog(doc: OpenDocument, onDismiss: () -> Unit) {
doc.viewer.goToPage(n - 1)
onDismiss()
}
- io.github.artcraftandroid.pdfcraft.ui.PdfDialog(onDismiss = onDismiss, title = "Go to page", confirm = "OK", onConfirm = ::go, confirmEnabled = text.isNotEmpty()) {
+ io.github.artcraftandroid.pdfcraft.ui.PdfDialog(onDismiss = onDismiss, title = stringResource(R.string.viewer_go_to_page), confirm = stringResource(R.string.common_ok), onConfirm = ::go, confirmEnabled = text.isNotEmpty()) {
Column {
- Text("1 - ${doc.pageCount}", color = c.textSecondary, fontSize = 14.sp)
+ Text(stringResource(R.string.viewer_go_to_page_range, doc.pageCount), color = c.textSecondary, fontSize = 14.sp)
Spacer(Modifier.height(10.dp))
io.github.artcraftandroid.pdfcraft.ui.PdfField(
- text, { text = it.filter(Char::isDigit).take(6); wrong = false }, "Enter page number", error = wrong, focus = focus,
+ text, { text = it.filter(Char::isDigit).take(6); wrong = false }, stringResource(R.string.viewer_enter_page_number), error = wrong, focus = focus,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = androidx.compose.ui.text.input.ImeAction.Go),
keyboardActions = KeyboardActions(onGo = { go() }),
)
if (previous != null) {
Spacer(Modifier.height(12.dp))
Text(
- "Back to page ${previous + 1}",
+ stringResource(R.string.viewer_back_to_page, previous + 1),
color = c.accent,
modifier = Modifier.clickable {
doc.viewer.goToPage(previous)
@@ -211,20 +214,20 @@ fun BoxScope.SelectionMenu(vm: AppViewModel, doc: OpenDocument, sel: Selection)
.background(c.menu, RoundedCornerShape(4.dp)),
) {
Row(Modifier.fillMaxWidth().height(61.dp), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically) {
- MenuIcon(LucideIcons.MessageSquarePlus, "Add comment", allowed) { vm.notePrompt = NotePrompt(doc, null, sel) }
- MenuIcon(LucideIcons.Highlighter, "Highlight", allowed) { markup(TextMarkup.Highlight) }
- MenuIcon(LucideIcons.Underline, "Underline", allowed) { markup(TextMarkup.Underline) }
- MenuIcon(LucideIcons.Strikethrough, "Strikethrough", allowed) { markup(TextMarkup.Strikethrough) }
+ MenuIcon(LucideIcons.MessageSquarePlus, stringResource(R.string.viewer_add_comment), allowed) { vm.notePrompt = NotePrompt(doc, null, sel) }
+ MenuIcon(LucideIcons.Highlighter, stringResource(R.string.common_tool_highlight), allowed) { markup(TextMarkup.Highlight) }
+ MenuIcon(LucideIcons.Underline, stringResource(R.string.common_tool_underline), allowed) { markup(TextMarkup.Underline) }
+ MenuIcon(LucideIcons.Strikethrough, stringResource(R.string.viewer_strikethrough), allowed) { markup(TextMarkup.Strikethrough) }
}
// an inset divider, then the rows with 8 dp above and below, as the reference's menu
Box(Modifier.fillMaxWidth().padding(horizontal = 4.dp).height(1.dp).background(c.divider))
Spacer(Modifier.height(8.dp))
- if (doc.writable || doc.source == null) MenuRow(LucideIcons.FilePenLine, "Edit text") {
+ if (doc.writable || doc.source == null) MenuRow(LucideIcons.FilePenLine, stringResource(R.string.viewer_edit_text)) {
doc.selection.clear()
vm.enterTool(doc, ViewerTool.Edit)
}
- if (doc.info.allowsCopying) MenuRow(LucideIcons.Copy, "Copy text") { vm.copySelection(doc) }
- MenuRow(LucideIcons.Volume2, "Read aloud") {
+ if (doc.info.allowsCopying) MenuRow(LucideIcons.Copy, stringResource(R.string.viewer_copy_text)) { vm.copySelection(doc) }
+ MenuRow(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud)) {
vm.startReadAloud(doc, fromSelection = true)
doc.selection.clear()
}
@@ -258,7 +261,7 @@ private fun MenuRow(icon: ImageVector, label: String, onClick: () -> Unit) {
fun NoteSheet(vm: AppViewModel, prompt: NotePrompt) {
val at = prompt.at
InlineNoteBar(
- hint = "Write a note",
+ hint = stringResource(R.string.viewer_write_note),
onDismiss = { vm.notePrompt = null },
onPost = { vm.postNote(prompt, it) },
onVoice = if (at != null && prompt.selection == null) ({ vm.notePrompt = null; vm.startVoice(prompt.doc, at) }) else null,
@@ -268,7 +271,7 @@ fun NoteSheet(vm: AppViewModel, prompt: NotePrompt) {
/** A reply being typed: the same bar, under the comment it answers. */
@Composable
fun ReplySheet(vm: AppViewModel, prompt: ReplyPrompt) {
- InlineNoteBar(hint = "Write a reply", onDismiss = { vm.replyPrompt = null }, onPost = { vm.postReply(prompt, it) }, onVoice = null)
+ InlineNoteBar(hint = stringResource(R.string.viewer_write_reply), onDismiss = { vm.replyPrompt = null }, onPost = { vm.postReply(prompt, it) }, onVoice = null)
}
/**
@@ -303,11 +306,11 @@ private fun InlineNoteBar(hint: String, onDismiss: () -> Unit, onPost: (String)
},
)
Row(Modifier.fillMaxWidth().height(48.dp).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- if (onVoice != null) BarIcon(LucideIcons.Mic, "Record voice comment", { onVoice() }, enabled = text.isBlank())
+ if (onVoice != null) BarIcon(LucideIcons.Mic, stringResource(R.string.voice_record_comment), { onVoice() }, enabled = text.isBlank())
Spacer(Modifier.weight(1f))
Box(Modifier.width(1.dp).height(21.dp).background(c.divider))
Spacer(Modifier.width(4.dp))
- BarIcon(LucideIcons.Send, "Post", { onPost(text) }, enabled = text.isNotBlank(), tint = c.toolAccent)
+ BarIcon(LucideIcons.Send, stringResource(R.string.common_post), { onPost(text) }, enabled = text.isNotBlank(), tint = c.toolAccent)
}
}
}
@@ -327,6 +330,7 @@ fun BoxScope.TextEntry(vm: AppViewModel, prompt: TextPrompt, onDone: (TextPrompt
val sizeSp = with(density) { (vm.toolPrefs.textSize * doc.viewer.pixelsPerPoint(prompt.at.page)).toSp() }
val keyboard = androidx.compose.ui.platform.LocalSoftwareKeyboardController.current
val currentText = androidx.compose.runtime.rememberUpdatedState(text)
+ val placeholder = stringResource(R.string.viewer_add_text)
// leaving the tool (Done) places the text too, after whatever else the tool had pending
androidx.compose.runtime.DisposableEffect(prompt) {
val before = doc.commitTool
@@ -358,7 +362,7 @@ fun BoxScope.TextEntry(vm: AppViewModel, prompt: TextPrompt, onDone: (TextPrompt
.focusRequester(focus),
decorationBox = { inner ->
Box {
- if (text.isEmpty()) Text("Add text", color = color.copy(alpha = 0.5f), fontSize = sizeSp)
+ if (text.isEmpty()) Text(placeholder, color = color.copy(alpha = 0.5f), fontSize = sizeSp)
inner()
}
},
@@ -383,6 +387,8 @@ fun BoxScope.SelectionHandles(doc: OpenDocument, sel: Selection) {
val size = with(density) { 20.dp.toPx() }
// the reference's handles: 20 dp drops in one blue in both themes
val blue = Color(0xFF4285F4)
+ val startLabel = stringResource(R.string.viewer_selection_start)
+ val endLabel = stringResource(R.string.viewer_selection_end)
for (start in listOf(true, false)) {
val r = (if (start) sel.startRect else sel.endRect) ?: continue
// the handle hangs from the line's bottom, at its outer edge
@@ -406,7 +412,7 @@ fun BoxScope.SelectionHandles(doc: OpenDocument, sel: Selection) {
doc.viewer.screenToPage(target, nearest = true)?.let { doc.selection.dragHandle(start, it) }
}
}
- .semantics { contentDescription = if (start) "Selection start" else "Selection end" },
+ .semantics { contentDescription = if (start) startLabel else endLabel },
) {
androidx.compose.foundation.Canvas(Modifier.fillMaxSize()) {
val rad = this.size.width / 2f
@@ -432,6 +438,7 @@ fun BoxScope.HorizontalScrubber(doc: OpenDocument, visible: Boolean, bottom: Dp,
val pillW = with(density) { 48.dp.toPx() }
val n = (doc.pageCount - 1).coerceAtLeast(1)
val x = if (dragging) dragX else v.currentPage.toFloat() / n * (track - pillW)
+ val pageOf = stringResource(R.string.viewer_page_of, v.currentPage + 1, doc.pageCount)
Box(Modifier.align(Alignment.CenterStart).fillMaxWidth().height(2.dp).background(c.divider))
Box(
Modifier
@@ -453,7 +460,7 @@ fun BoxScope.HorizontalScrubber(doc: OpenDocument, visible: Boolean, bottom: Dp,
onDrag()
}
}
- .semantics { contentDescription = "Page ${v.currentPage + 1} of ${doc.pageCount}" },
+ .semantics { contentDescription = pageOf },
contentAlignment = Alignment.Center,
) {
Text("${v.currentPage + 1}", color = c.text, fontSize = 15.sp)
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt
index 0892b98..285aeee 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt
@@ -58,9 +58,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
+import androidx.compose.ui.res.stringResource
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
+import io.github.artcraftandroid.pdfcraft.R
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.HintToast
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
@@ -336,9 +339,9 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
onShare = { vm.share(doc) },
onMore = { ctl.sheet = if (ctl.sheet == ViewerSheet.More) ViewerSheet.None else ViewerSheet.More },
moreOpen = ctl.sheet == ViewerSheet.More,
- title = if (ctl.tool == ViewerTool.Edit) "Edit PDF" else null,
- undoLabel = if (doc.localUndo != null) "Drawing" else doc.info.undo,
- redoLabel = if (doc.localUndo != null) "Drawing" else doc.info.redo,
+ title = if (ctl.tool == ViewerTool.Edit) stringResource(R.string.common_tool_edit_pdf) else null,
+ undoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.undo,
+ redoLabel = if (doc.localUndo != null) stringResource(R.string.viewer_undo_drawing) else doc.info.redo,
)
}
}
@@ -360,10 +363,10 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
onMoreTools = { ctl.sheet = if (ctl.sheet == ViewerSheet.MoreTools) ViewerSheet.None else ViewerSheet.MoreTools },
moreToolsOpen = ctl.sheet == ViewerSheet.MoreTools,
chips = listOf(
- QuickChip(if (vm.isStarred(doc)) "Unstar this file" else "Star this file", LucideIcons.Star, ToolHues.combine) { vm.toggleStar(doc) },
- QuickChip("Read aloud", LucideIcons.Headphones, ToolHues.read) { vm.startReadAloud(doc) },
- QuickChip("Create PDF", QuickTool.Create.icon, ToolHues.create) { vm.runQuickTool(doc, QuickTool.Create) },
- QuickChip("Organize pages", QuickTool.Organize.icon, ToolHues.organize) { vm.runQuickTool(doc, QuickTool.Organize) },
+ QuickChip(stringResource(if (vm.isStarred(doc)) R.string.viewer_unstar_file else R.string.viewer_star_file), LucideIcons.Star, ToolHues.combine) { vm.toggleStar(doc) },
+ QuickChip(stringResource(R.string.common_tool_read_aloud), LucideIcons.Headphones, ToolHues.read) { vm.startReadAloud(doc) },
+ QuickChip(stringResource(R.string.common_tool_create_pdf), QuickTool.Create.icon, ToolHues.create) { vm.runQuickTool(doc, QuickTool.Create) },
+ QuickChip(stringResource(R.string.common_tool_organize), QuickTool.Organize.icon, ToolHues.organize) { vm.runQuickTool(doc, QuickTool.Organize) },
),
onExtraHeight = { quickExtraPx = it },
)
@@ -403,9 +406,9 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {
vm.pageMenu?.takeIf { it.doc === doc }?.let { PageMenuView(vm, it) }
if (vm.imageSource?.first === doc) {
io.github.artcraftandroid.pdfcraft.ui.PdfSheet(onDismiss = { vm.imageSource = null }, dim = true) {
- io.github.artcraftandroid.pdfcraft.ui.SheetTitle("Add image")
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Images, "From photos", { vm.addImageFrom(camera = false) })
- io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Camera, "From camera", { vm.addImageFrom(camera = true) })
+ io.github.artcraftandroid.pdfcraft.ui.SheetTitle(stringResource(R.string.viewer_add_image))
+ io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Images, stringResource(R.string.viewer_image_from_photos), { vm.addImageFrom(camera = false) })
+ io.github.artcraftandroid.pdfcraft.ui.SheetRow(LucideIcons.Camera, stringResource(R.string.viewer_image_from_camera), { vm.addImageFrom(camera = true) })
Spacer(Modifier.height(12.dp))
}
}
@@ -438,14 +441,14 @@ fun edgeTap(x: Float, width: Float): Int {
private fun toolHint(tool: ViewerTool, markup: TextMarkup, doc: OpenDocument): String? = when (tool) {
ViewerTool.Markup -> when (markup) {
- TextMarkup.Highlight -> "Drag across the text to highlight it"
- TextMarkup.Underline -> "Drag across the text to underline it"
- TextMarkup.Strikethrough -> "Drag across the text to strike it through"
+ TextMarkup.Highlight -> text(R.string.viewer_hint_highlight)
+ TextMarkup.Underline -> text(R.string.viewer_hint_underline)
+ TextMarkup.Strikethrough -> text(R.string.viewer_hint_strikethrough)
}
- ViewerTool.Draw -> "Draw with one finger, scroll with two"
- ViewerTool.Comment -> "Tap where the comment goes"
- ViewerTool.Text -> "Tap to add text"
- ViewerTool.FillSign -> if (doc.info.fields > 0u) null else "Tap where you want to fill in text"
+ ViewerTool.Draw -> text(R.string.viewer_hint_draw)
+ ViewerTool.Comment -> text(R.string.viewer_hint_comment)
+ ViewerTool.Text -> text(R.string.viewer_hint_text)
+ ViewerTool.FillSign -> if (doc.info.fields > 0u) null else text(R.string.viewer_hint_fill_sign)
else -> null
}
@@ -614,11 +617,11 @@ private fun SuccessBannerView(b: io.github.artcraftandroid.pdfcraft.ui.SuccessBa
Icon(LucideIcons.CircleCheck, null, tint = Color.White, modifier = Modifier.padding(top = 2.dp).size(22.dp))
Spacer(Modifier.width(14.dp))
Text(b.text, color = Color.White, fontSize = 17.sp, lineHeight = 22.sp, modifier = Modifier.weight(1f))
- BarIcon(LucideIcons.X, "Close", onClose, tint = Color.White, size = 40.dp)
+ BarIcon(LucideIcons.X, stringResource(R.string.viewer_close), onClose, tint = Color.White, size = 40.dp)
}
b.undo?.let { undo ->
Text(
- "Undo", color = Color.White, fontSize = 17.sp, fontWeight = FontWeight.SemiBold,
+ stringResource(R.string.common_undo), color = Color.White, fontSize = 17.sp, fontWeight = FontWeight.SemiBold,
modifier = Modifier.align(Alignment.End).clickable { onClose(); undo() }.padding(horizontal = 24.dp, vertical = 12.dp),
)
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt
index 6f051f0..88d0f7c 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerSheets.kt
@@ -37,6 +37,7 @@ import androidx.compose.foundation.combinedClickable
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
@@ -45,9 +46,12 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.AttachmentInfo
import io.github.artcraftandroid.pdfcraft.core.CommentInfo
import io.github.artcraftandroid.pdfcraft.core.OutlineEntry
+import io.github.artcraftandroid.pdfcraft.plural
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.BarIcon
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
@@ -94,57 +98,60 @@ fun MoreSheet(vm: AppViewModel, doc: OpenDocument) {
Text(doc.title, color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
Spacer(Modifier.height(4.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
- Icon(LucideIcons.Smartphone, "Stored on this device", tint = c.icon, modifier = Modifier.size(16.dp))
+ Icon(LucideIcons.Smartphone, stringResource(R.string.sheet_stored_on_device), tint = c.icon, modifier = Modifier.size(16.dp))
Spacer(Modifier.width(6.dp))
- Text("PDF • ${modifiedLabel(doc.file.lastModified())}" + if (!doc.writable) " • Read-only" else "", color = c.text, fontSize = 13.sp)
+ Text(
+ "PDF • ${modifiedLabel(doc.file.lastModified(), stringResource(R.string.common_yesterday))}" + if (!doc.writable) " • " + stringResource(R.string.sheet_read_only) else "",
+ color = c.text, fontSize = 13.sp,
+ )
}
}
- BarIcon(LucideIcons.Printer, "Print", { close(); vm.print(doc) }, size = 40.dp)
- BarIcon(LucideIcons.Star, if (starred) "Remove the star" else "Add a star", { vm.toggleStar(doc) },
+ BarIcon(LucideIcons.Printer, stringResource(R.string.sheet_print), { close(); vm.print(doc) }, size = 40.dp)
+ BarIcon(LucideIcons.Star, stringResource(if (starred) R.string.sheet_remove_star else R.string.sheet_add_star), { vm.toggleStar(doc) },
tint = if (starred) Color(0xFFF5B800) else c.icon, size = 40.dp)
}
SheetDivider()
Column(Modifier.verticalScroll(scroll).padding(top = 5.dp)) {
- SheetRow(LucideIcons.Glasses, "View settings", { ctl.sheet = ViewerSheet.ViewSettings }, chevron = true)
- SheetRow(LucideIcons.LayoutGrid, "Pages", { close(); ctl.pagesOpen = true }, chevron = true)
- if (doc.info.attachments > 0u) SheetRow(LucideIcons.Paperclip, "Attachments", { ctl.sheet = ViewerSheet.Attachments }, chevron = true)
- SheetRow(LucideIcons.Bookmark, "Bookmarks & Table of Contents", { ctl.sheet = ViewerSheet.Bookmarks }, chevron = true)
- SheetRow(LucideIcons.MessagesSquare, "Comment List", { ctl.sheet = ViewerSheet.Comments }, chevron = true)
- SheetRow(LucideIcons.ShieldCheck, "Signatures", { ctl.sheet = ViewerSheet.Signatures }, chevron = true)
+ SheetRow(LucideIcons.Glasses, stringResource(R.string.sheet_view_settings), { ctl.sheet = ViewerSheet.ViewSettings }, chevron = true)
+ SheetRow(LucideIcons.LayoutGrid, stringResource(R.string.sheet_pages), { close(); ctl.pagesOpen = true }, chevron = true)
+ if (doc.info.attachments > 0u) SheetRow(LucideIcons.Paperclip, stringResource(R.string.sheet_attachments), { ctl.sheet = ViewerSheet.Attachments }, chevron = true)
+ SheetRow(LucideIcons.Bookmark, stringResource(R.string.sheet_bookmarks_contents), { ctl.sheet = ViewerSheet.Bookmarks }, chevron = true)
+ SheetRow(LucideIcons.MessagesSquare, stringResource(R.string.sheet_comment_list), { ctl.sheet = ViewerSheet.Comments }, chevron = true)
+ SheetRow(LucideIcons.ShieldCheck, stringResource(R.string.sign_signatures), { ctl.sheet = ViewerSheet.Signatures }, chevron = true)
SheetRow(
if (bookmarked) LucideIcons.BookmarkMinus else LucideIcons.BookmarkPlus,
- if (bookmarked) "Remove bookmark" else "Add bookmark",
+ stringResource(if (bookmarked) R.string.sheet_remove_bookmark else R.string.sheet_add_bookmark),
{ close(); vm.toggleBookmark(doc) },
)
- SheetRow(LucideIcons.Volume2, "Read aloud", { close(); vm.startReadAloud(doc) })
- SheetRow(LucideIcons.FilePenLine, "Edit PDF", { close(); vm.enterTool(doc, ViewerTool.Edit) })
+ SheetRow(LucideIcons.Volume2, stringResource(R.string.common_tool_read_aloud), { close(); vm.startReadAloud(doc) })
+ SheetRow(LucideIcons.FilePenLine, stringResource(R.string.common_tool_edit_pdf), { close(); vm.enterTool(doc, ViewerTool.Edit) })
GroupDivider()
- SheetRow(LucideIcons.FileOutput, "Export as...", { close(); vm.openExport(doc) })
- SheetRow(LucideIcons.FileArchive, "Compress PDF", { close(); vm.openCompress(doc) })
- SheetRow(LucideIcons.Combine, "Combine files", { close(); vm.openCombine(doc) })
- SheetRow(LucideIcons.FileLock2, "Set password", { close(); vm.openProtect(doc) })
- SheetRow(LucideIcons.FilePlus2, "Create PDF", { close(); vm.openCreate() })
+ SheetRow(LucideIcons.FileOutput, stringResource(R.string.sheet_export_as), { close(); vm.openExport(doc) })
+ SheetRow(LucideIcons.FileArchive, stringResource(R.string.common_tool_compress), { close(); vm.openCompress(doc) })
+ SheetRow(LucideIcons.Combine, stringResource(R.string.common_tool_combine), { close(); vm.openCombine(doc) })
+ SheetRow(LucideIcons.FileLock2, stringResource(R.string.common_tool_set_password), { close(); vm.openProtect(doc) })
+ SheetRow(LucideIcons.FilePlus2, stringResource(R.string.common_tool_create_pdf), { close(); vm.openCreate() })
if (doc.info.undo != null || doc.info.redo != null) {
GroupDivider()
- doc.info.undo?.let { SheetRow(LucideIcons.Undo2, "Undo $it", { close(); vm.undo(doc) }) }
- doc.info.redo?.let { SheetRow(LucideIcons.Redo2, "Redo $it", { close(); vm.redo(doc) }) }
+ doc.info.undo?.let { SheetRow(LucideIcons.Undo2, stringResource(R.string.sheet_undo_action, it), { close(); vm.undo(doc) }) }
+ doc.info.redo?.let { SheetRow(LucideIcons.Redo2, stringResource(R.string.sheet_redo_action, it), { close(); vm.redo(doc) }) }
}
GroupDivider()
- SheetRow(LucideIcons.Copy, "Save a copy", { close(); vm.saveCopyAs(doc) })
+ SheetRow(LucideIcons.Copy, stringResource(R.string.common_save_copy), { close(); vm.saveCopyAs(doc) })
Spacer(Modifier.height(8.dp))
}
}
}
-/** When the file was modified: the time today, "Yesterday", else the date. */
-internal fun modifiedLabel(t: Long, now: Long = System.currentTimeMillis()): String {
+/** When the file was modified: the time today, [yesterday] ("Yesterday"), else the date. */
+internal fun modifiedLabel(t: Long, yesterday: String, now: Long = System.currentTimeMillis()): String {
fun day(ms: Long) = java.util.Calendar.getInstance().apply { timeInMillis = ms }.let { it.get(java.util.Calendar.YEAR) * 400 + it.get(java.util.Calendar.DAY_OF_YEAR) }
val d = Date(t)
val today = day(now)
- val yesterday = day(now - 24L * 3600 * 1000)
+ val dayBefore = day(now - 24L * 3600 * 1000)
return when (day(t)) {
today -> DateFormat.getTimeInstance(DateFormat.SHORT).format(d)
- yesterday -> "Yesterday"
+ dayBefore -> yesterday
else -> DateFormat.getDateInstance(DateFormat.MEDIUM).format(d)
}
}
@@ -154,21 +161,21 @@ internal fun modifiedLabel(t: Long, now: Long = System.currentTimeMillis()): Str
fun ViewSettingsSheet(vm: AppViewModel, doc: OpenDocument) {
val ctl = doc.controller
PdfSheet(onDismiss = { ctl.sheet = ViewerSheet.None }) {
- SheetBackHeader("View settings", onBack = { ctl.sheet = ViewerSheet.More })
- SheetRow(LucideIcons.GalleryVerticalEnd, "Continuous", {
+ SheetBackHeader(stringResource(R.string.sheet_view_settings), onBack = { ctl.sheet = ViewerSheet.More })
+ SheetRow(LucideIcons.GalleryVerticalEnd, stringResource(R.string.sheet_continuous), {
vm.setPageMode(doc, PageMode.Continuous)
ctl.sheet = ViewerSheet.None
}, checked = doc.viewer.mode == PageMode.Continuous && !vm.readingMode)
- SheetRow(LucideIcons.File, "Single page", {
+ SheetRow(LucideIcons.File, stringResource(R.string.sheet_single_page), {
vm.setPageMode(doc, PageMode.SinglePage)
ctl.sheet = ViewerSheet.None
}, checked = doc.viewer.mode == PageMode.SinglePage && !vm.readingMode)
- SheetRow(LucideIcons.BookOpenText, "Reading Mode", {
+ SheetRow(LucideIcons.BookOpenText, stringResource(R.string.sheet_reading_mode), {
ctl.sheet = ViewerSheet.None
vm.openReadingMode(doc)
}, checked = vm.readingMode)
GroupDivider()
- SheetRow(LucideIcons.Moon, "Night Mode", { vm.setNightMode(doc, !ctl.nightMode); ctl.sheet = ViewerSheet.None }) {
+ SheetRow(LucideIcons.Moon, stringResource(R.string.sheet_night_mode), { vm.setNightMode(doc, !ctl.nightMode); ctl.sheet = ViewerSheet.None }) {
PdfSwitch(ctl.nightMode, { vm.setNightMode(doc, it); ctl.sheet = ViewerSheet.None })
}
Spacer(Modifier.height(24.dp))
@@ -188,9 +195,9 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
var parent by remember { mutableStateOf(-1) }
var renaming by remember { mutableStateOf<Int?>(null) }
PdfSheet(onDismiss = { ctl.sheet = ViewerSheet.None }, maxHeightFraction = 0.69f, fill = true) {
- SheetBackHeader("Bookmarks & Table of Contents", onBack = { ctl.sheet = ViewerSheet.More })
+ SheetBackHeader(stringResource(R.string.sheet_bookmarks_contents), onBack = { ctl.sheet = ViewerSheet.More })
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp)) {
- listOf("Contents", "Bookmarks").forEachIndexed { i, label ->
+ listOf(stringResource(R.string.sheet_tab_contents), stringResource(R.string.sheet_tab_bookmarks)).forEachIndexed { i, label ->
Column(
Modifier.weight(1f).clickable(role = Role.Tab) { tab = i }.padding(top = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally,
@@ -206,7 +213,7 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
val all = outline
when {
all == null -> Text("…", color = c.textSecondary, modifier = Modifier.padding(20.dp))
- all.isEmpty() -> Text("This document has no table of contents.", color = c.textSecondary, fontSize = 15.sp, modifier = Modifier.padding(20.dp))
+ all.isEmpty() -> Text(stringResource(R.string.sheet_no_contents), color = c.textSecondary, fontSize = 15.sp, modifier = Modifier.padding(20.dp))
else -> {
val level = if (parent < 0) 0u else all[parent].level + 1u
val start = parent + 1
@@ -224,7 +231,7 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
if (parent >= 0) {
item {
Row(Modifier.fillMaxWidth().clickable { parent = parentOf(all, parent) }.padding(horizontal = 12.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(LucideIcons.ArrowLeft, "Up a level", tint = c.icon, modifier = Modifier.size(22.dp))
+ Icon(LucideIcons.ArrowLeft, stringResource(R.string.sheet_up_level), tint = c.icon, modifier = Modifier.size(22.dp))
Spacer(Modifier.width(16.dp))
Text(all[parent].title, color = c.text, fontWeight = FontWeight.SemiBold, fontSize = 16.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
@@ -243,7 +250,7 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(e.title, color = c.text, fontSize = 16.sp, modifier = Modifier.weight(1f).padding(vertical = 10.dp), maxLines = 3, overflow = TextOverflow.Ellipsis)
- if (e.children > 0u) BarIcon(LucideIcons.ChevronRight, "Expand ${e.title}", { parent = i })
+ if (e.children > 0u) BarIcon(LucideIcons.ChevronRight, stringResource(R.string.sheet_expand_entry, e.title), { parent = i })
}
}
}
@@ -255,9 +262,9 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
Column(Modifier.fillMaxWidth().padding(32.dp), horizontalAlignment = Alignment.CenterHorizontally) {
Icon(LucideIcons.Bookmark, null, tint = c.textSecondary, modifier = Modifier.size(40.dp))
Spacer(Modifier.height(12.dp))
- Text("Your bookmarks show up here.", color = c.text, fontSize = 15.sp)
+ Text(stringResource(R.string.sheet_bookmarks_empty), color = c.text, fontSize = 15.sp)
Spacer(Modifier.height(16.dp))
- Text("Add a bookmark", color = c.accent, fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
+ Text(stringResource(R.string.sheet_add_a_bookmark), color = c.accent, fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
modifier = Modifier.clickable { vm.toggleBookmark(doc) }.padding(8.dp))
}
} else {
@@ -276,9 +283,9 @@ fun BookmarksSheet(vm: AppViewModel, doc: OpenDocument) {
onRename = { renaming = i },
onRenamed = { name ->
renaming = null
- if (name.isBlank()) vm.tell("That name can't be used.") else vm.bookmarks.rename(doc, b, name.trim())
+ if (name.isBlank()) vm.tell(text(R.string.sheet_bookmark_name_invalid)) else vm.bookmarks.rename(doc, b, name.trim())
},
- onDelete = { vm.bookmarks.remove(doc, b); vm.tell("${b.name} bookmark removed") },
+ onDelete = { vm.bookmarks.remove(doc, b); vm.tell(text(R.string.sheet_bookmark_removed, b.name)) },
onDeleteAll = { vm.confirmDeleteAllBookmarks = doc },
)
}
@@ -320,14 +327,14 @@ private fun UserBookmarkRow(name: String, page: Int, renaming: Boolean, onOpen:
} else {
Column(Modifier.weight(1f)) {
Text(name, color = c.text, fontSize = 16.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
- Text("Page ${page + 1}", color = c.textSecondary, fontSize = 13.sp)
+ Text(stringResource(R.string.sheet_page, page + 1), color = c.textSecondary, fontSize = 13.sp)
}
}
Box {
androidx.compose.material3.DropdownMenu(expanded = menu, onDismissRequest = { menu = false }, containerColor = c.menu) {
- androidx.compose.material3.DropdownMenuItem(text = { Text("Rename", color = c.text) }, onClick = { menu = false; onRename() })
- androidx.compose.material3.DropdownMenuItem(text = { Text("Delete", color = c.text) }, onClick = { menu = false; onDelete() })
- androidx.compose.material3.DropdownMenuItem(text = { Text("Delete all", color = c.text) }, onClick = { menu = false; onDeleteAll() })
+ androidx.compose.material3.DropdownMenuItem(text = { Text(stringResource(R.string.common_rename), color = c.text) }, onClick = { menu = false; onRename() })
+ androidx.compose.material3.DropdownMenuItem(text = { Text(stringResource(R.string.common_delete), color = c.text) }, onClick = { menu = false; onDelete() })
+ androidx.compose.material3.DropdownMenuItem(text = { Text(stringResource(R.string.sheet_delete_all), color = c.text) }, onClick = { menu = false; onDeleteAll() })
}
}
}
@@ -346,10 +353,10 @@ fun AttachmentsSheet(vm: AppViewModel, doc: OpenDocument) {
// the reference sets this title up level with the handle and its back arrow below it
Box(Modifier.fillMaxWidth().height(44.dp)) {
Text(
- "Attachments", color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold,
+ stringResource(R.string.sheet_attachments), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold,
modifier = Modifier.align(Alignment.TopStart).offset(x = 92.dp, y = (-12).dp),
)
- BarIcon(LucideIcons.ChevronLeft, "Back", { ctl.sheet = ViewerSheet.More }, modifier = Modifier.align(Alignment.TopStart).offset(x = 3.dp, y = (-5).dp))
+ BarIcon(LucideIcons.ChevronLeft, stringResource(R.string.common_back), { ctl.sheet = ViewerSheet.More }, modifier = Modifier.align(Alignment.TopStart).offset(x = 3.dp, y = (-5).dp))
}
LazyColumn {
items(files) { a ->
@@ -368,9 +375,9 @@ fun AttachmentsSheet(vm: AppViewModel, doc: OpenDocument) {
}
fun formatSize(bytes: Long): String = when {
- bytes < 1024 -> "$bytes bytes"
- bytes < 1024 * 1024 -> "%.1f KB".format(bytes / 1024.0)
- else -> "%.1f MB".format(bytes / 1024.0 / 1024.0)
+ bytes < 1024 -> plural(R.plurals.sheet_size_bytes, bytes.toInt(), bytes)
+ bytes < 1024 * 1024 -> text(R.string.sheet_size_kb, bytes / 1024.0)
+ else -> text(R.string.sheet_size_mb, bytes / 1024.0 / 1024.0)
}
/** `D:20261011143000+02'00'` (or plain text) as a short local date. */
@@ -449,7 +456,7 @@ fun MoreToolsSheet(vm: AppViewModel, doc: OpenDocument) {
CustomizeToolbar(vm) { customizing = false }
return@PdfSheet
}
- SheetTitle("More tools")
+ SheetTitle(stringResource(R.string.common_tool_more_tools))
val slots = toolbarSlots(androidx.compose.ui.platform.LocalConfiguration.current.screenWidthDp)
val prefs = vm.quickToolbar
val tools = prefs.bar.drop(slots) + prefs.grid
@@ -460,7 +467,7 @@ fun MoreToolsSheet(vm: AppViewModel, doc: OpenDocument) {
tools.chunked(6).forEach { row ->
Row(verticalAlignment = Alignment.Top) {
row.forEach { t ->
- ToolTile(t.icon, t.title, t.hue, Modifier.width(cell)) {
+ ToolTile(t.icon, stringResource(t.title), t.hue, Modifier.width(cell)) {
ctl.sheet = ViewerSheet.None
vm.runQuickTool(doc, t)
}
@@ -477,7 +484,7 @@ fun MoreToolsSheet(vm: AppViewModel, doc: OpenDocument) {
.clickable(role = Role.Button) { customizing = true },
contentAlignment = Alignment.Center,
) {
- Text("Customize toolbar", color = pdfColors.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
+ Text(stringResource(R.string.sheet_customize_toolbar), color = pdfColors.text, fontSize = 15.sp, fontWeight = FontWeight.SemiBold)
}
Spacer(Modifier.height(16.dp))
}
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt
index 9a34e6f..0b62395 100644
--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt
+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/VoiceSheet.kt
@@ -34,13 +34,16 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.github.artcraftandroid.pdfcraft.R
import io.github.artcraftandroid.pdfcraft.core.CommentInfo
+import io.github.artcraftandroid.pdfcraft.text
import io.github.artcraftandroid.pdfcraft.ui.AppViewModel
import io.github.artcraftandroid.pdfcraft.ui.LucideIcons
import io.github.artcraftandroid.pdfcraft.ui.OpenDocument
@@ -72,14 +75,14 @@ fun VoiceSheet(vm: AppViewModel, prompt: VoicePrompt) {
player.release()
if (!recorder.start()) {
vm.voicePrompt = null
- vm.tell("The microphone couldn't be started. Another app may be using it.")
+ vm.tell(text(R.string.voice_mic_failed))
}
}
fun stop() = scope.launch {
recorder.stop()
recorded = player.load(file)
- if (!recorded) vm.tell("Nothing was recorded.")
+ if (!recorded) vm.tell(text(R.string.voice_nothing_recorded))
}
fun close() {
@@ -103,27 +106,27 @@ fun VoiceSheet(vm: AppViewModel, prompt: VoicePrompt) {
LaunchedEffect(recorder.elapsedMs >= VOICE_WARN_MS) {
if (recorder.elapsedMs >= VOICE_WARN_MS && !warned) {
warned = true
- vm.tell("Recording stops at 30 minutes.")
+ vm.tell(text(R.string.voice_limit_warning))
}
}
DisposableEffect(prompt) { onDispose { player.release() } }
PdfSheet(onDismiss = ::close, dim = true) {
Row(Modifier.fillMaxWidth().padding(start = 20.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
- Text("Record voice comment", color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
+ Text(stringResource(R.string.voice_record_comment), color = c.text, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f))
TextButton(
onClick = {
player.release()
vm.postVoice(prompt, file)
},
enabled = recorded,
- ) { Text("Post", color = if (recorded) c.accent else c.textSecondary, fontWeight = FontWeight.SemiBold) }
+ ) { Text(stringResource(R.string.common_post), color = if (recorded) c.accent else c.textSecondary, fontWeight = FontWeight.SemiBold) }
}
Text(
when {
- recorder.recording -> "Recording…"
- player.playing -> "Playing…"
- recorded -> "Listen to your recording before posting it"
+ recorder.recording -> stringResource(R.string.voice_recording)
+ player.playing -> stringResource(R.string.voice_playing)
+ recorded -> stringResource(R.string.voice_listen_first)
else -> ""
},
color = c.textSecondary, fontSize = 14.sp, modifier = Modifier.padding(horizontal = 20.dp),
@@ -134,7 +137,7 @@ fun VoiceSheet(vm: AppViewModel, prompt: VoicePrompt) {
Spacer(Modifier.height(8.dp))
Text(clock(recorder.elapsedMs), color = c.text, fontSize = 15.sp, modifier = Modifier.align(Alignment.CenterHorizontally))
Spacer(Modifier.height(12.dp))
- RoundButton(LucideIcons.Square, "Stop recording", c.red, Modifier.align(Alignment.CenterHorizontally)) { if (recorder.recording) stop() }
+ RoundButton(LucideIcons.Square, stringResource(R.string.voice_stop_recording), c.red, Modifier.align(Alignment.CenterHorizontally)) { if (recorder.recording) stop() }
} else {
val progress = if (player.durationMs > 0) player.positionMs / player.durationMs.toFloat() else 0f
Waveform(recorder.levels, progress, c.accent, c.divider, Modifier.padding(horizontal = 20.dp).pointerInput(Unit) {
@@ -144,13 +147,13 @@ fun VoiceSheet(vm: AppViewModel, prompt: VoicePrompt) {
Text("${clock(player.positionMs.toLong())} / ${clock(player.durationMs.toLong())}", color = c.text, fontSize = 15.sp, modifier = Modifier.align(Alignment.CenterHorizontally))
Spacer(Modifier.height(12.dp))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically) {
- LabelledButton(LucideIcons.Trash2, "Delete") {
+ LabelledButton(LucideIcons.Trash2, stringResource(R.string.common_delete)) {
player.release()
file.delete()
vm.voicePrompt = null
}
- RoundButton(if (player.playing) LucideIcons.Pause else LucideIcons.Play, if (player.playing) "Pause" else "Play", c.accent) { player.toggle() }
- LabelledButton(LucideIcons.RotateCcw, "Record again") { begin() }
+ RoundButton(if (player.playing) LucideIcons.Pause else LucideIcons.Play, stringResource(if (player.playing) R.string.common_pause else R.string.common_play), c.accent) { player.toggle() }
+ LabelledButton(LucideIcons.RotateCcw, stringResource(R.string.voice_record_again)) { begin() }
}
}
Spacer(Modifier.height(20.dp))
@@ -218,14 +221,15 @@ fun VoiceCommentPlayer(vm: AppViewModel, doc: OpenDocument, comment: CommentInfo
ready = f != null && player.load(f)
}
DisposableEffect(comment.page, comment.index) { onDispose { player.release() } }
+ val playLabel = stringResource(if (player.playing) R.string.common_pause else R.string.voice_play_audio)
Row(Modifier.fillMaxWidth().padding(vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) {
if (ready == false) {
- Text("This recording can't be played.", color = c.textSecondary, fontSize = 14.sp)
+ Text(stringResource(R.string.voice_cannot_play), color = c.textSecondary, fontSize = 14.sp)
return@Row
}
Box(
Modifier.size(40.dp).clip(CircleShape).background(c.accent).clickable(enabled = ready == true, role = Role.Button) { player.toggle() }
- .semantics { contentDescription = if (player.playing) "Pause" else "Play audio" },
+ .semantics { contentDescription = playLabel },
contentAlignment = Alignment.Center,
) { Icon(if (player.playing) LucideIcons.Pause else LucideIcons.Play, null, tint = Color.White, modifier = Modifier.size(20.dp)) }
Spacer(Modifier.width(12.dp))
@@ -246,11 +250,11 @@ fun VoiceCommentPlayer(vm: AppViewModel, doc: OpenDocument, comment: CommentInfo
@Composable
fun MicRationaleDialog(vm: AppViewModel) {
io.github.artcraftandroid.pdfcraft.ui.PdfDialog(
- onDismiss = { vm.dismissMicRationale(false) }, title = "Use the microphone?",
- confirm = "Open settings", onConfirm = { vm.dismissMicRationale(true) },
- dismiss = "Not now", onDismissButton = { vm.dismissMicRationale(false) },
- ) { Text("PdfCraft needs the microphone to record voice comments. You can allow it in the app's settings.", color = io.github.artcraftandroid.pdfcraft.ui.pdfColors.text, fontSize = 14.sp) }
+ onDismiss = { vm.dismissMicRationale(false) }, title = stringResource(R.string.voice_mic_title),
+ confirm = stringResource(R.string.voice_open_settings), onConfirm = { vm.dismissMicRationale(true) },
+ dismiss = stringResource(R.string.voice_not_now), onDismissButton = { vm.dismissMicRationale(false) },
+ ) { Text(stringResource(R.string.voice_mic_rationale), color = io.github.artcraftandroid.pdfcraft.ui.pdfColors.text, fontSize = 14.sp) }
}
/** A comment's type as the lists name it (a Sound comment is a voice comment here). */
-fun commentKindLabel(c: CommentInfo): String = if (c.subtype == "Sound") "Voice comment" else c.kind
+fun commentKindLabel(c: CommentInfo): String = if (c.subtype == "Sound") text(R.string.voice_comment_kind) else c.kind
diff --git a/apps/pdfcraft-android/android/app/src/main/res/resources.properties b/apps/pdfcraft-android/android/app/src/main/res/resources.properties
new file mode 100644
index 0000000..467b3ef
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/main/res/resources.properties
@@ -0,0 +1 @@
+unqualifiedResLocale=en-US
diff --git a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml
index 0450ca5..60647f0 100644
--- a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml
+++ b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml
@@ -1,5 +1,1162 @@
<?xml version="1.0" encoding="utf-8"?>
+<!--
+ PdfCraft's text, in US English.
+
+ To translate PdfCraft: copy this file to res/values-<language>/strings.xml (values-es for
+ Spanish, values-pt-rBR for Brazilian Portuguese, values-zh-rCN for simplified Chinese) and
+ translate the text between the tags. Keep each name, every placeholder (%1$s, %2$d: the
+ number says which value goes there, so a translation may move them), escapes such as \' and
+ \n, and the "one" and "other" items of plurals (add the items your language needs: zero, two,
+ few, many). A string left out shows in English.
+-->
<resources>
- <string name="app_name">PdfCraft</string>
+ <string name="app_name" translatable="false">PdfCraft</string>
<string name="open_with">Open in PdfCraft</string>
+
+ <!-- Shared: buttons and words used on many screens -->
+ <string name="common_ok">OK</string>
+ <string name="common_cancel">Cancel</string>
+ <string name="common_done">Done</string>
+ <string name="common_save">Save</string>
+ <string name="common_save_copy">Save a copy</string>
+ <string name="common_delete">Delete</string>
+ <string name="common_back">Back</string>
+ <string name="common_share">Share</string>
+ <string name="common_open">Open</string>
+ <string name="common_create">Create</string>
+ <string name="common_clear">Clear</string>
+ <string name="common_rename">Rename</string>
+ <string name="common_undo">Undo</string>
+ <string name="common_redo">Redo</string>
+ <string name="common_play">Play</string>
+ <string name="common_pause">Pause</string>
+ <string name="common_sign">Sign</string>
+ <string name="common_post">Post</string>
+ <string name="common_more_options">More options</string>
+ <string name="common_password">Password</string>
+ <string name="common_your_name">Your name</string>
+ <string name="common_file_name">File name</string>
+ <string name="common_today">Today</string>
+ <string name="common_yesterday">Yesterday</string>
+
+ <!-- Shared: tool names -->
+ <string name="common_tool_edit_pdf">Edit PDF</string>
+ <string name="common_tool_read_aloud">Read aloud</string>
+ <string name="common_tool_combine">Combine files</string>
+ <string name="common_tool_set_password">Set password</string>
+ <string name="common_tool_organize">Organize pages</string>
+ <string name="common_tool_create_pdf">Create PDF</string>
+ <string name="common_tool_compress">Compress PDF</string>
+ <string name="common_tool_export">Export PDF</string>
+ <string name="common_tool_crop">Crop pages</string>
+ <string name="common_tool_fill_sign">Fill &amp; Sign</string>
+ <string name="common_tool_scan">Scan</string>
+ <string name="common_tool_more_tools">More tools</string>
+ <string name="common_tool_recognize_text">Recognize text</string>
+ <string name="common_tool_comment">Comment</string>
+ <string name="common_tool_highlight">Highlight</string>
+ <string name="common_tool_underline">Underline</string>
+ <string name="common_tool_draw">Draw</string>
+ <string name="common_tool_sign_digital_id">Sign with a digital ID</string>
+
+ <!-- Shared: messages -->
+ <string name="common_file_unreadable">The file couldn\'t be read.</string>
+ <string name="common_wrong_password">The password is incorrect.</string>
+
+ <!-- ================================================================== -->
+ <!-- Home, Files, Tools and Search, the tool screens, settings and shared dialogs -->
+ <!-- ================================================================== -->
+ <!-- Home: the bottom bar's tabs (also the Files and Tools screens' titles) -->
+ <string name="home_tab_home">Home</string>
+ <string name="home_tab_files">Files</string>
+ <string name="home_tab_tools">Tools</string>
+ <string name="home_tab_search">Search</string>
+
+ <!-- Home: header, welcome and the file lists -->
+ <string name="home_settings">Settings</string>
+ <string name="home_welcome">Welcome</string>
+ <string name="home_welcome_back">Welcome back</string>
+ <string name="home_start_with_tool">Start with a tool</string>
+ <!-- Tabs over Home's file list -->
+ <string name="home_list_recent">Recent</string>
+ <string name="home_list_starred">Starred</string>
+ <string name="home_list_on_device">On device</string>
+ <string name="home_list_view">List view</string>
+ <string name="home_grid_view">Grid view</string>
+ <string name="home_clear_recent">Clear recent</string>
+ <string name="home_sort_by_name">Sort by name</string>
+ <string name="home_sort_by_date">Sort by date</string>
+ <string name="home_other_files">Other files on this phone</string>
+ <string name="home_open_file">Open file</string>
+ <string name="home_new_scan">New scan</string>
+
+ <!-- Home: empty lists -->
+ <string name="home_no_recent_title">No recent files</string>
+ <string name="home_no_recent_body">Files you open will appear here.</string>
+ <string name="home_no_starred_title">No starred files</string>
+ <string name="home_no_starred_body">Star a file from its menu to find it here quickly.</string>
+ <string name="home_device_files_title">Files on your device</string>
+ <string name="home_device_files_body">Choose folders to list PDFs from, such as Documents or a folder inside Download. Files you open from anywhere stay in Recent.</string>
+ <!-- On this device, before any folder is added: the longer explanation -->
+ <string name="home_device_files_body_long">Choose folders to list PDFs from, such as Documents or a folder inside Download (Android doesn\'t let apps list the whole Download folder). PdfCraft sees only the folders you choose, and files you open from anywhere stay in Recent.</string>
+ <string name="home_no_pdfs_title">No PDFs in your folders</string>
+ <string name="home_no_pdfs_body">PDFs in the folders you added will appear here.</string>
+ <string name="home_add_folder">Add a folder</string>
+
+ <!-- Home: a file's row, and when it was last opened -->
+ <string name="home_just_now">Just now</string>
+ <!-- Accessibility label of the star icon on a starred file -->
+ <string name="home_starred_description">Starred</string>
+ <!-- Accessibility label of the location icon; %1$s is the folder the file is in -->
+ <string name="home_stored_on">Stored on %1$s</string>
+ <!-- Accessibility label of a file's menu button; %1$s is the file name -->
+ <string name="home_more_options_for">More options for %1$s</string>
+
+ <!-- Home: ticked files -->
+ <string name="home_clear_selection">Clear selection</string>
+ <plurals name="home_files_selected">
+ <item quantity="one">%d file selected</item>
+ <item quantity="other">%d files selected</item>
+ </plurals>
+ <string name="home_remove_from_recent">Remove from recent</string>
+ <plurals name="home_delete_files_title">
+ <item quantity="one">Delete %d file?</item>
+ <item quantity="other">Delete %d files?</item>
+ </plurals>
+ <string name="home_delete_files_body">They are removed from this phone.</string>
+ <string name="home_clear_recent_title">Clear recent files?</string>
+ <string name="home_clear_recent_body">The list of recent files is cleared. The files themselves stay where they are.</string>
+
+ <!-- A file's menu sheet -->
+ <!-- Opens Export PDF for this file; the three dots mean more choices follow -->
+ <string name="home_export_as">Export as...</string>
+ <string name="home_print">Print</string>
+ <string name="home_open_with">Open with</string>
+ <!-- Verb: add the file to Starred -->
+ <string name="home_star">Star</string>
+ <!-- Verb: take the file off Starred -->
+ <string name="home_unstar">Unstar</string>
+ <!-- Verb: make a copy of the file next to it -->
+ <string name="home_duplicate">Duplicate</string>
+ <string name="home_enter_name">Enter name</string>
+ <string name="home_delete_file_title">Delete file?</string>
+ <!-- %1$s is the file name -->
+ <string name="home_delete_file_body">Are you sure you want to permanently delete \'%1$s\'?</string>
+
+ <!-- Files tab -->
+ <string name="home_on_this_device">On this device</string>
+ <string name="home_photos">Photos</string>
+ <string name="home_look_in_other_folders">Look in other folders</string>
+ <!-- Verb: look for PDFs again -->
+ <string name="home_refresh">Refresh</string>
+ <!-- %1$s is the name of a folder the user added -->
+ <string name="home_stop_listing">Stop listing %1$s</string>
+ <string name="home_looking_for_pdfs">Looking for PDFs…</string>
+ <!-- Heading over files at the top of the phone's storage, in capitals like the folder headings -->
+ <string name="home_internal_storage">INTERNAL STORAGE</string>
+
+ <!-- Tools tab: categories -->
+ <string name="home_category_all">All</string>
+ <!-- Category of tools for reading PDFs -->
+ <string name="home_category_read">Read</string>
+ <!-- Category of tools that make new PDFs -->
+ <string name="home_category_create">Create</string>
+ <!-- Category of tools that change PDFs -->
+ <string name="home_category_edit">Edit</string>
+ <!-- Category of tools that turn PDFs into other files -->
+ <string name="home_category_convert">Convert</string>
+
+ <!-- Tools tab: tool names and one line about each -->
+ <string name="home_tool_add_comment">Add comment</string>
+ <string name="home_about_fill_sign">Fill in forms and sign them</string>
+ <string name="home_about_comment">Comment, highlight and draw</string>
+ <string name="home_about_read_aloud">Listen to a PDF</string>
+ <string name="home_about_create">Turn images and text into PDFs</string>
+ <string name="home_about_scan">Scan paper with the camera</string>
+ <string name="home_about_combine">Join several files into one PDF</string>
+ <string name="home_about_organize">Reorder, rotate, delete and insert pages</string>
+ <string name="home_about_crop">Trim margins or change page size</string>
+ <string name="home_about_edit">Change the text and pictures</string>
+ <string name="home_about_compress">Make a PDF smaller</string>
+ <string name="home_about_export">Save a PDF as a document, spreadsheet, slides or images</string>
+ <string name="home_about_protect">Protect a PDF with a password</string>
+
+ <!-- Search tab -->
+ <string name="home_search_your_files">Search your files</string>
+ <string name="home_search_empty_body">Find PDFs on this phone by name.</string>
+ <string name="home_recent_searches">Recent searches</string>
+ <!-- Accessibility label; %1$s is a past search -->
+ <string name="home_remove_search">Remove %1$s</string>
+ <plurals name="home_search_results">
+ <item quantity="one">%d result on this device</item>
+ <item quantity="other">%d results on this device</item>
+ </plurals>
+ <!-- Search result order -->
+ <string name="home_sort_relevant">Most relevant</string>
+ <string name="home_sort_name_az">Name A→Z</string>
+ <string name="home_sort_name_za">Name Z→A</string>
+ <string name="home_sort_oldest">Least recently modified</string>
+ <string name="home_sort_newest">Most recently modified</string>
+ <string name="home_no_results">No results</string>
+ <string name="home_no_results_body">Check the spelling, or try a shorter name.</string>
+
+ <!-- Settings -->
+ <string name="home_about_app">About PdfCraft</string>
+ <string name="home_preferences">Preferences</string>
+ <string name="home_help_support">Help &amp; Support</string>
+ <string name="home_help">Help</string>
+ <string name="home_report_problem">Report a problem or request a feature</string>
+ <string name="home_leaving_title">Leaving PdfCraft</string>
+ <string name="home_continue">Continue</string>
+ <string name="home_leaving_body">This opens a web page in your browser.</string>
+
+ <!-- Settings: Preferences -->
+ <string name="home_section_notifications">Notifications</string>
+ <string name="home_no_notifications">PdfCraft doesn\'t send notifications.</string>
+ <string name="home_section_suggestions">Auto-suggestions</string>
+ <string name="home_offer_suggestions">Offer words you used before when filling in forms</string>
+ <string name="home_clear_suggestions">Clear suggestions</string>
+ <!-- Section heading and dialog title (also asked the first time a comment is made) -->
+ <string name="home_author_title">Your name on comments</string>
+ <string name="home_author_hint">Tap to enter your name, to show on your comments</string>
+ <string name="home_section_screen">Screen setting</string>
+ <string name="home_keep_screen_on">Keep the screen on</string>
+ <string name="home_keep_screen_on_body">Keeps the screen on while you read, for up to 30 minutes without a touch.</string>
+ <string name="home_section_keyboard">Keyboard</string>
+ <string name="home_keyboard_shortcuts">Keyboard shortcuts</string>
+ <!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard -->
+ <string name="home_keyboard_shortcuts_body">With a keyboard connected: N or Page Down for the next page, P or Page Up for the previous one, the arrow keys to scroll, Ctrl+P to print, Ctrl and + or − to zoom.</string>
+
+ <!-- Settings: About PdfCraft -->
+ <string name="home_section_about">About</string>
+ <!-- %1$s is the app's version, %2$s the engine's version -->
+ <string name="home_version">Version %1$s (engine %2$s)</string>
+ <string name="home_version_copied">Version copied</string>
+ <string name="home_section_legal">Legal</string>
+ <!-- Also the title of the licences screen -->
+ <string name="home_licences">Open-source licences</string>
+ <string name="home_source_code">Source code</string>
+ <string name="home_engine">PdfCraft engine</string>
+ <!-- Keep the licence names (MIT, Apache-2.0) and the trademark notice -->
+ <string name="home_legal_notice">PdfCraft for Android is built on PdfCraft\'s Rust engine. MIT OR Apache-2.0. PdfCraft is not affiliated with Adobe; Acrobat is a trademark of Adobe Inc.</string>
+
+ <!-- Tool screens: Compress PDF -->
+ <string name="tools_compress_action">Compress</string>
+ <string name="tools_compression_level">Compression level:</string>
+ <string name="tools_compress_high">High compression</string>
+ <string name="tools_compress_high_desc">Smallest file, images softer</string>
+ <string name="tools_compress_medium">Medium compression</string>
+ <string name="tools_compress_medium_desc">Balanced file size and quality</string>
+ <string name="tools_compress_low">Low compression</string>
+ <string name="tools_compress_low_desc">Bigger file, images sharpest</string>
+
+ <!-- Tool screens: Set password -->
+ <string name="tools_about_passwords">About passwords</string>
+ <string name="tools_protect_intro">A protected copy of this file is saved.</string>
+ <!-- The * marks a field that must be filled in -->
+ <string name="tools_new_password">New password *</string>
+ <!-- The * marks a field that must be filled in -->
+ <string name="tools_repeat_password">Repeat the password *</string>
+ <string name="tools_password_rule">Use 6 to 128 characters: letters, numbers and symbols, no spaces.</string>
+ <string name="tools_password_mismatch">The passwords don\'t match.</string>
+ <!-- "Remove password" is the name of a command in the viewer -->
+ <string name="tools_about_passwords_body">The copy is encrypted with AES-256. Keep the password safe: it can\'t be recovered. To remove the password later, open the copy with it and choose Remove password.</string>
+
+ <!-- Tool screens: Export PDF -->
+ <string name="tools_export_action">Export</string>
+ <!-- Tab: export as an office document -->
+ <string name="tools_export_document">Document</string>
+ <!-- Tab: export each page as a picture -->
+ <string name="tools_export_image">Image</string>
+ <string name="tools_export_not_allowed">This document\'s security settings don\'t allow exporting its text. Export images of its pages instead.</string>
+ <!-- File formats: product and format names, usually left as they are -->
+ <string name="tools_format_word">Word (docx)</string>
+ <string name="tools_format_rtf">Rich Text Format (rtf)</string>
+ <string name="tools_format_excel">Excel (xlsx)</string>
+ <string name="tools_format_powerpoint">PowerPoint (pptx)</string>
+ <string name="tools_format_jpeg">JPEG (jpeg)</string>
+ <string name="tools_format_png">PNG (png)</string>
+
+ <!-- Tool screens: Create PDF -->
+ <string name="tools_create_title">Choose files to make a PDF</string>
+ <string name="tools_browse_files">Browse files</string>
+ <string name="tools_or_make_new">Or make a new one</string>
+ <string name="tools_scan_document">Scan a document</string>
+
+ <!-- Tool screens: Combine files -->
+ <!-- Title once two or more files are chosen -->
+ <plurals name="tools_file_count">
+ <item quantity="one">%d file</item>
+ <item quantity="other">%d files</item>
+ </plurals>
+ <string name="tools_add_files">Add files</string>
+ <string name="tools_combine_too_many">Remove some files: up to 12 can be combined.</string>
+ <string name="tools_drag_to_reorder">Drag to reorder</string>
+ <!-- Accessibility label; %1$s is the file name -->
+ <string name="tools_remove_file">Remove %1$s</string>
+ <string name="tools_file_removed">File removed</string>
+ <string name="tools_combine_as_pdf">Combine as PDF</string>
+ <string name="tools_combine_name_title">Name the combined file</string>
+
+ <!-- Tool screens: Crop pages and the scan's crop -->
+ <string name="tools_all_pages">All pages</string>
+ <string name="tools_current_page">Current page</string>
+ <string name="tools_previous_page">Previous page</string>
+ <string name="tools_next_page">Next page</string>
+ <!-- %1$d is the page number -->
+ <string name="tools_page_number">Page %1$d</string>
+ <!-- Verb: put the crop back to the whole page -->
+ <string name="tools_reset">Reset</string>
+ <!-- Verb (button) and the title of the scan's crop screen -->
+ <string name="tools_crop">Crop</string>
+ <string name="tools_auto_detect">Auto-detect</string>
+ <string name="tools_no_crop">No crop</string>
+
+ <!-- Tool screens: Scan -->
+ <!-- %1$d is the page shown, %2$d the number of pages -->
+ <string name="tools_page_of">Page %1$d of %2$d</string>
+ <string name="tools_save_pdf">Save PDF</string>
+ <!-- Accessibility label of the new file's name; %1$s is the name -->
+ <string name="tools_scan_name_description">File name: %1$s. Change</string>
+ <string name="tools_scan_empty">Take a photo of each page</string>
+ <string name="tools_add_page">Add page</string>
+ <!-- Verb: take this page's photo again -->
+ <string name="tools_retake">Retake</string>
+ <!-- Looks a scanned page can have -->
+ <string name="tools_filter_original">Original</string>
+ <string name="tools_filter_auto_colour">Auto colour</string>
+ <string name="tools_filter_grayscale">Grayscale</string>
+ <string name="tools_filter_whiteboard">Whiteboard</string>
+ <string name="tools_filter_light_text">Light text</string>
+
+ <!-- App dialogs: the first comment's name prompt -->
+ <!-- Verb: go on without entering a name -->
+ <string name="root_skip">Skip</string>
+ <string name="root_author_prompt_body">Add a name to show who made each comment. You can change it later in Preferences.</string>
+
+ <!-- App dialogs: a file that can't be written back -->
+ <string name="root_read_only_title">File is read-only</string>
+ <!-- Verb: throw the changes away -->
+ <string name="root_discard">Discard</string>
+ <!-- %1$s is the file name -->
+ <string name="root_read_only_body">Your changes to %1$s can\'t be saved where the file is. Save a copy to keep them.</string>
+
+ <!-- App dialogs: a link in a document -->
+ <string name="root_open_link_title">Open web page</string>
+ <!-- %1$s is the web site's address -->
+ <string name="root_open_link_body">Do you want to open the page at %1$s?</string>
+
+ <!-- App dialogs: bookmarks and Reading Mode -->
+ <string name="root_delete_bookmarks_title">Delete all bookmarks?</string>
+ <string name="root_delete_all">Delete all</string>
+ <string name="root_delete_bookmarks_body">All of this document\'s bookmarks are removed.</string>
+ <string name="root_reading_mode_title">Reading Mode</string>
+ <!-- "Continuous", "Single page" and "View settings" are names shown in the viewer -->
+ <string name="root_reading_mode_body">Tools work on the page itself. Choose Continuous or Single page in View settings to use this one.</string>
+
+ <!-- App dialogs: a password-protected file -->
+ <string name="root_enter_password">Enter password</string>
+ <!-- %1$s is the file name (shown in italics) -->
+ <string name="root_password_body">%1$s is protected. Please enter the password to open the document.</string>
+
+ <!-- Open-source licences: the parts that are not names -->
+ <string name="root_licence_pdfcraft">PdfCraft (engine and app)</string>
+ <string name="root_licence_pdfcraft_terms">MIT OR Apache-2.0, by storytold and contributors</string>
+ <string name="root_licence_lucide">Lucide icons</string>
+ <string name="root_licence_inter">Inter typeface</string>
+ <string name="root_licence_ocrs">Text recognition models (ocrs)</string>
+ <string name="root_licence_ocrs_terms">CC-BY-SA-4.0, Robert Knight; trained on HierText</string>
+ <string name="root_licence_rust">hayro, lopdf, boa and the engine\'s other Rust dependencies</string>
+ <string name="root_licence_rust_terms">MIT, Apache-2.0 and compatible licences; see NOTICE in the source</string>
+
+ <!-- Shared controls -->
+ <!-- Accessibility label of the area behind a bottom sheet -->
+ <string name="ui_close_sheet">Close sheet</string>
+ <string name="ui_show_password">Show password</string>
+ <string name="ui_hide_password">Hide password</string>
+
+ <!-- ================================================================== -->
+ <!-- The viewer: bars, page overlays, Read aloud, voice comments, Organize pages -->
+ <!-- ================================================================== -->
+ <!-- Viewer: the bottom quick toolbar's shortcut chips -->
+ <string name="viewer_star_file">Star this file</string>
+ <string name="viewer_unstar_file">Unstar this file</string>
+
+ <!-- Viewer: the top bar and its Undo menu -->
+ <!-- Translator note: what Undo and Redo would take back while drawing; shown after "Undo" / "Redo" (viewer_undo_named). -->
+ <string name="viewer_undo_drawing">Drawing</string>
+ <!-- Translator note: accessibility label of the Undo button that opens a small Undo / Redo menu. -->
+ <string name="viewer_undo_or_redo">Undo or redo</string>
+ <!-- Translator note: %1$s is what would be undone, for example "Drawing" or the name of an edit. -->
+ <string name="viewer_undo_named">Undo %1$s</string>
+ <!-- Translator note: %1$s is what would be redone, for example "Drawing" or the name of an edit. -->
+ <string name="viewer_redo_named">Redo %1$s</string>
+ <string name="viewer_find_in_document">Find in document</string>
+
+ <!-- Viewer: Find in the top bar -->
+ <!-- Translator note: accessibility label of the arrow that closes Find. -->
+ <string name="viewer_collapse">Collapse</string>
+ <!-- Translator note: go to the previous search result. -->
+ <string name="viewer_find_previous">Previous</string>
+ <!-- Translator note: go to the next search result. -->
+ <string name="viewer_find_next">Next</string>
+
+ <!-- Viewer: the quick toolbar's handle and the tool sub-toolbars -->
+ <string name="viewer_show_shortcuts">Show shortcuts</string>
+ <string name="viewer_hide_shortcuts">Hide shortcuts</string>
+ <!-- Translator note: accessibility label of the button that picks a tool's colour. -->
+ <string name="viewer_colour">Colour</string>
+
+ <!-- Viewer: the hint a tool shows when it starts -->
+ <string name="viewer_hint_highlight">Drag across the text to highlight it</string>
+ <string name="viewer_hint_underline">Drag across the text to underline it</string>
+ <string name="viewer_hint_strikethrough">Drag across the text to strike it through</string>
+ <string name="viewer_hint_draw">Draw with one finger, scroll with two</string>
+ <string name="viewer_hint_comment">Tap where the comment goes</string>
+ <string name="viewer_hint_text">Tap to add text</string>
+ <string name="viewer_hint_fill_sign">Tap where you want to fill in text</string>
+
+ <!-- Viewer: Add image sheet -->
+ <string name="viewer_add_image">Add image</string>
+ <string name="viewer_image_from_photos">From photos</string>
+ <string name="viewer_image_from_camera">From camera</string>
+
+ <!-- Viewer: the green banner a finished job leaves -->
+ <!-- Translator note: accessibility label of the X that closes the banner. -->
+ <string name="viewer_close">Close</string>
+
+ <!-- Viewer: the scrubber and Go to page -->
+ <!-- Translator note: %1$d is the current page number, %2$d the number of pages. -->
+ <string name="viewer_page_of">Page %1$d of %2$d</string>
+ <string name="viewer_go_to_page">Go to page</string>
+ <!-- Translator note: the range of page numbers that can be entered; %1$d is the last page. -->
+ <string name="viewer_go_to_page_range">1 - %1$d</string>
+ <string name="viewer_enter_page_number">Enter page number</string>
+ <!-- Translator note: link back to the page the last jump came from; %1$d is its number. -->
+ <string name="viewer_back_to_page">Back to page %1$d</string>
+
+ <!-- Viewer: the menu by selected text -->
+ <string name="viewer_add_comment">Add comment</string>
+ <string name="viewer_strikethrough">Strikethrough</string>
+ <string name="viewer_edit_text">Edit text</string>
+ <string name="viewer_copy_text">Copy text</string>
+ <!-- Translator note: accessibility labels of the two handles at the ends of selected text. -->
+ <string name="viewer_selection_start">Selection start</string>
+ <string name="viewer_selection_end">Selection end</string>
+
+ <!-- Viewer: typing a note, a reply or free text -->
+ <string name="viewer_write_note">Write a note</string>
+ <string name="viewer_write_reply">Write a reply</string>
+ <!-- Translator note: placeholder in the box where text is typed onto the page. -->
+ <string name="viewer_add_text">Add text</string>
+
+ <!-- Viewer: Reading Mode -->
+ <string name="viewer_reading_hint">Pinch or double-tap to make the text bigger.</string>
+ <string name="viewer_reading_no_text">No text on this page to reflow.</string>
+
+ <!-- Read Aloud: the player -->
+ <string name="read_aloud_no_voice">Read aloud needs a text-to-speech voice on this phone.</string>
+ <string name="read_aloud_open_player">Open the player</string>
+ <string name="read_aloud_close_player">Close the player</string>
+ <string name="read_aloud_read_again">Read again</string>
+ <string name="read_aloud_back_15">Back 15 seconds</string>
+ <string name="read_aloud_forward_15">Forward 15 seconds</string>
+ <!-- Translator note: opens the choice of the language the voice reads in. -->
+ <string name="read_aloud_voice">Voice</string>
+ <string name="read_aloud_choose_language">Choose language</string>
+ <string name="read_aloud_voice_settings">Voice settings</string>
+
+ <!-- Voice comments: recording -->
+ <string name="voice_record_comment">Record voice comment</string>
+ <string name="voice_mic_failed">The microphone couldn\'t be started. Another app may be using it.</string>
+ <string name="voice_nothing_recorded">Nothing was recorded.</string>
+ <string name="voice_limit_warning">Recording stops at 30 minutes.</string>
+ <string name="voice_recording">Recording…</string>
+ <string name="voice_playing">Playing…</string>
+ <string name="voice_listen_first">Listen to your recording before posting it</string>
+ <string name="voice_stop_recording">Stop recording</string>
+ <string name="voice_record_again">Record again</string>
+
+ <!-- Voice comments: playing one back in its panel -->
+ <string name="voice_cannot_play">This recording can\'t be played.</string>
+ <string name="voice_play_audio">Play audio</string>
+ <!-- Translator note: the type of a comment as comment lists name it. -->
+ <string name="voice_comment_kind">Voice comment</string>
+
+ <!-- Voice comments: the microphone was refused before -->
+ <string name="voice_mic_title">Use the microphone?</string>
+ <string name="voice_mic_rationale">PdfCraft needs the microphone to record voice comments. You can allow it in the app\'s settings.</string>
+ <string name="voice_open_settings">Open settings</string>
+ <string name="voice_not_now">Not now</string>
+
+ <!-- Pages: the grid of pages and organizing -->
+ <string name="pages_title">Pages</string>
+ <string name="pages_select">Select pages</string>
+ <!-- Translator note: the title while organizing; %1$d is how many pages are ticked. -->
+ <plurals name="pages_selected_count">
+ <item quantity="one">Selected %1$d</item>
+ <item quantity="other">Selected %1$d</item>
+ </plurals>
+ <!-- Translator note: accessibility label of a page's thumbnail; %1$d is its number. -->
+ <string name="pages_page">Page %1$d</string>
+ <string name="pages_insert_page">Insert Page</string>
+ <string name="pages_extract">Extract</string>
+ <!-- Translator note: rotate the selected pages a quarter turn to the left. Keep it short. -->
+ <string name="pages_rotate_left">Left</string>
+ <!-- Translator note: rotate the selected pages a quarter turn to the right. Keep it short. -->
+ <string name="pages_rotate_right">Right</string>
+
+ <!-- Pages: Insert sheet (where the new pages go, and what they are) -->
+ <string name="pages_insert">Insert</string>
+ <string name="pages_at_start">At the start</string>
+ <string name="pages_at_end">At the end</string>
+ <!-- Translator note: %1$d is a page number. -->
+ <string name="pages_after_page">After page %1$d</string>
+ <!-- Translator note: %1$d is a page number. -->
+ <string name="pages_before_page">Before page %1$d</string>
+ <string name="pages_blank_page">Blank page</string>
+ <string name="pages_from_file">From another file</string>
+ <string name="pages_from_scan">From a scan</string>
+
+ <!-- ================================================================== -->
+ <!-- The viewer's sheets: More, comments, lists, page menu, digital signatures -->
+ <!-- ================================================================== -->
+ <!-- Digital signatures: placing the signature box on a page -->
+ <string name="sign_place_hint">Drag a box where the signature goes</string>
+
+ <!-- Digital signatures: the Sign with a digital ID screen -->
+ <string name="sign_section_id">Digital ID</string>
+ <!-- Translator note: .p12 and .pfx are file extensions; keep them as they are -->
+ <string name="sign_no_id">You don\'t have a digital ID yet. Add the .p12 or .pfx file you were given, or create one for yourself.</string>
+ <string name="sign_add_id_file">Add a digital ID file</string>
+ <!-- Translator note: both a button and the title of the screen it opens -->
+ <string name="sign_create_id">Create a digital ID</string>
+ <string name="sign_section_appearance">Appearance</string>
+ <!-- Translator note: how the signature looks: only the signer's name and the date -->
+ <string name="sign_look_name">Name only</string>
+ <!-- Translator note: how the signature looks: the signer's name typed in a script font -->
+ <string name="sign_look_typed">Typed name</string>
+ <!-- Translator note: how the signature looks: the signature the reader drew in Fill & Sign -->
+ <string name="sign_look_drawn">My signature</string>
+ <string name="sign_look_name_about">Your name and the date in the box.</string>
+ <string name="sign_look_typed_about">Your name in a script font, with your name and the date beside it.</string>
+ <!-- Translator note: Fill & Sign is the name of a tool in the app -->
+ <string name="sign_look_drawn_about">Your saved Fill &amp; Sign signature, with your name and the date beside it.</string>
+ <!-- Translator note: Fill & Sign is the name of a tool in the app -->
+ <string name="sign_look_drawn_missing">Make a signature in Fill &amp; Sign first.</string>
+ <string name="sign_section_reason">Reason (optional)</string>
+ <string name="sign_reason_hint">For example: I approve this document</string>
+ <string name="sign_section_location">Location (optional)</string>
+ <string name="sign_location_hint">City or place</string>
+ <!-- Translator note: %1$s is the name on the digital ID -->
+ <string name="sign_section_password">Password for %1$s</string>
+ <!-- Translator note: the hint in the password field, and the title of the dialog asking for the password of a digital ID file being added -->
+ <string name="sign_id_password">Digital ID password</string>
+ <string name="sign_saves_note">Signing saves the document. Anyone who opens it can check that it hasn\'t changed since; changes made after signing are listed with the signature.</string>
+
+ <!-- Digital signatures: a digital ID in the list -->
+ <!-- Translator note: %1$s is a date -->
+ <string name="sign_id_expired">This digital ID expired on %1$s.</string>
+ <!-- Translator note: %1$s is a date -->
+ <string name="sign_id_not_yet_valid">This digital ID isn\'t valid until %1$s.</string>
+ <string name="sign_id_self_signed">Self-signed</string>
+ <!-- Translator note: %1$s is the name of whoever issued the certificate -->
+ <string name="sign_id_issued_by">Issued by %1$s</string>
+ <!-- Translator note: %1$s is a date -->
+ <string name="sign_id_valid_until">Valid until %1$s</string>
+ <!-- Translator note: accessibility label of the delete button. %1$s is the person's name on the digital ID -->
+ <string name="sign_remove_id_description">Remove %1$s\'s digital ID</string>
+ <string name="sign_remove_id_title">Remove digital ID?</string>
+ <string name="sign_remove">Remove</string>
+ <!-- Translator note: %1$s is the person's name on the digital ID -->
+ <string name="sign_remove_id_message">%1$s\'s digital ID is removed from PdfCraft. Documents already signed with it keep their signatures.</string>
+
+ <!-- Digital signatures: the password of a digital ID file being added -->
+ <string name="sign_add">Add</string>
+ <!-- Translator note: %1$s is the file's name -->
+ <string name="sign_id_password_prompt">Enter the password that protects %1$s.</string>
+
+ <!-- Digital signatures: the Create a digital ID screen -->
+ <string name="sign_create_about">A digital ID made here is self-signed: a document you sign with it shows any change made after you signed, but nobody else vouches that it\'s you. For that, use the ID file an organisation or a certificate authority gives you.</string>
+ <string name="sign_section_name">Name</string>
+ <string name="sign_section_email">Email (optional)</string>
+ <!-- Translator note: an example email address shown in the empty field -->
+ <string name="sign_email_hint">[email protected]</string>
+ <string name="sign_section_organisation">Organisation (optional)</string>
+ <string name="sign_organisation_hint">Company or organisation</string>
+ <string name="sign_password_hint">At least 6 characters</string>
+ <string name="sign_password_again">The password again</string>
+ <string name="sign_password_short">The password needs at least 6 characters.</string>
+ <string name="sign_password_mismatch">The passwords don\'t match.</string>
+ <string name="sign_password_note">PdfCraft doesn\'t keep the password and can\'t recover it: you type it each time you sign.</string>
+
+ <!-- Digital signatures: tapping an empty signature field -->
+ <string name="sign_add_your_signature">Add your signature</string>
+
+ <!-- Digital signatures: the Signatures sheet -->
+ <string name="sign_signatures">Signatures</string>
+ <string name="sign_none">This document has no signatures.</string>
+ <string name="sign_unknown_signer">Unknown signer</string>
+ <string name="sign_empty_field">Empty signature field</string>
+ <!-- Translator note: a certifying signature, one that says which changes the document still allows -->
+ <string name="sign_certified">Certified</string>
+ <string name="sign_add_signature">Add a digital signature</string>
+ <string name="sign_status_unsigned">Not signed yet</string>
+ <string name="sign_status_valid">Valid</string>
+ <string name="sign_status_invalid">Invalid</string>
+ <!-- Translator note: the signature is intact, but the signer isn't among the trusted ones -->
+ <string name="sign_status_unknown">Signer not verified</string>
+
+ <!-- Digital signatures: a signature's details -->
+ <!-- Translator note: %1$s is the reason the signer gave -->
+ <string name="sign_detail_reason">Reason: %1$s</string>
+ <!-- Translator note: %1$s is the place the signer gave -->
+ <string name="sign_detail_location">Location: %1$s</string>
+ <string name="sign_detail_cert_self_signed">Certificate: self-signed</string>
+ <!-- Translator note: %1$s is the name of whoever issued the certificate -->
+ <string name="sign_detail_cert_issued_by">Certificate: issued by %1$s</string>
+ <!-- Translator note: %1$s is the date the certificate stops being valid -->
+ <string name="sign_detail_valid_until">Valid until: %1$s</string>
+ <string name="sign_detail_certified_no_changes">Certified: no changes allowed</string>
+ <string name="sign_detail_certified_forms">Certified: form filling allowed</string>
+ <string name="sign_detail_certified_comments">Certified: form filling and comments allowed</string>
+ <string name="sign_detail_changes_none">Changes since signing: none</string>
+ <string name="sign_detail_changes_allowed">Changes since signing: allowed ones</string>
+ <!-- Translator note: %1$s lists the changes, as the PDF engine describes them -->
+ <string name="sign_detail_changes_allowed_list">Changes since signing: allowed ones (%1$s)</string>
+ <string name="sign_detail_changes_disallowed">Changes since signing: some that aren\'t allowed</string>
+ <!-- Translator note: %1$s lists the changes, as the PDF engine describes them -->
+ <string name="sign_detail_changes_disallowed_list">Changes since signing: some that aren\'t allowed (%1$s)</string>
+ <string name="sign_field_unsigned">Nobody has signed this field yet.</string>
+ <!-- Translator note: a button that shows the signature on its page -->
+ <string name="sign_go_to">Go to it</string>
+ <string name="sign_stop_trusting">Stop trusting</string>
+ <string name="sign_trust">Trust this signer</string>
+
+ <!-- Viewer sheets: More -->
+ <string name="sheet_stored_on_device">Stored on this device</string>
+ <!-- Translator note: the file can't be changed -->
+ <string name="sheet_read_only">Read-only</string>
+ <string name="sheet_print">Print</string>
+ <string name="sheet_add_star">Add a star</string>
+ <string name="sheet_remove_star">Remove the star</string>
+ <string name="sheet_view_settings">View settings</string>
+ <string name="sheet_pages">Pages</string>
+ <string name="sheet_attachments">Attachments</string>
+ <string name="sheet_bookmarks_contents">Bookmarks &amp; Table of Contents</string>
+ <string name="sheet_comment_list">Comment List</string>
+ <string name="sheet_add_bookmark">Add bookmark</string>
+ <string name="sheet_remove_bookmark">Remove bookmark</string>
+ <string name="sheet_export_as">Export as...</string>
+ <!-- Translator note: %1$s names the change, as the PDF engine describes it -->
+ <string name="sheet_undo_action">Undo %1$s</string>
+ <!-- Translator note: %1$s names the change, as the PDF engine describes it -->
+ <string name="sheet_redo_action">Redo %1$s</string>
+
+ <!-- Viewer sheets: View settings -->
+ <string name="sheet_continuous">Continuous</string>
+ <string name="sheet_single_page">Single page</string>
+ <string name="sheet_reading_mode">Reading Mode</string>
+ <string name="sheet_night_mode">Night Mode</string>
+
+ <!-- Viewer sheets: Bookmarks & Table of Contents -->
+ <!-- Translator note: the tab with the document's table of contents -->
+ <string name="sheet_tab_contents">Contents</string>
+ <!-- Translator note: the tab with the reader's own bookmarks -->
+ <string name="sheet_tab_bookmarks">Bookmarks</string>
+ <string name="sheet_no_contents">This document has no table of contents.</string>
+ <string name="sheet_up_level">Up a level</string>
+ <!-- Translator note: accessibility label. %1$s is the title of an entry in the table of contents -->
+ <string name="sheet_expand_entry">Expand %1$s</string>
+ <string name="sheet_bookmarks_empty">Your bookmarks show up here.</string>
+ <string name="sheet_add_a_bookmark">Add a bookmark</string>
+ <string name="sheet_bookmark_name_invalid">That name can\'t be used.</string>
+ <!-- Translator note: %1$s is the bookmark's name -->
+ <string name="sheet_bookmark_removed">%1$s bookmark removed</string>
+ <string name="sheet_delete_all">Delete all</string>
+ <!-- Translator note: %1$d is a page number -->
+ <string name="sheet_page">Page %1$d</string>
+
+ <!-- Viewer sheets: More tools -->
+ <string name="sheet_customize_toolbar">Customize toolbar</string>
+
+ <!-- Viewer sheets: file sizes -->
+ <plurals name="sheet_size_bytes">
+ <item quantity="one">%1$d byte</item>
+ <item quantity="other">%1$d bytes</item>
+ </plurals>
+ <!-- Translator note: %1$.1f is a number with one decimal; KB is kilobytes -->
+ <string name="sheet_size_kb">%1$.1f KB</string>
+ <!-- Translator note: %1$.1f is a number with one decimal; MB is megabytes -->
+ <string name="sheet_size_mb">%1$.1f MB</string>
+
+ <!-- Comment List -->
+ <string name="comments_title">Comments</string>
+ <string name="comments_none">No comments</string>
+ <!-- Translator note: replies aren't counted; a thread is a comment with its replies -->
+ <plurals name="comments_threads">
+ <item quantity="one">%1$d comment thread</item>
+ <item quantity="other">%1$d comment threads</item>
+ </plurals>
+ <!-- Translator note: accessibility labels of a page's fold button -->
+ <string name="comments_expand">Expand</string>
+ <string name="comments_collapse">Collapse</string>
+ <string name="comments_copy_text">Copy text</string>
+ <string name="comments_edit">Edit comment</string>
+ <!-- Translator note: adds text to a comment that has none -->
+ <string name="comments_add">Add comment</string>
+ <!-- Translator note: the author shown for a comment without one -->
+ <string name="comments_guest">Guest</string>
+ <string name="comments_options">Comment options</string>
+ <!-- Translator note: a button under a comment thread -->
+ <string name="comments_reply">Reply</string>
+ <!-- Translator note: the hint in the empty reply box -->
+ <string name="comments_reply_hint">Reply</string>
+ <!-- Translator note: accessibility label of the commenter's picture -->
+ <string name="comments_avatar">Avatar</string>
+ <string name="comments_empty_title">Get started</string>
+ <string name="comments_empty_body">Comments you add with the commenting tools show up here.</string>
+
+ <!-- Comment List: what a comment did, in italics under its author -->
+ <string name="comments_action_highlighted">Highlighted</string>
+ <string name="comments_action_underlined">Underlined</string>
+ <string name="comments_action_struck_out">Struck out text</string>
+ <string name="comments_action_freehand">Drew freehand</string>
+ <string name="comments_action_arrow">Drew an arrow</string>
+ <string name="comments_action_line">Drew a line</string>
+ <string name="comments_action_rectangle">Drew a rectangle</string>
+ <string name="comments_action_oval">Drew an oval</string>
+ <string name="comments_action_cloud">Drew a cloud</string>
+ <string name="comments_action_polygon">Drew a polygon</string>
+ <string name="comments_action_joined_lines">Drew joined lines</string>
+ <string name="comments_action_stamp">Stamped the page</string>
+ <string name="comments_action_note">Added a note</string>
+ <string name="comments_action_callout">Added a callout</string>
+ <string name="comments_action_text_box">Added a text box</string>
+ <string name="comments_action_replacement">Suggested a replacement</string>
+ <string name="comments_action_insertion">Suggested an insertion</string>
+ <string name="comments_action_voice">Recorded a voice note</string>
+ <string name="comments_action_other">Commented</string>
+
+ <!-- Comment panel -->
+ <string name="comments_previous">Previous comment</string>
+ <string name="comments_next">Next comment</string>
+ <!-- Translator note: which comment thread is shown: %1$d is its number, %2$d how many there are -->
+ <string name="comments_position">%1$d of %2$d</string>
+ <string name="comments_opacity">Opacity</string>
+ <string name="comments_line_thickness">Line thickness</string>
+
+ <!-- Comment panel: moving a selected comment (accessibility labels) -->
+ <string name="comments_move">Move comment</string>
+ <string name="comments_resize">Resize comment</string>
+
+ <!-- Edit PDF: list styles -->
+ <!-- Translator note: the list style with no bullets or numbers -->
+ <string name="lists_none">None</string>
+
+ <!-- Page menu (long press on a page) -->
+ <string name="page_menu_add_comment">Add comment</string>
+ <string name="page_menu_add_text">Add text</string>
+ <string name="page_menu_add_image">Add image</string>
+
+ <!-- ================================================================== -->
+ <!-- Editing tools: Edit PDF, Fill &amp; Sign, comment tools, the quick toolbar, forms -->
+ <!-- ================================================================== -->
+ <!-- Bottom toolbar: short tool names under the icons (keep them short; two lines at most) -->
+ <!-- Note: the Set password tool's short name on the toolbar -->
+ <string name="toolbar_label_password">Password</string>
+ <string name="toolbar_label_combine">Combine</string>
+ <string name="toolbar_label_compress">Compress</string>
+ <string name="toolbar_label_organize">Organize</string>
+ <string name="toolbar_label_crop">Crop</string>
+ <!-- Note: the Recognize text tool's short name on the toolbar -->
+ <string name="toolbar_label_recognize">Recognize</string>
+ <!-- Note: the tool that types text onto the page, as named on the toolbar -->
+ <string name="toolbar_label_add_text">Add text</string>
+ <!-- Note: the same tool's name in More tools, and its one sub-tool (text typed onto the page) -->
+ <string name="toolbar_tool_text">Text</string>
+
+ <!-- Customize toolbar: moving tools between the bottom toolbar and More tools -->
+ <string name="toolbar_customize">Customize toolbar</string>
+ <string name="toolbar_save">Save toolbar</string>
+ <!-- Note: %1$d is how many tools fit on the toolbar (6 to 8) -->
+ <plurals name="toolbar_customize_hint">
+ <item quantity="one">Drag tools between the toolbar and More tools. The toolbar holds %1$d.</item>
+ <item quantity="other">Drag tools between the toolbar and More tools. The toolbar holds %1$d.</item>
+ </plurals>
+ <!-- Note: heading over the tools that are on the bottom toolbar -->
+ <string name="toolbar_section_toolbar">Toolbar</string>
+ <!-- Note: spoken for a tool tile; %1$s is the tool's name -->
+ <string name="toolbar_tool_on_bar">%1$s, on the toolbar</string>
+ <!-- Note: spoken for a tool tile; %1$s is the tool's name -->
+ <string name="toolbar_tool_in_more_tools">%1$s, in More tools</string>
+
+ <!-- Highlight tool: marking text -->
+ <string name="toolbar_strikethrough">Strikethrough</string>
+ <!-- Note: "More tools" and "Recognize text" are the names of the menu and the tool -->
+ <string name="toolbar_no_text_to_mark">This page has no text to mark. Recognize text first (More tools ▸ Recognize text).</string>
+
+ <!-- Draw tool -->
+ <string name="toolbar_draw_freeform">Draw freeform</string>
+ <string name="toolbar_line_thickness">Line thickness</string>
+ <!-- Note: a setting that turns hand-drawn strokes into clean lines, boxes, ovals and polygons -->
+ <string name="toolbar_snap_to_shape">Snap to shape</string>
+ <string name="toolbar_snap_on">Snap to shape on</string>
+ <string name="toolbar_snap_off">Snap to shape off</string>
+ <!-- Note: spoken for each of the seven line widths; %1$d is 1 (thinnest) to 7 -->
+ <string name="toolbar_stroke_width">Stroke width %1$d</string>
+
+ <!-- Comment tool -->
+ <string name="toolbar_text_comment">Text comment</string>
+ <string name="toolbar_voice_comment">Voice comment</string>
+
+ <!-- Text tool -->
+ <string name="toolbar_text_size">Text size</string>
+ <!-- Note: a text size in points; %1$d is the number -->
+ <string name="toolbar_text_size_pt">%1$d pt</string>
+
+ <!-- Colour picker of the comment tools -->
+ <string name="toolbar_color_highlight">Highlight color</string>
+ <string name="toolbar_color_underline">Underline color</string>
+ <string name="toolbar_color_strikethrough">Strikethrough color</string>
+ <string name="toolbar_color_drawing">Drawing color</string>
+ <string name="toolbar_color_text">Text color</string>
+ <string name="toolbar_color_comment">Comment color</string>
+ <string name="toolbar_opacity">Opacity</string>
+ <!-- Note: spoken for the opacity slider; %1$d is a percentage from 25 to 100 -->
+ <string name="toolbar_opacity_percent">Opacity %1$d%%</string>
+
+ <!-- Colour names, spoken for the colour swatches -->
+ <string name="prefs_color_blue">Blue</string>
+ <string name="prefs_color_green">Green</string>
+ <string name="prefs_color_yellow">Yellow</string>
+ <string name="prefs_color_orange">Orange</string>
+ <string name="prefs_color_red">Red</string>
+ <string name="prefs_color_purple">Purple</string>
+ <string name="prefs_color_light_blue">Light blue</string>
+ <string name="prefs_color_light_green">Light green</string>
+ <string name="prefs_color_light_yellow">Light yellow</string>
+ <string name="prefs_color_light_orange">Light orange</string>
+ <string name="prefs_color_pink">Pink</string>
+ <string name="prefs_color_light_purple">Light purple</string>
+ <string name="prefs_color_white">White</string>
+ <string name="prefs_color_pale_grey">Pale grey</string>
+ <string name="prefs_color_light_grey">Light grey</string>
+ <string name="prefs_color_medium_grey">Medium grey</string>
+ <string name="prefs_color_dark_grey">Dark grey</string>
+ <string name="prefs_color_black">Black</string>
+ <string name="prefs_color_cyan">Cyan</string>
+
+ <!-- Edit PDF: the bottom bar with nothing selected -->
+ <string name="edit_add_text">Add text</string>
+ <string name="edit_add_image">Add image</string>
+ <string name="edit_tap_for_text">Tap the page where the text should go</string>
+ <string name="edit_tap_for_image">Tap the page where the picture should go</string>
+
+ <!-- Edit PDF: formatting a paragraph -->
+ <string name="edit_bold">Bold</string>
+ <string name="edit_italic">Italic</string>
+ <!-- Note: the underline text style, not the Underline comment tool -->
+ <string name="edit_underline">Underline</string>
+ <string name="edit_text_size">Text size</string>
+ <!-- Note: %1$d is a text size in points -->
+ <string name="edit_text_size_pt">Text size: %1$d pt</string>
+ <string name="edit_font">Font</string>
+ <string name="edit_colour">Colour</string>
+ <string name="edit_align_text">Align text</string>
+ <!-- Note: bulleted and numbered lists -->
+ <string name="edit_list">List</string>
+
+ <!-- Edit PDF: fonts (generic kinds of typeface, not font names) -->
+ <!-- Note: the paragraph's own font, as it was in the PDF -->
+ <string name="edit_font_original">Original font</string>
+ <string name="edit_font_sans">Sans serif</string>
+ <string name="edit_font_serif">Serif</string>
+ <string name="edit_font_mono">Monospace</string>
+
+ <!-- Edit PDF: list styles -->
+ <!-- Note: spoken for the list style buttons; "None" is no list (plain paragraphs) -->
+ <string name="edit_list_desc_none">List None</string>
+ <string name="edit_list_desc_bullet">List Bullet</string>
+ <string name="edit_list_desc_dash">List Dash</string>
+ <string name="edit_list_desc_number">List Number</string>
+ <!-- Note: a list numbered a., b., c. -->
+ <string name="edit_list_desc_lower">List Lower</string>
+ <!-- Note: a list numbered A., B., C. -->
+ <string name="edit_list_desc_upper">List Upper</string>
+ <!-- Note: a list numbered i., ii., iii. -->
+ <string name="edit_list_desc_roman">List Roman</string>
+
+ <!-- Edit PDF: text alignment -->
+ <string name="edit_align_left">Align left</string>
+ <string name="edit_align_right">Align right</string>
+ <string name="edit_align_center">Align center</string>
+ <string name="edit_align_justify">Align justify</string>
+
+ <!-- Edit PDF: the menu over a selected paragraph or picture -->
+ <string name="edit_edit_text">Edit text</string>
+ <string name="edit_select_all">Select all</string>
+ <!-- Note: spoken for the box where a paragraph's text is typed -->
+ <string name="edit_paragraph_text">Paragraph text</string>
+ <!-- Note: rotate the picture a quarter turn -->
+ <string name="edit_turn_left">Turn left</string>
+ <string name="edit_turn_right">Turn right</string>
+
+ <!-- Fill & Sign: what a tap places -->
+ <string name="fill_element_text">Text</string>
+ <!-- Note: an X mark -->
+ <string name="fill_element_cross">Cross</string>
+ <string name="fill_element_check">Checkmark</string>
+ <string name="fill_element_dot">Dot</string>
+ <string name="fill_element_box">Rounded box</string>
+ <!-- Note: a straight line (a shape), as on a form to strike something out -->
+ <string name="fill_element_line">Line</string>
+ <string name="fill_element_signature">Signature</string>
+ <string name="fill_element_initials">Initials</string>
+
+ <!-- Fill & Sign: the toolbar -->
+ <string name="fill_add_text">Add text</string>
+ <string name="fill_add_cross">Add a cross</string>
+ <string name="fill_add_check">Add a checkmark</string>
+ <string name="fill_add_dot">Add a dot</string>
+ <string name="fill_add_box">Add a rounded box</string>
+ <!-- Note: a straight line (a shape) -->
+ <string name="fill_add_line">Add a line</string>
+ <string name="fill_sign_or_initials">Sign or add initials</string>
+
+ <!-- Fill & Sign: the Sign panel -->
+ <string name="fill_add_signature">Add signature</string>
+ <string name="fill_add_initials">Add initials</string>
+ <string name="fill_your_signature">Your signature</string>
+ <string name="fill_your_initials">Your initials</string>
+ <string name="fill_clear_signature">Clear saved signature</string>
+ <string name="fill_clear_initials">Clear saved initials</string>
+ <string name="fill_tap_place_signature">Tap where you want to place your signature</string>
+ <string name="fill_tap_place_initials">Tap where you want to place your initials</string>
+
+ <!-- Fill & Sign: making a signature or initials -->
+ <string name="fill_create_signature">Create signature</string>
+ <string name="fill_create_initials">Create initials</string>
+ <string name="fill_draw_signature_first">Draw your signature first</string>
+ <string name="fill_draw_initials_first">Draw your initials first</string>
+ <!-- Note: tab: draw the signature with a finger -->
+ <string name="fill_tab_draw">Draw</string>
+ <!-- Note: tab: take the signature from a picture -->
+ <string name="fill_tab_image">Image</string>
+ <string name="fill_draw_signature_here">Draw your signature here</string>
+ <string name="fill_draw_initials_here">Draw your initials here</string>
+ <string name="fill_save_to_device">Save to device</string>
+
+ <!-- Fill & Sign: the menu over a placed element -->
+ <string name="fill_smaller">Smaller</string>
+ <string name="fill_bigger">Bigger</string>
+ <string name="fill_colour">Colour</string>
+
+ <!-- Form fields: the top bar while a field is filled in -->
+ <!-- Note: empties the field being filled in -->
+ <string name="forms_reset">Reset</string>
+ <string name="forms_previous_field">Previous field</string>
+ <string name="forms_next_field">Next field</string>
+
+ <!-- ================================================================== -->
+ <!-- Messages: notices at the bottom of the screen, progress, errors -->
+ <!-- ================================================================== -->
+ <!-- Messages: opening documents -->
+ <string name="msg_engine_not_started">PdfCraft couldn\'t start.</string>
+ <string name="msg_file_moved">This file has been moved or deleted.</string>
+ <string name="msg_opened_own_copy">Opened PdfCraft\'s copy. To change the original, open it again from the app it\'s in.</string>
+ <!-- "Open file" is the name of the button on Home that picks a file. -->
+ <string name="msg_file_access_lost">PdfCraft can\'t open this file any more. Open it again from the app it\'s in, or with Open file.</string>
+
+ <!-- Messages: undo and redo. %1$s is the name of the edit, as the engine gives it (for example "Add comment"). -->
+ <string name="msg_undone">%1$s undone</string>
+ <string name="msg_redone">%1$s redone</string>
+
+ <!-- Messages: viewer tools -->
+ <string name="msg_tool_blocked_security">This tool is not available due to the document\'s security settings.</string>
+ <!-- Draw tool: lines drawn are turned into neat shapes. -->
+ <string name="msg_snap_to_shape_on">Snap to shape on</string>
+
+ <!-- Messages: Find. %1$s is the text that was searched for. -->
+ <string name="msg_search_image_only">This file\'s words are pictures, so they can\'t be searched yet.</string>
+ <string name="msg_search_no_matches">No matches for “%1$s”</string>
+
+ <!-- Messages: share and print -->
+ <!-- Subject of the email when a document is shared. %1$s is the document's title. -->
+ <string name="msg_share_subject">Emailing %1$s</string>
+ <string name="msg_print_disabled">Print unavailable: the author has disabled printing for this document.</string>
+
+ <!-- Messages: saving. %1$s is a file name; %2$s is its size (for example "1.2 MB"). -->
+ <string name="msg_saved_copy">Saved a copy</string>
+ <string name="msg_saved_downloads">Saved as %1$s in Downloads</string>
+ <string name="msg_saved_downloads_size">Saved as %1$s in Downloads (%2$s)</string>
+
+ <!-- Messages: Read aloud -->
+ <string name="msg_read_aloud_encrypted">Read aloud isn\'t available for password-protected documents.</string>
+ <string name="msg_read_aloud_resumed">Reading on from where you stopped</string>
+ <!-- Button: read the document from the beginning again. -->
+ <string name="msg_read_aloud_start_over">Start over</string>
+
+ <!-- Messages: bookmarks. %1$s is the bookmark's name (for example "Page 3"). -->
+ <string name="msg_bookmark_added">%1$s bookmark added</string>
+ <string name="msg_bookmark_removed">%1$s bookmark removed</string>
+ <string name="msg_bookmarks_cleared">Bookmarks cleared</string>
+
+ <!-- Messages: voice comments -->
+ <string name="msg_voice_no_storage">Not enough free storage to record. Free up some space and try again.</string>
+ <string name="msg_voice_no_mic">Voice comments need access to the microphone.</string>
+
+ <!-- Messages: copying text -->
+ <!-- Label of a comment's text put on the clipboard (a noun). -->
+ <string name="msg_clip_comment">Comment</string>
+ <!-- Label of text selected in a PDF and put on the clipboard. -->
+ <string name="msg_clip_pdf_text">PDF text</string>
+ <string name="msg_copied">Copied</string>
+ <string name="msg_copy_not_allowed">This document doesn\'t allow copying its text.</string>
+
+ <!-- Messages: Recognize text (OCR) -->
+ <string name="msg_busy_preparing_ocr">Preparing text recognition…</string>
+ <string name="msg_ocr_not_installed">Text recognition isn\'t installed in this build.</string>
+ <string name="msg_busy_recognizing">Recognizing text…</string>
+ <string name="msg_ocr_done">Text recognized (English). It can now be selected, copied, searched and highlighted.</string>
+ <string name="msg_ocr_nothing">No pages needed recognizing</string>
+
+ <!-- Messages: Fill & Sign -->
+ <string name="msg_place_signature">Tap where you want to place your signature</string>
+ <string name="msg_place_initials">Tap where you want to place your initials</string>
+ <string name="msg_image_unreadable">That image couldn\'t be read.</string>
+
+ <!-- Messages: digital IDs and signing -->
+ <string name="msg_sign_read_only">This document can\'t be changed, so it can\'t be signed.</string>
+ <!-- %1$s is the reason, a sentence. -->
+ <string name="msg_id_cannot_sign">This digital ID can\'t sign documents. %1$s</string>
+ <!-- %1$s is the name of the person the digital ID belongs to. -->
+ <string name="msg_id_added">Added %1$s\'s digital ID</string>
+ <!-- %1$s is the reason the file was refused. -->
+ <string name="msg_id_unusable">PdfCraft can\'t use this file as a digital ID: %1$s</string>
+ <string name="msg_busy_creating_id">Creating your digital ID…</string>
+ <string name="msg_id_created">Digital ID created</string>
+ <string name="msg_busy_signing">Signing…</string>
+ <string name="msg_signed_saved">Signed and saved</string>
+ <!-- %1$s is the file name. "Save a copy" is the name of the button shown with this message. -->
+ <string name="msg_signed_not_saved">Signed, but %1$s can\'t be changed where it is. Save a copy to keep the signed file.</string>
+
+ <!-- Messages: a document's signatures, on opening it. %1$s is the signer's name. -->
+ <string name="msg_sig_invalid">This document\'s signature is invalid.</string>
+ <string name="msg_sig_some_invalid">At least one signature in this document is invalid.</string>
+ <string name="msg_sig_valid">Signed by %1$s. The signature is valid.</string>
+ <string name="msg_sig_valid_unknown">Signed by an unknown signer. The signature is valid.</string>
+ <!-- Shown only when the document has two or more signatures. -->
+ <plurals name="msg_sig_all_valid">
+ <item quantity="one">%1$d signature is valid.</item>
+ <item quantity="other">All %1$d signatures are valid.</item>
+ </plurals>
+ <string name="msg_sig_unverified">Signed by %1$s. The document hasn\'t changed since, but the signer isn\'t verified.</string>
+ <string name="msg_sig_unverified_unknown">Signed by an unknown signer. The document hasn\'t changed since, but the signer isn\'t verified.</string>
+ <string name="msg_sig_some_unverified">Signed. Some of the signers aren\'t verified.</string>
+ <!-- Button that opens the signatures' details (a noun). -->
+ <string name="msg_sig_details">Details</string>
+ <string name="msg_signer_trusted">%1$s is trusted on this device</string>
+ <string name="msg_signer_trusted_unknown">This signer is trusted on this device</string>
+
+ <!-- Messages: Edit PDF, adding a picture -->
+ <string name="msg_picture_unreadable">The picture couldn\'t be read.</string>
+ <string name="msg_gif_not_supported">GIF images can\'t be added.</string>
+
+ <!-- Messages: forms -->
+ <string name="msg_form_cleared">Form cleared</string>
+ <string name="msg_button_submit">This button sends the form online, which PdfCraft doesn\'t do.</string>
+ <string name="msg_button_script">This button runs a script, which PdfCraft doesn\'t run.</string>
+ <!-- Words remembered from form fields, offered while typing. -->
+ <string name="msg_suggestions_cleared">Suggestions cleared</string>
+
+ <!-- Messages: picked files. %1$s is a file name. -->
+ <string name="msg_that_file_unreadable">That file couldn\'t be read.</string>
+ <string name="msg_named_file_unreadable">%1$s couldn\'t be read.</string>
+ <string name="msg_files_unreadable">The files couldn\'t be read.</string>
+
+ <!-- Messages: tool jobs (progress texts and results) -->
+ <string name="msg_busy_compressing">Compressing…</string>
+ <string name="msg_compress_no_gain">This file is already as small as it can be.</string>
+ <string name="msg_busy_combining">Combining…</string>
+ <string name="msg_busy_setting_password">Setting password…</string>
+ <string name="msg_crop_all">Every page is cropped.</string>
+ <string name="msg_crop_page">The page is cropped.</string>
+ <!-- %1$s is a file format, for example DOCX. -->
+ <string name="msg_busy_exporting_to">Exporting to %1$s…</string>
+ <string name="msg_busy_exporting_images">Exporting images…</string>
+ <!-- %1$d is the page being exported, %2$d how many pages there are. -->
+ <string name="msg_busy_exporting_page">Exporting page %1$d of %2$d…</string>
+ <!-- Pictures/PdfCraft is a folder on the phone: keep it as it is. -->
+ <plurals name="msg_images_saved">
+ <item quantity="one">%1$d image saved to Pictures/PdfCraft</item>
+ <item quantity="other">%1$d images saved to Pictures/PdfCraft</item>
+ </plurals>
+ <string name="msg_busy_creating_pdf">Creating PDF…</string>
+ <!-- Create PDF takes at most this many files at once. -->
+ <plurals name="msg_create_first_files">
+ <item quantity="one">Only the first %1$d file was used.</item>
+ <item quantity="other">Only the first %1$d files were used.</item>
+ </plurals>
+ <string name="msg_busy_extracting">Extracting…</string>
+
+ <!-- Messages: Scan. %1$d is the page being cleaned up, %2$d how many pages there are. -->
+ <string name="msg_busy_saving_scan">Saving scan…</string>
+ <string name="msg_busy_cleaning_page">Cleaning up page %1$d of %2$d…</string>
+
+ <!-- Messages: Home and files. %1$s is a file name. -->
+ <string name="msg_rename_exists">A file named %1$s is already there.</string>
+ <string name="msg_rename_failed">The file couldn\'t be renamed.</string>
+ <string name="msg_rename_not_here">This file can\'t be renamed here.</string>
+ <string name="msg_duplicated">Duplicated as %1$s in Downloads</string>
+ <string name="msg_delete_failed">The file couldn\'t be deleted.</string>
+ <string name="msg_file_deleted">%1$s deleted</string>
+
+ <!-- ================================================================== -->
+ <!-- Files, notifications and errors from the system -->
+ <!-- ================================================================== -->
+ <!-- Files: engine and file failures shown to the reader -->
+ <string name="files_error_needs_password">This document is protected by a password.</string>
+ <string name="files_error_generic">Something went wrong.</string>
+ <!-- Translator note: a file handed to the app has no location on the phone -->
+ <string name="files_error_no_path">The file has no path.</string>
+ <string name="files_error_write">The file couldn\'t be written.</string>
+ <!-- Translator note: Downloads is the phone's Downloads folder -->
+ <string name="files_error_save_downloads">The file couldn\'t be saved to Downloads.</string>
+ <string name="files_error_save_image">The image couldn\'t be saved.</string>
+
+ <!-- Files: where a document is, as the file details show it -->
+ <!-- Translator note: the phone's own storage; a folder path may follow it, as in "Internal storage/Documents" -->
+ <string name="files_location_internal_storage">Internal storage</string>
+ <!-- Translator note: shown when the folder of a file on the phone isn't known -->
+ <string name="files_location_this_device">This device</string>
+ <!-- Translator note: the phone's Downloads folder -->
+ <string name="files_location_downloads">Downloads</string>
+ <!-- Translator note: Android's photos, videos and audio collection, which provided the file -->
+ <string name="files_location_media">Media</string>
+ <!-- Translator note: the file came from another app that didn't give its name -->
+ <string name="files_location_another_app">Another app</string>
+
+ <!-- Files: names the app gives -->
+ <!-- Translator note: a chosen folder's name when its storage provider gives none -->
+ <string name="files_folder_unnamed">Folder</string>
+ <!-- Translator note: the name of a bookmark the reader adds to a page. %1$d is the page number -->
+ <string name="files_bookmark_page">Page %1$d</string>
+
+ <!-- Main: messages when Android can't do what was asked -->
+ <string name="main_error_no_app">No app on this phone can do that.</string>
+ <string name="main_error_not_allowed">Android didn\'t allow that.</string>
+ <string name="main_error_print_not_allowed">Printing isn\'t allowed for this document.</string>
+
+ <!-- Service: the Read aloud notification -->
+ <!-- Translator note: the notification's text while the document is being read out -->
+ <string name="service_notification_reading">Reading aloud</string>
+ <!-- Translator note: the notification's text while reading is paused -->
+ <string name="service_notification_paused">Paused</string>
+ <!-- Translator note: notification button that jumps back 15 seconds in the reading -->
+ <string name="service_action_back">Back 15 seconds</string>
+ <!-- Translator note: notification button that jumps forward 15 seconds in the reading -->
+ <string name="service_action_forward">Forward 15 seconds</string>
+ <!-- Translator note: notification button that stops reading aloud -->
+ <string name="service_action_stop">Stop</string>
</resources>
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt b/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt
index b171091..bfb016b 100644
--- a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt
+++ b/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/CommentListTest.kt
@@ -33,29 +33,34 @@ class CommentListTest {
set(y, mo - 1, d, h, mi)
}.timeInMillis
+ // the app passes in its translated words; the tests use the English ones
+ private fun dateLabel(raw: String?, now: Long) = commentDateLabel(raw, "Today", "Yesterday", now)
+
+ private fun threads(n: Int) = threadsTitle(n, "No comments") { if (it == 1) "1 comment thread" else "$it comment threads" }
+
@Test
fun commentDatesSayTodayYesterdayOrTheDate() {
val now = at(2026, 10, 12, 9, 0)
- assertEquals("Today", commentDateLabel("D:20261012080000-06'00'", now))
- assertEquals("Yesterday", commentDateLabel("D:20261011235900-06'00'", now))
- assertEquals("Oct 10, 2026", commentDateLabel("D:20261010120000-06'00'", now))
+ assertEquals("Today", dateLabel("D:20261012080000-06'00'", now))
+ assertEquals("Yesterday", dateLabel("D:20261011235900-06'00'", now))
+ assertEquals("Oct 10, 2026", dateLabel("D:20261010120000-06'00'", now))
// 03:00 UTC on the 12th is still the 11th here
- assertEquals("Yesterday", commentDateLabel("D:20261012030000Z", now))
- assertNull(commentDateLabel(null, now))
+ assertEquals("Yesterday", dateLabel("D:20261012030000Z", now))
+ assertNull(dateLabel(null, now))
}
@Test
fun threadCountsReadNaturally() {
- assertEquals("No comments", threadsTitle(0))
- assertEquals("1 comment thread", threadsTitle(1))
- assertEquals("17 comment threads", threadsTitle(17))
+ assertEquals("No comments", threads(0))
+ assertEquals("1 comment thread", threads(1))
+ assertEquals("17 comment threads", threads(17))
}
@Test
fun theFileDateIsTheTimeTodayThenYesterdayThenTheDate() {
val now = at(2026, 10, 12, 9, 0)
- assertEquals("Yesterday", modifiedLabel(at(2026, 10, 11, 21, 39), now))
- assertEquals("Oct 9, 2026", modifiedLabel(at(2026, 10, 9, 10, 0), now))
- assertEquals(java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT).format(java.util.Date(at(2026, 10, 12, 7, 58))), modifiedLabel(at(2026, 10, 12, 7, 58), now))
+ assertEquals("Yesterday", modifiedLabel(at(2026, 10, 11, 21, 39), "Yesterday", now))
+ assertEquals("Oct 9, 2026", modifiedLabel(at(2026, 10, 9, 10, 0), "Yesterday", now))
+ assertEquals(java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT).format(java.util.Date(at(2026, 10, 12, 7, 58))), modifiedLabel(at(2026, 10, 12, 7, 58), "Yesterday", now))
}
}
diff --git a/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/UiTextTest.kt b/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/UiTextTest.kt
new file mode 100644
index 0000000..8fc7336
--- /dev/null
+++ b/apps/pdfcraft-android/android/app/src/test/java/io/github/artcraftandroid/pdfcraft/ui/UiTextTest.kt
@@ -0,0 +1,39 @@
+package io.github.artcraftandroid.pdfcraft.ui
+
+import java.io.File
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+/**
+ * The text people read comes from res/values/strings.xml, so a translation covers all of it:
+ * English written straight into a Text, a label or a message would stay English in every language.
+ */
+class UiTextTest {
+ // a call or argument that shows its string, followed by a string with words in it
+ private val shown = Regex(
+ """\b(?:Text|tell|SheetRow|SheetTitle|BarIcon|ToolTile|QuickItem|OrganizeItem)\(\s*"([^"]*)"""" +
+ """|\b(?:contentDescription|title|label|placeholder|confirm|dismiss|actionLabel|text)\s*=\s*"([^"]*)"""",
+ )
+
+ // file types and the letters drawn as icons are the same in every language
+ private val sameEverywhere = setOf("PDF", "Ag")
+
+ @Test
+ fun noEnglishInTheCode() {
+ val sources = File("src/main/java").walk().filter { it.extension == "kt" }.toList()
+ assertTrue("no sources found", sources.isNotEmpty())
+ val found = sources.flatMap { f ->
+ f.readLines().withIndex().flatMap { (i, line) ->
+ val comment = line.trimStart().let { it.startsWith("*") || it.startsWith("/*") }
+ val code = if (comment) "" else line.substringBefore("// ")
+ shown.findAll(code).mapNotNull { m ->
+ val s = m.groupValues[1].ifEmpty { m.groupValues[2] }
+ // words a person reads: a capital and lower case, or a space between letters
+ val words = Regex("""^[A-Z][a-z]|[A-Za-z] [A-Za-z]""").containsMatchIn(s)
+ if (words && s !in sameEverywhere) "${f.name}:${i + 1}: \"$s\"" else null
+ }.toList()
+ }
+ }
+ assertTrue("Text written in the code instead of res/values/strings.xml:\n" + found.joinToString("\n"), found.isEmpty())
+ }
+}