Merge remote-tracking branch 'sbosley/110810_various_bugfixes'

pull/14/head
Tim Su 15 years ago
commit c59bb2bb45

@ -351,6 +351,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name="com.todoroo.astrid.gtasks.GtasksListAdder"/>
<receiver android:name="com.todoroo.astrid.gtasks.GtasksDetailExposer">
<intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_DETAILS" />

@ -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);
}
}

@ -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
*/

@ -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;

@ -436,10 +436,12 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
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))

@ -13,6 +13,9 @@
<!-- filter title for GTasks lists (%s => list name) -->
<string name="gtasks_FEx_title">Google Tasks: %s</string>
<!-- dialog prompt for creating a new gtasks list -->
<string name="gtasks_FEx_creating_list">Creating list...</string>
<!-- dialog prompt for creating a new gtasks list -->
<string name="gtasks_FEx_create_list_dialog">New List Name:</string>

@ -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);

@ -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);

@ -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);

Loading…
Cancel
Save