am 352926aa: merge from open-source master

Merge commit '352926aa3a8ca45dae3e03a6e0ef6cc6b588e8df'

* commit '352926aa3a8ca45dae3e03a6e0ef6cc6b588e8df':
  empty initial commit
diff --git a/Android.mk b/Android.mk
index cac2687..8db1048 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,10 +1,14 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_MODULE_TAGS := optional
+
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
 LOCAL_PACKAGE_NAME := DeskClock
 
 LOCAL_OVERRIDES_PACKAGES := AlarmClock
 
+LOCAL_SDK_VERSION := current
+
 include $(BUILD_PACKAGE)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 293d0fe..e524bed 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -7,6 +7,7 @@
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.DEVICE_POWER" />
 
     <application android:label="@string/app_label"
                  android:icon="@drawable/ic_launcher_alarmclock">
@@ -98,6 +99,7 @@
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
                 <action android:name="android.intent.action.TIME_SET" />
                 <action android:name="android.intent.action.TIMEZONE_CHANGED" />
+                <action android:name="android.intent.action.LOCALE_CHANGED" />
             </intent-filter>
         </receiver>
 
diff --git a/res/drawable-hdpi/dialog_divider_horizontal_light.9.png b/res/drawable-hdpi/dialog_divider_horizontal_light.9.png
new file mode 100644
index 0000000..441ef32
--- /dev/null
+++ b/res/drawable-hdpi/dialog_divider_horizontal_light.9.png
Binary files differ
diff --git a/res/drawable-hdpi/divider_vertical_dark.9.png b/res/drawable-hdpi/divider_vertical_dark.9.png
new file mode 100644
index 0000000..702b878
--- /dev/null
+++ b/res/drawable-hdpi/divider_vertical_dark.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_dialog_time.png b/res/drawable-hdpi/ic_dialog_time.png
new file mode 100644
index 0000000..337a43a
--- /dev/null
+++ b/res/drawable-hdpi/ic_dialog_time.png
Binary files differ
diff --git a/res/drawable-hdpi/list_selector_background_pressed.9.png b/res/drawable-hdpi/list_selector_background_pressed.9.png
new file mode 100644
index 0000000..ba79cf7
--- /dev/null
+++ b/res/drawable-hdpi/list_selector_background_pressed.9.png
Binary files differ
diff --git a/res/drawable-mdpi/dialog_divider_horizontal_light.9.png b/res/drawable-mdpi/dialog_divider_horizontal_light.9.png
new file mode 100755
index 0000000..b69619b
--- /dev/null
+++ b/res/drawable-mdpi/dialog_divider_horizontal_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/divider_vertical_dark.9.png b/res/drawable-mdpi/divider_vertical_dark.9.png
new file mode 100644
index 0000000..702b878
--- /dev/null
+++ b/res/drawable-mdpi/divider_vertical_dark.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_dialog_time.png b/res/drawable-mdpi/ic_dialog_time.png
new file mode 100755
index 0000000..dffec29
--- /dev/null
+++ b/res/drawable-mdpi/ic_dialog_time.png
Binary files differ
diff --git a/res/drawable-mdpi/list_selector_background_pressed.9.png b/res/drawable-mdpi/list_selector_background_pressed.9.png
new file mode 100644
index 0000000..02b4e9a
--- /dev/null
+++ b/res/drawable-mdpi/list_selector_background_pressed.9.png
Binary files differ
diff --git a/res/drawable/clock_selector.xml b/res/drawable/clock_selector.xml
index efc9e5b..658100d 100644
--- a/res/drawable/clock_selector.xml
+++ b/res/drawable/clock_selector.xml
@@ -18,5 +18,5 @@
   <item android:state_pressed="false"
       android:drawable="@android:color/background_dark" />
   <item android:state_pressed="true"
-      android:drawable="@*android:drawable/list_selector_background_pressed" />
+      android:drawable="@drawable/list_selector_background_pressed" />
 </selector>
diff --git a/res/layout-land/desk_clock.xml b/res/layout-land/desk_clock.xml
index fbe310c..b785514 100644
--- a/res/layout-land/desk_clock.xml
+++ b/res/layout-land/desk_clock.xml
@@ -17,13 +17,13 @@
 <!-- This is the alarm clock in LANDSCAPE desk dock mode.
      -->
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
     >
     <LinearLayout
         android:id="@+id/desk_clock"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:orientation="vertical"
         android:paddingTop="25dip"
         >
@@ -36,8 +36,8 @@
             android:orientation="vertical"
             android:layout_gravity="left"
             android:layout_weight="1"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
             android:layout_marginLeft="25dip"
             android:layout_marginTop="18dip"
             android:layout_marginRight="18dip"
@@ -47,7 +47,7 @@
             <!-- across the top: next alarm, battery, nightmode button -->
             <LinearLayout
                 android:orientation="horizontal"
-                android:layout_width="fill_parent"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_weight="0"
                 android:layout_marginBottom="6dip"
@@ -90,7 +90,7 @@
             <LinearLayout
                 android:orientation="horizontal"
                 android:layout_weight="1"
-                android:layout_width="fill_parent"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:gravity="bottom"
                 >
@@ -118,8 +118,8 @@
     </LinearLayout>
 
     <View android:id="@+id/window_tint"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:background="#CC000000"
         android:visibility="visible"
         android:clickable="false"
diff --git a/res/layout/alarm_alert.xml b/res/layout/alarm_alert.xml
index 57588c3..2e06010 100644
--- a/res/layout/alarm_alert.xml
+++ b/res/layout/alarm_alert.xml
@@ -16,8 +16,8 @@
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
     android:gravity="center">
 
     <LinearLayout
@@ -34,14 +34,14 @@
             android:singleLine="true"
             android:ellipsize="end"
             android:gravity="center"
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content" />
         <ImageView
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="1dip"
             android:scaleType="fitXY"
             android:gravity="fill_horizontal"
-            android:src="@*android:drawable/dialog_divider_horizontal_light"
+            android:src="@drawable/dialog_divider_horizontal_light"
             android:layout_marginLeft="10dip"
             android:layout_marginRight="10dip"/>
 
diff --git a/res/layout/alarm_clock.xml b/res/layout/alarm_clock.xml
index a66fd59..e4d1ff9 100644
--- a/res/layout/alarm_clock.xml
+++ b/res/layout/alarm_clock.xml
@@ -16,15 +16,15 @@
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/base_layout"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
     android:orientation="vertical"> 
 
     <LinearLayout android:id="@+id/add_alarm"
         android:clickable="true"
         android:focusable="true"
         android:background="@android:drawable/list_selector_background"
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal">
 
@@ -46,7 +46,7 @@
     </LinearLayout>
 
     <ImageView
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:scaleType="fitXY"
         android:gravity="fill_horizontal"
@@ -54,12 +54,12 @@
 
     <ListView
         android:id="@+id/alarms_list"
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1" />
 
     <LinearLayout
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal" >
 
@@ -72,11 +72,11 @@
 
         <com.android.deskclock.DigitalClock
             style="@style/ButtonStripRight"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent">
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
 
             <LinearLayout
-                android:layout_width="fill_parent"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:baselineAligned="true">
 
diff --git a/res/layout/alarm_time.xml b/res/layout/alarm_time.xml
index 5c3b19b..c84c1e8 100644
--- a/res/layout/alarm_time.xml
+++ b/res/layout/alarm_time.xml
@@ -16,7 +16,7 @@
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
 
@@ -51,10 +51,10 @@
     </com.android.deskclock.DontPressWithParentLayout>
 
     <ImageView
-        android:src="@*android:drawable/divider_vertical_dark"
+        android:src="@drawable/divider_vertical_dark"
         android:background="?android:attr/windowBackground"
         android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
+        android:layout_height="match_parent"
         android:paddingTop="4dip"
         android:paddingBottom="4dip"
         android:scaleType="fitXY"
@@ -64,7 +64,7 @@
          and an optional line below, used for day/days of week -->
     <com.android.deskclock.DigitalClock android:id="@+id/digitalClock"
         android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
+        android:layout_height="match_parent"
         android:gravity="center_vertical"
         android:layout_weight="1"
         android:orientation="vertical"
@@ -72,7 +72,7 @@
         android:paddingRight="16dip">
 
         <LinearLayout
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:baselineAligned="true">
 
@@ -106,7 +106,7 @@
 
         <TextView android:id="@+id/daysOfWeek"
             android:includeFontPadding="false"
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textColor="?android:attr/textColorSecondary"/>
diff --git a/res/layout/analog_appwidget.xml b/res/layout/analog_appwidget.xml
index 7a32477..d2becb3 100644
--- a/res/layout/analog_appwidget.xml
+++ b/res/layout/analog_appwidget.xml
@@ -15,8 +15,9 @@
 -->
 
 <AnalogClock xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/analog_appwidget"
     android:dial="@drawable/appwidget_clock_dial"
     android:hand_hour="@drawable/appwidget_clock_hour"
     android:hand_minute="@drawable/appwidget_clock_minute"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent" />
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" />
diff --git a/res/layout/context_menu_header.xml b/res/layout/context_menu_header.xml
index 6ac4dc5..193f312 100644
--- a/res/layout/context_menu_header.xml
+++ b/res/layout/context_menu_header.xml
@@ -16,7 +16,7 @@
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:paddingTop="6dip"
     android:paddingBottom="9dip"
@@ -29,20 +29,20 @@
         android:layout_gravity="top"
         android:paddingTop="6dip"
         android:paddingRight="10dip"
-        android:src="@*android:drawable/ic_dialog_time"/>
+        android:src="@drawable/ic_dialog_time"/>
 
     <TextView android:id="@+id/header_time"
         style="?android:attr/textAppearanceLarge"
         android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
+        android:layout_height="match_parent"
         android:singleLine="true"
         android:gravity="center_vertical"
         android:ellipsize="none"/>
 
     <TextView android:id="@+id/header_label"
         style="?android:attr/textAppearanceLarge"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:layout_marginLeft="20dip"
         android:singleLine="true"
         android:gravity="right|center_vertical"
diff --git a/res/layout/desk_clock.xml b/res/layout/desk_clock.xml
index 018ef1f..1306c18 100644
--- a/res/layout/desk_clock.xml
+++ b/res/layout/desk_clock.xml
@@ -20,14 +20,14 @@
      Buttons are provided to access alarms, music, and other useful functions.
      -->
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
     >
     <!-- the top padding accounts for the status bar area -->
     <LinearLayout
         android:id="@+id/desk_clock"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:orientation="vertical"
         android:paddingTop="25dip"
         >
@@ -40,8 +40,8 @@
             android:orientation="vertical"
             android:layout_gravity="left"
             android:layout_weight="1"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
             android:layout_marginLeft="22dip"
             android:layout_marginTop="18dip"
             android:layout_marginRight="18dip"
@@ -51,7 +51,7 @@
             <!-- across the top: next alarm, nightmode button -->
             <LinearLayout
                 android:orientation="horizontal"
-                android:layout_width="fill_parent"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_weight="0"
                 android:layout_marginLeft="4dip"
@@ -99,7 +99,7 @@
 
             <include layout="@layout/desk_clock_battery"
                 android:layout_height="wrap_content"
-                android:layout_width="fill_parent"
+                android:layout_width="match_parent"
                 android:layout_weight="0"
                 android:layout_marginLeft="4dip"
                 />
@@ -111,8 +111,8 @@
     </LinearLayout>
 
     <View android:id="@+id/window_tint"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:background="#CC000000"
         android:visibility="visible"
         android:clickable="false"
diff --git a/res/layout/desk_clock_buttons.xml b/res/layout/desk_clock_buttons.xml
index 9d72282..b9e9129 100644
--- a/res/layout/desk_clock_buttons.xml
+++ b/res/layout/desk_clock_buttons.xml
@@ -16,14 +16,14 @@
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="horizontal"
-    android:layout_width="fill_parent"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight="0"
     >
     <ImageButton android:id="@+id/alarm_button"
 		style="@style/ButtonStripLeft"
         android:layout_height="wrap_content"
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_weight=".25"
         android:src="@drawable/ic_clock_strip_alarm"
         android:contentDescription="@string/alarm_button_description"
@@ -31,7 +31,7 @@
     <ImageButton android:id="@+id/gallery_button"
 		style="@style/ButtonStripMiddle"
         android:layout_height="wrap_content"
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_weight=".25"
         android:src="@drawable/ic_clock_strip_gallery"
         android:contentDescription="@string/gallery_button_description"
@@ -39,7 +39,7 @@
     <ImageButton android:id="@+id/music_button"
 		style="@style/ButtonStripMiddle"
         android:layout_height="wrap_content"
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_weight=".25"
         android:src="@drawable/ic_clock_strip_music"
         android:contentDescription="@string/music_button_description"
@@ -47,7 +47,7 @@
     <ImageButton android:id="@+id/home_button"
 		style="@style/ButtonStripRight"
         android:layout_height="wrap_content"
-        android:layout_width="fill_parent"
+        android:layout_width="match_parent"
         android:layout_weight=".25"
         android:src="@drawable/ic_clock_strip_home"
         android:contentDescription="@string/home_button_description"
diff --git a/res/layout/desk_clock_saver.xml b/res/layout/desk_clock_saver.xml
index fcde362..6d72e8d 100644
--- a/res/layout/desk_clock_saver.xml
+++ b/res/layout/desk_clock_saver.xml
@@ -16,13 +16,13 @@
 
 <!-- Special "screen saver mode" with just the time/date on black. -->
 <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
     >
 
     <View
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:layout_x="0dip"
         android:layout_y="0dip"
         android:background="#FF000000"
diff --git a/res/layout/desk_clock_time_date.xml b/res/layout/desk_clock_time_date.xml
index 5b2af22..e5869a7 100644
--- a/res/layout/desk_clock_time_date.xml
+++ b/res/layout/desk_clock_time_date.xml
@@ -48,7 +48,7 @@
 
         <TextView android:id="@+id/am_pm"
             android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
+            android:layout_height="match_parent"
             android:gravity="bottom"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textStyle="bold"
diff --git a/res/layout/save_cancel_alarm.xml b/res/layout/save_cancel_alarm.xml
deleted file mode 100644
index 837d951..0000000
--- a/res/layout/save_cancel_alarm.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:orientation="horizontal"
-    style="@android:style/ButtonBar">
-
-    <Button android:id="@+id/alarm_save"
-        android:focusable="true"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_weight="1"
-        android:text="@string/done"/>
-
-    <Button android:id="@+id/alarm_cancel"
-        android:focusable="true"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_weight="1"
-        android:text="@string/revert"/>
-
-    <Button android:id="@+id/alarm_delete"
-        android:focusable="true"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_weight="1"
-        android:text="@string/delete"/>
-
-</LinearLayout>
diff --git a/res/layout/set_alarm.xml b/res/layout/set_alarm.xml
new file mode 100644
index 0000000..660befe
--- /dev/null
+++ b/res/layout/set_alarm.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2010, 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.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <ListView android:id="@android:id/list"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:drawSelectorOnTop="false"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        style="@android:style/ButtonBar">
+
+        <Button android:id="@+id/alarm_save"
+            android:focusable="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:text="@string/done"/>
+
+        <Button android:id="@+id/alarm_cancel"
+            android:focusable="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:text="@string/revert"/>
+
+        <Button android:id="@+id/alarm_delete"
+            android:focusable="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:text="@string/delete"/>
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/res/raw/fallbackring.ogg b/res/raw/fallbackring.ogg
new file mode 100644
index 0000000..9d80037
--- /dev/null
+++ b/res/raw/fallbackring.ogg
Binary files differ
diff --git a/res/values-cs/donottranslate.xml b/res/values-cs/donottranslate.xml
new file mode 100644
index 0000000..0258120
--- /dev/null
+++ b/res/values-cs/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE MMMM d</string>
+</resources>
diff --git a/res/values-da/donottranslate.xml b/res/values-da/donottranslate.xml
new file mode 100644
index 0000000..3d64857
--- /dev/null
+++ b/res/values-da/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE d. MMMM</string>
+</resources>
diff --git a/res/values-de/donottranslate.xml b/res/values-de/donottranslate.xml
new file mode 100644
index 0000000..f55480c
--- /dev/null
+++ b/res/values-de/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE, d. MMMM</string>
+</resources>
diff --git a/res/values-el/donottranslate.xml b/res/values-el/donottranslate.xml
new file mode 100644
index 0000000..bff426c
--- /dev/null
+++ b/res/values-el/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE, d MMMM</string>
+</resources>
diff --git a/res/values-es-rUS/donottranslate.xml b/res/values-es-rUS/donottranslate.xml
new file mode 100644
index 0000000..8df03e6
--- /dev/null
+++ b/res/values-es-rUS/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE d \'de\' MMMM</string>
+</resources>
diff --git a/res/values-es/donottranslate.xml b/res/values-es/donottranslate.xml
new file mode 100644
index 0000000..8df03e6
--- /dev/null
+++ b/res/values-es/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE d \'de\' MMMM</string>
+</resources>
diff --git a/res/values-fr/donottranslate.xml b/res/values-fr/donottranslate.xml
new file mode 100644
index 0000000..ef72065
--- /dev/null
+++ b/res/values-fr/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEE d MMMM</string>
+</resources>
diff --git a/res/values-it/donottranslate.xml b/res/values-it/donottranslate.xml
new file mode 100644
index 0000000..ef72065
--- /dev/null
+++ b/res/values-it/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEE d MMMM</string>
+</resources>
diff --git a/res/values-ja/donottranslate.xml b/res/values-ja/donottranslate.xml
new file mode 100644
index 0000000..f027193
--- /dev/null
+++ b/res/values-ja/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">M月d日 (E)</string>
+</resources>
diff --git a/res/values-ko/donottranslate.xml b/res/values-ko/donottranslate.xml
new file mode 100644
index 0000000..47f9d62
--- /dev/null
+++ b/res/values-ko/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">MMMM d일 EEEE</string>
+</resources>
diff --git a/res/values-nb/donottranslate.xml b/res/values-nb/donottranslate.xml
new file mode 100644
index 0000000..3d64857
--- /dev/null
+++ b/res/values-nb/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE d. MMMM</string>
+</resources>
diff --git a/res/values-nl/donottranslate.xml b/res/values-nl/donottranslate.xml
new file mode 100644
index 0000000..67ffc47
--- /dev/null
+++ b/res/values-nl/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE d MMMM</string>
+</resources>
diff --git a/res/values-pl/donottranslate.xml b/res/values-pl/donottranslate.xml
new file mode 100644
index 0000000..bff426c
--- /dev/null
+++ b/res/values-pl/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE, d MMMM</string>
+</resources>
diff --git a/res/values-pt-rPT/donottranslate.xml b/res/values-pt-rPT/donottranslate.xml
new file mode 100644
index 0000000..ed4559f
--- /dev/null
+++ b/res/values-pt-rPT/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEE, d \'de\' MMMM</string>
+</resources>
diff --git a/res/values-pt/donottranslate.xml b/res/values-pt/donottranslate.xml
new file mode 100644
index 0000000..ed4559f
--- /dev/null
+++ b/res/values-pt/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEE, d \'de\' MMMM</string>
+</resources>
diff --git a/res/values-ru/donottranslate.xml b/res/values-ru/donottranslate.xml
new file mode 100644
index 0000000..bff426c
--- /dev/null
+++ b/res/values-ru/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE, d MMMM</string>
+</resources>
diff --git a/res/values-sv/donottranslate.xml b/res/values-sv/donottranslate.xml
new file mode 100644
index 0000000..67ffc47
--- /dev/null
+++ b/res/values-sv/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE d MMMM</string>
+</resources>
diff --git a/res/values-tr/donottranslate.xml b/res/values-tr/donottranslate.xml
new file mode 100644
index 0000000..5f2e5a8
--- /dev/null
+++ b/res/values-tr/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">dd MMMM EEEE</string>
+</resources>
diff --git a/res/values-zh-rCN/donottranslate.xml b/res/values-zh-rCN/donottranslate.xml
new file mode 100644
index 0000000..de1407d
--- /dev/null
+++ b/res/values-zh-rCN/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">M 月 d 日E</string>
+</resources>
diff --git a/res/values-zh-rTW/donottranslate.xml b/res/values-zh-rTW/donottranslate.xml
new file mode 100644
index 0000000..de1407d
--- /dev/null
+++ b/res/values-zh-rTW/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">M 月 d 日E</string>
+</resources>
diff --git a/res/values/donottranslate.xml b/res/values/donottranslate.xml
new file mode 100644
index 0000000..841d450
--- /dev/null
+++ b/res/values/donottranslate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year">EEEE, MMMM d</string>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4d9d57f..b99c233 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -248,6 +248,7 @@
     <string name="weather_fetch_failure">Weather information currently unavailable.</string>
 
     <string name="menu_item_dock_settings" msgid="9161438664257429372">Dock settings</string>
+
 </resources>
 
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index edacfea..8de806b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -16,8 +16,8 @@
 
 <resources>
     <style name="clock">
-        <item name="android:layout_width">fill_parent</item>
-        <item name="android:layout_height">fill_parent</item>
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">match_parent</item>
         <item name="android:layout_gravity">center_horizontal</item>
     </style>
 
diff --git a/src/com/android/deskclock/Alarm.java b/src/com/android/deskclock/Alarm.java
index 7d8c8a3..b05c3e5 100644
--- a/src/com/android/deskclock/Alarm.java
+++ b/src/com/android/deskclock/Alarm.java
@@ -208,6 +208,17 @@
         silent = p.readInt() == 1;
     }
 
+    // Creates a default alarm at the current time.
+    public Alarm() {
+        Calendar c = Calendar.getInstance();
+        c.setTimeInMillis(System.currentTimeMillis());
+        hour = c.get(Calendar.HOUR_OF_DAY);
+        minutes = c.get(Calendar.MINUTE);
+        vibrate = true;
+        daysOfWeek = new DaysOfWeek(0);
+        alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
+    }
+
     public String getLabelOrDefault(Context context) {
         if (label == null || label.length() == 0) {
             return context.getString(R.string.default_label);
diff --git a/src/com/android/deskclock/AlarmAlert.java b/src/com/android/deskclock/AlarmAlert.java
index 6319dff..72b8a3b 100644
--- a/src/com/android/deskclock/AlarmAlert.java
+++ b/src/com/android/deskclock/AlarmAlert.java
@@ -16,238 +16,88 @@
 
 package com.android.deskclock;
 
-import android.app.Activity;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
+import android.app.KeyguardManager;
 import android.content.BroadcastReceiver;
+import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.res.Configuration;
 import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.LayoutInflater;
-import android.view.Window;
+import android.os.Handler;
+import android.os.Message;
 import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.Toast;
-import android.widget.TextView;
-
-import java.util.Calendar;
 
 /**
- * Alarm Clock alarm alert: pops visible indicator and plays alarm
- * tone
+ * Full screen alarm alert: pops visible indicator and plays alarm tone. This
+ * activity shows the alert as a dialog.
  */
-public class AlarmAlert extends Activity {
+public class AlarmAlert extends AlarmAlertFullScreen {
 
-    // These defaults must match the values in res/xml/settings.xml
-    private static final String DEFAULT_SNOOZE = "10";
-    private static final String DEFAULT_VOLUME_BEHAVIOR = "2";
+    // If we try to check the keyguard more than 5 times, just launch the full
+    // screen activity.
+    private int mKeyguardRetryCount;
+    private final int MAX_KEYGUARD_CHECKS = 5;
 
-    private Alarm mAlarm;
-    private int mVolumeBehavior;
-
-    // Receives the ALARM_KILLED action from the AlarmKlaxon.
-    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+    private final Handler mHandler = new Handler() {
         @Override
-        public void onReceive(Context context, Intent intent) {
-            Alarm alarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
-            if (mAlarm.id == alarm.id) {
-                dismiss(true);
-            }
+        public void handleMessage(Message msg) {
+            handleScreenOff((KeyguardManager) msg.obj);
         }
     };
 
+    private final BroadcastReceiver mScreenOffReceiver =
+            new BroadcastReceiver() {
+                @Override
+                public void onReceive(Context context, Intent intent) {
+                    KeyguardManager km =
+                            (KeyguardManager) context.getSystemService(
+                            Context.KEYGUARD_SERVICE);
+                    handleScreenOff(km);
+                }
+            };
+
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
-        mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
-
-        // Get the volume/camera button behavior setting
-        final String vol =
-                PreferenceManager.getDefaultSharedPreferences(this)
-                .getString(SettingsActivity.KEY_VOLUME_BEHAVIOR,
-                        DEFAULT_VOLUME_BEHAVIOR);
-        mVolumeBehavior = Integer.parseInt(vol);
-
-        requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
-        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
-                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
-                | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
-                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
-        updateLayout();
-
-        // Register to get the alarm killed intent.
-        registerReceiver(mReceiver, new IntentFilter(Alarms.ALARM_KILLED));
+        // Listen for the screen turning off so that when the screen comes back
+        // on, the user does not need to unlock the phone to dismiss the alarm.
+        registerReceiver(mScreenOffReceiver,
+                new IntentFilter(Intent.ACTION_SCREEN_OFF));
     }
 
-    private void setTitle() {
-        String label = mAlarm.getLabelOrDefault(this);
-        TextView title = (TextView) findViewById(R.id.alertTitle);
-        title.setText(label);
-    }
-
-    // This method is overwritten in AlarmAlertFullScreen in order to show a
-    // full activity with the wallpaper as the background.
-    protected View inflateView(LayoutInflater inflater) {
-        return inflater.inflate(R.layout.alarm_alert, null);
-    }
-
-    private void updateLayout() {
-        LayoutInflater inflater = LayoutInflater.from(this);
-
-        setContentView(inflateView(inflater));
-
-        /* snooze behavior: pop a snooze confirmation view, kick alarm
-           manager. */
-        Button snooze = (Button) findViewById(R.id.snooze);
-        snooze.requestFocus();
-        snooze.setOnClickListener(new Button.OnClickListener() {
-            public void onClick(View v) {
-                snooze();
-            }
-        });
-
-        /* dismiss button: close notification */
-        findViewById(R.id.dismiss).setOnClickListener(
-                new Button.OnClickListener() {
-                    public void onClick(View v) {
-                        dismiss(false);
-                    }
-                });
-
-        /* Set the title from the passed in alarm */
-        setTitle();
-    }
-
-    // Attempt to snooze this alert.
-    private void snooze() {
-        final String snooze =
-                PreferenceManager.getDefaultSharedPreferences(this)
-                .getString(SettingsActivity.KEY_ALARM_SNOOZE, DEFAULT_SNOOZE);
-        int snoozeMinutes = Integer.parseInt(snooze);
-
-        final long snoozeTime = System.currentTimeMillis()
-                + (1000 * 60 * snoozeMinutes);
-        Alarms.saveSnoozeAlert(AlarmAlert.this, mAlarm.id, snoozeTime);
-
-        // Get the display time for the snooze and update the notification.
-        final Calendar c = Calendar.getInstance();
-        c.setTimeInMillis(snoozeTime);
-
-        // Append (snoozed) to the label.
-        String label = mAlarm.getLabelOrDefault(this);
-        label = getString(R.string.alarm_notify_snooze_label, label);
-
-        // Notify the user that the alarm has been snoozed.
-        Intent cancelSnooze = new Intent(this, AlarmReceiver.class);
-        cancelSnooze.setAction(Alarms.CANCEL_SNOOZE);
-        cancelSnooze.putExtra(Alarms.ALARM_ID, mAlarm.id);
-        PendingIntent broadcast =
-                PendingIntent.getBroadcast(this, mAlarm.id, cancelSnooze, 0);
-        NotificationManager nm = getNotificationManager();
-        Notification n = new Notification(R.drawable.stat_notify_alarm,
-                label, 0);
-        n.setLatestEventInfo(this, label,
-                getString(R.string.alarm_notify_snooze_text,
-                    Alarms.formatTime(this, c)), broadcast);
-        n.flags |= Notification.FLAG_AUTO_CANCEL
-                | Notification.FLAG_ONGOING_EVENT;
-        nm.notify(mAlarm.id, n);
-
-        String displayTime = getString(R.string.alarm_alert_snooze_set,
-                snoozeMinutes);
-        // Intentionally log the snooze time for debugging.
-        Log.v(displayTime);
-
-        // Display the snooze minutes in a toast.
-        Toast.makeText(AlarmAlert.this, displayTime, Toast.LENGTH_LONG).show();
-        stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
-        finish();
-    }
-
-    private NotificationManager getNotificationManager() {
-        return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-    }
-
-    // Dismiss the alarm.
-    private void dismiss(boolean killed) {
-        // The service told us that the alarm has been killed, do not modify
-        // the notification or stop the service.
-        if (!killed) {
-            // Cancel the notification and stop playing the alarm
-            NotificationManager nm = getNotificationManager();
-            nm.cancel(mAlarm.id);
-            stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
-        }
-        finish();
-    }
-
-    /**
-     * this is called when a second alarm is triggered while a
-     * previous alert window is still active.
-     */
-    @Override
-    protected void onNewIntent(Intent intent) {
-        super.onNewIntent(intent);
-
-        if (Log.LOGV) Log.v("AlarmAlert.OnNewIntent()");
-
-        mAlarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
-
-        setTitle();
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        // Don't hang around.
-        finish();
-    }
-    
     @Override
     public void onDestroy() {
         super.onDestroy();
-        if (Log.LOGV) Log.v("AlarmAlert.onDestroy()");
-        // No longer care about the alarm being killed.
-        unregisterReceiver(mReceiver);
+        unregisterReceiver(mScreenOffReceiver);
+        // Remove any of the keyguard messages just in case
+        mHandler.removeMessages(0);
     }
 
     @Override
-    public boolean dispatchKeyEvent(KeyEvent event) {
-        // Do this on key down to handle a few of the system keys.
-        boolean up = event.getAction() == KeyEvent.ACTION_UP;
-        switch (event.getKeyCode()) {
-            // Volume keys and camera keys dismiss the alarm
-            case KeyEvent.KEYCODE_VOLUME_UP:
-            case KeyEvent.KEYCODE_VOLUME_DOWN:
-            case KeyEvent.KEYCODE_CAMERA:
-            case KeyEvent.KEYCODE_FOCUS:
-                if (up) {
-                    switch (mVolumeBehavior) {
-                        case 1:
-                            snooze();
-                            break;
+    public void onBackPressed() {
+        finish();
+    }
 
-                        case 2:
-                            dismiss(false);
-                            break;
-
-                        default:
-                            break;
-                    }
-                }
-                return true;
-            default:
-                break;
+    private boolean checkRetryCount() {
+        if (mKeyguardRetryCount++ >= MAX_KEYGUARD_CHECKS) {
+            Log.e("Tried to read keyguard status too many times, bailing...");
+            return false;
         }
-        return super.dispatchKeyEvent(event);
+        return true;
+    }
+
+    private void handleScreenOff(final KeyguardManager km) {
+        if (!km.inKeyguardRestrictedInputMode() && checkRetryCount()) {
+            if (checkRetryCount()) {
+                mHandler.sendMessageDelayed(mHandler.obtainMessage(0, km), 500);
+            }
+        } else {
+            // Launch the full screen activity but do not turn the screen on.
+            Intent i = new Intent(this, AlarmAlertFullScreen.class);
+            i.putExtra(Alarms.ALARM_INTENT_EXTRA, mAlarm);
+            i.putExtra(SCREEN_OFF, true);
+            startActivity(i);
+            finish();
+        }
     }
 }
diff --git a/src/com/android/deskclock/AlarmAlertFullScreen.java b/src/com/android/deskclock/AlarmAlertFullScreen.java
index fe7d61d..0173a12 100644
--- a/src/com/android/deskclock/AlarmAlertFullScreen.java
+++ b/src/com/android/deskclock/AlarmAlertFullScreen.java
@@ -16,23 +16,267 @@
 
 package com.android.deskclock;
 
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.LayoutInflater;
+import android.view.Window;
 import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.Toast;
+import android.widget.TextView;
+
+import java.util.Calendar;
 
 /**
- * Full screen alarm alert: pops visible indicator and plays alarm tone. This
- * activity displays the alert in full screen in order to be secure. The
- * background is the current wallpaper.
+ * Alarm Clock alarm alert: pops visible indicator and plays alarm
+ * tone. This activity is the full screen version which shows over the lock
+ * screen with the wallpaper as the background.
  */
-public class AlarmAlertFullScreen extends AlarmAlert {
+public class AlarmAlertFullScreen extends Activity {
+
+    // These defaults must match the values in res/xml/settings.xml
+    private static final String DEFAULT_SNOOZE = "10";
+    private static final String DEFAULT_VOLUME_BEHAVIOR = "2";
+    protected static final String SCREEN_OFF = "screen_off";
+
+    protected Alarm mAlarm;
+    private int mVolumeBehavior;
+
+    // Receives the ALARM_KILLED action from the AlarmKlaxon.
+    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            Alarm alarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
+            if (alarm != null && mAlarm.id == alarm.id) {
+                dismiss(true);
+            }
+        }
+    };
+
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+
+        mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
+
+        // Get the volume/camera button behavior setting
+        final String vol =
+                PreferenceManager.getDefaultSharedPreferences(this)
+                .getString(SettingsActivity.KEY_VOLUME_BEHAVIOR,
+                        DEFAULT_VOLUME_BEHAVIOR);
+        mVolumeBehavior = Integer.parseInt(vol);
+
+        requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
+
+        final Window win = getWindow();
+        win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
+        // Turn on the screen unless we are being launched from the AlarmAlert
+        // subclass.
+        if (!getIntent().getBooleanExtra(SCREEN_OFF, false)) {
+            win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+        }
+
+        updateLayout();
+
+        // Register to get the alarm killed intent.
+        registerReceiver(mReceiver, new IntentFilter(Alarms.ALARM_KILLED));
+    }
+
+    private void setTitle() {
+        String label = mAlarm.getLabelOrDefault(this);
+        TextView title = (TextView) findViewById(R.id.alertTitle);
+        title.setText(label);
+    }
+
+    private void updateLayout() {
+        LayoutInflater inflater = LayoutInflater.from(this);
+
+        setContentView(inflater.inflate(R.layout.alarm_alert, null));
+
+        /* snooze behavior: pop a snooze confirmation view, kick alarm
+           manager. */
+        Button snooze = (Button) findViewById(R.id.snooze);
+        snooze.requestFocus();
+        snooze.setOnClickListener(new Button.OnClickListener() {
+            public void onClick(View v) {
+                snooze();
+            }
+        });
+
+        /* dismiss button: close notification */
+        findViewById(R.id.dismiss).setOnClickListener(
+                new Button.OnClickListener() {
+                    public void onClick(View v) {
+                        dismiss(false);
+                    }
+                });
+
+        /* Set the title from the passed in alarm */
+        setTitle();
+    }
+
+    // Attempt to snooze this alert.
+    private void snooze() {
+        // Do not snooze if the snooze button is disabled.
+        if (!findViewById(R.id.snooze).isEnabled()) {
+            dismiss(false);
+            return;
+        }
+        final String snooze =
+                PreferenceManager.getDefaultSharedPreferences(this)
+                .getString(SettingsActivity.KEY_ALARM_SNOOZE, DEFAULT_SNOOZE);
+        int snoozeMinutes = Integer.parseInt(snooze);
+
+        final long snoozeTime = System.currentTimeMillis()
+                + (1000 * 60 * snoozeMinutes);
+        Alarms.saveSnoozeAlert(AlarmAlertFullScreen.this, mAlarm.id,
+                snoozeTime);
+
+        // Get the display time for the snooze and update the notification.
+        final Calendar c = Calendar.getInstance();
+        c.setTimeInMillis(snoozeTime);
+
+        // Append (snoozed) to the label.
+        String label = mAlarm.getLabelOrDefault(this);
+        label = getString(R.string.alarm_notify_snooze_label, label);
+
+        // Notify the user that the alarm has been snoozed.
+        Intent cancelSnooze = new Intent(this, AlarmReceiver.class);
+        cancelSnooze.setAction(Alarms.CANCEL_SNOOZE);
+        cancelSnooze.putExtra(Alarms.ALARM_ID, mAlarm.id);
+        PendingIntent broadcast =
+                PendingIntent.getBroadcast(this, mAlarm.id, cancelSnooze, 0);
+        NotificationManager nm = getNotificationManager();
+        Notification n = new Notification(R.drawable.stat_notify_alarm,
+                label, 0);
+        n.setLatestEventInfo(this, label,
+                getString(R.string.alarm_notify_snooze_text,
+                    Alarms.formatTime(this, c)), broadcast);
+        n.flags |= Notification.FLAG_AUTO_CANCEL
+                | Notification.FLAG_ONGOING_EVENT;
+        nm.notify(mAlarm.id, n);
+
+        String displayTime = getString(R.string.alarm_alert_snooze_set,
+                snoozeMinutes);
+        // Intentionally log the snooze time for debugging.
+        Log.v(displayTime);
+
+        // Display the snooze minutes in a toast.
+        Toast.makeText(AlarmAlertFullScreen.this, displayTime,
+                Toast.LENGTH_LONG).show();
+        stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
+        finish();
+    }
+
+    private NotificationManager getNotificationManager() {
+        return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+    }
+
+    // Dismiss the alarm.
+    private void dismiss(boolean killed) {
+        // The service told us that the alarm has been killed, do not modify
+        // the notification or stop the service.
+        if (!killed) {
+            // Cancel the notification and stop playing the alarm
+            NotificationManager nm = getNotificationManager();
+            nm.cancel(mAlarm.id);
+            stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
+        }
+        finish();
+    }
+
+    /**
+     * this is called when a second alarm is triggered while a
+     * previous alert window is still active.
+     */
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+
+        if (Log.LOGV) Log.v("AlarmAlert.OnNewIntent()");
+
+        mAlarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
+
+        setTitle();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        // If the alarm was deleted at some point, disable snooze.
+        if (Alarms.getAlarm(getContentResolver(), mAlarm.id) == null) {
+            Button snooze = (Button) findViewById(R.id.snooze);
+            snooze.setEnabled(false);
+        }
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        if (!isFinishing()) {
+            // Don't hang around.
+            finish();
+        }
     }
     
     @Override
+    public void onDestroy() {
+        super.onDestroy();
+        if (Log.LOGV) Log.v("AlarmAlert.onDestroy()");
+        // No longer care about the alarm being killed.
+        unregisterReceiver(mReceiver);
+    }
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        // Do this on key down to handle a few of the system keys.
+        boolean up = event.getAction() == KeyEvent.ACTION_UP;
+        switch (event.getKeyCode()) {
+            // Volume keys and camera keys dismiss the alarm
+            case KeyEvent.KEYCODE_VOLUME_UP:
+            case KeyEvent.KEYCODE_VOLUME_DOWN:
+            case KeyEvent.KEYCODE_CAMERA:
+            case KeyEvent.KEYCODE_FOCUS:
+                if (up) {
+                    switch (mVolumeBehavior) {
+                        case 1:
+                            snooze();
+                            break;
+
+                        case 2:
+                            dismiss(false);
+                            break;
+
+                        default:
+                            break;
+                    }
+                }
+                return true;
+            default:
+                break;
+        }
+        return super.dispatchKeyEvent(event);
+    }
+
+    @Override
     public void onBackPressed() {
-        // Don't allow back to dismiss.
+        // Don't allow back to dismiss. This method is overriden by AlarmAlert
+        // so that the dialog is dismissed.
         return;
     }
 }
diff --git a/src/com/android/deskclock/AlarmClock.java b/src/com/android/deskclock/AlarmClock.java
index adfe740..5ade787 100644
--- a/src/com/android/deskclock/AlarmClock.java
+++ b/src/com/android/deskclock/AlarmClock.java
@@ -28,7 +28,6 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
-import android.provider.Settings;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.LayoutInflater;
@@ -36,7 +35,6 @@
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
-import android.view.View.OnCreateContextMenuListener;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.AdapterView.AdapterContextMenuInfo;
@@ -56,11 +54,11 @@
  */
 public class AlarmClock extends Activity implements OnItemClickListener {
 
-    final static String PREFERENCES = "AlarmClock";
+    static final String PREFERENCES = "AlarmClock";
 
     /** This must be false for production.  If true, turns on logging,
         test code, etc. */
-    final static boolean DEBUG = false;
+    static final boolean DEBUG = false;
 
     private SharedPreferences mPrefs;
     private LayoutInflater mFactory;
@@ -86,9 +84,9 @@
         public View newView(Context context, Cursor cursor, ViewGroup parent) {
             View ret = mFactory.inflate(R.layout.alarm_time, parent, false);
 
-            DigitalClock digitalClock = (DigitalClock) ret.findViewById(R.id.digitalClock);
+            DigitalClock digitalClock =
+                    (DigitalClock) ret.findViewById(R.id.digitalClock);
             digitalClock.setLive(false);
-            if (Log.LOGV) Log.v("newView " + cursor.getPosition());
             return ret;
         }
 
@@ -238,21 +236,8 @@
         });
     }
 
-    // Version of addNewAlarm that can be called from any activity, e.g. DeskClock
-    protected static void addNewAlarm(Context context) {
-        final Uri uri = Alarms.addAlarm(context.getContentResolver());
-        final String segment = uri.getPathSegments().get(1);
-        int newId = Integer.parseInt(segment);
-        if (Log.LOGV) {
-            Log.v("In AlarmClock, new alarm id = " + newId);
-        }
-        final Intent intent = new Intent(context, SetAlarm.class);
-        intent.putExtra(Alarms.ALARM_ID, newId);
-        context.startActivity(intent);
-    }
-
     private void addNewAlarm() {
-        addNewAlarm(this);
+        startActivity(new Intent(this, SetAlarm.class));
     }
 
     @Override
diff --git a/src/com/android/deskclock/AlarmKlaxon.java b/src/com/android/deskclock/AlarmKlaxon.java
index 040dc24..3c3543c 100644
--- a/src/com/android/deskclock/AlarmKlaxon.java
+++ b/src/com/android/deskclock/AlarmKlaxon.java
@@ -86,7 +86,7 @@
 
     @Override
     public void onCreate() {
-        mVibrator = new Vibrator();
+        mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
         // Listen for incoming calls to kill the alarm.
         mTelephonyManager =
                 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
@@ -204,7 +204,7 @@
                     // Must reset the media player to clear the error state.
                     mMediaPlayer.reset();
                     setDataSourceFromResource(getResources(), mMediaPlayer,
-                            com.android.internal.R.raw.fallbackring);
+                            R.raw.fallbackring);
                     startAlarm(mMediaPlayer);
                 } catch (Exception ex2) {
                     // At this point we just don't play anything.
diff --git a/src/com/android/deskclock/AlarmPreference.java b/src/com/android/deskclock/AlarmPreference.java
index a977728..8f1170e 100644
--- a/src/com/android/deskclock/AlarmPreference.java
+++ b/src/com/android/deskclock/AlarmPreference.java
@@ -60,10 +60,7 @@
         }
     }
 
-    public String getAlertString() {
-        if (mAlert != null) {
-            return mAlert.toString();
-        }
-        return Alarms.ALARM_ALERT_SILENT;
+    public Uri getAlert() {
+        return mAlert;
     }
 }
diff --git a/src/com/android/deskclock/AlarmProvider.java b/src/com/android/deskclock/AlarmProvider.java
index 4b6c8a3..133e79a 100644
--- a/src/com/android/deskclock/AlarmProvider.java
+++ b/src/com/android/deskclock/AlarmProvider.java
@@ -166,35 +166,7 @@
             throw new IllegalArgumentException("Cannot insert into URL: " + url);
         }
 
-        ContentValues values;
-        if (initialValues != null)
-            values = new ContentValues(initialValues);
-        else
-            values = new ContentValues();
-
-        if (!values.containsKey(Alarm.Columns.HOUR))
-            values.put(Alarm.Columns.HOUR, 0);
-
-        if (!values.containsKey(Alarm.Columns.MINUTES))
-            values.put(Alarm.Columns.MINUTES, 0);
-
-        if (!values.containsKey(Alarm.Columns.DAYS_OF_WEEK))
-            values.put(Alarm.Columns.DAYS_OF_WEEK, 0);
-
-        if (!values.containsKey(Alarm.Columns.ALARM_TIME))
-            values.put(Alarm.Columns.ALARM_TIME, 0);
-
-        if (!values.containsKey(Alarm.Columns.ENABLED))
-            values.put(Alarm.Columns.ENABLED, 0);
-
-        if (!values.containsKey(Alarm.Columns.VIBRATE))
-            values.put(Alarm.Columns.VIBRATE, 1);
-
-        if (!values.containsKey(Alarm.Columns.MESSAGE))
-            values.put(Alarm.Columns.MESSAGE, "");
-
-        if (!values.containsKey(Alarm.Columns.ALERT))
-            values.put(Alarm.Columns.ALERT, "");
+        ContentValues values = new ContentValues(initialValues);
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         long rowId = db.insert("alarms", Alarm.Columns.MESSAGE, values);
diff --git a/src/com/android/deskclock/AlarmReceiver.java b/src/com/android/deskclock/AlarmReceiver.java
index 92f929a..5bb0e5a 100644
--- a/src/com/android/deskclock/AlarmReceiver.java
+++ b/src/com/android/deskclock/AlarmReceiver.java
@@ -145,9 +145,7 @@
                 pendingNotify);
         n.flags |= Notification.FLAG_SHOW_LIGHTS
                 | Notification.FLAG_ONGOING_EVENT;
-        n.ledARGB = 0xFF00FF00;
-        n.ledOnMS = 500;
-        n.ledOffMS = 500;
+        n.defaults |= Notification.DEFAULT_LIGHTS;
 
         // Send the notification using the alarm id to easily identify the
         // correct notification.
diff --git a/src/com/android/deskclock/Alarms.java b/src/com/android/deskclock/Alarms.java
index ebb337b..92457ad 100644
--- a/src/com/android/deskclock/Alarms.java
+++ b/src/com/android/deskclock/Alarms.java
@@ -84,10 +84,16 @@
     /**
      * Creates a new Alarm.
      */
-    public static Uri addAlarm(ContentResolver contentResolver) {
-        ContentValues values = new ContentValues();
-        values.put(Alarm.Columns.HOUR, 8);
-        return contentResolver.insert(Alarm.Columns.CONTENT_URI, values);
+    public static long addAlarm(Context context, Alarm alarm) {
+        ContentValues values = createContentValues(alarm);
+        context.getContentResolver().insert(Alarm.Columns.CONTENT_URI, values);
+
+        long timeInMillis = calculateAlarm(alarm);
+        if (alarm.enabled) {
+            clearSnoozeIfNeeded(context, timeInMillis);
+        }
+        setNextAlert(context);
+        return timeInMillis;
     }
 
     /**
@@ -125,6 +131,41 @@
                 null, null);
     }
 
+    private static ContentValues createContentValues(Alarm alarm) {
+        ContentValues values = new ContentValues(8);
+        // Set the alarm_time value if this alarm does not repeat. This will be
+        // used later to disable expire alarms.
+        long time = 0;
+        if (!alarm.daysOfWeek.isRepeatSet()) {
+            time = calculateAlarm(alarm);
+        }
+
+        values.put(Alarm.Columns.ENABLED, alarm.enabled ? 1 : 0);
+        values.put(Alarm.Columns.HOUR, alarm.hour);
+        values.put(Alarm.Columns.MINUTES, alarm.minutes);
+        values.put(Alarm.Columns.ALARM_TIME, alarm.time);
+        values.put(Alarm.Columns.DAYS_OF_WEEK, alarm.daysOfWeek.getCoded());
+        values.put(Alarm.Columns.VIBRATE, alarm.vibrate);
+        values.put(Alarm.Columns.MESSAGE, alarm.label);
+
+        // A null alert Uri indicates a silent alarm.
+        values.put(Alarm.Columns.ALERT, alarm.alert == null ? ALARM_ALERT_SILENT
+                : alarm.alert.toString());
+
+        return values;
+    }
+
+    private static void clearSnoozeIfNeeded(Context context, long alarmTime) {
+        // If this alarm fires before the next snooze, clear the snooze to
+        // enable this alarm.
+        SharedPreferences prefs =
+                context.getSharedPreferences(AlarmClock.PREFERENCES, 0);
+        long snoozeTime = prefs.getLong(PREF_SNOOZE_TIME, 0);
+        if (alarmTime < snoozeTime) {
+            clearSnoozePreference(context, prefs);
+        }
+    }
+
     /**
      * Return an Alarm object representing the alarm id in the database.
      * Returns null if no alarm exists.
@@ -148,59 +189,19 @@
     /**
      * A convenience method to set an alarm in the Alarms
      * content provider.
-     *
-     * @param id             corresponds to the _id column
-     * @param enabled        corresponds to the ENABLED column
-     * @param hour           corresponds to the HOUR column
-     * @param minutes        corresponds to the MINUTES column
-     * @param daysOfWeek     corresponds to the DAYS_OF_WEEK column
-     * @param time           corresponds to the ALARM_TIME column
-     * @param vibrate        corresponds to the VIBRATE column
-     * @param message        corresponds to the MESSAGE column
-     * @param alert          corresponds to the ALERT column
      * @return Time when the alarm will fire.
      */
-    public static long setAlarm(
-            Context context, int id, boolean enabled, int hour, int minutes,
-            Alarm.DaysOfWeek daysOfWeek, boolean vibrate, String message,
-            String alert) {
-
-        ContentValues values = new ContentValues(8);
+    public static long setAlarm(Context context, Alarm alarm) {
+        ContentValues values = createContentValues(alarm);
         ContentResolver resolver = context.getContentResolver();
-        // Set the alarm_time value if this alarm does not repeat. This will be
-        // used later to disable expired alarms.
-        long time = 0;
-        if (!daysOfWeek.isRepeatSet()) {
-            time = calculateAlarm(hour, minutes, daysOfWeek).getTimeInMillis();
-        }
+        resolver.update(
+                ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI, alarm.id),
+                values, null, null);
 
-        if (Log.LOGV) Log.v(
-                "**  setAlarm * idx " + id + " hour " + hour + " minutes " +
-                minutes + " enabled " + enabled + " time " + time);
+        long timeInMillis = calculateAlarm(alarm);
 
-        values.put(Alarm.Columns.ENABLED, enabled ? 1 : 0);
-        values.put(Alarm.Columns.HOUR, hour);
-        values.put(Alarm.Columns.MINUTES, minutes);
-        values.put(Alarm.Columns.ALARM_TIME, time);
-        values.put(Alarm.Columns.DAYS_OF_WEEK, daysOfWeek.getCoded());
-        values.put(Alarm.Columns.VIBRATE, vibrate);
-        values.put(Alarm.Columns.MESSAGE, message);
-        values.put(Alarm.Columns.ALERT, alert);
-        resolver.update(ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI, id),
-                        values, null, null);
-
-        long timeInMillis =
-                calculateAlarm(hour, minutes, daysOfWeek).getTimeInMillis();
-
-        if (enabled) {
-            // If this alarm fires before the next snooze, clear the snooze to
-            // enable this alarm.
-            SharedPreferences prefs = context.getSharedPreferences(
-                    AlarmClock.PREFERENCES, 0);
-            long snoozeTime = prefs.getLong(PREF_SNOOZE_TIME, 0);
-            if (timeInMillis < snoozeTime) {
-                clearSnoozePreference(context, prefs);
-            }
+        if (alarm.enabled) {
+            clearSnoozeIfNeeded(context, timeInMillis);
         }
 
         setNextAlert(context);
@@ -229,6 +230,9 @@
 
     private static void enableAlarmInternal(final Context context,
             final Alarm alarm, boolean enabled) {
+        if (alarm == null) {
+            return;
+        }
         ContentResolver resolver = context.getContentResolver();
 
         ContentValues values = new ContentValues(2);
@@ -239,10 +243,12 @@
         if (enabled) {
             long time = 0;
             if (!alarm.daysOfWeek.isRepeatSet()) {
-                time = calculateAlarm(alarm.hour, alarm.minutes,
-                        alarm.daysOfWeek).getTimeInMillis();
+                time = calculateAlarm(alarm);
             }
             values.put(Alarm.Columns.ALARM_TIME, time);
+        } else {
+            // Clear the snooze if the id matches.
+            disableSnoozeAlert(context, alarm.id);
         }
 
         resolver.update(ContentUris.withAppendedId(
@@ -261,8 +267,7 @@
                     // A time of 0 indicates this is a repeating alarm, so
                     // calculate the time to get the next alert.
                     if (a.time == 0) {
-                        a.time = calculateAlarm(a.hour, a.minutes, a.daysOfWeek)
-                                .getTimeInMillis();
+                        a.time = calculateAlarm(a);
                     } else if (a.time < now) {
                         // Expired alarm, disable it and move along.
                         enableAlarmInternal(context, a, false);
@@ -360,7 +365,7 @@
         setStatusBarIcon(context, true);
 
         Calendar c = Calendar.getInstance();
-        c.setTime(new java.util.Date(atTimeInMillis));
+        c.setTimeInMillis(atTimeInMillis);
         String timeString = formatDayAndTime(context, c);
         saveNextAlarm(context, timeString);
     }
@@ -447,6 +452,9 @@
 
         // Get the alarm from the db.
         final Alarm alarm = getAlarm(context.getContentResolver(), id);
+        if (alarm == null) {
+            return false;
+        }
         // The time in the database is either 0 (repeating) or a specific time
         // for a non-repeating alarm. Update this value so the AlarmReceiver
         // has the right time to compare.
@@ -460,19 +468,22 @@
      * Tells the StatusBar whether the alarm is enabled or disabled
      */
     private static void setStatusBarIcon(Context context, boolean enabled) {
-        Intent alarmChanged = new Intent(Intent.ACTION_ALARM_CHANGED);
+        Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED");
         alarmChanged.putExtra("alarmSet", enabled);
         context.sendBroadcast(alarmChanged);
     }
 
+    private static long calculateAlarm(Alarm alarm) {
+        return calculateAlarm(alarm.hour, alarm.minutes, alarm.daysOfWeek)
+                .getTimeInMillis();
+    }
+
     /**
      * Given an alarm in hours and minutes, return a time suitable for
      * setting in AlarmManager.
-     * @param hour Always in 24 hour 0-23
-     * @param minute 0-59
-     * @param daysOfWeek 0-59
      */
-    static Calendar calculateAlarm(int hour, int minute, Alarm.DaysOfWeek daysOfWeek) {
+    static Calendar calculateAlarm(int hour, int minute,
+            Alarm.DaysOfWeek daysOfWeek) {
 
         // start with now
         Calendar c = Calendar.getInstance();
@@ -492,9 +503,6 @@
         c.set(Calendar.MILLISECOND, 0);
 
         int addDays = daysOfWeek.getNextAlarm(c);
-        /* Log.v("** TIMES * " + c.getTimeInMillis() + " hour " + hour +
-           " minute " + minute + " dow " + c.get(Calendar.DAY_OF_WEEK) + " from now " +
-           addDays); */
         if (addDays > 0) c.add(Calendar.DAY_OF_WEEK, addDays);
         return c;
     }
diff --git a/src/com/android/deskclock/AnalogAppWidgetProvider.java b/src/com/android/deskclock/AnalogAppWidgetProvider.java
index d78f82f..a493d90 100644
--- a/src/com/android/deskclock/AnalogAppWidgetProvider.java
+++ b/src/com/android/deskclock/AnalogAppWidgetProvider.java
@@ -16,33 +16,13 @@
 
 package com.android.deskclock;
 
-import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.appwidget.AppWidgetManager;
 import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.PorterDuff;
-import android.net.Uri;
-import android.provider.Calendar;
-import android.provider.Calendar.Attendees;
-import android.provider.Calendar.Calendars;
-import android.provider.Calendar.EventsColumns;
-import android.provider.Calendar.Instances;
-import android.provider.Calendar.Reminders;
-import android.text.format.DateFormat;
-import android.text.format.DateUtils;
-import android.util.Config;
-import android.util.Log;
-import android.view.View;
 import android.widget.RemoteViews;
 
-import java.util.Arrays;
-
 /**
  * Simple widget to show analog clock.
  */
@@ -51,13 +31,19 @@
 
     public void onReceive(Context context, Intent intent) {
         String action = intent.getAction();
-        
+
         if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
             RemoteViews views = new RemoteViews(context.getPackageName(),
                     R.layout.analog_appwidget);
-            
-            int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
-            
+
+            views.setOnClickPendingIntent(R.id.analog_appwidget,
+                    PendingIntent.getActivity(context, 0,
+                        new Intent(context, AlarmClock.class),
+                        PendingIntent.FLAG_CANCEL_CURRENT));
+
+            int[] appWidgetIds = intent.getIntArrayExtra(
+                    AppWidgetManager.EXTRA_APPWIDGET_IDS);
+
             AppWidgetManager gm = AppWidgetManager.getInstance(context);
             gm.updateAppWidget(appWidgetIds, views);
         }
diff --git a/src/com/android/deskclock/DeskClock.java b/src/com/android/deskclock/DeskClock.java
index de96e9b..74d55f5 100644
--- a/src/com/android/deskclock/DeskClock.java
+++ b/src/com/android/deskclock/DeskClock.java
@@ -29,7 +29,9 @@
 import android.content.pm.PackageManager;
 import android.content.res.Configuration;
 import android.content.res.Resources;
+import android.database.ContentObserver;
 import android.database.Cursor;
+import android.graphics.Rect;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
@@ -50,10 +52,13 @@
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
+import android.view.MotionEvent;
 import android.view.View.OnClickListener;
 import android.view.View.OnCreateContextMenuListener;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnGlobalFocusChangeListener;
 import android.view.Window;
 import android.view.WindowManager;
 import android.view.animation.Animation;
@@ -94,16 +99,14 @@
     // Alarm action for midnight (so we can update the date display).
     private static final String ACTION_MIDNIGHT = "com.android.deskclock.MIDNIGHT";
 
+    // Interval between forced polls of the weather widget.
+    private final long QUERY_WEATHER_DELAY = 60 * 60 * 1000; // 1 hr
+
     // Intent to broadcast for dock settings.
     private static final String DOCK_SETTINGS_ACTION = "com.android.settings.DOCK_SETTINGS";
 
-    // Interval between polls of the weather widget. Its refresh period is
-    // likely to be much longer (~3h), but we want to pick up any changes
-    // within 5 minutes.
-    private final long QUERY_WEATHER_DELAY = 5 * 60 * 1000; // 5 min
-
     // Delay before engaging the burn-in protection mode (green-on-black).
-    private final long SCREEN_SAVER_TIMEOUT = 5* 60 * 1000; // 10 min
+    private final long SCREEN_SAVER_TIMEOUT = 5 * 60 * 1000; // 5 min
 
     // Repositioning delay in screen saver.
     private final long SCREEN_SAVER_MOVE_DELAY = 60 * 1000; // 1 min
@@ -114,7 +117,7 @@
 
     // Opacity of black layer between clock display and wallpaper.
     private final float DIM_BEHIND_AMOUNT_NORMAL = 0.4f;
-    private final float DIM_BEHIND_AMOUNT_DIMMED = 0.7f; // higher contrast when display dimmed
+    private final float DIM_BEHIND_AMOUNT_DIMMED = 0.8f; // higher contrast when display dimmed
 
     // Internal message IDs.
     private final int QUERY_WEATHER_DATA_MSG     = 0x1000;
@@ -215,6 +218,14 @@
         }
     };
 
+    private final ContentObserver mContentObserver = new ContentObserver(mHandy) {
+        @Override
+        public void onChange(boolean selfChange) {
+            if (DEBUG) Log.d(LOG_TAG, "content observer notified that weather changed");
+            refreshWeather();
+        }
+    };
+
 
     private void moveScreenSaver() {
         moveScreenSaverTo(-1,-1);
@@ -346,8 +357,7 @@
     private void requestWeatherDataFetch() {
         if (DEBUG) Log.d(LOG_TAG, "forcing the Genie widget to update weather now...");
         sendBroadcast(new Intent(ACTION_GENIE_REFRESH).putExtra("requestWeather", true));
-        // update the display with any new data
-        scheduleWeatherQueryDelayed(5000);
+        // we expect the result to show up in our content observer
     }
 
     private boolean supportsWeather() {
@@ -410,35 +420,21 @@
 
             mWeatherIconDrawable = mGenieResources.getDrawable(cur.getInt(
                 cur.getColumnIndexOrThrow("iconResId")));
-
+            mWeatherCurrentTemperatureString = String.format("%d\u00b0",
+                (cur.getInt(cur.getColumnIndexOrThrow("temperature"))));
+            mWeatherHighTemperatureString = String.format("%d\u00b0",
+                (cur.getInt(cur.getColumnIndexOrThrow("highTemperature"))));
+            mWeatherLowTemperatureString = String.format("%d\u00b0",
+                (cur.getInt(cur.getColumnIndexOrThrow("lowTemperature"))));
             mWeatherLocationString = cur.getString(
                 cur.getColumnIndexOrThrow("location"));
-
-            // any of these may be NULL
-            final int colTemp = cur.getColumnIndexOrThrow("temperature");
-            final int colHigh = cur.getColumnIndexOrThrow("highTemperature");
-            final int colLow = cur.getColumnIndexOrThrow("lowTemperature");
-
-            mWeatherCurrentTemperatureString =
-                cur.isNull(colTemp)
-                    ? "\u2014"
-                    : String.format("%d\u00b0", cur.getInt(colTemp));
-            mWeatherHighTemperatureString =
-                cur.isNull(colHigh)
-                    ? "\u2014"
-                    : String.format("%d\u00b0", cur.getInt(colHigh));
-            mWeatherLowTemperatureString =
-                cur.isNull(colLow)
-                    ? "\u2014"
-                    : String.format("%d\u00b0", cur.getInt(colLow));
         } else {
             Log.w(LOG_TAG, "No weather information available (cur="
                 + cur +")");
             mWeatherIconDrawable = null;
+            mWeatherHighTemperatureString = "";
+            mWeatherLowTemperatureString = "";
             mWeatherLocationString = getString(R.string.weather_fetch_failure);
-            mWeatherCurrentTemperatureString =
-                mWeatherHighTemperatureString =
-                mWeatherLowTemperatureString = "";
         }
 
         mHandy.sendEmptyMessage(UPDATE_WEATHER_DISPLAY_MSG);
@@ -536,6 +532,7 @@
         if (mDimmed) {
             winParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
             winParams.dimAmount = DIM_BEHIND_AMOUNT_DIMMED;
+            winParams.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
 
             // show the window tint
             tintView.startAnimation(AnimationUtils.loadAnimation(this,
@@ -544,6 +541,7 @@
         } else {
             winParams.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
             winParams.dimAmount = DIM_BEHIND_AMOUNT_NORMAL;
+            winParams.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
 
             // hide the window tint
             tintView.startAnimation(AnimationUtils.loadAnimation(this,
@@ -571,7 +569,7 @@
 
         // reload the date format in case the user has changed settings
         // recently
-        mDateFormat = getString(com.android.internal.R.string.full_wday_month_day_no_year);
+        mDateFormat = getString(R.string.full_wday_month_day_no_year);
 
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_DATE_CHANGED);
@@ -580,6 +578,16 @@
         filter.addAction(ACTION_MIDNIGHT);
         registerReceiver(mIntentReceiver, filter);
 
+        // Listen for updates to weather data
+        Uri weatherNotificationUri = new Uri.Builder()
+            .scheme(android.content.ContentResolver.SCHEME_CONTENT)
+            .authority(WEATHER_CONTENT_AUTHORITY)
+            .path(WEATHER_CONTENT_PATH)
+            .build();
+        getContentResolver().registerContentObserver(
+            weatherNotificationUri, true, mContentObserver);
+
+        // Elaborate mechanism to find out when the day rolls over
         Calendar today = Calendar.getInstance();
         today.set(Calendar.HOUR_OF_DAY, 0);
         today.set(Calendar.MINUTE, 0);
@@ -593,8 +601,13 @@
             + alarmTimeUTC + " repeating every "
             + AlarmManager.INTERVAL_DAY + " with intent: " + mMidnightIntent);
 
-        // un-dim when resuming
-        mDimmed = false;
+        // If we weren't previously visible but now we are, it's because we're
+        // being started from another activity. So it's OK to un-dim.
+        if (mTime != null && mTime.getWindowVisibility() != View.VISIBLE) {
+            mDimmed = false;
+        }
+
+        // Adjust the display to reflect the currently chosen dim mode.
         doDim(false);
 
         restoreScreen(); // disable screen saver
@@ -627,6 +640,8 @@
 
         // Other things we don't want to be doing in the background.
         unregisterReceiver(mIntentReceiver);
+        getContentResolver().unregisterContentObserver(mContentObserver);
+
         AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
         am.cancel(mMidnightIntent);
         unscheduleWeatherQuery();
@@ -634,18 +649,6 @@
         super.onPause();
     }
 
-    @Override
-    public void onStop() {
-        if (DEBUG) Log.d(LOG_TAG, "onStop");
-
-        // Avoid situations where the user launches Alarm Clock and is
-        // surprised to find it in dim mode (because it was last used in dim
-        // mode, but that last use is long in the past).
-        mDimmed = false;
-
-        super.onStop();
-    }
-
     private void initViews() {
         // give up any internal focus before we switch layouts
         final View focused = getCurrentFocus();
@@ -746,12 +749,47 @@
                 }
             }
         });
+
+        final View tintView = findViewById(R.id.window_tint);
+        tintView.setOnTouchListener(new View.OnTouchListener() {
+            public boolean onTouch(View v, MotionEvent event) {
+                if (mDimmed && event.getAction() == MotionEvent.ACTION_DOWN) {
+                    // We want to un-dim the whole screen on tap.
+                    // ...Unless the user is specifically tapping on the dim
+                    // widget, in which case let it do the work.
+                    Rect r = new Rect();
+                    nightmodeButton.getHitRect(r);
+                    int[] gloc = new int[2];
+                    nightmodeButton.getLocationInWindow(gloc);
+                    r.offsetTo(gloc[0], gloc[1]); // convert to window coords
+
+                    if (!r.contains((int) event.getX(), (int) event.getY())) {
+                        mDimmed = false;
+                        doDim(true);
+                    }
+                }
+                return false; // always pass the click through
+            }
+        });
+
+        // Tidy up awkward focus behavior: the first view to be focused in
+        // trackball mode should be the alarms button
+        final ViewTreeObserver vto = alarmButton.getViewTreeObserver();
+        vto.addOnGlobalFocusChangeListener(new ViewTreeObserver.OnGlobalFocusChangeListener() {
+            public void onGlobalFocusChanged(View oldFocus, View newFocus) {
+                if (oldFocus == null && newFocus == nightmodeButton) {
+                    alarmButton.requestFocus();
+                }
+            }
+        });
     }
 
     @Override
     public void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
-        if (!mScreenSaverMode) {
+        if (mScreenSaverMode) {
+            moveScreenSaver();
+        } else {
             initViews();
             doDim(false);
             refreshAll();
@@ -765,7 +803,7 @@
                 startActivity(new Intent(DeskClock.this, AlarmClock.class));
                 return true;
             case R.id.menu_item_add_alarm:
-                AlarmClock.addNewAlarm(this);
+                startActivity(new Intent(this, SetAlarm.class));
                 return true;
             case R.id.menu_item_dock_settings:
                 startActivity(new Intent(DOCK_SETTINGS_ACTION));
diff --git a/src/com/android/deskclock/DigitalClock.java b/src/com/android/deskclock/DigitalClock.java
index 69a7156..56544e3 100644
--- a/src/com/android/deskclock/DigitalClock.java
+++ b/src/com/android/deskclock/DigitalClock.java
@@ -136,12 +136,12 @@
             filter.addAction(Intent.ACTION_TIME_TICK);
             filter.addAction(Intent.ACTION_TIME_CHANGED);
             filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
-            mContext.registerReceiver(mIntentReceiver, filter);
+            getContext().registerReceiver(mIntentReceiver, filter);
         }
 
         /* monitor 12/24-hour display preference */
         mFormatChangeObserver = new FormatChangeObserver();
-        mContext.getContentResolver().registerContentObserver(
+        getContext().getContentResolver().registerContentObserver(
                 Settings.System.CONTENT_URI, true, mFormatChangeObserver);
 
         updateTime();
@@ -155,9 +155,9 @@
         mAttached = false;
 
         if (mLive) {
-            mContext.unregisterReceiver(mIntentReceiver);
+            getContext().unregisterReceiver(mIntentReceiver);
         }
-        mContext.getContentResolver().unregisterContentObserver(
+        getContext().getContentResolver().unregisterContentObserver(
                 mFormatChangeObserver);
     }
 
@@ -178,7 +178,7 @@
     }
 
     private void setDateFormat() {
-        mFormat = Alarms.get24HourMode(mContext) ? Alarms.M24 : M12;
+        mFormat = Alarms.get24HourMode(getContext()) ? Alarms.M24 : M12;
         mAmPm.setShowAmPm(mFormat == M12);
     }
 
diff --git a/src/com/android/deskclock/SetAlarm.java b/src/com/android/deskclock/SetAlarm.java
index ce07cc1..5115c1f 100644
--- a/src/com/android/deskclock/SetAlarm.java
+++ b/src/com/android/deskclock/SetAlarm.java
@@ -21,8 +21,6 @@
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.media.RingtoneManager;
-import android.net.Uri;
 import android.os.Bundle;
 import android.preference.CheckBoxPreference;
 import android.preference.EditTextPreference;
@@ -59,6 +57,7 @@
     private int     mId;
     private int     mHour;
     private int     mMinutes;
+    private boolean mCreateNewAlarm;
 
     /**
      * Set an alarm.  Requires an Alarms.ALARM_ID to be passed in as an
@@ -68,6 +67,9 @@
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        // Override the default content view.
+        setContentView(R.layout.set_alarm);
+
         addPreferencesFromResource(R.xml.alarm_prefs);
 
         // Get each preference so we can retrieve the value later.
@@ -93,8 +95,20 @@
             Log.v("In SetAlarm, alarm id = " + mId);
         }
 
-        /* load alarm details from database */
-        Alarm alarm = Alarms.getAlarm(getContentResolver(), mId);
+        Alarm alarm = null;
+        if (mId == -1) {
+            // No alarm id means create a new alarm.
+            mCreateNewAlarm = true;
+            alarm = new Alarm();
+        } else {
+            /* load alarm details from database */
+            alarm = Alarms.getAlarm(getContentResolver(), mId);
+            // Bad alarm, bail to avoid a NPE.
+            if (alarm == null) {
+                finish();
+                return;
+            }
+        }
         mEnabledPref.setChecked(alarm.enabled);
         mLabel.setText(alarm.label);
         mLabel.setSummary(alarm.label);
@@ -110,62 +124,40 @@
         // their own.
         getListView().setItemsCanFocus(true);
 
-        // Grab the content view so we can modify it.
-        FrameLayout content = (FrameLayout) getWindow().getDecorView()
-                .findViewById(com.android.internal.R.id.content);
-
-        // Get the main ListView and remove it from the content view.
-        ListView lv = getListView();
-        content.removeView(lv);
-
-        // Create the new LinearLayout that will become the content view and
-        // make it vertical.
-        LinearLayout ll = new LinearLayout(this);
-        ll.setOrientation(LinearLayout.VERTICAL);
-
-        // Have the ListView expand to fill the screen minus the save/cancel
-        // buttons.
-        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
-                LayoutParams.FILL_PARENT,
-                LayoutParams.WRAP_CONTENT);
-        lp.weight = 1;
-        ll.addView(lv, lp);
-
-        // Inflate the buttons onto the LinearLayout.
-        View v = LayoutInflater.from(this).inflate(
-                R.layout.save_cancel_alarm, ll);
-
         // Attach actions to each button.
-        Button b = (Button) v.findViewById(R.id.alarm_save);
+        Button b = (Button) findViewById(R.id.alarm_save);
         b.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
+                    // Enable the alarm when clicking "Done"
+                    mEnabledPref.setChecked(true);
                     saveAlarm();
                     finish();
                 }
         });
-        b = (Button) v.findViewById(R.id.alarm_cancel);
+        b = (Button) findViewById(R.id.alarm_cancel);
         b.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
                     finish();
                 }
         });
-        b = (Button) v.findViewById(R.id.alarm_delete);
+        b = (Button) findViewById(R.id.alarm_delete);
         b.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
                     deleteAlarm();
                 }
         });
 
-        // Replace the old content view with our new one.
-        setContentView(ll);
+        // The last thing we do is pop the time picker if this is a new alarm.
+        if (mCreateNewAlarm) {
+            showTimePicker();
+        }
     }
 
     @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
             Preference preference) {
         if (preference == mTimePref) {
-            new TimePickerDialog(this, this, mHour, mMinutes,
-                    DateFormat.is24HourFormat(this)).show();
+            showTimePicker();
         }
 
         return super.onPreferenceTreeClick(preferenceScreen, preference);
@@ -177,6 +169,11 @@
         finish();
     }
 
+    private void showTimePicker() {
+        new TimePickerDialog(this, this, mHour, mMinutes,
+                DateFormat.is24HourFormat(this)).show();
+    }
+
     public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
         mHour = hourOfDay;
         mMinutes = minute;
@@ -194,12 +191,24 @@
     }
 
     private void saveAlarm() {
-        final String alert = mAlarmPref.getAlertString();
-        long time = Alarms.setAlarm(this, mId, mEnabledPref.isChecked(), mHour,
-                mMinutes, mRepeatPref.getDaysOfWeek(), mVibratePref.isChecked(),
-                mLabel.getText(), alert);
+        Alarm alarm = new Alarm();
+        alarm.id = mId;
+        alarm.enabled = mEnabledPref.isChecked();
+        alarm.hour = mHour;
+        alarm.minutes = mMinutes;
+        alarm.daysOfWeek = mRepeatPref.getDaysOfWeek();
+        alarm.vibrate = mVibratePref.isChecked();
+        alarm.label = mLabel.getText();
+        alarm.alert = mAlarmPref.getAlert();
 
-        if (mEnabledPref.isChecked()) {
+        long time;
+        if (mCreateNewAlarm) {
+            time = Alarms.addAlarm(this, alarm);
+        } else {
+            time = Alarms.setAlarm(this, alarm);
+        }
+
+        if (alarm.enabled) {
             popAlarmSetToast(this, time);
         }
     }
@@ -220,27 +229,6 @@
     }
 
     /**
-     * Write alarm out to persistent store and pops toast if alarm
-     * enabled.
-     * Used only in test code.
-     */
-    private static void saveAlarm(
-            Context context, int id, boolean enabled, int hour, int minute,
-            Alarm.DaysOfWeek daysOfWeek, boolean vibrate, String label,
-            String alert, boolean popToast) {
-        if (Log.LOGV) Log.v("** saveAlarm " + id + " " + label + " " + enabled
-                + " " + hour + " " + minute + " vibe " + vibrate);
-
-        // Fix alert string first
-        long time = Alarms.setAlarm(context, id, enabled, hour, minute,
-                daysOfWeek, vibrate, label, alert);
-
-        if (enabled && popToast) {
-            popAlarmSetToast(context, time);
-        }
-    }
-
-    /**
      * Display a toast that tells the user how long until the alarm
      * goes off.  This helps prevent "am/pm" mistakes.
      */
@@ -292,47 +280,4 @@
         String[] formats = context.getResources().getStringArray(R.array.alarm_set);
         return String.format(formats[index], daySeq, hourSeq, minSeq);
     }
-
-    public boolean onCreateOptionsMenu(Menu menu) {
-        super.onCreateOptionsMenu(menu);
-
-        if (AlarmClock.DEBUG) {
-            mTestAlarmItem = menu.add(0, 0, 0, "test alarm");
-        }
-
-        return true;
-    }
-
-    public boolean onOptionsItemSelected(MenuItem item) {
-        if (AlarmClock.DEBUG) {
-            if (item == mTestAlarmItem) {
-                setTestAlarm();
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-
-    /**
-     * Test code: this is disabled for production build.  Sets
-     * this alarm to go off on the next minute
-     */
-    void setTestAlarm() {
-
-        // start with now
-        java.util.Calendar c = java.util.Calendar.getInstance();
-        c.setTimeInMillis(System.currentTimeMillis());
-
-        int nowHour = c.get(java.util.Calendar.HOUR_OF_DAY);
-        int nowMinute = c.get(java.util.Calendar.MINUTE);
-
-        int minutes = (nowMinute + 1) % 60;
-        int hour = nowHour + (nowMinute == 0 ? 1 : 0);
-
-        saveAlarm(this, mId, true, hour, minutes, mRepeatPref.getDaysOfWeek(),
-                true, mLabel.getText(), mAlarmPref.getAlertString(), true);
-    }
-
 }