Adding checks for null to TextToSpeechSettings to handle cases
where the plugin fails to return properly from CheckVoiceData and GetSampleString.
This commit is contained in:
@@ -289,12 +289,27 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
*/
|
*/
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == VOICE_DATA_INTEGRITY_CHECK) {
|
if (requestCode == VOICE_DATA_INTEGRITY_CHECK) {
|
||||||
|
if (data == null){
|
||||||
|
// The CHECK_TTS_DATA activity for the plugin did not run properly;
|
||||||
|
// disable the preview and install controls and return.
|
||||||
|
mEnableDemo = false;
|
||||||
|
mVoicesMissing = false;
|
||||||
|
updateWidgetState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO (clchen): Add these extras to TextToSpeech.Engine
|
// TODO (clchen): Add these extras to TextToSpeech.Engine
|
||||||
ArrayList<String> available =
|
ArrayList<String> available =
|
||||||
data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES");
|
data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES");
|
||||||
ArrayList<String> unavailable =
|
ArrayList<String> unavailable =
|
||||||
data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES");
|
data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES");
|
||||||
|
if ((available == null) || (unavailable == null)){
|
||||||
|
// The CHECK_TTS_DATA activity for the plugin did not run properly;
|
||||||
|
// disable the preview and install controls and return.
|
||||||
|
mEnableDemo = false;
|
||||||
|
mVoicesMissing = false;
|
||||||
|
updateWidgetState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (available.size() > 0){
|
if (available.size() > 0){
|
||||||
if (mTts == null) {
|
if (mTts == null) {
|
||||||
mTts = new TextToSpeech(this, this);
|
mTts = new TextToSpeech(this, this);
|
||||||
@@ -335,8 +350,18 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
updateWidgetState();
|
updateWidgetState();
|
||||||
} else if (requestCode == GET_SAMPLE_TEXT) {
|
} else if (requestCode == GET_SAMPLE_TEXT) {
|
||||||
if (resultCode == TextToSpeech.LANG_AVAILABLE) {
|
if (resultCode == TextToSpeech.LANG_AVAILABLE) {
|
||||||
|
if (data == null){
|
||||||
|
// The GET_SAMPLE_TEXT activity for the plugin did not run properly;
|
||||||
|
// return without doing anything.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mTts != null) {
|
if (mTts != null) {
|
||||||
String sample = data.getExtras().getString("sampleText");
|
String sample = data.getStringExtra("sampleText");
|
||||||
|
if (sample == null){
|
||||||
|
// The GET_SAMPLE_TEXT activity for the plugin did not run properly;
|
||||||
|
// return without doing anything.
|
||||||
|
return;
|
||||||
|
}
|
||||||
mTts.speak(sample, TextToSpeech.QUEUE_FLUSH, null);
|
mTts.speak(sample, TextToSpeech.QUEUE_FLUSH, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user