eSpeakActivity: do not initiate an install of the voice data when the voice data is not installed

This commit is contained in:
Reece H. Dunn
2013-05-08 15:11:19 +01:00
parent 8bdb644285
commit 72bfb4205f
@@ -18,10 +18,7 @@
package com.reecedunn.espeak; package com.reecedunn.espeak;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@@ -61,7 +58,6 @@ public class eSpeakActivity extends Activity {
} }
private State mState; private State mState;
private boolean mDownloadedVoiceData;
private ArrayList<String> mVoices; private ArrayList<String> mVoices;
private TextToSpeech mTts; private TextToSpeech mTts;
private List<Pair<String,String>> mInformation; private List<Pair<String,String>> mInformation;
@@ -167,17 +163,6 @@ public class eSpeakActivity extends Activity {
startActivityForResult(checkIntent, REQUEST_CHECK); startActivityForResult(checkIntent, REQUEST_CHECK);
} }
/**
* Launches the voice data installer.
*/
private void downloadVoiceData() {
final IntentFilter filter = new IntentFilter(DownloadVoiceData.BROADCAST_LANGUAGES_UPDATED);
registerReceiver(mDownloadReceiver, filter);
final Intent checkIntent = new Intent(this, DownloadVoiceData.class);
startActivity(checkIntent);
}
/** /**
* Initializes the TTS engine. * Initializes the TTS engine.
*/ */
@@ -240,18 +225,12 @@ public class eSpeakActivity extends Activity {
*/ */
private void onDataChecked(int resultCode, Intent data) { private void onDataChecked(int resultCode, Intent data) {
if (resultCode != TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { if (resultCode != TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
if (mDownloadedVoiceData) { Log.e(TAG, "Voice data check failed (error code: " + resultCode + ").");
Log.e(TAG, "Voice data check failed (error code: " + resultCode + ")."); setState(State.ERROR);
setState(State.ERROR); } else {
populateInformationView(); mVoices = data.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
} else {
downloadVoiceData();
}
return;
} }
mVoices = data.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
initializeEngine(); initializeEngine();
populateInformationView(); populateInformationView();
} }
@@ -329,12 +308,4 @@ public class eSpeakActivity extends Activity {
} }
startActivityForResult(intent, REQUEST_DEFAULT); startActivityForResult(intent, REQUEST_DEFAULT);
} }
private final BroadcastReceiver mDownloadReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
mDownloadedVoiceData = true;
checkVoiceData();
}
};
} }