From f33ecdda7df9be10933ed603366b584751aa1ba8 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Sat, 27 Jun 2020 16:10:48 -0500 Subject: [PATCH] Create blocking room daos --- .../CaldavManualSortTaskAdapterTest.kt | 12 +- .../astrid/adapter/CaldavTaskAdapterTest.kt | 8 +- .../GoogleTaskManualSortAdapterTest.kt | 12 +- .../astrid/adapter/NonRecursiveQueryTest.kt | 12 +- .../astrid/adapter/OfflineSubtaskTest.kt | 12 +- .../astrid/alarms/AlarmJobServiceTest.kt | 8 +- .../com/todoroo/astrid/dao/TaskDaoTests.kt | 2 +- .../astrid/gtasks/GtasksListServiceTest.kt | 4 +- .../gtasks/GtasksMetadataServiceTest.kt | 8 +- .../java/com/todoroo/astrid/model/TaskTest.kt | 4 +- .../astrid/reminders/ReminderServiceTest.kt | 4 +- .../astrid/repeats/RepeatTaskHelperTest.kt | 8 +- .../astrid/service/QuickAddMarkupTest.kt | 4 +- .../todoroo/astrid/service/TaskMoverTest.kt | 12 +- .../todoroo/astrid/service/TitleParserTest.kt | 4 +- .../astrid/subtasks/SubtasksTestCase.kt | 8 +- .../todoroo/astrid/sync/NewSyncTestCase.kt | 8 +- .../org/tasks/data/CaldavDaoShiftTests.kt | 6 +- .../java/org/tasks/data/CaldavDaoTests.kt | 10 +- .../java/org/tasks/data/DeletionDaoTests.kt | 8 +- .../java/org/tasks/data/GoogleTaskDaoTests.kt | 8 +- .../org/tasks/data/GoogleTaskListDaoTest.kt | 2 +- .../java/org/tasks/data/LocationDaoTest.kt | 6 +- .../tasks/data/ManualGoogleTaskQueryTest.kt | 6 +- .../java/org/tasks/data/TagDataDaoTest.kt | 8 +- .../java/org/tasks/jobs/BackupServiceTests.kt | 4 +- .../java/org/tasks/gtasks/PlayServices.kt | 4 +- .../java/org/tasks/location/GeofenceApi.kt | 4 +- .../GeofenceTransitionsIntentService.kt | 4 +- .../todoroo/astrid/activity/MainActivity.kt | 4 +- .../astrid/activity/TaskEditActivity.java | 4 +- .../astrid/activity/TaskEditFragment.java | 8 +- .../astrid/activity/TaskListFragment.kt | 12 +- .../astrid/adapter/AstridTaskAdapter.kt | 12 +- .../adapter/CaldavManualSortTaskAdapter.kt | 12 +- .../todoroo/astrid/adapter/FilterAdapter.kt | 8 +- .../adapter/GoogleTaskManualSortAdapter.kt | 12 +- .../astrid/adapter/NavigationDrawerAdapter.kt | 8 +- .../astrid/adapter/SubheaderViewHolder.kt | 8 +- .../com/todoroo/astrid/adapter/TaskAdapter.kt | 8 +- .../astrid/adapter/TaskAdapterProvider.kt | 16 +- .../com/todoroo/astrid/alarms/AlarmService.kt | 4 +- .../astrid/backup/TasksXmlImporter.java | 42 +-- .../astrid/core/BuiltInFilterExposer.java | 6 +- .../java/com/todoroo/astrid/dao/Database.kt | 32 +- .../java/com/todoroo/astrid/dao/TaskDao.kt | 2 +- .../com/todoroo/astrid/dao/TaskDaoBlocking.kt | 280 ++++++++++++++++++ .../main/java/com/todoroo/astrid/data/Task.kt | 1 + .../todoroo/astrid/files/FilesControlSet.kt | 4 +- .../com/todoroo/astrid/gcal/GCalHelper.java | 6 +- .../astrid/gtasks/GtasksListService.java | 6 +- .../astrid/gtasks/auth/GtasksLoginActivity.kt | 4 +- .../astrid/notes/CommentsController.java | 6 +- .../astrid/provider/Astrid2TaskProvider.kt | 4 +- .../astrid/reminders/ReminderService.java | 8 +- .../astrid/repeats/RepeatTaskHelper.java | 6 +- .../todoroo/astrid/service/TaskCompleter.kt | 8 +- .../todoroo/astrid/service/TaskCreator.java | 36 +-- .../com/todoroo/astrid/service/TaskDeleter.kt | 8 +- .../astrid/service/TaskDuplicator.java | 42 +-- .../com/todoroo/astrid/service/TaskMover.kt | 10 +- .../com/todoroo/astrid/service/Upgrader.kt | 20 +- .../subtasks/SubtasksFilterUpdater.java | 10 +- .../astrid/subtasks/SubtasksHelper.java | 22 +- .../com/todoroo/astrid/tags/TagsControlSet.kt | 8 +- .../todoroo/astrid/timers/TimerPlugin.java | 6 +- .../todoroo/astrid/utility/TitleParser.java | 6 +- app/src/main/java/org/tasks/Notifier.kt | 4 +- .../activities/FilterSettingsActivity.kt | 4 +- .../GoogleTaskListSettingsActivity.java | 4 +- .../NavigationDrawerCustomization.kt | 10 +- .../tasks/activities/PlaceSettingsActivity.kt | 4 +- .../tasks/activities/TagSettingsActivity.java | 8 +- .../java/org/tasks/activities/UriHandler.kt | 4 +- .../org/tasks/backup/TasksJsonExporter.kt | 26 +- .../org/tasks/backup/TasksJsonImporter.kt | 26 +- .../BaseCaldavAccountSettingsActivity.java | 4 +- .../BaseCaldavCalendarSettingsActivity.java | 4 +- .../org/tasks/caldav/CaldavSynchronizer.java | 12 +- .../main/java/org/tasks/caldav/iCalendar.kt | 12 +- .../tasks/dashclock/DashClockExtension.java | 4 +- .../java/org/tasks/data/AlarmDaoBlocking.kt | 31 ++ .../java/org/tasks/data/CaldavDaoBlocking.kt | 275 +++++++++++++++++ .../tasks/data/ContentProviderDaoBlocking.kt | 47 +++ .../org/tasks/data/DeletionDaoBlocking.kt | 114 +++++++ .../java/org/tasks/data/FilterDaoBlocking.kt | 37 +++ .../org/tasks/data/GoogleTaskDaoBlocking.kt | 179 +++++++++++ .../tasks/data/GoogleTaskListDaoBlocking.kt | 72 +++++ .../org/tasks/data/LocationDaoBlocking.kt | 118 ++++++++ app/src/main/java/org/tasks/data/TagDao.kt | 2 +- .../java/org/tasks/data/TagDaoBlocking.kt | 49 +++ .../java/org/tasks/data/TagDataDaoBlocking.kt | 158 ++++++++++ .../tasks/data/TaskAttachmentDaoBlocking.kt | 33 +++ .../tasks/data/TaskListMetadataDaoBlocking.kt | 25 ++ .../org/tasks/data/UserActivityDaoBlocking.kt | 37 +++ .../java/org/tasks/dialogs/DateTimePicker.kt | 4 +- .../org/tasks/etesync/EteSynchronizer.java | 6 +- .../tasks/filters/FilterCriteriaProvider.java | 18 +- .../java/org/tasks/filters/FilterProvider.kt | 10 +- .../java/org/tasks/filters/PlaceFilter.java | 1 - .../tasks/gtasks/GoogleTaskSynchronizer.java | 18 +- .../org/tasks/injection/ApplicationModule.kt | 34 +-- .../org/tasks/injection/ProductionModule.kt | 8 +- .../main/java/org/tasks/jobs/AfterSaveWork.kt | 7 +- .../main/java/org/tasks/jobs/CleanupWork.kt | 16 +- .../java/org/tasks/jobs/ReverseGeocodeWork.kt | 4 +- app/src/main/java/org/tasks/jobs/SyncWork.kt | 8 +- .../java/org/tasks/jobs/WorkManagerImpl.kt | 8 +- .../locale/receiver/TaskerTaskCreator.java | 6 +- .../location/LocationPickerActivity.java | 4 +- .../notifications/NotificationDaoBlocking.kt | 27 ++ .../notifications/NotificationManager.java | 16 +- .../preferences/DefaultFilterProvider.kt | 10 +- .../tasks/preferences/fragments/Advanced.kt | 4 +- .../preferences/fragments/Synchronization.kt | 8 +- .../tasks/provider/TasksContentProvider.kt | 4 +- .../org/tasks/receivers/RefreshReceiver.java | 4 +- .../receivers/RepeatConfirmationReceiver.java | 6 +- .../tasks/reminders/NotificationActivity.java | 4 +- .../org/tasks/reminders/SnoozeActivity.java | 4 +- .../tasks/scheduling/RefreshScheduler.java | 6 +- .../java/org/tasks/sync/SyncAdapters.java | 10 +- .../java/org/tasks/tags/TagPickerViewModel.kt | 4 +- .../tasklist/DragAndDropRecyclerAdapter.kt | 4 +- .../tasklist/PagedListRecyclerAdapter.kt | 4 +- .../tasks/tasklist/TaskListRecyclerAdapter.kt | 4 +- .../main/java/org/tasks/ui/ChipListCache.java | 12 +- .../main/java/org/tasks/ui/ListFragment.kt | 6 +- .../java/org/tasks/ui/LocationControlSet.kt | 4 +- .../org/tasks/ui/NavigationDrawerFragment.kt | 4 +- .../java/org/tasks/ui/SubtaskControlSet.kt | 8 +- .../java/org/tasks/ui/TaskListViewModel.kt | 4 +- .../tasks/widget/ScrollableViewsFactory.java | 6 +- .../widget/ScrollableWidgetUpdateService.java | 4 +- .../java/org/tasks/widget/TasksWidget.java | 4 +- .../org/tasks/widget/WidgetClickActivity.java | 4 +- 136 files changed, 2007 insertions(+), 522 deletions(-) create mode 100644 app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/FilterDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/LocationDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/TagDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt create mode 100644 app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt diff --git a/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapterTest.kt b/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapterTest.kt index 75e0bf1da..f9d0192c4 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapterTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapterTest.kt @@ -3,7 +3,7 @@ package com.todoroo.astrid.adapter import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue import com.todoroo.astrid.api.CaldavFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -14,8 +14,8 @@ import org.junit.Test import org.tasks.LocalBroadcastManager import org.tasks.R import org.tasks.data.CaldavCalendar -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.data.TaskListQuery.getQuery import org.tasks.injection.InjectingTestCase @@ -34,9 +34,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class CaldavManualSortTaskAdapterTest : InjectingTestCase() { - @Inject lateinit var googleTaskDao: GoogleTaskDao - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking @Inject lateinit var preferences: Preferences @Inject lateinit var localBroadcastManager: LocalBroadcastManager diff --git a/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavTaskAdapterTest.kt b/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavTaskAdapterTest.kt index 7f21329fb..8edbcf1be 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavTaskAdapterTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/adapter/CaldavTaskAdapterTest.kt @@ -2,7 +2,7 @@ package com.todoroo.astrid.adapter import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.* @@ -19,9 +19,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class CaldavTaskAdapterTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var googleTaskDao: GoogleTaskDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking @Inject lateinit var localBroadcastManager: LocalBroadcastManager private lateinit var adapter: TaskAdapter diff --git a/app/src/androidTest/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapterTest.kt b/app/src/androidTest/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapterTest.kt index ede6b75f0..18a79373a 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapterTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapterTest.kt @@ -3,7 +3,7 @@ package com.todoroo.astrid.adapter import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue import com.todoroo.astrid.api.GtasksFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -12,8 +12,8 @@ import org.junit.Before import org.junit.Test import org.tasks.LocalBroadcastManager import org.tasks.R -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.data.TaskListQuery.getQuery import org.tasks.injection.InjectingTestCase @@ -32,9 +32,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class GoogleTaskManualSortAdapterTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var googleTaskDao: GoogleTaskDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking @Inject lateinit var preferences: Preferences @Inject lateinit var localBroadcastManager: LocalBroadcastManager diff --git a/app/src/androidTest/java/com/todoroo/astrid/adapter/NonRecursiveQueryTest.kt b/app/src/androidTest/java/com/todoroo/astrid/adapter/NonRecursiveQueryTest.kt index c788b7bd0..8c19d161a 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/adapter/NonRecursiveQueryTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/adapter/NonRecursiveQueryTest.kt @@ -5,7 +5,7 @@ import androidx.test.core.app.ApplicationProvider import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue import com.todoroo.astrid.core.BuiltInFilterExposer -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -14,8 +14,8 @@ import org.junit.Before import org.junit.Test import org.tasks.LocalBroadcastManager import org.tasks.R -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.data.TaskListQuery.getQuery import org.tasks.injection.InjectingTestCase @@ -28,9 +28,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class NonRecursiveQueryTest : InjectingTestCase() { - @Inject lateinit var googleTaskDao: GoogleTaskDao - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var preferences: Preferences @Inject lateinit var localBroadcastManager: LocalBroadcastManager diff --git a/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt b/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt index a01a35eb3..5f6080f16 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt @@ -5,7 +5,7 @@ import androidx.test.core.app.ApplicationProvider import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue import com.todoroo.astrid.core.BuiltInFilterExposer -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -13,8 +13,8 @@ import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import org.tasks.LocalBroadcastManager -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.data.TaskListQuery.getQuery import org.tasks.injection.InjectingTestCase @@ -27,9 +27,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class OfflineSubtaskTest : InjectingTestCase() { - @Inject lateinit var googleTaskDao: GoogleTaskDao - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var preferences: Preferences @Inject lateinit var localBroadcastManager: LocalBroadcastManager diff --git a/app/src/androidTest/java/com/todoroo/astrid/alarms/AlarmJobServiceTest.kt b/app/src/androidTest/java/com/todoroo/astrid/alarms/AlarmJobServiceTest.kt index 615a071b8..764f6ae15 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/alarms/AlarmJobServiceTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/alarms/AlarmJobServiceTest.kt @@ -1,14 +1,14 @@ package com.todoroo.astrid.alarms import com.natpryce.makeiteasy.MakeItEasy.with -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test import org.tasks.data.Alarm -import org.tasks.data.AlarmDao +import org.tasks.data.AlarmDaoBlocking import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import org.tasks.jobs.AlarmEntry @@ -21,8 +21,8 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class AlarmJobServiceTest : InjectingTestCase() { - @Inject lateinit var alarmDao: AlarmDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var alarmDao: AlarmDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var jobs: NotificationQueue @Inject lateinit var alarmService: AlarmService diff --git a/app/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.kt b/app/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.kt index 5e9fb1df8..bd5795b91 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/dao/TaskDaoTests.kt @@ -24,7 +24,7 @@ import javax.inject.Inject @HiltAndroidTest class TaskDaoTests : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var taskDeleter: TaskDeleter /** Test basic task creation, fetch, and save */ diff --git a/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.kt b/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.kt index 48f2a2ca5..d7018b7a3 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.Before import org.junit.Test import org.tasks.LocalBroadcastManager import org.tasks.data.GoogleTaskAccount -import org.tasks.data.GoogleTaskListDao +import org.tasks.data.GoogleTaskListDaoBlocking import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import org.tasks.makers.GtaskListMaker.ID @@ -27,7 +27,7 @@ import javax.inject.Inject class GtasksListServiceTest : InjectingTestCase() { @Inject lateinit var taskDeleter: TaskDeleter @Inject lateinit var localBroadcastManager: LocalBroadcastManager - @Inject lateinit var googleTaskListDao: GoogleTaskListDao + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking private lateinit var gtasksListService: GtasksListService diff --git a/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.kt b/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.kt index d9854b23a..462e9c167 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/gtasks/GtasksMetadataServiceTest.kt @@ -5,7 +5,7 @@ */ package com.todoroo.astrid.gtasks -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -13,7 +13,7 @@ import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull import org.junit.Test import org.tasks.data.GoogleTask -import org.tasks.data.GoogleTaskDao +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import javax.inject.Inject @@ -21,8 +21,8 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class GtasksMetadataServiceTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var googleTaskDao: GoogleTaskDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking private var task: Task? = null private var metadata: GoogleTask? = null diff --git a/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt b/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt index 1a45951b8..1036b0e23 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/model/TaskTest.kt @@ -1,6 +1,6 @@ package com.todoroo.astrid.model -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -15,7 +15,7 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class TaskTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Test fun testSavedTaskHasCreationDate() { diff --git a/app/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.kt b/app/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.kt index 2a723382f..ee8c68f42 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/reminders/ReminderServiceTest.kt @@ -2,7 +2,7 @@ package com.todoroo.astrid.reminders import com.natpryce.makeiteasy.MakeItEasy.with import com.todoroo.andlib.utility.DateUtilities -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -38,7 +38,7 @@ import javax.inject.Inject @HiltAndroidTest class ReminderServiceTest : InjectingTestCase() { @Inject lateinit var preferences: Preferences - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var jobs: NotificationQueue private lateinit var service: ReminderService diff --git a/app/src/androidTest/java/com/todoroo/astrid/repeats/RepeatTaskHelperTest.kt b/app/src/androidTest/java/com/todoroo/astrid/repeats/RepeatTaskHelperTest.kt index c3c4ec066..bc447bf0e 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/repeats/RepeatTaskHelperTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/repeats/RepeatTaskHelperTest.kt @@ -4,7 +4,7 @@ import android.annotation.SuppressLint import com.google.ical.values.RRule import com.natpryce.makeiteasy.MakeItEasy.with import com.todoroo.astrid.alarms.AlarmService -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import com.todoroo.astrid.gcal.GCalHelper import dagger.hilt.android.testing.HiltAndroidTest @@ -32,7 +32,7 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class RepeatTaskHelperTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking private lateinit var localBroadcastManager: LocalBroadcastManager private lateinit var alarmService: AlarmService private lateinit var gCalHelper: GCalHelper @@ -40,7 +40,9 @@ class RepeatTaskHelperTest : InjectingTestCase() { private lateinit var mocks: InOrder @Before - fun before() { + override fun setUp() { + super.setUp() + alarmService = Mockito.mock(AlarmService::class.java) gCalHelper = Mockito.mock(GCalHelper::class.java) localBroadcastManager = Mockito.mock(LocalBroadcastManager::class.java) diff --git a/app/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.kt b/app/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.kt index 7760be8e3..a968bb78f 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/service/QuickAddMarkupTest.kt @@ -11,7 +11,7 @@ import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.assertEquals import org.junit.Test -import org.tasks.data.TagDataDao +import org.tasks.data.TagDataDaoBlocking import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import java.util.* @@ -21,7 +21,7 @@ import javax.inject.Inject @HiltAndroidTest class QuickAddMarkupTest : InjectingTestCase() { private val tags = ArrayList() - @Inject lateinit var tagDataDao: TagDataDao + @Inject lateinit var tagDataDao: TagDataDaoBlocking private var task: Task? = null diff --git a/app/src/androidTest/java/com/todoroo/astrid/service/TaskMoverTest.kt b/app/src/androidTest/java/com/todoroo/astrid/service/TaskMoverTest.kt index 370e2f607..cb0726ece 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/service/TaskMoverTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/service/TaskMoverTest.kt @@ -3,15 +3,15 @@ package com.todoroo.astrid.service import com.natpryce.makeiteasy.MakeItEasy.with import com.todoroo.astrid.api.CaldavFilter import com.todoroo.astrid.api.GtasksFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.* import org.junit.Before import org.junit.Test import org.tasks.data.CaldavCalendar -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import org.tasks.jobs.WorkManager @@ -34,10 +34,10 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class TaskMoverTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var googleTaskDao: GoogleTaskDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking @Inject lateinit var workManager: WorkManager - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var caldavDao: CaldavDaoBlocking @Inject lateinit var taskMover: TaskMover @Before diff --git a/app/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.kt b/app/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.kt index 57afc769b..c411191d9 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/service/TitleParserTest.kt @@ -15,7 +15,7 @@ import org.junit.Assert.* import org.junit.Before import org.junit.Test import org.tasks.R -import org.tasks.data.TagDataDao +import org.tasks.data.TagDataDaoBlocking import org.tasks.date.DateTimeUtils import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule @@ -26,7 +26,7 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class TitleParserTest : InjectingTestCase() { - @Inject lateinit var tagDataDao: TagDataDao + @Inject lateinit var tagDataDao: TagDataDaoBlocking @Inject lateinit var preferences: Preferences @Inject lateinit var taskCreator: TaskCreator diff --git a/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt b/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt index 231b07473..eaf70acd7 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt @@ -3,11 +3,11 @@ package com.todoroo.astrid.subtasks import androidx.test.InstrumentationRegistry import com.todoroo.astrid.api.Filter import com.todoroo.astrid.core.BuiltInFilterExposer -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull -import org.tasks.data.TaskListMetadataDao +import org.tasks.data.TaskListMetadataDaoBlocking import org.tasks.injection.InjectingTestCase import org.tasks.preferences.Preferences import javax.inject.Inject @@ -15,8 +15,8 @@ import javax.inject.Inject abstract class SubtasksTestCase : InjectingTestCase() { lateinit var updater: SubtasksFilterUpdater lateinit var filter: Filter - @Inject lateinit var taskListMetadataDao: TaskListMetadataDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskListMetadataDao: TaskListMetadataDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var preferences: Preferences override fun setUp() { diff --git a/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt b/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt index 7060da77b..5ad1d53d4 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/sync/NewSyncTestCase.kt @@ -1,15 +1,15 @@ package com.todoroo.astrid.sync -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import org.tasks.data.TagData -import org.tasks.data.TagDataDao +import org.tasks.data.TagDataDaoBlocking import org.tasks.injection.InjectingTestCase import javax.inject.Inject open class NewSyncTestCase : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var tagDataDao: TagDataDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var tagDataDao: TagDataDaoBlocking fun createTask(): Task { val task = Task() diff --git a/app/src/androidTest/java/org/tasks/data/CaldavDaoShiftTests.kt b/app/src/androidTest/java/org/tasks/data/CaldavDaoShiftTests.kt index 71451522a..db5ac3d45 100644 --- a/app/src/androidTest/java/org/tasks/data/CaldavDaoShiftTests.kt +++ b/app/src/androidTest/java/org/tasks/data/CaldavDaoShiftTests.kt @@ -3,7 +3,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue import com.todoroo.andlib.utility.DateUtilities.now -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.assertEquals @@ -20,8 +20,8 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class CaldavDaoShiftTests : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking private val tasks = ArrayList() diff --git a/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt b/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt index 3d039791c..41e012115 100644 --- a/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt +++ b/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt @@ -1,7 +1,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.helper.UUIDHelper import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -22,10 +22,10 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class CaldavDaoTests : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var tagDao: TagDao - @Inject lateinit var tagDataDao: TagDataDao - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var tagDao: TagDaoBlocking + @Inject lateinit var tagDataDao: TagDataDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking @Test fun insertNewTaskAtTopOfEmptyList() { diff --git a/app/src/androidTest/java/org/tasks/data/DeletionDaoTests.kt b/app/src/androidTest/java/org/tasks/data/DeletionDaoTests.kt index 75ad10e00..1fec375b7 100644 --- a/app/src/androidTest/java/org/tasks/data/DeletionDaoTests.kt +++ b/app/src/androidTest/java/org/tasks/data/DeletionDaoTests.kt @@ -1,7 +1,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.helper.UUIDHelper import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -21,9 +21,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class DeletionDaoTests : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var deletionDao: DeletionDao - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var deletionDao: DeletionDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking @Test fun deleting1000DoesntCrash() { diff --git a/app/src/androidTest/java/org/tasks/data/GoogleTaskDaoTests.kt b/app/src/androidTest/java/org/tasks/data/GoogleTaskDaoTests.kt index 78b5d5482..3b27eb9b4 100644 --- a/app/src/androidTest/java/org/tasks/data/GoogleTaskDaoTests.kt +++ b/app/src/androidTest/java/org/tasks/data/GoogleTaskDaoTests.kt @@ -1,7 +1,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.assertEquals @@ -22,9 +22,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class GoogleTaskDaoTests : InjectingTestCase() { - @Inject lateinit var googleTaskListDao: GoogleTaskListDao - @Inject lateinit var googleTaskDao: GoogleTaskDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Before override fun setUp() { diff --git a/app/src/androidTest/java/org/tasks/data/GoogleTaskListDaoTest.kt b/app/src/androidTest/java/org/tasks/data/GoogleTaskListDaoTest.kt index dd6373ee5..2d068efe3 100644 --- a/app/src/androidTest/java/org/tasks/data/GoogleTaskListDaoTest.kt +++ b/app/src/androidTest/java/org/tasks/data/GoogleTaskListDaoTest.kt @@ -15,7 +15,7 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class GoogleTaskListDaoTest : InjectingTestCase() { - @Inject lateinit var googleTaskListDao: GoogleTaskListDao + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking @Test fun noResultsForEmptyAccount() { diff --git a/app/src/androidTest/java/org/tasks/data/LocationDaoTest.kt b/app/src/androidTest/java/org/tasks/data/LocationDaoTest.kt index 25188a9bb..bef63bbdc 100644 --- a/app/src/androidTest/java/org/tasks/data/LocationDaoTest.kt +++ b/app/src/androidTest/java/org/tasks/data/LocationDaoTest.kt @@ -2,7 +2,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with import com.todoroo.andlib.utility.DateUtilities.now -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -33,8 +33,8 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class LocationDaoTest : InjectingTestCase() { - @Inject lateinit var locationDao: LocationDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var locationDao: LocationDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Test fun getExistingPlace() { diff --git a/app/src/androidTest/java/org/tasks/data/ManualGoogleTaskQueryTest.kt b/app/src/androidTest/java/org/tasks/data/ManualGoogleTaskQueryTest.kt index 970a05ab5..c081408fc 100644 --- a/app/src/androidTest/java/org/tasks/data/ManualGoogleTaskQueryTest.kt +++ b/app/src/androidTest/java/org/tasks/data/ManualGoogleTaskQueryTest.kt @@ -2,7 +2,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with import com.todoroo.astrid.api.GtasksFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.helper.UUIDHelper import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -29,8 +29,8 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class ManualGoogleTaskQueryTest : InjectingTestCase() { - @Inject lateinit var googleTaskDao: GoogleTaskDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var preferences: Preferences private val filter: GtasksFilter = GtasksFilter(newGoogleTaskList(with(REMOTE_ID, "1234"))) diff --git a/app/src/androidTest/java/org/tasks/data/TagDataDaoTest.kt b/app/src/androidTest/java/org/tasks/data/TagDataDaoTest.kt index be0e6011a..979089c80 100644 --- a/app/src/androidTest/java/org/tasks/data/TagDataDaoTest.kt +++ b/app/src/androidTest/java/org/tasks/data/TagDataDaoTest.kt @@ -1,7 +1,7 @@ package org.tasks.data import com.natpryce.makeiteasy.MakeItEasy.with -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules import org.junit.Assert.assertEquals @@ -22,9 +22,9 @@ import javax.inject.Inject @UninstallModules(ProductionModule::class) @HiltAndroidTest class TagDataDaoTest : InjectingTestCase() { - @Inject lateinit var taskDao: TaskDao - @Inject lateinit var tagDao: TagDao - @Inject lateinit var tagDataDao: TagDataDao + @Inject lateinit var taskDao: TaskDaoBlocking + @Inject lateinit var tagDao: TagDaoBlocking + @Inject lateinit var tagDataDao: TagDataDaoBlocking @Test fun tagDataOrderedByNameIgnoresNullNames() { diff --git a/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.kt b/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.kt index 92e99b2e7..2ece920b6 100644 --- a/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.kt +++ b/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.kt @@ -7,7 +7,7 @@ package org.tasks.jobs import android.net.Uri import androidx.test.InstrumentationRegistry -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -30,7 +30,7 @@ import javax.inject.Inject @HiltAndroidTest class BackupServiceTests : InjectingTestCase() { @Inject lateinit var jsonExporter: TasksJsonExporter - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var preferences: Preferences private lateinit var temporaryDirectory: File diff --git a/app/src/googleplay/java/org/tasks/gtasks/PlayServices.kt b/app/src/googleplay/java/org/tasks/gtasks/PlayServices.kt index 029e42937..07eb38bb7 100644 --- a/app/src/googleplay/java/org/tasks/gtasks/PlayServices.kt +++ b/app/src/googleplay/java/org/tasks/gtasks/PlayServices.kt @@ -7,7 +7,7 @@ import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import dagger.hilt.android.qualifiers.ApplicationContext import org.tasks.R -import org.tasks.data.LocationDao +import org.tasks.data.LocationDaoBlocking import org.tasks.preferences.Preferences import timber.log.Timber import javax.inject.Inject @@ -15,7 +15,7 @@ import javax.inject.Inject class PlayServices @Inject constructor( @param:ApplicationContext private val context: Context, private val preferences: Preferences, - private val locationDao: LocationDao) { + private val locationDao: LocationDaoBlocking) { suspend fun check(activity: Activity?) { val playServicesAvailable = locationDao.geofenceCount() == 0 || refreshAndCheck() diff --git a/app/src/googleplay/java/org/tasks/location/GeofenceApi.kt b/app/src/googleplay/java/org/tasks/location/GeofenceApi.kt index d22e13299..954da9656 100644 --- a/app/src/googleplay/java/org/tasks/location/GeofenceApi.kt +++ b/app/src/googleplay/java/org/tasks/location/GeofenceApi.kt @@ -8,7 +8,7 @@ import com.google.android.gms.location.Geofence import com.google.android.gms.location.GeofencingRequest import com.google.android.gms.location.LocationServices import dagger.hilt.android.qualifiers.ApplicationContext -import org.tasks.data.LocationDao +import org.tasks.data.LocationDaoBlocking import org.tasks.data.MergedGeofence import org.tasks.data.Place import org.tasks.preferences.PermissionChecker @@ -18,7 +18,7 @@ import javax.inject.Inject class GeofenceApi @Inject constructor( @param:ApplicationContext private val context: Context, private val permissionChecker: PermissionChecker, - private val locationDao: LocationDao) { + private val locationDao: LocationDaoBlocking) { fun registerAll() = locationDao.getPlacesWithGeofences().forEach(this::update) diff --git a/app/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.kt b/app/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.kt index 516389e91..11fe0a594 100644 --- a/app/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.kt +++ b/app/src/googleplay/java/org/tasks/location/GeofenceTransitionsIntentService.kt @@ -9,7 +9,7 @@ import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.reminders.ReminderService import dagger.hilt.android.AndroidEntryPoint import org.tasks.Notifier -import org.tasks.data.LocationDao +import org.tasks.data.LocationDaoBlocking import org.tasks.data.Place import org.tasks.injection.InjectingJobIntentService import org.tasks.notifications.Notification @@ -19,7 +19,7 @@ import javax.inject.Inject @AndroidEntryPoint class GeofenceTransitionsIntentService : InjectingJobIntentService() { - @Inject lateinit var locationDao: LocationDao + @Inject lateinit var locationDao: LocationDaoBlocking @Inject lateinit var notifier: Notifier override fun doWork(intent: Intent) { diff --git a/app/src/main/java/com/todoroo/astrid/activity/MainActivity.kt b/app/src/main/java/com/todoroo/astrid/activity/MainActivity.kt index 91fd93f9b..470ab4504 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/MainActivity.kt +++ b/app/src/main/java/com/todoroo/astrid/activity/MainActivity.kt @@ -22,7 +22,7 @@ import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.astrid.activity.TaskEditFragment.TaskEditFragmentCallbackHandler import com.todoroo.astrid.activity.TaskListFragment.TaskListFragmentCallbackHandler import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import com.todoroo.astrid.service.TaskCreator import com.todoroo.astrid.timers.TimerControlSet.TimerControlSetCallback @@ -65,7 +65,7 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl @Inject lateinit var repeatConfirmationReceiver: RepeatConfirmationReceiver @Inject lateinit var defaultFilterProvider: DefaultFilterProvider @Inject lateinit var theme: Theme - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var localBroadcastManager: LocalBroadcastManager @Inject lateinit var taskCreator: TaskCreator @Inject lateinit var playServices: PlayServices diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.java b/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.java index 369d6a351..2af461fe0 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskEditActivity.java @@ -1,6 +1,6 @@ package com.todoroo.astrid.activity; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.service.TaskCreator; import dagger.hilt.android.AndroidEntryPoint; import io.reactivex.Single; @@ -17,7 +17,7 @@ public class TaskEditActivity extends InjectingAppCompatActivity { private static final String TOKEN_ID = "id"; @Inject TaskCreator taskCreator; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; private CompositeDisposable disposables; @Override diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index a53bb8669..c1729a5c7 100755 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -41,7 +41,7 @@ import com.google.android.material.appbar.AppBarLayout; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.notes.CommentsController; import com.todoroo.astrid.repeats.RepeatControlSet; @@ -56,7 +56,7 @@ import javax.inject.Inject; import org.tasks.R; import org.tasks.analytics.Firebase; import org.tasks.data.UserActivity; -import org.tasks.data.UserActivityDao; +import org.tasks.data.UserActivityDaoBlocking; import org.tasks.databinding.FragmentTaskEditBinding; import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.Linkify; @@ -76,8 +76,8 @@ public final class TaskEditFragment extends Fragment private static final String EXTRA_THEME = "extra_theme"; private static final String EXTRA_COMPLETED = "extra_completed"; - @Inject TaskDao taskDao; - @Inject UserActivityDao userActivityDao; + @Inject TaskDaoBlocking taskDao; + @Inject UserActivityDaoBlocking userActivityDao; @Inject TaskDeleter taskDeleter; @Inject NotificationManager notificationManager; @Inject DialogBuilder dialogBuilder; diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.kt b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.kt index 4f94cb8c0..487ad5859 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.kt +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.kt @@ -37,7 +37,7 @@ import com.todoroo.astrid.adapter.TaskAdapter import com.todoroo.astrid.adapter.TaskAdapterProvider import com.todoroo.astrid.api.* import com.todoroo.astrid.core.BuiltInFilterExposer -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import com.todoroo.astrid.service.TaskCreator import com.todoroo.astrid.service.TaskDeleter @@ -57,8 +57,8 @@ import org.tasks.R import org.tasks.ShortcutManager import org.tasks.activities.* import org.tasks.caldav.BaseCaldavCalendarSettingsActivity -import org.tasks.data.CaldavDao -import org.tasks.data.TagDataDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.TagDataDaoBlocking import org.tasks.data.TaskContainer import org.tasks.db.DbUtils.chunkedMap import org.tasks.dialogs.DateTimePicker.Companion.newDateTimePicker @@ -101,10 +101,10 @@ class TaskListFragment : Fragment(), OnRefreshListener, Toolbar.OnMenuItemClickL @Inject lateinit var taskMover: TaskMover @Inject lateinit var toaster: Toaster @Inject lateinit var taskAdapterProvider: TaskAdapterProvider - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var taskDuplicator: TaskDuplicator - @Inject lateinit var tagDataDao: TagDataDao - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var tagDataDao: TagDataDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking @Inject lateinit var defaultThemeColor: ThemeColor @Inject lateinit var colorProvider: ColorProvider @Inject lateinit var notificationManager: NotificationManager diff --git a/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.kt index 122b0d2ea..45b6038df 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.kt @@ -2,13 +2,13 @@ package com.todoroo.astrid.adapter import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import com.todoroo.astrid.subtasks.SubtasksFilterUpdater import org.tasks.LocalBroadcastManager import org.tasks.Strings.isNullOrEmpty -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.data.TaskListMetadata import timber.log.Timber @@ -19,9 +19,9 @@ class AstridTaskAdapter internal constructor( private val list: TaskListMetadata, private val filter: Filter, private val updater: SubtasksFilterUpdater, - googleTaskDao: GoogleTaskDao, - caldavDao: CaldavDao, - private val taskDao: TaskDao, + googleTaskDao: GoogleTaskDaoBlocking, + caldavDao: CaldavDaoBlocking, + private val taskDao: TaskDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) : TaskAdapter(false, googleTaskDao, caldavDao, taskDao, localBroadcastManager) { diff --git a/app/src/main/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapter.kt index 82fda4af1..22beea650 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/CaldavManualSortTaskAdapter.kt @@ -1,15 +1,15 @@ package com.todoroo.astrid.adapter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import org.tasks.LocalBroadcastManager -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskContainer class CaldavManualSortTaskAdapter internal constructor( - googleTaskDao: GoogleTaskDao, - private val caldavDao: CaldavDao, - private val taskDao: TaskDao, + googleTaskDao: GoogleTaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, + private val taskDao: TaskDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) : TaskAdapter(false, googleTaskDao, caldavDao, taskDao, localBroadcastManager) { diff --git a/app/src/main/java/com/todoroo/astrid/adapter/FilterAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/FilterAdapter.kt index 4f336ed52..3b44231d4 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/FilterAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/FilterAdapter.kt @@ -18,8 +18,8 @@ import com.todoroo.astrid.api.FilterListItem import com.todoroo.astrid.api.FilterListItem.Type.* import org.tasks.LocalBroadcastManager import org.tasks.billing.Inventory -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.filters.NavigationDrawerSubheader import org.tasks.locale.Locale import org.tasks.preferences.Preferences @@ -33,8 +33,8 @@ class FilterAdapter @Inject constructor( private val inventory: Inventory, private val colorProvider: ColorProvider, private val preferences: Preferences, - private val googleTaskDao: GoogleTaskDao, - private val caldavDao: CaldavDao, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) : BaseAdapter() { private var selected: Filter? = null private var items: List = ArrayList() diff --git a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt index 79f375228..19e4c031f 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskManualSortAdapter.kt @@ -1,15 +1,15 @@ package com.todoroo.astrid.adapter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import org.tasks.BuildConfig import org.tasks.LocalBroadcastManager -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking class GoogleTaskManualSortAdapter internal constructor( - private val googleTaskDao: GoogleTaskDao, - caldavDao: CaldavDao, - private val taskDao: TaskDao, + private val googleTaskDao: GoogleTaskDaoBlocking, + caldavDao: CaldavDaoBlocking, + private val taskDao: TaskDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) : TaskAdapter(false, googleTaskDao, caldavDao, taskDao, localBroadcastManager) { diff --git a/app/src/main/java/com/todoroo/astrid/adapter/NavigationDrawerAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/NavigationDrawerAdapter.kt index 81c6fc4ad..e47f7e488 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/NavigationDrawerAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/NavigationDrawerAdapter.kt @@ -18,8 +18,8 @@ import io.reactivex.subjects.PublishSubject import org.tasks.LocalBroadcastManager import org.tasks.activities.DragAndDropDiffer import org.tasks.billing.Inventory -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.filters.NavigationDrawerSubheader import org.tasks.locale.Locale import org.tasks.preferences.Preferences @@ -34,8 +34,8 @@ class NavigationDrawerAdapter @Inject constructor( private val inventory: Inventory, private val colorProvider: ColorProvider, private val preferences: Preferences, - private val googleTaskDao: GoogleTaskDao, - private val caldavDao: CaldavDao, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) : RecyclerView.Adapter(), DragAndDropDiffer> { diff --git a/app/src/main/java/com/todoroo/astrid/adapter/SubheaderViewHolder.kt b/app/src/main/java/com/todoroo/astrid/adapter/SubheaderViewHolder.kt index 48e630e47..3a36107aa 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/SubheaderViewHolder.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/SubheaderViewHolder.kt @@ -11,8 +11,8 @@ import butterknife.ButterKnife import butterknife.OnClick import org.tasks.LocalBroadcastManager import org.tasks.R -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.filters.NavigationDrawerSubheader import org.tasks.filters.NavigationDrawerSubheader.SubheaderType import org.tasks.preferences.Preferences @@ -23,8 +23,8 @@ internal class SubheaderViewHolder( itemView: View, activity: Activity, private val preferences: Preferences, - private val googleTaskDao: GoogleTaskDao, - private val caldavDao: CaldavDao, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.kt b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.kt index 764afc5bc..bb9f39585 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.kt @@ -7,7 +7,7 @@ package com.todoroo.astrid.adapter import com.todoroo.astrid.core.SortHelper.SORT_DUE import com.todoroo.astrid.core.SortHelper.SORT_IMPORTANCE -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import org.tasks.BuildConfig import org.tasks.LocalBroadcastManager @@ -19,9 +19,9 @@ import kotlin.collections.HashSet open class TaskAdapter( private val newTasksOnTop: Boolean, - private val googleTaskDao: GoogleTaskDao, - private val caldavDao: CaldavDao, - private val taskDao: TaskDao, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, + private val taskDao: TaskDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) { private val selected = HashSet() diff --git a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.kt b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.kt index 9adc78607..d84acfd79 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.kt +++ b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.kt @@ -6,27 +6,27 @@ import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.GtasksFilter import com.todoroo.astrid.api.TagFilter import com.todoroo.astrid.core.BuiltInFilterExposer -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task.Companion.isUuidEmpty import com.todoroo.astrid.subtasks.SubtasksFilterUpdater import com.todoroo.astrid.subtasks.SubtasksHelper import dagger.hilt.android.qualifiers.ApplicationContext import org.tasks.LocalBroadcastManager import org.tasks.Strings.isNullOrEmpty -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskDaoBlocking import org.tasks.data.TaskListMetadata -import org.tasks.data.TaskListMetadataDao +import org.tasks.data.TaskListMetadataDaoBlocking import org.tasks.preferences.Preferences import javax.inject.Inject class TaskAdapterProvider @Inject constructor( @param:ApplicationContext private val context: Context, private val preferences: Preferences, - private val taskListMetadataDao: TaskListMetadataDao, - private val taskDao: TaskDao, - private val googleTaskDao: GoogleTaskDao, - private val caldavDao: CaldavDao, + private val taskListMetadataDao: TaskListMetadataDaoBlocking, + private val taskDao: TaskDaoBlocking, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val localBroadcastManager: LocalBroadcastManager) { fun createTaskAdapter(filter: Filter): TaskAdapter { if (filter.supportsAstridSorting() && preferences.isAstridSort) { diff --git a/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt b/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt index 809d2e2c0..d8994e212 100644 --- a/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt +++ b/app/src/main/java/com/todoroo/astrid/alarms/AlarmService.kt @@ -6,7 +6,7 @@ package com.todoroo.astrid.alarms import org.tasks.data.Alarm -import org.tasks.data.AlarmDao +import org.tasks.data.AlarmDaoBlocking import org.tasks.jobs.AlarmEntry import org.tasks.jobs.NotificationQueue import java.util.* @@ -20,7 +20,7 @@ import javax.inject.Singleton */ @Singleton class AlarmService @Inject constructor( - private val alarmDao: AlarmDao, + private val alarmDao: AlarmDaoBlocking, private val jobs: NotificationQueue) { fun rescheduleAlarms(taskId: Long, oldDueDate: Long, newDueDate: Long) { diff --git a/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java b/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java index 87fb7efaf..064c4fe7d 100755 --- a/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java +++ b/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java @@ -15,7 +15,7 @@ import android.net.Uri; import android.os.Handler; import android.text.TextUtils; import com.todoroo.andlib.utility.DialogUtilities; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskMover; import java.io.IOException; @@ -27,18 +27,18 @@ import org.tasks.R; import org.tasks.analytics.Firebase; import org.tasks.backup.XmlReader; import org.tasks.data.Alarm; -import org.tasks.data.AlarmDao; +import org.tasks.data.AlarmDaoBlocking; import org.tasks.data.Geofence; import org.tasks.data.GoogleTask; -import org.tasks.data.GoogleTaskDao; -import org.tasks.data.LocationDao; +import org.tasks.data.GoogleTaskDaoBlocking; +import org.tasks.data.LocationDaoBlocking; import org.tasks.data.Place; import org.tasks.data.Tag; -import org.tasks.data.TagDao; +import org.tasks.data.TagDaoBlocking; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; import org.tasks.data.UserActivity; -import org.tasks.data.UserActivityDao; +import org.tasks.data.UserActivityDaoBlocking; import org.tasks.dialogs.DialogBuilder; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -49,17 +49,17 @@ public class TasksXmlImporter { private static final String FORMAT2 = "2"; // $NON-NLS-1$ private static final String FORMAT3 = "3"; // $NON-NLS-1$ - private final TagDataDao tagDataDao; - private final UserActivityDao userActivityDao; + private final TagDataDaoBlocking tagDataDao; + private final UserActivityDaoBlocking userActivityDao; private final DialogBuilder dialogBuilder; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final LocalBroadcastManager localBroadcastManager; - private final AlarmDao alarmDao; - private final TagDao tagDao; - private final GoogleTaskDao googleTaskDao; + private final AlarmDaoBlocking alarmDao; + private final TagDaoBlocking tagDao; + private final GoogleTaskDaoBlocking googleTaskDao; private final TaskMover taskMover; private final Firebase firebase; - private final LocationDao locationDao; + private final LocationDaoBlocking locationDao; private Activity activity; private Handler handler; private int taskCount; @@ -71,15 +71,15 @@ public class TasksXmlImporter { @Inject public TasksXmlImporter( - TagDataDao tagDataDao, - UserActivityDao userActivityDao, + TagDataDaoBlocking tagDataDao, + UserActivityDaoBlocking userActivityDao, DialogBuilder dialogBuilder, - TaskDao taskDao, - LocationDao locationDao, + TaskDaoBlocking taskDao, + LocationDaoBlocking locationDao, LocalBroadcastManager localBroadcastManager, - AlarmDao alarmDao, - TagDao tagDao, - GoogleTaskDao googleTaskDao, + AlarmDaoBlocking alarmDao, + TagDaoBlocking tagDao, + GoogleTaskDaoBlocking googleTaskDao, TaskMover taskMover, Firebase firebase) { this.tagDataDao = tagDataDao; diff --git a/app/src/main/java/com/todoroo/astrid/core/BuiltInFilterExposer.java b/app/src/main/java/com/todoroo/astrid/core/BuiltInFilterExposer.java index a0c542e0a..e848e01c3 100644 --- a/app/src/main/java/com/todoroo/astrid/core/BuiltInFilterExposer.java +++ b/app/src/main/java/com/todoroo/astrid/core/BuiltInFilterExposer.java @@ -13,7 +13,7 @@ import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.PermaSql; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.timers.TimerPlugin; @@ -37,12 +37,12 @@ import org.tasks.themes.CustomIcons; public final class BuiltInFilterExposer { private final Preferences preferences; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final Context context; @Inject public BuiltInFilterExposer( - @ApplicationContext Context context, Preferences preferences, TaskDao taskDao) { + @ApplicationContext Context context, Preferences preferences, TaskDaoBlocking taskDao) { this.context = context; this.preferences = preferences; this.taskDao = taskDao; diff --git a/app/src/main/java/com/todoroo/astrid/dao/Database.kt b/app/src/main/java/com/todoroo/astrid/dao/Database.kt index 22b42a569..dd38c7929 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/Database.kt +++ b/app/src/main/java/com/todoroo/astrid/dao/Database.kt @@ -5,7 +5,7 @@ import androidx.room.RoomDatabase import com.todoroo.astrid.data.Task import org.tasks.data.* import org.tasks.notifications.Notification -import org.tasks.notifications.NotificationDao +import org.tasks.notifications.NotificationDaoBlocking @Database( entities = [ @@ -28,21 +28,21 @@ import org.tasks.notifications.NotificationDao GoogleTaskAccount::class], version = 76) 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 fun notificationDao(): NotificationDaoBlocking + abstract val tagDataDao: TagDataDaoBlocking + abstract val userActivityDao: UserActivityDaoBlocking + abstract val taskAttachmentDao: TaskAttachmentDaoBlocking + abstract val taskListMetadataDao: TaskListMetadataDaoBlocking + abstract val alarmDao: AlarmDaoBlocking + abstract val locationDao: LocationDaoBlocking + abstract val tagDao: TagDaoBlocking + abstract val googleTaskDao: GoogleTaskDaoBlocking + abstract val filterDao: FilterDaoBlocking + abstract val googleTaskListDao: GoogleTaskListDaoBlocking + abstract val taskDao: TaskDaoBlocking + abstract val caldavDao: CaldavDaoBlocking + abstract val deletionDao: DeletionDaoBlocking + abstract val contentProviderDao: ContentProviderDaoBlocking /** @return human-readable database name for debugging */ diff --git a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt index 210c1d924..3057cb5fb 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt +++ b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.kt @@ -294,7 +294,7 @@ SELECT EXISTS(SELECT 1 FROM tasks WHERE parent > 0 AND deleted = 0) AS hasSubtas companion object { const val TRANS_SUPPRESS_REFRESH = "suppress-refresh" - private fun getQuery(queryTemplate: String, vararg fields: Field): SimpleSQLiteQuery { + fun getQuery(queryTemplate: String, vararg fields: Field): SimpleSQLiteQuery { return SimpleSQLiteQuery( com.todoroo.andlib.sql.Query.select(*fields) .withQueryTemplate(PermaSql.replacePlaceholdersForQuery(queryTemplate)) diff --git a/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt b/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt new file mode 100644 index 000000000..b66836b13 --- /dev/null +++ b/app/src/main/java/com/todoroo/astrid/dao/TaskDaoBlocking.kt @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2012 Todoroo Inc + * + * See the file "LICENSE" for the full license governing this code. + */ +package com.todoroo.astrid.dao + +import androidx.paging.DataSource +import androidx.room.* +import androidx.sqlite.db.SimpleSQLiteQuery +import com.todoroo.andlib.sql.Field +import com.todoroo.andlib.utility.AndroidUtilities.assertNotMainThread +import com.todoroo.andlib.utility.DateUtilities +import com.todoroo.astrid.api.Filter +import com.todoroo.astrid.dao.TaskDao.Companion.getQuery +import com.todoroo.astrid.data.Task +import com.todoroo.astrid.data.Task.Companion.NO_ID +import com.todoroo.astrid.helper.UUIDHelper +import kotlinx.coroutines.runBlocking +import org.tasks.BuildConfig +import org.tasks.data.Place +import org.tasks.data.SubtaskInfo +import org.tasks.data.TaskContainer +import org.tasks.data.TaskListQuery +import org.tasks.db.DbUtils.chunkedMap +import org.tasks.db.DbUtils.eachChunk +import org.tasks.jobs.WorkManager +import org.tasks.preferences.Preferences +import org.tasks.time.DateTimeUtils.currentTimeMillis +import timber.log.Timber + +@Dao +abstract class TaskDaoBlocking(private val database: Database) { + private lateinit var workManager: WorkManager + + fun initialize(workManager: WorkManager) { + this.workManager = workManager + } + + fun needsRefresh(): List { + return needsRefresh(DateUtilities.now()) + } + + @Query("SELECT * FROM tasks WHERE completed = 0 AND deleted = 0 AND (hideUntil > :now OR dueDate > :now)") + abstract fun needsRefresh(now: Long): List + + fun fetchBlocking(id: Long) = runBlocking { + fetch(id) + } + + @Query("SELECT * FROM tasks WHERE _id = :id LIMIT 1") + abstract suspend fun fetch(id: Long): Task? + + fun fetch(ids: List): List = ids.chunkedMap(this::fetchInternal) + + @Query("SELECT * FROM tasks WHERE _id IN (:ids)") + internal abstract fun fetchInternal(ids: List): List + + @Query("SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0") + abstract fun activeTimers(): Int + + @Query("SELECT tasks.* FROM tasks INNER JOIN notification ON tasks._id = notification.task") + abstract fun activeNotifications(): List + + @Query("SELECT * FROM tasks WHERE remoteId = :remoteId") + abstract fun fetch(remoteId: String): Task? + + @Query("SELECT * FROM tasks WHERE completed = 0 AND deleted = 0") + abstract fun getActiveTasks(): List + + @Query("SELECT * FROM tasks WHERE hideUntil < (strftime('%s','now')*1000)") + abstract fun getVisibleTasks(): List + + @Query("SELECT * FROM tasks WHERE remoteId IN (:remoteIds) " + + "AND recurrence IS NOT NULL AND LENGTH(recurrence) > 0") + abstract fun getRecurringTasks(remoteIds: List): List + + @Query("UPDATE tasks SET completed = :completionDate " + "WHERE remoteId = :remoteId") + abstract fun setCompletionDate(remoteId: String, completionDate: Long) + + @Query("UPDATE tasks SET snoozeTime = :millis WHERE _id in (:taskIds)") + abstract fun snooze(taskIds: List, millis: Long) + + @Query("SELECT tasks.* FROM tasks " + + "LEFT JOIN google_tasks ON tasks._id = google_tasks.gt_task " + + "WHERE gt_list_id IN (SELECT gtl_remote_id FROM google_task_lists WHERE gtl_account = :account)" + + "AND (tasks.modified > google_tasks.gt_last_sync OR google_tasks.gt_remote_id = '' OR google_tasks.gt_deleted > 0) " + + "ORDER BY CASE WHEN gt_parent = 0 THEN 0 ELSE 1 END, gt_order ASC") + abstract fun getGoogleTasksToPush(account: String): List + + @Query(""" + SELECT tasks.* + FROM tasks + INNER JOIN caldav_tasks ON tasks._id = caldav_tasks.cd_task + WHERE caldav_tasks.cd_calendar = :calendar + AND (tasks.modified > caldav_tasks.cd_last_sync OR caldav_tasks.cd_last_sync = 0)""") + abstract fun getCaldavTasksToPush(calendar: String): List + + @Query("SELECT * FROM TASKS " + + "WHERE completed = 0 AND deleted = 0 AND (notificationFlags > 0 OR notifications > 0)") + abstract fun getTasksWithReminders(): List + + // --- SQL clause generators + @Query("SELECT * FROM tasks") + abstract fun getAll(): List + + @Query("SELECT calendarUri FROM tasks " + "WHERE calendarUri IS NOT NULL AND calendarUri != ''") + abstract fun getAllCalendarEvents(): List + + @Query("UPDATE tasks SET calendarUri = '' " + "WHERE calendarUri IS NOT NULL AND calendarUri != ''") + abstract fun clearAllCalendarEvents(): Int + + @Query("SELECT calendarUri FROM tasks " + + "WHERE completed > 0 AND calendarUri IS NOT NULL AND calendarUri != ''") + abstract fun getCompletedCalendarEvents(): List + + @Query("UPDATE tasks SET calendarUri = '' " + + "WHERE completed > 0 AND calendarUri IS NOT NULL AND calendarUri != ''") + abstract fun clearCompletedCalendarEvents(): Int + + @Transaction + open fun fetchTasks(callback: (SubtaskInfo) -> List): List { + return runBlocking { + fetchTasks(callback, getSubtaskInfo()) + } + } + + @Transaction + open fun fetchTasks(callback: (SubtaskInfo) -> List, subtasks: SubtaskInfo): List { + assertNotMainThread() + + val start = if (BuildConfig.DEBUG) DateUtilities.now() else 0 + val queries = callback.invoke(subtasks) + val db = database.openHelper.writableDatabase + val last = queries.size - 1 + for (i in 0 until last) { + db.execSQL(queries[i]) + } + val result = fetchTasks(SimpleSQLiteQuery(queries[last])) + Timber.v("%sms: %s", DateUtilities.now() - start, queries.joinToString(";\n")) + return result + } + + fun fetchTasks(preferences: Preferences, filter: Filter): List { + return fetchTasks { + TaskListQuery.getQuery(preferences, filter, it) + } + } + + @RawQuery + abstract fun fetchTasks(query: SimpleSQLiteQuery): List + + @RawQuery + abstract fun count(query: SimpleSQLiteQuery): Int + + @Query(""" +SELECT EXISTS(SELECT 1 FROM tasks WHERE parent > 0 AND deleted = 0) AS hasSubtasks, + EXISTS(SELECT 1 + FROM google_tasks + INNER JOIN tasks ON gt_task = _id + WHERE deleted = 0 + AND gt_parent > 0 + AND gt_deleted = 0) AS hasGoogleSubtasks + """) + abstract suspend fun getSubtaskInfo(): SubtaskInfo + + @RawQuery(observedEntities = [Place::class]) + abstract fun getTaskFactory( + query: SimpleSQLiteQuery): DataSource.Factory + + fun touch(id: Long) = touch(listOf(id)) + + fun touch(ids: List) { + ids.eachChunk { touchInternal(it) } + workManager.sync(false) + } + + @Query("UPDATE tasks SET modified = :now WHERE _id in (:ids)") + abstract fun touchInternal(ids: List, now: Long = currentTimeMillis()) + + fun setParent(parent: Long, tasks: List) = + tasks.eachChunk { setParentInternal(parent, it) } + + @Query("UPDATE tasks SET parent = :parent WHERE _id IN (:children)") + internal abstract fun setParentInternal(parent: Long, children: List) + + @Transaction + open fun fetchChildren(id: Long): List { + return fetch(getChildren(id)) + } + + fun getChildren(id: Long): List { + return getChildren(listOf(id)) + } + + @Query("WITH RECURSIVE " + + " recursive_tasks (task) AS ( " + + " SELECT _id " + + " FROM tasks " + + "WHERE parent IN (:ids)" + + "UNION ALL " + + " SELECT _id " + + " FROM tasks " + + " INNER JOIN recursive_tasks " + + " ON recursive_tasks.task = tasks.parent" + + " WHERE tasks.deleted = 0)" + + "SELECT task FROM recursive_tasks") + abstract fun getChildren(ids: List): List + + @Query("UPDATE tasks SET collapsed = :collapsed WHERE _id = :id") + abstract fun setCollapsed(id: Long, collapsed: Boolean) + + @Transaction + open fun setCollapsed(preferences: Preferences, filter: Filter, collapsed: Boolean) { + fetchTasks(preferences, filter) + .filter(TaskContainer::hasChildren) + .map(TaskContainer::getId) + .eachChunk { collapse(it, collapsed) } + } + + @Query("UPDATE tasks SET collapsed = :collapsed WHERE _id IN (:ids)") + abstract fun collapse(ids: List, collapsed: Boolean) + + // --- save + // TODO: get rid of this super-hack + /** + * Saves the given task to the database.getDatabase(). Task must already exist. Returns true on + * success. + */ + @JvmOverloads + fun save(task: Task, original: Task? = fetchBlocking(task.id)) { + if (!task.insignificantChange(original)) { + task.modificationDate = DateUtilities.now() + } + if (update(task) == 1) { + workManager.afterSave(task, original) + } + } + + @Insert + abstract fun insert(task: Task): Long + + @Update + abstract fun update(task: Task): Int + + fun createNew(task: Task) { + task.id = NO_ID + if (task.creationDate == 0L) { + task.creationDate = DateUtilities.now() + } + if (Task.isUuidEmpty(task.remoteId)) { + task.remoteId = UUIDHelper.newUUID() + } + val insert = insert(task) + task.id = insert + } + + fun count(filter: Filter): Int { + val query = getQuery(filter.sqlQuery, Field.COUNT) + val start = if (BuildConfig.DEBUG) DateUtilities.now() else 0 + val count = count(query) + Timber.v("%sms: %s", DateUtilities.now() - start, query.sql) + return count + } + + fun fetchFiltered(filter: Filter): List { + return fetchFiltered(filter.getSqlQuery()) + } + + fun fetchFiltered(queryTemplate: String): List { + val query = getQuery(queryTemplate, Task.FIELDS) + val start = if (BuildConfig.DEBUG) DateUtilities.now() else 0 + val tasks = fetchTasks(query) + Timber.v("%sms: %s", DateUtilities.now() - start, query.sql) + return tasks.map(TaskContainer::getTask) + } + + @Query("SELECT _id FROM tasks LEFT JOIN google_tasks ON _id = gt_task AND gt_deleted = 0 LEFT JOIN caldav_tasks ON _id = cd_task AND cd_deleted = 0 WHERE gt_id IS NULL AND cd_id IS NULL AND parent = 0") + abstract fun getLocalTasks(): List +} \ No newline at end of file diff --git a/app/src/main/java/com/todoroo/astrid/data/Task.kt b/app/src/main/java/com/todoroo/astrid/data/Task.kt index 6a2375f1a..5e28155a4 100644 --- a/app/src/main/java/com/todoroo/astrid/data/Task.kt +++ b/app/src/main/java/com/todoroo/astrid/data/Task.kt @@ -11,6 +11,7 @@ import com.todoroo.andlib.data.Table import com.todoroo.andlib.sql.Field import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import org.tasks.Strings import org.tasks.backup.XmlReader import org.tasks.data.Tag diff --git a/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.kt b/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.kt index f1bdd9767..b199da153 100644 --- a/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.kt +++ b/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.kt @@ -21,7 +21,7 @@ import com.todoroo.astrid.data.Task import dagger.hilt.android.AndroidEntryPoint import org.tasks.R import org.tasks.data.TaskAttachment -import org.tasks.data.TaskAttachmentDao +import org.tasks.data.TaskAttachmentDaoBlocking import org.tasks.dialogs.AddAttachmentDialog import org.tasks.dialogs.DialogBuilder import org.tasks.files.FileHelper @@ -33,7 +33,7 @@ import javax.inject.Inject @AndroidEntryPoint class FilesControlSet : TaskEditControlFragment() { @Inject lateinit var activity: Activity - @Inject lateinit var taskAttachmentDao: TaskAttachmentDao + @Inject lateinit var taskAttachmentDao: TaskAttachmentDaoBlocking @Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var preferences: Preferences diff --git a/app/src/main/java/com/todoroo/astrid/gcal/GCalHelper.java b/app/src/main/java/com/todoroo/astrid/gcal/GCalHelper.java index 22f8163a3..496cf7bcc 100644 --- a/app/src/main/java/com/todoroo/astrid/gcal/GCalHelper.java +++ b/app/src/main/java/com/todoroo/astrid/gcal/GCalHelper.java @@ -15,7 +15,7 @@ import android.net.Uri; import android.provider.CalendarContract; import android.text.format.Time; import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import dagger.hilt.android.qualifiers.ApplicationContext; import java.util.TimeZone; @@ -32,7 +32,7 @@ public class GCalHelper { /** If task has no estimated time, how early to set a task in calendar (seconds) */ private static final long DEFAULT_CAL_TIME = DateUtilities.ONE_HOUR; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final Preferences preferences; private final PermissionChecker permissionChecker; private final CalendarEventProvider calendarEventProvider; @@ -41,7 +41,7 @@ public class GCalHelper { @Inject public GCalHelper( @ApplicationContext Context context, - TaskDao taskDao, + TaskDaoBlocking taskDao, Preferences preferences, PermissionChecker permissionChecker, CalendarEventProvider calendarEventProvider) { diff --git a/app/src/main/java/com/todoroo/astrid/gtasks/GtasksListService.java b/app/src/main/java/com/todoroo/astrid/gtasks/GtasksListService.java index 995073604..27c03d84e 100644 --- a/app/src/main/java/com/todoroo/astrid/gtasks/GtasksListService.java +++ b/app/src/main/java/com/todoroo/astrid/gtasks/GtasksListService.java @@ -15,18 +15,18 @@ import javax.inject.Inject; import org.tasks.LocalBroadcastManager; import org.tasks.data.GoogleTaskAccount; import org.tasks.data.GoogleTaskList; -import org.tasks.data.GoogleTaskListDao; +import org.tasks.data.GoogleTaskListDaoBlocking; import timber.log.Timber; public class GtasksListService { - private final GoogleTaskListDao googleTaskListDao; + private final GoogleTaskListDaoBlocking googleTaskListDao; private final TaskDeleter taskDeleter; private final LocalBroadcastManager localBroadcastManager; @Inject public GtasksListService( - GoogleTaskListDao googleTaskListDao, + GoogleTaskListDaoBlocking googleTaskListDao, TaskDeleter taskDeleter, LocalBroadcastManager localBroadcastManager) { this.googleTaskListDao = googleTaskListDao; diff --git a/app/src/main/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.kt b/app/src/main/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.kt index faf40c0ff..d7765e041 100644 --- a/app/src/main/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.kt +++ b/app/src/main/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.kt @@ -15,7 +15,7 @@ import dagger.hilt.android.AndroidEntryPoint import org.tasks.PermissionUtil.verifyPermissions import org.tasks.R import org.tasks.data.GoogleTaskAccount -import org.tasks.data.GoogleTaskListDao +import org.tasks.data.GoogleTaskListDaoBlocking import org.tasks.dialogs.DialogBuilder import org.tasks.gtasks.GoogleAccountManager import org.tasks.injection.InjectingAppCompatActivity @@ -34,7 +34,7 @@ import javax.inject.Inject class GtasksLoginActivity : InjectingAppCompatActivity() { @Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var googleAccountManager: GoogleAccountManager - @Inject lateinit var googleTaskListDao: GoogleTaskListDao + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking @Inject lateinit var permissionRequestor: ActivityPermissionRequestor override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/todoroo/astrid/notes/CommentsController.java b/app/src/main/java/com/todoroo/astrid/notes/CommentsController.java index b46a2f6e5..ffe23d2d4 100644 --- a/app/src/main/java/com/todoroo/astrid/notes/CommentsController.java +++ b/app/src/main/java/com/todoroo/astrid/notes/CommentsController.java @@ -24,14 +24,14 @@ import java.util.ArrayList; import javax.inject.Inject; import org.tasks.R; import org.tasks.data.UserActivity; -import org.tasks.data.UserActivityDao; +import org.tasks.data.UserActivityDaoBlocking; import org.tasks.files.FileHelper; import org.tasks.locale.Locale; import org.tasks.preferences.Preferences; public class CommentsController { - private final UserActivityDao userActivityDao; + private final UserActivityDaoBlocking userActivityDao; private final ArrayList items = new ArrayList<>(); private final Activity activity; private final Preferences preferences; @@ -43,7 +43,7 @@ public class CommentsController { @Inject public CommentsController( - UserActivityDao userActivityDao, Activity activity, Preferences preferences, Locale locale) { + UserActivityDaoBlocking userActivityDao, Activity activity, Preferences preferences, Locale locale) { this.userActivityDao = userActivityDao; this.activity = activity; this.preferences = preferences; diff --git a/app/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.kt b/app/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.kt index 6cdf379d3..42d1527cc 100644 --- a/app/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.kt +++ b/app/src/main/java/com/todoroo/astrid/provider/Astrid2TaskProvider.kt @@ -20,7 +20,7 @@ import dagger.hilt.android.components.ApplicationComponent import org.tasks.BuildConfig import org.tasks.R import org.tasks.analytics.Firebase -import org.tasks.data.ContentProviderDao +import org.tasks.data.ContentProviderDaoBlocking import timber.log.Timber import java.math.BigInteger import java.security.MessageDigest @@ -39,7 +39,7 @@ class Astrid2TaskProvider : ContentProvider() { @EntryPoint @InstallIn(ApplicationComponent::class) interface Astrid2TaskProviderEntryPoint { - val contentProviderDao: ContentProviderDao + val contentProviderDao: ContentProviderDaoBlocking val firebase: Firebase } diff --git a/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java b/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java index bf656c022..13b1d0841 100644 --- a/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java +++ b/app/src/main/java/com/todoroo/astrid/reminders/ReminderService.java @@ -10,7 +10,7 @@ import static com.google.common.collect.Lists.transform; import androidx.annotation.Nullable; import com.todoroo.andlib.utility.DateUtilities; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import java.util.List; import javax.inject.Inject; @@ -36,15 +36,15 @@ public final class ReminderService { private final NotificationQueue jobs; private final Random random; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final Preferences preferences; @Inject - ReminderService(Preferences preferences, NotificationQueue notificationQueue, TaskDao taskDao) { + ReminderService(Preferences preferences, NotificationQueue notificationQueue, TaskDaoBlocking taskDao) { this(preferences, notificationQueue, new Random(), taskDao); } - ReminderService(Preferences preferences, NotificationQueue jobs, Random random, TaskDao taskDao) { + ReminderService(Preferences preferences, NotificationQueue jobs, Random random, TaskDaoBlocking taskDao) { this.preferences = preferences; this.jobs = jobs; this.random = random; diff --git a/app/src/main/java/com/todoroo/astrid/repeats/RepeatTaskHelper.java b/app/src/main/java/com/todoroo/astrid/repeats/RepeatTaskHelper.java index 0a29a0de1..5c348ad0e 100644 --- a/app/src/main/java/com/todoroo/astrid/repeats/RepeatTaskHelper.java +++ b/app/src/main/java/com/todoroo/astrid/repeats/RepeatTaskHelper.java @@ -20,7 +20,7 @@ import com.google.ical.values.RRule; import com.google.ical.values.WeekdayNum; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.alarms.AlarmService; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gcal.GCalHelper; import java.text.ParseException; @@ -38,7 +38,7 @@ public class RepeatTaskHelper { private static final Comparator weekdayCompare = (object1, object2) -> object1.wday.javaDayNum - object2.wday.javaDayNum; private final GCalHelper gcalHelper; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final LocalBroadcastManager localBroadcastManager; private final AlarmService alarmService; @@ -46,7 +46,7 @@ public class RepeatTaskHelper { public RepeatTaskHelper( GCalHelper gcalHelper, AlarmService alarmService, - TaskDao taskDao, + TaskDaoBlocking taskDao, LocalBroadcastManager localBroadcastManager) { this.gcalHelper = gcalHelper; this.taskDao = taskDao; diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt b/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt index 4ad944390..8786a38ac 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskCompleter.kt @@ -1,15 +1,15 @@ package com.todoroo.astrid.service import com.todoroo.andlib.utility.DateUtilities -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task -import org.tasks.data.GoogleTaskDao +import org.tasks.data.GoogleTaskDaoBlocking import timber.log.Timber import javax.inject.Inject class TaskCompleter @Inject internal constructor( - private val taskDao: TaskDao, - private val googleTaskDao: GoogleTaskDao) { + private val taskDao: TaskDaoBlocking, + private val googleTaskDao: GoogleTaskDaoBlocking) { fun setComplete(taskId: Long) = taskDao.fetchBlocking(taskId)?.let { setComplete(it, true) } diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java b/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java index 6611446bd..e28c52ebe 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java +++ b/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java @@ -12,7 +12,7 @@ import com.todoroo.astrid.api.CaldavFilter; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.PermaSql; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.utility.TitleParser; @@ -20,17 +20,17 @@ import java.util.ArrayList; import java.util.Map; import javax.inject.Inject; import org.tasks.R; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.data.CaldavTask; import org.tasks.data.Geofence; import org.tasks.data.GoogleTask; -import org.tasks.data.GoogleTaskDao; -import org.tasks.data.LocationDao; +import org.tasks.data.GoogleTaskDaoBlocking; +import org.tasks.data.LocationDaoBlocking; import org.tasks.data.Place; import org.tasks.data.Tag; -import org.tasks.data.TagDao; +import org.tasks.data.TagDaoBlocking; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.Preferences; import timber.log.Timber; @@ -39,25 +39,25 @@ public class TaskCreator { private final GCalHelper gcalHelper; private final Preferences preferences; - private final TagDao tagDao; - private final GoogleTaskDao googleTaskDao; + private final TagDaoBlocking tagDao; + private final GoogleTaskDaoBlocking googleTaskDao; private final DefaultFilterProvider defaultFilterProvider; - private final CaldavDao caldavDao; - private final LocationDao locationDao; - private final TagDataDao tagDataDao; - private final TaskDao taskDao; + private final CaldavDaoBlocking caldavDao; + private final LocationDaoBlocking locationDao; + private final TagDataDaoBlocking tagDataDao; + private final TaskDaoBlocking taskDao; @Inject public TaskCreator( GCalHelper gcalHelper, Preferences preferences, - TagDataDao tagDataDao, - TaskDao taskDao, - TagDao tagDao, - GoogleTaskDao googleTaskDao, + TagDataDaoBlocking tagDataDao, + TaskDaoBlocking taskDao, + TagDaoBlocking tagDao, + GoogleTaskDaoBlocking googleTaskDao, DefaultFilterProvider defaultFilterProvider, - CaldavDao caldavDao, - LocationDao locationDao) { + CaldavDaoBlocking caldavDao, + LocationDaoBlocking locationDao) { this.gcalHelper = gcalHelper; this.preferences = preferences; this.tagDataDao = tagDataDao; diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.kt b/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.kt index ba238b1a7..0d87667c7 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.kt @@ -1,7 +1,7 @@ package com.todoroo.astrid.service import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import kotlinx.collections.immutable.persistentListOf import org.tasks.LocalBroadcastManager @@ -14,11 +14,11 @@ import java.util.* import javax.inject.Inject class TaskDeleter @Inject constructor( - private val deletionDao: DeletionDao, + private val deletionDao: DeletionDaoBlocking, private val workManager: WorkManager, - private val taskDao: TaskDao, + private val taskDao: TaskDaoBlocking, private val localBroadcastManager: LocalBroadcastManager, - private val googleTaskDao: GoogleTaskDao, + private val googleTaskDao: GoogleTaskDaoBlocking, private val preferences: Preferences) { fun markDeleted(item: Task) = markDeleted(persistentListOf(item.id)) diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskDuplicator.java b/app/src/main/java/com/todoroo/astrid/service/TaskDuplicator.java index 9dd49c2a2..d71eafcc4 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskDuplicator.java +++ b/app/src/main/java/com/todoroo/astrid/service/TaskDuplicator.java @@ -4,7 +4,7 @@ import static com.google.common.collect.Lists.transform; import static com.todoroo.andlib.utility.DateUtilities.now; import static com.todoroo.astrid.data.Task.NO_UUID; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gcal.GCalHelper; import java.util.ArrayList; @@ -12,43 +12,43 @@ import java.util.List; import javax.inject.Inject; import org.tasks.LocalBroadcastManager; import org.tasks.data.Alarm; -import org.tasks.data.AlarmDao; -import org.tasks.data.CaldavDao; +import org.tasks.data.AlarmDaoBlocking; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.data.CaldavTask; import org.tasks.data.Geofence; import org.tasks.data.GoogleTask; -import org.tasks.data.GoogleTaskDao; -import org.tasks.data.LocationDao; +import org.tasks.data.GoogleTaskDaoBlocking; +import org.tasks.data.LocationDaoBlocking; import org.tasks.data.Tag; -import org.tasks.data.TagDao; +import org.tasks.data.TagDaoBlocking; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; import org.tasks.preferences.Preferences; public class TaskDuplicator { private final GCalHelper gcalHelper; - private final TaskDao taskDao; - private final TagDao tagDao; - private final TagDataDao tagDataDao; - private final GoogleTaskDao googleTaskDao; - private final CaldavDao caldavDao; - private final LocationDao locationDao; - private final AlarmDao alarmDao; + private final TaskDaoBlocking taskDao; + private final TagDaoBlocking tagDao; + private final TagDataDaoBlocking tagDataDao; + private final GoogleTaskDaoBlocking googleTaskDao; + private final CaldavDaoBlocking caldavDao; + private final LocationDaoBlocking locationDao; + private final AlarmDaoBlocking alarmDao; private final Preferences preferences; private final LocalBroadcastManager localBroadcastManager; @Inject public TaskDuplicator( GCalHelper gcalHelper, - TaskDao taskDao, + TaskDaoBlocking taskDao, LocalBroadcastManager localBroadcastManager, - TagDao tagDao, - TagDataDao tagDataDao, - GoogleTaskDao googleTaskDao, - CaldavDao caldavDao, - LocationDao locationDao, - AlarmDao alarmDao, + TagDaoBlocking tagDao, + TagDataDaoBlocking tagDataDao, + GoogleTaskDaoBlocking googleTaskDao, + CaldavDaoBlocking caldavDao, + LocationDaoBlocking locationDao, + AlarmDaoBlocking alarmDao, Preferences preferences) { this.gcalHelper = gcalHelper; this.taskDao = taskDao; diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt b/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt index 7b6242b4e..6c361bc95 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskMover.kt @@ -5,7 +5,7 @@ import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.api.CaldavFilter import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.GtasksFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.qualifiers.ApplicationContext import org.tasks.BuildConfig @@ -18,10 +18,10 @@ import javax.inject.Inject class TaskMover @Inject constructor( @param:ApplicationContext private val context: Context, - private val taskDao: TaskDao, - private val caldavDao: CaldavDao, - private val googleTaskDao: GoogleTaskDao, - private val googleTaskListDao: GoogleTaskListDao, + private val taskDao: TaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val googleTaskListDao: GoogleTaskListDaoBlocking, private val preferences: Preferences, private val localBroadcastManager: LocalBroadcastManager) { diff --git a/app/src/main/java/com/todoroo/astrid/service/Upgrader.kt b/app/src/main/java/com/todoroo/astrid/service/Upgrader.kt index 7bc2e6abe..f0b2e257b 100644 --- a/app/src/main/java/com/todoroo/astrid/service/Upgrader.kt +++ b/app/src/main/java/com/todoroo/astrid/service/Upgrader.kt @@ -6,7 +6,7 @@ import com.google.common.collect.ImmutableListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimaps import com.todoroo.astrid.api.GtasksFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.qualifiers.ApplicationContext import org.tasks.R import org.tasks.Strings.isNullOrEmpty @@ -26,16 +26,16 @@ import javax.inject.Inject class Upgrader @Inject constructor( @param:ApplicationContext private val context: Context, private val preferences: Preferences, - private val tagDataDao: TagDataDao, - private val tagDao: TagDao, - private val filterDao: FilterDao, + private val tagDataDao: TagDataDaoBlocking, + private val tagDao: TagDaoBlocking, + private val filterDao: FilterDaoBlocking, private val defaultFilterProvider: DefaultFilterProvider, - private val googleTaskListDao: GoogleTaskListDao, - private val userActivityDao: UserActivityDao, - private val taskAttachmentDao: TaskAttachmentDao, - private val caldavDao: CaldavDao, - private val taskDao: TaskDao, - private val locationDao: LocationDao, + private val googleTaskListDao: GoogleTaskListDaoBlocking, + private val userActivityDao: UserActivityDaoBlocking, + private val taskAttachmentDao: TaskAttachmentDaoBlocking, + private val caldavDao: CaldavDaoBlocking, + private val taskDao: TaskDaoBlocking, + private val locationDao: LocationDaoBlocking, private val iCal: iCalendar, private val widgetManager: AppWidgetManager, private val taskMover: TaskMover) { diff --git a/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksFilterUpdater.java b/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksFilterUpdater.java index 6ef6ce52c..cf608b37f 100644 --- a/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksFilterUpdater.java +++ b/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksFilterUpdater.java @@ -4,7 +4,7 @@ import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.db.QueryUtils.showHiddenAndCompleted; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import java.util.ArrayList; import java.util.HashMap; @@ -15,7 +15,7 @@ import javax.inject.Inject; import org.json.JSONArray; import org.json.JSONException; import org.tasks.data.TaskListMetadata; -import org.tasks.data.TaskListMetadataDao; +import org.tasks.data.TaskListMetadataDaoBlocking; import timber.log.Timber; public class SubtasksFilterUpdater { @@ -23,13 +23,13 @@ public class SubtasksFilterUpdater { public static final String ACTIVE_TASKS_ORDER = "active_tasks_order"; // $NON-NLS-1$ public static final String TODAY_TASKS_ORDER = "today_tasks_order"; // $NON-NLS-1$ - private final TaskListMetadataDao taskListMetadataDao; - private final TaskDao taskDao; + private final TaskListMetadataDaoBlocking taskListMetadataDao; + private final TaskDaoBlocking taskDao; private final HashMap idToNode = new HashMap<>(); private Node treeRoot; @Inject - public SubtasksFilterUpdater(TaskListMetadataDao taskListMetadataDao, TaskDao taskDao) { + public SubtasksFilterUpdater(TaskListMetadataDaoBlocking taskListMetadataDao, TaskDaoBlocking taskDao) { this.taskDao = taskDao; this.taskListMetadataDao = taskListMetadataDao; } diff --git a/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java b/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java index b1dae8f0c..8d4ba0b73 100644 --- a/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java +++ b/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java @@ -6,7 +6,7 @@ import static org.tasks.db.QueryUtils.showHiddenAndCompleted; import android.content.Context; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.core.BuiltInFilterExposer; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.subtasks.SubtasksFilterUpdater.Node; import dagger.hilt.android.qualifiers.ApplicationContext; @@ -16,9 +16,9 @@ import java.util.List; import java.util.Map; import javax.inject.Inject; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; import org.tasks.data.TaskListMetadata; -import org.tasks.data.TaskListMetadataDao; +import org.tasks.data.TaskListMetadataDaoBlocking; import org.tasks.preferences.Preferences; import timber.log.Timber; @@ -26,17 +26,17 @@ public class SubtasksHelper { private final Context context; private final Preferences preferences; - private final TaskDao taskDao; - private final TagDataDao tagDataDao; - private final TaskListMetadataDao taskListMetadataDao; + private final TaskDaoBlocking taskDao; + private final TagDataDaoBlocking tagDataDao; + private final TaskListMetadataDaoBlocking taskListMetadataDao; @Inject public SubtasksHelper( @ApplicationContext Context context, Preferences preferences, - TaskDao taskDao, - TagDataDao tagDataDao, - TaskListMetadataDao taskListMetadataDao) { + TaskDaoBlocking taskDao, + TagDataDaoBlocking tagDataDao, + TaskListMetadataDaoBlocking taskListMetadataDao) { this.context = context; this.preferences = preferences; this.taskDao = taskDao; @@ -73,7 +73,7 @@ public class SubtasksHelper { } /** Takes a subtasks string containing local ids and remaps it to one containing UUIDs */ - public static String convertTreeToRemoteIds(TaskDao taskDao, String localTree) { + public static String convertTreeToRemoteIds(TaskDaoBlocking taskDao, String localTree) { List localIds = getIdList(localTree); Map idMap = getIdMap(taskDao, localIds); idMap.put(-1L, "-1"); // $NON-NLS-1$ @@ -115,7 +115,7 @@ public class SubtasksHelper { }); } - private static Map getIdMap(TaskDao taskDao, List keys) { + private static Map getIdMap(TaskDaoBlocking taskDao, List keys) { List tasks = taskDao.fetch(keys); Map map = new HashMap<>(); for (Task task : tasks) { diff --git a/app/src/main/java/com/todoroo/astrid/tags/TagsControlSet.kt b/app/src/main/java/com/todoroo/astrid/tags/TagsControlSet.kt index 776111f1a..42902a53d 100644 --- a/app/src/main/java/com/todoroo/astrid/tags/TagsControlSet.kt +++ b/app/src/main/java/com/todoroo/astrid/tags/TagsControlSet.kt @@ -18,9 +18,9 @@ import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.data.Task import dagger.hilt.android.AndroidEntryPoint import org.tasks.R -import org.tasks.data.TagDao +import org.tasks.data.TagDaoBlocking import org.tasks.data.TagData -import org.tasks.data.TagDataDao +import org.tasks.data.TagDataDaoBlocking import org.tasks.tags.TagPickerActivity import org.tasks.ui.ChipProvider import org.tasks.ui.TaskEditControlFragment @@ -34,8 +34,8 @@ import javax.inject.Inject */ @AndroidEntryPoint class TagsControlSet : TaskEditControlFragment() { - @Inject lateinit var tagDao: TagDao - @Inject lateinit var tagDataDao: TagDataDao + @Inject lateinit var tagDao: TagDaoBlocking + @Inject lateinit var tagDataDao: TagDataDaoBlocking @Inject lateinit var chipProvider: ChipProvider @BindView(R.id.no_tags) diff --git a/app/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java b/app/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java index de1504fea..040cf9947 100644 --- a/app/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java +++ b/app/src/main/java/com/todoroo/astrid/timers/TimerPlugin.java @@ -17,7 +17,7 @@ import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.utility.Constants; import dagger.hilt.android.qualifiers.ApplicationContext; @@ -32,13 +32,13 @@ public class TimerPlugin { private final Context context; private final NotificationManager notificationManager; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; @Inject public TimerPlugin( @ApplicationContext Context context, NotificationManager notificationManager, - TaskDao taskDao) { + TaskDaoBlocking taskDao) { this.context = context; this.notificationManager = notificationManager; this.taskDao = taskDao; diff --git a/app/src/main/java/com/todoroo/astrid/utility/TitleParser.java b/app/src/main/java/com/todoroo/astrid/utility/TitleParser.java index 9312f02f5..2cd5b7f7f 100644 --- a/app/src/main/java/com/todoroo/astrid/utility/TitleParser.java +++ b/app/src/main/java/com/todoroo/astrid/utility/TitleParser.java @@ -21,12 +21,12 @@ import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; import timber.log.Timber; public class TitleParser { - public static void parse(TagDataDao tagDataDao, Task task, ArrayList tags) { + public static void parse(TagDataDaoBlocking tagDataDao, Task task, ArrayList tags) { repeatHelper(task); listHelper( tagDataDao, @@ -46,7 +46,7 @@ public class TitleParser { return pattern; } - public static void listHelper(TagDataDao tagDataDao, Task task, ArrayList tags) { + public static void listHelper(TagDataDaoBlocking tagDataDao, Task task, ArrayList tags) { String inputText = task.getTitle(); Pattern tagPattern = Pattern.compile("(\\s|^)#(\\(.*\\)|[^\\s]+)"); Pattern contextPattern = Pattern.compile("(\\s|^)@(\\(.*\\)|[^\\s]+)"); diff --git a/app/src/main/java/org/tasks/Notifier.kt b/app/src/main/java/org/tasks/Notifier.kt index 147ab77df..007fd7901 100644 --- a/app/src/main/java/org/tasks/Notifier.kt +++ b/app/src/main/java/org/tasks/Notifier.kt @@ -7,7 +7,7 @@ import androidx.core.app.NotificationCompat import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.astrid.activity.MainActivity import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.reminders.ReminderService import com.todoroo.astrid.voice.VoiceOutputAssistant import dagger.hilt.android.qualifiers.ApplicationContext @@ -25,7 +25,7 @@ import kotlin.math.min class Notifier @Inject constructor( @param:ApplicationContext private val context: Context, - private val taskDao: TaskDao, + private val taskDao: TaskDaoBlocking, private val notificationManager: NotificationManager, private val telephonyManager: TelephonyManager, private val audioManager: AudioManager, diff --git a/app/src/main/java/org/tasks/activities/FilterSettingsActivity.kt b/app/src/main/java/org/tasks/activities/FilterSettingsActivity.kt index 22ce2cacf..64f303cd4 100644 --- a/app/src/main/java/org/tasks/activities/FilterSettingsActivity.kt +++ b/app/src/main/java/org/tasks/activities/FilterSettingsActivity.kt @@ -37,7 +37,7 @@ import dagger.hilt.android.AndroidEntryPoint import org.tasks.R import org.tasks.Strings import org.tasks.data.Filter -import org.tasks.data.FilterDao +import org.tasks.data.FilterDaoBlocking import org.tasks.filters.FilterCriteriaProvider import org.tasks.locale.Locale import java.util.* @@ -46,7 +46,7 @@ import kotlin.math.max @AndroidEntryPoint class FilterSettingsActivity : BaseListSettingsActivity() { - @Inject lateinit var filterDao: FilterDao + @Inject lateinit var filterDao: FilterDaoBlocking @Inject lateinit var locale: Locale @Inject lateinit var database: Database @Inject lateinit var filterCriteriaProvider: FilterCriteriaProvider diff --git a/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java b/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java index 1b4b55fcd..3bcc1704f 100644 --- a/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java +++ b/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java @@ -25,7 +25,7 @@ import javax.inject.Inject; import org.tasks.R; import org.tasks.data.GoogleTaskAccount; import org.tasks.data.GoogleTaskList; -import org.tasks.data.GoogleTaskListDao; +import org.tasks.data.GoogleTaskListDaoBlocking; import timber.log.Timber; @AndroidEntryPoint @@ -34,7 +34,7 @@ public class GoogleTaskListSettingsActivity extends BaseListSettingsActivity { public static final String EXTRA_ACCOUNT = "extra_account"; public static final String EXTRA_STORE_DATA = "extra_store_data"; @Inject @ApplicationContext Context context; - @Inject GoogleTaskListDao googleTaskListDao; + @Inject GoogleTaskListDaoBlocking googleTaskListDao; @Inject GtasksListService gtasksListService; @Inject TaskDeleter taskDeleter; @Inject GtasksInvoker gtasksInvoker; diff --git a/app/src/main/java/org/tasks/activities/NavigationDrawerCustomization.kt b/app/src/main/java/org/tasks/activities/NavigationDrawerCustomization.kt index 387411170..93784eb63 100644 --- a/app/src/main/java/org/tasks/activities/NavigationDrawerCustomization.kt +++ b/app/src/main/java/org/tasks/activities/NavigationDrawerCustomization.kt @@ -42,11 +42,11 @@ class NavigationDrawerCustomization : ThemedInjectingAppCompatActivity(), Toolba @Inject lateinit var adapter: NavigationDrawerAdapter @Inject lateinit var localBroadcastManager: LocalBroadcastManager @Inject lateinit var preferences: Preferences - @Inject lateinit var tagDataDao: TagDataDao - @Inject lateinit var googleTaskListDao: GoogleTaskListDao - @Inject lateinit var filterDao: FilterDao - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var locationDao: LocationDao + @Inject lateinit var tagDataDao: TagDataDaoBlocking + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking + @Inject lateinit var filterDao: FilterDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var locationDao: LocationDaoBlocking private lateinit var binding: ActivityTagOrganizerBinding private lateinit var toolbar: Toolbar diff --git a/app/src/main/java/org/tasks/activities/PlaceSettingsActivity.kt b/app/src/main/java/org/tasks/activities/PlaceSettingsActivity.kt index 3b00809c5..fdc2c753e 100644 --- a/app/src/main/java/org/tasks/activities/PlaceSettingsActivity.kt +++ b/app/src/main/java/org/tasks/activities/PlaceSettingsActivity.kt @@ -12,7 +12,7 @@ import com.todoroo.astrid.activity.TaskListFragment import dagger.hilt.android.AndroidEntryPoint import org.tasks.R import org.tasks.Strings.isNullOrEmpty -import org.tasks.data.LocationDao +import org.tasks.data.LocationDaoBlocking import org.tasks.data.Place import org.tasks.filters.PlaceFilter import org.tasks.location.MapFragment @@ -28,7 +28,7 @@ class PlaceSettingsActivity : BaseListSettingsActivity(), MapFragment.MapFragmen @BindView(R.id.name) lateinit var name: TextInputEditText @BindView(R.id.name_layout) lateinit var nameLayout: TextInputLayout - @Inject lateinit var locationDao: LocationDao + @Inject lateinit var locationDao: LocationDaoBlocking @Inject lateinit var map: MapFragment private lateinit var place: Place diff --git a/app/src/main/java/org/tasks/activities/TagSettingsActivity.java b/app/src/main/java/org/tasks/activities/TagSettingsActivity.java index 0e3bacdb4..eed682d0f 100644 --- a/app/src/main/java/org/tasks/activities/TagSettingsActivity.java +++ b/app/src/main/java/org/tasks/activities/TagSettingsActivity.java @@ -23,9 +23,9 @@ import com.todoroo.astrid.helper.UUIDHelper; import dagger.hilt.android.AndroidEntryPoint; import javax.inject.Inject; import org.tasks.R; -import org.tasks.data.TagDao; +import org.tasks.data.TagDaoBlocking; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; @AndroidEntryPoint public class TagSettingsActivity extends BaseListSettingsActivity { @@ -33,8 +33,8 @@ public class TagSettingsActivity extends BaseListSettingsActivity { public static final String TOKEN_AUTOPOPULATE_NAME = "autopopulateName"; // $NON-NLS-1$ public static final String EXTRA_TAG_DATA = "tagData"; // $NON-NLS-1$ private static final String EXTRA_TAG_UUID = "uuid"; // $NON-NLS-1$ - @Inject TagDataDao tagDataDao; - @Inject TagDao tagDao; + @Inject TagDataDaoBlocking tagDataDao; + @Inject TagDaoBlocking tagDao; @BindView(R.id.name) TextInputEditText name; diff --git a/app/src/main/java/org/tasks/activities/UriHandler.kt b/app/src/main/java/org/tasks/activities/UriHandler.kt index 869e7b4de..58e2c2d93 100644 --- a/app/src/main/java/org/tasks/activities/UriHandler.kt +++ b/app/src/main/java/org/tasks/activities/UriHandler.kt @@ -3,7 +3,7 @@ package org.tasks.activities import android.net.Uri import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.AndroidEntryPoint import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers @@ -18,7 +18,7 @@ import javax.inject.Inject @AndroidEntryPoint class UriHandler : AppCompatActivity() { - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/org/tasks/backup/TasksJsonExporter.kt b/app/src/main/java/org/tasks/backup/TasksJsonExporter.kt index 228e183cc..71f4741dc 100755 --- a/app/src/main/java/org/tasks/backup/TasksJsonExporter.kt +++ b/app/src/main/java/org/tasks/backup/TasksJsonExporter.kt @@ -12,7 +12,7 @@ import com.google.gson.Gson import com.google.gson.GsonBuilder import com.todoroo.andlib.utility.DialogUtilities import com.todoroo.astrid.backup.BackupConstants -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import org.tasks.BuildConfig import org.tasks.R @@ -32,20 +32,20 @@ import java.util.* import javax.inject.Inject class TasksJsonExporter @Inject constructor( - private val tagDataDao: TagDataDao, - private val taskDao: TaskDao, - private val userActivityDao: UserActivityDao, + private val tagDataDao: TagDataDaoBlocking, + private val taskDao: TaskDaoBlocking, + private val userActivityDao: UserActivityDaoBlocking, private val preferences: Preferences, - private val alarmDao: AlarmDao, - private val locationDao: LocationDao, - private val tagDao: TagDao, - private val googleTaskDao: GoogleTaskDao, - private val filterDao: FilterDao, - private val googleTaskListDao: GoogleTaskListDao, - private val taskAttachmentDao: TaskAttachmentDao, - private val caldavDao: CaldavDao, + private val alarmDao: AlarmDaoBlocking, + private val locationDao: LocationDaoBlocking, + private val tagDao: TagDaoBlocking, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val filterDao: FilterDaoBlocking, + private val googleTaskListDao: GoogleTaskListDaoBlocking, + private val taskAttachmentDao: TaskAttachmentDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val workManager: WorkManager, - private val taskListMetadataDao: TaskListMetadataDao) { + private val taskListMetadataDao: TaskListMetadataDaoBlocking) { private var context: Context? = null private var exportCount = 0 diff --git a/app/src/main/java/org/tasks/backup/TasksJsonImporter.kt b/app/src/main/java/org/tasks/backup/TasksJsonImporter.kt index f04d316ed..78b32cb38 100644 --- a/app/src/main/java/org/tasks/backup/TasksJsonImporter.kt +++ b/app/src/main/java/org/tasks/backup/TasksJsonImporter.kt @@ -6,7 +6,7 @@ import android.net.Uri import android.os.Handler import com.google.gson.Gson import com.google.gson.JsonObject -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.service.TaskMover import com.todoroo.astrid.service.Upgrader import com.todoroo.astrid.service.Upgrader.Companion.getAndroidColor @@ -23,21 +23,21 @@ import java.io.InputStreamReader import javax.inject.Inject class TasksJsonImporter @Inject constructor( - private val tagDataDao: TagDataDao, - private val userActivityDao: UserActivityDao, - private val taskDao: TaskDao, - private val locationDao: LocationDao, + private val tagDataDao: TagDataDaoBlocking, + private val userActivityDao: UserActivityDaoBlocking, + private val taskDao: TaskDaoBlocking, + private val locationDao: LocationDaoBlocking, private val localBroadcastManager: LocalBroadcastManager, - private val alarmDao: AlarmDao, - private val tagDao: TagDao, - private val googleTaskDao: GoogleTaskDao, - private val googleTaskListDao: GoogleTaskListDao, - private val filterDao: FilterDao, - private val taskAttachmentDao: TaskAttachmentDao, - private val caldavDao: CaldavDao, + private val alarmDao: AlarmDaoBlocking, + private val tagDao: TagDaoBlocking, + private val googleTaskDao: GoogleTaskDaoBlocking, + private val googleTaskListDao: GoogleTaskListDaoBlocking, + private val filterDao: FilterDaoBlocking, + private val taskAttachmentDao: TaskAttachmentDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val preferences: Preferences, private val taskMover: TaskMover, - private val taskListMetadataDao: TaskListMetadataDao) { + private val taskListMetadataDao: TaskListMetadataDaoBlocking) { private val result = ImportResult() diff --git a/app/src/main/java/org/tasks/caldav/BaseCaldavAccountSettingsActivity.java b/app/src/main/java/org/tasks/caldav/BaseCaldavAccountSettingsActivity.java index 92a0ae5c0..d8a51ba5d 100644 --- a/app/src/main/java/org/tasks/caldav/BaseCaldavAccountSettingsActivity.java +++ b/app/src/main/java/org/tasks/caldav/BaseCaldavAccountSettingsActivity.java @@ -31,7 +31,7 @@ import org.tasks.R; import org.tasks.billing.Inventory; import org.tasks.billing.PurchaseActivity; import org.tasks.data.CaldavAccount; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.databinding.ActivityCaldavAccountSettingsBinding; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.ThemedInjectingAppCompatActivity; @@ -44,7 +44,7 @@ public abstract class BaseCaldavAccountSettingsActivity extends ThemedInjectingA public static final String EXTRA_CALDAV_DATA = "caldavData"; // $NON-NLS-1$ protected static final String PASSWORD_MASK = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"; - @Inject protected CaldavDao caldavDao; + @Inject protected CaldavDaoBlocking caldavDao; @Inject protected KeyStoreEncryption encryption; @Inject DialogBuilder dialogBuilder; @Inject TaskDeleter taskDeleter; diff --git a/app/src/main/java/org/tasks/caldav/BaseCaldavCalendarSettingsActivity.java b/app/src/main/java/org/tasks/caldav/BaseCaldavCalendarSettingsActivity.java index 976bbac8c..5cd68a83c 100644 --- a/app/src/main/java/org/tasks/caldav/BaseCaldavCalendarSettingsActivity.java +++ b/app/src/main/java/org/tasks/caldav/BaseCaldavCalendarSettingsActivity.java @@ -26,7 +26,7 @@ import org.tasks.R; import org.tasks.activities.BaseListSettingsActivity; import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavCalendar; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.ui.DisplayableException; public abstract class BaseCaldavCalendarSettingsActivity extends BaseListSettingsActivity { @@ -34,7 +34,7 @@ public abstract class BaseCaldavCalendarSettingsActivity extends BaseListSetting public static final String EXTRA_CALDAV_CALENDAR = "extra_caldav_calendar"; public static final String EXTRA_CALDAV_ACCOUNT = "extra_caldav_account"; - @Inject protected CaldavDao caldavDao; + @Inject protected CaldavDaoBlocking caldavDao; @Inject TaskDeleter taskDeleter; @BindView(R.id.root_layout) diff --git a/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java b/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java index 8db7f661c..1ecf566b0 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java +++ b/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java @@ -27,7 +27,7 @@ import at.bitfire.dav4jvm.property.GetETag; import at.bitfire.dav4jvm.property.SyncToken; import at.bitfire.ical4android.ICalendar; import com.google.common.collect.Iterables; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.helper.UUIDHelper; import com.todoroo.astrid.service.TaskDeleter; @@ -54,7 +54,7 @@ import org.tasks.analytics.Firebase; import org.tasks.billing.Inventory; import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavCalendar; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.data.CaldavTask; import timber.log.Timber; @@ -65,8 +65,8 @@ public class CaldavSynchronizer { new ProdId("+//IDN tasks.org//android-" + BuildConfig.VERSION_CODE + "//EN")); } - private final CaldavDao caldavDao; - private final TaskDao taskDao; + private final CaldavDaoBlocking caldavDao; + private final TaskDaoBlocking taskDao; private final LocalBroadcastManager localBroadcastManager; private final TaskDeleter taskDeleter; private final Inventory inventory; @@ -78,8 +78,8 @@ public class CaldavSynchronizer { @Inject public CaldavSynchronizer( @ApplicationContext Context context, - CaldavDao caldavDao, - TaskDao taskDao, + CaldavDaoBlocking caldavDao, + TaskDaoBlocking taskDao, LocalBroadcastManager localBroadcastManager, TaskDeleter taskDeleter, Inventory inventory, diff --git a/app/src/main/java/org/tasks/caldav/iCalendar.kt b/app/src/main/java/org/tasks/caldav/iCalendar.kt index 86b792748..2b60618d5 100644 --- a/app/src/main/java/org/tasks/caldav/iCalendar.kt +++ b/app/src/main/java/org/tasks/caldav/iCalendar.kt @@ -3,7 +3,7 @@ package org.tasks.caldav import at.bitfire.ical4android.Task import at.bitfire.ical4android.Task.Companion.tasksFromReader import com.todoroo.andlib.utility.DateUtilities -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.helper.UUIDHelper import com.todoroo.astrid.service.TaskCreator import net.fortuna.ical4j.model.Parameter @@ -27,15 +27,15 @@ import javax.inject.Inject @Suppress("ClassName") class iCalendar @Inject constructor( - private val tagDataDao: TagDataDao, + private val tagDataDao: TagDataDaoBlocking, private val preferences: Preferences, - private val locationDao: LocationDao, + private val locationDao: LocationDaoBlocking, private val workManager: WorkManager, private val geofenceApi: GeofenceApi, private val taskCreator: TaskCreator, - private val tagDao: TagDao, - private val taskDao: TaskDao, - private val caldavDao: CaldavDao) { + private val tagDao: TagDaoBlocking, + private val taskDao: TaskDaoBlocking, + private val caldavDao: CaldavDaoBlocking) { companion object { private const val APPLE_SORT_ORDER = "X-APPLE-SORT-ORDER" diff --git a/app/src/main/java/org/tasks/dashclock/DashClockExtension.java b/app/src/main/java/org/tasks/dashclock/DashClockExtension.java index a5ea2bbde..f4b0b6b4d 100644 --- a/app/src/main/java/org/tasks/dashclock/DashClockExtension.java +++ b/app/src/main/java/org/tasks/dashclock/DashClockExtension.java @@ -6,7 +6,7 @@ import android.content.Intent; import com.google.android.apps.dashclock.api.ExtensionData; import com.todoroo.astrid.activity.MainActivity; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import dagger.hilt.android.AndroidEntryPoint; import java.util.List; @@ -21,7 +21,7 @@ import timber.log.Timber; public class DashClockExtension extends com.google.android.apps.dashclock.api.DashClockExtension { @Inject DefaultFilterProvider defaultFilterProvider; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject Preferences preferences; @Inject LocalBroadcastManager localBroadcastManager; diff --git a/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt b/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt new file mode 100644 index 000000000..2158a3397 --- /dev/null +++ b/app/src/main/java/org/tasks/data/AlarmDaoBlocking.kt @@ -0,0 +1,31 @@ +package org.tasks.data + +import androidx.room.Dao +import androidx.room.Delete +import androidx.room.Insert +import androidx.room.Query + +@Dao +interface AlarmDaoBlocking { + @Query("SELECT alarms.* FROM alarms INNER JOIN tasks ON tasks._id = alarms.task " + + "WHERE tasks.completed = 0 AND tasks.deleted = 0 AND tasks.lastNotified < alarms.time " + + "ORDER BY time ASC") + fun getActiveAlarms(): List + + @Query("SELECT alarms.* FROM alarms INNER JOIN tasks ON tasks._id = alarms.task " + + "WHERE tasks._id = :taskId AND tasks.completed = 0 AND tasks.deleted = 0 AND tasks.lastNotified < alarms.time " + + "ORDER BY time ASC") + fun getActiveAlarms(taskId: Long): List + + @Query("SELECT * FROM alarms WHERE task = :taskId ORDER BY time ASC") + fun getAlarms(taskId: Long): List + + @Delete + fun delete(alarm: Alarm) + + @Insert + fun insert(alarm: Alarm): Long + + @Insert + fun insert(alarms: Iterable) +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt b/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt new file mode 100644 index 000000000..d96948426 --- /dev/null +++ b/app/src/main/java/org/tasks/data/CaldavDaoBlocking.kt @@ -0,0 +1,275 @@ +package org.tasks.data + +import android.content.Context +import androidx.lifecycle.LiveData +import androidx.room.* +import com.todoroo.andlib.utility.DateUtilities.now +import com.todoroo.astrid.api.FilterListItem.NO_ORDER +import com.todoroo.astrid.core.SortHelper.APPLE_EPOCH +import com.todoroo.astrid.data.Task +import com.todoroo.astrid.helper.UUIDHelper +import org.tasks.R +import org.tasks.data.CaldavDao.Companion.LOCAL +import org.tasks.date.DateTimeUtils.toAppleEpoch +import org.tasks.db.DbUtils.chunkedMap +import org.tasks.filters.CaldavFilters +import org.tasks.time.DateTimeUtils.currentTimeMillis + +@Dao +abstract class CaldavDaoBlocking { + @Query("SELECT * FROM caldav_lists") + abstract fun subscribeToCalendars(): LiveData> + + @Query("SELECT * FROM caldav_lists WHERE cdl_uuid = :uuid LIMIT 1") + abstract fun getCalendarByUuid(uuid: String): CaldavCalendar? + + @Query("SELECT * FROM caldav_lists WHERE cdl_account = :uuid") + abstract fun getCalendarsByAccount(uuid: String): List + + @Query("SELECT * FROM caldav_accounts WHERE cda_uuid = :uuid LIMIT 1") + abstract fun getAccountByUuid(uuid: String): CaldavAccount? + + @Query("SELECT COUNT(*) FROM caldav_accounts WHERE cda_account_type != 2") + abstract fun accountCount(): Int + + @Query("SELECT * FROM caldav_accounts ORDER BY cda_account_type, UPPER(cda_name)") + abstract fun getAccounts(): List + + @Query("UPDATE caldav_accounts SET cda_collapsed = :collapsed WHERE cda_id = :id") + abstract fun setCollapsed(id: Long, collapsed: Boolean) + + @Insert + abstract fun insert(caldavAccount: CaldavAccount): Long + + @Update + abstract fun update(caldavAccount: CaldavAccount) + + fun insert(caldavCalendar: CaldavCalendar) { + caldavCalendar.id = insertInternal(caldavCalendar) + } + + @Insert + abstract fun insertInternal(caldavCalendar: CaldavCalendar): Long + + @Update + abstract fun update(caldavCalendar: CaldavCalendar) + + @Transaction + open fun insert(task: Task, caldavTask: CaldavTask, addToTop: Boolean): Long { + if (caldavTask.order != null) { + return insert(caldavTask) + } + if (addToTop) { + caldavTask.order = findFirstTask(caldavTask.calendar!!, task.parent) + ?.takeIf { task.creationDate.toAppleEpoch() >= it } + ?.minus(1) + } else { + caldavTask.order = findLastTask(caldavTask.calendar!!, task.parent) + ?.takeIf { task.creationDate.toAppleEpoch() <= it } + ?.plus(1) + } + return insert(caldavTask) + } + + @Query("SELECT MIN(IFNULL(cd_order, (created - $APPLE_EPOCH) / 1000)) FROM caldav_tasks INNER JOIN tasks ON _id = cd_task WHERE cd_calendar = :calendar AND cd_deleted = 0 AND deleted = 0 AND parent = :parent") + internal abstract fun findFirstTask(calendar: String, parent: Long): Long? + + @Query("SELECT MAX(IFNULL(cd_order, (created - $APPLE_EPOCH) / 1000)) FROM caldav_tasks INNER JOIN tasks ON _id = cd_task WHERE cd_calendar = :calendar AND cd_deleted = 0 AND deleted = 0 AND parent = :parent") + internal abstract fun findLastTask(calendar: String, parent: Long): Long? + + @Insert + abstract fun insert(caldavTask: CaldavTask): Long + + @Insert + abstract fun insert(tasks: Iterable) + + @Update + abstract fun update(caldavTask: CaldavTask) + + fun update(caldavTask: SubsetCaldav) { + update(caldavTask.cd_id, caldavTask.cd_order, caldavTask.cd_remote_parent) + } + + @Query("UPDATE caldav_tasks SET cd_order = :position, cd_remote_parent = :parent WHERE cd_id = :id") + internal abstract fun update(id: Long, position: Long?, parent: String?) + + @Query("UPDATE caldav_tasks SET cd_order = :position WHERE cd_id = :id") + internal abstract fun update(id: Long, position: Long?) + + @Query("UPDATE caldav_tasks SET cd_remote_parent = :remoteParent WHERE cd_id = :id") + internal abstract fun update(id: Long, remoteParent: String?) + + @Update + abstract fun update(tasks: Iterable) + + @Delete + abstract fun delete(caldavTask: CaldavTask) + + @Query("SELECT * FROM caldav_tasks WHERE cd_deleted > 0 AND cd_calendar = :calendar") + abstract fun getDeleted(calendar: String): List + + @Query("UPDATE caldav_tasks SET cd_deleted = :now WHERE cd_task IN (:tasks)") + abstract fun markDeleted(tasks: List, now: Long = currentTimeMillis()) + + @Query("SELECT * FROM caldav_tasks WHERE cd_task = :taskId AND cd_deleted = 0 LIMIT 1") + abstract fun getTask(taskId: Long): CaldavTask? + + @Query("SELECT cd_remote_id FROM caldav_tasks WHERE cd_task = :taskId AND cd_deleted = 0") + abstract fun getRemoteIdForTask(taskId: Long): String? + + @Query("SELECT * FROM caldav_tasks WHERE cd_calendar = :calendar AND cd_object = :obj LIMIT 1") + abstract fun getTask(calendar: String, obj: String): CaldavTask? + + @Query("SELECT * FROM caldav_tasks WHERE cd_calendar = :calendar AND cd_remote_id = :remoteId") + abstract fun getTaskByRemoteId(calendar: String, remoteId: String): CaldavTask? + + @Query("SELECT * FROM caldav_tasks WHERE cd_task = :taskId") + abstract fun getTasks(taskId: Long): List + + @Query("SELECT * FROM caldav_tasks WHERE cd_task in (:taskIds) AND cd_deleted = 0") + abstract fun getTasks(taskIds: List): List + + @Query("SELECT task.*, caldav_task.* FROM tasks AS task " + + "INNER JOIN caldav_tasks AS caldav_task ON _id = cd_task " + + "WHERE cd_deleted = 0 AND cd_vtodo IS NOT NULL AND cd_vtodo != ''") + abstract fun getTasks(): List + + @Query("SELECT task.*, caldav_task.* FROM tasks AS task " + + "INNER JOIN caldav_tasks AS caldav_task ON _id = cd_task " + + "WHERE cd_calendar = :calendar " + + "AND modified > cd_last_sync " + + "AND cd_deleted = 0") + abstract fun getCaldavTasksToPush(calendar: String): List + + @Query("SELECT * FROM caldav_lists ORDER BY cdl_name COLLATE NOCASE") + abstract fun getCalendars(): List + + @Query("SELECT * FROM caldav_lists WHERE cdl_uuid = :uuid LIMIT 1") + abstract fun getCalendar(uuid: String): CaldavCalendar? + + @Query("SELECT cd_object FROM caldav_tasks WHERE cd_calendar = :calendar") + abstract fun getObjects(calendar: String): List + + fun getTasks(calendar: String, objects: List): List = + objects.chunkedMap { getTasksInternal(calendar, it) } + + @Query("SELECT cd_task FROM caldav_tasks WHERE cd_calendar = :calendar AND cd_object IN (:objects)") + abstract fun getTasksInternal(calendar: String, objects: List): List + + @Query("SELECT * FROM caldav_lists WHERE cdl_account = :account AND cdl_url NOT IN (:urls)") + abstract fun findDeletedCalendars(account: String, urls: List): List + + @Query("SELECT * FROM caldav_lists WHERE cdl_account = :account AND cdl_url = :url LIMIT 1") + abstract fun getCalendarByUrl(account: String, url: String): CaldavCalendar? + + @Query("SELECT caldav_accounts.* from caldav_accounts" + + " INNER JOIN caldav_tasks ON cd_task = :task" + + " INNER JOIN caldav_lists ON cd_calendar = cdl_uuid" + + " WHERE cdl_account = cda_uuid") + abstract fun getAccountForTask(task: Long): CaldavAccount? + + @Query("SELECT DISTINCT cd_calendar FROM caldav_tasks WHERE cd_deleted = 0 AND cd_task IN (:tasks)") + abstract fun getCalendars(tasks: List): List + + @Query("SELECT caldav_lists.*, COUNT(tasks._id) AS count" + + " FROM caldav_lists" + + " LEFT JOIN caldav_tasks ON caldav_tasks.cd_calendar = caldav_lists.cdl_uuid" + + " LEFT JOIN tasks ON caldav_tasks.cd_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND cd_deleted = 0" + + " WHERE caldav_lists.cdl_account = :uuid" + + " GROUP BY caldav_lists.cdl_uuid") + abstract fun getCaldavFilters(uuid: String, now: Long = currentTimeMillis()): List + + @Query("SELECT tasks._id FROM tasks " + + "INNER JOIN tags ON tags.task = tasks._id " + + "INNER JOIN caldav_tasks ON cd_task = tasks._id " + + "GROUP BY tasks._id") + abstract fun getTasksWithTags(): List + + @Query("UPDATE tasks SET parent = IFNULL((" + + " SELECT p.cd_task FROM caldav_tasks AS p" + + " INNER JOIN caldav_tasks ON caldav_tasks.cd_task = tasks._id" + + " WHERE p.cd_remote_id = caldav_tasks.cd_remote_parent" + + " AND p.cd_calendar = caldav_tasks.cd_calendar" + + " AND p.cd_deleted = 0), 0)" + + "WHERE _id IN (SELECT _id FROM tasks INNER JOIN caldav_tasks ON _id = cd_task WHERE cd_deleted = 0)") + abstract fun updateParents() + + @Query("UPDATE tasks SET parent = IFNULL((" + + " SELECT p.cd_task FROM caldav_tasks AS p" + + " INNER JOIN caldav_tasks " + + " ON caldav_tasks.cd_task = tasks._id" + + " AND caldav_tasks.cd_calendar = :calendar" + + " WHERE p.cd_remote_id = caldav_tasks.cd_remote_parent" + + " AND p.cd_calendar = caldav_tasks.cd_calendar" + + " AND caldav_tasks.cd_deleted = 0), 0)" + + "WHERE _id IN (SELECT _id FROM tasks INNER JOIN caldav_tasks ON _id = cd_task WHERE cd_deleted = 0 AND cd_calendar = :calendar)") + abstract fun updateParents(calendar: String) + + @Transaction + open fun move(task: TaskContainer, newParent: Long, newPosition: Long?) { + val previousParent = task.parent + val caldavTask = task.caldavTask + val previousPosition = task.caldavSortOrder + if (newPosition != null) { + if (newParent == previousParent && newPosition < previousPosition) { + shiftDown(task.caldav!!, newParent, newPosition, previousPosition) + } else { + shiftDown(task.caldav!!, newParent, newPosition) + } + } + caldavTask.cd_order = newPosition + update(caldavTask.cd_id, caldavTask.cd_order) + } + + @Transaction + open fun shiftDown(calendar: String, parent: Long, from: Long, to: Long? = null) { + val updated = ArrayList() + val tasks = getTasksToShift(calendar, parent, from, to) + for (i in tasks.indices) { + val task = tasks[i] + val current = from + i + if (task.sortOrder == current) { + val caldavTask = task.caldavTask + caldavTask.order = current + 1 + updated.add(caldavTask) + } else if (task.sortOrder > current) { + break + } + } + update(updated) + touchInternal(updated.map(CaldavTask::task)) + } + + @Query("UPDATE tasks SET modified = :modificationTime WHERE _id in (:ids)") + internal abstract fun touchInternal(ids: List, modificationTime: Long = now()) + + @Query("SELECT task.*, caldav_task.*, IFNULL(cd_order, (created - $APPLE_EPOCH) / 1000) AS primary_sort FROM caldav_tasks AS caldav_task INNER JOIN tasks AS task ON _id = cd_task WHERE cd_calendar = :calendar AND parent = :parent AND cd_deleted = 0 AND deleted = 0 AND primary_sort >= :from AND primary_sort < IFNULL(:to, ${Long.MAX_VALUE}) ORDER BY primary_sort") + internal abstract fun getTasksToShift(calendar: String, parent: Long, from: Long, to: Long?): List + + @Query("UPDATE caldav_lists SET cdl_order = $NO_ORDER") + abstract fun resetOrders() + + @Query("UPDATE caldav_lists SET cdl_order = :order WHERE cdl_id = :id") + abstract fun setOrder(id: Long, order: Int) + + fun setupLocalAccount(context: Context): CaldavAccount { + val account = getLocalAccount() + getLocalList(context, account) + return account + } + + fun getLocalList(context: Context) = getLocalList(context, getLocalAccount()) + + private fun getLocalAccount() = getAccountByUuid(LOCAL) ?: CaldavAccount().apply { + accountType = CaldavAccount.TYPE_LOCAL + uuid = LOCAL + id = insert(this) + } + + private fun getLocalList(context: Context, account: CaldavAccount): CaldavCalendar = + getCalendarsByAccount(account.uuid!!).getOrNull(0) + ?: CaldavCalendar(context.getString(R.string.default_list), UUIDHelper.newUUID()).apply { + this.account = account.uuid + insert(this) + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt b/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt new file mode 100644 index 000000000..5407fc46b --- /dev/null +++ b/app/src/main/java/org/tasks/data/ContentProviderDaoBlocking.kt @@ -0,0 +1,47 @@ +package org.tasks.data + +import android.database.Cursor +import androidx.room.Dao +import androidx.room.Query +import androidx.room.RawQuery +import androidx.sqlite.db.SupportSQLiteQuery +import com.todoroo.astrid.data.Task + +@Dao +interface ContentProviderDaoBlocking { + @Query("SELECT name FROM tags WHERE task = :taskId ORDER BY UPPER(name) ASC") + fun getTagNames(taskId: Long): List + + @Query(""" + SELECT * + FROM tasks + WHERE completed = 0 + AND deleted = 0 + AND hideUntil < (strftime('%s', 'now') * 1000) + ORDER BY (CASE + WHEN (dueDate = 0) THEN + (strftime('%s', 'now') * 1000) * 2 + ELSE ((CASE WHEN (dueDate / 1000) % 60 > 0 THEN dueDate ELSE (dueDate + 43140000) END)) END) + + 172800000 * importance + ASC + LIMIT 100""") + fun getAstrid2TaskProviderTasks(): List + + @Query("SELECT * FROM tagdata WHERE name IS NOT NULL AND name != '' ORDER BY UPPER(name) ASC") + fun tagDataOrderedByName(): List + + @Query("SELECT * FROM tasks") + fun getTasks(): Cursor + + @Query(""" + SELECT caldav_lists.*, caldav_accounts.cda_name + FROM caldav_lists + INNER JOIN caldav_accounts ON cdl_account = cda_uuid""") + fun getLists(): Cursor + + @Query("SELECT * FROM google_task_lists") + fun getGoogleTaskLists(): Cursor + + @RawQuery + fun rawQuery(query: SupportSQLiteQuery): Cursor +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt b/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt new file mode 100644 index 000000000..2ab6e89a4 --- /dev/null +++ b/app/src/main/java/org/tasks/data/DeletionDaoBlocking.kt @@ -0,0 +1,114 @@ +package org.tasks.data + +import androidx.room.Dao +import androidx.room.Delete +import androidx.room.Query +import androidx.room.Transaction +import org.tasks.data.CaldavDao.Companion.LOCAL +import org.tasks.db.DbUtils.eachChunk +import java.util.* + +@Dao +abstract class DeletionDaoBlocking { + @Query("DELETE FROM caldav_tasks WHERE cd_task IN(:ids)") + abstract fun deleteCaldavTasks(ids: List) + + @Query("DELETE FROM google_tasks WHERE gt_task IN(:ids)") + abstract fun deleteGoogleTasks(ids: List) + + @Query("DELETE FROM tags WHERE task IN(:ids)") + abstract fun deleteTags(ids: List) + + @Query("DELETE FROM geofences WHERE task IN(:ids)") + abstract fun deleteGeofences(ids: List) + + @Query("DELETE FROM alarms WHERE task IN(:ids)") + abstract fun deleteAlarms(ids: List) + + @Query("DELETE FROM tasks WHERE _id IN(:ids)") + abstract fun deleteTasks(ids: List) + + @Transaction + open fun delete(ids: List) { + ids.eachChunk { + deleteAlarms(it) + deleteGeofences(it) + deleteTags(it) + deleteGoogleTasks(it) + deleteCaldavTasks(it) + deleteTasks(it) + } + } + + @Query("UPDATE tasks " + + "SET modified = (strftime('%s','now')*1000), deleted = (strftime('%s','now')*1000)" + + "WHERE _id IN(:ids)") + abstract fun markDeletedInternal(ids: List) + + fun markDeleted(ids: Iterable) { + ids.eachChunk(this::markDeletedInternal) + } + + @Query("SELECT gt_task FROM google_tasks WHERE gt_deleted = 0 AND gt_list_id = :listId") + abstract fun getActiveGoogleTasks(listId: String): List + + @Delete + abstract fun deleteGoogleTaskList(googleTaskList: GoogleTaskList) + + @Transaction + open fun delete(googleTaskList: GoogleTaskList): List { + val tasks = getActiveGoogleTasks(googleTaskList.remoteId!!) + delete(tasks) + deleteGoogleTaskList(googleTaskList) + return tasks + } + + @Delete + abstract fun deleteGoogleTaskAccount(googleTaskAccount: GoogleTaskAccount) + + @Query("SELECT * FROM google_task_lists WHERE gtl_account = :account ORDER BY gtl_title ASC") + abstract fun getLists(account: String): List + + @Transaction + open fun delete(googleTaskAccount: GoogleTaskAccount): List { + val deleted = ArrayList() + for (list in getLists(googleTaskAccount.account!!)) { + deleted.addAll(delete(list)) + } + deleteGoogleTaskAccount(googleTaskAccount) + return deleted + } + + @Query("SELECT cd_task FROM caldav_tasks WHERE cd_calendar = :calendar AND cd_deleted = 0") + abstract fun getActiveCaldavTasks(calendar: String): List + + @Delete + abstract fun deleteCaldavCalendar(caldavCalendar: CaldavCalendar) + + @Transaction + open fun delete(caldavCalendar: CaldavCalendar): List { + val tasks = getActiveCaldavTasks(caldavCalendar.uuid!!) + delete(tasks) + deleteCaldavCalendar(caldavCalendar) + return tasks + } + + @Query("SELECT * FROM caldav_lists WHERE cdl_account = :account") + abstract fun getCalendars(account: String): List + + @Delete + abstract fun deleteCaldavAccount(caldavAccount: CaldavAccount) + + @Query("DELETE FROM tasks WHERE _id IN (SELECT _id FROM tasks INNER JOIN caldav_tasks ON _id = cd_task INNER JOIN caldav_lists ON cdl_uuid = cd_calendar WHERE cdl_account = '$LOCAL' AND deleted > 0)") + abstract fun purgeDeleted() + + @Transaction + open fun delete(caldavAccount: CaldavAccount): List { + val deleted = ArrayList() + for (calendar in getCalendars(caldavAccount.uuid!!)) { + deleted.addAll(delete(calendar)) + } + deleteCaldavAccount(caldavAccount) + return deleted + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt b/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt new file mode 100644 index 000000000..4e6d027b2 --- /dev/null +++ b/app/src/main/java/org/tasks/data/FilterDaoBlocking.kt @@ -0,0 +1,37 @@ +package org.tasks.data + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.Query +import androidx.room.Update +import com.todoroo.astrid.api.FilterListItem.NO_ORDER + +@Dao +interface FilterDaoBlocking { + @Update + fun update(filter: Filter) + + @Query("DELETE FROM filters WHERE _id = :id") + fun delete(id: Long) + + @Query("SELECT * FROM filters WHERE title = :title COLLATE NOCASE LIMIT 1") + fun getByName(title: String): Filter? + + @Insert + fun insert(filter: Filter): Long + + @Query("SELECT * FROM filters") + fun getFilters(): List + + @Query("SELECT * FROM filters WHERE _id = :id LIMIT 1") + fun getById(id: Long): Filter? + + @Query("SELECT * FROM filters") + fun getAll(): List + + @Query("UPDATE filters SET f_order = $NO_ORDER") + fun resetOrders() + + @Query("UPDATE filters SET f_order = :order WHERE _id = :id") + fun setOrder(id: Long, order: Int) +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt b/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt new file mode 100644 index 000000000..7f833e580 --- /dev/null +++ b/app/src/main/java/org/tasks/data/GoogleTaskDaoBlocking.kt @@ -0,0 +1,179 @@ +package org.tasks.data + +import androidx.room.* +import com.todoroo.astrid.data.Task +import org.tasks.time.DateTimeUtils.currentTimeMillis + +@Dao +abstract class GoogleTaskDaoBlocking { + @Insert + abstract fun insert(task: GoogleTask): Long + + @Insert + abstract fun insert(tasks: Iterable) + + @Transaction + open fun insertAndShift(task: GoogleTask, top: Boolean) { + if (top) { + task.order = 0 + shiftDown(task.listId!!, task.parent, 0) + } else { + task.order = getBottom(task.listId!!, task.parent) + } + task.id = insert(task) + } + + @Query("UPDATE google_tasks SET gt_order = gt_order + 1 WHERE gt_list_id = :listId AND gt_parent = :parent AND gt_order >= :position") + abstract fun shiftDown(listId: String, parent: Long, position: Long) + + @Query("UPDATE google_tasks SET gt_order = gt_order - 1 WHERE gt_list_id = :listId AND gt_parent = :parent AND gt_order > :from AND gt_order <= :to") + abstract fun shiftUp(listId: String, parent: Long, from: Long, to: Long) + + @Query("UPDATE google_tasks SET gt_order = gt_order + 1 WHERE gt_list_id = :listId AND gt_parent = :parent AND gt_order < :from AND gt_order >= :to") + abstract fun shiftDown(listId: String, parent: Long, from: Long, to: Long) + + @Query("UPDATE google_tasks SET gt_order = gt_order - 1 WHERE gt_list_id = :listId AND gt_parent = :parent AND gt_order >= :position") + abstract fun shiftUp(listId: String, parent: Long, position: Long) + + @Transaction + open fun move(task: SubsetGoogleTask, newParent: Long, newPosition: Long) { + val previousParent = task.parent + val previousPosition = task.order + if (newParent == previousParent) { + if (previousPosition < newPosition) { + shiftUp(task.listId, newParent, previousPosition, newPosition) + } else { + shiftDown(task.listId, newParent, previousPosition, newPosition) + } + } else { + shiftUp(task.listId, previousParent, previousPosition) + shiftDown(task.listId, newParent, newPosition) + } + task.parent = newParent + task.order = newPosition + update(task) + } + + @Query("UPDATE google_task_accounts SET gta_collapsed = :collapsed WHERE gta_id = :id") + abstract fun setCollapsed(id: Long, collapsed: Boolean) + + @Query("SELECT * FROM google_tasks WHERE gt_task = :taskId AND gt_deleted = 0 LIMIT 1") + abstract fun getByTaskId(taskId: Long): GoogleTask? + + @Update + abstract fun update(googleTask: GoogleTask) + + private fun update(googleTask: SubsetGoogleTask) { + update(googleTask.id, googleTask.parent, googleTask.order) + } + + @Query("UPDATE google_tasks SET gt_order = :order, gt_parent = :parent, gt_moved = 1 WHERE gt_id = :id") + abstract fun update(id: Long, parent: Long, order: Long) + + @Query("UPDATE google_tasks SET gt_deleted = :now WHERE gt_task = :task OR gt_parent = :task") + abstract fun markDeleted(task: Long, now: Long = currentTimeMillis()) + + @Delete + abstract fun delete(deleted: GoogleTask) + + @Query("SELECT * FROM google_tasks WHERE gt_remote_id = :remoteId LIMIT 1") + abstract fun getByRemoteId(remoteId: String): GoogleTask? + + @Query("SELECT * FROM google_tasks WHERE gt_task = :taskId AND gt_deleted > 0") + abstract fun getDeletedByTaskId(taskId: Long): List + + @Query("SELECT * FROM google_tasks WHERE gt_task = :taskId") + abstract fun getAllByTaskId(taskId: Long): List + + @Query("SELECT DISTINCT gt_list_id FROM google_tasks WHERE gt_deleted = 0 AND gt_task IN (:tasks)") + abstract fun getLists(tasks: List): List + + @Query("SELECT gt_task FROM google_tasks WHERE gt_parent IN (:ids) AND gt_deleted = 0") + abstract fun getChildren(ids: List): List + + @Query("SELECT tasks.* FROM tasks JOIN google_tasks ON tasks._id = gt_task WHERE gt_parent = :taskId") + abstract fun getChildTasks(taskId: Long): List + + @Query("SELECT * FROM google_tasks WHERE gt_parent = :id AND gt_deleted = 0") + abstract fun getChildren(id: Long): List + + @Query("SELECT IFNULL(MAX(gt_order), -1) + 1 FROM google_tasks WHERE gt_list_id = :listId AND gt_parent = :parent") + abstract fun getBottom(listId: String, parent: Long): Long + + @Query("SELECT gt_remote_id FROM google_tasks JOIN tasks ON tasks._id = gt_task WHERE deleted = 0 AND gt_list_id = :listId AND gt_parent = :parent AND gt_order < :order AND gt_remote_id IS NOT NULL AND gt_remote_id != '' ORDER BY gt_order DESC") + abstract fun getPrevious(listId: String, parent: Long, order: Long): String? + + @Query("SELECT gt_remote_id FROM google_tasks WHERE gt_task = :task") + abstract fun getRemoteId(task: Long): String? + + @Query("SELECT gt_task FROM google_tasks WHERE gt_remote_id = :remoteId") + abstract fun getTask(remoteId: String): Long + + @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) + @Query("SELECT google_tasks.*, gt_order AS primary_sort, NULL AS secondary_sort FROM google_tasks JOIN tasks ON tasks._id = gt_task WHERE gt_parent = 0 AND gt_list_id = :listId AND tasks.deleted = 0 UNION SELECT c.*, p.gt_order AS primary_sort, c.gt_order AS secondary_sort FROM google_tasks AS c LEFT JOIN google_tasks AS p ON c.gt_parent = p.gt_task JOIN tasks ON tasks._id = c.gt_task WHERE c.gt_parent > 0 AND c.gt_list_id = :listId AND tasks.deleted = 0 ORDER BY primary_sort ASC, secondary_sort ASC") + abstract fun getByLocalOrder(listId: String): List + + @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) + @Query("SELECT google_tasks.*, gt_remote_order AS primary_sort, NULL AS secondary_sort FROM google_tasks JOIN tasks ON tasks._id = gt_task WHERE gt_parent = 0 AND gt_list_id = :listId AND tasks.deleted = 0 UNION SELECT c.*, p.gt_remote_order AS primary_sort, c.gt_remote_order AS secondary_sort FROM google_tasks AS c LEFT JOIN google_tasks AS p ON c.gt_parent = p.gt_task JOIN tasks ON tasks._id = c.gt_task WHERE c.gt_parent > 0 AND c.gt_list_id = :listId AND tasks.deleted = 0 ORDER BY primary_sort ASC, secondary_sort ASC") + abstract fun getByRemoteOrder(listId: String): List + + @Query("UPDATE google_tasks" + + " SET gt_parent = IFNULL((" + + " SELECT gt_task FROM google_tasks AS p" + + " WHERE p.gt_remote_id = google_tasks.gt_remote_parent" + + " AND p.gt_list_id = google_tasks.gt_list_id " + + " AND p.gt_deleted = 0)," + + " 0)" + + " WHERE gt_moved = 0") + abstract fun updateParents() + + @Query("UPDATE google_tasks SET gt_parent = IFNULL((SELECT gt_task FROM google_tasks AS p WHERE p.gt_remote_id = google_tasks.gt_remote_parent), 0) WHERE gt_list_id = :listId AND gt_moved = 0") + abstract fun updateParents(listId: String) + + @Query("UPDATE google_tasks SET gt_remote_parent = :parent, gt_remote_order = :position WHERE gt_remote_id = :id") + abstract fun updatePosition(id: String, parent: String, position: String) + + @Transaction + open fun reposition(listId: String) { + updateParents(listId) + val orderedTasks = getByRemoteOrder(listId) + var subtasks = 0L + var parent = 0L + for (task in orderedTasks) { + if (task.parent > 0) { + if (task.order != subtasks && !task.isMoved) { + task.order = subtasks + update(task) + } + subtasks++ + } else { + subtasks = 0 + if (task.order != parent && !task.isMoved) { + task.order = parent + update(task) + } + parent++ + } + } + } + + fun validateSorting(listId: String) { + val orderedTasks = getByLocalOrder(listId) + var subtasks = 0L + var parent = 0L + for (task in orderedTasks) { + if (task.parent > 0) { + if (task.order != subtasks) { + throw IllegalStateException("Subtask violation, expected $subtasks but was ${task.order}") + } + subtasks++ + } else { + subtasks = 0 + if (task.order != parent) { + throw IllegalStateException("Parent violation, expected $parent but was ${task.order}") + } + parent++ + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt b/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt new file mode 100644 index 000000000..359da9337 --- /dev/null +++ b/app/src/main/java/org/tasks/data/GoogleTaskListDaoBlocking.kt @@ -0,0 +1,72 @@ +package org.tasks.data + +import androidx.lifecycle.LiveData +import androidx.room.* +import com.todoroo.astrid.api.FilterListItem.NO_ORDER +import org.tasks.filters.GoogleTaskFilters +import org.tasks.time.DateTimeUtils.currentTimeMillis + +@Dao +interface GoogleTaskListDaoBlocking { + @Query("SELECT COUNT(*) FROM google_task_accounts") + fun accountCount(): Int + + @Query("SELECT * FROM google_task_accounts") + fun getAccounts(): List + + @Query("SELECT * FROM google_task_accounts WHERE gta_account = :account COLLATE NOCASE LIMIT 1") + fun getAccount(account: String): GoogleTaskAccount? + + @Query("SELECT * FROM google_task_lists WHERE gtl_id = :id") + fun getById(id: Long): GoogleTaskList? + + @Query("SELECT * FROM google_task_lists WHERE gtl_account = :account ORDER BY gtl_title ASC") + fun getLists(account: String): List + + @Query("SELECT * FROM google_task_lists WHERE gtl_remote_id = :remoteId LIMIT 1") + fun getByRemoteId(remoteId: String): GoogleTaskList? + + @Query("SELECT * FROM google_task_lists WHERE gtl_remote_id IN (:remoteIds)") + fun getByRemoteId(remoteIds: List): List + + @Query("SELECT * FROM google_task_lists") + fun subscribeToLists(): LiveData> + + @Query("SELECT * FROM google_task_lists WHERE gtl_remote_id = :remoteId AND IFNULL(gtl_account, '') = ''") + fun findExistingList(remoteId: String): GoogleTaskList? + + @Query("SELECT * FROM google_task_lists") + fun getAllLists(): List + + @Query("UPDATE google_task_lists SET gtl_last_sync = 0 WHERE gtl_account = :account") + fun resetLastSync(account: String) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertOrReplace(googleTaskList: GoogleTaskList): Long + + @Insert + fun insert(googleTaskList: GoogleTaskList): Long + + @Insert + fun insert(googleTaskAccount: GoogleTaskAccount) + + @Update + fun update(account: GoogleTaskAccount) + + @Update + fun update(list: GoogleTaskList) + + @Query("SELECT google_task_lists.*, COUNT(tasks._id) AS count" + + " FROM google_task_lists " + + " LEFT JOIN google_tasks ON google_tasks.gt_list_id = google_task_lists.gtl_remote_id" + + " LEFT JOIN tasks ON google_tasks.gt_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND gt_deleted = 0" + + " WHERE google_task_lists.gtl_account = :account" + + " GROUP BY google_task_lists.gtl_remote_id") + fun getGoogleTaskFilters(account: String, now: Long = currentTimeMillis()): List + + @Query("UPDATE google_task_lists SET gtl_remote_order = $NO_ORDER") + fun resetOrders() + + @Query("UPDATE google_task_lists SET gtl_remote_order = :order WHERE gtl_id = :id") + fun setOrder(id: Long, order: Int) +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt b/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt new file mode 100644 index 000000000..fe0fa514d --- /dev/null +++ b/app/src/main/java/org/tasks/data/LocationDaoBlocking.kt @@ -0,0 +1,118 @@ +package org.tasks.data + +import androidx.lifecycle.LiveData +import androidx.room.* +import com.todoroo.astrid.api.FilterListItem.NO_ORDER +import org.tasks.filters.LocationFilters +import org.tasks.time.DateTimeUtils.currentTimeMillis + +@Dao +interface LocationDaoBlocking { + @Query("SELECT places.*" + + " FROM places" + + " INNER JOIN geofences ON geofences.place = places.uid" + + " INNER JOIN tasks ON geofences.task = tasks._id" + + " WHERE tasks.completed = 0 AND tasks.deleted = 0" + + " AND (geofences.arrival > 0 OR geofences.departure > 0)" + + " GROUP BY places.uid") + fun getPlacesWithGeofences(): List + + @Query("SELECT places.*," + + " max(geofences.arrival) as arrival," + + " max(geofences.departure) as departure," + + " min(geofences.radius) as radius" + + " FROM places" + + " INNER JOIN geofences ON geofences.place = places.uid" + + " INNER JOIN tasks ON tasks._id = geofences.task" + + " WHERE place = :uid AND tasks.completed = 0 AND tasks.deleted = 0" + + " AND (geofences.arrival > 0 OR geofences.departure > 0)" + + " GROUP BY places.uid") + fun getGeofencesByPlace(uid: String): MergedGeofence? + + @Query("DELETE FROM geofences WHERE place = :place") + fun deleteGeofencesByPlace(place: String) + + @Query("SELECT geofences.* FROM geofences" + + " INNER JOIN tasks ON tasks._id = geofences.task" + + " WHERE place = :place AND arrival = 1 AND tasks.completed = 0" + + " AND tasks.deleted = 0 AND tasks.snoozeTime < :now AND tasks.hideUntil < :now") + fun getArrivalGeofences(place: String, now: Long): List + + @Query("SELECT geofences.* FROM geofences" + + " INNER JOIN tasks ON tasks._id = geofences.task" + + " WHERE place = :place AND departure = 1 AND tasks.completed = 0" + + " AND tasks.deleted = 0 AND tasks.snoozeTime < :now AND tasks.hideUntil < :now") + fun getDepartureGeofences(place: String, now: Long): List + + @Query("SELECT * FROM geofences" + + " INNER JOIN places ON geofences.place = places.uid" + + " WHERE task = :taskId ORDER BY name ASC LIMIT 1") + fun getGeofences(taskId: Long): Location? + + @Query("SELECT geofences.*, places.* FROM geofences INNER JOIN places ON geofences.place = places.uid INNER JOIN tasks ON tasks._id = geofences.task WHERE tasks._id = :taskId AND tasks.deleted = 0 AND tasks.completed = 0") + fun getActiveGeofences(taskId: Long): List + + @Query("SELECT places.*" + + " FROM places" + + " INNER JOIN geofences ON geofences.place = places.uid" + + " WHERE geofences.task = :taskId") + fun getPlaceForTask(taskId: Long): Place? + + @Query("SELECT geofences.*, places.* FROM geofences INNER JOIN places ON geofences.place = places.uid INNER JOIN tasks ON tasks._id = geofences.task WHERE tasks.deleted = 0 AND tasks.completed = 0") + fun getActiveGeofences(): List + + @Query("SELECT COUNT(*) FROM geofences") + suspend fun geofenceCount(): Int + + @Delete + fun delete(location: Geofence) + + @Delete + fun delete(place: Place) + + @Insert + fun insert(location: Geofence): Long + + @Insert(onConflict = OnConflictStrategy.IGNORE) + fun insert(place: Place): Long + + @Update + fun update(place: Place) + + @Update + fun update(geofence: Geofence) + + @Query("SELECT * FROM places WHERE uid = :uid LIMIT 1") + fun getByUid(uid: String): Place? + + @Query("SELECT * FROM geofences WHERE task = :taskId") + fun getGeofencesForTask(taskId: Long): List + + @Query("SELECT * FROM places") + fun getPlaces(): List + + @Query("SELECT * FROM places WHERE place_id = :id") + fun getPlace(id: Long): Place? + + @Query("SELECT * FROM places WHERE uid = :uid") + fun getPlace(uid: String): Place? + + @Query("SELECT places.*, IFNULL(COUNT(geofence_id),0) AS count FROM places LEFT OUTER JOIN geofences ON geofences.place = places.uid GROUP BY uid ORDER BY COUNT(geofence_id) DESC") + fun getPlaceUsage(): LiveData> + + @Query("SELECT * FROM places WHERE latitude LIKE :latitude AND longitude LIKE :longitude") + fun findPlace(latitude: String, longitude: String): Place? + + @Query("SELECT places.*, COUNT(tasks._id) AS count FROM places " + + " LEFT JOIN geofences ON geofences.place = places.uid " + + " LEFT JOIN tasks ON geofences.task = tasks._id AND tasks.completed = 0 AND tasks.deleted = 0 AND tasks.hideUntil < :now" + + " GROUP BY places.uid" + + " ORDER BY name COLLATE NOCASE ASC") + fun getPlaceFilters(now: Long = currentTimeMillis()): List + + @Query("UPDATE places SET place_order = $NO_ORDER") + fun resetOrders() + + @Query("UPDATE places SET place_order = :order WHERE place_id = :id") + fun setOrder(id: Long, order: Int) +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/TagDao.kt b/app/src/main/java/org/tasks/data/TagDao.kt index 3f0d683c1..ca9dc57c9 100644 --- a/app/src/main/java/org/tasks/data/TagDao.kt +++ b/app/src/main/java/org/tasks/data/TagDao.kt @@ -30,7 +30,7 @@ abstract class TagDao { abstract fun delete(tags: List) @Transaction - open fun applyTags(task: Task, tagDataDao: TagDataDao, current: List): Boolean { + open fun applyTags(task: Task, tagDataDao: TagDataDaoBlocking, current: List): Boolean { val taskId = task.id val existing = HashSet(tagDataDao.getTagDataForTask(taskId)) val selected = HashSet(current) diff --git a/app/src/main/java/org/tasks/data/TagDaoBlocking.kt b/app/src/main/java/org/tasks/data/TagDaoBlocking.kt new file mode 100644 index 000000000..4f051f62a --- /dev/null +++ b/app/src/main/java/org/tasks/data/TagDaoBlocking.kt @@ -0,0 +1,49 @@ +package org.tasks.data + +import androidx.room.* +import com.todoroo.astrid.data.Task + +@Dao +abstract class TagDaoBlocking { + @Query("UPDATE tags SET name = :name WHERE tag_uid = :tagUid") + abstract fun rename(tagUid: String, name: String) + + @Insert + abstract fun insert(tag: Tag) + + @Insert + abstract fun insert(tags: Iterable) + + @Query("DELETE FROM tags WHERE task = :taskId AND tag_uid in (:tagUids)") + abstract fun deleteTags(taskId: Long, tagUids: List) + + @Query("SELECT * FROM tags WHERE tag_uid = :tagUid") + abstract fun getByTagUid(tagUid: String): List + + @Query("SELECT * FROM tags WHERE task = :taskId") + abstract fun getTagsForTask(taskId: Long): List + + @Query("SELECT * FROM tags WHERE task = :taskId AND tag_uid = :tagUid") + abstract fun getTagByTaskAndTagUid(taskId: Long, tagUid: String): Tag? + + @Delete + abstract fun delete(tags: List) + + @Transaction + open fun applyTags(task: Task, tagDataDao: TagDataDaoBlocking, current: List): Boolean { + val taskId = task.id + val existing = HashSet(tagDataDao.getTagDataForTask(taskId)) + val selected = HashSet(current) + val added = selected subtract existing + val removed = existing subtract selected + deleteTags(taskId, removed.map { td -> td.remoteId!! }) + insert(task, added) + return removed.isNotEmpty() || added.isNotEmpty() + } + + fun insert(task: Task, tags: Collection) { + if (!tags.isEmpty()) { + insert(tags.map { Tag(task, it) }) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt b/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt new file mode 100644 index 000000000..61ceb6651 --- /dev/null +++ b/app/src/main/java/org/tasks/data/TagDataDaoBlocking.kt @@ -0,0 +1,158 @@ +package org.tasks.data + +import androidx.core.util.Pair +import androidx.lifecycle.LiveData +import androidx.room.* +import com.todoroo.astrid.api.FilterListItem.NO_ORDER +import com.todoroo.astrid.data.Task +import com.todoroo.astrid.helper.UUIDHelper +import org.tasks.db.DbUtils +import org.tasks.filters.AlphanumComparator +import org.tasks.filters.TagFilters +import org.tasks.time.DateTimeUtils.currentTimeMillis +import java.util.* +import kotlin.collections.HashSet + +@Dao +abstract class TagDataDaoBlocking { + @Query("SELECT * FROM tagdata") + abstract fun subscribeToTags(): LiveData> + + @Query("SELECT * FROM tagdata WHERE name = :name COLLATE NOCASE LIMIT 1") + abstract fun getTagByName(name: String): TagData? + + /** + * If a tag already exists in the database that case insensitively matches the given tag, return + * that. Otherwise, return the argument + */ + fun getTagWithCase(tag: String): String? { + return getTagByName(tag)?.name ?: tag + } + + fun searchTags(query: String): List { + return searchTagsInternal("%$query%") + .sortedWith(AlphanumComparator(TagData::name)) + .toMutableList() + } + + @Query("SELECT * FROM tagdata WHERE name LIKE :query AND name NOT NULL AND name != ''") + protected abstract fun searchTagsInternal(query: String): List + + @Query("SELECT * FROM tagdata") + abstract fun getAll(): List + + @Query("SELECT * FROM tagdata WHERE remoteId = :uuid LIMIT 1") + abstract fun getByUuid(uuid: String): TagData? + + @Query("SELECT * FROM tagdata WHERE remoteId IN (:uuids)") + abstract fun getByUuid(uuids: Collection): List + + @Query("SELECT * FROM tagdata WHERE name IS NOT NULL AND name != '' ORDER BY UPPER(name) ASC") + abstract fun tagDataOrderedByName(): List + + @Delete + abstract fun deleteTagData(tagData: TagData) + + @Query("DELETE FROM tags WHERE tag_uid = :tagUid") + abstract fun deleteTags(tagUid: String) + + @Query("SELECT * FROM tags WHERE task IN (:tasks) AND tag_uid NOT IN (:tagsToKeep)") + abstract fun tagsToDelete(tasks: List, tagsToKeep: List): List + + fun getTagSelections(tasks: List): Pair, Set> { + val allTags = getAllTags(tasks) + val tags = allTags.map { t: String? -> HashSet(t?.split(",") ?: emptySet()) } + val partialTags = tags.flatten().toMutableSet() + var commonTags: MutableSet? = null + if (tags.isEmpty()) { + commonTags = HashSet() + } else { + for (s in tags) { + if (commonTags == null) { + commonTags = s.toMutableSet() + } else { + commonTags.retainAll(s) + } + } + } + partialTags.removeAll(commonTags!!) + return Pair(partialTags, commonTags) + } + + @Query("SELECT GROUP_CONCAT(DISTINCT(tag_uid)) FROM tasks" + + " LEFT JOIN tags ON tags.task = tasks._id" + + " WHERE tasks._id IN (:tasks)" + + " GROUP BY tasks._id") + abstract fun getAllTags(tasks: List): List + + @Transaction + open fun applyTags( + tasks: List, partiallySelected: List, selected: List): List { + val modified = HashSet() + val keep = partiallySelected.plus(selected).map { it.remoteId!! } + for (sublist in tasks.chunked(DbUtils.MAX_SQLITE_ARGS - keep.size)) { + val tags = tagsToDelete(sublist.map(Task::id), keep) + deleteTags(tags) + modified.addAll(tags.map(Tag::task)) + } + for (task in tasks) { + val added = selected subtract getTagDataForTask(task.id) + if (added.isNotEmpty()) { + modified.add(task.id) + insert(added.map { Tag(task, it) }) + } + } + return ArrayList(modified) + } + + @Transaction + open fun delete(tagData: TagData) { + deleteTags(tagData.remoteId!!) + deleteTagData(tagData) + } + + @Delete + abstract fun delete(tagData: List) + + @Delete + abstract fun deleteTags(tags: List) + + @Query("SELECT tagdata.* FROM tagdata " + + "INNER JOIN tags ON tags.tag_uid = tagdata.remoteId " + + "WHERE tags.task = :id " + + "ORDER BY UPPER(tagdata.name) ASC") + abstract fun getTagDataForTask(id: Long): List + + @Query("SELECT * FROM tagdata WHERE name IN (:names)") + abstract fun getTags(names: List): List + + @Update + abstract fun update(tagData: TagData) + + @Insert + abstract fun insert(tag: TagData): Long + + @Insert + abstract fun insert(tags: Iterable) + + fun createNew(tag: TagData) { + if (Task.isUuidEmpty(tag.remoteId)) { + tag.remoteId = UUIDHelper.newUUID() + } + tag.id = insert(tag) + } + + @Query("SELECT tagdata.*, COUNT(tasks._id) AS count" + + " FROM tagdata" + + " LEFT JOIN tags ON tags.tag_uid = tagdata.remoteId" + + " LEFT JOIN tasks ON tags.task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now" + + " WHERE tagdata.name IS NOT NULL AND tagdata.name != ''" + + " GROUP BY tagdata.remoteId") + abstract fun getTagFilters(now: Long = currentTimeMillis()): List + + @Query("UPDATE tagdata SET td_order = $NO_ORDER") + abstract fun resetOrders() + + @Query("UPDATE tagdata SET td_order = :order WHERE _id = :id") + abstract fun setOrder(id: Long, order: Int) +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt b/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt new file mode 100644 index 000000000..77ceb5dd8 --- /dev/null +++ b/app/src/main/java/org/tasks/data/TaskAttachmentDaoBlocking.kt @@ -0,0 +1,33 @@ +package org.tasks.data + +import androidx.room.* +import com.todoroo.astrid.data.Task +import com.todoroo.astrid.helper.UUIDHelper + +@Dao +abstract class TaskAttachmentDaoBlocking { + @Query("SELECT * FROM task_attachments WHERE task_id = :taskUuid") + abstract fun getAttachments(taskUuid: String): List + + @Query("SELECT task_attachments.* FROM task_attachments INNER JOIN tasks ON tasks._id = :task WHERE task_id = tasks.remoteId") + abstract fun getAttachments(task: Long): List + + @Query("SELECT * FROM task_attachments") + abstract fun getAttachments(): List + + @Delete + abstract fun delete(taskAttachment: TaskAttachment) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + abstract fun insert(attachment: TaskAttachment) + + @Update + abstract fun update(attachment: TaskAttachment) + + fun createNew(attachment: TaskAttachment) { + if (Task.isUuidEmpty(attachment.remoteId)) { + attachment.remoteId = UUIDHelper.newUUID() + } + insert(attachment) + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt b/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt new file mode 100644 index 000000000..f88edee16 --- /dev/null +++ b/app/src/main/java/org/tasks/data/TaskListMetadataDaoBlocking.kt @@ -0,0 +1,25 @@ +package org.tasks.data + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.Query +import androidx.room.Update + +@Dao +abstract class TaskListMetadataDaoBlocking { + @Query("SELECT * from task_list_metadata where tag_uuid = :tagUuid OR filter = :tagUuid LIMIT 1") + abstract fun fetchByTagOrFilter(tagUuid: String): TaskListMetadata? + + @Query("SELECT * FROM task_list_metadata") + abstract fun getAll(): List + + @Update + abstract fun update(taskListMetadata: TaskListMetadata) + + @Insert + abstract fun insert(taskListMetadata: TaskListMetadata): Long + + fun createNew(taskListMetadata: TaskListMetadata) { + taskListMetadata.id = insert(taskListMetadata) + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt b/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt new file mode 100644 index 000000000..126c42d89 --- /dev/null +++ b/app/src/main/java/org/tasks/data/UserActivityDaoBlocking.kt @@ -0,0 +1,37 @@ +package org.tasks.data + +import androidx.room.* +import com.todoroo.andlib.utility.DateUtilities +import com.todoroo.astrid.data.Task +import com.todoroo.astrid.helper.UUIDHelper + +@Dao +abstract class UserActivityDaoBlocking { + @Insert + abstract fun insert(userActivity: UserActivity) + + @Update + abstract fun update(userActivity: UserActivity) + + @Delete + abstract fun delete(userActivity: UserActivity) + + @Query("SELECT * FROM userActivity WHERE target_id = :taskUuid ORDER BY created_at DESC ") + abstract fun getCommentsForTask(taskUuid: String): List + + @Query("SELECT userActivity.* FROM userActivity INNER JOIN tasks ON tasks._id = :task WHERE target_id = tasks.remoteId") + abstract fun getComments(task: Long): List + + @Query("SELECT * FROM userActivity") + abstract fun getComments(): List + + fun createNew(item: UserActivity) { + if (item.created == null || item.created == 0L) { + item.created = DateUtilities.now() + } + if (Task.isUuidEmpty(item.remoteId)) { + item.remoteId = UUIDHelper.newUUID() + } + insert(item) + } +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt b/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt index 3e81148bf..00f758f29 100644 --- a/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt +++ b/app/src/main/java/org/tasks/dialogs/DateTimePicker.kt @@ -20,7 +20,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.todoroo.andlib.utility.DateUtilities -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.Task import dagger.hilt.android.AndroidEntryPoint import org.tasks.R @@ -41,7 +41,7 @@ class DateTimePicker : BottomSheetDialogFragment() { @Inject lateinit var activity: Activity @Inject lateinit var preferences: Preferences @Inject lateinit var locale: Locale - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var notificationManager: NotificationManager @Inject lateinit var theme: Theme diff --git a/app/src/main/java/org/tasks/etesync/EteSynchronizer.java b/app/src/main/java/org/tasks/etesync/EteSynchronizer.java index 3a199ca05..bf5d24393 100644 --- a/app/src/main/java/org/tasks/etesync/EteSynchronizer.java +++ b/app/src/main/java/org/tasks/etesync/EteSynchronizer.java @@ -40,7 +40,7 @@ import org.tasks.billing.Inventory; import org.tasks.caldav.iCalendar; import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavCalendar; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.data.CaldavTask; import org.tasks.data.CaldavTaskContainer; import timber.log.Timber; @@ -52,7 +52,7 @@ public class EteSynchronizer { new ProdId("+//IDN tasks.org//android-" + BuildConfig.VERSION_CODE + "//EN")); } - private final CaldavDao caldavDao; + private final CaldavDaoBlocking caldavDao; private final LocalBroadcastManager localBroadcastManager; private final TaskDeleter taskDeleter; private final Inventory inventory; @@ -63,7 +63,7 @@ public class EteSynchronizer { @Inject public EteSynchronizer( @ApplicationContext Context context, - CaldavDao caldavDao, + CaldavDaoBlocking caldavDao, LocalBroadcastManager localBroadcastManager, TaskDeleter taskDeleter, Inventory inventory, diff --git a/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.java b/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.java index 0b5f136d9..48636746e 100644 --- a/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.java +++ b/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.java @@ -24,14 +24,14 @@ import java.util.Map; import javax.inject.Inject; import org.tasks.R; import org.tasks.data.CaldavCalendar; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.data.CaldavTask; import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTaskList; -import org.tasks.data.GoogleTaskListDao; +import org.tasks.data.GoogleTaskListDaoBlocking; import org.tasks.data.Tag; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; public class FilterCriteriaProvider { @@ -45,17 +45,17 @@ public class FilterCriteriaProvider { private static final String IDENTIFIER_TAG_CONTAINS = "tag_contains"; private final Context context; - private final TagDataDao tagDataDao; + private final TagDataDaoBlocking tagDataDao; private final Resources r; - private final GoogleTaskListDao googleTaskListDao; - private final CaldavDao caldavDao; + private final GoogleTaskListDaoBlocking googleTaskListDao; + private final CaldavDaoBlocking caldavDao; @Inject public FilterCriteriaProvider( @ApplicationContext Context context, - TagDataDao tagDataDao, - GoogleTaskListDao googleTaskListDao, - CaldavDao caldavDao) { + TagDataDaoBlocking tagDataDao, + GoogleTaskListDaoBlocking googleTaskListDao, + CaldavDaoBlocking caldavDao) { this.context = context; this.tagDataDao = tagDataDao; diff --git a/app/src/main/java/org/tasks/filters/FilterProvider.kt b/app/src/main/java/org/tasks/filters/FilterProvider.kt index 85f31b394..04d5efb98 100644 --- a/app/src/main/java/org/tasks/filters/FilterProvider.kt +++ b/app/src/main/java/org/tasks/filters/FilterProvider.kt @@ -30,12 +30,12 @@ class FilterProvider @Inject constructor( @param:ApplicationContext private val context: Context, private val inventory: Inventory, private val builtInFilterExposer: BuiltInFilterExposer, - private val filterDao: FilterDao, - private val tagDataDao: TagDataDao, - private val googleTaskListDao: GoogleTaskListDao, - private val caldavDao: CaldavDao, + private val filterDao: FilterDaoBlocking, + private val tagDataDao: TagDataDaoBlocking, + private val googleTaskListDao: GoogleTaskListDaoBlocking, + private val caldavDao: CaldavDaoBlocking, private val preferences: Preferences, - private val locationDao: LocationDao) { + private val locationDao: LocationDaoBlocking) { val listPickerItems: List get() = googleTaskFilters(false).plus(caldavFilters(false)) diff --git a/app/src/main/java/org/tasks/filters/PlaceFilter.java b/app/src/main/java/org/tasks/filters/PlaceFilter.java index 770bc98a9..4c4095dad 100644 --- a/app/src/main/java/org/tasks/filters/PlaceFilter.java +++ b/app/src/main/java/org/tasks/filters/PlaceFilter.java @@ -4,7 +4,6 @@ import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import androidx.annotation.NonNull; - import com.todoroo.andlib.data.Table; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Field; diff --git a/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java b/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java index ebbfd3cb2..d92d50c85 100644 --- a/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java +++ b/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java @@ -13,7 +13,7 @@ import com.google.api.services.tasks.model.Tasks; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.GtasksFilter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.api.GtasksApiUtilities; @@ -40,9 +40,9 @@ import org.tasks.analytics.Firebase; import org.tasks.billing.Inventory; import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTaskAccount; -import org.tasks.data.GoogleTaskDao; +import org.tasks.data.GoogleTaskDaoBlocking; import org.tasks.data.GoogleTaskList; -import org.tasks.data.GoogleTaskListDao; +import org.tasks.data.GoogleTaskListDaoBlocking; import org.tasks.preferences.DefaultFilterProvider; import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.Preferences; @@ -65,12 +65,12 @@ public class GoogleTaskSynchronizer { }; private final Context context; - private final GoogleTaskListDao googleTaskListDao; + private final GoogleTaskListDaoBlocking googleTaskListDao; private final GtasksListService gtasksListService; private final Preferences preferences; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final Firebase firebase; - private final GoogleTaskDao googleTaskDao; + private final GoogleTaskDaoBlocking googleTaskDao; private final TaskCreator taskCreator; private final DefaultFilterProvider defaultFilterProvider; private final PermissionChecker permissionChecker; @@ -83,12 +83,12 @@ public class GoogleTaskSynchronizer { @Inject public GoogleTaskSynchronizer( @ApplicationContext Context context, - GoogleTaskListDao googleTaskListDao, + GoogleTaskListDaoBlocking googleTaskListDao, GtasksListService gtasksListService, Preferences preferences, - TaskDao taskDao, + TaskDaoBlocking taskDao, Firebase firebase, - GoogleTaskDao googleTaskDao, + GoogleTaskDaoBlocking googleTaskDao, TaskCreator taskCreator, DefaultFilterProvider defaultFilterProvider, PermissionChecker permissionChecker, diff --git a/app/src/main/java/org/tasks/injection/ApplicationModule.kt b/app/src/main/java/org/tasks/injection/ApplicationModule.kt index 4b93d92ab..927f93b5f 100644 --- a/app/src/main/java/org/tasks/injection/ApplicationModule.kt +++ b/app/src/main/java/org/tasks/injection/ApplicationModule.kt @@ -2,7 +2,7 @@ package org.tasks.injection import android.content.Context import com.todoroo.astrid.dao.Database -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -17,7 +17,7 @@ import org.tasks.jobs.WorkManager import org.tasks.locale.Locale import org.tasks.location.Geocoder import org.tasks.location.MapboxGeocoder -import org.tasks.notifications.NotificationDao +import org.tasks.notifications.NotificationDaoBlocking import javax.inject.Singleton @Module @@ -33,55 +33,55 @@ class ApplicationModule { @Provides @Singleton - fun getNotificationDao(db: Database): NotificationDao = db.notificationDao() + fun getNotificationDao(db: Database): NotificationDaoBlocking = db.notificationDao() @Provides @Singleton - fun getTagDataDao(db: Database): TagDataDao = db.tagDataDao + fun getTagDataDao(db: Database): TagDataDaoBlocking = db.tagDataDao @Provides @Singleton - fun getUserActivityDao(db: Database): UserActivityDao = db.userActivityDao + fun getUserActivityDao(db: Database): UserActivityDaoBlocking = db.userActivityDao @Provides @Singleton - fun getTaskAttachmentDao(db: Database): TaskAttachmentDao = db.taskAttachmentDao + fun getTaskAttachmentDao(db: Database): TaskAttachmentDaoBlocking = db.taskAttachmentDao @Provides @Singleton - fun getTaskListMetadataDao(db: Database): TaskListMetadataDao = db.taskListMetadataDao + fun getTaskListMetadataDao(db: Database): TaskListMetadataDaoBlocking = db.taskListMetadataDao @Provides @Singleton - fun getGoogleTaskDao(db: Database): GoogleTaskDao = db.googleTaskDao + fun getGoogleTaskDao(db: Database): GoogleTaskDaoBlocking = db.googleTaskDao @Provides @Singleton - fun getAlarmDao(db: Database): AlarmDao = db.alarmDao + fun getAlarmDao(db: Database): AlarmDaoBlocking = db.alarmDao @Provides @Singleton - fun getGeofenceDao(db: Database): LocationDao = db.locationDao + fun getGeofenceDao(db: Database): LocationDaoBlocking = db.locationDao @Provides @Singleton - fun getTagDao(db: Database): TagDao = db.tagDao + fun getTagDao(db: Database): TagDaoBlocking = db.tagDao @Provides @Singleton - fun getFilterDao(db: Database): FilterDao = db.filterDao + fun getFilterDao(db: Database): FilterDaoBlocking = db.filterDao @Provides @Singleton - fun getGoogleTaskListDao(db: Database): GoogleTaskListDao = db.googleTaskListDao + fun getGoogleTaskListDao(db: Database): GoogleTaskListDaoBlocking = db.googleTaskListDao @Provides @Singleton - fun getCaldavDao(db: Database): CaldavDao = db.caldavDao + fun getCaldavDao(db: Database): CaldavDaoBlocking = db.caldavDao @Provides @Singleton - fun getTaskDao(db: Database, workManager: WorkManager): TaskDao { + fun getTaskDao(db: Database, workManager: WorkManager): TaskDaoBlocking { val taskDao = db.taskDao taskDao.initialize(workManager) return taskDao @@ -89,11 +89,11 @@ class ApplicationModule { @Provides @Singleton - fun getDeletionDao(db: Database): DeletionDao = db.deletionDao + fun getDeletionDao(db: Database): DeletionDaoBlocking = db.deletionDao @Provides @Singleton - fun getContentProviderDao(db: Database): ContentProviderDao = db.contentProviderDao + fun getContentProviderDao(db: Database): ContentProviderDaoBlocking = db.contentProviderDao @Provides fun getBillingClient(@ApplicationContext context: Context, inventory: Inventory, firebase: Firebase): BillingClient diff --git a/app/src/main/java/org/tasks/injection/ProductionModule.kt b/app/src/main/java/org/tasks/injection/ProductionModule.kt index abc088131..25325e8da 100644 --- a/app/src/main/java/org/tasks/injection/ProductionModule.kt +++ b/app/src/main/java/org/tasks/injection/ProductionModule.kt @@ -10,8 +10,8 @@ import dagger.hilt.android.components.ApplicationComponent import dagger.hilt.android.qualifiers.ApplicationContext import org.tasks.BuildConfig import org.tasks.R -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskListDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskListDaoBlocking import org.tasks.db.Migrations import org.tasks.jobs.WorkManager import org.tasks.jobs.WorkManagerImpl @@ -40,8 +40,8 @@ internal class ProductionModule { fun getWorkManager( @ApplicationContext context: Context, preferences: Preferences, - googleTaskListDao: GoogleTaskListDao, - caldavDao: CaldavDao): WorkManager { + googleTaskListDao: GoogleTaskListDaoBlocking, + caldavDao: CaldavDaoBlocking): WorkManager { return WorkManagerImpl(context, preferences, googleTaskListDao, caldavDao) } } \ No newline at end of file diff --git a/app/src/main/java/org/tasks/jobs/AfterSaveWork.kt b/app/src/main/java/org/tasks/jobs/AfterSaveWork.kt index 968af2e15..09f633a95 100644 --- a/app/src/main/java/org/tasks/jobs/AfterSaveWork.kt +++ b/app/src/main/java/org/tasks/jobs/AfterSaveWork.kt @@ -9,6 +9,7 @@ import androidx.hilt.work.WorkerInject import androidx.work.Data import androidx.work.WorkerParameters import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.data.SyncFlags import com.todoroo.astrid.data.Task import com.todoroo.astrid.reminders.ReminderService @@ -18,7 +19,7 @@ import org.tasks.LocalBroadcastManager import org.tasks.R import org.tasks.Strings.isNullOrEmpty import org.tasks.analytics.Firebase -import org.tasks.data.CaldavDao +import org.tasks.data.CaldavDaoBlocking import org.tasks.injection.InjectingWorker import org.tasks.location.GeofenceApi import org.tasks.notifications.NotificationManager @@ -37,10 +38,10 @@ class AfterSaveWork @WorkerInject constructor( private val reminderService: ReminderService, private val refreshScheduler: RefreshScheduler, private val localBroadcastManager: LocalBroadcastManager, - private val taskDao: TaskDao, + private val taskDao: TaskDaoBlocking, private val syncAdapters: SyncAdapters, private val workManager: WorkManager, - private val caldavDao: CaldavDao) : InjectingWorker(context, workerParams, firebase) { + private val caldavDao: CaldavDaoBlocking) : InjectingWorker(context, workerParams, firebase) { override fun run(): Result { val data = inputData diff --git a/app/src/main/java/org/tasks/jobs/CleanupWork.kt b/app/src/main/java/org/tasks/jobs/CleanupWork.kt index a95ff66b3..5598a2ef0 100644 --- a/app/src/main/java/org/tasks/jobs/CleanupWork.kt +++ b/app/src/main/java/org/tasks/jobs/CleanupWork.kt @@ -8,10 +8,10 @@ import com.todoroo.astrid.alarms.AlarmService import com.todoroo.astrid.reminders.ReminderService import com.todoroo.astrid.timers.TimerPlugin import org.tasks.analytics.Firebase -import org.tasks.data.DeletionDao -import org.tasks.data.LocationDao -import org.tasks.data.TaskAttachmentDao -import org.tasks.data.UserActivityDao +import org.tasks.data.DeletionDaoBlocking +import org.tasks.data.LocationDaoBlocking +import org.tasks.data.TaskAttachmentDaoBlocking +import org.tasks.data.UserActivityDaoBlocking import org.tasks.files.FileHelper import org.tasks.injection.InjectingWorker import org.tasks.location.GeofenceApi @@ -27,10 +27,10 @@ class CleanupWork @WorkerInject constructor( private val timerPlugin: TimerPlugin, private val reminderService: ReminderService, private val alarmService: AlarmService, - private val taskAttachmentDao: TaskAttachmentDao, - private val userActivityDao: UserActivityDao, - private val locationDao: LocationDao, - private val deletionDao: DeletionDao) : InjectingWorker(context, workerParams, firebase) { + private val taskAttachmentDao: TaskAttachmentDaoBlocking, + private val userActivityDao: UserActivityDaoBlocking, + private val locationDao: LocationDaoBlocking, + private val deletionDao: DeletionDaoBlocking) : InjectingWorker(context, workerParams, firebase) { public override fun run(): Result { val tasks = inputData.getLongArray(EXTRA_TASK_IDS) diff --git a/app/src/main/java/org/tasks/jobs/ReverseGeocodeWork.kt b/app/src/main/java/org/tasks/jobs/ReverseGeocodeWork.kt index 68b50b576..7a77173df 100644 --- a/app/src/main/java/org/tasks/jobs/ReverseGeocodeWork.kt +++ b/app/src/main/java/org/tasks/jobs/ReverseGeocodeWork.kt @@ -6,7 +6,7 @@ import androidx.hilt.work.WorkerInject import androidx.work.WorkerParameters import org.tasks.LocalBroadcastManager import org.tasks.analytics.Firebase -import org.tasks.data.LocationDao +import org.tasks.data.LocationDaoBlocking import org.tasks.injection.InjectingWorker import org.tasks.location.Geocoder import timber.log.Timber @@ -18,7 +18,7 @@ class ReverseGeocodeWork @WorkerInject constructor( firebase: Firebase, private val localBroadcastManager: LocalBroadcastManager, private val geocoder: Geocoder, - private val locationDao: LocationDao) : InjectingWorker(context, workerParams, firebase) { + private val locationDao: LocationDaoBlocking) : InjectingWorker(context, workerParams, firebase) { companion object { const val PLACE_ID = "place_id" diff --git a/app/src/main/java/org/tasks/jobs/SyncWork.kt b/app/src/main/java/org/tasks/jobs/SyncWork.kt index 8354d37d0..45a80643b 100644 --- a/app/src/main/java/org/tasks/jobs/SyncWork.kt +++ b/app/src/main/java/org/tasks/jobs/SyncWork.kt @@ -7,8 +7,8 @@ import androidx.work.WorkerParameters import org.tasks.LocalBroadcastManager import org.tasks.analytics.Firebase import org.tasks.caldav.CaldavSynchronizer -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskListDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskListDaoBlocking import org.tasks.etesync.EteSynchronizer import org.tasks.gtasks.GoogleTaskSynchronizer import org.tasks.injection.InjectingWorker @@ -26,8 +26,8 @@ class SyncWork @WorkerInject constructor( private val googleTaskSynchronizer: GoogleTaskSynchronizer, private val localBroadcastManager: LocalBroadcastManager, private val preferences: Preferences, - private val caldavDao: CaldavDao, - private val googleTaskListDao: GoogleTaskListDao, + private val caldavDao: CaldavDaoBlocking, + private val googleTaskListDao: GoogleTaskListDaoBlocking, private val syncAdapters: SyncAdapters) : InjectingWorker(context, workerParams, firebase) { public override fun run(): Result { diff --git a/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt b/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt index a00a27a82..1114c5d85 100644 --- a/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt +++ b/app/src/main/java/org/tasks/jobs/WorkManagerImpl.kt @@ -16,8 +16,8 @@ import io.reactivex.functions.BiFunction import io.reactivex.schedulers.Schedulers import org.tasks.BuildConfig import org.tasks.R -import org.tasks.data.CaldavDao -import org.tasks.data.GoogleTaskListDao +import org.tasks.data.CaldavDaoBlocking +import org.tasks.data.GoogleTaskListDaoBlocking import org.tasks.data.Place import org.tasks.date.DateTimeUtils.midnight import org.tasks.date.DateTimeUtils.newDateTime @@ -39,8 +39,8 @@ import kotlin.math.max class WorkManagerImpl constructor( private val context: Context, private val preferences: Preferences, - private val googleTaskListDao: GoogleTaskListDao, - private val caldavDao: CaldavDao): WorkManager { + private val googleTaskListDao: GoogleTaskListDaoBlocking, + private val caldavDao: CaldavDaoBlocking): WorkManager { private val alarmManager: AlarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager private val workManager = androidx.work.WorkManager.getInstance(context) diff --git a/app/src/main/java/org/tasks/locale/receiver/TaskerTaskCreator.java b/app/src/main/java/org/tasks/locale/receiver/TaskerTaskCreator.java index c429b77b8..cd8144d70 100644 --- a/app/src/main/java/org/tasks/locale/receiver/TaskerTaskCreator.java +++ b/app/src/main/java/org/tasks/locale/receiver/TaskerTaskCreator.java @@ -3,7 +3,7 @@ package org.tasks.locale.receiver; import static org.tasks.Strings.isNullOrEmpty; import static org.tasks.time.DateTimeUtils.currentTimeMillis; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task.Priority; import com.todoroo.astrid.service.TaskCreator; @@ -21,10 +21,10 @@ class TaskerTaskCreator { private static final DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_LOCAL_TIME; private final TaskCreator taskCreator; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; @Inject - TaskerTaskCreator(TaskCreator taskCreator, TaskDao taskDao) { + TaskerTaskCreator(TaskCreator taskCreator, TaskDaoBlocking taskDao) { this.taskCreator = taskCreator; this.taskDao = taskDao; } diff --git a/app/src/main/java/org/tasks/location/LocationPickerActivity.java b/app/src/main/java/org/tasks/location/LocationPickerActivity.java index 232753583..3efb5bb1d 100644 --- a/app/src/main/java/org/tasks/location/LocationPickerActivity.java +++ b/app/src/main/java/org/tasks/location/LocationPickerActivity.java @@ -51,7 +51,7 @@ import org.tasks.R; import org.tasks.activities.PlaceSettingsActivity; import org.tasks.billing.Inventory; import org.tasks.caldav.GeoUtils; -import org.tasks.data.LocationDao; +import org.tasks.data.LocationDaoBlocking; import org.tasks.data.Place; import org.tasks.data.PlaceUsage; import org.tasks.dialogs.DialogBuilder; @@ -108,7 +108,7 @@ public class LocationPickerActivity extends InjectingAppCompatActivity @Inject Theme theme; @Inject Toaster toaster; - @Inject LocationDao locationDao; + @Inject LocationDaoBlocking locationDao; @Inject PlaceSearchProvider searchProvider; @Inject PermissionChecker permissionChecker; @Inject ActivityPermissionRequestor permissionRequestor; diff --git a/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt b/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt new file mode 100644 index 000000000..81849c990 --- /dev/null +++ b/app/src/main/java/org/tasks/notifications/NotificationDaoBlocking.kt @@ -0,0 +1,27 @@ +package org.tasks.notifications + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query + +@Dao +interface NotificationDaoBlocking { + @Query("SELECT task FROM notification") + fun getAll(): List + + @Query("SELECT * FROM notification ORDER BY timestamp DESC") + fun getAllOrdered(): List + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertAll(notifications: List) + + @Query("DELETE FROM notification WHERE task = :taskId") + fun delete(taskId: Long) + + @Query("DELETE FROM notification WHERE task IN(:taskIds)") + fun deleteAll(taskIds: List) + + @Query("SELECT MAX(timestamp) FROM notification") + fun latestTimestamp(): Long +} \ No newline at end of file diff --git a/app/src/main/java/org/tasks/notifications/NotificationManager.java b/app/src/main/java/org/tasks/notifications/NotificationManager.java index dd52066b6..360ca8cb1 100644 --- a/app/src/main/java/org/tasks/notifications/NotificationManager.java +++ b/app/src/main/java/org/tasks/notifications/NotificationManager.java @@ -27,7 +27,7 @@ import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.reminders.ReminderService; import dagger.hilt.android.qualifiers.ApplicationContext; @@ -42,7 +42,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.tasks.LocalBroadcastManager; import org.tasks.R; -import org.tasks.data.LocationDao; +import org.tasks.data.LocationDaoBlocking; import org.tasks.data.Place; import org.tasks.intents.TaskIntents; import org.tasks.preferences.Preferences; @@ -70,9 +70,9 @@ public class NotificationManager { private final NotificationManagerCompat notificationManagerCompat; private final ColorProvider colorProvider; private final LocalBroadcastManager localBroadcastManager; - private final LocationDao locationDao; - private final NotificationDao notificationDao; - private final TaskDao taskDao; + private final LocationDaoBlocking locationDao; + private final NotificationDaoBlocking notificationDao; + private final TaskDaoBlocking taskDao; private final Context context; private final Preferences preferences; private final Throttle throttle = new Throttle(NOTIFICATIONS_PER_SECOND); @@ -82,9 +82,9 @@ public class NotificationManager { public NotificationManager( @ApplicationContext Context context, Preferences preferences, - NotificationDao notificationDao, - TaskDao taskDao, - LocationDao locationDao, + NotificationDaoBlocking notificationDao, + TaskDaoBlocking taskDao, + LocationDaoBlocking locationDao, LocalBroadcastManager localBroadcastManager) { this.context = context; this.preferences = preferences; diff --git a/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt b/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt index 7eac5666a..1bc251490 100644 --- a/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt +++ b/app/src/main/java/org/tasks/preferences/DefaultFilterProvider.kt @@ -16,11 +16,11 @@ import javax.inject.Inject class DefaultFilterProvider @Inject constructor( @param:ApplicationContext private val context: Context, private val preferences: Preferences, - private val filterDao: FilterDao, - private val tagDataDao: TagDataDao, - private val googleTaskListDao: GoogleTaskListDao, - private val caldavDao: CaldavDao, - private val locationDao: LocationDao) { + private val filterDao: FilterDaoBlocking, + private val tagDataDao: TagDataDaoBlocking, + private val googleTaskListDao: GoogleTaskListDaoBlocking, + private val caldavDao: CaldavDaoBlocking, + private val locationDao: LocationDaoBlocking) { var dashclockFilter: Filter get() = getFilterFromPreference(R.string.p_dashclock_filter) diff --git a/app/src/main/java/org/tasks/preferences/fragments/Advanced.kt b/app/src/main/java/org/tasks/preferences/fragments/Advanced.kt index 28f9fd572..badf84c13 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/Advanced.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/Advanced.kt @@ -7,7 +7,7 @@ import androidx.annotation.StringRes import androidx.preference.Preference import androidx.preference.SwitchPreferenceCompat import com.todoroo.astrid.dao.Database -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.AndroidEntryPoint import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers @@ -35,7 +35,7 @@ class Advanced : InjectingPreferenceFragment() { @Inject lateinit var preferences: Preferences @Inject lateinit var database: Database - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var calendarEventProvider: CalendarEventProvider @Inject lateinit var toaster: Toaster @Inject lateinit var permissionRequester: FragmentPermissionRequestor diff --git a/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt b/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt index d7d1ee07d..e2833a48f 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt @@ -15,9 +15,9 @@ import org.tasks.Strings.isNullOrEmpty import org.tasks.caldav.CaldavAccountSettingsActivity import org.tasks.data.CaldavAccount import org.tasks.data.CaldavAccount.Companion.TYPE_LOCAL -import org.tasks.data.CaldavDao +import org.tasks.data.CaldavDaoBlocking import org.tasks.data.GoogleTaskAccount -import org.tasks.data.GoogleTaskListDao +import org.tasks.data.GoogleTaskListDaoBlocking import org.tasks.etesync.EteSyncAccountSettingsActivity import org.tasks.injection.InjectingPreferenceFragment import org.tasks.jobs.WorkManager @@ -35,8 +35,8 @@ class Synchronization : InjectingPreferenceFragment() { @Inject lateinit var workManager: WorkManager @Inject lateinit var preferences: Preferences @Inject lateinit var toaster: Toaster - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var googleTaskListDao: GoogleTaskListDao + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking @Inject lateinit var taskDeleter: TaskDeleter override fun getPreferenceXml() = R.xml.preferences_synchronization diff --git a/app/src/main/java/org/tasks/provider/TasksContentProvider.kt b/app/src/main/java/org/tasks/provider/TasksContentProvider.kt index 65d6d1adb..757178656 100644 --- a/app/src/main/java/org/tasks/provider/TasksContentProvider.kt +++ b/app/src/main/java/org/tasks/provider/TasksContentProvider.kt @@ -14,14 +14,14 @@ import dagger.hilt.android.components.ApplicationComponent import org.tasks.BuildConfig import org.tasks.R import org.tasks.analytics.Firebase -import org.tasks.data.ContentProviderDao +import org.tasks.data.ContentProviderDaoBlocking class TasksContentProvider : ContentProvider() { @EntryPoint @InstallIn(ApplicationComponent::class) interface TasksContentProviderEntryPoint { - val contentProviderDao: ContentProviderDao + val contentProviderDao: ContentProviderDaoBlocking val firebase: Firebase } diff --git a/app/src/main/java/org/tasks/receivers/RefreshReceiver.java b/app/src/main/java/org/tasks/receivers/RefreshReceiver.java index b7ef1cfdd..e378b0798 100644 --- a/app/src/main/java/org/tasks/receivers/RefreshReceiver.java +++ b/app/src/main/java/org/tasks/receivers/RefreshReceiver.java @@ -5,7 +5,7 @@ import android.content.Context; import android.content.Intent; import androidx.annotation.NonNull; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.provider.Astrid2TaskProvider; import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.qualifiers.ApplicationContext; @@ -22,7 +22,7 @@ public class RefreshReceiver extends InjectingJobIntentService { @Inject @ApplicationContext Context context; @Inject DefaultFilterProvider defaultFilterProvider; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject Preferences preferences; @Override diff --git a/app/src/main/java/org/tasks/receivers/RepeatConfirmationReceiver.java b/app/src/main/java/org/tasks/receivers/RepeatConfirmationReceiver.java index c353b182e..bc667a0fd 100644 --- a/app/src/main/java/org/tasks/receivers/RepeatConfirmationReceiver.java +++ b/app/src/main/java/org/tasks/receivers/RepeatConfirmationReceiver.java @@ -9,7 +9,7 @@ import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.activity.MainActivity; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.api.AstridApiConstants; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import java.text.ParseException; import javax.inject.Inject; @@ -23,12 +23,12 @@ public class RepeatConfirmationReceiver extends BroadcastReceiver { private final Activity activity; private final Firebase firebase; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final Locale locale; @Inject public RepeatConfirmationReceiver( - Activity activity, Firebase firebase, TaskDao taskDao, Locale locale) { + Activity activity, Firebase firebase, TaskDaoBlocking taskDao, Locale locale) { this.activity = activity; this.firebase = firebase; this.taskDao = taskDao; diff --git a/app/src/main/java/org/tasks/reminders/NotificationActivity.java b/app/src/main/java/org/tasks/reminders/NotificationActivity.java index 98769ea52..6dd62ee85 100644 --- a/app/src/main/java/org/tasks/reminders/NotificationActivity.java +++ b/app/src/main/java/org/tasks/reminders/NotificationActivity.java @@ -5,7 +5,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.FragmentManager; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import dagger.hilt.android.AndroidEntryPoint; import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -27,7 +27,7 @@ public class NotificationActivity extends InjectingAppCompatActivity public static final String EXTRA_TASK_ID = "extra_task_id"; private static final String FRAG_TAG_NOTIFICATION_FRAGMENT = "frag_tag_notification_fragment"; @Inject NotificationManager notificationManager; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject ThemeAccent themeAccent; private long taskId; diff --git a/app/src/main/java/org/tasks/reminders/SnoozeActivity.java b/app/src/main/java/org/tasks/reminders/SnoozeActivity.java index 42762c914..e1dd5c771 100644 --- a/app/src/main/java/org/tasks/reminders/SnoozeActivity.java +++ b/app/src/main/java/org/tasks/reminders/SnoozeActivity.java @@ -4,7 +4,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.FragmentManager; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.reminders.ReminderService; import dagger.hilt.android.AndroidEntryPoint; import java.util.ArrayList; @@ -29,7 +29,7 @@ public class SnoozeActivity extends InjectingAppCompatActivity private static final int REQUEST_DATE_TIME = 10101; private final List taskIds = new ArrayList<>(); @Inject NotificationManager notificationManager; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject ReminderService reminderService; @Inject ThemeAccent themeAccent; private boolean pickingDateTime; diff --git a/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java b/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java index 63e552b5a..6f988d433 100644 --- a/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java +++ b/app/src/main/java/org/tasks/scheduling/RefreshScheduler.java @@ -4,7 +4,7 @@ import static com.todoroo.andlib.utility.DateUtilities.ONE_MINUTE; import static org.tasks.time.DateTimeUtils.currentTimeMillis; import com.google.common.collect.ImmutableList; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import java.util.List; import java.util.SortedSet; @@ -20,11 +20,11 @@ public class RefreshScheduler { private final Preferences preferences; private final WorkManager workManager; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final SortedSet jobs = new TreeSet<>(); @Inject - RefreshScheduler(Preferences preferences, WorkManager workManager, TaskDao taskDao) { + RefreshScheduler(Preferences preferences, WorkManager workManager, TaskDaoBlocking taskDao) { this.preferences = preferences; this.workManager = workManager; this.taskDao = taskDao; diff --git a/app/src/main/java/org/tasks/sync/SyncAdapters.java b/app/src/main/java/org/tasks/sync/SyncAdapters.java index fff4c4871..c7b56f529 100644 --- a/app/src/main/java/org/tasks/sync/SyncAdapters.java +++ b/app/src/main/java/org/tasks/sync/SyncAdapters.java @@ -4,19 +4,19 @@ import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import javax.inject.Inject; -import org.tasks.data.CaldavDao; -import org.tasks.data.GoogleTaskListDao; +import org.tasks.data.CaldavDaoBlocking; +import org.tasks.data.GoogleTaskListDaoBlocking; import org.tasks.jobs.WorkManager; public class SyncAdapters { private final WorkManager workManager; - private final CaldavDao caldavDao; - private final GoogleTaskListDao googleTaskListDao; + private final CaldavDaoBlocking caldavDao; + private final GoogleTaskListDaoBlocking googleTaskListDao; @Inject public SyncAdapters( - WorkManager workManager, CaldavDao caldavDao, GoogleTaskListDao googleTaskListDao) { + WorkManager workManager, CaldavDaoBlocking caldavDao, GoogleTaskListDaoBlocking googleTaskListDao) { this.workManager = workManager; this.caldavDao = caldavDao; this.googleTaskListDao = googleTaskListDao; diff --git a/app/src/main/java/org/tasks/tags/TagPickerViewModel.kt b/app/src/main/java/org/tasks/tags/TagPickerViewModel.kt index 33a9a312d..d80f42eed 100644 --- a/app/src/main/java/org/tasks/tags/TagPickerViewModel.kt +++ b/app/src/main/java/org/tasks/tags/TagPickerViewModel.kt @@ -11,11 +11,11 @@ import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers import org.tasks.Strings.isNullOrEmpty import org.tasks.data.TagData -import org.tasks.data.TagDataDao +import org.tasks.data.TagDataDaoBlocking import org.tasks.tags.CheckBoxTriStates.State import java.util.* -class TagPickerViewModel @ViewModelInject constructor(private val tagDataDao: TagDataDao) : ViewModel() { +class TagPickerViewModel @ViewModelInject constructor(private val tagDataDao: TagDataDaoBlocking) : ViewModel() { private val tags = MutableLiveData>() private val disposables = CompositeDisposable() private val selected: MutableSet = HashSet() diff --git a/app/src/main/java/org/tasks/tasklist/DragAndDropRecyclerAdapter.kt b/app/src/main/java/org/tasks/tasklist/DragAndDropRecyclerAdapter.kt index 71fad203c..6118f2f4f 100644 --- a/app/src/main/java/org/tasks/tasklist/DragAndDropRecyclerAdapter.kt +++ b/app/src/main/java/org/tasks/tasklist/DragAndDropRecyclerAdapter.kt @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.ItemTouchHelper.Callback.makeMovementFlags import androidx.recyclerview.widget.RecyclerView import com.todoroo.astrid.activity.TaskListFragment import com.todoroo.astrid.adapter.TaskAdapter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.utility.Flags import io.reactivex.disposables.CompositeDisposable import io.reactivex.subjects.PublishSubject @@ -26,7 +26,7 @@ class DragAndDropRecyclerAdapter( viewHolderFactory: ViewHolderFactory, private val taskList: TaskListFragment, tasks: List, - taskDao: TaskDao, + taskDao: TaskDaoBlocking, preferences: Preferences) : TaskListRecyclerAdapter(adapter, viewHolderFactory, taskList, taskDao, preferences), DragAndDropDiffer { private val disableHeaders = taskList.getFilter().let { !it.supportsSorting() diff --git a/app/src/main/java/org/tasks/tasklist/PagedListRecyclerAdapter.kt b/app/src/main/java/org/tasks/tasklist/PagedListRecyclerAdapter.kt index cfad71da7..e6863cd2d 100644 --- a/app/src/main/java/org/tasks/tasklist/PagedListRecyclerAdapter.kt +++ b/app/src/main/java/org/tasks/tasklist/PagedListRecyclerAdapter.kt @@ -6,7 +6,7 @@ import androidx.recyclerview.widget.AsyncDifferConfig import androidx.recyclerview.widget.RecyclerView import com.todoroo.astrid.activity.TaskListFragment import com.todoroo.astrid.adapter.TaskAdapter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.preferences.Preferences @@ -16,7 +16,7 @@ class PagedListRecyclerAdapter( viewHolderFactory: ViewHolderFactory, taskList: TaskListFragment, list: List, - taskDao: TaskDao, + taskDao: TaskDaoBlocking, preferences: Preferences) : TaskListRecyclerAdapter(adapter, viewHolderFactory, taskList, taskDao, preferences) { private val differ: AsyncPagedListDiffer = diff --git a/app/src/main/java/org/tasks/tasklist/TaskListRecyclerAdapter.kt b/app/src/main/java/org/tasks/tasklist/TaskListRecyclerAdapter.kt index e8ac45d56..0f38a03cb 100644 --- a/app/src/main/java/org/tasks/tasklist/TaskListRecyclerAdapter.kt +++ b/app/src/main/java/org/tasks/tasklist/TaskListRecyclerAdapter.kt @@ -7,7 +7,7 @@ import com.todoroo.astrid.activity.TaskListFragment import com.todoroo.astrid.adapter.TaskAdapter import com.todoroo.astrid.adapter.TaskAdapterDataSource import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import org.tasks.data.TaskContainer import org.tasks.intents.TaskIntents import org.tasks.preferences.Preferences @@ -17,7 +17,7 @@ abstract class TaskListRecyclerAdapter internal constructor( private val adapter: TaskAdapter, internal val viewHolderFactory: ViewHolderFactory, private val taskList: TaskListFragment, - private val taskDao: TaskDao, + private val taskDao: TaskDaoBlocking, internal val preferences: Preferences) : RecyclerView.Adapter(), ViewHolderCallbacks, ListUpdateCallback, TaskAdapterDataSource { diff --git a/app/src/main/java/org/tasks/ui/ChipListCache.java b/app/src/main/java/org/tasks/ui/ChipListCache.java index d5b1c233a..74020ca9b 100644 --- a/app/src/main/java/org/tasks/ui/ChipListCache.java +++ b/app/src/main/java/org/tasks/ui/ChipListCache.java @@ -11,11 +11,11 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.tasks.LocalBroadcastManager; import org.tasks.data.CaldavCalendar; -import org.tasks.data.CaldavDao; +import org.tasks.data.CaldavDaoBlocking; import org.tasks.data.GoogleTaskList; -import org.tasks.data.GoogleTaskListDao; +import org.tasks.data.GoogleTaskListDaoBlocking; import org.tasks.data.TagData; -import org.tasks.data.TagDataDao; +import org.tasks.data.TagDataDaoBlocking; @Singleton public class ChipListCache { @@ -27,9 +27,9 @@ public class ChipListCache { @Inject ChipListCache( - GoogleTaskListDao googleTaskListDao, - CaldavDao caldavDao, - TagDataDao tagDataDao, + GoogleTaskListDaoBlocking googleTaskListDao, + CaldavDaoBlocking caldavDao, + TagDataDaoBlocking tagDataDao, LocalBroadcastManager localBroadcastManager) { this.localBroadcastManager = localBroadcastManager; diff --git a/app/src/main/java/org/tasks/ui/ListFragment.kt b/app/src/main/java/org/tasks/ui/ListFragment.kt index 1311f9397..16f2cd960 100644 --- a/app/src/main/java/org/tasks/ui/ListFragment.kt +++ b/app/src/main/java/org/tasks/ui/ListFragment.kt @@ -25,9 +25,9 @@ class ListFragment : TaskEditControlFragment() { @BindView(R.id.chip_group) lateinit var chipGroup: ChipGroup - @Inject lateinit var googleTaskListDao: GoogleTaskListDao - @Inject lateinit var googleTaskDao: GoogleTaskDao - @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var googleTaskListDao: GoogleTaskListDaoBlocking + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking + @Inject lateinit var caldavDao: CaldavDaoBlocking @Inject lateinit var defaultFilterProvider: DefaultFilterProvider @Inject lateinit var taskMover: TaskMover @Inject lateinit var chipProvider: ChipProvider diff --git a/app/src/main/java/org/tasks/ui/LocationControlSet.kt b/app/src/main/java/org/tasks/ui/LocationControlSet.kt index ee829fe0c..0c6cdddc6 100644 --- a/app/src/main/java/org/tasks/ui/LocationControlSet.kt +++ b/app/src/main/java/org/tasks/ui/LocationControlSet.kt @@ -25,7 +25,7 @@ import org.tasks.R import org.tasks.Strings.isNullOrEmpty import org.tasks.data.Geofence import org.tasks.data.Location -import org.tasks.data.LocationDao +import org.tasks.data.LocationDaoBlocking import org.tasks.data.Place import org.tasks.dialogs.DialogBuilder import org.tasks.dialogs.GeofenceDialog @@ -40,7 +40,7 @@ class LocationControlSet : TaskEditControlFragment() { @Inject lateinit var preferences: Preferences @Inject lateinit var dialogBuilder: DialogBuilder @Inject lateinit var geofenceApi: GeofenceApi - @Inject lateinit var locationDao: LocationDao + @Inject lateinit var locationDao: LocationDaoBlocking @Inject lateinit var device: Device @Inject lateinit var permissionRequestor: FragmentPermissionRequestor @Inject lateinit var permissionChecker: PermissionChecker diff --git a/app/src/main/java/org/tasks/ui/NavigationDrawerFragment.kt b/app/src/main/java/org/tasks/ui/NavigationDrawerFragment.kt index 2baed582d..0d5d0d6e4 100644 --- a/app/src/main/java/org/tasks/ui/NavigationDrawerFragment.kt +++ b/app/src/main/java/org/tasks/ui/NavigationDrawerFragment.kt @@ -20,7 +20,7 @@ import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.astrid.adapter.NavigationDrawerAdapter import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.FilterListItem -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import dagger.hilt.android.AndroidEntryPoint import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers @@ -42,7 +42,7 @@ class NavigationDrawerFragment : Fragment() { @Inject lateinit var localBroadcastManager: LocalBroadcastManager @Inject lateinit var adapter: NavigationDrawerAdapter @Inject lateinit var filterProvider: FilterProvider - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var taskDao: TaskDaoBlocking private lateinit var recyclerView: RecyclerView private lateinit var mDrawerLayout: DrawerLayout diff --git a/app/src/main/java/org/tasks/ui/SubtaskControlSet.kt b/app/src/main/java/org/tasks/ui/SubtaskControlSet.kt index a5a587a49..a3cfe4153 100644 --- a/app/src/main/java/org/tasks/ui/SubtaskControlSet.kt +++ b/app/src/main/java/org/tasks/ui/SubtaskControlSet.kt @@ -28,7 +28,7 @@ import com.todoroo.astrid.activity.MainActivity import com.todoroo.astrid.api.CaldavFilter import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.GtasksFilter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import com.todoroo.astrid.dao.TaskDao.TaskCriteria.activeAndVisible import com.todoroo.astrid.data.Task import com.todoroo.astrid.service.TaskCompleter @@ -57,11 +57,11 @@ class SubtaskControlSet : TaskEditControlFragment(), SubtaskViewHolder.Callbacks @Inject lateinit var activity: Activity @Inject lateinit var taskCompleter: TaskCompleter @Inject lateinit var localBroadcastManager: LocalBroadcastManager - @Inject lateinit var googleTaskDao: GoogleTaskDao + @Inject lateinit var googleTaskDao: GoogleTaskDaoBlocking @Inject lateinit var toaster: Toaster @Inject lateinit var taskCreator: TaskCreator - @Inject lateinit var caldavDao: CaldavDao - @Inject lateinit var taskDao: TaskDao + @Inject lateinit var caldavDao: CaldavDaoBlocking + @Inject lateinit var taskDao: TaskDaoBlocking @Inject lateinit var locale: Locale @Inject lateinit var checkBoxProvider: CheckBoxProvider @Inject lateinit var chipProvider: ChipProvider diff --git a/app/src/main/java/org/tasks/ui/TaskListViewModel.kt b/app/src/main/java/org/tasks/ui/TaskListViewModel.kt index 12465702d..7ff9f8d4b 100644 --- a/app/src/main/java/org/tasks/ui/TaskListViewModel.kt +++ b/app/src/main/java/org/tasks/ui/TaskListViewModel.kt @@ -8,7 +8,7 @@ import androidx.sqlite.db.SimpleSQLiteQuery import com.todoroo.andlib.utility.AndroidUtilities import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.api.Filter -import com.todoroo.astrid.dao.TaskDao +import com.todoroo.astrid.dao.TaskDaoBlocking import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -21,7 +21,7 @@ import timber.log.Timber class TaskListViewModel @ViewModelInject constructor( private val preferences: Preferences, - private val taskDao: TaskDao) : ViewModel(), Observer> { + private val taskDao: TaskDaoBlocking) : ViewModel(), Observer> { private var tasks = MutableLiveData>() private var filter: Filter? = null diff --git a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java index f5f69a877..0ab858437 100644 --- a/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java +++ b/app/src/main/java/org/tasks/widget/ScrollableViewsFactory.java @@ -10,7 +10,7 @@ import android.widget.RemoteViews; import android.widget.RemoteViewsService; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.subtasks.SubtasksHelper; import java.util.ArrayList; @@ -30,7 +30,7 @@ import timber.log.Timber; class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { private final int widgetId; - private final TaskDao taskDao; + private final TaskDaoBlocking taskDao; private final DefaultFilterProvider defaultFilterProvider; private final CheckBoxProvider checkBoxProvider; private final Locale locale; @@ -65,7 +65,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory { Preferences preferences, Context context, int widgetId, - TaskDao taskDao, + TaskDaoBlocking taskDao, DefaultFilterProvider defaultFilterProvider, CheckBoxProvider checkBoxProvider, Locale locale) { diff --git a/app/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java b/app/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java index 9f72acbab..a9d4b53cb 100644 --- a/app/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java +++ b/app/src/main/java/org/tasks/widget/ScrollableWidgetUpdateService.java @@ -5,7 +5,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.widget.RemoteViewsService; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.subtasks.SubtasksHelper; import dagger.hilt.android.AndroidEntryPoint; import javax.inject.Inject; @@ -18,7 +18,7 @@ import org.tasks.ui.CheckBoxProvider; @AndroidEntryPoint public class ScrollableWidgetUpdateService extends RemoteViewsService { - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject Preferences preferences; @Inject SubtasksHelper subtasksHelper; @Inject DefaultFilterProvider defaultFilterProvider; diff --git a/app/src/main/java/org/tasks/widget/TasksWidget.java b/app/src/main/java/org/tasks/widget/TasksWidget.java index 8279dea5f..e63af5f5c 100644 --- a/app/src/main/java/org/tasks/widget/TasksWidget.java +++ b/app/src/main/java/org/tasks/widget/TasksWidget.java @@ -15,7 +15,7 @@ import android.widget.RemoteViews; import androidx.annotation.ColorInt; import androidx.core.graphics.ColorUtils; import com.todoroo.astrid.api.Filter; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.qualifiers.ApplicationContext; import javax.inject.Inject; @@ -35,7 +35,7 @@ public class TasksWidget extends AppWidgetProvider { @Inject Preferences preferences; @Inject DefaultFilterProvider defaultFilterProvider; @Inject Locale locale; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject @ApplicationContext Context context; @Override diff --git a/app/src/main/java/org/tasks/widget/WidgetClickActivity.java b/app/src/main/java/org/tasks/widget/WidgetClickActivity.java index 6718cc115..64f821700 100644 --- a/app/src/main/java/org/tasks/widget/WidgetClickActivity.java +++ b/app/src/main/java/org/tasks/widget/WidgetClickActivity.java @@ -5,7 +5,7 @@ import static org.tasks.Strings.isNullOrEmpty; import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.FragmentManager; -import com.todoroo.astrid.dao.TaskDao; +import com.todoroo.astrid.dao.TaskDaoBlocking; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.TaskCompleter; import dagger.hilt.android.AndroidEntryPoint; @@ -31,7 +31,7 @@ public class WidgetClickActivity extends InjectingAppCompatActivity private static final String FRAG_TAG_DATE_TIME_PICKER = "frag_tag_date_time_picker"; @Inject TaskCompleter taskCompleter; - @Inject TaskDao taskDao; + @Inject TaskDaoBlocking taskDao; @Inject LocalBroadcastManager localBroadcastManager; @Inject Preferences preferences;