From 56963a80c6992f5f111470852b13e32c59c95be8 Mon Sep 17 00:00:00 2001 From: rsudev Date: Sun, 25 Aug 2013 17:08:54 +0200 Subject: Fixes #2770, TTS not starting Fixes #3177, TTS talking compass does not uses force English as well - moving checks to SpeechService, avoiding calling the intent - set requested locale to 'en' if 'forceEnglish' --- main/src/cgeo/geocaching/speech/SpeechService.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'main/src/cgeo/geocaching/speech') diff --git a/main/src/cgeo/geocaching/speech/SpeechService.java b/main/src/cgeo/geocaching/speech/SpeechService.java index ae289ed..1907bfc 100644 --- a/main/src/cgeo/geocaching/speech/SpeechService.java +++ b/main/src/cgeo/geocaching/speech/SpeechService.java @@ -1,7 +1,9 @@ package cgeo.geocaching.speech; import cgeo.geocaching.DirectionProvider; +import cgeo.geocaching.R; import cgeo.geocaching.cgeoapplication; +import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.GeoDirHandler; @@ -14,6 +16,7 @@ import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.speech.tts.TextToSpeech; +import android.speech.tts.TextToSpeech.Engine; import android.speech.tts.TextToSpeech.OnInitListener; import java.util.Locale; @@ -144,11 +147,19 @@ public class SpeechService extends Service implements OnInitListener { return; } - int switchLocale = tts.setLanguage(Locale.getDefault()); + Locale locale = Locale.getDefault(); + if (Settings.isUseEnglish()) { + locale = Locale.ENGLISH; + } + + int switchLocale = tts.setLanguage(locale); - if (switchLocale == TextToSpeech.LANG_MISSING_DATA - || switchLocale == TextToSpeech.LANG_NOT_SUPPORTED) { + if (switchLocale == TextToSpeech.LANG_MISSING_DATA) { + startingActivity.startActivity(new Intent(Engine.ACTION_INSTALL_TTS_DATA)); + return; + } else if (switchLocale == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("Current languge not supported by text to speech."); + ActivityMixin.showToast(startingActivity, R.string.err_tts_lang_not_supported); return; } -- cgit v1.1