Skip to content

Commit

Permalink
fix: speech to text button on chat activity not working fossasia#2469
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamkumar1739 committed Feb 7, 2020
1 parent 388d20b commit c59a7c0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 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 @@ -170,6 +163,18 @@ class STTFragment : Fragment() {
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()
recognizer?.destroy()
}

override fun onPause() {
super.onPause()
if (thisActivity is ChatActivity) {
Expand Down

0 comments on commit c59a7c0

Please sign in to comment.