From 140b4957fe9dc746ff715e51b1d1568d2ac36531 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sun, 1 Jan 2017 13:03:11 +0100 Subject: [PATCH] DroidFish: Workaround for bug in Samsung text to speech implementation. --- DroidFish/src/org/petero/droidfish/Speech.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DroidFish/src/org/petero/droidfish/Speech.java b/DroidFish/src/org/petero/droidfish/Speech.java index f697c87..39bfa5c 100644 --- a/DroidFish/src/org/petero/droidfish/Speech.java +++ b/DroidFish/src/org/petero/droidfish/Speech.java @@ -68,7 +68,13 @@ public class Speech { initialized = true; int toast = -1; if (status == TextToSpeech.SUCCESS) { - int code = tts.setLanguage(loc); + int code = TextToSpeech.LANG_NOT_SUPPORTED; + try { + code = tts.setLanguage(loc); + } catch (Throwable t) { + // Some Samsung devices are broken and throw an + // exception if the language is not supported + } switch (code) { case TextToSpeech.LANG_AVAILABLE: case TextToSpeech.LANG_COUNTRY_AVAILABLE: @@ -216,7 +222,7 @@ public class Speech { case EN: return Locale.US; case DE: - return Locale.GERMAN; + return Locale.GERMANY; case NONE: return null; }