Android Open Source - Android-TTSNotifier T T S Notifier Preferences






From Project

Back to project page Android-TTSNotifier.

License

The source code is released under:

GNU General Public License

If you think the Android project Android-TTSNotifier listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package vub.lhoste.ttsnotifier;
/*from w w  w  .  j  a  v  a2s  .  c om*/
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceClickListener;

public class TTSNotifierPreferences extends PreferenceActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Activity ctx = this;
    addPreferencesFromResource(R.xml.preferences);
    if (!TTSDispatcher.isTtsBetaInstalled(this)) {
      TTSDispatcher.notifyTTSBeta(ctx);
    }
    Intent svc = new Intent(this, TTSNotifierService.class);
    startService(svc);
    // Assign the buttons
    Preference customPref;
    customPref = (Preference) findPreference("btnTestTTS");
    customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
      public boolean onPreferenceClick(Preference preference) {
        TTSNotifierService.waitForSpeechInitialised();
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        TTSNotifierService.setLanguage(prefs.getBoolean("cbxChangeLanguage", false), prefs.getString("txtLanguage", "English"));
        TTSNotifierService.speak(TTSNotifierService.myLanguage.getTxtTest(), false);
        return true;
      }
    });
    customPref = (Preference) findPreference("btnInstallTTSBeta");
    if (TTSDispatcher.isTtsBetaInstalled(ctx)) {
      customPref.setEnabled(false);
    } else {
      customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        public boolean onPreferenceClick(Preference preference) {
          TTSDispatcher.installTTSBeta(ctx);
          return true;
        }
      });
    }
    
  }
  
  @Override
  public void onDestroy() {
    super.onDestroy();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    TTSNotifierService.setLanguage(prefs.getBoolean("cbxChangeLanguage", false), prefs.getString("txtLanguage", "English"));
  }
  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    TTSNotifierService.setLanguage(prefs.getBoolean("cbxChangeLanguage", false), prefs.getString("txtLanguage", "English"));
  }
}




Java Source Code List

vub.lhoste.ttsnotifier.TTSDispatcher.java
vub.lhoste.ttsnotifier.TTSNotifierLanguageDE.java
vub.lhoste.ttsnotifier.TTSNotifierLanguageEN.java
vub.lhoste.ttsnotifier.TTSNotifierLanguageFR.java
vub.lhoste.ttsnotifier.TTSNotifierLanguageNL.java
vub.lhoste.ttsnotifier.TTSNotifierLanguage.java
vub.lhoste.ttsnotifier.TTSNotifierPreferences.java
vub.lhoste.ttsnotifier.TTSNotifierReceiver.java
vub.lhoste.ttsnotifier.TTSNotifierService.java
vub.lhoste.ttsnotifier.TTSNotifierStartServiceActivity.java