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
Add function restoreActivityState() in STTFragment.kt to make invisible views visible and perform other tasks
  • Loading branch information
shubhamkumar1739 committed Feb 15, 2020
1 parent 49800b5 commit 159f30e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/java/org/fossasia/susi/ai/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,8 @@ class ChatActivity : AppCompatActivity(), IChatView {
companion object {
val ALARM = "ALARM"
}

fun setChatSearchInputGone() {
chatSearchInput.visibility = View.GONE
}
}
5 changes: 4 additions & 1 deletion app/src/main/java/org/fossasia/susi/ai/chat/STTfragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class STTFragment : Fragment() {
val thisActivity = activity
if (thisActivity is ChatActivity) thisActivity.setText(voiceResults[0])
recognizer.destroy()
activity?.supportFragmentManager?.popBackStackImmediate()
restoreActivityState()
}

Expand Down Expand Up @@ -171,7 +172,7 @@ class STTFragment : Fragment() {
activity?.searchChat?.show()
activity?.voiceSearchChat?.show()
activity?.btnSpeak?.isEnabled = true
activity?.supportFragmentManager?.popBackStackImmediate()
(activity as ChatActivity)?.setChatSearchInputGone()
recognizer?.destroy()
}

Expand All @@ -190,6 +191,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 159f30e

Please sign in to comment.