From 3bbbc686d79a22a9b5727f7ad1d09532e82cdec1 Mon Sep 17 00:00:00 2001 From: Inhishonor Date: Wed, 19 Feb 2025 13:29:29 -0800 Subject: [PATCH] Add code to check if there is a STT provider on device. --- .../com/moez/QKSMS/feature/compose/ComposeActivity.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 06f12a9a..31b4b161 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -155,6 +155,17 @@ class ComposeActivity : QkThemedActivity(), ComposeView { showBackButton(true) viewModel.bindView(this) + // Check if there is a speech recognition service available + val packageManager = packageManager + val speechRecognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) + val resolveInfoList = packageManager.queryIntentActivities(speechRecognizerIntent, PackageManager.MATCH_DEFAULT_ONLY) + + if (resolveInfoList.isEmpty()) { + // No STT provider found, show a Toast message + Toast.makeText(this, "No speech-to-text service available on this device.", Toast.LENGTH_SHORT).show() + } + + contentView.layoutTransition = LayoutTransition().apply { disableTransitionType(LayoutTransition.CHANGING) }