Add 'google_task_lists' table

pull/618/head
Alex Baker 7 years ago
parent c7e2a37e77
commit a65d354eda

@ -0,0 +1,721 @@
{
"formatVersion": 1,
"database": {
"version": 52,
"identityHash": "23e6e3a7316ca88f4c420928ee481149",
"entities": [
{
"tableName": "notification",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `type` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "uid",
"columnName": "uid",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "taskId",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"uid"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_notification_task",
"unique": true,
"columnNames": [
"task"
],
"createSql": "CREATE UNIQUE INDEX `index_notification_task` ON `${TABLE_NAME}` (`task`)"
}
],
"foreignKeys": []
},
{
"tableName": "tagdata",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `name` TEXT, `color` INTEGER, `tagOrdering` TEXT, `deleted` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "color",
"columnName": "color",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "tagOrdering",
"columnName": "tagOrdering",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "userActivity",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `action` TEXT, `message` TEXT, `picture` TEXT, `target_id` TEXT, `created_at` INTEGER, `deleted_at` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "action",
"columnName": "action",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "message",
"columnName": "message",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "picture",
"columnName": "picture",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "targetId",
"columnName": "target_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "created",
"columnName": "created_at",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "deleted",
"columnName": "deleted_at",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "task_attachments",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `task_id` TEXT, `name` TEXT, `path` TEXT, `content_type` TEXT, `deleted_at` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskId",
"columnName": "task_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "path",
"columnName": "path",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "contentType",
"columnName": "content_type",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "deleted",
"columnName": "deleted_at",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "task_list_metadata",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `tag_uuid` TEXT, `filter` TEXT, `task_ids` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tagUuid",
"columnName": "tag_uuid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "filter",
"columnName": "filter",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskIds",
"columnName": "task_ids",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT, `importance` INTEGER, `dueDate` INTEGER, `hideUntil` INTEGER, `created` INTEGER, `modified` INTEGER, `completed` INTEGER, `deleted` INTEGER, `notes` TEXT, `estimatedSeconds` INTEGER, `elapsedSeconds` INTEGER, `timerStart` INTEGER, `notificationFlags` INTEGER, `notifications` INTEGER, `lastNotified` INTEGER, `snoozeTime` INTEGER, `recurrence` TEXT, `repeatUntil` INTEGER, `calendarUri` TEXT, `remoteId` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "importance",
"columnName": "importance",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "dueDate",
"columnName": "dueDate",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "hideUntil",
"columnName": "hideUntil",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "created",
"columnName": "created",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "modified",
"columnName": "modified",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "completed",
"columnName": "completed",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "notes",
"columnName": "notes",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "estimatedSeconds",
"columnName": "estimatedSeconds",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "elapsedSeconds",
"columnName": "elapsedSeconds",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "timerStart",
"columnName": "timerStart",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "notificationFlags",
"columnName": "notificationFlags",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "notifications",
"columnName": "notifications",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lastNotified",
"columnName": "lastNotified",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "snoozeTime",
"columnName": "snoozeTime",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "recurrence",
"columnName": "recurrence",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "repeatUntil",
"columnName": "repeatUntil",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "calendarUri",
"columnName": "calendarUri",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [
{
"name": "t_rid",
"unique": true,
"columnNames": [
"remoteId"
],
"createSql": "CREATE UNIQUE INDEX `t_rid` ON `${TABLE_NAME}` (`remoteId`)"
}
],
"foreignKeys": []
},
{
"tableName": "alarms",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `time` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "time",
"columnName": "time",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "locations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `name` TEXT, `latitude` REAL NOT NULL, `longitude` REAL NOT NULL, `radius` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "latitude",
"columnName": "latitude",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "longitude",
"columnName": "longitude",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "radius",
"columnName": "radius",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "tags",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `name` TEXT, `tag_uid` TEXT, `task_uid` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tagUid",
"columnName": "tag_uid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskUid",
"columnName": "task_uid",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "google_tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `remote_id` TEXT, `list_id` TEXT, `parent` INTEGER NOT NULL, `indent` INTEGER NOT NULL, `order` INTEGER NOT NULL, `remote_order` INTEGER NOT NULL, `last_sync` INTEGER NOT NULL, `deleted` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remoteId",
"columnName": "remote_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "listId",
"columnName": "list_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "parent",
"columnName": "parent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "indent",
"columnName": "indent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "order",
"columnName": "order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remoteOrder",
"columnName": "remote_order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastSync",
"columnName": "last_sync",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "filters",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `sql` TEXT, `values` TEXT, `criterion` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "sql",
"columnName": "sql",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "values",
"columnName": "values",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "criterion",
"columnName": "criterion",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "google_task_lists",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `remote_id` TEXT, `title` TEXT, `remote_order` INTEGER NOT NULL, `last_sync` INTEGER NOT NULL, `deleted` INTEGER NOT NULL, `color` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remoteId",
"columnName": "remote_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "remoteOrder",
"columnName": "remote_order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastSync",
"columnName": "last_sync",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "color",
"columnName": "color",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"23e6e3a7316ca88f4c420928ee481149\")"
]
}
}

@ -2,7 +2,6 @@ package org.tasks.tasklist;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.gtasks.GtasksList;
public class GtasksListFragment extends TaskListFragment { public class GtasksListFragment extends TaskListFragment {
public static TaskListFragment newGtasksListFragment(GtasksFilter gtasksFilter, GtasksList list) { public static TaskListFragment newGtasksListFragment(GtasksFilter gtasksFilter, GtasksList list) {

@ -1,7 +1,6 @@
package org.tasks.ui; package org.tasks.ui;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;

@ -4,7 +4,8 @@ import android.arch.persistence.room.Room;
import android.content.Context; import android.content.Context;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import org.tasks.data.StoreObjectDao;
import org.tasks.data.GoogleTaskListDao;
import org.tasks.data.TagDataDao; import org.tasks.data.TagDataDao;
import org.tasks.data.TaskListMetadataDao; import org.tasks.data.TaskListMetadataDao;
import org.tasks.data.UserActivityDao; import org.tasks.data.UserActivityDao;
@ -57,8 +58,8 @@ public class TestModule {
} }
@Provides @Provides
public StoreObjectDao getStoreObjectDao(Database database) { public GoogleTaskListDao getGoogleTaskListDao(Database database) {
return database.getStoreObjectDao(); return database.getGoogleTaskListDao();
} }
@Provides @Provides

@ -3,34 +3,30 @@ package org.tasks.makers;
import com.natpryce.makeiteasy.Instantiator; import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.Property; import com.natpryce.makeiteasy.Property;
import com.natpryce.makeiteasy.PropertyValue; import com.natpryce.makeiteasy.PropertyValue;
import org.tasks.data.StoreObject;
import com.todoroo.astrid.gtasks.GtasksList; import org.tasks.data.GoogleTaskList;
import static com.natpryce.makeiteasy.Property.newProperty; import static com.natpryce.makeiteasy.Property.newProperty;
import static org.tasks.makers.Maker.make; import static org.tasks.makers.Maker.make;
public class GtaskListMaker { public class GtaskListMaker {
public static final Property<GtasksList, Long> ID = newProperty(); public static final Property<GoogleTaskList, Long> ID = newProperty();
public static final Property<GtasksList, Integer> ORDER = newProperty(); public static final Property<GoogleTaskList, Integer> ORDER = newProperty();
public static final Property<GtasksList, String> REMOTE_ID = newProperty(); public static final Property<GoogleTaskList, String> REMOTE_ID = newProperty();
public static final Property<GtasksList, Long> LAST_SYNC = newProperty(); public static final Property<GoogleTaskList, Long> LAST_SYNC = newProperty();
public static final Property<GtasksList, String> NAME = newProperty(); public static final Property<GoogleTaskList, String> NAME = newProperty();
public static GtasksList newGtaskList(PropertyValue<? super GtasksList, ?>... properties) { public static GoogleTaskList newGtaskList(PropertyValue<? super GoogleTaskList, ?>... properties) {
return make(instantiator, properties); return make(instantiator, properties);
} }
private static final Instantiator<GtasksList> instantiator = lookup -> { private static final Instantiator<GoogleTaskList> instantiator = lookup -> new GoogleTaskList() {{
StoreObject storeObject = new StoreObject() {{
setType(GtasksList.TYPE);
setDeleted(0L); setDeleted(0L);
setId(lookup.valueOf(GtaskListMaker.ID, 0L)); setId(lookup.valueOf(GtaskListMaker.ID, 0L));
setItem(lookup.valueOf(REMOTE_ID, "1")); setRemoteId(lookup.valueOf(REMOTE_ID, "1"));
setValue(lookup.valueOf(NAME, "Default")); setTitle(lookup.valueOf(NAME, "Default"));
setValue2(String.valueOf(lookup.valueOf(ORDER, 0))); setRemoteOrder(lookup.valueOf(ORDER, 0));
setValue3(String.valueOf(lookup.valueOf(LAST_SYNC, 0L))); setLastSync(lookup.valueOf(LAST_SYNC, 0L));
}}; }};
return new GtasksList(storeObject);
};
} }

@ -15,6 +15,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.InjectingTestCase; import org.tasks.injection.InjectingTestCase;
import org.tasks.injection.TestComponent; import org.tasks.injection.TestComponent;
@ -36,7 +37,7 @@ public class GtasksIndentActionTest extends InjectingTestCase {
@Inject GoogleTaskDao googleTaskDao; @Inject GoogleTaskDao googleTaskDao;
private Task task; private Task task;
private GtasksList storeList; private GoogleTaskList storeList;
@Test @Test
public void testIndentWithoutMetadata() { public void testIndentWithoutMetadata() {

@ -4,13 +4,14 @@ import android.support.test.runner.AndroidJUnit4;
import com.google.api.client.util.DateTime; import com.google.api.client.util.DateTime;
import com.google.api.services.tasks.model.TaskList; import com.google.api.services.tasks.model.TaskList;
import org.tasks.data.StoreObjectDao;
import com.todoroo.astrid.service.TaskDeleter; import com.todoroo.astrid.service.TaskDeleter;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.LocalBroadcastManager; import org.tasks.LocalBroadcastManager;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao;
import org.tasks.data.TaskListDataProvider; import org.tasks.data.TaskListDataProvider;
import org.tasks.injection.InjectingTestCase; import org.tasks.injection.InjectingTestCase;
import org.tasks.injection.TestComponent; import org.tasks.injection.TestComponent;
@ -39,13 +40,13 @@ public class GtasksListServiceTest extends InjectingTestCase {
@Inject LocalBroadcastManager localBroadcastManager; @Inject LocalBroadcastManager localBroadcastManager;
@Inject GoogleTaskDao googleTaskDao; @Inject GoogleTaskDao googleTaskDao;
@Inject StoreObjectDao storeObjectDao; @Inject GoogleTaskListDao googleTaskListDao;
private GtasksListService gtasksListService; private GtasksListService gtasksListService;
@Override @Override
public void setUp() { public void setUp() {
super.setUp(); super.setUp();
gtasksListService = new GtasksListService(storeObjectDao, taskListDataProvider, taskDeleter, gtasksListService = new GtasksListService(googleTaskListDao, taskListDataProvider, taskDeleter,
localBroadcastManager, googleTaskDao); localBroadcastManager, googleTaskDao);
} }
@ -65,13 +66,13 @@ public class GtasksListServiceTest extends InjectingTestCase {
with(ID, 1L), with(ID, 1L),
with(REMOTE_ID, "1"), with(REMOTE_ID, "1"),
with(NAME, "Default")), with(NAME, "Default")),
storeObjectDao.getGtasksList(1L)); googleTaskListDao.getById(1L));
} }
@Test @Test
public void testGetListByRemoteId() { public void testGetListByRemoteId() {
GtasksList list = newGtaskList(with(REMOTE_ID, "1")); GoogleTaskList list = newGtaskList(with(REMOTE_ID, "1"));
storeObjectDao.persist(list); list.setId(googleTaskListDao.insertOrReplace(list));
assertEquals(list, gtasksListService.getList("1")); assertEquals(list, gtasksListService.getList("1"));
} }
@ -83,19 +84,19 @@ public class GtasksListServiceTest extends InjectingTestCase {
@Test @Test
public void testDeleteMissingList() { public void testDeleteMissingList() {
storeObjectDao.persist(newGtaskList(with(ID, 1L), with(REMOTE_ID, "1"))); googleTaskListDao.insertOrReplace(newGtaskList(with(ID, 1L), with(REMOTE_ID, "1")));
TaskList taskList = newRemoteList(with(RemoteGtaskListMaker.REMOTE_ID, "2")); TaskList taskList = newRemoteList(with(RemoteGtaskListMaker.REMOTE_ID, "2"));
setLists(taskList); setLists(taskList);
assertEquals(singletonList(newGtaskList(with(ID, 2L), with(REMOTE_ID, "2")).getStoreObject()), assertEquals(singletonList(newGtaskList(with(ID, 2L), with(REMOTE_ID, "2"))),
storeObjectDao.getGtasksLists()); googleTaskListDao.getActiveLists());
} }
@Test @Test
public void testUpdateListName() { public void testUpdateListName() {
storeObjectDao.persist(newGtaskList( googleTaskListDao.insertOrReplace(newGtaskList(
with(ID, 1L), with(ID, 1L),
with(REMOTE_ID, "1"), with(REMOTE_ID, "1"),
with(NAME, "oldName"))); with(NAME, "oldName")));
@ -104,7 +105,7 @@ public class GtasksListServiceTest extends InjectingTestCase {
with(RemoteGtaskListMaker.REMOTE_ID, "1"), with(RemoteGtaskListMaker.REMOTE_ID, "1"),
with(RemoteGtaskListMaker.NAME, "newName"))); with(RemoteGtaskListMaker.NAME, "newName")));
assertEquals("newName", storeObjectDao.getGtasksList(1).getName()); assertEquals("newName", googleTaskListDao.getById(1).getTitle());
} }
@Test @Test

@ -16,6 +16,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.InjectingTestCase; import org.tasks.injection.InjectingTestCase;
import org.tasks.injection.TestComponent; import org.tasks.injection.TestComponent;
@ -157,7 +158,7 @@ public class GtasksTaskListUpdaterTest extends InjectingTestCase {
} }
void createParentSiblingMaps() { void createParentSiblingMaps() {
for(GtasksList list : gtasksListService.getLists()) { for(GoogleTaskList list : gtasksListService.getLists()) {
gtasksTaskListUpdater.updateParentSiblingMapsFor(list); gtasksTaskListUpdater.updateParentSiblingMapsFor(list);
} }
} }

@ -15,6 +15,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.InjectingTestCase; import org.tasks.injection.InjectingTestCase;
import org.tasks.injection.TestComponent; import org.tasks.injection.TestComponent;
@ -38,7 +39,7 @@ public class GtasksTaskMovingTest extends InjectingTestCase {
@Inject GoogleTaskDao googleTaskDao; @Inject GoogleTaskDao googleTaskDao;
private Task A, B, C, D, E, F; private Task A, B, C, D, E, F;
private GtasksList list; private GoogleTaskList list;
/* Starting State: /* Starting State:
* *

@ -2,7 +2,6 @@ package org.tasks.tasklist;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.gtasks.GtasksList;
public class GtasksListFragment extends TaskListFragment { public class GtasksListFragment extends TaskListFragment {
public static TaskListFragment newGtasksListFragment(GtasksFilter gtasksFilter, GtasksList list) { public static TaskListFragment newGtasksListFragment(GtasksFilter gtasksFilter, GtasksList list) {

@ -1,7 +1,6 @@
package org.tasks.ui; package org.tasks.ui;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;

@ -8,6 +8,7 @@ package com.todoroo.astrid.gtasks;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import org.tasks.data.GoogleTaskList;
import org.tasks.gtasks.SyncAdapterHelper; import org.tasks.gtasks.SyncAdapterHelper;
import java.util.List; import java.util.List;
@ -41,7 +42,7 @@ public class GtasksFilterExposer {
} }
List<Filter> listFilters = newArrayList(); List<Filter> listFilters = newArrayList();
for (GtasksList list : gtasksListService.getLists()) { for (GoogleTaskList list : gtasksListService.getLists()) {
listFilters.add(filterFromList(list)); listFilters.add(filterFromList(list));
} }
return listFilters; return listFilters;
@ -49,7 +50,7 @@ public class GtasksFilterExposer {
public Filter getFilter(long id) { public Filter getFilter(long id) {
if (syncAdapterHelper.isEnabled()) { if (syncAdapterHelper.isEnabled()) {
GtasksList list = gtasksListService.getList(id); GoogleTaskList list = gtasksListService.getList(id);
if (list != null) { if (list != null) {
return filterFromList(list); return filterFromList(list);
} }
@ -57,7 +58,7 @@ public class GtasksFilterExposer {
return null; return null;
} }
private Filter filterFromList(GtasksList list) { private Filter filterFromList(GoogleTaskList list) {
return new GtasksFilter(list); return new GtasksFilter(list);
} }
} }

@ -7,12 +7,13 @@ package com.todoroo.astrid.gtasks;
import com.google.api.services.tasks.model.TaskList; import com.google.api.services.tasks.model.TaskList;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import org.tasks.data.StoreObjectDao;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.TaskDeleter; import com.todoroo.astrid.service.TaskDeleter;
import org.tasks.LocalBroadcastManager; import org.tasks.LocalBroadcastManager;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao;
import org.tasks.data.TaskListDataProvider; import org.tasks.data.TaskListDataProvider;
import java.util.HashSet; import java.util.HashSet;
@ -24,34 +25,33 @@ import javax.inject.Inject;
import timber.log.Timber; import timber.log.Timber;
import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.transform;
import static org.tasks.time.DateTimeUtils.printTimestamp; import static org.tasks.time.DateTimeUtils.printTimestamp;
public class GtasksListService { public class GtasksListService {
private final StoreObjectDao storeObjectDao; private final GoogleTaskListDao googleTaskListDao;
private final TaskListDataProvider taskListDataProvider; private final TaskListDataProvider taskListDataProvider;
private final TaskDeleter taskDeleter; private final TaskDeleter taskDeleter;
private LocalBroadcastManager localBroadcastManager; private final LocalBroadcastManager localBroadcastManager;
private final GoogleTaskDao googleTaskDao; private final GoogleTaskDao googleTaskDao;
@Inject @Inject
public GtasksListService(StoreObjectDao storeObjectDao, TaskListDataProvider taskListDataProvider, public GtasksListService(GoogleTaskListDao googleTaskListDao, TaskListDataProvider taskListDataProvider,
TaskDeleter taskDeleter, LocalBroadcastManager localBroadcastManager, TaskDeleter taskDeleter, LocalBroadcastManager localBroadcastManager,
GoogleTaskDao googleTaskDao) { GoogleTaskDao googleTaskDao) {
this.storeObjectDao = storeObjectDao; this.googleTaskListDao = googleTaskListDao;
this.taskListDataProvider = taskListDataProvider; this.taskListDataProvider = taskListDataProvider;
this.taskDeleter = taskDeleter; this.taskDeleter = taskDeleter;
this.localBroadcastManager = localBroadcastManager; this.localBroadcastManager = localBroadcastManager;
this.googleTaskDao = googleTaskDao; this.googleTaskDao = googleTaskDao;
} }
public List<GtasksList> getLists() { public List<GoogleTaskList> getLists() {
return transform(storeObjectDao.getGtasksLists(), GtasksList::new); return googleTaskListDao.getActiveLists();
} }
public GtasksList getList(long id) { public GoogleTaskList getList(long id) {
return storeObjectDao.getGtasksList(id); return googleTaskListDao.getById(id);
} }
/** /**
@ -60,10 +60,10 @@ public class GtasksListService {
* @param remoteLists remote information about your lists * @param remoteLists remote information about your lists
*/ */
public synchronized void updateLists(List<TaskList> remoteLists) { public synchronized void updateLists(List<TaskList> remoteLists) {
List<GtasksList> lists = getLists(); List<GoogleTaskList> lists = getLists();
Set<Long> previousLists = new HashSet<>(); Set<Long> previousLists = new HashSet<>();
for(GtasksList list : lists) { for(GoogleTaskList list : lists) {
previousLists.add(list.getId()); previousLists.add(list.getId());
} }
@ -71,8 +71,8 @@ public class GtasksListService {
com.google.api.services.tasks.model.TaskList remote = remoteLists.get(i); com.google.api.services.tasks.model.TaskList remote = remoteLists.get(i);
String id = remote.getId(); String id = remote.getId();
GtasksList local = null; GoogleTaskList local = null;
for(GtasksList list : lists) { for(GoogleTaskList list : lists) {
if(list.getRemoteId().equals(id)) { if(list.getRemoteId().equals(id)) {
local = list; local = list;
break; break;
@ -82,24 +82,25 @@ public class GtasksListService {
String title = remote.getTitle(); String title = remote.getTitle();
if(local == null) { if(local == null) {
Timber.d("Adding new gtask list %s", title); Timber.d("Adding new gtask list %s", title);
local = new GtasksList(id); local = new GoogleTaskList();
local.setRemoteId(id);
} }
local.setName(title); local.setTitle(title);
local.setOrder(i); local.setRemoteOrder(i);
storeObjectDao.persist(local); googleTaskListDao.insertOrReplace(local);
previousLists.remove(local.getId()); previousLists.remove(local.getId());
} }
// check for lists that aren't on remote server // check for lists that aren't on remote server
for(Long listId : previousLists) { for(Long listId : previousLists) {
deleteList(storeObjectDao.getGtasksList(listId)); deleteList(googleTaskListDao.getById(listId));
} }
localBroadcastManager.broadcastRefreshList(); localBroadcastManager.broadcastRefreshList();
} }
public void deleteList(GtasksList gtasksList) { public void deleteList(GoogleTaskList gtasksList) {
List<Task> tasks = taskListDataProvider List<Task> tasks = taskListDataProvider
.constructCursor(new GtasksFilter(gtasksList), Task.PROPERTIES) .constructCursor(new GtasksFilter(gtasksList), Task.PROPERTIES)
.toList(); .toList();
@ -107,14 +108,14 @@ public class GtasksListService {
taskDeleter.delete(task); taskDeleter.delete(task);
} }
googleTaskDao.deleteList(gtasksList.getRemoteId()); googleTaskDao.deleteList(gtasksList.getRemoteId());
storeObjectDao.delete(gtasksList.getId()); googleTaskListDao.deleteById(gtasksList.getId());
} }
public List<GtasksList> getListsToUpdate(List<TaskList> remoteLists) { public List<GoogleTaskList> getListsToUpdate(List<TaskList> remoteLists) {
List<GtasksList> listsToUpdate = newArrayList(); List<GoogleTaskList> listsToUpdate = newArrayList();
for (TaskList remoteList : remoteLists) { for (TaskList remoteList : remoteLists) {
GtasksList localList = getList(remoteList.getId()); GoogleTaskList localList = getList(remoteList.getId());
String listName = localList.getName(); String listName = localList.getTitle();
Long lastSync = localList.getLastSync(); Long lastSync = localList.getLastSync();
long lastUpdate = remoteList.getUpdated().getValue(); long lastUpdate = remoteList.getUpdated().getValue();
if (lastSync < lastUpdate) { if (lastSync < lastUpdate) {
@ -127,8 +128,8 @@ public class GtasksListService {
return listsToUpdate; return listsToUpdate;
} }
public GtasksList getList(String listId) { public GoogleTaskList getList(String listId) {
for(GtasksList list : getLists()) { for(GoogleTaskList list : getLists()) {
if (list != null && list.getRemoteId().equals(listId)) { if (list != null && list.getRemoteId().equals(listId)) {
return list; return list;
} }

@ -18,6 +18,7 @@ import org.tasks.R;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking; import org.tasks.analytics.Tracking;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.GoogleTaskListSelectionHandler; import org.tasks.gtasks.GoogleTaskListSelectionHandler;
import org.tasks.gtasks.PlayServicesAvailability; import org.tasks.gtasks.PlayServicesAvailability;
@ -99,13 +100,13 @@ public class GtasksPreferences extends InjectingPreferenceActivity implements Go
.show(getFragmentManager(), FRAG_TAG_GOOGLE_TASK_LIST_SELECTION); .show(getFragmentManager(), FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
return false; return false;
}); });
GtasksList defaultList = getDefaultList(); GoogleTaskList defaultList = getDefaultList();
if (defaultList != null) { if (defaultList != null) {
defaultListPreference.setSummary(defaultList.getName()); defaultListPreference.setSummary(defaultList.getTitle());
} }
} }
private GtasksList getDefaultList() { private GoogleTaskList getDefaultList() {
return gtasksListService.getList(gtasksPreferenceService.getDefaultList()); return gtasksListService.getList(gtasksPreferenceService.getDefaultList());
} }
@ -157,11 +158,10 @@ public class GtasksPreferences extends InjectingPreferenceActivity implements Go
} }
@Override @Override
public void selectedList(GtasksList list) { public void selectedList(GoogleTaskList list) {
tracker.reportEvent(Tracking.Events.GTASK_DEFAULT_LIST); tracker.reportEvent(Tracking.Events.GTASK_DEFAULT_LIST);
String listId = list.getRemoteId(); String listId = list.getRemoteId();
gtasksPreferenceService.setDefaultList(listId); gtasksPreferenceService.setDefaultList(listId);
findPreference(R.string.p_gtasks_default_list).setSummary(list.getName()); findPreference(R.string.p_gtasks_default_list).setSummary(list.getTitle());
} }
} }

@ -17,6 +17,7 @@ import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;
import org.tasks.tasklist.GtasksListFragment; import org.tasks.tasklist.GtasksListFragment;
@ -29,7 +30,7 @@ import javax.inject.Inject;
public class GtasksSubtaskListFragment extends GtasksListFragment { public class GtasksSubtaskListFragment extends GtasksListFragment {
public static TaskListFragment newGtasksSubtaskListFragment(GtasksFilter filter, GtasksList list) { public static TaskListFragment newGtasksSubtaskListFragment(GtasksFilter filter, GoogleTaskList list) {
GtasksSubtaskListFragment fragment = new GtasksSubtaskListFragment(); GtasksSubtaskListFragment fragment = new GtasksSubtaskListFragment();
fragment.filter = filter; fragment.filter = filter;
fragment.list = list; fragment.list = list;

@ -12,6 +12,7 @@ import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.ApplicationScope; import org.tasks.injection.ApplicationScope;
import java.util.ArrayList; import java.util.ArrayList;
@ -56,7 +57,7 @@ public class GtasksTaskListUpdater {
return googleTaskDao.getByTaskId(taskId); return googleTaskDao.getByTaskId(taskId);
} }
private void iterateThroughList(GtasksList list, OrderedListIterator iterator) { private void iterateThroughList(GoogleTaskList list, OrderedListIterator iterator) {
String listId = list.getRemoteId(); String listId = list.getRemoteId();
gtasksSyncService.iterateThroughList(listId, iterator, 0, false); gtasksSyncService.iterateThroughList(listId, iterator, 0, false);
} }
@ -85,7 +86,7 @@ public class GtasksTaskListUpdater {
} }
} }
void updateParentSiblingMapsFor(GtasksList list) { void updateParentSiblingMapsFor(GoogleTaskList list) {
final AtomicLong previousTask = new AtomicLong(Task.NO_ID); final AtomicLong previousTask = new AtomicLong(Task.NO_ID);
final AtomicInteger previousIndent = new AtomicInteger(-1); final AtomicInteger previousIndent = new AtomicInteger(-1);
@ -130,7 +131,7 @@ public class GtasksTaskListUpdater {
/** /**
* Indent a task and all its children * Indent a task and all its children
*/ */
public void indent(final GtasksList list, final long targetTaskId, final int delta) { public void indent(final GoogleTaskList list, final long targetTaskId, final int delta) {
if(list == null) { if(list == null) {
return; return;
} }
@ -184,7 +185,7 @@ public class GtasksTaskListUpdater {
* Helper function to iterate through a list and compute a new parent for the target task * Helper function to iterate through a list and compute a new parent for the target task
* based on the target parent's indent * based on the target parent's indent
*/ */
private long computeNewParent(GtasksList list, long targetTaskId, int targetParentIndent) { private long computeNewParent(GoogleTaskList list, long targetTaskId, int targetParentIndent) {
final AtomicInteger desiredParentIndent = new AtomicInteger(targetParentIndent); final AtomicInteger desiredParentIndent = new AtomicInteger(targetParentIndent);
final AtomicLong targetTask = new AtomicLong(targetTaskId); final AtomicLong targetTask = new AtomicLong(targetTaskId);
final AtomicLong lastPotentialParent = new AtomicLong(Task.NO_ID); final AtomicLong lastPotentialParent = new AtomicLong(Task.NO_ID);
@ -213,7 +214,7 @@ public class GtasksTaskListUpdater {
* Move a task and all its children to the position right above * Move a task and all its children to the position right above
* taskIdToMoveto. Will change the indent level to match taskIdToMoveTo. * taskIdToMoveto. Will change the indent level to match taskIdToMoveTo.
*/ */
void moveTo(GtasksList list, final long targetTaskId, void moveTo(GoogleTaskList list, final long targetTaskId,
final long moveBeforeTaskId) { final long moveBeforeTaskId) {
if(list == null) { if(list == null) {
return; return;
@ -269,7 +270,7 @@ public class GtasksTaskListUpdater {
} }
} }
private void traverseTreeAndWriteValues(GtasksList list, Node node, AtomicLong order, int indent) { private void traverseTreeAndWriteValues(GoogleTaskList list, Node node, AtomicLong order, int indent) {
if(node.taskId != Task.NO_ID) { if(node.taskId != Task.NO_ID) {
GoogleTask googleTask = getTaskMetadata(node.taskId); GoogleTask googleTask = getTaskMetadata(node.taskId);
if(googleTask == null) { if(googleTask == null) {
@ -306,7 +307,7 @@ public class GtasksTaskListUpdater {
return null; return null;
} }
private Node buildTreeModel(GtasksList list) { private Node buildTreeModel(GoogleTaskList list) {
final Node root = new Node(Task.NO_ID, null); final Node root = new Node(Task.NO_ID, null);
final AtomicInteger previoustIndent = new AtomicInteger(-1); final AtomicInteger previoustIndent = new AtomicInteger(-1);
final AtomicReference<Node> currentNode = new AtomicReference<>(root); final AtomicReference<Node> currentNode = new AtomicReference<>(root);
@ -354,7 +355,7 @@ public class GtasksTaskListUpdater {
/** /**
* Apply an operation only to the children of the task * Apply an operation only to the children of the task
*/ */
void applyToChildren(GtasksList list, long targetTaskId, void applyToChildren(GoogleTaskList list, long targetTaskId,
OrderedListNodeVisitor visitor) { OrderedListNodeVisitor visitor) {
Node root = buildTreeModel(list); Node root = buildTreeModel(list);
@ -377,7 +378,7 @@ public class GtasksTaskListUpdater {
/** /**
* Removes a task from the order hierarchy and un-indent children * Removes a task from the order hierarchy and un-indent children
*/ */
void onDeleteTask(GtasksList list, final long targetTaskId) { void onDeleteTask(GoogleTaskList list, final long targetTaskId) {
if(list == null) { if(list == null) {
return; return;
} }

@ -19,6 +19,7 @@ import com.todoroo.astrid.data.Task;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -38,7 +39,7 @@ class OrderedMetadataListFragmentHelper {
private DraggableTaskAdapter taskAdapter; private DraggableTaskAdapter taskAdapter;
private TaskListFragment fragment; private TaskListFragment fragment;
private GtasksList list; private GoogleTaskList list;
@Inject @Inject
OrderedMetadataListFragmentHelper(TaskDao taskDao, GtasksTaskListUpdater updater, GoogleTaskDao googleTaskDao) { OrderedMetadataListFragmentHelper(TaskDao taskDao, GtasksTaskListUpdater updater, GoogleTaskDao googleTaskDao) {
@ -168,7 +169,7 @@ class OrderedMetadataListFragmentHelper {
} }
} }
public void setList(GtasksList list) { public void setList(GoogleTaskList list) {
this.list = list; this.list = list;
} }

@ -5,10 +5,10 @@
*/ */
package com.todoroo.astrid.service; package com.todoroo.astrid.service;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.sync.GtasksSyncService; import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import org.tasks.data.GoogleTaskList;
import org.tasks.gtasks.SyncAdapterHelper; import org.tasks.gtasks.SyncAdapterHelper;
import org.tasks.sync.SyncExecutor; import org.tasks.sync.SyncExecutor;
@ -38,7 +38,7 @@ public class SyncV2Service {
this.gtasksSyncService = gtasksSyncService; this.gtasksSyncService = gtasksSyncService;
} }
public void clearCompleted(final GtasksList list, final SyncResultCallback callback) { public void clearCompleted(final GoogleTaskList list, final SyncResultCallback callback) {
if (syncAdapterHelper.isEnabled()) { if (syncAdapterHelper.isEnabled()) {
syncExecutor.execute(callback, () -> { syncExecutor.execute(callback, () -> {
callback.started(); callback.started();

@ -14,9 +14,10 @@ import android.widget.Toast;
import com.google.api.services.tasks.model.TaskList; import com.google.api.services.tasks.model.TaskList;
import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import org.tasks.data.StoreObjectDao;
import org.tasks.data.StoreObject; import org.tasks.data.GoogleTaskList;
import com.todoroo.astrid.gtasks.GtasksList; import org.tasks.data.GoogleTaskListDao;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import org.tasks.R; import org.tasks.R;
@ -61,10 +62,10 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
public static final String ACTION_RELOAD = "action_reload"; public static final String ACTION_RELOAD = "action_reload";
private boolean isNewList; private boolean isNewList;
private GtasksList gtasksList; private GoogleTaskList gtasksList;
private int selectedTheme; private int selectedTheme;
@Inject StoreObjectDao storeObjectDao; @Inject GoogleTaskListDao googleTaskListDao;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject GtasksListService gtasksListService; @Inject GtasksListService gtasksListService;
@ -83,21 +84,21 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
setContentView(R.layout.activity_google_task_list_settings); setContentView(R.layout.activity_google_task_list_settings);
ButterKnife.bind(this); ButterKnife.bind(this);
StoreObject storeObject = getIntent().getParcelableExtra(EXTRA_STORE_DATA); gtasksList = getIntent().getParcelableExtra(EXTRA_STORE_DATA);
if (storeObject == null) { if (gtasksList == null) {
isNewList = true; isNewList = true;
storeObject = new StoreObject(); gtasksList = new GoogleTaskList();
storeObject.setType(GtasksList.TYPE);
} }
gtasksList = new GtasksList(storeObject);
if (savedInstanceState == null) { if (savedInstanceState == null) {
selectedTheme = gtasksList.getColor(); Integer color = gtasksList.getColor();
selectedTheme = color == null ? -1 : color;
} else { } else {
selectedTheme = savedInstanceState.getInt(EXTRA_SELECTED_THEME); selectedTheme = savedInstanceState.getInt(EXTRA_SELECTED_THEME);
} }
final boolean backButtonSavesTask = preferences.backButtonSavesTask(); final boolean backButtonSavesTask = preferences.backButtonSavesTask();
toolbar.setTitle(isNewList ? getString(R.string.new_list) : gtasksList.getName()); toolbar.setTitle(isNewList ? getString(R.string.new_list) : gtasksList.getTitle());
toolbar.setNavigationIcon(ContextCompat.getDrawable(this, toolbar.setNavigationIcon(ContextCompat.getDrawable(this,
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp)); backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp));
toolbar.setNavigationOnClickListener(v -> { toolbar.setNavigationOnClickListener(v -> {
@ -121,7 +122,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT);
} else { } else {
name.setText(gtasksList.getName()); name.setText(gtasksList.getTitle());
} }
updateTheme(); updateTheme();
@ -173,7 +174,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
} else { } else {
if (colorChanged()) { if (colorChanged()) {
gtasksList.setColor(selectedTheme); gtasksList.setColor(selectedTheme);
storeObjectDao.persist(gtasksList); googleTaskListDao.insertOrReplace(gtasksList);
setResult(RESULT_OK, new Intent(ACTION_RELOAD).putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); setResult(RESULT_OK, new Intent(ACTION_RELOAD).putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
} }
finish(); finish();
@ -197,7 +198,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
} }
private void deleteTag() { private void deleteTag() {
dialogBuilder.newMessageDialog(R.string.delete_tag_confirmation, gtasksList.getName()) dialogBuilder.newMessageDialog(R.string.delete_tag_confirmation, gtasksList.getTitle())
.setPositiveButton(R.string.delete, (dialog, which) -> newDeleteListDialog(gtasksList.getRemoteId()) .setPositiveButton(R.string.delete, (dialog, which) -> newDeleteListDialog(gtasksList.getRemoteId())
.show(getSupportFragmentManager(), FRAG_TAG_DELETE_LIST_DIALOG)) .show(getSupportFragmentManager(), FRAG_TAG_DELETE_LIST_DIALOG))
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -241,16 +242,17 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
} }
private boolean nameChanged() { private boolean nameChanged() {
return !getNewName().equals(gtasksList.getName()); return !getNewName().equals(gtasksList.getTitle());
} }
@Override @Override
public void onListCreated(TaskList taskList) { public void onListCreated(TaskList taskList) {
tracker.reportEvent(Tracking.Events.GTASK_NEW_LIST); tracker.reportEvent(Tracking.Events.GTASK_NEW_LIST);
gtasksList = new GtasksList(taskList.getId()); gtasksList = new GoogleTaskList();
gtasksList.setName(taskList.getTitle()); gtasksList.setRemoteId(taskList.getId());
gtasksList.setTitle(taskList.getTitle());
gtasksList.setColor(selectedTheme); gtasksList.setColor(selectedTheme);
storeObjectDao.persist(gtasksList); gtasksList.setId(googleTaskListDao.insertOrReplace(gtasksList));
setResult(RESULT_OK, new Intent().putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); setResult(RESULT_OK, new Intent().putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
finish(); finish();
} }
@ -266,9 +268,9 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
@Override @Override
public void onListRenamed(TaskList taskList) { public void onListRenamed(TaskList taskList) {
tracker.reportEvent(Tracking.Events.GTASK_RENAME_LIST); tracker.reportEvent(Tracking.Events.GTASK_RENAME_LIST);
gtasksList.setName(taskList.getTitle()); gtasksList.setTitle(taskList.getTitle());
gtasksList.setColor(selectedTheme); gtasksList.setColor(selectedTheme);
storeObjectDao.persist(gtasksList); googleTaskListDao.insertOrReplace(gtasksList);
setResult(RESULT_OK, new Intent(ACTION_RELOAD).putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); setResult(RESULT_OK, new Intent(ACTION_RELOAD).putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
finish(); finish();
} }

@ -4,10 +4,9 @@ import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.os.Bundle; import android.os.Bundle;
import org.tasks.data.StoreObject;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import org.tasks.data.GoogleTaskList;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.GoogleTaskListSelectionHandler; import org.tasks.gtasks.GoogleTaskListSelectionHandler;
import org.tasks.injection.InjectingNativeDialogFragment; import org.tasks.injection.InjectingNativeDialogFragment;
@ -21,11 +20,11 @@ import static org.tasks.activities.SupportGoogleTaskListPicker.createDialog;
public class NativeGoogleTaskListPicker extends InjectingNativeDialogFragment { public class NativeGoogleTaskListPicker extends InjectingNativeDialogFragment {
public static NativeGoogleTaskListPicker newNativeGoogleTaskListPicker(GtasksList defaultList) { public static NativeGoogleTaskListPicker newNativeGoogleTaskListPicker(GoogleTaskList defaultList) {
NativeGoogleTaskListPicker dialog = new NativeGoogleTaskListPicker(); NativeGoogleTaskListPicker dialog = new NativeGoogleTaskListPicker();
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
if (defaultList != null) { if (defaultList != null) {
arguments.putParcelable(EXTRA_SELECTED, defaultList.getStoreObject()); arguments.putParcelable(EXTRA_SELECTED, defaultList);
} }
dialog.setArguments(arguments); dialog.setArguments(arguments);
return dialog; return dialog;
@ -43,11 +42,7 @@ public class NativeGoogleTaskListPicker extends InjectingNativeDialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
StoreObject storeObject = arguments.getParcelable(EXTRA_SELECTED); GoogleTaskList selected = arguments.getParcelable(EXTRA_SELECTED);
GtasksList selected = null;
if (storeObject != null) {
selected = new GtasksList(storeObject);
}
return createDialog(getActivity(), themeCache, dialogBuilder, gtasksListService, return createDialog(getActivity(), themeCache, dialogBuilder, gtasksListService,
selected, themeAccent, list -> handler.selectedList(list)); selected, themeAccent, list -> handler.selectedList(list));
} }

@ -7,11 +7,10 @@ import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import org.tasks.data.StoreObject;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.GoogleTaskList;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.GoogleTaskListSelectionHandler; import org.tasks.gtasks.GoogleTaskListSelectionHandler;
import org.tasks.injection.DialogFragmentComponent; import org.tasks.injection.DialogFragmentComponent;
@ -28,11 +27,11 @@ import static com.google.common.collect.Lists.transform;
public class SupportGoogleTaskListPicker extends InjectingDialogFragment { public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
public static SupportGoogleTaskListPicker newSupportGoogleTaskListPicker(GtasksList selected) { public static SupportGoogleTaskListPicker newSupportGoogleTaskListPicker(GoogleTaskList selected) {
SupportGoogleTaskListPicker dialog = new SupportGoogleTaskListPicker(); SupportGoogleTaskListPicker dialog = new SupportGoogleTaskListPicker();
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
if (selected != null) { if (selected != null) {
arguments.putParcelable(EXTRA_SELECTED, selected.getStoreObject()); arguments.putParcelable(EXTRA_SELECTED, selected);
} }
dialog.setArguments(arguments); dialog.setArguments(arguments);
return dialog; return dialog;
@ -51,11 +50,7 @@ public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
StoreObject storeObject = arguments.getParcelable(EXTRA_SELECTED); GoogleTaskList selected = arguments == null ? null : arguments.getParcelable(EXTRA_SELECTED);
GtasksList selected = null;
if (storeObject != null) {
selected = new GtasksList(storeObject);
}
return createDialog(getActivity(), themeCache, dialogBuilder, gtasksListService, return createDialog(getActivity(), themeCache, dialogBuilder, gtasksListService,
selected, themeAccent, list -> handler.selectedList(list)); selected, themeAccent, list -> handler.selectedList(list));
} }
@ -69,10 +64,10 @@ public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
public static AlertDialog createDialog(Context context, ThemeCache themeCache, public static AlertDialog createDialog(Context context, ThemeCache themeCache,
DialogBuilder dialogBuilder, GtasksListService gtasksListService, DialogBuilder dialogBuilder, GtasksListService gtasksListService,
GtasksList selected, ThemeAccent themeAccent, GoogleTaskList selected, ThemeAccent themeAccent,
final GoogleTaskListSelectionHandler handler) { final GoogleTaskListSelectionHandler handler) {
final List<GtasksList> lists = gtasksListService.getLists(); final List<GoogleTaskList> lists = gtasksListService.getLists();
List<String> listNames = transform(lists, GtasksList::getName); List<String> listNames = transform(lists, GoogleTaskList::getTitle);
SingleCheckedArrayAdapter adapter = new SingleCheckedArrayAdapter(context, listNames, themeAccent) { SingleCheckedArrayAdapter adapter = new SingleCheckedArrayAdapter(context, listNames, themeAccent) {
@Override @Override
protected int getDrawable(int position) { protected int getDrawable(int position) {
@ -81,7 +76,7 @@ public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
@Override @Override
protected int getDrawableColor(int position) { protected int getDrawableColor(int position) {
GtasksList list = lists.get(position); GoogleTaskList list = lists.get(position);
int color = list.getColor(); int color = list.getColor();
return color >= 0 return color >= 0
? themeCache.getThemeColor(color).getPrimaryColor() ? themeCache.getThemeColor(color).getPrimaryColor()
@ -89,7 +84,7 @@ public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
} }
}; };
if (selected != null) { if (selected != null) {
adapter.setChecked(selected.getName()); adapter.setChecked(selected.getTitle());
} }
return dialogBuilder.newDialog() return dialogBuilder.newDialog()
.setSingleChoiceItems(adapter, -1, (dialog, which) -> { .setSingleChoiceItems(adapter, -1, (dialog, which) -> {

@ -38,11 +38,9 @@ import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import org.tasks.data.StoreObjectDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.SyncFlags; import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.GtasksTaskListUpdater; import com.todoroo.astrid.gtasks.GtasksTaskListUpdater;
@ -58,6 +56,8 @@ import org.tasks.R;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao;
import org.tasks.injection.InjectingAbstractThreadedSyncAdapter; import org.tasks.injection.InjectingAbstractThreadedSyncAdapter;
import org.tasks.injection.SyncAdapterComponent; import org.tasks.injection.SyncAdapterComponent;
import org.tasks.notifications.NotificationManager; import org.tasks.notifications.NotificationManager;
@ -90,7 +90,7 @@ public class GoogleTaskSyncAdapter extends InjectingAbstractThreadedSyncAdapter
@Inject GtasksPreferenceService gtasksPreferenceService; @Inject GtasksPreferenceService gtasksPreferenceService;
@Inject LocalBroadcastManager localBroadcastManager; @Inject LocalBroadcastManager localBroadcastManager;
@Inject StoreObjectDao storeObjectDao; @Inject GoogleTaskListDao googleTaskListDao;
@Inject GtasksSyncService gtasksSyncService; @Inject GtasksSyncService gtasksSyncService;
@Inject GtasksListService gtasksListService; @Inject GtasksListService gtasksListService;
@Inject GtasksTaskListUpdater gtasksTaskListUpdater; @Inject GtasksTaskListUpdater gtasksTaskListUpdater;
@ -181,7 +181,7 @@ public class GoogleTaskSyncAdapter extends InjectingAbstractThreadedSyncAdapter
if (gtasksListService.getList(gtasksPreferenceService.getDefaultList()) == null) { if (gtasksListService.getList(gtasksPreferenceService.getDefaultList()) == null) {
gtasksPreferenceService.setDefaultList(null); gtasksPreferenceService.setDefaultList(null);
} }
for (final GtasksList list : gtasksListService.getListsToUpdate(gtaskLists)) { for (final GoogleTaskList list : gtasksListService.getListsToUpdate(gtaskLists)) {
fetchAndApplyRemoteChanges(list); fetchAndApplyRemoteChanges(list);
} }
} }
@ -305,7 +305,7 @@ public class GoogleTaskSyncAdapter extends InjectingAbstractThreadedSyncAdapter
taskDao.saveExistingWithSqlConstraintCheck(task); taskDao.saveExistingWithSqlConstraintCheck(task);
} }
private synchronized void fetchAndApplyRemoteChanges(GtasksList list) throws UserRecoverableAuthIOException { private synchronized void fetchAndApplyRemoteChanges(GoogleTaskList list) throws UserRecoverableAuthIOException {
String listId = list.getRemoteId(); String listId = list.getRemoteId();
long lastSyncDate = list.getLastSync(); long lastSyncDate = list.getLastSync();
@ -337,7 +337,7 @@ public class GoogleTaskSyncAdapter extends InjectingAbstractThreadedSyncAdapter
lastSyncDate = Math.max(lastSyncDate, container.getUpdateTime()); lastSyncDate = Math.max(lastSyncDate, container.getUpdateTime());
} }
list.setLastSync(lastSyncDate); list.setLastSync(lastSyncDate);
storeObjectDao.persist(list); googleTaskListDao.insertOrReplace(list);
gtasksTaskListUpdater.correctOrderAndIndentForList(listId); gtasksTaskListUpdater.correctOrderAndIndentForList(listId);
} }
} catch (UserRecoverableAuthIOException e) { } catch (UserRecoverableAuthIOException e) {

@ -9,14 +9,13 @@ import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import org.tasks.data.StoreObject;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.service.SyncV2Service; import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import org.tasks.R; import org.tasks.R;
import org.tasks.activities.GoogleTaskListSettingsActivity; import org.tasks.activities.GoogleTaskListSettingsActivity;
import org.tasks.analytics.Tracking; import org.tasks.analytics.Tracking;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;
import javax.inject.Inject; import javax.inject.Inject;
@ -25,7 +24,7 @@ import static android.app.Activity.RESULT_OK;
public class GtasksListFragment extends TaskListFragment { public class GtasksListFragment extends TaskListFragment {
public static TaskListFragment newGtasksListFragment(GtasksFilter filter, GtasksList list) { public static TaskListFragment newGtasksListFragment(GtasksFilter filter, GoogleTaskList list) {
GtasksListFragment fragment = new GtasksListFragment(); GtasksListFragment fragment = new GtasksListFragment();
fragment.filter = filter; fragment.filter = filter;
fragment.list = list; fragment.list = list;
@ -37,15 +36,14 @@ public class GtasksListFragment extends TaskListFragment {
@Inject SyncV2Service syncService; @Inject SyncV2Service syncService;
protected GtasksList list; protected GoogleTaskList list;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null) {
StoreObject storeObject = savedInstanceState.getParcelable(EXTRA_STORE_OBJECT); list = savedInstanceState.getParcelable(EXTRA_STORE_OBJECT);
list = new GtasksList(storeObject);
} }
} }
@ -60,7 +58,7 @@ public class GtasksListFragment extends TaskListFragment {
switch(item.getItemId()) { switch(item.getItemId()) {
case R.id.menu_gtasks_list_settings: case R.id.menu_gtasks_list_settings:
Intent intent = new Intent(getActivity(), GoogleTaskListSettingsActivity.class); Intent intent = new Intent(getActivity(), GoogleTaskListSettingsActivity.class);
intent.putExtra(GoogleTaskListSettingsActivity.EXTRA_STORE_DATA, list.getStoreObject()); intent.putExtra(GoogleTaskListSettingsActivity.EXTRA_STORE_DATA, list);
startActivityForResult(intent, REQUEST_LIST_SETTINGS); startActivityForResult(intent, REQUEST_LIST_SETTINGS);
return true; return true;
default: default:
@ -108,7 +106,7 @@ public class GtasksListFragment extends TaskListFragment {
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putParcelable(EXTRA_STORE_OBJECT, list.getStoreObject()); outState.putParcelable(EXTRA_STORE_OBJECT, list);
} }
@Override @Override

@ -7,10 +7,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.tasks.data.StoreObject;
import com.todoroo.astrid.data.SyncFlags; import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.GtasksPreferenceService;
@ -19,6 +17,7 @@ import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking; import org.tasks.analytics.Tracking;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.injection.FragmentComponent; import org.tasks.injection.FragmentComponent;
import javax.inject.Inject; import javax.inject.Inject;
@ -46,8 +45,8 @@ public class GoogleTaskListFragment extends TaskEditControlFragment {
@Inject Tracker tracker; @Inject Tracker tracker;
private long taskId; private long taskId;
@Nullable private GtasksList originalList; @Nullable private GoogleTaskList originalList;
@Nullable private GtasksList selectedList; @Nullable private GoogleTaskList selectedList;
@Nullable @Nullable
@Override @Override
@ -56,14 +55,8 @@ public class GoogleTaskListFragment extends TaskEditControlFragment {
if (savedInstanceState != null) { if (savedInstanceState != null) {
taskId = savedInstanceState.getLong(EXTRA_TASK_ID); taskId = savedInstanceState.getLong(EXTRA_TASK_ID);
StoreObject originalStoreObject = savedInstanceState.getParcelable(EXTRA_ORIGINAL_LIST); originalList = savedInstanceState.getParcelable(EXTRA_ORIGINAL_LIST);
if (originalStoreObject != null) { selectedList = savedInstanceState.getParcelable(EXTRA_SELECTED_LIST);
originalList = new GtasksList(originalStoreObject);
}
StoreObject selectedStoreObject = savedInstanceState.getParcelable(EXTRA_SELECTED_LIST);
if (selectedStoreObject != null) {
selectedList = new GtasksList(selectedStoreObject);
}
} else { } else {
GoogleTask googleTask = googleTaskDao.getByTaskId(taskId); GoogleTask googleTask = googleTaskDao.getByTaskId(taskId);
if (googleTask != null) { if (googleTask != null) {
@ -85,10 +78,10 @@ public class GoogleTaskListFragment extends TaskEditControlFragment {
outState.putLong(EXTRA_TASK_ID, taskId); outState.putLong(EXTRA_TASK_ID, taskId);
if (originalList != null) { if (originalList != null) {
outState.putParcelable(EXTRA_ORIGINAL_LIST, originalList.getStoreObject()); outState.putParcelable(EXTRA_ORIGINAL_LIST, originalList);
} }
if (selectedList != null) { if (selectedList != null) {
outState.putParcelable(EXTRA_SELECTED_LIST, selectedList.getStoreObject()); outState.putParcelable(EXTRA_SELECTED_LIST, selectedList);
} }
} }
@ -146,14 +139,14 @@ public class GoogleTaskListFragment extends TaskEditControlFragment {
component.inject(this); component.inject(this);
} }
public void setList(GtasksList list) { public void setList(GoogleTaskList list) {
this.selectedList = list; this.selectedList = list;
refreshView(); refreshView();
} }
private void refreshView() { private void refreshView() {
if (selectedList != null) { if (selectedList != null) {
textView.setText(selectedList.getName()); textView.setText(selectedList.getTitle());
} }
} }
} }

@ -22,11 +22,12 @@ import android.widget.LinearLayout;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.UserActivityDao; import org.tasks.data.UserActivityDao;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import org.tasks.data.UserActivity; import org.tasks.data.UserActivity;
import com.todoroo.astrid.files.FilesControlSet; import com.todoroo.astrid.files.FilesControlSet;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.notes.CommentsController; import com.todoroo.astrid.notes.CommentsController;
import com.todoroo.astrid.repeats.RepeatControlSet; import com.todoroo.astrid.repeats.RepeatControlSet;
import com.todoroo.astrid.service.TaskDeleter; import com.todoroo.astrid.service.TaskDeleter;
@ -321,7 +322,7 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
getEditTitleControlSet().repeatChanged(repeat); getEditTitleControlSet().repeatChanged(repeat);
} }
public void onGoogleTaskListChanged(GtasksList list) { public void onGoogleTaskListChanged(GoogleTaskList list) {
getGoogleTaskListFragment().setList(list); getGoogleTaskListFragment().setList(list);
} }

@ -23,11 +23,12 @@ import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.api.PermaSql; import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.api.TagFilter; import com.todoroo.astrid.api.TagFilter;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.TagDataDao; import org.tasks.data.TagDataDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import org.tasks.data.TagData; import org.tasks.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import com.todoroo.astrid.gtasks.GtasksSubtaskListFragment; import com.todoroo.astrid.gtasks.GtasksSubtaskListFragment;
import com.todoroo.astrid.repeats.RepeatControlSet; import com.todoroo.astrid.repeats.RepeatControlSet;
@ -317,7 +318,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
} }
} else if (filter instanceof GtasksFilter) { } else if (filter instanceof GtasksFilter) {
GtasksFilter gtasksFilter = (GtasksFilter) filter; GtasksFilter gtasksFilter = (GtasksFilter) filter;
GtasksList list = gtasksListService.getList(gtasksFilter.getStoreId()); GoogleTaskList list = gtasksListService.getList(gtasksFilter.getStoreId());
if (list != null) { if (list != null) {
return preferences.getBoolean(R.string.p_manual_sort, false) return preferences.getBoolean(R.string.p_manual_sort, false)
? GtasksSubtaskListFragment.newGtasksSubtaskListFragment(gtasksFilter, list) ? GtasksSubtaskListFragment.newGtasksSubtaskListFragment(gtasksFilter, list)
@ -503,7 +504,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
} }
@Override @Override
public void selectedList(GtasksList list) { public void selectedList(GoogleTaskList list) {
getTaskEditFragment().onGoogleTaskListChanged(list); getTaskEditFragment().onGoogleTaskListChanged(list);
} }

@ -9,10 +9,10 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -27,10 +27,12 @@ public class GtasksFilter extends Filter {
super(); super();
} }
public GtasksFilter(GtasksList list) { public GtasksFilter(GoogleTaskList list) {
super(list.getName(), getQueryTemplate(list), getValuesForNewTasks(list)); super(list.getTitle(), getQueryTemplate(list), getValuesForNewTasks(list));
storeId = list.getId(); storeId = list.getId();
if (list.hasColor()) {
tint = list.getColor(); tint = list.getColor();
}
icon = CLOUD; icon = CLOUD;
} }
@ -46,7 +48,7 @@ public class GtasksFilter extends Filter {
return storeId; return storeId;
} }
private static QueryTemplate getQueryTemplate(GtasksList list) { private static QueryTemplate getQueryTemplate(GoogleTaskList list) {
return new QueryTemplate() return new QueryTemplate()
.join(Join.left(GoogleTask.TABLE, Task.ID.eq(Field.field("google_tasks.task")))) .join(Join.left(GoogleTask.TABLE, Task.ID.eq(Field.field("google_tasks.task"))))
.where(Criterion.and( .where(Criterion.and(
@ -54,7 +56,7 @@ public class GtasksFilter extends Filter {
Field.field("list_id").eq(list.getRemoteId()))); Field.field("list_id").eq(list.getRemoteId())));
} }
private static Map<String, Object> getValuesForNewTasks(GtasksList list) { private static Map<String, Object> getValuesForNewTasks(GoogleTaskList list) {
Map<String, Object> values = new HashMap<>(); Map<String, Object> values = new HashMap<>();
values.put(GoogleTask.KEY, list.getRemoteId()); values.put(GoogleTask.KEY, list.getRemoteId());
return values; return values;

@ -36,7 +36,6 @@ import com.todoroo.astrid.data.Task;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.FilterDao; import org.tasks.data.FilterDao;
import org.tasks.data.StoreObjectDao;
import org.tasks.dialogs.DialogBuilder; import org.tasks.dialogs.DialogBuilder;
import org.tasks.filters.FilterCriteriaProvider; import org.tasks.filters.FilterCriteriaProvider;
import org.tasks.injection.ActivityComponent; import org.tasks.injection.ActivityComponent;
@ -137,7 +136,6 @@ public class CustomFilterActivity extends ThemedInjectingAppCompatActivity imple
@Inject Database database; @Inject Database database;
@Inject FilterDao filterDao; @Inject FilterDao filterDao;
@Inject StoreObjectDao storeObjectDao;
@Inject DialogBuilder dialogBuilder; @Inject DialogBuilder dialogBuilder;
@Inject FilterCriteriaProvider filterCriteriaProvider; @Inject FilterCriteriaProvider filterCriteriaProvider;
@Inject Locale locale; @Inject Locale locale;

@ -18,9 +18,9 @@ import com.todoroo.andlib.utility.AndroidUtilities;
import org.tasks.data.Filter; import org.tasks.data.Filter;
import org.tasks.data.FilterDao; import org.tasks.data.FilterDao;
import org.tasks.data.StoreObject; import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao;
import org.tasks.data.StoreObjectDao;
import org.tasks.data.TagData; import org.tasks.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import org.tasks.data.TaskAttachment; import org.tasks.data.TaskAttachment;
@ -59,15 +59,15 @@ import timber.log.Timber;
UserActivity.class, UserActivity.class,
TaskAttachment.class, TaskAttachment.class,
TaskListMetadata.class, TaskListMetadata.class,
StoreObject.class,
Task.class, Task.class,
Alarm.class, Alarm.class,
Location.class, Location.class,
Tag.class, Tag.class,
GoogleTask.class, GoogleTask.class,
Filter.class Filter.class,
GoogleTaskList.class
}, },
version = 51) version = 52)
public abstract class Database extends RoomDatabase { public abstract class Database extends RoomDatabase {
public abstract NotificationDao notificationDao(); public abstract NotificationDao notificationDao();
@ -75,12 +75,12 @@ public abstract class Database extends RoomDatabase {
public abstract UserActivityDao getUserActivityDao(); public abstract UserActivityDao getUserActivityDao();
public abstract TaskAttachmentDao getTaskAttachmentDao(); public abstract TaskAttachmentDao getTaskAttachmentDao();
public abstract TaskListMetadataDao getTaskListMetadataDao(); public abstract TaskListMetadataDao getTaskListMetadataDao();
public abstract StoreObjectDao getStoreObjectDao();
public abstract AlarmDao getAlarmDao(); public abstract AlarmDao getAlarmDao();
public abstract LocationDao getLocationDao(); public abstract LocationDao getLocationDao();
public abstract TagDao getTagDao(); public abstract TagDao getTagDao();
public abstract GoogleTaskDao getGoogleTaskDao(); public abstract GoogleTaskDao getGoogleTaskDao();
public abstract FilterDao getFilterDao(); public abstract FilterDao getFilterDao();
public abstract GoogleTaskListDao getGoogleTaskListDao();
public static final String NAME = "database"; public static final String NAME = "database";

@ -1,111 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.gtasks;
import com.google.common.base.Strings;
import org.tasks.data.StoreObject;
/**
* {@link StoreObject} entries for a GTasks List
*
* @author Tim Su <tim@todoroo.com>
*/
public class GtasksList {
private StoreObject storeObject;
public GtasksList(final String remoteId) {
this(newStoreObject());
setLastSync(0L);
setRemoteId(remoteId);
}
private static StoreObject newStoreObject() {
StoreObject storeObject = new StoreObject();
storeObject.setType(GtasksList.TYPE);
return storeObject;
}
public GtasksList(StoreObject storeObject) {
if (!storeObject.getType().equals(TYPE)) {
throw new RuntimeException("Type is not " + TYPE);
}
this.storeObject = storeObject;
}
/**
* type
*/
public static final String TYPE = "gtasks-list"; //$NON-NLS-1$
public Long getId() {
return storeObject.getId();
}
public String getRemoteId() {
return storeObject.getItem();
}
private void setRemoteId(String remoteId) {
storeObject.setItem(remoteId);
}
public String getName() {
return storeObject.getValue();
}
public void setName(String name) {
storeObject.setValue(name);
}
public void setOrder(int order) {
storeObject.setValue2(Integer.toString(order));
}
public int getColor() {
String color = storeObject.getValue4();
return Strings.isNullOrEmpty(color) ? -1 : Integer.parseInt(storeObject.getValue4());
}
public void setColor(int color) {
storeObject.setValue4(Integer.toString(color));
}
public long getLastSync() {
String lastSync = storeObject.getValue3();
return Strings.isNullOrEmpty(lastSync) ? 0 : Long.parseLong(lastSync);
}
public void setLastSync(long timestamp) {
storeObject.setValue3(Long.toString(timestamp));
}
public StoreObject getStoreObject() {
return storeObject;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof GtasksList)) return false;
GtasksList that = (GtasksList) o;
return storeObject != null ? storeObject.equals(that.storeObject) : that.storeObject == null;
}
@Override
public int hashCode() {
return storeObject != null ? storeObject.hashCode() : 0;
}
@Override
public String toString() {
return "GtasksList{" +
"storeObject=" + storeObject +
'}';
}
}

@ -0,0 +1,178 @@
package org.tasks.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;
import android.os.Parcel;
import android.os.Parcelable;
@Entity(tableName = "google_task_lists")
public class GoogleTaskList implements Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private long id;
@ColumnInfo(name = "remote_id")
private String remoteId;
@ColumnInfo(name = "title")
private String title;
@ColumnInfo(name = "remote_order")
private int remoteOrder;
@ColumnInfo(name = "last_sync")
private long lastSync;
@ColumnInfo(name = "deleted")
private long deleted;
@ColumnInfo(name = "color")
private Integer color;
public GoogleTaskList() {
}
@Ignore
public GoogleTaskList(Parcel parcel) {
id = parcel.readLong();
remoteId = parcel.readString();
title = parcel.readString();
remoteOrder = parcel.readInt();
lastSync = parcel.readLong();
deleted = parcel.readLong();
color = parcel.readInt();
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getRemoteOrder() {
return remoteOrder;
}
public void setRemoteOrder(int remoteOrder) {
this.remoteOrder = remoteOrder;
}
public long getLastSync() {
return lastSync;
}
public void setLastSync(long lastSync) {
this.lastSync = lastSync;
}
public long getDeleted() {
return deleted;
}
public void setDeleted(long deleted) {
this.deleted = deleted;
}
public boolean hasColor() {
return color != null;
}
public Integer getColor() {
return color;
}
public void setColor(Integer color) {
this.color = color;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GoogleTaskList)) return false;
GoogleTaskList that = (GoogleTaskList) o;
if (id != that.id) return false;
if (remoteOrder != that.remoteOrder) return false;
if (lastSync != that.lastSync) return false;
if (deleted != that.deleted) return false;
if (remoteId != null ? !remoteId.equals(that.remoteId) : that.remoteId != null)
return false;
if (title != null ? !title.equals(that.title) : that.title != null) return false;
return color != null ? color.equals(that.color) : that.color == null;
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (remoteId != null ? remoteId.hashCode() : 0);
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + remoteOrder;
result = 31 * result + (int) (lastSync ^ (lastSync >>> 32));
result = 31 * result + (int) (deleted ^ (deleted >>> 32));
result = 31 * result + (color != null ? color.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "GoogleTaskList{" +
"id=" + id +
", remoteId='" + remoteId + '\'' +
", title='" + title + '\'' +
", remoteOrder=" + remoteOrder +
", lastSync=" + lastSync +
", deleted=" + deleted +
", color=" + color +
'}';
}
public static Creator<GoogleTaskList> CREATOR = new Creator<GoogleTaskList>() {
@Override
public GoogleTaskList createFromParcel(Parcel parcel) {
return new GoogleTaskList(parcel);
}
@Override
public GoogleTaskList[] newArray(int size) {
return new GoogleTaskList[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeLong(id);
parcel.writeString(remoteId);
parcel.writeString(title);
parcel.writeInt(remoteOrder);
parcel.writeLong(lastSync);
parcel.writeLong(deleted);
parcel.writeInt(color);
}
}

@ -0,0 +1,24 @@
package org.tasks.data;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import java.util.List;
@Dao
public interface GoogleTaskListDao {
@Query("SELECT * FROM google_task_lists WHERE _id = :id")
GoogleTaskList getById(long id);
@Query("SELECT * FROM google_task_lists WHERE deleted = 0 ORDER BY title ASC")
List<GoogleTaskList> getActiveLists();
@Insert(onConflict = OnConflictStrategy.REPLACE)
long insertOrReplace(GoogleTaskList googleTaskList);
@Query("DELETE FROM google_task_lists WHERE _id = :id")
void deleteById(long id);
}

@ -1,193 +0,0 @@
package org.tasks.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.Index;
import android.arch.persistence.room.PrimaryKey;
import android.os.Parcel;
import android.os.Parcelable;
@Entity(tableName = "store",
indices = @Index(name = "so_id", value = {"type", "item"}))
public class StoreObject implements Parcelable{
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private Long id;
@ColumnInfo(name = "type")
private String type;
@ColumnInfo(name = "item")
private String item;
@ColumnInfo(name = "value")
private String value;
@ColumnInfo(name = "value2")
private String value2;
@ColumnInfo(name = "value3")
private String value3;
@ColumnInfo(name = "value4")
private String value4;
@ColumnInfo(name = "deleted")
private Long deleted = 0L;
public StoreObject() {
}
@Ignore
public StoreObject(Parcel source) {
id = source.readLong();
type = source.readString();
item = source.readString();
value = source.readString();
value2 = source.readString();
value3 = source.readString();
value4 = source.readString();
deleted = source.readLong();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getValue2() {
return value2;
}
public void setValue2(String value2) {
this.value2 = value2;
}
public String getValue3() {
return value3;
}
public void setValue3(String value3) {
this.value3 = value3;
}
public String getValue4() {
return value4;
}
public void setValue4(String value4) {
this.value4 = value4;
}
public Long getDeleted() {
return deleted;
}
public void setDeleted(Long deleted) {
this.deleted = deleted;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof StoreObject)) return false;
StoreObject that = (StoreObject) o;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (type != null ? !type.equals(that.type) : that.type != null) return false;
if (item != null ? !item.equals(that.item) : that.item != null) return false;
if (value != null ? !value.equals(that.value) : that.value != null) return false;
if (value2 != null ? !value2.equals(that.value2) : that.value2 != null) return false;
if (value3 != null ? !value3.equals(that.value3) : that.value3 != null) return false;
if (value4 != null ? !value4.equals(that.value4) : that.value4 != null) return false;
return deleted != null ? deleted.equals(that.deleted) : that.deleted == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (item != null ? item.hashCode() : 0);
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (value2 != null ? value2.hashCode() : 0);
result = 31 * result + (value3 != null ? value3.hashCode() : 0);
result = 31 * result + (value4 != null ? value4.hashCode() : 0);
result = 31 * result + (deleted != null ? deleted.hashCode() : 0);
return result;
}
public static Creator<StoreObject> CREATOR = new Creator<StoreObject>() {
@Override
public StoreObject createFromParcel(Parcel source) {
return new StoreObject(source);
}
@Override
public StoreObject[] newArray(int size) {
return new StoreObject[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(type);
dest.writeString(item);
dest.writeString(value);
dest.writeString(value2);
dest.writeString(value3);
dest.writeString(value4);
dest.writeLong(deleted);
}
@Override
public String toString() {
return "StoreObject{" +
"id=" + id +
", type='" + type + '\'' +
", item='" + item + '\'' +
", value='" + value + '\'' +
", value2='" + value2 + '\'' +
", value3='" + value3 + '\'' +
", value4='" + value4 + '\'' +
", deleted=" + deleted +
'}';
}
}

@ -1,54 +0,0 @@
package org.tasks.data;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import com.todoroo.astrid.gtasks.GtasksList;
import java.util.List;
@Dao
public abstract class StoreObjectDao {
@Query("SELECT * FROM store WHERE _id = :id LIMIT 1")
abstract StoreObject getById(long id);
public GtasksList getGtasksList(long id) {
StoreObject result = getById(id);
if (result == null) {
throw new RuntimeException(String.format("No store object found [id=%s]", id));
} else if (!result.getType().equals(GtasksList.TYPE)) {
throw new RuntimeException("Not a google task list");
}
return new GtasksList(result);
}
@Query("SELECT * FROM store WHERE deleted = 0 AND type = 'gtasks-list' ORDER BY value ASC")
public abstract List<StoreObject> getGtasksLists();
@Insert(onConflict = OnConflictStrategy.REPLACE)
public abstract long insert(StoreObject storeObject);
public boolean persist(StoreObject storeObject) {
long id = insert(storeObject);
if (id >= 0) {
storeObject.setId(id);
return true;
}
return false;
}
public void persist(GtasksList list) {
persist(list.getStoreObject());
}
@Update
public abstract void update(StoreObject storeObject);
@Query("DELETE FROM store WHERE _id = :id")
public abstract void delete(long id);
}

@ -83,6 +83,16 @@ public class Migrations {
} }
}; };
private static final Migration MIGRATION_51_52 = new Migration(51, 52) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE IF NOT EXISTS `google_task_lists` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `remote_id` TEXT, `title` TEXT, `remote_order` INTEGER NOT NULL, `last_sync` INTEGER NOT NULL, `deleted` INTEGER NOT NULL, `color` INTEGER)");
database.execSQL("INSERT INTO `google_task_lists` (`remote_id`, `title`, `remote_order`, `last_sync`, `color`, `deleted`) " +
"SELECT `item`, `value`, `value2`, `value3`, `value4`, `deleted` FROM `store` WHERE `type` = 'gtasks-list'");
database.execSQL("DROP TABLE IF EXISTS `store`");
}
};
private static Migration NOOP(int from, int to) { private static Migration NOOP(int from, int to) {
return new Migration(from, to) { return new Migration(from, to) {
@Override @Override
@ -97,17 +107,12 @@ public class Migrations {
MIGRATION_36_37, MIGRATION_36_37,
MIGRATION_37_38, MIGRATION_37_38,
MIGRATION_38_39, MIGRATION_38_39,
NOOP(39, 40), NOOP(39, 46),
NOOP(40, 41),
NOOP(41, 42),
NOOP(42, 43),
NOOP(43, 44),
NOOP(44, 45),
NOOP(45, 46),
MIGRATION_46_47, MIGRATION_46_47,
MIGRATION_47_48, MIGRATION_47_48,
MIGRATION_48_49, MIGRATION_48_49,
MIGRATION_49_50, MIGRATION_49_50,
MIGRATION_50_51 MIGRATION_50_51,
MIGRATION_51_52
}; };
} }

@ -12,15 +12,15 @@ import com.todoroo.astrid.api.MultipleSelectCriterion;
import com.todoroo.astrid.api.PermaSql; import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.api.TextInputCriterion; import com.todoroo.astrid.api.TextInputCriterion;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import org.tasks.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.gtasks.GtasksListService;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.Tag; import org.tasks.data.Tag;
import org.tasks.data.TagData;
import org.tasks.gtasks.SyncAdapterHelper; import org.tasks.gtasks.SyncAdapterHelper;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;
@ -169,12 +169,12 @@ public class FilterCriteriaProvider {
} }
private CustomFilterCriterion getGtasksFilterCriteria() { private CustomFilterCriterion getGtasksFilterCriteria() {
List<GtasksList> lists = gtasksListService.getLists(); List<GoogleTaskList> lists = gtasksListService.getLists();
String[] listNames = new String[lists.size()]; String[] listNames = new String[lists.size()];
String[] listIds = new String[lists.size()]; String[] listIds = new String[lists.size()];
for (int i = 0; i < lists.size(); i++) { for (int i = 0; i < lists.size(); i++) {
listNames[i] = lists.get(i).getName(); listNames[i] = lists.get(i).getTitle();
listIds[i] = lists.get(i).getRemoteId(); listIds[i] = lists.get(i).getRemoteId();
} }

@ -1,7 +1,7 @@
package org.tasks.gtasks; package org.tasks.gtasks;
import com.todoroo.astrid.gtasks.GtasksList; import org.tasks.data.GoogleTaskList;
public interface GoogleTaskListSelectionHandler { public interface GoogleTaskListSelectionHandler {
void selectedList(GtasksList list); void selectedList(GoogleTaskList list);
} }

@ -6,7 +6,7 @@ import android.content.Context;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import org.tasks.data.FilterDao; import org.tasks.data.FilterDao;
import org.tasks.data.StoreObjectDao; import org.tasks.data.GoogleTaskListDao;
import org.tasks.data.TagDataDao; import org.tasks.data.TagDataDao;
import org.tasks.data.TaskAttachmentDao; import org.tasks.data.TaskAttachmentDao;
import org.tasks.data.TaskListMetadataDao; import org.tasks.data.TaskListMetadataDao;
@ -92,11 +92,6 @@ public class ApplicationModule {
return database.getTaskListMetadataDao(); return database.getTaskListMetadataDao();
} }
@Provides
public StoreObjectDao getStoreObjectDao(Database database) {
return database.getStoreObjectDao();
}
@Provides @Provides
public GoogleTaskDao getGoogleTaskDao(Database database) { public GoogleTaskDao getGoogleTaskDao(Database database) {
return database.getGoogleTaskDao(); return database.getGoogleTaskDao();
@ -121,4 +116,9 @@ public class ApplicationModule {
public FilterDao getFilterDao(Database database) { public FilterDao getFilterDao(Database database) {
return database.getFilterDao(); return database.getFilterDao();
} }
@Provides
public GoogleTaskListDao getGoogleTaskListDao(Database database) {
return database.getGoogleTaskListDao();
}
} }

Loading…
Cancel
Save