diff --git a/res/menu/message_list_option.xml b/res/menu/message_list_option.xml
index 97cb9e62c..e2a8685ae 100644
--- a/res/menu/message_list_option.xml
+++ b/res/menu/message_list_option.xml
@@ -37,11 +37,61 @@
/>
-
+ -
+
+
- dd-MMM-yyyy
yyyy-MM-dd
+ Batch Ops
+ Delete selected
+ Mark selected read
+ Mark selected unread
+ Flag selected
+ Unflag selected
+ Move selected
+ Copy selected
+ Star mode
+ Select mode
+ Plain mode
+ Select all
+ Deselect all
diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java
index 0e3fcffe1..9f0bc569d 100644
--- a/src/com/android/email/activity/MessageList.java
+++ b/src/com/android/email/activity/MessageList.java
@@ -433,7 +433,8 @@ public class MessageList
{
onRestoreListState(savedInstanceState);
}
-
+
+ setTitle();
}
private void onRestoreListState(Bundle savedInstanceState)
@@ -485,13 +486,17 @@ public class MessageList
notifMgr.cancel(mAccount.getAccountNumber());
notifMgr.cancel(-1000 - mAccount.getAccountNumber());
+ setTitle();
+ }
+
+ private void setTitle()
+ {
setTitle(
- mAccount.getDescription()
- + " - " +
- mCurrentFolder.displayName
-
- );
+ mAccount.getDescription()
+ + " - " +
+ mCurrentFolder.displayName
+ );
}
@Override
@@ -702,13 +707,11 @@ public class MessageList
case WIDGET_FLAG:
{
mSelectedWidget = WIDGET_MULTISELECT;
- showBatchButtons();
break;
}
case WIDGET_MULTISELECT:
{
mSelectedWidget = WIDGET_NONE;
- hideBatchButtons();
break;
}
case WIDGET_NONE:
@@ -731,13 +734,11 @@ public class MessageList
case WIDGET_NONE:
{
mSelectedWidget=WIDGET_MULTISELECT;
- showBatchButtons();
break;
}
case WIDGET_MULTISELECT:
{
mSelectedWidget=WIDGET_FLAG;
- hideBatchButtons();
break;
}
@@ -745,7 +746,25 @@ public class MessageList
}
-
+ configureWidgets();
+
+ }
+
+ private void configureWidgets()
+ {
+ switch (mSelectedWidget)
+ {
+ case WIDGET_FLAG:
+ hideBatchButtons();
+ break;
+ case WIDGET_NONE:
+ hideBatchButtons();
+ break;
+ case WIDGET_MULTISELECT:
+ showBatchButtons();
+ break;
+ }
+
int count = mListView.getChildCount();
for (int i=0; i 27)
- {
- mess = mess.substring(0, 27);
- }
-
- return mess;
- }
-
class MessageListAdapter extends BaseAdapter
{
private List messages = java.util.Collections.synchronizedList(new ArrayList());
@@ -2226,44 +2353,67 @@ public class MessageList
}
}
}
-
- public void onClick(View v)
+
+ private boolean computeBatchDirection(boolean flagged)
{
boolean newState = false;
- List messageList = new ArrayList();
+
for (MessageInfoHolder holder : mAdapter.messages)
{
if (holder.selected)
{
- if (v == mBatchDeleteButton)
- {
- mAdapter.removeMessage(holder);
- }
- else if (v == mBatchFlagButton)
+ if (flagged)
{
if (!holder.flagged)
{
newState = true;
}
}
- else if (v == mBatchReadButton)
+ else
{
if (!holder.read)
{
newState = true;
}
}
- messageList.add(holder.message);
}
}
+ return newState;
+ }
+
+ private boolean anySelected()
+ {
+ for (MessageInfoHolder holder : mAdapter.messages)
+ {
+ if (holder.selected)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ public void onClick(View v)
+ {
+ boolean newState = false;
+ List messageList = new ArrayList();
+ List removeHolderList = new ArrayList();
+
+ if (v == mBatchFlagButton)
+ {
+ newState = computeBatchDirection(true);
+ }
+ else
+ {
+ newState = computeBatchDirection(false);
+ }
for (MessageInfoHolder holder : mAdapter.messages)
{
if (holder.selected)
{
if (v == mBatchDeleteButton)
{
- //nothing
+ removeHolderList.add(holder);
}
else if (v == mBatchFlagButton)
{
@@ -2273,8 +2423,10 @@ public class MessageList
{
holder.read = newState;
}
+ messageList.add(holder.message);
}
}
+ mAdapter.removeMessages(removeHolderList);
if (!messageList.isEmpty())
{
@@ -2298,5 +2450,62 @@ public class MessageList
mHandler.sortMessages();
}
-
+ private void setAllSelected(boolean isSelected)
+ {
+ mSelectedCount = 0;
+ for (MessageInfoHolder holder : mAdapter.messages)
+ {
+ holder.selected = isSelected;
+ mSelectedCount += (isSelected ? 1 : 0);
+ }
+ mAdapter.notifyDataSetChanged();
+ showBatchButtons();
+ }
+
+ private void flagSelected(Flag flag, boolean newState)
+ {
+ List messageList = new ArrayList();
+ for (MessageInfoHolder holder : mAdapter.messages)
+ {
+ if (holder.selected)
+ {
+ messageList.add(holder.message);
+ if (flag == Flag.SEEN)
+ {
+ holder.read = newState;
+ }
+ else if (flag == Flag.FLAGGED)
+ {
+ holder.flagged = newState;
+ }
+ }
+ }
+ MessagingController.getInstance(getApplication()).setFlag(mAccount, mCurrentFolder.name, messageList.toArray(new Message[0]),
+ flag , newState);
+ mHandler.sortMessages();
+ }
+
+ private void deleteSelected()
+ {
+ List messageList = new ArrayList();
+ List removeHolderList = new ArrayList();
+ for (MessageInfoHolder holder : mAdapter.messages)
+ {
+ if (holder.selected)
+ {
+ removeHolderList.add(holder);
+ messageList.add(holder.message);
+ }
+ }
+ mAdapter.removeMessages(removeHolderList);
+
+ MessagingController.getInstance(getApplication()).deleteMessages(mAccount, mCurrentFolder.name, messageList.toArray(new Message[0]), null);
+ mSelectedCount = 0;
+ configureBatchButtons();
+ }
+
+ private void moveOrCopySelected(boolean isMove)
+ {
+
+ }
}