From 67be84728a05f969ae1306fc1fed21fb1a2a8526 Mon Sep 17 00:00:00 2001 From: satok Date: Wed, 26 Aug 2009 02:58:02 +0900 Subject: [PATCH] Update UI of accounts folder list and smart folders BUG: 1904417 * Changed the order of menu options * Made context menu for smart folders * Added context menu for Accounts --- res/menu/account_folder_list_context.xml | 16 ++++--- res/menu/account_folder_list_option.xml | 12 ++--- ...count_folder_list_smart_folder_context.xml | 22 ++++++++++ .../email/activity/AccountFolderList.java | 44 ++++++++++++++----- 4 files changed, 69 insertions(+), 25 deletions(-) create mode 100644 res/menu/account_folder_list_smart_folder_context.xml diff --git a/res/menu/account_folder_list_context.xml b/res/menu/account_folder_list_context.xml index 9ec024acc..ad91750ef 100644 --- a/res/menu/account_folder_list_context.xml +++ b/res/menu/account_folder_list_context.xml @@ -1,12 +1,12 @@ - + + + - - - diff --git a/res/menu/account_folder_list_option.xml b/res/menu/account_folder_list_option.xml index 2fcc13451..934713c60 100644 --- a/res/menu/account_folder_list_option.xml +++ b/res/menu/account_folder_list_option.xml @@ -4,9 +4,9 @@ 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. @@ -20,15 +20,15 @@ android:title="@string/refresh_action" android:icon="@*android:drawable/ic_menu_refresh" /> - + + + + + + diff --git a/src/com/android/email/activity/AccountFolderList.java b/src/com/android/email/activity/AccountFolderList.java index d82d12e71..8eab3c98c 100644 --- a/src/com/android/email/activity/AccountFolderList.java +++ b/src/com/android/email/activity/AccountFolderList.java @@ -226,7 +226,7 @@ public class AccountFolderList extends ListActivity public void onClick(View v) { switch (v.getId()) { case R.id.button_compose: - onCompose(); + onCompose(-1); break; case R.id.button_refresh: onRefresh(-1); @@ -379,10 +379,12 @@ public class AccountFolderList extends ListActivity } } - private void onCompose() { - long defaultAccountId = Account.getDefaultAccountId(this); - if (defaultAccountId != -1) { - MessageCompose.actionCompose(this, defaultAccountId); + private void onCompose(long accountId) { + if (accountId == -1) { + accountId = Account.getDefaultAccountId(this); + } + if (accountId != -1) { + MessageCompose.actionCompose(this, accountId); } else { onAddNewAccount(); } @@ -450,20 +452,35 @@ public class AccountFolderList extends ListActivity (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (mListAdapter.isMailbox(menuInfo.position)) { - // TODO is there any context menu for smart mailboxes? + Cursor c = (Cursor) mListView.getItemAtPosition(menuInfo.position); + long id = c.getLong(MAILBOX_COLUMN_ID); + switch (item.getItemId()) { + case R.id.open_folder: + MessageList.actionHandleMailbox(this, id); + break; + case R.id.check_mail: + onRefresh(-1); + break; + } return false; } else if (mListAdapter.isAccount(menuInfo.position)) { Cursor c = (Cursor) mListView.getItemAtPosition(menuInfo.position); long accountId = c.getLong(Account.CONTENT_ID_COLUMN); switch (item.getItemId()) { - case R.id.delete_account: - onDeleteAccount(accountId); + case R.id.open: + MailboxList.actionHandleAccount(this, accountId); + break; + case R.id.compose: + onCompose(accountId); + break; + case R.id.refresh_account: + onRefresh(accountId); break; case R.id.edit_account: onEditAccount(accountId); break; - case R.id.refresh_account: - onRefresh(accountId); + case R.id.delete_account: + onDeleteAccount(accountId); break; } return true; @@ -481,7 +498,7 @@ public class AccountFolderList extends ListActivity onRefresh(-1); break; case R.id.compose: - onCompose(); + onCompose(-1); break; default: return super.onOptionsItemSelected(item); @@ -505,7 +522,10 @@ public class AccountFolderList extends ListActivity super.onCreateContextMenu(menu, v, info); AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) info; if (mListAdapter.isMailbox(menuInfo.position)) { - // TODO is there any context menu for smart mailboxes? + Cursor c = (Cursor) mListView.getItemAtPosition(menuInfo.position); + String displayName = c.getString(Account.CONTENT_DISPLAY_NAME_COLUMN); + menu.setHeaderTitle(displayName); + getMenuInflater().inflate(R.menu.account_folder_list_smart_folder_context, menu); } else if (mListAdapter.isAccount(menuInfo.position)) { Cursor c = (Cursor) mListView.getItemAtPosition(menuInfo.position); String accountName = c.getString(Account.CONTENT_DISPLAY_NAME_COLUMN);