Skip to content

Commit c59a7c0

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

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 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) {
@@ -170,6 +163,18 @@ class STTFragment : Fragment() {
170163
recognizer.startListening(intent)
171164
}
172165

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+
recognizer?.destroy()
176+
}
177+
173178
override fun onPause() {
174179
super.onPause()
175180
if (thisActivity is ChatActivity) {

0 commit comments

Comments
 (0)