rewrite of filters for teammember's tasks, readonly again, modified standard-filters so readonly-tasks dont clutter those filters like Inbox, Recent, Taglists, workspaces, tasks assigned by you/to you. Fixes AST-354

pull/14/head
Arne Jans 14 years ago committed by Tim Su
parent 61e6db4aab
commit 6e1c31dfdf

@ -140,6 +140,9 @@ public final class Task extends AbstractModel {
/** whether repeat occurs relative to completion date instead of due date */
public static final int FLAG_REPEAT_AFTER_COMPLETION = 1 << 1;
/** whether task is readonly */
public static final int FLAG_IS_READONLY = 1 << 2;
// --- notification flags
/** whether to send a reminder at deadline */

@ -46,7 +46,9 @@ public final class CoreFilterExposer extends BroadcastReceiver {
Filter recent = new Filter(r.getString(R.string.BFE_Recent),
r.getString(R.string.BFE_Recent),
new QueryTemplate().orderBy(Order.desc(Task.MODIFICATION_DATE)).limit(15),
new QueryTemplate().where(
Criterion.not(TaskCriteria.isReadOnly())).orderBy(
Order.desc(Task.MODIFICATION_DATE)).limit(15),
null);
recent.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_new)).getBitmap();
@ -68,6 +70,7 @@ public final class CoreFilterExposer extends BroadcastReceiver {
Filter inbox = new Filter(r.getString(R.string.BFE_Active), r.getString(R.string.BFE_Active),
new QueryTemplate().where(
Criterion.and(TaskCriteria.isActive(), TaskCriteria.isVisible(),
Criterion.not(TaskCriteria.isReadOnly()),
Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).where(
Criterion.and(MetadataCriteria.withKey(TagService.KEY),
TagService.TAG.like("x_%", "x"))))))), //$NON-NLS-1$ //$NON-NLS-2$

@ -14,6 +14,7 @@ import com.timsu.astrid.R;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterCategory;
@ -39,7 +40,7 @@ public class ProducteevFilterExposer extends BroadcastReceiver {
/**
* @param context
*/
public static Filter filterFromList(Context context, ProducteevDashboard dashboard) {
public static Filter filterFromList(Context context, ProducteevDashboard dashboard, long currentUserId) {
String dashboardTitle = dashboard.getName();
String title = dashboard.getName();
ContentValues values = new ContentValues();
@ -48,18 +49,49 @@ public class ProducteevFilterExposer extends BroadcastReceiver {
values.put(ProducteevTask.ID.name, 0);
values.put(ProducteevTask.CREATOR_ID.name, 0);
values.put(ProducteevTask.RESPONSIBLE_ID.name, 0);
Filter filter = new Filter(dashboardTitle, title, new QueryTemplate().join(
Filter filter;
if (currentUserId != -1)
filter = new Filter(dashboardTitle, title, new QueryTemplate().join(
ProducteevDataService.METADATA_JOIN).where(Criterion.and(
MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
TaskCriteria.isActive(),
TaskCriteria.isVisible(),
Criterion.or(ProducteevTask.CREATOR_ID.eq(currentUserId),
ProducteevTask.RESPONSIBLE_ID.eq(currentUserId)),
ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))),
values);
else
filter = new Filter(dashboardTitle, title, new QueryTemplate().join(
ProducteevDataService.METADATA_JOIN).where(Criterion.and(
MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
TaskCriteria.isActive(),
TaskCriteria.isVisible(),
ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))),
values);
return filter;
}
private Filter filterUserAssignedByMe(Context context, ProducteevUser user, long currentUserId) {
String title = context.getString(R.string.producteev_FEx_responsible_title, user.toString());
ContentValues values = new ContentValues();
values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY);
values.put(ProducteevTask.ID.name, 0);
values.put(ProducteevTask.CREATOR_ID.name, currentUserId);
values.put(ProducteevTask.RESPONSIBLE_ID.name, user.getId());
Filter filter = new Filter(user.toString(), title, new QueryTemplate().join(
ProducteevDataService.METADATA_JOIN).where(Criterion.and(
MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
TaskCriteria.isActive(),
TaskCriteria.isVisible(),
ProducteevTask.DASHBOARD_ID.eq(dashboard.getId()))),
values);
ProducteevTask.CREATOR_ID.eq(currentUserId),
ProducteevTask.RESPONSIBLE_ID.eq(user.getId()))),
values);
return filter;
}
private Filter filterFromUser(Context context, ProducteevUser user) {
private Filter filterUserAssignedByOthers(Context context, ProducteevUser user, long currentUserId) {
String title = context.getString(R.string.producteev_FEx_responsible_title, user.toString());
ContentValues values = new ContentValues();
values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY);
@ -71,6 +103,7 @@ public class ProducteevFilterExposer extends BroadcastReceiver {
MetadataCriteria.withKey(ProducteevTask.METADATA_KEY),
TaskCriteria.isActive(),
TaskCriteria.isVisible(),
Criterion.not(ProducteevTask.CREATOR_ID.eq(currentUserId)),
ProducteevTask.RESPONSIBLE_ID.eq(user.getId()))),
values);
@ -92,27 +125,38 @@ public class ProducteevFilterExposer extends BroadcastReceiver {
FilterListHeader producteevHeader = new FilterListHeader(context.getString(R.string.producteev_FEx_header));
long currentUserId = Preferences.getLong(ProducteevUtilities.PREF_USER_ID, -1);
// load dashboards
Filter[] dashboardFilters = new Filter[dashboards.length];
for(int i = 0; i < dashboards.length; i++)
dashboardFilters[i] = filterFromList(context, new ProducteevDashboard(dashboards[i]));
dashboardFilters[i] = filterFromList(context, new ProducteevDashboard(dashboards[i]), currentUserId);
FilterCategory producteevDashboards = new FilterCategory(context.getString(R.string.producteev_FEx_dashboard),
dashboardFilters);
// load responsible people
// load responsible people, assigned by me
TreeSet<ProducteevUser> people = loadResponsiblePeople(dashboards);
Filter[] peopleFilters = new Filter[people.size()];
Filter[] peopleByMeFilters = new Filter[people.size()];
int index = 0;
for (ProducteevUser person : people)
peopleFilters[index++] = filterFromUser(context, person);
FilterCategory producteevUsers = new FilterCategory(context.getString(R.string.producteev_FEx_responsible),
peopleFilters);
peopleByMeFilters[index++] = filterUserAssignedByMe(context, person, currentUserId);
FilterCategory producteevUsersByMeCategory = new FilterCategory(context.getString(R.string.producteev_FEx_responsible_byme),
peopleByMeFilters);
// load responsible people, assigned by others
Filter[] peopleByOthersFilters = new Filter[people.size()];
index = 0;
for (ProducteevUser person : people)
peopleByOthersFilters[index++] = filterUserAssignedByOthers(context, person, currentUserId);
FilterCategory producteevUsersByOthersCategory = new FilterCategory(context.getString(R.string.producteev_FEx_responsible_byothers),
peopleByOthersFilters);
// transmit filter list
FilterListItem[] list = new FilterListItem[3];
FilterListItem[] list = new FilterListItem[4];
list[0] = producteevHeader;
list[1] = producteevDashboards;
list[2] = producteevUsers;
list[2] = producteevUsersByMeCategory;
list[3] = producteevUsersByOthersCategory;
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ProducteevUtilities.IDENTIFIER);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list);

@ -238,7 +238,9 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
if(remote.pdvTask.getValue(ProducteevTask.CREATOR_ID) != userId &&
remote.pdvTask.getValue(ProducteevTask.RESPONSIBLE_ID) != userId)
continue;
remote.task.setFlag(Task.FLAGS, Task.FLAG_IS_READONLY, true);
else
remote.task.setFlag(Task.FLAGS, Task.FLAG_IS_READONLY, false);
// update reminder flags for incoming remote tasks to prevent annoying
if(remote.task.hasDueDate() && remote.task.getValue(Task.DUE_DATE) < DateUtilities.now())
@ -302,7 +304,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
Notification notification = new Notification(icon, null, when);
CharSequence contentTitle = context.getString(R.string.producteev_notification_title)+": "+dashboard.getName();
Filter filter = ProducteevFilterExposer.filterFromList(context, dashboard);
Filter filter = ProducteevFilterExposer.filterFromList(context, dashboard, userId);
Intent notificationIntent = ShortcutActivity.createIntent(filter);
// filter the tags from the message

@ -130,7 +130,8 @@ public class TagFilterExposer extends BroadcastReceiver {
Filter[] filters = new Filter[sortedTagSet.size()];
int index = 0;
for(Tag tag : sortedTagSet) {
filters[index++] = filterFromTag(context, tag, TaskCriteria.activeAndVisible());
filters[index++] = filterFromTag(context, tag,
Criterion.and(TaskCriteria.activeAndVisible(), Criterion.not(TaskCriteria.isReadOnly())));
}
FilterCategory tagsFilter = new FilterCategory(context.getString(R.string.tag_FEx_by_size), filters);
list[2] = tagsFilter;

@ -8,7 +8,12 @@ import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.*;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
@ -107,6 +112,7 @@ public final class TagService {
return new QueryTemplate().where(Criterion.and(
Criterion.not(Task.ID.in(Query.select(Metadata.TASK).from(Metadata.TABLE).where(MetadataCriteria.withKey(KEY)))),
TaskCriteria.isActive(),
Criterion.not(TaskCriteria.isReadOnly()),
TaskCriteria.isVisible()));
}

@ -844,10 +844,13 @@
<string name="producteev_FEx_dashboard">Arbeitsbereiche</string>
<!-- filter category for Producteev responsible person -->
<string name="producteev_FEx_responsible">Zugeordnet an</string>
<string name="producteev_FEx_responsible_byme">Von mir übertragen an</string>
<!-- filter category for Producteev responsible person -->
<string name="producteev_FEx_responsible_byothers">Von anderen übertragen an</string>
<!-- Producteev dashboard filter title (%s => dashboardname) -->
<string name="producteev_FEx_responsible_title">Zugeordnet an \'%s\'</string>
<string name="producteev_FEx_responsible_title">Übertragen an \'%s\'</string>
<!-- detail for showing tasks created by someone else (%s => person name) -->
<string name="producteev_PDE_task_from">von %s</string>

@ -11,9 +11,12 @@
<string name="producteev_FEx_dashboard">Workspaces</string>
<!-- filter category for Producteev responsible person -->
<string name="producteev_FEx_responsible">Assigned To</string>
<string name="producteev_FEx_responsible_byme">Assigned by me to</string>
<!-- Producteev dashboard filter title (%s => dashboardname) -->
<!-- filter category for Producteev responsible person -->
<string name="producteev_FEx_responsible_byothers">Assigned by others to</string>
<!-- Producteev responsible filter title (%s => responsiblename) -->
<string name="producteev_FEx_responsible_title">Assigned To \'%s\'</string>
<!-- detail for showing tasks created by someone else (%s => person name) -->

@ -794,6 +794,9 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
ContextMenuInfo menuInfo) {
AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo)menuInfo;
Task task = ((ViewHolder)adapterInfo.targetView.getTag()).task;
if (task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY))
return;
int id = (int)task.getId();
menu.setHeaderTitle(task.getValue(Task.TITLE));

@ -88,6 +88,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
public static final Property<?>[] PROPERTIES = new Property<?>[] {
Task.ID,
Task.TITLE,
Task.FLAGS,
Task.IMPORTANCE,
Task.DUE_DATE,
Task.COMPLETION_DATE,
@ -319,6 +320,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
completedItems.get(task.getId()) ? DateUtilities.now() : 0);
}
completeBox.setChecked(task.isCompleted());
// disable checkbox if task is readonly
completeBox.setEnabled(!viewHolder.task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY));
}
// importance bar
@ -689,7 +692,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
@Override
public void run() {
mBarListener.addWithAction(item);
mBar.show(viewHolder.view);
if (!viewHolder.task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY))
mBar.show(viewHolder.view);
}
});
}
@ -831,7 +835,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
Collection<TaskAction> actions = taskActionManager.get(taskId);
prepareQuickActionBar(viewHolder, actions);
//mBarAnchor = v;
if(actions != null)
if(actions != null && !viewHolder.task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY))
mBar.show(v);
taskActionManager.request(viewHolder);
@ -868,6 +872,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
boolean state = task.isCompleted();
viewHolder.completeBox.setChecked(state);
viewHolder.completeBox.setEnabled(!viewHolder.task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY));
TextView name = viewHolder.nameView;
if(state) {

@ -13,6 +13,7 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
@ -64,6 +65,10 @@ public class TaskDao extends DatabaseDao<Task> {
return Task.DELETION_DATE.neq(0);
}
public static Criterion isReadOnly() {
return Field.field(Task.FLAGS.name+" & "+Task.FLAG_IS_READONLY).eq(Task.FLAG_IS_READONLY);
}
/** @return tasks that were not deleted */
public static Criterion notDeleted() {
return Task.DELETION_DATE.eq(0);

Loading…
Cancel
Save