am bd9eae10: Present Clock\'s timer beep as the default ringtone
* commit 'bd9eae10b13e015d1997d06f13e9abe06a7f306b':
Present Clock's timer beep as the default ringtone
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a5167e2..19751d6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -77,7 +77,7 @@
</intent-filter>
</activity-alias>
- <activity android:name="SettingsActivity"
+ <activity android:name=".settings.SettingsActivity"
android:label="@string/settings"
android:theme="@style/SettingsTheme"
android:taskAffinity=""
@@ -295,7 +295,7 @@
</service>
<!-- Settings activity for screensaver -->
- <activity android:name=".ScreensaverSettingsActivity"
+ <activity android:name=".settings.ScreensaverSettingsActivity"
android:label="@string/screensaver_settings"
android:theme="@style/SettingsTheme"
android:taskAffinity=""
diff --git a/res/layout/screensaver_settings.xml b/res/layout/screensaver_settings.xml
index 0e8f2bb..38b6332 100644
--- a/res/layout/screensaver_settings.xml
+++ b/res/layout/screensaver_settings.xml
@@ -17,6 +17,6 @@
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
- android:name="com.android.deskclock.ScreensaverSettingsActivity$PrefsFragment"
+ android:name="com.android.deskclock.settings.ScreensaverSettingsActivity$PrefsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
\ No newline at end of file
diff --git a/res/layout/settings.xml b/res/layout/settings.xml
index 207dff5..4159f5b 100644
--- a/res/layout/settings.xml
+++ b/res/layout/settings.xml
@@ -17,6 +17,6 @@
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
- android:name="com.android.deskclock.SettingsActivity$PrefsFragment"
+ android:name="com.android.deskclock.settings.SettingsActivity$PrefsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
diff --git a/res/xml/dream_info.xml b/res/xml/dream_info.xml
index 2add99b..57508f3 100644
--- a/res/xml/dream_info.xml
+++ b/res/xml/dream_info.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<dream xmlns:android="http://schemas.android.com/apk/res/android"
- android:settingsActivity="com.android.deskclock.ScreensaverSettingsActivity"
+ android:settingsActivity="com.android.deskclock.settings.ScreensaverSettingsActivity"
/>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 2fa9cb1..37b416a 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -53,7 +53,7 @@
android:defaultValue="10"
android:dialogTitle="@string/auto_silence_title" />
- <com.android.deskclock.SnoozeLengthDialog
+ <com.android.deskclock.settings.SnoozeLengthDialog
android:key="snooze_duration"
android:title="@string/snooze_duration_title"
android:defaultValue="10"/>
@@ -62,7 +62,7 @@
android:key="volume_setting"
android:title="@string/alarm_volume_title" />
- <com.android.deskclock.CrescendoLengthDialog
+ <com.android.deskclock.settings.CrescendoLengthDialog
android:key="alarm_crescendo_duration"
android:title="@string/crescendo_duration_title"
android:defaultValue="0"/>
@@ -85,12 +85,12 @@
<PreferenceCategory
android:title="@string/timer_settings">
- <RingtonePreference
+ <com.android.deskclock.settings.TimerRingtonePreference
android:key="timer_ringtone"
android:title="@string/timer_ringtone_title"
android:ringtoneType="alarm" />
- <com.android.deskclock.CrescendoLengthDialog
+ <com.android.deskclock.settings.CrescendoLengthDialog
android:key="timer_crescendo_duration"
android:title="@string/crescendo_duration_title"
android:defaultValue="0"/>
diff --git a/src/com/android/deskclock/AlarmInitReceiver.java b/src/com/android/deskclock/AlarmInitReceiver.java
index 3942de7..5df4da8 100644
--- a/src/com/android/deskclock/AlarmInitReceiver.java
+++ b/src/com/android/deskclock/AlarmInitReceiver.java
@@ -24,7 +24,7 @@
import android.preference.PreferenceManager;
import com.android.deskclock.alarms.AlarmStateManager;
-
+import com.android.deskclock.settings.SettingsActivity;
import com.android.deskclock.timer.TimerObj;
public class AlarmInitReceiver extends BroadcastReceiver {
diff --git a/src/com/android/deskclock/DeskClock.java b/src/com/android/deskclock/DeskClock.java
index 985626b..5134a94 100644
--- a/src/com/android/deskclock/DeskClock.java
+++ b/src/com/android/deskclock/DeskClock.java
@@ -49,6 +49,7 @@
import com.android.deskclock.alarms.AlarmStateManager;
import com.android.deskclock.events.Events;
import com.android.deskclock.provider.Alarm;
+import com.android.deskclock.settings.SettingsActivity;
import com.android.deskclock.stopwatch.StopwatchFragment;
import com.android.deskclock.stopwatch.StopwatchService;
import com.android.deskclock.stopwatch.Stopwatches;
diff --git a/src/com/android/deskclock/Screensaver.java b/src/com/android/deskclock/Screensaver.java
index 0820f26..9b9c5b9 100644
--- a/src/com/android/deskclock/Screensaver.java
+++ b/src/com/android/deskclock/Screensaver.java
@@ -32,6 +32,7 @@
import android.widget.TextClock;
import com.android.deskclock.Utils.ScreensaverMoveSaverRunnable;
+import com.android.deskclock.settings.ScreensaverSettingsActivity;
public class Screensaver extends DreamService {
diff --git a/src/com/android/deskclock/Utils.java b/src/com/android/deskclock/Utils.java
index 9651456..acec617 100644
--- a/src/com/android/deskclock/Utils.java
+++ b/src/com/android/deskclock/Utils.java
@@ -62,6 +62,7 @@
import com.android.deskclock.data.DataModel;
import com.android.deskclock.provider.AlarmInstance;
import com.android.deskclock.provider.DaysOfWeek;
+import com.android.deskclock.settings.SettingsActivity;
import com.android.deskclock.stopwatch.Stopwatches;
import com.android.deskclock.timer.Timers;
diff --git a/src/com/android/deskclock/alarms/AlarmActivity.java b/src/com/android/deskclock/alarms/AlarmActivity.java
index 033041c..3087ea9 100644
--- a/src/com/android/deskclock/alarms/AlarmActivity.java
+++ b/src/com/android/deskclock/alarms/AlarmActivity.java
@@ -53,10 +53,10 @@
import com.android.deskclock.AnimatorUtils;
import com.android.deskclock.LogUtils;
import com.android.deskclock.R;
-import com.android.deskclock.SettingsActivity;
import com.android.deskclock.Utils;
import com.android.deskclock.events.Events;
import com.android.deskclock.provider.AlarmInstance;
+import com.android.deskclock.settings.SettingsActivity;
import com.android.deskclock.widget.CircleView;
public class AlarmActivity extends AppCompatActivity
diff --git a/src/com/android/deskclock/alarms/AlarmKlaxon.java b/src/com/android/deskclock/alarms/AlarmKlaxon.java
index ba89d9d..971c5e9 100644
--- a/src/com/android/deskclock/alarms/AlarmKlaxon.java
+++ b/src/com/android/deskclock/alarms/AlarmKlaxon.java
@@ -24,9 +24,9 @@
import com.android.deskclock.AsyncRingtonePlayer;
import com.android.deskclock.LogUtils;
-import com.android.deskclock.SettingsActivity;
import com.android.deskclock.Utils;
import com.android.deskclock.provider.AlarmInstance;
+import com.android.deskclock.settings.SettingsActivity;
/**
* Manages playing ringtone and vibrating the device.
diff --git a/src/com/android/deskclock/alarms/AlarmStateManager.java b/src/com/android/deskclock/alarms/AlarmStateManager.java
index a6f3f52..cbfae21 100644
--- a/src/com/android/deskclock/alarms/AlarmStateManager.java
+++ b/src/com/android/deskclock/alarms/AlarmStateManager.java
@@ -40,7 +40,7 @@
import com.android.deskclock.DeskClock;
import com.android.deskclock.LogUtils;
import com.android.deskclock.R;
-import com.android.deskclock.SettingsActivity;
+import com.android.deskclock.settings.SettingsActivity;
import com.android.deskclock.Utils;
import com.android.deskclock.events.Events;
import com.android.deskclock.provider.Alarm;
diff --git a/src/com/android/deskclock/data/CityModel.java b/src/com/android/deskclock/data/CityModel.java
index 910a16c..3cf47d1 100644
--- a/src/com/android/deskclock/data/CityModel.java
+++ b/src/com/android/deskclock/data/CityModel.java
@@ -25,9 +25,9 @@
import android.preference.PreferenceManager;
import com.android.deskclock.R;
-import com.android.deskclock.SettingsActivity;
import com.android.deskclock.Utils;
import com.android.deskclock.data.DataModel.CitySort;
+import com.android.deskclock.settings.SettingsActivity;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/com/android/deskclock/data/DataModel.java b/src/com/android/deskclock/data/DataModel.java
index 2ed96b2..76585b5 100644
--- a/src/com/android/deskclock/data/DataModel.java
+++ b/src/com/android/deskclock/data/DataModel.java
@@ -157,6 +157,14 @@
//
/**
+ * @return the uri of the default ringtone to play for all timers when no user selection exists
+ */
+ public Uri getDefaultTimerRingtoneUri() {
+ enforceMainLooper();
+ return mTimerModel.getDefaultTimerRingtoneUri();
+ }
+
+ /**
* @return the uri of the ringtone to play for all timers
*/
public Uri getTimerRingtoneUri() {
diff --git a/src/com/android/deskclock/data/SettingsDAO.java b/src/com/android/deskclock/data/SettingsDAO.java
index c4b4ddc..b538b30 100644
--- a/src/com/android/deskclock/data/SettingsDAO.java
+++ b/src/com/android/deskclock/data/SettingsDAO.java
@@ -22,10 +22,10 @@
import android.preference.PreferenceManager;
import com.android.deskclock.R;
-import com.android.deskclock.ScreensaverSettingsActivity;
-import com.android.deskclock.SettingsActivity;
import com.android.deskclock.data.DataModel.CitySort;
import com.android.deskclock.data.DataModel.ClockStyle;
+import com.android.deskclock.settings.ScreensaverSettingsActivity;
+import com.android.deskclock.settings.SettingsActivity;
import java.util.TimeZone;
diff --git a/src/com/android/deskclock/data/TimerModel.java b/src/com/android/deskclock/data/TimerModel.java
index f886e04..9cdd9cc 100644
--- a/src/com/android/deskclock/data/TimerModel.java
+++ b/src/com/android/deskclock/data/TimerModel.java
@@ -25,7 +25,7 @@
import android.preference.PreferenceManager;
import com.android.deskclock.R;
-import com.android.deskclock.SettingsActivity;
+import com.android.deskclock.settings.SettingsActivity;
/**
* All timer data will eventually be accessed via this model.
@@ -58,6 +58,10 @@
prefs.registerOnSharedPreferenceChangeListener(mPreferenceListener);
}
+ Uri getDefaultTimerRingtoneUri() {
+ return mSettingsModel.getDefaultTimerRingtoneUri();
+ }
+
Uri getTimerRingtoneUri() {
if (mTimerRingtoneUri == null) {
mTimerRingtoneUri = mSettingsModel.getTimerRingtoneUri();
@@ -68,7 +72,7 @@
String getTimerRingtoneTitle() {
if (mTimerRingtoneTitle == null) {
- final Uri defaultUri = mSettingsModel.getDefaultTimerRingtoneUri();
+ final Uri defaultUri = getDefaultTimerRingtoneUri();
final Uri uri = getTimerRingtoneUri();
if (defaultUri.equals(uri)) {
diff --git a/src/com/android/deskclock/provider/AlarmInstance.java b/src/com/android/deskclock/provider/AlarmInstance.java
index 5a984b8..831331c 100644
--- a/src/com/android/deskclock/provider/AlarmInstance.java
+++ b/src/com/android/deskclock/provider/AlarmInstance.java
@@ -28,7 +28,7 @@
import com.android.deskclock.LogUtils;
import com.android.deskclock.R;
-import com.android.deskclock.SettingsActivity;
+import com.android.deskclock.settings.SettingsActivity;
import java.util.Calendar;
import java.util.LinkedList;
diff --git a/src/com/android/deskclock/CrescendoLengthDialog.java b/src/com/android/deskclock/settings/CrescendoLengthDialog.java
similarity index 96%
rename from src/com/android/deskclock/CrescendoLengthDialog.java
rename to src/com/android/deskclock/settings/CrescendoLengthDialog.java
index f303cf4..23b9da0 100644
--- a/src/com/android/deskclock/CrescendoLengthDialog.java
+++ b/src/com/android/deskclock/settings/CrescendoLengthDialog.java
@@ -1,4 +1,4 @@
-package com.android.deskclock;
+package com.android.deskclock.settings;
import android.app.AlertDialog;
import android.content.Context;
@@ -10,10 +10,12 @@
import android.widget.NumberPicker;
import android.widget.TextView;
+import com.android.deskclock.R;
+
/**
* A dialog preference that shows a number picker for selecting crescendo length
*/
-public class CrescendoLengthDialog extends DialogPreference {
+public final class CrescendoLengthDialog extends DialogPreference {
private static final String DEFAULT_CRESCENDO_TIME = "0";
private static final int CRESCENDO_TIME_STEP = 5;
diff --git a/src/com/android/deskclock/ScreensaverSettingsActivity.java b/src/com/android/deskclock/settings/ScreensaverSettingsActivity.java
similarity index 91%
rename from src/com/android/deskclock/ScreensaverSettingsActivity.java
rename to src/com/android/deskclock/settings/ScreensaverSettingsActivity.java
index 88c58f7..3f64379 100644
--- a/src/com/android/deskclock/ScreensaverSettingsActivity.java
+++ b/src/com/android/deskclock/settings/ScreensaverSettingsActivity.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.deskclock;
+package com.android.deskclock.settings;
import android.os.Bundle;
import android.preference.ListPreference;
@@ -23,13 +23,15 @@
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
+import com.android.deskclock.R;
+
/**
* Settings for Clock Daydream
*/
-public class ScreensaverSettingsActivity extends AppCompatActivity {
+public final class ScreensaverSettingsActivity extends AppCompatActivity {
public static final String KEY_CLOCK_STYLE = "screensaver_clock_style";
- static final String KEY_NIGHT_MODE = "screensaver_night_mode";
+ public static final String KEY_NIGHT_MODE = "screensaver_night_mode";
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/src/com/android/deskclock/SettingsActivity.java b/src/com/android/deskclock/settings/SettingsActivity.java
similarity index 98%
rename from src/com/android/deskclock/SettingsActivity.java
rename to src/com/android/deskclock/settings/SettingsActivity.java
index 49fba8a..9ab124f 100644
--- a/src/com/android/deskclock/SettingsActivity.java
+++ b/src/com/android/deskclock/settings/SettingsActivity.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.deskclock;
+package com.android.deskclock.settings;
import android.app.Activity;
import android.content.Context;
@@ -32,6 +32,10 @@
import android.view.Menu;
import android.view.MenuItem;
+import com.android.deskclock.BaseActivity;
+import com.android.deskclock.LogUtils;
+import com.android.deskclock.R;
+import com.android.deskclock.Utils;
import com.android.deskclock.data.DataModel;
import java.util.ArrayList;
@@ -43,7 +47,7 @@
/**
* Settings for the Alarm Clock.
*/
-public class SettingsActivity extends BaseActivity {
+public final class SettingsActivity extends BaseActivity {
public static final String KEY_ALARM_SNOOZE = "snooze_duration";
public static final String KEY_ALARM_VOLUME = "volume_setting";
@@ -293,7 +297,6 @@
timerRingtonePref.setSummary(DataModel.getDataModel().getTimerRingtoneTitle());
timerRingtonePref.setOnPreferenceChangeListener(this);
timerRingtonePref.setShowSilent(false);
- timerRingtonePref.setShowDefault(false);
}
private void updateAutoSnoozeSummary(ListPreference listPref, String delay) {
diff --git a/src/com/android/deskclock/SnoozeLengthDialog.java b/src/com/android/deskclock/settings/SnoozeLengthDialog.java
similarity index 79%
rename from src/com/android/deskclock/SnoozeLengthDialog.java
rename to src/com/android/deskclock/settings/SnoozeLengthDialog.java
index f39472c..44ba65b 100644
--- a/src/com/android/deskclock/SnoozeLengthDialog.java
+++ b/src/com/android/deskclock/settings/SnoozeLengthDialog.java
@@ -1,4 +1,20 @@
-package com.android.deskclock;
+/*
+ * Copyright (C) 2015 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.deskclock.settings;
import android.app.AlertDialog;
import android.content.Context;
@@ -10,10 +26,13 @@
import android.widget.NumberPicker;
import android.widget.TextView;
+import com.android.deskclock.R;
+import com.android.deskclock.Utils;
+
/**
* A dialog preference that shows a number picker for selecting snooze length
*/
-public class SnoozeLengthDialog extends DialogPreference {
+public final class SnoozeLengthDialog extends DialogPreference {
private static final String DEFAULT_SNOOZE_TIME = "10";
@@ -92,9 +111,6 @@
public void setSummary() {
setSummary(Utils.getNumberFormattedQuantityString(mContext, R.plurals.snooze_duration,
- mSnoozeMinutes));
+ mSnoozeMinutes));
}
-}
-
-
-
+}
\ No newline at end of file
diff --git a/src/com/android/deskclock/settings/TimerRingtonePreference.java b/src/com/android/deskclock/settings/TimerRingtonePreference.java
new file mode 100644
index 0000000..7a30d92
--- /dev/null
+++ b/src/com/android/deskclock/settings/TimerRingtonePreference.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 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.deskclock.settings;
+
+import android.content.Context;
+import android.content.Intent;
+import android.media.RingtoneManager;
+import android.preference.RingtonePreference;
+import android.support.annotation.NonNull;
+import android.util.AttributeSet;
+
+import com.android.deskclock.data.DataModel;
+
+/**
+ * A custom RingtonePreference that presents the application's default timer ringtone as the value
+ * behind the default selection.
+ */
+public final class TimerRingtonePreference extends RingtonePreference {
+
+ public TimerRingtonePreference(Context context) {
+ super(context);
+ }
+
+ public TimerRingtonePreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public TimerRingtonePreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public TimerRingtonePreference(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ @Override
+ protected void onPrepareRingtonePickerIntent(@NonNull Intent ringtonePickerIntent) {
+ super.onPrepareRingtonePickerIntent(ringtonePickerIntent);
+
+ // Replace the default ringtone uri with the beeping ringtone for timers.
+ ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
+ DataModel.getDataModel().getDefaultTimerRingtoneUri());
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/deskclock/timer/TimerKlaxon.java b/src/com/android/deskclock/timer/TimerKlaxon.java
index ddc6511..0281d11 100644
--- a/src/com/android/deskclock/timer/TimerKlaxon.java
+++ b/src/com/android/deskclock/timer/TimerKlaxon.java
@@ -21,8 +21,8 @@
import com.android.deskclock.AsyncRingtonePlayer;
import com.android.deskclock.LogUtils;
-import com.android.deskclock.SettingsActivity;
import com.android.deskclock.data.DataModel;
+import com.android.deskclock.settings.SettingsActivity;
public abstract class TimerKlaxon {
diff --git a/src/com/android/deskclock/worldclock/CitySelectionActivity.java b/src/com/android/deskclock/worldclock/CitySelectionActivity.java
index 970cd76..726cf45 100644
--- a/src/com/android/deskclock/worldclock/CitySelectionActivity.java
+++ b/src/com/android/deskclock/worldclock/CitySelectionActivity.java
@@ -42,10 +42,10 @@
import com.android.deskclock.BaseActivity;
import com.android.deskclock.R;
-import com.android.deskclock.SettingsActivity;
import com.android.deskclock.Utils;
import com.android.deskclock.data.City;
import com.android.deskclock.data.DataModel;
+import com.android.deskclock.settings.SettingsActivity;
import java.util.ArrayList;
import java.util.Calendar;