Browse Source

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

master
Reece H. Dunn 12 years ago
parent
commit
72bfb4205f
1 changed files with 4 additions and 33 deletions
  1. 4
    33
      android/src/com/reecedunn/espeak/eSpeakActivity.java

+ 4
- 33
android/src/com/reecedunn/espeak/eSpeakActivity.java View File

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;
} }


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;
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.
*/ */
*/ */
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 + ").");
setState(State.ERROR);
populateInformationView();
} else {
downloadVoiceData();
}
return;
Log.e(TAG, "Voice data check failed (error code: " + resultCode + ").");
setState(State.ERROR);
} else {
mVoices = data.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
} }


mVoices = data.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);

initializeEngine(); initializeEngine();
populateInformationView(); populateInformationView();
} }
} }
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();
}
};
} }

Loading…
Cancel
Save