OSDN Git Service

Use the current Locale as the default language when TTS settings are not
authorJean-Michel Trivi <jmtrivi@google.com>
Tue, 7 Jul 2009 00:58:52 +0000 (17:58 -0700)
committerJean-Michel Trivi <jmtrivi@google.com>
Tue, 7 Jul 2009 01:02:08 +0000 (18:02 -0700)
found, rather than a hardcoded value stored in TextToSpeech.Engine.

packages/TtsService/src/android/tts/TtsService.java

index 0bed72b..10f4d6e 100755 (executable)
@@ -36,6 +36,7 @@ import android.util.Log;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.concurrent.locks.ReentrantLock;
 
 /**
@@ -183,7 +184,8 @@ public class TtsService extends Service implements OnCompletionListener {
         String defaultLang = android.provider.Settings.Secure.getString(mResolver,
                 android.provider.Settings.Secure.TTS_DEFAULT_LANG);
         if (defaultLang == null) {
-            return TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_LANG;
+            // no setting found, use the current Locale to determine the default language
+            return Locale.getDefault().getISO3Language();
         } else {
             return defaultLang;
         }
@@ -194,7 +196,8 @@ public class TtsService extends Service implements OnCompletionListener {
         String defaultCountry = android.provider.Settings.Secure.getString(mResolver,
                 android.provider.Settings.Secure.TTS_DEFAULT_COUNTRY);
         if (defaultCountry == null) {
-            return TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
+            // no setting found, use the current Locale to determine the default country
+            return Locale.getDefault().getISO3Country();
         } else {
             return defaultCountry;
         }
@@ -205,7 +208,8 @@ public class TtsService extends Service implements OnCompletionListener {
         String defaultVar = android.provider.Settings.Secure.getString(mResolver,
                 android.provider.Settings.Secure.TTS_DEFAULT_VARIANT);
         if (defaultVar == null) {
-            return TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
+            // no setting found, use the current Locale to determine the default variant
+            return Locale.getDefault().getVariant();
         } else {
             return defaultVar;
         }