From 706817761966e68880c85051bf4e8ac3011fe38c Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 2 Feb 2012 16:05:40 -0800 Subject: [PATCH] Comments popover in LAYOUT_DOUBLE --- .../astrid/activity/AstridActivity.java | 11 +++++++-- .../astrid/activity/TaskListActivity.java | 24 ++++++++++++++++--- .../astrid/activity/TaskListFragment.java | 2 +- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/AstridActivity.java b/astrid/src/com/todoroo/astrid/activity/AstridActivity.java index 25cf01b8b..794472557 100644 --- a/astrid/src/com/todoroo/astrid/activity/AstridActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/AstridActivity.java @@ -77,6 +77,12 @@ public class AstridActivity extends FragmentActivity return frag; } + public TagUpdatesFragment getTagUpdatesFragment() { + TagUpdatesFragment frag = (TagUpdatesFragment) getSupportFragmentManager() + .findFragmentByTag(TagUpdatesFragment.TAG_UPDATES_FRAGMENT); + + return frag; + } @Override @@ -155,10 +161,11 @@ public class AstridActivity extends FragmentActivity } public void setupActivityFragment(TagData tagData) { - if (fragmentLayout != LAYOUT_TRIPLE) + if (fragmentLayout == LAYOUT_SINGLE) return; - findViewById(R.id.taskedit_fragment_container).setVisibility(View.VISIBLE); + if (fragmentLayout == LAYOUT_TRIPLE) + findViewById(R.id.taskedit_fragment_container).setVisibility(View.VISIBLE); FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index c8cb80b7a..6be8ae913 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -21,6 +21,7 @@ import com.timsu.astrid.R; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.actfm.TagSettingsActivity; +import com.todoroo.astrid.actfm.TagUpdatesFragment; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.reminders.NotificationFragment; @@ -43,6 +44,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener private FragmentPopover listsPopover; private FragmentPopover editPopover; + private FragmentPopover commentsPopover; private MainMenuPopover mainMenuPopover; private final OnClickListener mainMenuClickListener = new OnClickListener() { @@ -64,9 +66,18 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener private final OnClickListener commentsButtonClickListener = new OnClickListener() { @Override public void onClick(View v) { - TaskListFragment tlf = getTaskListFragment(); - if (tlf != null) - tlf.commentsButtonClicked(); + if (fragmentLayout == LAYOUT_DOUBLE) { + TagUpdatesFragment frag = getTagUpdatesFragment(); + if (frag != null) { + setupPopoverWithFragment(commentsPopover, frag, null); + commentsPopover.show(listsNav); + } + } else { + // In this case we should be in LAYOUT_SINGLE--delegate to the task list fragment + TaskListFragment tlf = getTaskListFragment(); + if (tlf != null) + tlf.handleCommentsButtonClicked(); + } } }; @@ -130,6 +141,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener } else { fragmentLayout = LAYOUT_DOUBLE; createEditPopover(); + createCommentsPopover(); } setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT, @@ -168,6 +180,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener }); } + private void createCommentsPopover() { + commentsPopover = new FragmentPopover(this, R.layout.taskedit_popover); + } + private void createMainMenuPopover() { mainMenuPopover = new MainMenuPopover(this, R.layout.main_menu_popover); mainMenuPopover.setMenuListener(this); @@ -260,6 +276,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener editPopover.dismiss(); if (mainMenuPopover != null) mainMenuPopover.dismiss(); + if (commentsPopover != null) + commentsPopover.dismiss(); } public void setSelectedItem(Filter item) { diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 020676fbb..8f5c71773 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -1202,7 +1202,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, /** * Comments button in action bar was clicked */ - protected void commentsButtonClicked() { + protected void handleCommentsButtonClicked() { Intent intent = new Intent(getActivity(), TagUpdatesActivity.class); intent.putExtra(TagViewFragment.EXTRA_TAG_DATA, getTagDataForUpdates()); startActivity(intent);