From c0991bad280488a4b45b1819f8ac64a30820103d Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Thu, 18 Mar 2010 20:24:49 -0700 Subject: Adding an EngineSettings screen to Pico that enables languages to be installed individually. Change-Id: I29f98ff65a3c8c90747f635d0ad3887ab27a65d7 --- pico/AndroidManifest.xml | 7 +++ pico/res/values/strings.xml | 2 + pico/res/xml/voices_list.xml | 39 ++++++++++++++ pico/src/com/svox/pico/EngineSettings.java | 87 ++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100755 pico/res/xml/voices_list.xml create mode 100755 pico/src/com/svox/pico/EngineSettings.java (limited to 'pico') diff --git a/pico/AndroidManifest.xml b/pico/AndroidManifest.xml index fcf6980..c8cb570 100755 --- a/pico/AndroidManifest.xml +++ b/pico/AndroidManifest.xml @@ -55,6 +55,13 @@ + + + + + + + diff --git a/pico/res/values/strings.xml b/pico/res/values/strings.xml index f68995a..932403d 100755 --- a/pico/res/values/strings.xml +++ b/pico/res/values/strings.xml @@ -26,4 +26,6 @@ Dies ist ein Beispiel für Sprachsynthese in Deutsch mit Pico. Questo è un esempio di sintesi vocale in italiano con Pico. Este es un ejemplo de síntesis de voz en español con Pico. + Installed + Not Installed diff --git a/pico/res/xml/voices_list.xml b/pico/res/xml/voices_list.xml new file mode 100755 index 0000000..3b7e640 --- /dev/null +++ b/pico/res/xml/voices_list.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/pico/src/com/svox/pico/EngineSettings.java b/pico/src/com/svox/pico/EngineSettings.java new file mode 100755 index 0000000..dee798a --- /dev/null +++ b/pico/src/com/svox/pico/EngineSettings.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.svox.pico; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.Preference.OnPreferenceClickListener; +import android.util.Log; + +import java.util.ArrayList; +import java.util.Locale; + +/* + * Checks if the voice data for the SVOX Pico Engine is present on the + * sd card. + */ +public class EngineSettings extends PreferenceActivity { + private final static String MARKET_URI_START = "market://search?q=pname:com.svox.pico.voice."; + private static final int VOICE_DATA_CHECK_CODE = 42; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent i = new Intent(); + i.setClass(this, CheckVoiceData.class); + startActivityForResult(i, VOICE_DATA_CHECK_CODE); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data){ + if (requestCode == VOICE_DATA_CHECK_CODE){ + ArrayList available = data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES"); + ArrayList unavailable = data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES"); + + addPreferencesFromResource(R.xml.voices_list); + + for (int i = 0; i < available.size(); i++){ + Log.e("debug", available.get(i)); + String[] languageCountry = available.get(i).split("-"); + Locale loc = new Locale(languageCountry[0], languageCountry[1]); + Preference pref = findPreference(available.get(i)); + pref.setTitle(loc.getDisplayLanguage() + " (" + loc.getDisplayCountry() + ")"); + pref.setSummary(R.string.installed); + pref.setEnabled(false); + } + + + for (int i = 0; i < unavailable.size(); i++){ + final String unavailableLang = unavailable.get(i); + String[] languageCountry = unavailableLang.split("-"); + Locale loc = new Locale(languageCountry[0], languageCountry[1]); + Preference pref = findPreference(unavailableLang); + pref.setTitle(loc.getDisplayLanguage() + " (" + loc.getDisplayCountry() + ")"); + pref.setSummary(R.string.not_installed); + pref.setEnabled(true); + pref.setOnPreferenceClickListener(new OnPreferenceClickListener(){ + public boolean onPreferenceClick(Preference preference) { + Uri marketUri = Uri.parse(MARKET_URI_START + unavailableLang.toLowerCase().replace("-", ".")); + Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); + startActivity(marketIntent); + return false; + } + }); + } + } + } + + +} -- cgit v1.1