Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
refactor(i18n): move the Language page's text into string resources
Durganshu5124737a668e
diff --git a/app/src/main/java/com/gotcha/ui/LanguageScreen.kt b/app/src/main/java/com/gotcha/ui/LanguageScreen.ktindex 799d664..69109c2 100644--- a/app/src/main/java/com/gotcha/ui/LanguageScreen.kt+++ b/app/src/main/java/com/gotcha/ui/LanguageScreen.kt@@ -6,6 +6,7 @@ import android.content.Intentimport android.net.Uriimport android.os.Buildimport android.widget.Toast+import androidx.annotation.StringResimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.material3.Buttonimport androidx.compose.material3.DropdownMenuItem@@ -29,8 +30,10 @@ import androidx.compose.runtime.setValueimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.platform.testTag+import androidx.compose.ui.res.stringResourceimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.dp+import com.gotcha.Rimport com.gotcha.audio.AudioModelimport com.gotcha.audio.AudioProviderimport com.gotcha.audio.SpeechLanguageCheck@@ -41,9 +44,6 @@ import com.gotcha.ui.theme.SkinExposedDropdownMenuimport kotlinx.coroutines.launchimport android.provider.Settings as AndroidSettings-/** Voice-language dropdown entry meaning "no explicit choice — follow the reply language". */-private const val FOLLOW_REPLY_LANGUAGE = "Same as AI reply language"-/*** The Language page: every language choice, told apart, and the only place any* of them is set (issue #114).@@ -138,8 +138,7 @@ fun LanguageScreen(SettingsScaffold(title = SettingsPage.LANGUAGE.title, onBack = onBack, overlay = overlay) {Text(- "Every language Gotcha uses, in one place: what the app's own screens are " +- "written in, what Gotcha speaks and hears, and what it writes its answers in.",+ stringResource(R.string.language_page_intro),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)@@ -148,13 +147,12 @@ fun LanguageScreen(// ---- 1. App display language ----Text(- "App display language",+ stringResource(R.string.language_display_title),style = MaterialTheme.typography.titleMedium,fontWeight = FontWeight.Bold)Text(- "Gotcha's own buttons, labels and settings are in English only for now — " +- "changing this affects the rest of your phone, not this app.",+ stringResource(R.string.language_display_description),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)@@ -163,20 +161,18 @@ fun LanguageScreen(modifier = Modifier.fillMaxWidth().settingsField("settings_open_app_locale")- ) { Text("Open Android language settings") }+ ) { Text(stringResource(R.string.language_display_open_settings)) }HorizontalDivider(thickness = 1.dp)// ---- 2. Voice language ----Text(- "Voice language",+ stringResource(R.string.language_voice_title),style = MaterialTheme.typography.titleMedium,fontWeight = FontWeight.Bold)Text(- "What Gotcha speaks aloud and listens for during voice input and calls. " +- "Leave it following the reply language unless you want answers written " +- "in one language and spoken in another.",+ stringResource(R.string.language_voice_description),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)@@ -185,10 +181,14 @@ fun LanguageScreen(onExpandedChange = { voiceExpanded = it }) {OutlinedTextField(- value = voiceLanguage.ifBlank { FOLLOW_REPLY_LANGUAGE },+ value = if (voiceLanguage.isBlank()) {+ stringResource(R.string.language_voice_follow_reply)+ } else {+ stringResource(Language.fromLabel(voiceLanguage).nameRes)+ },onValueChange = {},readOnly = true,- label = { Text("Voice language") },+ label = { Text(stringResource(R.string.language_voice_title)) },trailingIcon = {ExposedDropdownMenuDefaults.TrailingIcon(expanded = voiceExpanded)},@@ -202,17 +202,17 @@ fun LanguageScreen(onDismissRequest = { voiceExpanded = false }) {DropdownMenuItem(- text = { Text(FOLLOW_REPLY_LANGUAGE) },+ text = { Text(stringResource(R.string.language_voice_follow_reply)) },onClick = {voiceLanguage = ""voiceExpanded = false})- Language.labels.forEach { lang ->+ Language.entries.forEach { lang ->DropdownMenuItem(- text = { Text(lang) },+ text = { Text(stringResource(lang.nameRes)) },onClick = {- voiceLanguage = lang+ voiceLanguage = lang.labelvoiceExpanded = false})@@ -220,19 +220,18 @@ fun LanguageScreen(}}Text(- "Which model and voice read it out are picked under Settings → AI → Speech.",+ stringResource(R.string.language_voice_speech_hint),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)Text(- "Transcription language",+ stringResource(R.string.language_transcription_title),style = MaterialTheme.typography.titleSmall,fontWeight = FontWeight.Bold)Text(- "The language Gotcha writes your speech down in, for voice input, calls " +- "and transcribing audio files.",+ stringResource(R.string.language_transcription_description),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)@@ -252,7 +251,7 @@ fun LanguageScreen(})Text(- transcriptionOverrideHint(initial.sttProvider),+ stringResource(transcriptionOverrideHint(initial.sttProvider)),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)@@ -274,17 +273,22 @@ fun LanguageScreen(enabled = !testingVoice,modifier = Modifier.fillMaxWidth()) {- Text(if (testingVoice) "Playing…" else "Test voice")+ Text(+ stringResource(+ if (testingVoice) R.string.language_test_voice_playing else R.string.language_test_voice+ )+ )}voiceDataMissing?.let { missingLang ->SkinAlertDialog(onDismissRequest = { voiceDataMissing = null },- title = { Text("Voice data not installed") },+ title = { Text(stringResource(R.string.language_voice_data_missing_title)) },text = {Text(- "Your device doesn't have Android's built-in voice for " +- "${missingLang.label}. It was spoken in English instead. " +- "Install the voice data to fix pronunciation."+ stringResource(+ R.string.language_voice_data_missing_body,+ stringResource(missingLang.nameRes)+ ))},confirmButton = {@@ -300,15 +304,15 @@ fun LanguageScreen(} catch (_: Exception) {Toast.makeText(localContext,- "Could not open text-to-speech settings.",+ localContext.getString(R.string.language_tts_settings_failed),Toast.LENGTH_SHORT).show()}}- ) { Text("Install") }+ ) { Text(stringResource(R.string.language_voice_data_install)) }},dismissButton = {- TextButton(onClick = { voiceDataMissing = null }) { Text("Cancel") }+ TextButton(onClick = { voiceDataMissing = null }) { Text(stringResource(R.string.action_cancel)) }})}@@ -317,13 +321,12 @@ fun LanguageScreen(// ---- 3. AI reply language ----Text(- "AI reply language",+ stringResource(R.string.language_reply_title),style = MaterialTheme.typography.titleMedium,fontWeight = FontWeight.Bold)Text(- "The language the assistant writes its answers in. Tool names, commands " +- "and file paths stay in English so they keep working.",+ stringResource(R.string.language_reply_description),style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)@@ -332,10 +335,10 @@ fun LanguageScreen(onExpandedChange = { replyExpanded = it }) {OutlinedTextField(- value = preferredLanguage,+ value = stringResource(Language.fromLabel(preferredLanguage).nameRes),onValueChange = {},readOnly = true,- label = { Text("AI reply language") },+ label = { Text(stringResource(R.string.language_reply_title)) },trailingIcon = {ExposedDropdownMenuDefaults.TrailingIcon(expanded = replyExpanded)},@@ -348,11 +351,11 @@ fun LanguageScreen(expanded = replyExpanded,onDismissRequest = { replyExpanded = false }) {- Language.labels.forEach { lang ->+ Language.entries.forEach { lang ->DropdownMenuItem(- text = { Text(lang) },+ text = { Text(stringResource(lang.nameRes)) },onClick = {- preferredLanguage = lang+ preferredLanguage = lang.labelreplyExpanded = false})@@ -363,26 +366,41 @@ fun LanguageScreen(Button(onClick = {onSave { applyLanguages(it) }- overlay.show("Saved language settings.")+ overlay.show(localContext.getString(R.string.language_saved))},modifier = Modifier.fillMaxWidth().testTag("settings_save_language")- ) { Text("Save Language Settings") }+ ) { Text(stringResource(R.string.language_save)) }}}/** What the transcription override does with the speech-to-text [provider] in use. */-internal fun transcriptionOverrideHint(provider: AudioProvider): String = when {- provider.isApiBased() ->- "Leave this empty and speech is transcribed in the voice language. Set it to " +- "force one language, which helps accuracy when the model tends to guess wrong."- provider == AudioProvider.ANDROID ->- "Only Samosa AI and external speech-to-text use this. Android Built-in " +- "always transcribes in the voice language."- else -> "Only Samosa AI and external speech-to-text use this. Speech-to-text is off."+@StringRes+internal fun transcriptionOverrideHint(provider: AudioProvider): Int = when {+ provider.isApiBased() -> R.string.language_transcription_hint_api+ provider == AudioProvider.ANDROID -> R.string.language_transcription_hint_android+ else -> R.string.language_transcription_hint_off}+/**+ * The language's name in the app's display language. [Language.label] stays the+ * stored value and the name the model and speech engines are given.+ */+@get:StringRes+internal val Language.nameRes: Int+ get() = when (this) {+ Language.ENGLISH -> R.string.language_english+ Language.SPANISH -> R.string.language_spanish+ Language.FRENCH -> R.string.language_french+ Language.GERMAN -> R.string.language_german+ Language.HINDI -> R.string.language_hindi+ Language.JAPANESE -> R.string.language_japanese+ Language.CHINESE -> R.string.language_chinese+ Language.ITALIAN -> R.string.language_italian+ Language.PORTUGUESE -> R.string.language_portuguese+ }+/*** Open the per-app language screen where it can work, otherwise the device-wide* language list. If neither activity can be started, a toast says so.@@ -418,7 +436,7 @@ internal fun openLanguageSettings(}Toast.makeText(context,- "Could not open language settings.",+ context.getString(R.string.language_display_settings_failed),Toast.LENGTH_SHORT).show()}diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 5db23d1..f758031 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -18,4 +18,44 @@<item>Third-party backends (Samosa AI or a User-Provided Provider you configure yourself) have their own terms and data-retention practices, which apply once a request leaves your phone.</item><item>You must use the App lawfully — no hacking, fraud, harassment, illegal activity, or infringement of others\' rights. You are responsible for any damage to your device or data.</item></string-array>++ <!-- Language names, shown wherever a Language is picked. -->+ <string name="language_english">English</string>+ <string name="language_spanish">Spanish</string>+ <string name="language_french">French</string>+ <string name="language_german">German</string>+ <string name="language_hindi">Hindi</string>+ <string name="language_japanese">Japanese</string>+ <string name="language_chinese">Chinese</string>+ <string name="language_italian">Italian</string>+ <string name="language_portuguese">Portuguese</string>++ <!-- Settings → Language -->+ <string name="language_page_intro">Every language Gotcha uses, in one place: what the app\'s own screens are written in, what Gotcha speaks and hears, and what it writes its answers in.</string>+ <string name="language_display_title">App display language</string>+ <string name="language_display_description">Gotcha\'s own buttons, labels and settings are in English only for now — changing this affects the rest of your phone, not this app.</string>+ <string name="language_display_open_settings">Open Android language settings</string>+ <string name="language_display_settings_failed">Could not open language settings.</string>+ <string name="language_voice_title">Voice language</string>+ <string name="language_voice_description">What Gotcha speaks aloud and listens for during voice input and calls. Leave it following the reply language unless you want answers written in one language and spoken in another.</string>+ <string name="language_voice_follow_reply">Same as AI reply language</string>+ <string name="language_voice_speech_hint">Which model and voice read it out are picked under Settings → AI → Speech.</string>+ <string name="language_transcription_title">Transcription language</string>+ <string name="language_transcription_description">The language Gotcha writes your speech down in, for voice input, calls and transcribing audio files.</string>+ <string name="language_transcription_hint_api">Leave this empty and speech is transcribed in the voice language. Set it to force one language, which helps accuracy when the model tends to guess wrong.</string>+ <string name="language_transcription_hint_android">Only Samosa AI and external speech-to-text use this. Android Built-in always transcribes in the voice language.</string>+ <string name="language_transcription_hint_off">Only Samosa AI and external speech-to-text use this. Speech-to-text is off.</string>+ <string name="language_test_voice">Test voice</string>+ <string name="language_test_voice_playing">Playing…</string>+ <string name="language_voice_data_missing_title">Voice data not installed</string>+ <string name="language_voice_data_missing_body">Your device doesn\'t have Android\'s built-in voice for %1$s. It was spoken in English instead. Install the voice data to fix pronunciation.</string>+ <string name="language_voice_data_install">Install</string>+ <string name="language_tts_settings_failed">Could not open text-to-speech settings.</string>+ <string name="language_reply_title">AI reply language</string>+ <string name="language_reply_description">The language the assistant writes its answers in. Tool names, commands and file paths stay in English so they keep working.</string>+ <string name="language_saved">Saved language settings.</string>+ <string name="language_save">Save Language Settings</string>++ <!-- Shared actions -->+ <string name="action_cancel">Cancel</string></resources>diff --git a/app/src/test/java/com/gotcha/ui/LanguageScreenTest.kt b/app/src/test/java/com/gotcha/ui/LanguageScreenTest.ktindex c80bfb2..f77a276 100644--- a/app/src/test/java/com/gotcha/ui/LanguageScreenTest.kt+++ b/app/src/test/java/com/gotcha/ui/LanguageScreenTest.kt@@ -5,6 +5,8 @@ import android.content.ContextWrapperimport android.content.Intentimport android.net.Uriimport androidx.test.core.app.ApplicationProvider+import com.gotcha.audio.AudioProvider+import com.gotcha.i18n.Languageimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertNotNullimport org.junit.Assert.assertTrue@@ -71,4 +73,21 @@ class LanguageScreenTest {openLanguageSettings(failingContext, appHasLocales = true)assertEquals("Could not open language settings.", ShadowToast.getTextOfLatestToast())}++ @Test+ fun `every language name reads as its label in English`() {+ // The stored label doubles as the English name; a mismatch would change the dropdowns.+ for (lang in Language.entries) {+ assertEquals(lang.label, context.getString(lang.nameRes))+ }+ }++ @Test+ fun `transcription hint follows the speech-to-text provider`() {+ assertEquals(+ "Only Samosa AI and external speech-to-text use this. Android Built-in " ++ "always transcribes in the voice language.",+ context.getString(transcriptionOverrideHint(AudioProvider.ANDROID))+ )+ }}