Skip to content

Commit

Permalink
fix: speech to text button on chat activity not working #2469
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamkumar1739 committed Feb 7, 2020
1 parent 388d20b commit a146cb5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/src/main/java/org/fossasia/susi/ai/chat/STTfragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,7 @@ class STTFragment : Fragment() {
val thisActivity = activity
if (thisActivity is ChatActivity) thisActivity.setText(voiceResults[0])
recognizer.destroy()
if ((activity as ChatActivity).recordingThread != null) {
chatPresenter.startHotwordDetection()
}
(activity as ChatActivity).fabsetting.show()
activity?.searchChat?.show()
activity?.voiceSearchChat?.show()
activity?.btnSpeak?.isEnabled = true
activity?.supportFragmentManager?.popBackStackImmediate()
restoreActivityState()
}

override fun onReadyForSpeech(params: Bundle) {
Expand Down Expand Up @@ -169,6 +162,17 @@ class STTFragment : Fragment() {
recognizer.setRecognitionListener(listener)
recognizer.startListening(intent)
}

private fun restoreActivityState() {
if ((activity as ChatActivity).recordingThread != null) {
chatPresenter.startHotwordDetection()
}
(activity as ChatActivity).fabsetting.show()
activity?.searchChat?.show()
activity?.voiceSearchChat?.show()
activity?.btnSpeak?.isEnabled = true
activity?.supportFragmentManager?.popBackStackImmediate()
}

override fun onPause() {
super.onPause()
Expand Down

0 comments on commit a146cb5

Please sign in to comment.