Now google tasks filters launch the google tasks list activity

pull/14/head
Tim Su 14 years ago
parent f3d0cee32e
commit 291479de07

@ -3,6 +3,7 @@
*/
package com.todoroo.astrid.gtasks;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
@ -23,10 +24,11 @@ import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterCategory;
import com.todoroo.astrid.api.FilterListHeader;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria;
import com.todoroo.astrid.data.TaskApiDao.TaskCriteria;
/**
@ -48,7 +50,7 @@ public class GtasksFilterExposer extends BroadcastReceiver {
values.putAll(GtasksMetadata.createEmptyMetadata(AbstractModel.NO_ID).getMergedValues());
values.remove(Metadata.TASK.name);
values.put(GtasksMetadata.LIST_ID.name, list.getValue(GtasksList.REMOTE_ID));
Filter filter = new Filter(listName, listName, new QueryTemplate().join(
FilterWithCustomIntent filter = new FilterWithCustomIntent(listName, listName, new QueryTemplate().join(
Join.left(Metadata.TABLE, Task.ID.eq(Metadata.TASK))).where(Criterion.and(
MetadataCriteria.withKey(GtasksMetadata.METADATA_KEY),
TaskCriteria.isVisible(),
@ -56,6 +58,12 @@ public class GtasksFilterExposer extends BroadcastReceiver {
GtasksMetadata.LIST_ID.eq(list.getValue(GtasksList.REMOTE_ID)))).orderBy(
Order.asc(Functions.cast(GtasksMetadata.ORDER, "INTEGER"))), //$NON-NLS-1$
values);
Intent intent = new Intent(ContextManager.getContext(), GtasksListActivity.class);
intent.putExtra(GtasksListActivity.TOKEN_LIST_ID, list.getValue(GtasksList.REMOTE_ID));
intent.putExtra(GtasksListActivity.TOKEN_FILTER, filter);
PendingIntent pendingIntent = PendingIntent.getActivity(ContextManager.getContext(),
0, intent, 0);
filter.intent = pendingIntent;
return filter;
}

@ -23,6 +23,8 @@ public class GtasksListActivity extends DraggableTaskListActivity {
@Autowired private GtasksTaskListUpdater gtasksTaskListUpdater;
public static final String TOKEN_LIST_ID = "listId"; //$NON-NLS-1$
// --- gtasks temp stuff
private final String listId = "17816916813445155620:0:0"; //$NON-NLS-1$
Filter builtInFilter = new Filter("Tim's Tasks", "Tim's Tasks", new QueryTemplate().join( //$NON-NLS-1$ //$NON-NLS-2$
@ -43,7 +45,8 @@ public class GtasksListActivity extends DraggableTaskListActivity {
@Override
public void onCreate(Bundle icicle) {
getIntent().putExtra(TOKEN_FILTER, builtInFilter);
if(!getIntent().hasExtra(TOKEN_FILTER))
getIntent().putExtra(TOKEN_FILTER, builtInFilter);
super.onCreate(icicle);
getTouchListView().setDropListener(dropListener);
@ -55,7 +58,6 @@ public class GtasksListActivity extends DraggableTaskListActivity {
public void drop(int from, int to) {
long targetTaskId = taskAdapter.getItemId(from);
long destinationTaskId = taskAdapter.getItemId(to);
System.err.format("%d -> %d ::: %d -> %d\n", from, to, targetTaskId, destinationTaskId);
gtasksTaskListUpdater.moveTo(listId, targetTaskId, destinationTaskId);
loadTaskListContent(true);
}

@ -45,6 +45,7 @@ import com.todoroo.astrid.adapter.FilterAdapter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterCategory;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.api.IntentFilter;
import com.todoroo.astrid.core.SearchFilter;
import com.todoroo.astrid.data.Task;
@ -203,9 +204,17 @@ public class FilterListActivity extends ExpandableListActivity {
protected boolean onItemClicked(FilterListItem item) {
if(item instanceof Filter) {
Filter filter = (Filter)item;
Intent intent = new Intent(FilterListActivity.this, TaskListActivity.class);
intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
startActivity(intent);
if(filter instanceof FilterWithCustomIntent) {
try {
((FilterWithCustomIntent)filter).intent.send();
} catch (CanceledException e) {
// we won't do anything in this case
}
} else {
Intent intent = new Intent(FilterListActivity.this, TaskListActivity.class);
intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
startActivity(intent);
}
AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$
new Class<?>[] { Integer.TYPE, Integer.TYPE },
R.anim.slide_left_in, R.anim.slide_left_out);

@ -0,0 +1,79 @@
package com.todoroo.astrid.api;
import android.app.PendingIntent;
import android.content.ContentValues;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import com.todoroo.andlib.sql.QueryTemplate;
public class FilterWithCustomIntent extends Filter {
public PendingIntent intent = null;
protected FilterWithCustomIntent() {
super();
}
public FilterWithCustomIntent(String listingTitle, String title,
QueryTemplate sqlQuery, ContentValues valuesForNewTasks) {
super(listingTitle, title, sqlQuery, valuesForNewTasks);
}
public FilterWithCustomIntent(String listingTitle, String title,
String sqlQuery, ContentValues valuesForNewTasks) {
super(listingTitle, title, sqlQuery, valuesForNewTasks);
}
// --- parcelable
/**
* {@inheritDoc}
*/
@Override
public int describeContents() {
return 0;
}
/**
* {@inheritDoc}
*/
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeParcelable(intent, 0);
}
@Override
public void readFromParcel(Parcel source) {
super.readFromParcel(source);
intent = source.readParcelable(Intent.class.getClassLoader());
}
/**
* Parcelable Creator Object
*/
@SuppressWarnings("hiding")
public static final Parcelable.Creator<FilterWithCustomIntent> CREATOR = new Parcelable.Creator<FilterWithCustomIntent>() {
/**
* {@inheritDoc}
*/
public FilterWithCustomIntent createFromParcel(Parcel source) {
FilterWithCustomIntent item = new FilterWithCustomIntent();
item.readFromParcel(source);
return item;
}
/**
* {@inheritDoc}
*/
public FilterWithCustomIntent[] newArray(int size) {
return new FilterWithCustomIntent[size];
}
};
}
Loading…
Cancel
Save