<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"/>
<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"
<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>
<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>
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>
<!-- 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"
android:textStyle="bold|italic"
android:singleLine="true"/>
- </com.android.alarmclock.DigitalClock>
+ </com.android.deskclock.DigitalClock>
<CheckBox android:id="@+id/alarmButton"
android:focusable="false"
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">
android:includeFontPadding="false"
android:textSize="28sp"/>
</LinearLayout>
-</com.android.alarmclock.DigitalClock>
+</com.android.deskclock.DigitalClock>
<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"
<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" />
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.content.Context;
import android.database.Cursor;
* 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.
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.Activity;
import android.app.Notification;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.os.Bundle;
import android.view.WindowManager;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.content.Context;
import android.os.PowerManager;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.Activity;
import android.app.AlertDialog;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.content.Context;
import android.content.Intent;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.Service;
import android.content.Context;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.content.Context;
import android.media.Ringtone;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.content.ContentProvider;
import android.content.ContentUris;
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 {
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.KeyguardManager;
import android.app.Notification;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.AlarmManager;
import android.app.PendingIntent;
// 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";
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.AlarmManager;
import android.app.PendingIntent;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.Activity;
import android.content.SharedPreferences;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.content.BroadcastReceiver;
import android.content.Context;
--- /dev/null
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.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);
+ }
+ }
+}
* package-level logging flag
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.os.SystemClock;
import android.util.Config;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.AlertDialog.Builder;
import android.content.Context;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.app.TimePickerDialog;
import android.content.Context;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.media.AudioManager;
import android.os.Bundle;
* limitations under the License.
*/
-package com.android.alarmclock;
+package com.android.deskclock;
import android.widget.Toast;