From be6b1310e196d50f5a8073d7f60f2d9ff3668f84 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 16 Apr 2012 13:35:33 -0700 Subject: [PATCH] Make clicking on task links in comments edit task --- .../todoroo/astrid/notes/EditNoteActivity.java | 2 +- astrid/res/values/strings-updates.xml | 2 +- .../todoroo/astrid/adapter/UpdateAdapter.java | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java index c99c3072d..1be082b5d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/notes/EditNoteActivity.java @@ -499,7 +499,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene String commentPicture = u.getValue(Update.PICTURE); - Spanned title = UpdateAdapter.getUpdateComment(u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW); + Spanned title = UpdateAdapter.getUpdateComment(null, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW); return new NoteOrUpdate(user.optString("picture"), title, commentPicture, diff --git a/astrid/res/values/strings-updates.xml b/astrid/res/values/strings-updates.xml index 1f52a0181..91795ed85 100644 --- a/astrid/res/values/strings-updates.xml +++ b/astrid/res/values/strings-updates.xml @@ -16,7 +16,7 @@ %1$s added @task to this list %1$s assigned @task to %4$s %1$s commented: %3$s - %1$s Re: %2$s: %3$s + %1$s Re: @task: %3$s %1$s Re: %2$s: %3$s %1$s created this list %1$s created the list %2$s diff --git a/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java b/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java index 45eb4adce..342ea361b 100644 --- a/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java @@ -34,6 +34,7 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; +import com.todoroo.astrid.activity.AstridActivity; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Update; @@ -51,6 +52,7 @@ public class UpdateAdapter extends CursorAdapter { // --- instance variables protected final Fragment fragment; + protected final AstridActivity activity; private final int resource; private final LayoutInflater inflater; private final ImageDiskCache imageCache; @@ -102,7 +104,7 @@ public class UpdateAdapter extends CursorAdapter { this.resource = resource; this.fragment = fragment; - + this.activity = (AstridActivity) fragment.getActivity(); } public static String getLinkColor(Fragment f) { @@ -158,7 +160,7 @@ public class UpdateAdapter extends CursorAdapter { // name final TextView nameView = (TextView)view.findViewById(R.id.title); { - nameView.setText(getUpdateComment(update, user, linkColor, fromView)); + nameView.setText(getUpdateComment(activity, update, user, linkColor, fromView)); nameView.setMovementMethod(new LinkMovementMethod()); } @@ -225,7 +227,7 @@ public class UpdateAdapter extends CursorAdapter { } @SuppressWarnings("nls") - public static Spanned getUpdateComment (Update update, JSONObject user, String linkColor, String fromView) { + public static Spanned getUpdateComment (final AstridActivity activity, Update update, JSONObject user, String linkColor, String fromView) { if (user == null) { user = ActFmPreferenceService.userFromModel(update); } @@ -243,13 +245,14 @@ public class UpdateAdapter extends CursorAdapter { taskId = local.getId(); } - return getUpdateComment(update.getValue(Update.ACTION_CODE), + return getUpdateComment(activity, update.getValue(Update.ACTION_CODE), user.optString("name"), update.getValue(Update.TARGET_NAME), update.getValue(Update.MESSAGE), otherUser.optString("name"), update.getValue(Update.ACTION), linkColor, fromView, taskId); } - public static Spanned getUpdateComment (String actionCode, String user, String targetName, String message, String otherUser, String action, String linkColor, String fromView, final long taskId) { + public static Spanned getUpdateComment (final AstridActivity activity, String actionCode, String user, String targetName, + String message, String otherUser, String action, String linkColor, String fromView, final long taskId) { if (TextUtils.isEmpty(user)) { user = ContextManager.getString(R.string.ENA_no_user); } @@ -321,7 +324,7 @@ public class UpdateAdapter extends CursorAdapter { if (taskLinkIndex < 0) return Html.fromHtml(original); - if (taskId <= 0) { + if (taskId <= 0 || activity == null) { original = original.replace(TASK_LINK_TOKEN, targetNameLink); return Html.fromHtml(original); } @@ -332,7 +335,7 @@ public class UpdateAdapter extends CursorAdapter { taskSpan.setSpan(new ClickableSpan() { @Override public void onClick(View widget) { - System.err.println("Click " + taskId); + activity.onTaskListItemClicked(taskId); } }, 0, targetName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);