From 812c5b128e32d757444295d25da5afd61f39cab4 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 23 Oct 2012 14:35:26 -0700 Subject: [PATCH] Launch task comments view when non-editable task clicked --- .../astrid/actfm/TaskCommentsFragment.java | 11 +++++++++-- .../todoroo/astrid/activity/AstridActivity.java | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java index 122671b2e..8a779a07e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java @@ -6,10 +6,12 @@ import android.view.ViewGroup; import android.widget.ListView; import com.timsu.astrid.R; +import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.adapter.UpdateAdapter; +import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Update; import com.todoroo.astrid.service.StatisticsConstants; @@ -18,6 +20,9 @@ public class TaskCommentsFragment extends CommentsFragment { public static final String EXTRA_TASK = "extra_task"; //$NON-NLS-1$ + @Autowired + private TaskDao taskDao; + private Task task; public TaskCommentsFragment() { @@ -26,8 +31,10 @@ public class TaskCommentsFragment extends CommentsFragment { @Override protected void loadModelFromIntent(Intent intent) { - if (task == null) - task = intent.getParcelableExtra(EXTRA_TASK); + if (task == null) { + long taskId = intent.getLongExtra(EXTRA_TASK, 0L); + task = taskDao.fetch(taskId, Task.PROPERTIES); + } } @Override diff --git a/astrid/src/com/todoroo/astrid/activity/AstridActivity.java b/astrid/src/com/todoroo/astrid/activity/AstridActivity.java index 1c1f3fee7..e4275782b 100644 --- a/astrid/src/com/todoroo/astrid/activity/AstridActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/AstridActivity.java @@ -27,8 +27,10 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DialogUtilities; +import com.todoroo.astrid.actfm.CommentsActivity; import com.todoroo.astrid.actfm.CommentsFragment; import com.todoroo.astrid.actfm.TagCommentsFragment; +import com.todoroo.astrid.actfm.TaskCommentsFragment; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterListItem; @@ -248,6 +250,14 @@ public class AstridActivity extends FragmentActivity @Override public void onTaskListItemClicked(long taskId, boolean editable) { + if (editable) { + editTask(taskId); + } else { + showComments(taskId); + } + } + + private void editTask(long taskId) { Intent intent = new Intent(this, TaskEditActivity.class); intent.putExtra(TaskEditFragment.TOKEN_ID, taskId); getIntent().putExtra(TaskEditFragment.TOKEN_ID, taskId); // Needs to be in activity intent so that TEA onResume doesn't create a blank activity @@ -286,6 +296,13 @@ public class AstridActivity extends FragmentActivity } } + private void showComments(long taskId) { + Intent intent = new Intent(this, CommentsActivity.class); + intent.putExtra(TaskCommentsFragment.EXTRA_TASK, taskId); + startActivity(intent); + AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_left_in, R.anim.slide_left_out); + } + @Override public void onBackPressed() { if (isFinishing())