Move ACTION constant to Constants.kt

Use "MarkCompleted" instead of "MarkComplete" in names
This commit is contained in:
Naveen 2022-06-29 11:06:38 +05:30
parent 4a78896f05
commit e6d20b93d5
4 changed files with 11 additions and 12 deletions

View File

@ -253,7 +253,7 @@
android:permission="android.permission.BIND_REMOTEVIEWS" />
<service android:name=".services.SnoozeService" />
<service android:name=".services.MarkCompleteService" />
<service android:name=".services.MarkCompletedService" />
<service
android:name=".jobs.CalDAVUpdateListener"

View File

@ -37,8 +37,7 @@ import com.simplemobiletools.calendar.pro.interfaces.WidgetsDao
import com.simplemobiletools.calendar.pro.models.*
import com.simplemobiletools.calendar.pro.receivers.CalDAVSyncReceiver
import com.simplemobiletools.calendar.pro.receivers.NotificationReceiver
import com.simplemobiletools.calendar.pro.services.MarkCompleteService
import com.simplemobiletools.calendar.pro.services.MarkCompleteService.Companion.ACTION_MARK_COMPLETE
import com.simplemobiletools.calendar.pro.services.MarkCompletedService
import com.simplemobiletools.calendar.pro.services.SnoozeService
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
@ -316,7 +315,7 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
.setChannelId(channelId)
.apply {
if (event.isTask() && !event.isTaskCompleted()) {
addAction(R.drawable.ic_task_vector, getString(R.string.mark_completed), getMarkCompletePendingIntent(this@getNotification, event))
addAction(R.drawable.ic_task_vector, getString(R.string.mark_completed), getMarkCompletedPendingIntent(this@getNotification, event))
}
addAction(R.drawable.ic_snooze_vector, getString(R.string.snooze), getSnoozePendingIntent(this@getNotification, event))
}
@ -361,8 +360,8 @@ private fun getSnoozePendingIntent(context: Context, event: Event): PendingInten
}
}
private fun getMarkCompletePendingIntent(context: Context, task: Event): PendingIntent {
val intent = Intent(context, MarkCompleteService::class.java).setAction(ACTION_MARK_COMPLETE)
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)
return PendingIntent.getService(context, task.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}

View File

@ -220,6 +220,9 @@ const val AVAILABILITY = "AVAILABILITY"
const val EVENT_TYPE_ID = "EVENT_TYPE_ID"
const val EVENT_CALENDAR_ID = "EVENT_CALENDAR_ID"
// actions
const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED"
fun getNowSeconds() = System.currentTimeMillis() / 1000L
fun isWeekend(i: Int, isSundayFirst: Boolean): Boolean {

View File

@ -5,14 +5,15 @@ import android.content.Intent
import com.simplemobiletools.calendar.pro.extensions.cancelNotification
import com.simplemobiletools.calendar.pro.extensions.cancelPendingIntent
import com.simplemobiletools.calendar.pro.extensions.eventsDB
import com.simplemobiletools.calendar.pro.helpers.ACTION_MARK_COMPLETED
import com.simplemobiletools.calendar.pro.helpers.EVENT_ID
import com.simplemobiletools.calendar.pro.helpers.FLAG_TASK_COMPLETED
class MarkCompleteService : IntentService("MarkComplete") {
class MarkCompletedService : IntentService("MarkCompleted") {
@Deprecated("Deprecated in Java")
override fun onHandleIntent(intent: Intent?) {
if (intent != null && intent.action == ACTION_MARK_COMPLETE) {
if (intent != null && intent.action == ACTION_MARK_COMPLETED) {
val taskId = intent.getLongExtra(EVENT_ID, 0L)
val task = eventsDB.getTaskWithId(taskId)
if (task != null) {
@ -23,8 +24,4 @@ class MarkCompleteService : IntentService("MarkComplete") {
}
}
}
companion object {
const val ACTION_MARK_COMPLETE = "ACTION_MARK_COMPLETE"
}
}