</intent-filter>
</activity>
+ <activity android:name="SettingsActivity" android:label="@string/settings">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
<activity android:name="SetAlarm" android:label="@string/set_alarm" />
<activity android:name="AlarmAlert" android:label="@string/alert_title"
android:theme="@android:style/Theme.Dialog"
android:launchMode="singleTask"
android:taskAffinity=":AlarmAlert"
+ android:screenOrientation="nosensor"
android:configChanges="orientation|keyboardHidden|keyboard|navigation" />
<activity android:name="ClockPicker" />
<!-- Short Day of week: Sun -->
<item>Sun</item>
</string-array>
+
+ <!-- Menu item title for general Alarm Clock Settings -->
+ <string name="settings">Settings</string>
+
+ <!-- Setting title for whether the alarm should play in silent mode.
+ Usually, silent mode only affects the ringer, but this setting
+ will make the alarms respect silent mode too. -->
+ <string name="alarm_in_silent_mode_title">Alarm in silent mode</string>
+
+ <!-- Setting summary for whether the alarm should play in silent mode. -->
+ <string name="alarm_in_silent_mode_summary">Play alarm even when the phone is in silent mode</string>
</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/settings">
+
+ <CheckBoxPreference
+ android:key="alarm_in_silent_mode"
+ android:title="@string/alarm_in_silent_mode_title"
+ android:summary="@string/alarm_in_silent_mode_summary" />
+
+</PreferenceScreen>
--- /dev/null
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.alarmclock;
+
+import android.media.AudioManager;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
+import android.provider.Settings;
+
+/**
+ * Settings for the Alarm Clock.
+ */
+public class SettingsActivity extends PreferenceActivity {
+
+ private static final int ALARM_STREAM_TYPE_BIT =
+ 1 << AudioManager.STREAM_ALARM;
+
+ private static final String KEY_ALARM_IN_SILENT_MODE =
+ "alarm_in_silent_mode";
+ private CheckBoxPreference mAlarmInSilentModePref;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.settings);
+
+ mAlarmInSilentModePref =
+ (CheckBoxPreference) findPreference(KEY_ALARM_IN_SILENT_MODE);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ refresh();
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
+ 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);
+ }
+
+ private void refresh() {
+ int silentModeStreams = Settings.System.getInt(getContentResolver(),
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
+ mAlarmInSilentModePref.setChecked(
+ (silentModeStreams & ALARM_STREAM_TYPE_BIT) == 0);
+ }
+
+}