01/01: fixes #1035 [Settings] Error when no text to speech engine is installed
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository say-my-texts. See http://git.chorem.org/say-my-texts.git commit 0d6bd9172c6d715ae11ebca5f191dae020ec3dbb Author: Kevin Morin <morin@codelutin.com> Date: Mon Jun 16 17:00:37 2014 +0200 fixes #1035 [Settings] Error when no text to speech engine is installed --- res/values-fr/strings.xml | 3 +++ res/values/strings.xml | 3 +++ .../android/saymytexts/SayMyTextService.java | 4 +++- .../android/saymytexts/SettingsActivity.java | 25 ++++++++++++++++------ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index ad19591..f8c3754 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -26,6 +26,9 @@ <string name="preference_ask_phone_number_title">Votre numéro</string> <string name="preference_ask_phone_number_message">Veuillez saisir votre numéro pour l\'envoi du SMS de test</string> + <string name="texttospeech_init_error">Erreur lors de l\'initialisation de la synthèse vocale.</string> + <string name="texttospeech_not_installed">L\'application a besoin d\'un moteur de synthèse vocale. Veuillez en installer un. </string> + <!--ACRA--> <string name="crash_toast_text">Erreur innatendue, préparation du rapport de bug</string> <string name="crash_dialog_title">Say My Texts a planté</string> diff --git a/res/values/strings.xml b/res/values/strings.xml index d0a3ba0..d8792de 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,6 +26,9 @@ <string name="preference_ask_phone_number_title">Your phone number</string> <string name="preference_ask_phone_number_message">Enter your phone number to send the text</string> + <string name="texttospeech_init_error">Error during text to speech initialization.</string> + <string name="texttospeech_not_installed">The application needs a text to speech engine to work. Please install one.</string> + <!--ACRA--> <string name="crash_toast_text">Ooooops ! the application crashed, but a report has been sent to my developer to help fix the issue !</string> <string name="crash_dialog_title">say My Texts has crashed</string> diff --git a/src/org/chorem/android/saymytexts/SayMyTextService.java b/src/org/chorem/android/saymytexts/SayMyTextService.java index 3222042..61b7c0c 100644 --- a/src/org/chorem/android/saymytexts/SayMyTextService.java +++ b/src/org/chorem/android/saymytexts/SayMyTextService.java @@ -39,6 +39,7 @@ import android.speech.tts.UtteranceProgressListener; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; +import android.widget.Toast; import com.google.common.base.Function; import java.util.ArrayList; @@ -310,7 +311,8 @@ public class SayMyTextService extends Service implements TextToSpeech.OnInitList } else { setCanSpeak(null); - textToSpeech = new TextToSpeech(this, this); + Toast.makeText(this, R.string.texttospeech_init_error, Toast.LENGTH_LONG).show(); + this.stopSelf(); } } diff --git a/src/org/chorem/android/saymytexts/SettingsActivity.java b/src/org/chorem/android/saymytexts/SettingsActivity.java index 668cb67..be81be4 100644 --- a/src/org/chorem/android/saymytexts/SettingsActivity.java +++ b/src/org/chorem/android/saymytexts/SettingsActivity.java @@ -27,6 +27,7 @@ package org.chorem.android.saymytexts; import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -45,6 +46,7 @@ import android.telephony.TelephonyManager; import android.text.InputType; import android.util.Log; import android.widget.EditText; +import android.widget.Toast; /** * Activity to set settings @@ -66,18 +68,29 @@ public class SettingsActivity extends Activity { .replace(android.R.id.content, new SettingsFragment()) .commit(); - Intent checkIntent = new Intent(); - checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); - startActivityForResult(checkIntent, CHECK_TTS_REQUEST_CODE); + try { + Intent checkIntent = new Intent(); + checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); + startActivityForResult(checkIntent, CHECK_TTS_REQUEST_CODE); + + } catch(ActivityNotFoundException eee) { + Log.e(TAG, "No activity found fo texttospeech", eee); + Toast.makeText(this, R.string.texttospeech_not_installed, Toast.LENGTH_LONG).show(); + } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CHECK_TTS_REQUEST_CODE) { - if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL) { - Intent installIntent = new Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); - startActivity(installIntent); + try { + if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL) { + Intent installIntent = new Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); + startActivity(installIntent); + } + } catch(ActivityNotFoundException eee) { + Log.e(TAG, "No activity found fo texttospeech", eee); + Toast.makeText(this, R.string.texttospeech_not_installed, Toast.LENGTH_LONG).show(); } } else { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm