OSDN Git Service

Moving things around a little in the new DeskClock.
authorDaniel Sandler <dsandler@google.com>
Fri, 16 Oct 2009 20:12:30 +0000 (16:12 -0400)
committerDaniel Sandler <dsandler@google.com>
Fri, 16 Oct 2009 20:12:30 +0000 (16:12 -0400)
- Package is now com.android.deskclock
- Launches in response to insertion in desk dock or
  DESK dialercode

TODO next: split the AlarmClock activity into a DeskClock
and AlarmList (or similar).

24 files changed:
AndroidManifest.xml
res/layout/alarm_time.xml
res/layout/digital_clock.xml
res/xml/alarm_prefs.xml
src/com/android/deskclock/Alarm.java [moved from src/com/android/alarmclock/Alarm.java with 99% similarity]
src/com/android/deskclock/AlarmAlert.java [moved from src/com/android/alarmclock/AlarmAlert.java with 99% similarity]
src/com/android/deskclock/AlarmAlertFullScreen.java [moved from src/com/android/alarmclock/AlarmAlertFullScreen.java with 97% similarity]
src/com/android/deskclock/AlarmAlertWakeLock.java [moved from src/com/android/alarmclock/AlarmAlertWakeLock.java with 98% similarity]
src/com/android/deskclock/AlarmClock.java [moved from src/com/android/alarmclock/AlarmClock.java with 99% similarity]
src/com/android/deskclock/AlarmInitReceiver.java [moved from src/com/android/alarmclock/AlarmInitReceiver.java with 97% similarity]
src/com/android/deskclock/AlarmKlaxon.java [moved from src/com/android/alarmclock/AlarmKlaxon.java with 99% similarity]
src/com/android/deskclock/AlarmPreference.java [moved from src/com/android/alarmclock/AlarmPreference.java with 98% similarity]
src/com/android/deskclock/AlarmProvider.java [moved from src/com/android/alarmclock/AlarmProvider.java with 97% similarity]
src/com/android/deskclock/AlarmReceiver.java [moved from src/com/android/alarmclock/AlarmReceiver.java with 99% similarity]
src/com/android/deskclock/Alarms.java [moved from src/com/android/alarmclock/Alarms.java with 99% similarity]
src/com/android/deskclock/AnalogAppWidgetProvider.java [moved from src/com/android/alarmclock/AnalogAppWidgetProvider.java with 98% similarity]
src/com/android/deskclock/ClockPicker.java [moved from src/com/android/alarmclock/ClockPicker.java with 99% similarity]
src/com/android/deskclock/DigitalClock.java [moved from src/com/android/alarmclock/DigitalClock.java with 99% similarity]
src/com/android/deskclock/DockEventReceiver.java [new file with mode: 0644]
src/com/android/deskclock/Log.java [moved from src/com/android/alarmclock/Log.java with 97% similarity]
src/com/android/deskclock/RepeatPreference.java [moved from src/com/android/alarmclock/RepeatPreference.java with 98% similarity]
src/com/android/deskclock/SetAlarm.java [moved from src/com/android/alarmclock/SetAlarm.java with 99% similarity]
src/com/android/deskclock/SettingsActivity.java [moved from src/com/android/alarmclock/SettingsActivity.java with 99% similarity]
src/com/android/deskclock/ToastMaster.java [moved from src/com/android/alarmclock/ToastMaster.java with 96% similarity]

index d731009..95824e4 100644 (file)
@@ -1,5 +1,5 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.android.alarmclock">
+        package="com.android.deskclock">
 
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
@@ -11,7 +11,7 @@
     <application android:label="@string/app_label"
                  android:icon="@drawable/ic_launcher_alarmclock">
 
-        <provider android:name="AlarmProvider" android:authorities="com.android.alarmclock" />
+        <provider android:name="AlarmProvider" android:authorities="com.android.deskclock" />
 
         <activity android:name="AlarmClock" android:label="@string/app_label"
                 android:icon="@drawable/ic_widget_analog_clock"
@@ -20,6 +20,7 @@
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.DESK_DOCK" />
             </intent-filter>
         </activity>
 
@@ -53,7 +54,7 @@
 
         <receiver android:name="AlarmReceiver">
             <intent-filter>
-               <action android:name="com.android.alarmclock.ALARM_ALERT" />
+               <action android:name="com.android.deskclock.ALARM_ALERT" />
                <action android:name="alarm_killed" />
                <action android:name="cancel_snooze" />
             </intent-filter>
@@ -67,7 +68,7 @@
              causes the AlarmAlert activity to pause. -->
         <service android:name="AlarmKlaxon">
             <intent-filter>
-                <action android:name="com.android.alarmclock.ALARM_ALERT" />
+                <action android:name="com.android.deskclock.ALARM_ALERT" />
             </intent-filter>
         </service>
 
             </intent-filter>
             <meta-data android:name="android.appwidget.provider" android:resource="@xml/analog_appwidget" />
         </receiver>
+
+        <receiver android:name="DockEventReceiver">
+            
+            <intent-filter>
+                <action android:name="android.intent.action.DOCK_EVENT" />
+            </intent-filter>
+            
+            <intent-filter>
+                <action android:name="android.provider.Telephony.SECRET_CODE" />
+                <data android:scheme="android_secret_code" android:host="3375" /><!-- DESK -->
+            </intent-filter>
+            
+        </receiver>
     </application>
 </manifest>
 
index ecf5cda..6541804 100644 (file)
@@ -23,7 +23,7 @@
     <!-- A layout that displays the time.  Shows time, am/pm (if 12-hour),
          and an optional line below, used for day/days of week -->
 
-    <com.android.alarmclock.DigitalClock android:id="@+id/digitalClock"
+    <com.android.deskclock.DigitalClock android:id="@+id/digitalClock"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
         android:layout_weight="1"
@@ -81,7 +81,7 @@
             android:textStyle="bold|italic"
             android:singleLine="true"/>
 
-    </com.android.alarmclock.DigitalClock>
+    </com.android.deskclock.DigitalClock>
 
     <CheckBox android:id="@+id/alarmButton"
         android:focusable="false"
index bca806f..0619686 100644 (file)
@@ -14,7 +14,7 @@
      limitations under the License.
 -->
 
-<com.android.alarmclock.DigitalClock android:id="@+id/clock"
+<com.android.deskclock.DigitalClock android:id="@+id/clock"
     xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/clock"
     android:gravity="center">
@@ -49,4 +49,4 @@
             android:includeFontPadding="false"
             android:textSize="28sp"/>
     </LinearLayout>
-</com.android.alarmclock.DigitalClock>
+</com.android.deskclock.DigitalClock>
index ff672e1..84b44e2 100644 (file)
@@ -19,7 +19,7 @@
     <Preference android:key="time" 
         android:persistent="false"
         android:title="@string/time"/>
-    <com.android.alarmclock.AlarmPreference
+    <com.android.deskclock.AlarmPreference
         android:key="alarm" 
         android:title="@string/alert"
         android:ringtoneType="alarm"
@@ -29,7 +29,7 @@
     <CheckBoxPreference android:key="vibrate" 
         android:persistent="false"
         android:title="@string/alarm_vibrate"/>
-    <com.android.alarmclock.RepeatPreference
+    <com.android.deskclock.RepeatPreference
         android:persistent="false"
         android:key="setRepeat" 
         android:title="@string/alarm_repeat" />
similarity index 99%
rename from src/com/android/alarmclock/Alarm.java
rename to src/com/android/deskclock/Alarm.java
index 350b7b4..13e4bd7 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.content.Context;
 import android.database.Cursor;
@@ -72,7 +72,7 @@ public final class Alarm implements Parcelable {
          * The content:// style URL for this table
          */
         public static final Uri CONTENT_URI =
-                Uri.parse("content://com.android.alarmclock/alarm");
+                Uri.parse("content://com.android.deskclock/alarm");
 
         /**
          * Hour in 24-hour localtime 0 - 23.
similarity index 99%
rename from src/com/android/alarmclock/AlarmAlert.java
rename to src/com/android/deskclock/AlarmAlert.java
index 89a866a..732bee8 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.Activity;
 import android.app.Notification;
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.os.Bundle;
 import android.view.WindowManager;
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.content.Context;
 import android.os.PowerManager;
similarity index 99%
rename from src/com/android/alarmclock/AlarmClock.java
rename to src/com/android/deskclock/AlarmClock.java
index 75477fd..cb9fc35 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.content.Context;
 import android.content.Intent;
similarity index 99%
rename from src/com/android/alarmclock/AlarmKlaxon.java
rename to src/com/android/deskclock/AlarmKlaxon.java
index 7205db6..b8f4b6b 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.Service;
 import android.content.Context;
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.content.Context;
 import android.media.Ringtone;
similarity index 97%
rename from src/com/android/alarmclock/AlarmProvider.java
rename to src/com/android/deskclock/AlarmProvider.java
index 5849a38..c635b01 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.content.ContentProvider;
 import android.content.ContentUris;
@@ -38,8 +38,8 @@ public class AlarmProvider extends ContentProvider {
             UriMatcher.NO_MATCH);
 
     static {
-        sURLMatcher.addURI("com.android.alarmclock", "alarm", ALARMS);
-        sURLMatcher.addURI("com.android.alarmclock", "alarm/#", ALARMS_ID);
+        sURLMatcher.addURI("com.android.deskclock", "alarm", ALARMS);
+        sURLMatcher.addURI("com.android.deskclock", "alarm/#", ALARMS_ID);
     }
 
     private static class DatabaseHelper extends SQLiteOpenHelper {
similarity index 99%
rename from src/com/android/alarmclock/AlarmReceiver.java
rename to src/com/android/deskclock/AlarmReceiver.java
index 97374ef..18457b6 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.KeyguardManager;
 import android.app.Notification;
similarity index 99%
rename from src/com/android/alarmclock/Alarms.java
rename to src/com/android/deskclock/Alarms.java
index 63a67d7..cd47b18 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.AlarmManager;
 import android.app.PendingIntent;
@@ -41,7 +41,7 @@ public class Alarms {
     // This action triggers the AlarmReceiver as well as the AlarmKlaxon. It
     // is a public action used in the manifest for receiving Alarm broadcasts
     // from the alarm manager.
-    public static final String ALARM_ALERT_ACTION = "com.android.alarmclock.ALARM_ALERT";
+    public static final String ALARM_ALERT_ACTION = "com.android.deskclock.ALARM_ALERT";
 
     // This is a private action used when the user clears all notifications.
     public static final String CLEAR_NOTIFICATION = "clear_notification";
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.AlarmManager;
 import android.app.PendingIntent;
similarity index 99%
rename from src/com/android/alarmclock/ClockPicker.java
rename to src/com/android/deskclock/ClockPicker.java
index 31150a2..077eba1 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.Activity;
 import android.content.SharedPreferences;
similarity index 99%
rename from src/com/android/alarmclock/DigitalClock.java
rename to src/com/android/deskclock/DigitalClock.java
index 7ae92f1..14205e7 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
diff --git a/src/com/android/deskclock/DockEventReceiver.java b/src/com/android/deskclock/DockEventReceiver.java
new file mode 100644 (file)
index 0000000..e15e2cb
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.deskclock;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+
+/**
+ * BroadcastReceiver which receives {@link Intent#ACTION_DOCK_EVENT} events.
+ * Launches the CarDockActivity if the device is placed into a car dock.
+ *
+ * TODO: This is the wrong way to launch, as this would cause contention
+ * between multiple activities trying to launch if others did the same. Instead
+ * register for a regular intent which should fire when placed into a car dock.
+ */
+public class DockEventReceiver extends BroadcastReceiver {
+    @Override
+    public void onReceive(Context context, Intent intent) {        
+        Intent clockIntent = new Intent(Intent.ACTION_MAIN);
+        clockIntent.setComponent(
+                new ComponentName(context, AlarmClock.class));
+        clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        
+        String action = intent.getAction();
+        if (Intent.ACTION_DOCK_EVENT.equals(action)) {
+            // Code to control a sticky notification for the dock.
+            /*
+            NotificationManager notificationManager = (NotificationManager)
+                    context.getSystemService(Context.NOTIFICATION_SERVICE);
+            
+            int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, -1);
+            if (dockState == Intent.EXTRA_DOCK_STATE_DESK) {
+                Notification n = new Notification();
+                n.icon = R.drawable.notification;
+                n.defaults = Notification.DEFAULT_LIGHTS;
+                n.flags = Notification.FLAG_ONGOING_EVENT;
+                n.tickerText = context.getString(R.string.notification_title);
+                n.when = 0;
+                n.setLatestEventInfo(
+                        context,
+                        context.getString(R.string.notification_title),
+                        context.getString(R.string.notification_text),
+                        PendingIntent.getActivity(context, 0, clockIntent, 0));
+                notificationManager.notify(0, n);
+            } else if (dockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                notificationManager.cancelAll();
+            }
+            */
+        } else if (android.provider.Telephony.Intents.SECRET_CODE_ACTION.equals(action)) {
+            // The user dialed *#*#DESK#*#*
+            context.startActivity(clockIntent);
+        }
+    }
+}
similarity index 97%
rename from src/com/android/alarmclock/Log.java
rename to src/com/android/deskclock/Log.java
index 18cc391..7e128b9 100644 (file)
@@ -18,7 +18,7 @@
  * package-level logging flag
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.os.SystemClock;
 import android.util.Config;
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.AlertDialog.Builder;
 import android.content.Context;
similarity index 99%
rename from src/com/android/alarmclock/SetAlarm.java
rename to src/com/android/deskclock/SetAlarm.java
index 03533af..1acc1d7 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.app.TimePickerDialog;
 import android.content.Context;
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.media.AudioManager;
 import android.os.Bundle;
similarity index 96%
rename from src/com/android/alarmclock/ToastMaster.java
rename to src/com/android/deskclock/ToastMaster.java
index c4c2815..4d51696 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.alarmclock;
+package com.android.deskclock;
 
 import android.widget.Toast;