Fixes to the [untagged] business. Think it works now. Also, fix to the way the locale reminder string is displayed - using task plural.

pull/14/head
Tim Su 17 years ago
parent 95eaa160cd
commit 7b77ab0274

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid"
android:versionCode="101"
android:versionName="2.7.3">
android:versionCode="102"
android:versionName="2.8.0">
<!-- ============================ Metadata ============================ -->

@ -103,7 +103,8 @@
<skip />
<!-- title bar -->
<string name="taskList_titlePrefix">Astrid: </string>
<string name="taskList_titleTagPrefix">Tagged \"%s\": </string>
<string name="taskList_titleTagPrefix">Tagged \"%s\":</string>
<string name="taskList_titleUntagged">Untagged Tasks:</string>
<string name="taskList_hiddenSuffix"> hidden</string>
<string name="addtask_label">New Task</string>
<string name="missing_tag">Could Not Find Requested Tag!</string>
@ -343,7 +344,7 @@ Thanks for using Astrid!\n
<string name="notif_definiteDueDate">Absolute Deadline!</string>
<string name="notif_preferredDueDate">Goal Deadline!</string>
<string name="notif_timerStarted">Working on:</string>
<string name="notif_tagNotification">You have %d tasks tagged %s!</string>
<string name="notif_tagNotification">You have %s tagged %s!</string>
<!-- Error Messages -->
<skip />

@ -83,6 +83,7 @@ public class TagListSubActivity extends SubActivity {
HashMap<TagModelForView, Integer> tagToTaskCount;
private Handler handler;
private TextView loadingText;
private boolean untaggedTagDisplayed;
private static SortMode sortMode = SortMode.SIZE;
private static boolean sortReverse = false;
@ -164,9 +165,12 @@ public class TagListSubActivity extends SubActivity {
// show "untagged" as a category at the top, in the proper language/localization
String untaggedLabel = getResources().getString(R.string.tagList_untagged);
TagModelForView untaggedModel = TagModelForView.getUntaggedModel(untaggedLabel);
tagArray.addFirst(untaggedModel);
int count = countActiveTasks(activeTasks, getTagController().getUntaggedTasks());
tagToTaskCount.put(untaggedModel, count);
if(count > 0) {
untaggedTagDisplayed = true;
tagArray.addFirst(untaggedModel);
tagToTaskCount.put(untaggedModel, count);
}
if(sortReverse)
Collections.reverse(tagArray);
@ -208,10 +212,13 @@ public class TagListSubActivity extends SubActivity {
private void setUpListUI(ListAdapter adapter) {
// set up the title
Resources r = getResources();
int tags = tagArray.size();
if(untaggedTagDisplayed)
tags--;
StringBuilder title = new StringBuilder().
append(r.getString(R.string.tagList_titlePrefix)).
append(" ").append(r.getQuantityString(R.plurals.Ntags,
tagArray.size(), tagArray.size()));
tags, tags));
final CharSequence finalTitle = title;
handler.post(new Runnable() {
public void run() {
@ -439,7 +446,7 @@ public class TagListSubActivity extends SubActivity {
name.setText(new StringBuilder(tag.getName()).
append(" (").append(tagCount.get(tag)).append(")"));
if(tagCount.get(tag) == 0)
if(tagCount == null || tagCount.get(tag) == null || tagCount.get(tag) == 0)
name.setTextColor(r.getColor(R.color.task_list_done));
else
name.setTextColor(r.getColor(android.R.color.white));

@ -596,8 +596,12 @@ public class TaskListSubActivity extends SubActivity {
StringBuilder title = new StringBuilder().
append(r.getString(R.string.taskList_titlePrefix)).append(" ");
if(context.filterTag != null) {
title.append(r.getString(R.string.taskList_titleTagPrefix,
context.filterTag.getName())).append(" ");
if(TagModelForView.UNTAGGED_IDENTIFIER.equals(context.filterTag.getTagIdentifier())) {
title.append(r.getString(R.string.taskList_titleUntagged)).append(" ");
} else {
title.append(r.getString(R.string.taskList_titleTagPrefix,
context.filterTag.getName())).append(" ");
}
}
if(finalCompleted > 0)

@ -20,12 +20,12 @@
package com.timsu.astrid.data.tag;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.CursorJoiner;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
@ -128,7 +128,7 @@ public class TagController extends AbstractController {
* the TagToTask map once for each active task.
**/
public LinkedList<TaskIdentifier> getUntaggedTasks() throws SQLException {
LinkedList<TaskIdentifier> list = new LinkedList<TaskIdentifier>();
HashSet<Long> ids = new HashSet<Long>();
String[] tagMapColumns = new String[] { TagToTaskMapping.TASK };
Cursor tagMapCursor = tagToTaskMapDatabase.query(TAG_TASK_MAP_NAME,
@ -141,30 +141,30 @@ public class TagController extends AbstractController {
Cursor taskCursor = taskDatabase.query(TASK_TABLE_NAME, taskColumns,
null, null, null, null, KEY_ROWID + " ASC");
LinkedList<TaskIdentifier> list = new LinkedList<TaskIdentifier>();
try {
CursorJoiner joiner = new CursorJoiner(taskCursor, taskColumns,
tagMapCursor, tagMapColumns);
for (CursorJoiner.Result joinerResult : joiner) {
switch (joinerResult) {
case LEFT:
long taskId = taskCursor.getLong(0);
// conditional is necessary for handling deleted tasks
if(tagMapCursor.isLast() || tagMapCursor.getLong(0) > taskId) {
list.add(new TaskIdentifier(taskId));
}
break;
default:
// in other cases, do nothing
break;
}
}
if(taskCursor.getCount() == 0)
return list;
do {
taskCursor.moveToNext();
ids.add(taskCursor.getLong(0));
} while(!taskCursor.isLast());
if(tagMapCursor.getCount() > 0) {
do {
tagMapCursor.moveToNext();
ids.remove(tagMapCursor.getLong(0));
} while(!tagMapCursor.isLast());
}
} finally {
taskCursor.close();
tagMapCursor.close();
taskDatabase.close();
}
for(Long id : ids)
list.add(new TaskIdentifier(id));
return list;
}

@ -6,6 +6,7 @@ import java.util.LinkedList;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.util.Log;
import com.timsu.astrid.R;
@ -47,8 +48,9 @@ public class LocaleReceiver extends BroadcastReceiver {
new TagIdentifier(tagId));
int count = TagListSubActivity.countActiveTasks(activeTasks, tasks);
if(count > 0) {
String reminder = context.getResources().getString(
R.string.notif_tagNotification, count, tagName);
Resources r = context.getResources();
String reminder = r.getString(R.string.notif_tagNotification,
r.getQuantityString(R.plurals.Ntasks, count, count), tagName);
Notifications.showTagNotification(context, tagId, reminder);
}
} finally {

Loading…
Cancel
Save