Completed tasks now stick around in google tasks lists until they are explicitly cleared from the menu

pull/14/head
Sam Bosley 13 years ago
parent 14e8d33258
commit 85e1cd2f78

@ -22,7 +22,7 @@
<classpathentry exported="true" kind="lib" path="libs/jackson-core-asl-1.6.7.jar"/>
<classpathentry exported="true" kind="lib" path="libs/google-api-client-googleapis-extensions-android2-1.4.1-beta.jar"/>
<classpathentry exported="true" kind="lib" path="libs/google-api-client-extensions-android2-1.4.1-beta.jar"/>
<classpathentry kind="src" path="astridApi_src"/>
<classpathentry kind="src" path="facebook_src"/>
<classpathentry kind="src" path="astridApi_src"/>
<classpathentry kind="output" path="ecbuild"/>
</classpath>

@ -62,7 +62,7 @@ public class GtasksFilterExposer extends BroadcastReceiver {
ContextManager.getString(R.string.gtasks_FEx_title, listName), new QueryTemplate().join(
Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK))).where(Criterion.and(
MetadataCriteria.withKey(GtasksMetadata.METADATA_KEY),
TaskCriteria.activeAndVisible(),
TaskCriteria.notDeleted(),
GtasksMetadata.LIST_ID.eq(list.getValue(GtasksList.REMOTE_ID)))).orderBy(
Order.asc(Functions.cast(GtasksMetadata.ORDER, "LONG"))).groupBy(Task.ID), //$NON-NLS-1$
values);

@ -1,16 +1,22 @@
package com.todoroo.astrid.gtasks;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.commonsware.cwac.tlv.TouchListView;
import com.commonsware.cwac.tlv.TouchListView.DropListener;
import com.commonsware.cwac.tlv.TouchListView.SwipeListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.DraggableTaskListActivity;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService;
public class GtasksListActivity extends DraggableTaskListActivity {
@ -75,4 +81,61 @@ public class GtasksListActivity extends DraggableTaskListActivity {
}
};
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem item = menu.add(Menu.NONE, MENU_SORT_ID, Menu.FIRST, "Clear completed");
item.setIcon(android.R.drawable.ic_input_delete); // Needs new icon
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, final MenuItem item) {
if (item.getItemId() == MENU_SORT_ID) {
clearCompletedTasks();
return true;
} else {
return super.onMenuItemSelected(featureId, item);
}
}
private void clearCompletedTasks() {
final ProgressDialog pd = new ProgressDialog(this); //progressDialog(this, this.getString(R.string.gtasks_GLA_clearing))
final TodorooCursor<Task> tasks = taskService.fetchFiltered(filter.sqlQuery, null, Task.ID, Task.COMPLETION_DATE);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setMessage(this.getString(R.string.gtasks_GLA_clearing));pd.setMax(tasks.getCount());
pd.show();
new Thread() {
@Override
public void run() {
String listId = null;
try {
for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) {
Task t = new Task(tasks);
if (t.isCompleted()) {
if (listId == null) {
listId = gtasksMetadataService.getTaskMetadata(t.getId()).getValue(GtasksMetadata.LIST_ID);
}
t.setValue(Task.DELETION_DATE, DateUtilities.now());
taskService.save(t);
}
pd.incrementProgressBy(1);
}
} finally {
tasks.close();
pd.dismiss();
}
if (listId != null) {
gtasksTaskListUpdater.correctMetadataForList(listId);
}
GtasksListActivity.this.runOnUiThread(new Runnable() {
public void run() {
loadTaskListContent(true);
}
});
}
}.start();
}
}

@ -160,14 +160,15 @@ public class GtasksService {
}
}
public com.google.api.services.tasks.v1.model.Tasks getAllGtasksFromTaskList(TaskList list, boolean includeDeleted) throws IOException {
return getAllGtasksFromListId(list.id, includeDeleted);
public com.google.api.services.tasks.v1.model.Tasks getAllGtasksFromTaskList(TaskList list, boolean includeDeleted, boolean includeHidden) throws IOException {
return getAllGtasksFromListId(list.id, includeDeleted, includeHidden);
}
public com.google.api.services.tasks.v1.model.Tasks getAllGtasksFromListId(String listId, boolean includeDeleted) throws IOException {
public com.google.api.services.tasks.v1.model.Tasks getAllGtasksFromListId(String listId, boolean includeDeleted, boolean includeHidden) throws IOException {
com.google.api.services.tasks.v1.model.Tasks toReturn = null;
List request = service.tasks.list(listId);
request.showDeleted = includeDeleted;
request.showHidden = includeHidden;
try {
toReturn = request.execute();
} catch (IOException e) {

@ -73,7 +73,7 @@ public class GtasksLegacyMigrator {
defaultListId = list.id;
}
Tasks allTasks = gtasksService.getAllGtasksFromListId(list.id, false);
Tasks allTasks = gtasksService.getAllGtasksFromListId(list.id, false, false);
if (allTasks.items != null) {
for (com.google.api.services.tasks.v1.model.Task t : allTasks.items) {

@ -245,7 +245,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
// first, pull all tasks. then we can write them
// include deleted tasks so we can delete them in astrid
data.remoteUpdated = readAllRemoteTasks(true);
data.remoteUpdated = readAllRemoteTasks(true, true);
for(GtasksTaskContainer remote : data.remoteUpdated) {
if(remote.task.getId() < 1) {
@ -300,7 +300,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
private SyncData<GtasksTaskContainer> populateSyncData() throws IOException {
// fetch remote tasks
ArrayList<GtasksTaskContainer> remoteTasks = readAllRemoteTasks(false);
ArrayList<GtasksTaskContainer> remoteTasks = readAllRemoteTasks(false, false);
// fetch locally created tasks
TodorooCursor<Task> localCreated = gtasksMetadataService.getLocallyCreated(PROPERTIES);
@ -315,7 +315,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
// ------------------------------------------------- create / push / pull
// ----------------------------------------------------------------------
private ArrayList<GtasksTaskContainer> readAllRemoteTasks(final boolean includeDeleted) {
private ArrayList<GtasksTaskContainer> readAllRemoteTasks(final boolean includeDeleted, final boolean includeHidden) {
final ArrayList<GtasksTaskContainer> list = new ArrayList<GtasksTaskContainer>();
final Semaphore listsFinished = new Semaphore(0);
@ -329,7 +329,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
String listId = dashboard.getValue(GtasksList.REMOTE_ID);
if(Constants.DEBUG)
Log.e("gtasks-debug", "ACTION: getTasks, " + listId);
List<com.google.api.services.tasks.v1.model.Task> remoteTasks = taskService.getAllGtasksFromListId(listId, includeDeleted).items;
List<com.google.api.services.tasks.v1.model.Task> remoteTasks = taskService.getAllGtasksFromListId(listId, includeDeleted, includeHidden).items;
addRemoteTasksToList(remoteTasks, list);
} catch (Exception e) {
handleException("read-remotes", e, false);
@ -530,7 +530,9 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
task.setValue(Task.COMPLETION_DATE, GtasksApiUtilities.gtasksCompletedTimeToUnixTime(remoteTask.completed, 0));
if (remoteTask.deleted == null || !remoteTask.deleted.booleanValue())
task.setValue(Task.DELETION_DATE, 0L);
else if (remoteTask.deleted)
else if (remoteTask.deleted.booleanValue())
task.setValue(Task.DELETION_DATE, DateUtilities.now());
if (remoteTask.hidden != null && remoteTask.hidden.booleanValue())
task.setValue(Task.DELETION_DATE, DateUtilities.now());
long dueDate = GtasksApiUtilities.gtasksDueTimeToUnixTime(remoteTask.due, 0);

@ -70,7 +70,10 @@
<!-- Error Message when we receive a HTTP 401 Unauthorized multiple times -->
<string name="gtasks_GLA_errorAuth_captcha">You may have encountered a captcha.
Try logging in from the browser, then come back to try again:</string>
<!-- Message while clearing completed tasks -->
<string name="gtasks_GLA_clearing">Clearing completed tasks...</string>
<!-- ============================================== GtasksPreferences == -->
<!-- GTasks Preferences Title -->

@ -149,7 +149,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
@Autowired ExceptionService exceptionService;
@Autowired TaskService taskService;
@Autowired protected TaskService taskService;
@Autowired MetadataService metadataService;

Loading…
Cancel
Save