Android Open Source - callerid-for-android Preferences Activity






From Project

Back to project page callerid-for-android.

License

The source code is released under:

GNU General Public License

If you think the Android project callerid-for-android 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 com.integralblue.callerid;
//from  w  w w .  j av  a  2  s.c  o m
import com.google.inject.Inject;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import roboguice.activity.RoboPreferenceActivity;

public class PreferencesActivity extends RoboPreferenceActivity implements OnSharedPreferenceChangeListener {
  final static int CHECK_TTS_DATA = 0;
  
  @Inject SharedPreferences sharedPreferences;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
  }

  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if("tts_enabled".equals(key) && sharedPreferences.getBoolean("tts_enabled", true)){
      //make sure the TTS data has been installed
      Intent checkIntent = new Intent();
      checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
      startActivityForResult(checkIntent, CHECK_TTS_DATA);
    }
  }
  
  @Override
  protected void onActivityResult(
          int requestCode, int resultCode, Intent data) {
      if (requestCode == CHECK_TTS_DATA) {
          if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
            // no problem - all is good
          } else {
              // missing data, install it
              Intent installIntent = new Intent();
              installIntent.setAction(
                  TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
              startActivity(installIntent);
              
              //since TTS isn't available, set the preference back to disabled
            Editor editor = sharedPreferences.edit();
            editor.putBoolean("tts_enabled", false);
            editor.commit();
          }
      }
  }
}




Java Source Code List

com.blundell.tut.LoaderImageView.java
com.integralblue.callerid.CallerIDApplication.java
com.integralblue.callerid.CallerIDBroadcastReceiver.java
com.integralblue.callerid.CallerIDLookup.java
com.integralblue.callerid.CallerIDResult.java
com.integralblue.callerid.CallerIDService.java
com.integralblue.callerid.GeocoderAsyncTask.java
com.integralblue.callerid.HttpCallerIDLookup.java
com.integralblue.callerid.LookupAsyncTask.java
com.integralblue.callerid.LookupFragment.java
com.integralblue.callerid.MainActivity.java
com.integralblue.callerid.PreferencesActivity.java
com.integralblue.callerid.RecentCallsFragment.java
com.integralblue.callerid.SpecialPhoneNumbers.java
com.integralblue.callerid.TabsAdapter.java
com.integralblue.callerid.contacts.ContactsHelper.java
com.integralblue.callerid.contacts.NewContactsHelper.java
com.integralblue.callerid.contacts.OldContactsHelper.java
com.integralblue.callerid.geocoder.AndroidGeocoder.java
com.integralblue.callerid.geocoder.Geocoder.java
com.integralblue.callerid.geocoder.NominatimGeocoder.java
com.integralblue.callerid.inject.CallerIDModule.java
com.integralblue.callerid.inject.ContactsHelperProvider.java
com.integralblue.callerid.inject.CountryDetector.java
com.integralblue.callerid.inject.GeocoderHelperProvider.java
com.integralblue.callerid.inject.PreferencesNameProvider.java
com.integralblue.callerid.inject.RestTemplateProvider.java
com.integralblue.callerid.inject.TextToSpeechHelper.java
com.integralblue.callerid.inject.VersionInformationHelper.java
com.integralblue.callerid.widget.DontPressWithParentImageView.java
com.squareup.okhttp.OkHttpURLStreamHandlerFactory.java
com.squareup.okhttp.internal.OkHttpClientHandler.java