summaryrefslogtreecommitdiffstats
path: root/src/com/android/deskclock/provider/Alarm.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/deskclock/provider/Alarm.java')
-rw-r--r--src/com/android/deskclock/provider/Alarm.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/com/android/deskclock/provider/Alarm.java b/src/com/android/deskclock/provider/Alarm.java
index fc8aebdb2..33b6e16c0 100644
--- a/src/com/android/deskclock/provider/Alarm.java
+++ b/src/com/android/deskclock/provider/Alarm.java
@@ -27,14 +27,17 @@ import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.ParcelUuid;
import com.android.deskclock.R;
import com.android.deskclock.data.DataModel;
import com.android.deskclock.data.Weekdays;
+import lineageos.app.ProfileManager;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
+import java.util.UUID;
public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
/**
@@ -59,7 +62,9 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
VIBRATE,
LABEL,
RINGTONE,
- DELETE_AFTER_USE
+ DELETE_AFTER_USE,
+ INCREASING_VOLUME,
+ PROFILE
};
private static final String[] QUERY_ALARMS_WITH_INSTANCES_COLUMNS = {
@@ -72,6 +77,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
ClockDatabaseHelper.ALARMS_TABLE_NAME + "." + LABEL,
ClockDatabaseHelper.ALARMS_TABLE_NAME + "." + RINGTONE,
ClockDatabaseHelper.ALARMS_TABLE_NAME + "." + DELETE_AFTER_USE,
+ ClockDatabaseHelper.ALARMS_TABLE_NAME + "." + INCREASING_VOLUME,
+ ClockDatabaseHelper.ALARMS_TABLE_NAME + "." + PROFILE,
ClockDatabaseHelper.INSTANCES_TABLE_NAME + "."
+ ClockContract.InstancesColumns.ALARM_STATE,
ClockDatabaseHelper.INSTANCES_TABLE_NAME + "." + ClockContract.InstancesColumns._ID,
@@ -97,6 +104,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
private static final int LABEL_INDEX = 6;
private static final int RINGTONE_INDEX = 7;
private static final int DELETE_AFTER_USE_INDEX = 8;
+ private static final int INCREASING_VOLUME_INDEX = 10;
+ private static final int PROFILE_INDEX = 11;
private static final int INSTANCE_STATE_INDEX = 9;
public static final int INSTANCE_ID_INDEX = 10;
public static final int INSTANCE_YEAR_INDEX = 11;
@@ -107,7 +116,7 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
public static final int INSTANCE_LABEL_INDEX = 16;
public static final int INSTANCE_VIBRATE_INDEX = 17;
- private static final int COLUMN_COUNT = DELETE_AFTER_USE_INDEX + 1;
+ private static final int COLUMN_COUNT = PROFILE_INDEX + 1;
private static final int ALARM_JOIN_INSTANCE_COLUMN_COUNT = INSTANCE_VIBRATE_INDEX + 1;
public static ContentValues createContentValues(Alarm alarm) {
@@ -123,6 +132,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
values.put(VIBRATE, alarm.vibrate ? 1 : 0);
values.put(LABEL, alarm.label);
values.put(DELETE_AFTER_USE, alarm.deleteAfterUse);
+ values.put(INCREASING_VOLUME, alarm.increasingVolume ? 1 : 0);
+ values.put(PROFILE, alarm.profile.toString());
if (alarm.alert == null) {
// We want to put null, so default alarm changes
values.putNull(RINGTONE);
@@ -284,6 +295,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
public String label;
public Uri alert;
public boolean deleteAfterUse;
+ public boolean increasingVolume;
+ public UUID profile;
public int instanceState;
public int instanceId;
@@ -301,6 +314,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
this.label = "";
this.alert = DataModel.getDataModel().getDefaultAlarmRingtoneUri();
this.deleteAfterUse = false;
+ this.increasingVolume = false;
+ this.profile = ProfileManager.NO_PROFILE;
}
public Alarm(Cursor c) {
@@ -312,6 +327,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
vibrate = c.getInt(VIBRATE_INDEX) == 1;
label = c.getString(LABEL_INDEX);
deleteAfterUse = c.getInt(DELETE_AFTER_USE_INDEX) == 1;
+ increasingVolume = c.getInt(INCREASING_VOLUME_INDEX) == 1;
+ profile = getProfileFromCursor(c);
if (c.getColumnCount() == ALARM_JOIN_INSTANCE_COLUMN_COUNT) {
instanceState = c.getInt(INSTANCE_STATE_INDEX);
@@ -337,6 +354,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
label = p.readString();
alert = p.readParcelable(null);
deleteAfterUse = p.readInt() == 1;
+ increasingVolume = p.readInt() == 1;
+ profile = ParcelUuid.CREATOR.createFromParcel(p).getUuid();
}
/**
@@ -346,6 +365,17 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
return getContentUri(id);
}
+ private static UUID getProfileFromCursor(Cursor c) {
+ if (!c.isNull(PROFILE_INDEX)) {
+ try {
+ return UUID.fromString(c.getString(PROFILE_INDEX));
+ } catch (IllegalArgumentException ex) {
+ // fall back to no profile
+ }
+ }
+ return ProfileManager.NO_PROFILE;
+ }
+
public String getLabelOrDefault(Context context) {
return label.isEmpty() ? context.getString(R.string.default_label) : label;
}
@@ -371,6 +401,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
p.writeString(label);
p.writeParcelable(alert, flags);
p.writeInt(deleteAfterUse ? 1 : 0);
+ p.writeInt(increasingVolume ? 1 : 0);
+ p.writeParcelable(new ParcelUuid(profile), 0);
}
public int describeContents() {
@@ -383,6 +415,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
result.mVibrate = vibrate;
result.mLabel = label;
result.mRingtone = alert;
+ result.mIncreasingVolume = increasingVolume;
+ result.mProfile = profile;
return result;
}
@@ -463,6 +497,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
", vibrate=" + vibrate +
", label='" + label + '\'' +
", deleteAfterUse=" + deleteAfterUse +
+ ", increasingVolume=" + increasingVolume +
+ ", profile=" + profile +
'}';
}
}