OSDN Git Service

Unbundle the DeskClock.
authorPatrick Scott <phanna@android.com>
Wed, 20 Jan 2010 17:50:10 +0000 (12:50 -0500)
committerPatrick Scott <phanna@android.com>
Wed, 20 Jan 2010 18:22:05 +0000 (13:22 -0500)
- Copy some framework resources into the app.
- Add a new layout to SetAlarm to avoid using an internal id to obtain the
  content view.
- Use a string literal to identify the ALARM_CHANGED intent. This is not ideal
  but is better than exposing the actual intent string for now.

22 files changed:
Android.mk
res/drawable-hdpi/dialog_divider_horizontal_light.9.png [new file with mode: 0644]
res/drawable-hdpi/divider_vertical_dark.9.png [new file with mode: 0644]
res/drawable-hdpi/ic_dialog_time.png [new file with mode: 0644]
res/drawable-hdpi/list_selector_background_pressed.9.png [new file with mode: 0644]
res/drawable-mdpi/dialog_divider_horizontal_light.9.png [new file with mode: 0755]
res/drawable-mdpi/divider_vertical_dark.9.png [new file with mode: 0644]
res/drawable-mdpi/ic_dialog_time.png [new file with mode: 0755]
res/drawable-mdpi/list_selector_background_pressed.9.png [new file with mode: 0644]
res/drawable/clock_selector.xml
res/layout/alarm_alert.xml
res/layout/alarm_time.xml
res/layout/context_menu_header.xml
res/layout/save_cancel_alarm.xml [deleted file]
res/layout/set_alarm.xml [new file with mode: 0644]
res/raw/fallbackring.ogg [new file with mode: 0644]
res/values/strings.xml
src/com/android/deskclock/AlarmKlaxon.java
src/com/android/deskclock/Alarms.java
src/com/android/deskclock/DeskClock.java
src/com/android/deskclock/DigitalClock.java
src/com/android/deskclock/SetAlarm.java

index 946631c..8db1048 100644 (file)
@@ -9,4 +9,6 @@ LOCAL_PACKAGE_NAME := DeskClock
 
 LOCAL_OVERRIDES_PACKAGES := AlarmClock
 
+LOCAL_SDK_VERSION := current
+
 include $(BUILD_PACKAGE)
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 (file)
index 0000000..441ef32
Binary files /dev/null and b/res/drawable-hdpi/dialog_divider_horizontal_light.9.png 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 (file)
index 0000000..702b878
Binary files /dev/null and b/res/drawable-hdpi/divider_vertical_dark.9.png differ
diff --git a/res/drawable-hdpi/ic_dialog_time.png b/res/drawable-hdpi/ic_dialog_time.png
new file mode 100644 (file)
index 0000000..337a43a
Binary files /dev/null and b/res/drawable-hdpi/ic_dialog_time.png 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 (file)
index 0000000..ba79cf7
Binary files /dev/null and b/res/drawable-hdpi/list_selector_background_pressed.9.png 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 (executable)
index 0000000..b69619b
Binary files /dev/null and b/res/drawable-mdpi/dialog_divider_horizontal_light.9.png 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 (file)
index 0000000..702b878
Binary files /dev/null and b/res/drawable-mdpi/divider_vertical_dark.9.png differ
diff --git a/res/drawable-mdpi/ic_dialog_time.png b/res/drawable-mdpi/ic_dialog_time.png
new file mode 100755 (executable)
index 0000000..dffec29
Binary files /dev/null and b/res/drawable-mdpi/ic_dialog_time.png 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 (file)
index 0000000..02b4e9a
Binary files /dev/null and b/res/drawable-mdpi/list_selector_background_pressed.9.png differ
index efc9e5b..658100d 100644 (file)
@@ -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>
index cefc3e4..2e06010 100644 (file)
@@ -41,7 +41,7 @@
             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"/>
 
index 9c4fb7b..c84c1e8 100644 (file)
@@ -51,7 +51,7 @@
     </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="match_parent"
index 55846f5..193f312 100644 (file)
@@ -29,7 +29,7 @@
         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"
diff --git a/res/layout/save_cancel_alarm.xml b/res/layout/save_cancel_alarm.xml
deleted file mode 100644 (file)
index 7c5612f..0000000
+++ /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="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>
diff --git a/res/layout/set_alarm.xml b/res/layout/set_alarm.xml
new file mode 100644 (file)
index 0000000..660befe
--- /dev/null
@@ -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 (file)
index 0000000..9d80037
Binary files /dev/null and b/res/raw/fallbackring.ogg differ
index 1cf4057..c9aa301 100644 (file)
          respond. This is a sign of an error; if the weather widget is not
          present on the device, we show nothing at all. -->
     <string name="weather_fetch_failure">Weather information currently unavailable.</string>
+
+    <!-- String matching the lock screen format for displaying the date. -->
+    <string name="full_wday_month_day_no_year" translatable="false">EEEE, MMMM d</string>
 </resources>
 
 
index 040dc24..3c3543c 100644 (file)
@@ -86,7 +86,7 @@ public class AlarmKlaxon extends Service {
 
     @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 @@ public class AlarmKlaxon extends Service {
                     // 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.
index f46b058..bf13d16 100644 (file)
@@ -469,7 +469,7 @@ public class Alarms {
      * 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);
     }
index a66613c..d5df2c5 100644 (file)
@@ -566,7 +566,7 @@ public class DeskClock extends Activity {
 
         // 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);
index 69a7156..56544e3 100644 (file)
@@ -136,12 +136,12 @@ public class DigitalClock extends LinearLayout {
             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 @@ public class DigitalClock extends LinearLayout {
         mAttached = false;
 
         if (mLive) {
-            mContext.unregisterReceiver(mIntentReceiver);
+            getContext().unregisterReceiver(mIntentReceiver);
         }
-        mContext.getContentResolver().unregisterContentObserver(
+        getContext().getContentResolver().unregisterContentObserver(
                 mFormatChangeObserver);
     }
 
@@ -178,7 +178,7 @@ public class DigitalClock extends LinearLayout {
     }
 
     private void setDateFormat() {
-        mFormat = Alarms.get24HourMode(mContext) ? Alarms.M24 : M12;
+        mFormat = Alarms.get24HourMode(getContext()) ? Alarms.M24 : M12;
         mAmPm.setShowAmPm(mFormat == M12);
     }
 
index 3db6545..5174d41 100644 (file)
@@ -66,6 +66,9 @@ public class SetAlarm extends PreferenceActivity
     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.
@@ -113,33 +116,8 @@ public class SetAlarm extends PreferenceActivity
         // 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.MATCH_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"
@@ -148,21 +126,18 @@ public class SetAlarm extends PreferenceActivity
                     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);
     }
 
     @Override