Skip to content

Commit

Permalink
AlarmType
Browse files Browse the repository at this point in the history
adds "quick notification" to alarm types (#552)
  • Loading branch information
forrestguice committed May 13, 2022
1 parent 70f0f67 commit 7df4c64
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,20 @@ public AlarmEvent.AlarmEventItem getEventItem(Context context)

public int getIcon()
{
return ((type == AlarmClockItem.AlarmType.NOTIFICATION) ? ICON_NOTIFICATION : ICON_ALARM);
switch (this.type) {
case ALARM: return ICON_ALARM;
case NOTIFICATION: case NOTIFICATION1:
default: return ICON_NOTIFICATION;
}
}

public String getLabel(Context context)
{
return getLabel((type == AlarmClockItem.AlarmType.ALARM) ? context.getString(R.string.alarmMode_alarm) : context.getString(R.string.alarmMode_notification));
switch(type) {
case ALARM: return context.getString(R.string.alarmMode_alarm);
case NOTIFICATION: case NOTIFICATION1:
default: return context.getString(R.string.alarmMode_notification);
}
}

/*public String getLabelAlt(Context context)
Expand Down Expand Up @@ -447,7 +455,8 @@ public void setRepeatingDays(String repeatingDaysString)
public static enum AlarmType
{
ALARM("Alarm"),
NOTIFICATION("Notification");
NOTIFICATION("Notification"),
NOTIFICATION1("Quick Notification");

private String displayString;

Expand Down Expand Up @@ -475,6 +484,7 @@ public static void initDisplayStrings( Context context )
{
ALARM.setDisplayString(context.getString(R.string.alarmMode_alarm));
NOTIFICATION.setDisplayString(context.getString(R.string.alarmMode_notification));
NOTIFICATION1.setDisplayString(context.getString(R.string.alarmMode_notification1));
}

public static AlarmType valueOf(String value, AlarmType defaultType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,8 @@ private AlarmDatabaseAdapter.AlarmItemTaskListener onScheduledNotification(final
@Override
public void onFinished(Boolean result, AlarmClockItem item)
{
if (item.type == AlarmClockItem.AlarmType.NOTIFICATION)
if (item.type == AlarmClockItem.AlarmType.NOTIFICATION
|| item.type == AlarmClockItem.AlarmType.NOTIFICATION1)
{
Log.d(TAG, "State Saved (onScheduledNotification)");
addAlarmTimeout(context, ACTION_SHOW, item.getUri(), item.alarmtime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public static long[] loadPrefVibratePattern(Context context, AlarmClockItem.Alar
switch (type)
{
case NOTIFICATION:
case NOTIFICATION1:
case ALARM:
default: // TODO
return new long[] {0, 400, 200, 400, 800}; // 0 immediate start, 400ms buzz, 200ms break, 400ms buzz, 800ms break [repeat]
Expand Down Expand Up @@ -305,6 +306,7 @@ public static Uri setDefaultRingtone(Context context, AlarmClockItem.AlarmType t
key_name = PREF_KEY_ALARM_RINGTONE_NAME_ALARM;
break;
case NOTIFICATION:
case NOTIFICATION1:
default:
uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION);
key_uri = PREF_KEY_ALARM_RINGTONE_URI_NOTIFICATION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public boolean onMenuItemClick(MenuItem menuItem)
switch (menuItem.getItemId())
{
case R.id.alarmTypeNotification: item.type = AlarmClockItem.AlarmType.NOTIFICATION; break;
case R.id.alarmTypeNotification1: item.type = AlarmClockItem.AlarmType.NOTIFICATION1; break;
case R.id.alarmTypeAlarm: default: item.type = AlarmClockItem.AlarmType.ALARM; break;
}
if (listener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ public boolean onMenuItemClick(MenuItem menuItem)
case R.id.alarmTypeNotification:
return changeAlarmType(item, AlarmClockItem.AlarmType.NOTIFICATION);

case R.id.alarmTypeNotification1:
return changeAlarmType(item, AlarmClockItem.AlarmType.NOTIFICATION1);

case R.id.alarmTypeAlarm:
default:
return changeAlarmType(item, AlarmClockItem.AlarmType.ALARM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,9 @@ public boolean onMenuItemClick(MenuItem menuItem)
case R.id.alarmTypeNotification:
return changeAlarmType(context, position, AlarmClockItem.AlarmType.NOTIFICATION);

case R.id.alarmTypeNotification1:
return changeAlarmType(context, position, AlarmClockItem.AlarmType.NOTIFICATION1);

case R.id.alarmTypeAlarm:
default:
return changeAlarmType(context, position, AlarmClockItem.AlarmType.ALARM);
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/alarmtype.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
android:icon="?attr/icActionNotification"
app:showAsAction="never" />

<item android:id="@+id/alarmTypeNotification1"
android:title="@string/alarmMode_notification1"
android:icon="?attr/icActionNotification"
app:showAsAction="never" />

</group>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@

<string name="alarmMode_alarm">Alarm</string> <!-- alarm type (setting) -->
<string name="alarmMode_notification">Notification</string> <!-- alarm type (setting) -->
<string name="alarmMode_notification1">Quick Notification</string> <!-- alarm type (setting) --> <!-- TODO -->

<string name="configLabel_alarmEdit_scheduleTray">Schedule:</string> <!-- group title -->
<string name="configLabel_alarmEdit_onAlertTray">On Alert:</string> <!-- group title -->
Expand Down

0 comments on commit 7df4c64

Please sign in to comment.