Skip to content

Commit 0313ee1

Browse files
committed
fix: disable stop listening feature for android 9 and 10
Disabling stop listening button for Android > 8. `SpeechRecognizer.stopListening()` is not behaving as expected. @see: https://issuetracker.google.com/issues/158198432
1 parent 6459f92 commit 0313ee1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

voice/src/main/kotlin/com/algolia/instantsearch/voice/ui/VoiceInputDialogFragment.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.algolia.instantsearch.voice.ui
22

3+
import android.os.Build
34
import android.os.Bundle
4-
import androidx.constraintlayout.widget.ConstraintLayout
5-
import androidx.fragment.app.DialogFragment
65
import android.view.LayoutInflater
76
import android.view.View
87
import android.view.ViewGroup
8+
import androidx.constraintlayout.widget.ConstraintLayout
9+
import androidx.fragment.app.DialogFragment
910
import com.algolia.instantsearch.voice.R
1011
import com.algolia.instantsearch.voice.VoiceSpeechRecognizer
1112

@@ -73,7 +74,12 @@ class VoiceInputDialogFragment : DialogFragment() {
7374
androidView.setOnClickListenerClose { dismiss() }
7475
androidView.setOnClickMicrophoneListener {
7576
when (androidView.getMicrophoneState()) {
76-
VoiceMicrophone.State.Activated -> speechRecognizer.stop()
77+
VoiceMicrophone.State.Activated -> {
78+
// Disabling stop listening button for Android > 8.
79+
// `SpeechRecognizer.stopListening()` is not behaving as expected.
80+
// @see: https://issuetracker.google.com/issues/158198432
81+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) speechRecognizer.stop()
82+
}
7783
VoiceMicrophone.State.Deactivated -> speechRecognizer.start()
7884
}
7985
}

0 commit comments

Comments
 (0)