Switch to assigned by me filter when assigning a task from active tasks list

pull/14/head
Sam Bosley 13 years ago
parent 1422f378a5
commit 24dfae45e4

@ -251,6 +251,7 @@ public final class Task extends RemoteModel {
defaultValues.put(LAST_SYNC.name, 0); defaultValues.put(LAST_SYNC.name, 0);
defaultValues.put(REMOTE_ID.name, 0); defaultValues.put(REMOTE_ID.name, 0);
defaultValues.put(USER_ID.name, 0); defaultValues.put(USER_ID.name, 0);
defaultValues.put(CREATOR_ID.name, 0);
defaultValues.put(USER.name, "{}"); defaultValues.put(USER.name, "{}");
defaultValues.put(SHARED_WITH.name, "{}"); defaultValues.put(SHARED_WITH.name, "{}");
} }

@ -100,6 +100,8 @@ public class EditPeopleControlSet extends PopupControlSet {
private final int loginRequestCode; private final int loginRequestCode;
private boolean assignedToMe = false;
static { static {
AstridDependencyInjector.initialize(); AstridDependencyInjector.initialize();
} }
@ -494,6 +496,8 @@ public class EditPeopleControlSet extends PopupControlSet {
task.setValue(Task.USER_ID, Task.USER_ID_SELF); task.setValue(Task.USER_ID, Task.USER_ID_SELF);
if(!TextUtils.isEmpty(task.getValue(Task.USER))) if(!TextUtils.isEmpty(task.getValue(Task.USER)))
task.setValue(Task.USER, ""); task.setValue(Task.USER, "");
assignedToMe = true;
} else if(userJson.optLong("id") == Task.USER_ID_UNASSIGNED) { } else if(userJson.optLong("id") == Task.USER_ID_UNASSIGNED) {
dirty = task.getValue(Task.USER_ID) == Task.USER_ID_UNASSIGNED ? dirty : true; dirty = task.getValue(Task.USER_ID) == Task.USER_ID_UNASSIGNED ? dirty : true;
task.setValue(Task.USER_ID, Task.USER_ID_UNASSIGNED); task.setValue(Task.USER_ID, Task.USER_ID_UNASSIGNED);
@ -685,6 +689,14 @@ public class EditPeopleControlSet extends PopupControlSet {
return values.toArray(new Object[values.size()]); return values.toArray(new Object[values.size()]);
} }
/**
* Warning - only valid after a call to saveSharingSettings
* @return
*/
public boolean isAssignedToMe() {
return assignedToMe;
}
/** Resume save /** Resume save
* @param data */ * @param data */
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {

@ -110,13 +110,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
null); null);
list[1].listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_pencil)).getBitmap(); list[1].listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_pencil)).getBitmap();
list[2] = new Filter(r.getString(R.string.BFE_Assigned), list[2] = getAssignedByMeFilter(r);
r.getString(R.string.BFE_Assigned),
new QueryTemplate().where(Criterion.and(TaskCriteria.isActive(),
Criterion.or(Task.CREATOR_ID.eq(0), Task.CREATOR_ID.eq(ActFmPreferenceService.userId())),
Task.USER_ID.neq(0))),
null);
list[2].listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_assigned)).getBitmap();
int untaggedLabel = gtasksPreferenceService.isLoggedIn() ? int untaggedLabel = gtasksPreferenceService.isLoggedIn() ?
R.string.tag_FEx_untagged_w_astrid : R.string.tag_FEx_untagged; R.string.tag_FEx_untagged_w_astrid : R.string.tag_FEx_untagged;
@ -147,6 +141,17 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
} }
} }
public static Filter getAssignedByMeFilter(Resources r) {
Filter f = new Filter(r.getString(R.string.BFE_Assigned),
r.getString(R.string.BFE_Assigned),
new QueryTemplate().where(Criterion.and(TaskCriteria.isActive(),
Criterion.or(Task.CREATOR_ID.eq(0), Task.CREATOR_ID.eq(ActFmPreferenceService.userId())),
Task.USER_ID.neq(0))),
null);
f.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_assigned)).getBitmap();
return f;
}
/** /**
* Simple activity for deleting stuff * Simple activity for deleting stuff
* *

@ -154,6 +154,8 @@ public final class TaskEditActivity extends Activity {
public static final String OVERRIDE_FINISH_ANIM = "finishAnim"; //$NON-NLS-1$ public static final String OVERRIDE_FINISH_ANIM = "finishAnim"; //$NON-NLS-1$
public static final String TASK_WAS_ASSIGNED = "task_assigned"; //$NON-NLS-1$
// --- services // --- services
@Autowired @Autowired
@ -660,7 +662,14 @@ public final class TaskEditActivity extends Activity {
model.putTransitory("task-edit-save", true); //$NON-NLS-1$ model.putTransitory("task-edit-save", true); //$NON-NLS-1$
taskService.save(model); taskService.save(model);
if (!onPause && !cancelFinish) { if (!onPause && !cancelFinish) {
if (!peopleControlSet.isAssignedToMe()) {
Intent data = new Intent();
data.putExtra(TASK_WAS_ASSIGNED, true);
setResult(RESULT_OK, data);
}
shouldSaveState = false; shouldSaveState = false;
finish(); finish();
} }

@ -87,6 +87,7 @@ import com.todoroo.astrid.api.TaskAction;
import com.todoroo.astrid.api.TaskContextActionExposer; import com.todoroo.astrid.api.TaskContextActionExposer;
import com.todoroo.astrid.api.TaskDecoration; import com.todoroo.astrid.api.TaskDecoration;
import com.todoroo.astrid.core.CoreFilterExposer; import com.todoroo.astrid.core.CoreFilterExposer;
import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.core.SortHelper; import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
@ -561,6 +562,9 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
AndroidUtilities.copyDatabases(this, "/sdcard/tmp");
StatisticsService.sessionStart(this); StatisticsService.sessionStart(this);
if (addOnService.hasPowerPack() && if (addOnService.hasPowerPack() &&
Preferences.getBoolean(R.string.p_voiceInputEnabled, true) && Preferences.getBoolean(R.string.p_voiceInputEnabled, true) &&
@ -741,11 +745,21 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
} }
if(resultCode != RESULT_CANCELED) { if(resultCode != RESULT_CANCELED) {
if (data.hasExtra(TaskEditActivity.TASK_WAS_ASSIGNED) && data.getBooleanExtra(TaskEditActivity.TASK_WAS_ASSIGNED, false) && !isFilter) {
switchToAssignedFilter();
} else {
taskAdapter.flushCaches(); taskAdapter.flushCaches();
loadTaskListContent(true); loadTaskListContent(true);
taskService.cleanup(); taskService.cleanup();
} }
} }
}
private void switchToAssignedFilter() {
filter = CustomFilterExposer.getAssignedByMeFilter(getResources());
setUpTaskList();
isFilter = true;
}
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) { int totalItemCount) {

Loading…
Cancel
Save