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 5, 2020
1 parent 3799b9d commit 6ea0d22
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 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 @@ -116,14 +116,7 @@ class STTFragment : Fragment() {
speechProgress.onResultOrOnError()
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 @@ -175,6 +168,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?.chatSearchInput?.visibility = View.GONE
recognizer?.destroy()
}

override fun onPause() {
super.onPause()
if (thisActivity is ChatActivity) {
Expand All @@ -190,6 +195,8 @@ class STTFragment : Fragment() {

override fun onDestroyView() {
super.onDestroyView()
restoreActivityState()
activity?.supportFragmentManager?.popBackStack()
mainHandler.removeCallbacks(runnable)
subHandler.removeCallbacks(delayRunnable)
}
Expand Down

0 comments on commit 6ea0d22

Please sign in to comment.