Fix for text to speech crash #457

This commit is contained in:
mhutti1 2017-02-11 19:27:17 +00:00
parent b7f7d2524f
commit b70acca2b6
2 changed files with 10 additions and 1 deletions

View File

@ -161,4 +161,5 @@
<string name="confirm_stop_download_title">Stop download?</string>
<string name="confirm_stop_download_msg">Are you sure you want to stop this download?</string>
<string name="download_change_storage">Storage device selector</string>
<string name="tts_not_enabled">Text to speech is not enabled for this ZIM file</string>
</resources>

View File

@ -84,11 +84,19 @@ public class KiwixTextToSpeech {
} else {
Locale locale = LanguageUtils.ISO3ToLocale(ZimContentProvider.getLanguage());
int result;
if (ZimContentProvider.getLanguage().equals("mul")) {
Log.d(TAG_KIWIX, "TextToSpeech: disabled " +
ZimContentProvider.getLanguage());
Toast.makeText(context,
context.getResources().getString(R.string.tts_not_enabled),
Toast.LENGTH_LONG).show();
return;
}
if (locale == null
|| (result = tts.isLanguageAvailable(locale)) == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.d(TAG_KIWIX, "TextToSpeech: language not supported: " +
ZimContentProvider.getLanguage() + " (" + locale.getLanguage() + ")");
ZimContentProvider.getLanguage());
Toast.makeText(context,
context.getResources().getString(R.string.tts_lang_not_supported),
Toast.LENGTH_LONG).show();