|
|
@ -51,7 +51,6 @@ class AndroidNotificationTray
|
|
|
|
Log.d("AndroidNotificationTray", msg)
|
|
|
|
Log.d("AndroidNotificationTray", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun removeNotification(id: Int) {
|
|
|
|
override fun removeNotification(id: Int) {
|
|
|
|
val manager = NotificationManagerCompat.from(context)
|
|
|
|
val manager = NotificationManagerCompat.from(context)
|
|
|
|
manager.cancel(id)
|
|
|
|
manager.cancel(id)
|
|
|
@ -63,8 +62,6 @@ class AndroidNotificationTray
|
|
|
|
timestamp: Timestamp,
|
|
|
|
timestamp: Timestamp,
|
|
|
|
reminderTime: Long) {
|
|
|
|
reminderTime: Long) {
|
|
|
|
val notificationManager = NotificationManagerCompat.from(context)
|
|
|
|
val notificationManager = NotificationManagerCompat.from(context)
|
|
|
|
//val summary = buildSummary(habit, reminderTime)
|
|
|
|
|
|
|
|
//notificationManager.notify(Int.MAX_VALUE, summary)
|
|
|
|
|
|
|
|
val notification = buildNotification(habit, reminderTime, timestamp)
|
|
|
|
val notification = buildNotification(habit, reminderTime, timestamp)
|
|
|
|
createAndroidNotificationChannel(context)
|
|
|
|
createAndroidNotificationChannel(context)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -109,7 +106,7 @@ class AndroidNotificationTray
|
|
|
|
.addAction(removeRepetitionAction)
|
|
|
|
.addAction(removeRepetitionAction)
|
|
|
|
|
|
|
|
|
|
|
|
val defaultText = context.getString(R.string.default_reminder_question)
|
|
|
|
val defaultText = context.getString(R.string.default_reminder_question)
|
|
|
|
val builder = NotificationCompat.Builder(context, REMINDERS_CHANNEL_ID)
|
|
|
|
val builder = Builder(context, REMINDERS_CHANNEL_ID)
|
|
|
|
.setSmallIcon(R.drawable.ic_notification)
|
|
|
|
.setSmallIcon(R.drawable.ic_notification)
|
|
|
|
.setContentTitle(habit.name)
|
|
|
|
.setContentTitle(habit.name)
|
|
|
|
.setContentText(if(habit.description.isBlank()) defaultText else habit.description)
|
|
|
|
.setContentText(if(habit.description.isBlank()) defaultText else habit.description)
|
|
|
@ -121,7 +118,6 @@ class AndroidNotificationTray
|
|
|
|
.setWhen(reminderTime)
|
|
|
|
.setWhen(reminderTime)
|
|
|
|
.setShowWhen(true)
|
|
|
|
.setShowWhen(true)
|
|
|
|
.setOngoing(preferences.shouldMakeNotificationsSticky())
|
|
|
|
.setOngoing(preferences.shouldMakeNotificationsSticky())
|
|
|
|
.setGroup("group" + habit.getId())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disableSound)
|
|
|
|
if (!disableSound)
|
|
|
|
builder.setSound(ringtoneManager.getURI())
|
|
|
|
builder.setSound(ringtoneManager.getURI())
|
|
|
@ -139,18 +135,6 @@ class AndroidNotificationTray
|
|
|
|
return builder.build()
|
|
|
|
return builder.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun buildSummary(habit: Habit,
|
|
|
|
|
|
|
|
reminderTime: Long): Notification {
|
|
|
|
|
|
|
|
return NotificationCompat.Builder(context, REMINDERS_CHANNEL_ID)
|
|
|
|
|
|
|
|
.setSmallIcon(R.drawable.ic_notification)
|
|
|
|
|
|
|
|
.setContentTitle(context.getString(R.string.app_name))
|
|
|
|
|
|
|
|
.setWhen(reminderTime)
|
|
|
|
|
|
|
|
.setShowWhen(true)
|
|
|
|
|
|
|
|
.setGroup("group" + habit.getId())
|
|
|
|
|
|
|
|
.setGroupSummary(true)
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
companion object {
|
|
|
|
private const val REMINDERS_CHANNEL_ID = "REMINDERS"
|
|
|
|
private const val REMINDERS_CHANNEL_ID = "REMINDERS"
|
|
|
|
fun createAndroidNotificationChannel(context: Context) {
|
|
|
|
fun createAndroidNotificationChannel(context: Context) {
|
|
|
|