File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
kotlin/com/algolia/instantsearch/voice/ui Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,15 @@ class VoiceAndroidView(
2424 }
2525
2626 override fun setSuggestions (suggestions : Array <out String >) {
27- val formattedSuggestions = suggestions.joinToString(" " ) { formatterSuggestion(it) }
28- val html = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
29- Html .fromHtml(formattedSuggestions, Html .FROM_HTML_MODE_LEGACY )
30- } else {
31- Html .fromHtml(formattedSuggestions)
27+ view.suggestions?.let {
28+ val formattedSuggestions = suggestions.joinToString(" " ) { formatterSuggestion(it) }
29+ val html = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
30+ Html .fromHtml(formattedSuggestions, Html .FROM_HTML_MODE_LEGACY )
31+ } else {
32+ Html .fromHtml(formattedSuggestions)
33+ }
34+ it.text = html
3235 }
33-
34- view.suggestions.text = html
3536 }
3637
3738 override fun setTitle (title : VoiceUI .Title ) {
@@ -47,7 +48,7 @@ class VoiceAndroidView(
4748 }
4849
4950 override fun setSuggestionVisibility (isVisible : Boolean ) {
50- view.voiceInput.suggestions.visibility = if (isVisible) View .VISIBLE else View .INVISIBLE
51+ view.voiceInput.suggestions? .visibility = if (isVisible) View .VISIBLE else View .INVISIBLE
5152 }
5253
5354 override fun setHintVisibility (isVisible : Boolean ) {
Original file line number Diff line number Diff line change @@ -72,12 +72,12 @@ class VoiceInputDialogFragment : DialogFragment() {
7272 VoiceMicrophone .State .Deactivated -> speechRecognizer.start()
7373 }
7474 })
75- suggestions?.let (androidView::setSuggestions)
76- speechRecognizer.setRecognitionListener(presenter)
77- speechRecognizer.stateListener = presenter
75+ suggestions?.let {
76+ androidView.setSuggestions(it)
77+ androidView.setSubtitle(resources.getString(R .string.input_subtitle_listening))
78+ }
7879 }
7980
80-
8181 override fun onResume () {
8282 super .onResume()
8383 if (autoStart) start()
Original file line number Diff line number Diff line change 11<resources >
22 <!-- region VoiceInputDialogFragment -->
33 <string name =" input_title_listening" >Listening…</string >
4- <string name =" input_subtitle_listening" >Say something like:</string >
4+ <string name =" input_subtitle_listening" >Say something</string >
5+ <string name =" input_subtitle_suggestions" >Say something like:</string >
56 <string name =" input_title_error" >Sorry, we didn\'t quite get that.</string >
67 <string name =" input_subtitle_error" >Try repeating your request.</string >
78 <string name =" input_hint_error" >Try again</string >
You can’t perform that action at this time.
0 commit comments