FileDocCategorySizeDatePackage
SettingActivity.javaAPI DocAndroid 1.5 API3934Wed May 06 22:42:46 BST 2009com.android.im.app

SettingActivity

public class SettingActivity extends android.preference.PreferenceActivity

Fields Summary
private static final String
KEY_NOTIFICATION_SOUND
private static final String
KEY_NOTIFICATION_VIBRATE
private static final String
KEY_ENABLE_NOTIFICATIONS
private static final String
KEY_HIDE_OFFLINE_CONTACTS
private long
mProviderId
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);
        addPreferencesFromResource(R.xml.preferences);
        Intent intent = getIntent();
        mProviderId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1);
        if (mProviderId < 0) {
            Log.e(ImApp.LOG_TAG,"SettingActivity intent requires provider id extra");
            throw new RuntimeException("SettingActivity must be created with an provider id");
        }
        setInitialValues();
    
public booleanonPreferenceTreeClick(android.preference.PreferenceScreen preferenceScreen, android.preference.Preference preference)

        if (preference instanceof CheckBoxPreference) {
            final Im.ProviderSettings.QueryMap settings = new Im.ProviderSettings.QueryMap(
                    getContentResolver(), mProviderId,
                    false /* keep updated */, null /* no handler */);
            String key = preference.getKey();
            boolean value = ((CheckBoxPreference) preference).isChecked();

            if (key.equals(KEY_HIDE_OFFLINE_CONTACTS)) {
                settings.setHideOfflineContacts(value);
            } else if (key.equals(KEY_ENABLE_NOTIFICATIONS)) {
                settings.setEnableNotification(value);
            } else if (key.equals(KEY_NOTIFICATION_VIBRATE)) {
                settings.setVibrate(value);
            } else if (key.equals(KEY_NOTIFICATION_SOUND)){
                if (!value) {
                    settings.setRingtoneURI(null);
                }
            }
            settings.close();
            return true;
        }
        
        return false;
    
private voidsetInitialValues()

        Im.ProviderSettings.QueryMap settings = new Im.ProviderSettings.QueryMap(
                getContentResolver(), mProviderId,
                false /* keep updated */, null /* no handler */);

        CheckBoxPreference pref = (CheckBoxPreference) findPreference(KEY_HIDE_OFFLINE_CONTACTS);
        pref.setChecked(settings.getHideOfflineContacts());

        pref = (CheckBoxPreference) findPreference(KEY_ENABLE_NOTIFICATIONS);
        pref.setChecked(settings.getEnableNotification());

        pref = (CheckBoxPreference) findPreference(KEY_NOTIFICATION_VIBRATE);
        pref.setChecked(settings.getVibrate());

        pref = (CheckBoxPreference) findPreference(KEY_NOTIFICATION_SOUND);
        pref.setChecked(settings.getRingtoneURI() != null);
        settings.close();