diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 1b65dde45..ec3ab3d5b 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -351,6 +351,7 @@
+
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListAdder.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListAdder.java
index 802e49ee2..d56eb2444 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListAdder.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListAdder.java
@@ -3,7 +3,9 @@ package com.todoroo.astrid.gtasks;
import java.io.IOException;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.content.DialogInterface;
+import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.FrameLayout;
@@ -17,12 +19,18 @@ import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.gtasks.api.GtasksService;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
-public class GtasksListAdder {
+public class GtasksListAdder extends Activity {
@Autowired GtasksPreferenceService gtasksPreferenceService;
@Autowired GtasksListService gtasksListService;
- public void showNewListDialog(final Activity activity) {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ showNewListDialog(this);
+ }
+
+ private void showNewListDialog(final Activity activity) {
DependencyInjectionService.getInstance().inject(this);
FrameLayout frame = new FrameLayout(activity);
@@ -30,36 +38,51 @@ public class GtasksListAdder {
frame.addView(editText);
frame.setPadding(10, 0, 10, 0);
- DialogUtilities.viewDialog(activity,
- activity.getString(R.string.gtasks_FEx_create_list_dialog),
- frame, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (gtasksPreferenceService.isLoggedIn() && ! gtasksPreferenceService.isOngoing()) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- String token = gtasksPreferenceService.getToken();
- token = GtasksTokenValidator.validateAuthToken(token);
- GtasksService service = new GtasksService(token);
- try {
- String title = editText.getText().toString();
- if (TextUtils.isEmpty(title)) //Don't create a list without a title
- return;
- StoreObject newList = gtasksListService.addNewList(service.createGtaskList(title));
- if (newList != null) {
- FilterWithCustomIntent listFilter = (FilterWithCustomIntent) GtasksFilterExposer.filterFromList(activity, newList);
- listFilter.start(activity);
- }
-
- } catch (IOException e) {
- DialogUtilities.okDialog(activity, activity.getString(R.string.gtasks_FEx_create_list_error), null);
- }
+ DialogInterface.OnClickListener onClick = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (gtasksPreferenceService.isLoggedIn() && ! gtasksPreferenceService.isOngoing()) {
+ final ProgressDialog pd = DialogUtilities.progressDialog(GtasksListAdder.this,
+ GtasksListAdder.this.getString(R.string.gtasks_FEx_creating_list));
+ pd.show();
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ String token = gtasksPreferenceService.getToken();
+ token = GtasksTokenValidator.validateAuthToken(token);
+ GtasksService service = new GtasksService(token);
+ try {
+ String title = editText.getText().toString();
+ if (TextUtils.isEmpty(title)) //Don't create a list without a title
+ return;
+ StoreObject newList = gtasksListService.addNewList(service.createGtaskList(title));
+ if (newList != null) {
+ FilterWithCustomIntent listFilter = (FilterWithCustomIntent) GtasksFilterExposer.filterFromList(activity, newList);
+ listFilter.start(activity);
}
- }).start();
+
+ } catch (IOException e) {
+ DialogUtilities.okDialog(activity, activity.getString(R.string.gtasks_FEx_create_list_error), null);
+ } finally {
+ pd.dismiss();
+ finish();
+ }
}
- }
- }, null);
+ }).start();
+ }
+ }
+ };
+
+ DialogInterface.OnClickListener onCancel = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ };
+
+ DialogUtilities.viewDialog(activity,
+ activity.getString(R.string.gtasks_FEx_create_list_dialog),
+ frame, onClick, onCancel);
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksApiUtilities.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksApiUtilities.java
index 245080fda..8617ce468 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksApiUtilities.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/api/GtasksApiUtilities.java
@@ -46,6 +46,17 @@ public class GtasksApiUtilities {
}
}
+ public static String unixTimeToGtasksDate(long time) {
+ if (time == 0) return null;
+ synchronized(timeWriter) {
+ Date date = new Date(time);
+ date.setHours(0);
+ date.setMinutes(0);
+ date.setSeconds(0);
+ return new DateTime(date, TimeZone.getDefault()).toStringRfc3339();
+ }
+ }
+
/*
* The two methods below are useful for testing
*/
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncOnSaveService.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncOnSaveService.java
index 3efd8b3c2..4f3445093 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncOnSaveService.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncOnSaveService.java
@@ -208,11 +208,11 @@ public final class GtasksSyncOnSaveService {
remoteModel.notes = task.getValue(Task.NOTES);
}
if (values.containsKey(Task.DUE_DATE.name)) {
- remoteModel.due = GtasksApiUtilities.unixTimeToGtasksTime(task.getValue(Task.DUE_DATE));
+ remoteModel.due = GtasksApiUtilities.unixTimeToGtasksDate(task.getValue(Task.DUE_DATE));
}
if (values.containsKey(Task.COMPLETION_DATE.name)) {
if (task.isCompleted()) {
- remoteModel.completed = GtasksApiUtilities.unixTimeToGtasksTime(task.getValue(Task.COMPLETION_DATE));
+ remoteModel.completed = GtasksApiUtilities.unixTimeToGtasksDate(task.getValue(Task.COMPLETION_DATE));
remoteModel.status = "completed"; //$NON-NLS-1$
} else {
remoteModel.completed = null;
diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java
index 0b96f4782..e1875c3e1 100644
--- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java
+++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java
@@ -436,10 +436,12 @@ public class GtasksSyncProvider extends SyncProvider {
com.google.api.services.tasks.v1.model.Task model) {
if(shouldTransmit(local, Task.TITLE, remote))
model.title = local.task.getValue(Task.TITLE);
- if(shouldTransmit(local, Task.DUE_DATE, remote))
- model.due = GtasksApiUtilities.unixTimeToGtasksTime(local.task.getValue(Task.DUE_DATE));
+ if(shouldTransmit(local, Task.DUE_DATE, remote)) {
+ model.due = GtasksApiUtilities.unixTimeToGtasksDate(local.task.getValue(Task.DUE_DATE));
+ System.err.println("Setting model due time to: " + model.due);
+ }
if(shouldTransmit(local, Task.COMPLETION_DATE, remote)) {
- model.completed = GtasksApiUtilities.unixTimeToGtasksTime(local.task.getValue(Task.COMPLETION_DATE));
+ model.completed = GtasksApiUtilities.unixTimeToGtasksDate(local.task.getValue(Task.COMPLETION_DATE));
model.status = (local.task.isCompleted() ? "completed" : "needsAction");
}
if(shouldTransmit(local, Task.DELETION_DATE, remote))
diff --git a/astrid/res/values/strings-gtasks.xml b/astrid/res/values/strings-gtasks.xml
index 746020d1d..f2301dd3d 100644
--- a/astrid/res/values/strings-gtasks.xml
+++ b/astrid/res/values/strings-gtasks.xml
@@ -13,6 +13,9 @@
Google Tasks: %s
+
+ Creating list...
+
New List Name:
diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java
index 65c36ffb6..b833a802f 100644
--- a/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java
+++ b/tests/src/com/todoroo/astrid/gtasks/GtasksApiTest.java
@@ -141,7 +141,7 @@ public class GtasksApiTest extends DatabaseTestCase {
}
private boolean listHasTaskWithTitle(String listId, String title) throws Exception {
- com.google.api.services.tasks.v1.model.Tasks newListTasks = service.getAllGtasksFromListId(listId, false);
+ com.google.api.services.tasks.v1.model.Tasks newListTasks = service.getAllGtasksFromListId(listId, false, false);
if (newListTasks.items != null) {
for (Task t : newListTasks.items) {
if (t.title.equals(title)) {
@@ -153,7 +153,7 @@ public class GtasksApiTest extends DatabaseTestCase {
}
private boolean taskWithTitleExists(String title) throws Exception {
- Tasks defaultList = service.getAllGtasksFromListId(DEFAULT_LIST, false);
+ Tasks defaultList = service.getAllGtasksFromListId(DEFAULT_LIST, false, false);
if (defaultList.items != null) {
for (Task t : defaultList.items) {
if (t.title.equals(title))
@@ -264,7 +264,7 @@ public class GtasksApiTest extends DatabaseTestCase {
private void clearDefaultList() {
try {
- Tasks tasks = service.getAllGtasksFromListId(DEFAULT_LIST, false);
+ Tasks tasks = service.getAllGtasksFromListId(DEFAULT_LIST, false, false);
if (tasks.items != null) {
for (Task t : tasks.items) {
service.deleteGtask(DEFAULT_LIST, t.id);
diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
index 8a2de9a41..562e97ef5 100644
--- a/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
+++ b/tests/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
@@ -523,7 +523,7 @@ public class GtasksNewSyncTest extends DatabaseTestCase {
}
private void setupTestList() throws Exception {
- Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false);
+ Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
if (defaultListTasks.items != null) {
for (com.google.api.services.tasks.v1.model.Task t : defaultListTasks.items) {
gtasksService.deleteGtask(DEFAULT_LIST, t.id);
diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
index 3bb3a1975..8e8efd0fa 100644
--- a/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
+++ b/tests/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
@@ -147,7 +147,7 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
}
private boolean taskWithTitleExists(String title) throws IOException {
- Tasks allTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false);
+ Tasks allTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
if (allTasks.items != null) {
for (com.google.api.services.tasks.v1.model.Task t : allTasks.items) {
if (t.title.equals(title))
@@ -209,7 +209,7 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
}
private void setupTestList() throws Exception {
- Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false);
+ Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
if (defaultListTasks.items != null) {
for (com.google.api.services.tasks.v1.model.Task t : defaultListTasks.items) {
gtasksService.deleteGtask(DEFAULT_LIST, t.id);