Speech to text dialog displays custom app name

This commit is contained in:
Elad Keyshawn 2016-06-07 01:28:57 +03:00
parent a66c6c02a7
commit 284f44b364
2 changed files with 3 additions and 2 deletions

View File

@ -87,6 +87,6 @@
<string name="pref_extras">Extras</string>
<string name="new_tab_snackbar">Article opened in new tab</string>
<string name="search_widget_text">Search Kiwix</string>
<string name="speech_prompt_text">Speak to search Kiwix</string>
<string name="speech_prompt_text">Speak to search %s</string>
<string name="speech_not_supported">Sorry! Your device does not support speech input</string>
</resources>

View File

@ -173,12 +173,13 @@ public class SearchActivity extends AppCompatActivity
private void promptSpeechInput() {
String appName = getResources().getString(R.string.app_name);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); // TODO: choose selected lang on kiwix
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
getString(R.string.speech_prompt_text));
String.format(getString(R.string.speech_prompt_text), appName));
try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException a) {