mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
Add import IDs to existing tasks on start
This commit is contained in:
@@ -1115,7 +1115,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
val newImportId = if (mEvent.id != null) {
|
val newImportId = if (mEvent.id != null) {
|
||||||
mEvent.importId
|
mEvent.importId
|
||||||
} else {
|
} else {
|
||||||
UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
generateImportId()
|
||||||
}
|
}
|
||||||
|
|
||||||
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) {
|
||||||
|
@@ -159,6 +159,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
ConfirmationDialog(this, "", R.string.upgraded_to_pro_calendar, R.string.ok, 0, false) {}
|
ConfirmationDialog(this, "", R.string.upgraded_to_pro_calendar, R.string.ok, 0, false) {}
|
||||||
config.wasUpgradedFromFreeShown = true
|
config.wasUpgradedFromFreeShown = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addImportIdsToTasks {
|
||||||
|
refreshViewPager()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@@ -354,7 +354,7 @@ class TaskActivity : SimpleActivity() {
|
|||||||
val newImportId = if (mTask.id != null) {
|
val newImportId = if (mTask.id != null) {
|
||||||
mTask.importId
|
mTask.importId
|
||||||
} else {
|
} else {
|
||||||
UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
generateImportId()
|
||||||
}
|
}
|
||||||
|
|
||||||
val reminders = getReminders()
|
val reminders = getReminders()
|
||||||
|
@@ -708,3 +708,24 @@ inline fun Context.queryCursorInlined(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.addImportIdsToTasks(callback: () -> Unit) {
|
||||||
|
ensureBackgroundThread {
|
||||||
|
var count = 0
|
||||||
|
|
||||||
|
eventsDB.getAllTasks()
|
||||||
|
.forEach { task ->
|
||||||
|
if (task.importId.isEmpty()) {
|
||||||
|
eventsDB.updateTaskImportId(
|
||||||
|
importId = generateImportId(),
|
||||||
|
id = task.id!!
|
||||||
|
)
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.helpers
|
|||||||
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
||||||
import com.simplemobiletools.calendar.pro.activities.TaskActivity
|
import com.simplemobiletools.calendar.pro.activities.TaskActivity
|
||||||
import com.simplemobiletools.commons.helpers.MONTH_SECONDS
|
import com.simplemobiletools.commons.helpers.MONTH_SECONDS
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
const val STORED_LOCALLY_ONLY = 0
|
const val STORED_LOCALLY_ONLY = 0
|
||||||
const val ROW_COUNT = 6
|
const val ROW_COUNT = 6
|
||||||
@@ -258,3 +259,7 @@ fun getActivityToOpen(isTask: Boolean) = if (isTask) {
|
|||||||
} else {
|
} else {
|
||||||
EventActivity::class.java
|
EventActivity::class.java
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun generateImportId(): String {
|
||||||
|
return UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
||||||
|
}
|
||||||
|
@@ -12,6 +12,9 @@ interface EventsDao {
|
|||||||
@Query("SELECT * FROM events")
|
@Query("SELECT * FROM events")
|
||||||
fun getAllEvents(): List<Event>
|
fun getAllEvents(): List<Event>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM events WHERE type = $TYPE_TASK")
|
||||||
|
fun getAllTasks(): List<Event>
|
||||||
|
|
||||||
@Query("SELECT * FROM events WHERE event_type IN (:eventTypeIds) AND type = $TYPE_EVENT")
|
@Query("SELECT * FROM events WHERE event_type IN (:eventTypeIds) AND type = $TYPE_EVENT")
|
||||||
fun getAllEventsWithTypes(eventTypeIds: List<Long>): List<Event>
|
fun getAllEventsWithTypes(eventTypeIds: List<Long>): List<Event>
|
||||||
|
|
||||||
@@ -122,6 +125,9 @@ interface EventsDao {
|
|||||||
@Query("UPDATE events SET flags = :newFlags WHERE id = :id")
|
@Query("UPDATE events SET flags = :newFlags WHERE id = :id")
|
||||||
fun updateTaskCompletion(id: Long, newFlags: Int)
|
fun updateTaskCompletion(id: Long, newFlags: Int)
|
||||||
|
|
||||||
|
@Query("UPDATE events SET import_id = :importId WHERE id = :id AND type = $TYPE_TASK")
|
||||||
|
fun updateTaskImportId(importId: String, id: Long)
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
fun insertOrUpdate(event: Event): Long
|
fun insertOrUpdate(event: Event): Long
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user