summaryrefslogtreecommitdiffstats
path: root/src/com/android/deskclock/Alarm.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/deskclock/Alarm.java')
-rw-r--r--src/com/android/deskclock/Alarm.java38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/com/android/deskclock/Alarm.java b/src/com/android/deskclock/Alarm.java
index dedc0d848..23d4b9541 100644
--- a/src/com/android/deskclock/Alarm.java
+++ b/src/com/android/deskclock/Alarm.java
@@ -17,14 +17,16 @@
package com.android.deskclock;
import android.content.Context;
+import android.content.Intent;
import android.database.Cursor;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.BaseColumns;
-import android.text.format.DateFormat;
+import android.text.TextUtils;
+import java.net.URISyntaxException;
import java.text.DateFormatSymbols;
import java.util.Calendar;
@@ -59,6 +61,8 @@ public final class Alarm implements Parcelable {
p.writeString(label);
p.writeParcelable(alert, flags);
p.writeInt(silent ? 1 : 0);
+ p.writeString(intent);
+ p.writeInt(noDialog ? 1 : 0);
}
//////////////////////////////
// end Parcelable apis
@@ -124,6 +128,18 @@ public final class Alarm implements Parcelable {
public static final String ALERT = "alert";
/**
+ * Intent to fire when alarm triggers
+ * <P>Type: STRING</P>
+ */
+ public static final String INTENT = "intent";
+
+ /**
+ * Option to show dialog or not
+ * <P>Type: BOOLEAN</P>
+ */
+ public static final String NO_DIALOG = "no_dialog";
+
+ /**
* The default sort order for this table
*/
public static final String DEFAULT_SORT_ORDER =
@@ -134,7 +150,7 @@ public final class Alarm implements Parcelable {
static final String[] ALARM_QUERY_COLUMNS = {
_ID, HOUR, MINUTES, DAYS_OF_WEEK, ALARM_TIME,
- ENABLED, VIBRATE, MESSAGE, ALERT };
+ ENABLED, VIBRATE, MESSAGE, ALERT, INTENT, NO_DIALOG };
/**
* These save calls to cursor.getColumnIndexOrThrow()
@@ -149,6 +165,8 @@ public final class Alarm implements Parcelable {
public static final int ALARM_VIBRATE_INDEX = 6;
public static final int ALARM_MESSAGE_INDEX = 7;
public static final int ALARM_ALERT_INDEX = 8;
+ public static final int ALARM_INTENT_INDEX = 9;
+ public static final int ALARM_NO_DIALOG_INDEX = 10;
}
//////////////////////////////
// End column definitions
@@ -165,6 +183,8 @@ public final class Alarm implements Parcelable {
public String label;
public Uri alert;
public boolean silent;
+ public String intent;
+ public boolean noDialog;
public Alarm(Cursor c) {
id = c.getInt(Columns.ALARM_ID_INDEX);
@@ -193,6 +213,18 @@ public final class Alarm implements Parcelable {
RingtoneManager.TYPE_ALARM);
}
}
+ String intentString = c.getString(Columns.ALARM_INTENT_INDEX);
+ if (!TextUtils.isEmpty(intentString)) {
+ try {
+ // Try and parse the URI, see if it breaks.
+ Intent.parseUri(intentString, Intent.URI_INTENT_SCHEME);
+ // If it's an invalid URI, the exception will short-circuit.
+ intent = intentString;
+ } catch (URISyntaxException e) {
+ intent = null;
+ }
+ }
+ noDialog = c.getInt(Columns.ALARM_NO_DIALOG_INDEX) == 1;
}
public Alarm(Parcel p) {
@@ -206,6 +238,8 @@ public final class Alarm implements Parcelable {
label = p.readString();
alert = (Uri) p.readParcelable(null);
silent = p.readInt() == 1;
+ intent = p.readString();
+ noDialog = p.readInt() == 1;
}
// Creates a default alarm at the current time.