diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java index e577a75ee..edbf0f0df 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagsControlSet.java @@ -266,4 +266,9 @@ public final class TagsControlSet extends PopupControlSet { tagsDisplay.setText(buildTagString()); } + public boolean hasLists() { + LinkedHashSet tags = getTagSet(); + return !tags.isEmpty(); + } + } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java index 17c0733e4..18a1fae94 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditActivity.java @@ -182,6 +182,7 @@ public final class TaskEditActivity extends Activity { private EditPeopleControlSet peopleControlSet = null; private EditNotesControlSet notesControlSet = null; private HideUntilControlSet hideUntilControls = null; + private TagsControlSet tagsControlSet = null; private EditText title; private final List controls = @@ -296,10 +297,10 @@ public final class TaskEditActivity extends Activity { //moreControls.addView(importanceControl.getDisplayView()); controlSetMap.put(getString(R.string.TEA_ctrl_importance_pref), importanceControl); - TagsControlSet tagsControl = new TagsControlSet(TaskEditActivity.this, R.layout.control_set_tags, R.layout.control_set_tags_display, R.string.TEA_tags_label); - controls.add(tagsControl); + tagsControlSet = new TagsControlSet(TaskEditActivity.this, R.layout.control_set_tags, R.layout.control_set_tags_display, R.string.TEA_tags_label); + controls.add(tagsControlSet); //moreControls.addView(tagsControl.getDisplayView()); - controlSetMap.put(getString(R.string.TEA_ctrl_lists_pref), tagsControl); + controlSetMap.put(getString(R.string.TEA_ctrl_lists_pref), tagsControlSet); notesControlSet = new EditNotesControlSet(TaskEditActivity.this, R.layout.control_set_notes, R.layout.control_set_notes_display); notesEditText = (EditText) notesControlSet.getView().findViewById(R.id.notes); @@ -533,6 +534,18 @@ public final class TaskEditActivity extends Activity { if (isNewTask) { hideUntilControls.setDefaults(); } + autoExpand(); + } + } + + private void autoExpand() { + LinearLayout moreControls = (LinearLayout) findViewById(R.id.more_controls); + LinearLayout moreHeader = (LinearLayout) findViewById(R.id.more_header); + + if (notesControlSet.hasNotes() && notesControlSet.getDisplayView().getParent() == moreControls) { + moreHeader.performClick(); + } else if (tagsControlSet.hasLists() && tagsControlSet.getDisplayView().getParent() == moreControls) { + moreHeader.performClick(); } } diff --git a/astrid/src/com/todoroo/astrid/ui/EditNotesControlSet.java b/astrid/src/com/todoroo/astrid/ui/EditNotesControlSet.java index b27ac3ea1..67ec040c9 100644 --- a/astrid/src/com/todoroo/astrid/ui/EditNotesControlSet.java +++ b/astrid/src/com/todoroo/astrid/ui/EditNotesControlSet.java @@ -48,4 +48,8 @@ public class EditNotesControlSet extends PopupControlSet { return null; } + public boolean hasNotes() { + return !TextUtils.isEmpty(editText.getText()); + } + }