Skip to content

Commit a146cb5

Browse files
fix: speech to text button on chat activity not working #2469
1 parent 388d20b commit a146cb5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

app/src/main/java/org/fossasia/susi/ai/chat/STTfragment.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,7 @@ class STTFragment : Fragment() {
113113
val thisActivity = activity
114114
if (thisActivity is ChatActivity) thisActivity.setText(voiceResults[0])
115115
recognizer.destroy()
116-
if ((activity as ChatActivity).recordingThread != null) {
117-
chatPresenter.startHotwordDetection()
118-
}
119-
(activity as ChatActivity).fabsetting.show()
120-
activity?.searchChat?.show()
121-
activity?.voiceSearchChat?.show()
122-
activity?.btnSpeak?.isEnabled = true
123-
activity?.supportFragmentManager?.popBackStackImmediate()
116+
restoreActivityState()
124117
}
125118

126119
override fun onReadyForSpeech(params: Bundle) {
@@ -169,6 +162,17 @@ class STTFragment : Fragment() {
169162
recognizer.setRecognitionListener(listener)
170163
recognizer.startListening(intent)
171164
}
165+
166+
private fun restoreActivityState() {
167+
if ((activity as ChatActivity).recordingThread != null) {
168+
chatPresenter.startHotwordDetection()
169+
}
170+
(activity as ChatActivity).fabsetting.show()
171+
activity?.searchChat?.show()
172+
activity?.voiceSearchChat?.show()
173+
activity?.btnSpeak?.isEnabled = true
174+
activity?.supportFragmentManager?.popBackStackImmediate()
175+
}
172176

173177
override fun onPause() {
174178
super.onPause()

0 commit comments

Comments
 (0)