fossasia / susi_android

SUSI.AI Android App https://play.google.com/apps/testing/ai.susi
Apache License 2.0
2.42k stars 1.11k forks source link

fix: Speech to text button on chat activity not working #2469 #2486

Open shubhamkumar1739 opened 4 years ago

shubhamkumar1739 commented 4 years ago

Fixes #2469 Speech to text button on chat activity not working

Changes: add functions to make view visible

Screenshots : ezgif com-video-to-gif(3)

ci-reporter[bot] commented 4 years ago

The build is failing

✨ Good work on this PR so far! ✨ Unfortunately, the Circle CI build is failing as of 90334f2afb214b4bdb3d736e9c6388ecb5795bb3. Here's the output:

spotless check
> Task :spotlessCheck UP-TO-DATE

I'm sure you can fix it! If you need help, don't hesitate to ask a maintainer of the project!


Failed build for 90334f2 ##### `spotless check` ``` > Task :spotlessCheck UP-TO-DATE ```
Failed build for 8accce4 ##### `lint check` ``` > Task :app:preBuild UP-TO-DATE ```
Failed build for 8accce4 ##### `lint check` ``` > Task :app:preBuild UP-TO-DATE ```
Failed build for a146cb5 ##### `spotless check` ``` > Task :spotlessCheck UP-TO-DATE ```
Failed build for a146cb5 ##### `spotless check` ``` > Task :spotlessCheck UP-TO-DATE ```

This comment was automagically generated by ci-reporter. If you see a problem, open an issue here.
pallav12 commented 4 years ago

@shubhamkumar1739 problem is bit bigger than just working of speech to text button. Notice the SearchTextView in issue gif also the icons on top are gone. Simple null check in onError of STTFragment of activity can fix the working of speech to text.

shubhamkumar1739 commented 4 years ago

Yes but I have also fixed the problem which caused the icons to disappear.

There was also another error that was occurring : you weren't able to chat with SUSI after you got stuck into this state. I have fixed that as well

pallav12 commented 4 years ago

Can you try adding a simple null check in onError rather then creating restoreActivityState() Because it not only fix both the issues you mentioned but also fix another crash issue ie start STTFragment and close it instantaneously, do this three times and app will crash. Change onError to

  if(activity!=null) {
                    Toast.makeText(activity?.applicationContext, "Could not recognize speech, try again.", Toast.LENGTH_SHORT).show()
                    speechProgress?.onResultOrOnError()
                    recognizer.destroy()
                    activity?.fabsetting?.show()
                    activity?.searchChat?.show()
                    activity?.voiceSearchChat?.show()
                    activity?.btnSpeak?.isEnabled = true
                    activity?.supportFragmentManager?.popBackStackImmediate()
                }

Just give it a try...

shubhamkumar1739 commented 4 years ago

Actually adding null check on onError didn't work. But i realised i had missed some implementations. So i pushed the changes again.

shubhamkumar1739 commented 4 years ago

Please look at it now. I dont think the app will crash now.

pallav12 commented 4 years ago

It is... Screenshot (12)

gif

shubhamkumar1739 commented 4 years ago

What I was saying that applying null check in onError didn't fix the "invisible view" issue. This crash issue isn't occurring on my device as well as other devices that I tested on. But I will apply the null check nonetheless :)

pallav12 commented 4 years ago

No don't... Im not a mentor, it's just a suggestion... Btw my device is oppo a3s, it fixed the crash issue

shubhamkumar1739 commented 4 years ago

Since the problem is occurring frequently, it's better to fix it. You don't have to be a mentor to help. Thanks a lot.