From 58bd29e740a137cf705cbfa7ad512135d6b57fdc Mon Sep 17 00:00:00 2001 From: satok Date: Thu, 3 Sep 2009 12:58:28 +0900 Subject: [PATCH] Fixed Labels for buld email BUG:2084730 --- .../android/email/activity/MessageList.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index 02a5a0cbe..df0bd1c4c 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -660,13 +660,20 @@ public class MessageList extends ListActivity implements OnItemClickListener, On return numChanged; } - private boolean testMultiple(Set selectedSet, int column_id) { + /** + * Test selected messages for showing appropriate labels + * @param selectedSet + * @param column_id + * @param defaultflag + * @return true when the specified flagged message is selected + */ + private boolean testMultiple(Set selectedSet, int column_id, boolean defaultflag) { Cursor c = mListAdapter.getCursor(); c.moveToPosition(-1); while (c.moveToNext()) { long id = c.getInt(MessageListAdapter.COLUMN_ID); if (selectedSet.contains(Long.valueOf(id))) { - if (c.getInt(column_id) != 0) { + if (c.getInt(column_id) == (defaultflag? 1 : 0)) { return true; } } @@ -675,12 +682,15 @@ public class MessageList extends ListActivity implements OnItemClickListener, On } private void updateFooterButtonNames () { - if (testMultiple(mListAdapter.getSelectedSet(), MessageListAdapter.COLUMN_READ)) { + // Show "unread_action" when one or more read messages are selected. + if (testMultiple(mListAdapter.getSelectedSet(), MessageListAdapter.COLUMN_READ, true)) { mReadUnreadButton.setText(R.string.unread_action); } else { mReadUnreadButton.setText(R.string.read_action); } - if (testMultiple(mListAdapter.getSelectedSet(), MessageListAdapter.COLUMN_FAVORITE)) { + // Show "set_star_action" when one or more un-starred messages are selected. + if (testMultiple(mListAdapter.getSelectedSet(), + MessageListAdapter.COLUMN_FAVORITE, false)) { mFavoriteButton.setText(R.string.set_star_action); } else { mFavoriteButton.setText(R.string.remove_star_action);