Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
Fix issue #206
Browse files Browse the repository at this point in the history
  • Loading branch information
mpcjanssen authored and ginatrapani committed Jan 10, 2013
1 parent 7cd7cf5 commit ff8eaf4
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/com/todotxt/todotxttouch/AddTask.java
Expand Up @@ -141,7 +141,7 @@ public void onCreate(Bundle savedInstanceState) {
// priorities
priorities = (Spinner) findViewById(R.id.priorities);
final ArrayList<String> prioArr = new ArrayList<String>();
prioArr.add(0,this.getApplicationContext().getString(R.string.add_task_priority_btn));
prioArr.add(0,"-");
prioArr.addAll(Priority.rangeInCode(Priority.A, Priority.E));
priorities.setAdapter(Util.newSpinnerAdapter(this, prioArr));
if (iniTask != null) {
Expand Down
8 changes: 8 additions & 0 deletions src/com/todotxt/todotxttouch/task/ByContextFilter.java
Expand Up @@ -50,7 +50,15 @@ public boolean apply(Task input) {
return true;
}
}
/*
* Match tasks without context if filter contains "-"
*/
if (input.getContexts().size()==0 && contexts.contains("-")) {
return true;
}

return false;

}

/* FOR TESTING ONLY, DO NOT USE IN APPLICATION */
Expand Down
6 changes: 6 additions & 0 deletions src/com/todotxt/todotxttouch/task/ByProjectFilter.java
Expand Up @@ -49,6 +49,12 @@ public boolean apply(Task input) {
return true;
}
}
/*
* Match tasks without project if filter contains "-"
*/
if (input.getProjects().size()==0 && projects.contains("-")) {
return true;
}
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions src/com/todotxt/todotxttouch/task/TaskBagImpl.java
Expand Up @@ -248,6 +248,7 @@ public ArrayList<String> getContexts() {
}
ArrayList<String> ret = new ArrayList<String>(res);
Collections.sort(ret);
ret.add(0, "-");
return ret;
}

Expand All @@ -260,6 +261,7 @@ public ArrayList<String> getProjects() {
}
ArrayList<String> ret = new ArrayList<String>(res);
Collections.sort(ret);
ret.add(0, "-");
return ret;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/src/com/todotxt/todotxttouch/task/ByContextFilterTest.java
Expand Up @@ -105,4 +105,16 @@ public void testFilter_multipleFilterContext_multipleDifferentTaskContext() {
assertFalse("apply was not false",
filter.apply(new Task(1, "hello world @xyz @goodbye")));
}

public void testFilter_noContextFilter_noTaskContext() {
ByContextFilter filter = new ByContextFilter(Arrays.asList("-"));
assertTrue("apply was not true",
filter.apply(new Task(1, "hello world")));
}

public void testFilter_noContextFilter_oneTaskContext() {
ByContextFilter filter = new ByContextFilter(Arrays.asList("-"));
assertFalse("apply was not false",
filter.apply(new Task(1, "hello world @xyz")));
}
}
12 changes: 12 additions & 0 deletions tests/src/com/todotxt/todotxttouch/task/ByProjectFilterTest.java
Expand Up @@ -105,4 +105,16 @@ public void testFilter_multipleFilterProject_multipleDifferentTaskProject() {
assertFalse("apply was not false",
filter.apply(new Task(1, "hello world +xyz +goodbye")));
}

public void testFilter_filterNoProject() {
ByProjectFilter filter = new ByProjectFilter(Arrays.asList("-"));
assertTrue("apply was not true",
filter.apply(new Task(1, "hello world")));
}

public void testFilter_filterNoProject_oneTaskProject() {
ByProjectFilter filter = new ByProjectFilter(Arrays.asList("-"));
assertFalse("apply was not false",
filter.apply(new Task(1, "hello world +Test")));
}
}

0 comments on commit ff8eaf4

Please sign in to comment.