Skip to content

Commit

Permalink
Merge pull request #443 from FossifyOrg/fix_task_completion_button
Browse files Browse the repository at this point in the history
Fix "Mark completed" notification button
  • Loading branch information
naveensingh authored Jan 24, 2025
2 parents 9d6936b + 561330e commit f97b3ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ private fun getSnoozePendingIntent(context: Context, event: Event): PendingInten
private fun getMarkCompletedPendingIntent(context: Context, task: Event): PendingIntent {
val intent = Intent(context, MarkCompletedService::class.java).setAction(ACTION_MARK_COMPLETED)
intent.putExtra(EVENT_ID, task.id)
intent.putExtra(EVENT_OCCURRENCE_TS, task.startTS)
return PendingIntent.getService(context, task.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}

Expand Down Expand Up @@ -946,4 +947,4 @@ fun Context.getWeekNumberWidth(): Int {
} else {
0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ import android.app.IntentService
import android.content.Intent
import org.fossify.calendar.extensions.eventsDB
import org.fossify.calendar.extensions.updateTaskCompletion
import org.fossify.calendar.extensions.updateWidgets
import org.fossify.calendar.helpers.ACTION_MARK_COMPLETED
import org.fossify.calendar.helpers.EVENT_ID
import org.fossify.calendar.helpers.EVENT_OCCURRENCE_TS

class MarkCompletedService : IntentService("MarkCompleted") {

@Deprecated("Deprecated in Java")
override fun onHandleIntent(intent: Intent?) {
if (intent != null && intent.action == ACTION_MARK_COMPLETED) {
val taskId = intent.getLongExtra(EVENT_ID, 0L)
val task = eventsDB.getTaskWithId(taskId)
val task = eventsDB.getTaskWithId(taskId)?.apply {
val occurrenceTS = intent.getLongExtra(EVENT_OCCURRENCE_TS, 0L)
if (occurrenceTS != 0L) {
startTS = occurrenceTS
endTS = occurrenceTS
}
}

if (task != null) {
updateTaskCompletion(task, completed = true)
updateWidgets()
}
}
}
Expand Down

0 comments on commit f97b3ca

Please sign in to comment.