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

Settings

public class Settings extends Object
Class used to maintain settings.

Fields Summary
private static final String
ANDPY_CONFS_KEYSOUND_KEY
private static final String
ANDPY_CONFS_VIBRATE_KEY
private static final String
ANDPY_CONFS_PREDICTION_KEY
private static boolean
mKeySound
private static boolean
mVibrate
private static boolean
mPrediction
private static Settings
mInstance
private static int
mRefCount
private static android.content.SharedPreferences
mSharedPref
Constructors Summary
protected Settings(android.content.SharedPreferences pref)


       
        mSharedPref = pref;
        initConfs();
    
Methods Summary
public static com.android.inputmethod.pinyin.SettingsgetInstance(android.content.SharedPreferences pref)

        if (mInstance == null) {
            mInstance = new Settings(pref);
        }
        assert (pref == mSharedPref);
        mRefCount++;
        return mInstance;
    
public static booleangetKeySound()

        return mKeySound;
    
public static booleangetPrediction()

        return mPrediction;
    
public static booleangetVibrate()

        return mVibrate;
    
private voidinitConfs()

        mKeySound = mSharedPref.getBoolean(ANDPY_CONFS_KEYSOUND_KEY, true);
        mVibrate = mSharedPref.getBoolean(ANDPY_CONFS_VIBRATE_KEY, false);
        mPrediction = mSharedPref.getBoolean(ANDPY_CONFS_PREDICTION_KEY, true);
    
public static voidreleaseInstance()

        mRefCount--;
        if (mRefCount == 0) {
            mInstance = null;
        }
    
public static voidsetKeySound(boolean v)

        if (mKeySound == v) return;
        mKeySound = v;
    
public static voidsetPrediction(boolean v)

        if (mPrediction == v) return;
        mPrediction = v;
    
public static voidsetVibrate(boolean v)

        if (mVibrate == v) return;
        mVibrate = v;
    
public static voidwriteBack()

        Editor editor = mSharedPref.edit();
        editor.putBoolean(ANDPY_CONFS_VIBRATE_KEY, mVibrate);
        editor.putBoolean(ANDPY_CONFS_KEYSOUND_KEY, mKeySound);
        editor.putBoolean(ANDPY_CONFS_PREDICTION_KEY, mPrediction);
        editor.commit();