pull/3770/merge
daladim 1 week ago committed by GitHub
commit 4972ff0ade
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,6 +2,7 @@ package org.tasks.notifications
import android.Manifest
import android.annotation.SuppressLint
import android.app.NotificationChannel
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
@ -15,6 +16,7 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import org.tasks.broadcast.RefreshBroadcaster
import org.tasks.R
import org.tasks.data.dao.CaldavDao
import org.tasks.data.dao.LocationDao
import org.tasks.data.dao.NotificationDao
import org.tasks.data.dao.TaskDao
@ -44,6 +46,7 @@ class NotificationManager @Inject constructor(
private val preferences: Preferences,
private val notificationDao: NotificationDao,
private val taskDao: TaskDao,
private val caldavDao: CaldavDao,
private val locationDao: LocationDao,
private val refreshBroadcaster: RefreshBroadcaster,
private val notificationManager: ThrottledNotificationManager,
@ -348,8 +351,24 @@ class NotificationManager @Inject constructor(
val markdown = markdownProvider.markdown(force = true)
val taskTitle = markdown.toMarkdown(task.title)
val taskDescription = markdown.toMarkdown(task.notes)
val calendarName = caldavDao.getCalendarNameForTask(id) ?: "No calendar name"
val builder = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_DEFAULT)
// Create an Android notification channel for this list
// This gives the user a way to enable notifications only for some lists
val channelId = "$NOTIFICATION_CHANNEL_PREFIX$calendarName"
// TODO: de-duplicate with createNotificationChannel from NotificationSchedulerIntentService
val importance = android.app.NotificationManager.IMPORTANCE_HIGH
val notificationChannel = NotificationChannel(channelId, calendarName, importance)
notificationChannel.enableLights(true)
notificationChannel.enableVibration(true)
notificationChannel.setBypassDnd(true)
notificationChannel.setShowBadge(true)
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.NotificationManager
notificationManager.createNotificationChannel(notificationChannel)
val builder = NotificationCompat.Builder(context, calendarName)
.setCategory(NotificationCompat.CATEGORY_REMINDER)
.setContentTitle(taskTitle)
.setColor(colorProvider.getPriorityColor(task.priority))
@ -481,6 +500,7 @@ class NotificationManager @Inject constructor(
companion object {
const val NOTIFICATION_CHANNEL_DEFAULT = "notifications"
const val NOTIFICATION_CHANNEL_PREFIX = "notifications_"
const val NOTIFICATION_CHANNEL_TASKER = "notifications_tasker"
const val NOTIFICATION_CHANNEL_TIMERS = "notifications_timers"
const val NOTIFICATION_CHANNEL_MISCELLANEOUS = "notifications_miscellaneous"

@ -192,6 +192,13 @@ WHERE cd_calendar = :calendar
@Query("SELECT * FROM caldav_tasks WHERE cd_task = :taskId")
abstract suspend fun getTasks(taskId: Long): List<CaldavTask>
@Query("""
SELECT caldav_lists.cdl_name FROM caldav_tasks
JOIN caldav_lists ON caldav_tasks.cd_calendar = caldav_lists.cdl_uuid
WHERE caldav_tasks.cd_id = :taskId
""")
abstract suspend fun getCalendarNameForTask(taskId: Long): String?
@Query("""
SELECT EXISTS(SELECT 1
FROM caldav_tasks

Loading…
Cancel
Save