speech: open app settings on permanent mic-permission denial
- Commit
6a4b4eaa2decbc1ba9d828a31e6ca12f4591f497- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-16 16:05 UTC (3 months ago)
- Parents
3a7bc52
Route the 'Grant microphone' button through the shared rememberPermissionRequest helper so that after permanent RECORD_AUDIO denial it opens app settings instead of doing nothing; the refresh++ grant-state refresh is preserved.
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 5af387bbcb..e33067d7e0 100644--- a/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt+++ b/speech/src/main/java/com/vayunmathur/speech/MainActivity.kt@@ -14,10 +14,8 @@ import android.speech.RecognizerIntent import android.speech.SpeechRecognizer import android.speech.tts.TextToSpeech import androidx.activity.ComponentActivity-import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge-import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row@@ -59,6 +57,7 @@ import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.rememberPermissionRequest import com.vayunmathur.library.util.DataStoreUtils import com.vayunmathur.speech.service.WhisperRecognitionService import com.vayunmathur.speech.util.PiperModel@@ -152,8 +151,8 @@ private fun SetupScreen() { Settings.Secure.getString(context.contentResolver, "tts_default_synth") == context.packageName } - val micPermission = rememberLauncherForActivityResult(- ActivityResultContracts.RequestPermission()+ val launchMicRequest = rememberPermissionRequest(+ Manifest.permission.RECORD_AUDIO ) { refresh++ } SpeechSetupScreen(@@ -168,8 +167,7 @@ private fun SetupScreen() { currentTestLang = if (installedCodes.isNotEmpty()) installedCodes.first() else "en", ), actions = object : SpeechSetupActions {- override fun requestMicPermission() =- micPermission.launch(Manifest.permission.RECORD_AUDIO)+ override fun requestMicPermission() = launchMicRequest() override fun openVoiceInputSettings() { val localeIntent = Intent(Settings.ACTION_LOCALE_SETTINGS).apply {