show the alarm label at notification and reminder screen, if set

This commit is contained in:
tibbi 2018-03-28 17:23:13 +02:00
parent dfaa49cfc3
commit 32c41e9261
2 changed files with 14 additions and 3 deletions

View File

@ -29,7 +29,17 @@ class ReminderActivity : SimpleActivity() {
alarm = dbHelper.getAlarmWithId(id) ?: return
}
reminder_title.text = getString(if (isAlarmReminder) R.string.alarm else R.string.timer)
val label = if (isAlarmReminder) {
if (alarm!!.label.isEmpty()) {
getString(R.string.alarm)
} else {
alarm!!.label
}
} else {
getString(R.string.timer)
}
reminder_title.text = label
reminder_text.text = if (isAlarmReminder) getFormattedTime(getPassedSeconds(), false, false) else getString(R.string.time_expired)
reminder_stop.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getAdjustedPrimaryColor())
reminder_stop.setOnClickListener {

View File

@ -284,9 +284,10 @@ fun Context.getHideAlarmPendingIntent(alarm: Alarm): PendingIntent {
@SuppressLint("NewApi")
fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, addDeleteIntent: Boolean): Notification {
val channelId = "alarm_channel"
val label = if (alarm.label.isNotEmpty()) alarm.label else getString(R.string.alarm)
if (isOreoPlus()) {
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val name = getString(R.string.alarm)
val name = label
val importance = NotificationManager.IMPORTANCE_HIGH
NotificationChannel(channelId, name, importance).apply {
enableLights(true)
@ -298,7 +299,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, add
val reminderActivityIntent = getReminderActivityIntent()
val builder = NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.alarm))
.setContentTitle(label)
.setContentText(getFormattedTime(getPassedSeconds(), false, false))
.setSmallIcon(R.drawable.ic_alarm)
.setContentIntent(pendingIntent)