Enable room kotlin codegen

pull/2884/head
Alex Baker 6 months ago
parent 93670bb9e4
commit c9fc02a42e

@ -64,6 +64,7 @@ android {
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.incremental", "true")
arg("room.generateKotlin", "true")
}
}

@ -64,20 +64,20 @@ open class BaseTaskEditViewModelTest : InjectingTestCase() {
calendarEventProvider,
gCalHelper,
taskMover,
db.locationDao,
db.locationDao(),
geofenceApi,
db.tagDao,
db.tagDataDao,
db.tagDao(),
db.tagDataDao(),
preferences,
db.googleTaskDao,
db.caldavDao,
db.googleTaskDao(),
db.caldavDao(),
taskCompleter,
alarmService,
MutableSharedFlow(),
MutableSharedFlow(),
userActivityDao = userActivityDao,
taskAttachmentDao = db.taskAttachmentDao,
alarmDao = db.alarmDao,
taskAttachmentDao = db.taskAttachmentDao(),
alarmDao = db.alarmDao(),
)
}

@ -4,8 +4,37 @@ import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RoomDatabase
import com.todoroo.astrid.data.Task
import org.tasks.data.*
import org.tasks.data.Alarm
import org.tasks.data.AlarmDao
import org.tasks.data.Attachment
import org.tasks.data.CaldavAccount
import org.tasks.data.CaldavCalendar
import org.tasks.data.CaldavDao
import org.tasks.data.CaldavTask
import org.tasks.data.ContentProviderDao
import org.tasks.data.DeletionDao
import org.tasks.data.Filter
import org.tasks.data.FilterDao
import org.tasks.data.Geofence
import org.tasks.data.GoogleTaskDao
import org.tasks.data.GoogleTaskListDao
import org.tasks.data.LocationDao
import org.tasks.data.Place
import org.tasks.data.Principal
import org.tasks.data.PrincipalAccess
import org.tasks.data.PrincipalDao
import org.tasks.data.Tag
import org.tasks.data.TagDao
import org.tasks.data.TagData
import org.tasks.data.TagDataDao
import org.tasks.data.TaskAttachment
import org.tasks.data.TaskAttachmentDao
import org.tasks.data.TaskDao
import org.tasks.data.TaskListMetadata
import org.tasks.data.TaskListMetadataDao
import org.tasks.data.UpgraderDao
import org.tasks.data.UserActivity
import org.tasks.data.UserActivityDao
import org.tasks.db.Migrations
import org.tasks.notifications.Notification
import org.tasks.notifications.NotificationDao
@ -37,22 +66,22 @@ import org.tasks.notifications.NotificationDao
)
abstract class Database : RoomDatabase() {
abstract fun notificationDao(): NotificationDao
abstract val tagDataDao: TagDataDao
abstract val userActivityDao: UserActivityDao
abstract val taskAttachmentDao: TaskAttachmentDao
abstract val taskListMetadataDao: TaskListMetadataDao
abstract val alarmDao: AlarmDao
abstract val locationDao: LocationDao
abstract val tagDao: TagDao
abstract val googleTaskDao: GoogleTaskDao
abstract val filterDao: FilterDao
abstract val googleTaskListDao: GoogleTaskListDao
abstract val taskDao: TaskDao
abstract val caldavDao: CaldavDao
abstract val deletionDao: DeletionDao
abstract val contentProviderDao: ContentProviderDao
abstract val upgraderDao: UpgraderDao
abstract val principalDao: PrincipalDao
abstract fun tagDataDao(): TagDataDao
abstract fun userActivityDao(): UserActivityDao
abstract fun taskAttachmentDao(): TaskAttachmentDao
abstract fun taskListMetadataDao(): TaskListMetadataDao
abstract fun alarmDao(): AlarmDao
abstract fun locationDao(): LocationDao
abstract fun tagDao(): TagDao
abstract fun googleTaskDao(): GoogleTaskDao
abstract fun filterDao(): FilterDao
abstract fun googleTaskListDao(): GoogleTaskListDao
abstract fun taskDao(): TaskDao
abstract fun caldavDao(): CaldavDao
abstract fun deletionDao(): DeletionDao
abstract fun contentProviderDao(): ContentProviderDao
abstract fun upgraderDao(): UpgraderDao
abstract fun principalDao(): PrincipalDao
/** @return human-readable database name for debugging
*/

@ -167,7 +167,7 @@ class TaskMover @Inject constructor(
task = id1,
calendar = listId,
remoteId = caldavTask.remoteId,
`object` = caldavTask.`object`,
obj = caldavTask.obj,
)
vtodoCache.move(from!!, selected.calendar, caldavTask)
caldavDao.insert(task, newParent, preferences.addTasksToTop())
@ -177,7 +177,7 @@ class TaskMover @Inject constructor(
task = it.task,
calendar = listId,
remoteId = it.remoteId,
`object` = it.`object`,
obj = it.obj,
)
vtodoCache.move(from, selected.calendar, it)
newChild.remoteParent = it.remoteParent

@ -179,14 +179,14 @@ class TasksJsonImporter @Inject constructor(
?.filter { it.deleted == 0L }
?.any {
val existing = if (
it.`object`.isNullOrBlank() ||
it.`object` == "null.ics" // caused by an old bug
it.obj.isNullOrBlank() ||
it.obj == "null.ics" // caused by an old bug
) {
it.remoteId?.let { remoteId ->
caldavDao.getTaskByRemoteId(it.calendar!!, remoteId)
}
} else {
caldavDao.getTask(it.calendar!!, it.`object`!!)
caldavDao.getTask(it.calendar!!, it.obj!!)
}
existing != null
} == true

@ -301,9 +301,9 @@ class CaldavSynchronizer @Inject constructor(
caldavTask: CaldavTask
): Boolean {
try {
if (!isNullOrEmpty(caldavTask.`object`)) {
if (!isNullOrEmpty(caldavTask.obj)) {
val remote = DavResource(
httpClient, httpUrl.newBuilder().addPathSegment(caldavTask.`object`!!).build())
httpClient, httpUrl.newBuilder().addPathSegment(caldavTask.obj!!).build())
remote.delete(null) {}
}
} catch (e: HttpException) {
@ -339,7 +339,7 @@ class CaldavSynchronizer @Inject constructor(
val requestBody = data.toRequestBody(contentType = MIME_ICALENDAR)
try {
val remote = DavResource(
httpClient, httpUrl.newBuilder().addPathSegment(caldavTask.`object`!!).build())
httpClient, httpUrl.newBuilder().addPathSegment(caldavTask.obj!!).build())
remote.put(requestBody) {
if (it.isSuccessful) {
fromResponse(it)?.eTag?.takeIf(String::isNotBlank)?.let { etag ->

@ -15,14 +15,14 @@ class VtodoCache @Inject constructor(
) {
fun move(from: CaldavCalendar, to: CaldavCalendar, task: CaldavTask) {
val source =
fileStorage.getFile(from.account, from.uuid, task.`object`)
fileStorage.getFile(from.account, from.uuid, task.obj)
if (source?.exists() != true) {
return
}
val target =
fileStorage.getFile(to.account, to.uuid)
?.apply { mkdirs() }
?.let { File(it, task.`object`!!) }
?.let { File(it, task.obj!!) }
?: return
source.copyTo(target, overwrite = true)
source.delete()
@ -40,13 +40,13 @@ class VtodoCache @Inject constructor(
val file = fileStorage.getFile(
calendar?.account,
caldavTask?.calendar,
caldavTask?.`object`
caldavTask?.obj
)
return fileStorage.read(file)
}
fun putVtodo(calendar: CaldavCalendar, caldavTask: CaldavTask, vtodo: String?) {
val `object` = caldavTask.`object`?.takeIf { it.isNotBlank() } ?: return
val `object` = caldavTask.obj?.takeIf { it.isNotBlank() } ?: return
val directory =
fileStorage
.getFile(calendar.account, caldavTask.calendar)
@ -65,7 +65,7 @@ class VtodoCache @Inject constructor(
fun delete(calendar: CaldavCalendar, caldavTask: CaldavTask) {
fileStorage
.getFile(calendar.account!!, caldavTask.calendar!!, caldavTask.`object`!!)
.getFile(calendar.account!!, caldavTask.calendar!!, caldavTask.obj!!)
?.delete()
}

@ -215,7 +215,7 @@ class iCalendar @Inject constructor(
task = task.id,
calendar = calendar.uuid,
remoteId = remote.uid,
`object` = obj
obj = obj
)
val isNew = caldavTask.id == com.todoroo.astrid.data.Task.NO_ID
val dirty = task.modificationDate > caldavTask.lastSync || caldavTask.lastSync == 0L

@ -32,7 +32,7 @@ data class CaldavTask(
@ColumnInfo(name = "cd_remote_id")
var remoteId: String? = UUIDHelper.newUUID(),
@ColumnInfo(name = "cd_object")
var `object`: String? = remoteId?.let { "$it.ics" },
var obj: String? = remoteId?.let { "$it.ics" },
@ColumnInfo(name = "cd_etag")
var etag: String? = null,
@ColumnInfo(name = "cd_last_sync")

@ -80,7 +80,7 @@ abstract class TagDataDao {
+ " LEFT JOIN tags ON tags.task = tasks._id"
+ " WHERE tasks._id IN (:tasks)"
+ " GROUP BY tasks._id")
internal abstract suspend fun getAllTags(tasks: List<Long>): List<String>
internal abstract suspend fun getAllTags(tasks: List<Long>): List<String?>
@Transaction
open suspend fun applyTags(

@ -61,11 +61,11 @@ class EtebaseClient(
suspend fun updateItem(collection: Collection, task: CaldavTask, content: ByteArray): Item {
val itemManager = etebase.collectionManager.getItemManager(collection)
val item = cache.itemGet(itemManager, collection.uid, task.`object`!!)
val item = cache.itemGet(itemManager, collection.uid, task.obj!!)
?: itemManager
.create(ItemMetadata().apply { name = task.remoteId!! }, "")
.apply {
task.`object` = uid
task.obj = uid
caldavDao.update(task)
}
item.meta = updateMtime(item.meta, task.lastSync)
@ -75,7 +75,7 @@ class EtebaseClient(
suspend fun deleteItem(collection: Collection, task: CaldavTask): Item? {
val itemManager = etebase.collectionManager.getItemManager(collection)
return cache.itemGet(itemManager, collection.uid, task.`object`!!)
return cache.itemGet(itemManager, collection.uid, task.obj!!)
?.takeIf { !it.isDeleted }
?.apply {
meta = updateMtime(meta)

@ -206,7 +206,7 @@ class EtebaseSynchronizer @Inject constructor(
caldavDao.update(it)
}
} else {
caldavTask?.`object` = item.uid
caldavTask?.obj = item.uid
iCal.fromVtodo(account, caldavCalendar, caldavTask, task, vtodo, item.uid, null)
}
}

@ -16,10 +16,23 @@ import org.tasks.analytics.Firebase
import org.tasks.billing.BillingClient
import org.tasks.billing.BillingClientImpl
import org.tasks.billing.Inventory
import org.tasks.data.*
import org.tasks.data.AlarmDao
import org.tasks.data.CaldavDao
import org.tasks.data.ContentProviderDao
import org.tasks.data.DeletionDao
import org.tasks.data.FilterDao
import org.tasks.data.GoogleTaskDao
import org.tasks.data.GoogleTaskListDao
import org.tasks.data.LocationDao
import org.tasks.data.TagDao
import org.tasks.data.TagDataDao
import org.tasks.data.TaskAttachmentDao
import org.tasks.data.TaskDao
import org.tasks.data.TaskListMetadataDao
import org.tasks.data.UserActivityDao
import org.tasks.jobs.WorkManager
import org.tasks.notifications.NotificationDao
import java.util.*
import java.util.Locale
import javax.inject.Singleton
@Module
@ -41,67 +54,67 @@ class ApplicationModule {
@Provides
@Singleton
fun getTagDataDao(db: Database): TagDataDao = db.tagDataDao
fun getTagDataDao(db: Database): TagDataDao = db.tagDataDao()
@Provides
@Singleton
fun getUserActivityDao(db: Database): UserActivityDao = db.userActivityDao
fun getUserActivityDao(db: Database): UserActivityDao = db.userActivityDao()
@Provides
@Singleton
fun getTaskAttachmentDao(db: Database): TaskAttachmentDao = db.taskAttachmentDao
fun getTaskAttachmentDao(db: Database): TaskAttachmentDao = db.taskAttachmentDao()
@Provides
@Singleton
fun getTaskListMetadataDao(db: Database): TaskListMetadataDao = db.taskListMetadataDao
fun getTaskListMetadataDao(db: Database): TaskListMetadataDao = db.taskListMetadataDao()
@Provides
@Singleton
fun getGoogleTaskDao(db: Database): GoogleTaskDao = db.googleTaskDao
fun getGoogleTaskDao(db: Database): GoogleTaskDao = db.googleTaskDao()
@Provides
@Singleton
fun getAlarmDao(db: Database): AlarmDao = db.alarmDao
fun getAlarmDao(db: Database): AlarmDao = db.alarmDao()
@Provides
@Singleton
fun getGeofenceDao(db: Database): LocationDao = db.locationDao
fun getGeofenceDao(db: Database): LocationDao = db.locationDao()
@Provides
@Singleton
fun getTagDao(db: Database): TagDao = db.tagDao
fun getTagDao(db: Database): TagDao = db.tagDao()
@Provides
@Singleton
fun getFilterDao(db: Database): FilterDao = db.filterDao
fun getFilterDao(db: Database): FilterDao = db.filterDao()
@Provides
@Singleton
fun getGoogleTaskListDao(db: Database): GoogleTaskListDao = db.googleTaskListDao
fun getGoogleTaskListDao(db: Database): GoogleTaskListDao = db.googleTaskListDao()
@Provides
@Singleton
fun getCaldavDao(db: Database): CaldavDao = db.caldavDao
fun getCaldavDao(db: Database): CaldavDao = db.caldavDao()
@Provides
@Singleton
fun getTaskDao(db: Database): TaskDao = db.taskDao
fun getTaskDao(db: Database): TaskDao = db.taskDao()
@Provides
@Singleton
fun getDeletionDao(db: Database): DeletionDao = db.deletionDao
fun getDeletionDao(db: Database): DeletionDao = db.deletionDao()
@Provides
@Singleton
fun getContentProviderDao(db: Database): ContentProviderDao = db.contentProviderDao
fun getContentProviderDao(db: Database): ContentProviderDao = db.contentProviderDao()
@Provides
@Singleton
fun getUpgraderDao(db: Database) = db.upgraderDao
fun getUpgraderDao(db: Database) = db.upgraderDao()
@Provides
@Singleton
fun getPrincipalDao(db: Database) = db.principalDao
fun getPrincipalDao(db: Database) = db.principalDao()
@Provides
fun getBillingClient(

@ -24,7 +24,7 @@ object CaldavTaskMaker {
remoteId = remoteId,
remoteParent = it.valueOf(REMOTE_PARENT, null as String?),
etag = it.valueOf(ETAG, null as String?),
`object` = it.valueOf(OBJECT, remoteId?.let { id -> "$id.ics" }),
obj = it.valueOf(OBJECT, remoteId?.let { id -> "$id.ics" }),
)
}

Loading…
Cancel
Save