FileDocCategorySizeDatePackage
SettingsActivity.javaAPI DocAndroid 1.5 API3801Wed May 06 22:42:48 BST 2009com.android.inputmethod.pinyin

SettingsActivity

public class SettingsActivity extends android.preference.PreferenceActivity implements Preference.OnPreferenceChangeListener
Setting activity of Pinyin IME.

Fields Summary
private static String
TAG
private android.preference.CheckBoxPreference
mKeySoundPref
private android.preference.CheckBoxPreference
mVibratePref
private android.preference.CheckBoxPreference
mPredictionPref
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

    
    
        
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.settings);

        PreferenceScreen prefSet = getPreferenceScreen();

        mKeySoundPref = (CheckBoxPreference) prefSet
                .findPreference(getString(R.string.setting_sound_key));
        mVibratePref = (CheckBoxPreference) prefSet
                .findPreference(getString(R.string.setting_vibrate_key));
        mPredictionPref = (CheckBoxPreference) prefSet
                .findPreference(getString(R.string.setting_prediction_key));
        
        prefSet.setOnPreferenceChangeListener(this);
        
        Settings.getInstance(PreferenceManager
                .getDefaultSharedPreferences(getApplicationContext()));

        updatePreference(prefSet, getString(R.string.setting_advanced_key));
        
        updateWidgets();
    
protected voidonDestroy()

        Settings.releaseInstance();
        super.onDestroy();
    
protected voidonPause()

        super.onPause();
        Settings.setKeySound(mKeySoundPref.isChecked());
        Settings.setVibrate(mVibratePref.isChecked());
        Settings.setPrediction(mPredictionPref.isChecked());

        Settings.writeBack();
    
public booleanonPreferenceChange(android.preference.Preference preference, java.lang.Object newValue)

        return true;
    
protected voidonResume()

        super.onResume();
        updateWidgets();
    
public voidupdatePreference(android.preference.PreferenceGroup parentPref, java.lang.String prefKey)

        Preference preference = parentPref.findPreference(prefKey);
        if (preference == null) {
            return;
        }
        Intent intent = preference.getIntent();
        if (intent != null) {
            PackageManager pm = getPackageManager();
            List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
            int listSize = list.size();
            if (listSize == 0)
                parentPref.removePreference(preference);
        }
    
private voidupdateWidgets()

        mKeySoundPref.setChecked(Settings.getKeySound());
        mVibratePref.setChecked(Settings.getVibrate());
        mPredictionPref.setChecked(Settings.getPrediction());