am d9c1e51d: Merge branch \'readonly-p4-donut\' into donut

Merge commit 'd9c1e51d841369ba7f26b8769337471ca10b7b84'

* commit 'd9c1e51d841369ba7f26b8769337471ca10b7b84':
  AI 149446: Add sending pending outbox message feature; integrates 148664, 148823 from imode to donut.
This commit is contained in:
Mihai Preda 2009-06-01 13:13:38 -07:00 committed by The Android Open Source Project
commit 061f4d21dc
4 changed files with 90 additions and 21 deletions

View File

@ -84,10 +84,14 @@
<string name="accounts_context_menu_title">Account options</string>
<!-- Appears in message list view while messages are being loaded -->
<string name="status_loading_more">Loading messages\u2026</string>
<!-- Appears in message list view of outbox while messages are being sent -->
<string name="status_sending_messages">Sending messages\u2026</string>
<!-- Appears in message list view when there's a network error. -->
<!-- Also appears in a toast, in the message viewer, when there's a network error. -->
<string name="status_network_error">Connection error</string>
<!-- Appears in message list view when error when trying to "Load more messages". -->
<string name="status_sending_messages_failed">Retry sending messages</string>
<!-- Appears in message list view when error when trying to "Load more messages". -->
<string name="status_loading_more_failed">Retry loading more messages</string>
<!-- Notification title in status bar -->
<string name="notification_new_title">New email</string>
@ -137,6 +141,9 @@
<!-- Appears at the bottom of list of messages; user selects to load more messages from that folder. -->
<string name="message_list_load_more_messages_action">Load more messages</string>
<!-- Appears at the bottom of list of messages of outbox;
user selects to send pending messages. -->
<string name="message_list_send_pending_messages_action">Send outgoing messages</string>
<!-- Hint text in To field -->
<string name="message_compose_to_hint">To</string>
<!-- Hint text in Cc field -->

View File

@ -1586,7 +1586,7 @@ public class MessagingController implements Runnable {
message.setFlag(Flag.X_SEND_IN_PROGRESS, true);
sender.sendMessage(message);
message.setFlag(Flag.X_SEND_IN_PROGRESS, false);
// Upload to "sent" folder if not supported server-side
if (requireCopyMessageToSentFolder) {
localFolder.copyMessages(
@ -1604,19 +1604,22 @@ public class MessagingController implements Runnable {
}
catch (Exception e) {
message.setFlag(Flag.X_SEND_FAILED, true);
synchronized (mListeners) {
for (MessagingListener l : mListeners) {
l.sendPendingMessageFailed(account, message, e);
}
}
}
}
catch (Exception e) {
/*
* We ignore this exception because a future refresh will retry this
* message.
*/
synchronized (mListeners) {
for (MessagingListener l : mListeners) {
l.sendPendingMessageFailed(account, message, e);
}
}
}
}
localFolder.expunge();
if (localFolder.getMessageCount() == 0) {
localFolder.delete(false);
}
synchronized (mListeners) {
for (MessagingListener l : mListeners) {
l.sendPendingMessagesCompleted(account);
@ -1624,11 +1627,11 @@ public class MessagingController implements Runnable {
}
}
catch (Exception e) {
// synchronized (mListeners) {
// for (MessagingListener l : mListeners) {
// // TODO general failed
// }
// }
synchronized (mListeners) {
for (MessagingListener l : mListeners) {
l.sendPendingMessagesFailed(account, e);
}
}
}
}

View File

@ -100,6 +100,12 @@ public class MessagingListener {
public void sendPendingMessagesCompleted(Account account) {
}
public void sendPendingMessagesFailed(Account account, Exception reason) {
}
public void sendPendingMessageFailed(Account account, Message message, Exception reason) {
}
public void emptyTrashCompleted(Account account) {
}

View File

@ -596,6 +596,13 @@ public class FolderMessageList extends ExpandableListActivity {
int childPosition, long id) {
FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getGroup(groupPosition);
if (folder.outbox) {
if (childPosition == folder.messages.size() && !folder.loading) {
mHandler.folderLoading(mAccount.getOutboxFolderName(), true);
mHandler.progress(true);
MessagingController.getInstance(getApplication()).sendPendingMessages(
mAccount,
null);
}
return false;
}
if (childPosition == folder.messages.size() && !folder.loading) {
@ -617,7 +624,8 @@ public class FolderMessageList extends ExpandableListActivity {
else if (childPosition >= folder.messages.size()) {
return false;
}
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getChild(groupPosition, childPosition);
MessageInfoHolder message =
(MessageInfoHolder) mAdapter.getChild(groupPosition, childPosition);
onOpenMessage(folder, message);
@ -636,6 +644,8 @@ public class FolderMessageList extends ExpandableListActivity {
mRefreshRemote,
mAdapter.mListener);
if (forceRemote) {
mHandler.folderLoading(mAccount.getOutboxFolderName(), true);
mHandler.progress(true);
MessagingController.getInstance(getApplication()).sendPendingMessages(
mAccount,
null);
@ -975,9 +985,34 @@ public class FolderMessageList extends ExpandableListActivity {
if (!account.equals(mAccount)) {
return;
}
mHandler.folderLoading(account.getOutboxFolderName(), false);
mHandler.progress(false);
onRefresh(false);
}
@Override
public void sendPendingMessagesFailed(Account account, Exception reason) {
if (!account.equals(mAccount)) {
return;
}
String outboxName = account.getOutboxFolderName();
mHandler.folderLoading(outboxName, false);
mHandler.progress(false);
mHandler.folderStatus(outboxName, reason.getMessage(), false);
onRefresh(false);
}
@Override
public void sendPendingMessageFailed(Account account, Message message,
Exception reason) {
if (!account.equals(mAccount)) {
return;
}
// TODO May we move failed message to draft folder?
//mHandler.removeMessageByUid(folder, message.getUid());
//mHandler.folderStatus(account.getOutboxFolderName(), reason.getMessage(), false);
}
@Override
public void messageUidChanged(
Account account,
@ -1023,6 +1058,7 @@ public class FolderMessageList extends ExpandableListActivity {
}
try {
folder.open(Folder.OpenMode.READ_WRITE, null);
holder.messageCount = folder.getMessageCount();
holder.unreadMessageCount = folder.getUnreadMessageCount();
folder.close(false);
}
@ -1194,10 +1230,14 @@ public class FolderMessageList extends ExpandableListActivity {
holder.folderStatus.setVisibility(View.VISIBLE);
}
if (folder.unreadMessageCount != 0) {
if (!folder.outbox && folder.unreadMessageCount != 0) {
holder.newMessageCount.setText(Integer.toString(folder.unreadMessageCount));
holder.newMessageCount.setVisibility(View.VISIBLE);
}
else if (folder.outbox && folder.messageCount > 0) {
holder.newMessageCount.setText(Integer.toString(folder.messageCount));
holder.newMessageCount.setVisibility(View.VISIBLE);
}
else {
holder.newMessageCount.setVisibility(View.GONE);
}
@ -1247,20 +1287,32 @@ public class FolderMessageList extends ExpandableListActivity {
view.setTag(holder);
}
if (folder.loading) {
holder.main.setText(getString(R.string.status_loading_more));
if (folder.outbox) {
holder.main.setText(R.string.status_sending_messages);
} else {
holder.main.setText(R.string.status_loading_more);
}
holder.progress.setVisibility(View.VISIBLE);
}
else {
if (folder.status == null) {
if (mSyncWindowUser) {
holder.main.setText(getString(
R.string.message_list_load_more_messages_action));
if (folder.outbox) {
holder.main.setText(R.string.message_list_send_pending_messages_action);
} else {
holder.main.setText(getString(R.string.refresh_action));
if (mSyncWindowUser) {
holder.main.setText(
R.string.message_list_load_more_messages_action);
} else {
holder.main.setText(R.string.refresh_action);
}
}
}
else {
holder.main.setText(getString(R.string.status_loading_more_failed));
if (folder.outbox) {
holder.main.setText(R.string.status_sending_messages_failed);
} else {
holder.main.setText(R.string.status_loading_more_failed);
}
}
holder.progress.setVisibility(View.GONE);
}
@ -1334,6 +1386,7 @@ public class FolderMessageList extends ExpandableListActivity {
public String displayName;
public ArrayList<MessageInfoHolder> messages;
public long lastChecked;
public int messageCount;
public int unreadMessageCount;
public boolean loading;
public String status;