Tweaks to quick-add to make it work in all cases

pull/14/head
Tim Su 15 years ago
parent 8c3bee018c
commit fec3f3c93a

@ -2,7 +2,6 @@ package com.todoroo.astrid.producteev;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.sync.SyncProviderUtilities;
/**
@ -28,10 +27,6 @@ public class ProducteevUtilities extends SyncProviderUtilities {
/** setting for dashboard to use default one */
public static final int DASHBOARD_DEFAULT = 0;
static {
Task.IMPORTANCE_LEAST = 5;
}
@Override
public String getIdentifier() {
return IDENTIFIER;

@ -730,7 +730,8 @@ public final class TaskEditActivity extends TabActivity {
int min = Task.IMPORTANCE_MOST;
int max = Task.IMPORTANCE_LEAST;
int importanceOffset = max;
if(ProducteevUtilities.INSTANCE.isLoggedIn())
max = 5;
for(int i = min; i <= max; i++) {
final ToggleButton button = new ToggleButton(TaskEditActivity.this);
@ -741,7 +742,7 @@ public final class TaskEditActivity extends TabActivity {
if(ProducteevUtilities.INSTANCE.isLoggedIn())
label.append(5 - i).append("\n\u2605"); //$NON-NLS-1$
else {
for(int j = importanceOffset; j >= i; j--)
for(int j = Task.IMPORTANCE_LEAST; j >= i; j--)
label.append('!');
}

@ -23,6 +23,7 @@ import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.producteev.ProducteevUtilities;
import com.todoroo.astrid.producteev.sync.ProducteevTask;
import com.todoroo.astrid.tags.TagService;
@ -322,25 +323,29 @@ public class TaskService {
Pattern importancePattern = Pattern.compile("(\\s|^)!(\\d)(\\s|$)");
while(true) {
Matcher m = tagPattern.matcher(title);
if(m.matches()) {
if(m.find()) {
tags.add(m.group(2));
} else {
m = contextPattern.matcher(title);
if(m.matches()) {
if(m.find()) {
tags.add(m.group(2));
} else {
m = importancePattern.matcher(title);
if(m.matches()) {
int importance = Integer.parseInt(m.group(2));
task.setValue(Task.IMPORTANCE, Task.IMPORTANCE_LEAST + 1 - importance);
if(task.getValue(Task.IMPORTANCE) < Task.IMPORTANCE_MOST)
task.setValue(Task.IMPORTANCE, Task.IMPORTANCE_MOST);
if(m.find()) {
int value = Integer.parseInt(m.group(2));
// not in producteev world: !1 to !4 => importance 3 to 0
int importance = Math.max(Task.IMPORTANCE_MOST, Task.IMPORTANCE_LEAST + 1 - value);
// in the producteev world, !1 to !4 => importance 4 to 1
if(ProducteevUtilities.INSTANCE.isLoggedIn())
importance++;
task.setValue(Task.IMPORTANCE, importance);
} else
break;
}
}
title = title.substring(0, m.start()) + title.substring(m.end() + 1);
title = title.substring(0, m.start()) + title.substring(m.end());
}
task.setValue(Task.TITLE, title.trim());
}

@ -135,11 +135,12 @@ public final class UpgradeService {
if(from < V3_7_0) {
newVersionString(changeLog, "3.7.0 (2/7/10)", new String[] {
"Improved UI for displaying task actions. Tap a task to " +
"bring up an action bar, tap anywhere to dismiss.",
"bring actions, tap again to dismiss.",
"Task notes can be viewed by tapping the note icon to " +
"the right of the task.",
"Added Astrid to 'Send-To' menu of Android Browser and " +
"other apps for easy task creation.",
"Added Astrid as 'Send-To' choice in Android Browser and " +
"other apps.",
"Quick-add tasks with #tags, @contexts, or !4 importance",
"Fixed bug with custom filters & tasks being hidden",
});
upgrade3To3_7();

@ -62,8 +62,8 @@ public class QuickAddMarkupTest extends TodorooTestCase {
private Task task;
private ArrayList<String> tags = new ArrayList<String>();
private void assertTagsAre(String... tags) {
List<String> expected = Arrays.asList(tags);
private void assertTagsAre(String... expectedTags) {
List<String> expected = Arrays.asList(expectedTags);
assertEquals(expected.toString(), tags.toString());
}

Loading…
Cancel
Save