speech: open voice-input settings before locale settings
- Commit
b93817cf6629e77fafb435904feb5e4c78e23c63- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-08 02:38 UTC (28 days ago)
- Parents
05b6fca
The step 2 button is labelled 'Open voice input settings' and its handler is named openVoiceInputSettings, but the candidate-intent list tried ACTION_LOCALE_SETTINGS first and launched whichever intent did not throw. Locale settings always resolves, so the loop broke on the first candidate and the voice-input screen was never opened; the user landed on the system language page with no way to pick a recognizer. Reorder the candidates to try ACTION_VOICE_INPUT_SETTINGS first, keeping locale settings and the generic settings page as fallbacks for devices with no voice-input activity. Tighten MainActivityTest to pin the launched action instead of accepting any of the three. User-visible effect: the step 2 button now opens the voice-input settings screen where this app can be selected as the recognizer. Verified with :speech:testDevUnitTest from the worktree root.
Diff
speech/src/main/java/com/vayunmathur/speech/MainActivity.kt
diff --git a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt b/speech/src/main/java/com/vayunmathur/speech/MainActivity.ktindex bce54d13c0..e681cc2755 100644--- a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt+++ b/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt@@ -143,8 +143,8 @@ private fun SetupScreen() { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } val candidates = listOf(- localeIntent, voiceInputIntent,+ localeIntent, Intent(Settings.ACTION_SETTINGS).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }, ) var launched = false
speech/src/test/java/com/vayunmathur/speech/MainActivityTest.kt
diff --git a/speech/src/test/java/com/vayunmathur/speech/MainActivityTest.kt b/speech/src/test/java/com/vayunmathur/speech/MainActivityTest.ktindex 94e207bfd9..6586e4e227 100644--- a/speech/src/test/java/com/vayunmathur/speech/MainActivityTest.kt+++ b/speech/src/test/java/com/vayunmathur/speech/MainActivityTest.kt@@ -17,7 +17,6 @@ import org.robolectric.Shadows.shadowOf import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull-import kotlin.test.assertTrue @RunWith(RobolectricTestRunner::class) class MainActivityTest {@@ -45,14 +44,7 @@ class MainActivityTest { rule.waitForIdle() val intent = shadowOf(rule.activity).nextStartedActivity assertNotNull(intent, "no activity launched for voice input settings")- assertTrue(- intent.action in listOf(- Settings.ACTION_LOCALE_SETTINGS,- Settings.ACTION_VOICE_INPUT_SETTINGS,- Settings.ACTION_SETTINGS,- ),- "unexpected settings action ${intent.action}",- )+ assertEquals(Settings.ACTION_VOICE_INPUT_SETTINGS, intent.action) } @Test