Clean up menus in MessageList

* Final list of options while normal mailbox is shown
* New list of options while smart folder is shown
* Correct lists of context options for drafts, outbox, trash, and
    everywhere else (full list)
* Enable reply, reply all, and forward

TODO: needs a better icon for menu->folders

Resolves bug 1904421 items 4a, 4b, 5a
Resolves bug 2078092
This commit is contained in:
Andrew Stadler 2009-08-25 14:11:38 -07:00
parent 67be84728a
commit 98c10db510
8 changed files with 134 additions and 15 deletions

View File

@ -14,7 +14,13 @@
limitations under the License.
-->
<!-- This context menu is shown for message lists except in trash, outbox, or drafts -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/open" android:title="@string/open_action" />
<item android:id="@+id/delete" android:title="@string/delete_action" />
<item android:id="@+id/forward" android:title="@string/forward_action" />
<item android:id="@+id/reply_all" android:title="@string/reply_all_action" />
<item android:id="@+id/reply" android:title="@string/reply_action" />
<item android:id="@+id/mark_as_read" android:title="@string/mark_as_read_action" />
</menu>

View File

@ -14,10 +14,9 @@
limitations under the License.
-->
<!-- For received messages -->
<!-- This context menu is shown for drafts message lists -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/forward" android:title="@string/forward_action" />
<item android:id="@+id/reply_all" android:title="@string/reply_all_action" />
<item android:id="@+id/reply" android:title="@string/reply_action" />
<item android:id="@+id/mark_as_read" android:title="@string/mark_as_read_action" />
<item android:id="@+id/open" android:title="@string/open_action" />
<item android:id="@+id/delete" android:title="@string/discard_action" />
</menu>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This context menu is shown for outbox message lists -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/open" android:title="@string/open_action" />
<item android:id="@+id/delete" android:title="@string/discard_action" />
</menu>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This context menu is shown for trash message lists -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/open" android:title="@string/open_action" />
<item android:id="@+id/delete" android:title="@string/delete_action" />
</menu>

View File

@ -14,6 +14,8 @@
limitations under the License.
-->
<!-- This menu is shown when MessageList is viewing a regular mailbox. -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/refresh"
android:alphabeticShortcut="r"
@ -25,6 +27,10 @@
android:title="@string/compose_action"
android:icon="@*android:drawable/ic_menu_compose"
/>
<item android:id="@+id/folders"
android:title="@string/folders_action"
android:icon="@drawable/ic_list_folder"
/>
<item android:id="@+id/accounts"
android:title="@string/accounts_action"
android:icon="@*android:drawable/ic_menu_account_list"

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This menu is shown when MessageList is viewing a smart-folder mailbox. -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/refresh"
android:alphabeticShortcut="r"
android:title="@string/refresh_action"
android:icon="@*android:drawable/ic_menu_refresh"
/>
<item android:id="@+id/compose"
android:alphabeticShortcut="c"
android:title="@string/compose_action"
android:icon="@*android:drawable/ic_menu_compose"
/>
<item android:id="@+id/accounts"
android:title="@string/accounts_action"
android:icon="@*android:drawable/ic_menu_account_list"
/>
</menu>

View File

@ -73,6 +73,8 @@
<!-- Menu item -->
<string name="remove_account_action">Remove account</string>
<!-- Menu item -->
<string name="folders_action">Folders</string>
<!-- Menu item -->
<string name="accounts_action">Accounts</string>
<!-- Menu item -->
<string name="mark_as_read_action">Mark as read</string>

View File

@ -349,7 +349,11 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
if (mMailboxId < 0) {
getMenuInflater().inflate(R.menu.message_list_option_smart_folder, menu);
} else {
getMenuInflater().inflate(R.menu.message_list_option, menu);
}
return true;
}
@ -359,6 +363,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
case R.id.refresh:
onRefresh();
return true;
case R.id.folders:
onFolders();
return true;
case R.id.accounts:
onAccounts();
return true;
@ -389,21 +396,21 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
menu.setHeaderTitle(messageName);
// TODO: There is no context menu for the outbox
// TODO: There is probably a special context menu for the trash
// TODO: Should not be reading from DB in UI thread
EmailContent.Mailbox mailbox = EmailContent.Mailbox.restoreMailboxWithId(this,
itemView.mMailboxId);
Mailbox mailbox = Mailbox.restoreMailboxWithId(this, itemView.mMailboxId);
switch (mailbox.mType) {
case EmailContent.Mailbox.TYPE_DRAFTS:
getMenuInflater().inflate(R.menu.message_list_context, menu);
getMenuInflater().inflate(R.menu.message_list_context_drafts, menu);
break;
case EmailContent.Mailbox.TYPE_OUTBOX:
getMenuInflater().inflate(R.menu.message_list_context_outbox, menu);
break;
case EmailContent.Mailbox.TYPE_TRASH:
getMenuInflater().inflate(R.menu.message_list_context_trash, menu);
break;
default:
getMenuInflater().inflate(R.menu.message_list_context, menu);
getMenuInflater().inflate(R.menu.message_list_context_extra, menu);
// The default menu contains "mark as read". If the message is read, change
// the menu text to "mark as unread."
if (itemView.mRead) {
@ -427,13 +434,13 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
onDelete(info.id, itemView.mAccountId);
break;
case R.id.reply:
//onReply(holder);
onReply(itemView.mMessageId);
break;
case R.id.reply_all:
//onReplyAll(holder);
onReplyAll(itemView.mMessageId);
break;
case R.id.forward:
//onForward(holder);
onForward(itemView.mMessageId);
break;
case R.id.mark_as_read:
onSetMessageRead(info.id, !itemView.mRead);
@ -451,6 +458,15 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
}
}
private void onFolders() {
if (mMailboxId >= 0) {
// TODO smaller projection
Mailbox mailbox = Mailbox.restoreMailboxWithId(this, mMailboxId);
MailboxList.actionHandleAccount(this, mailbox.mAccountKey);
finish();
}
}
private void onAccounts() {
AccountFolderList.actionShowAccounts(this);
finish();
@ -486,6 +502,18 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
}
}
private void onReply(long messageId) {
MessageCompose.actionReply(this, messageId, false);
}
private void onReplyAll(long messageId) {
MessageCompose.actionReply(this, messageId, true);
}
private void onForward(long messageId) {
MessageCompose.actionForward(this, messageId);
}
private void onLoadMoreMessages() {
if (mMailboxId >= 0) {
mController.loadMoreMessages(mMailboxId, mControllerCallback);