FileDocCategorySizeDatePackage
SettingsActivity.javaAPI DocAndroid 1.5 API2905Wed May 06 22:42:42 BST 2009com.android.alarmclock

SettingsActivity

public class SettingsActivity extends android.preference.PreferenceActivity
Settings for the Alarm Clock.

Fields Summary
private static final int
ALARM_STREAM_TYPE_BIT
private static final String
KEY_ALARM_IN_SILENT_MODE
private android.preference.CheckBoxPreference
mAlarmInSilentModePref
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

    
    
        
        super.onCreate(savedInstanceState);
        
        addPreferencesFromResource(R.xml.settings);
        
        mAlarmInSilentModePref =
                (CheckBoxPreference) findPreference(KEY_ALARM_IN_SILENT_MODE);
    
public booleanonPreferenceTreeClick(android.preference.PreferenceScreen preferenceScreen, android.preference.Preference preference)

        
        if (preference == mAlarmInSilentModePref) {
            
            int ringerModeStreamTypes = Settings.System.getInt(
                    getContentResolver(),
                    Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
            
            if (mAlarmInSilentModePref.isChecked()) {
                ringerModeStreamTypes &= ~ALARM_STREAM_TYPE_BIT;
            } else {
                ringerModeStreamTypes |= ALARM_STREAM_TYPE_BIT;
            }
            
            Settings.System.putInt(getContentResolver(),
                    Settings.System.MODE_RINGER_STREAMS_AFFECTED,
                    ringerModeStreamTypes);
            
            return true;
        }
        
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    
protected voidonResume()

        super.onResume();
        refresh();
    
private voidrefresh()

        int silentModeStreams = Settings.System.getInt(getContentResolver(),
                Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
        mAlarmInSilentModePref.setChecked(
                (silentModeStreams & ALARM_STREAM_TYPE_BIT) == 0);