mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-05-31 19:29:14 +02:00
show the alarm label at notification and reminder screen, if set
This commit is contained in:
parent
dfaa49cfc3
commit
32c41e9261
@ -29,7 +29,17 @@ class ReminderActivity : SimpleActivity() {
|
|||||||
alarm = dbHelper.getAlarmWithId(id) ?: return
|
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_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.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getAdjustedPrimaryColor())
|
||||||
reminder_stop.setOnClickListener {
|
reminder_stop.setOnClickListener {
|
||||||
|
@ -284,9 +284,10 @@ fun Context.getHideAlarmPendingIntent(alarm: Alarm): PendingIntent {
|
|||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, addDeleteIntent: Boolean): Notification {
|
fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, addDeleteIntent: Boolean): Notification {
|
||||||
val channelId = "alarm_channel"
|
val channelId = "alarm_channel"
|
||||||
|
val label = if (alarm.label.isNotEmpty()) alarm.label else getString(R.string.alarm)
|
||||||
if (isOreoPlus()) {
|
if (isOreoPlus()) {
|
||||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
val name = getString(R.string.alarm)
|
val name = label
|
||||||
val importance = NotificationManager.IMPORTANCE_HIGH
|
val importance = NotificationManager.IMPORTANCE_HIGH
|
||||||
NotificationChannel(channelId, name, importance).apply {
|
NotificationChannel(channelId, name, importance).apply {
|
||||||
enableLights(true)
|
enableLights(true)
|
||||||
@ -298,7 +299,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, add
|
|||||||
|
|
||||||
val reminderActivityIntent = getReminderActivityIntent()
|
val reminderActivityIntent = getReminderActivityIntent()
|
||||||
val builder = NotificationCompat.Builder(this)
|
val builder = NotificationCompat.Builder(this)
|
||||||
.setContentTitle(getString(R.string.alarm))
|
.setContentTitle(label)
|
||||||
.setContentText(getFormattedTime(getPassedSeconds(), false, false))
|
.setContentText(getFormattedTime(getPassedSeconds(), false, false))
|
||||||
.setSmallIcon(R.drawable.ic_alarm)
|
.setSmallIcon(R.drawable.ic_alarm)
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user