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
Shubham Kumar committed Feb 7, 2020
1 parent 388d20b commit cea4b42
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 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,13 +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
restoreActivityState()
activity?.supportFragmentManager?.popBackStackImmediate()
}

Expand Down Expand Up @@ -169,7 +163,16 @@ 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?.chatSearchInput?.visibility = View.GONE
}
override fun onPause() {
super.onPause()
if (thisActivity is ChatActivity) {
Expand Down

0 comments on commit cea4b42

Please sign in to comment.