From 95993a4b8466c2a47f4eba7a65b4ba194986cff5 Mon Sep 17 00:00:00 2001 From: satok Date: Tue, 18 Aug 2009 17:42:04 +0900 Subject: [PATCH] Update Title bar to use custom titles BUG: 2050630 * remove fat title bar * show new titles by using custom title bar --- res/layout/account_folder_list.xml | 2 - res/layout/list_title.xml | 50 +++++++++++++++++ res/layout/mailbox_list.xml | 2 - res/layout/mailbox_list_item.xml | 6 +-- res/values/strings.xml | 6 +-- .../email/activity/AccountFolderList.java | 30 +++++------ .../android/email/activity/MailboxList.java | 35 +++++------- .../android/email/activity/MessageList.java | 54 +++++++++++++++---- 8 files changed, 124 insertions(+), 61 deletions(-) create mode 100644 res/layout/list_title.xml diff --git a/res/layout/account_folder_list.xml b/res/layout/account_folder_list.xml index 70defbf89..7bea3cc7e 100644 --- a/res/layout/account_folder_list.xml +++ b/res/layout/account_folder_list.xml @@ -20,8 +20,6 @@ android:layout_height="fill_parent" android:orientation="vertical" > - - + + + + + + + + + + + diff --git a/res/layout/mailbox_list.xml b/res/layout/mailbox_list.xml index d934629a5..607b6172e 100644 --- a/res/layout/mailbox_list.xml +++ b/res/layout/mailbox_list.xml @@ -20,8 +20,6 @@ android:layout_width="fill_parent" android:layout_height="fill_parent"> - - diff --git a/res/values/strings.xml b/res/values/strings.xml index 4425797f4..9c67e6ef8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -172,6 +172,9 @@ Outbox + + Mailbox + Load more messages Notify me when email arrives. - - Sync contacts from this account. Setup could not finish diff --git a/src/com/android/email/activity/AccountFolderList.java b/src/com/android/email/activity/AccountFolderList.java index 8d6a3aa05..b050a7cfe 100644 --- a/src/com/android/email/activity/AccountFolderList.java +++ b/src/com/android/email/activity/AccountFolderList.java @@ -59,6 +59,7 @@ import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.CursorAdapter; import android.widget.ListView; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; @@ -81,8 +82,7 @@ public class AccountFolderList extends ListActivity private EmailContent.Account mSelectedContextAccount; private ListView mListView; - private View mRefreshButton; - private View mProgress; + private ProgressBar mProgressIcon; AccountsAdapter mListAdapter; @@ -157,9 +157,13 @@ public class AccountFolderList extends ListActivity public void onCreate(Bundle icicle) { super.onCreate(icicle); - requestWindowFeature(Window.FEATURE_NO_TITLE); - + requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.account_folder_list); + getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, + R.layout.list_title); + + mProgressIcon = (ProgressBar) findViewById(R.id.title_progress_icon); + mListView = getListView(); mListView.setItemsCanFocus(false); mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET); @@ -171,19 +175,11 @@ public class AccountFolderList extends ListActivity mSelectedContextAccount = (Account) icicle.getParcelable(ICICLE_SELECTED_ACCOUNT); } - // Set up fat title bar elements - findViewById(R.id.chip).setVisibility(View.GONE); - findViewById(R.id.button_compose).setOnClickListener(this); - mRefreshButton = findViewById(R.id.button_refresh); - mRefreshButton.setOnClickListener(this); - ((TextView) findViewById(R.id.account_name)).setText(R.string.accounts_title); - findViewById(R.id.account_status).setVisibility(View.GONE); - mProgress = findViewById(R.id.progress); - mProgress.setVisibility(View.GONE); - // Called only for filling cache of specialMailboxDisplayName getSpecialMailboxDisplayName(this, 0); + ((TextView) findViewById(R.id.title_left_text)).setText(R.string.app_name); + mLoadAccountsTask = (LoadAccountsTask) new LoadAccountsTask().execute(); } @@ -586,11 +582,9 @@ public class AccountFolderList extends ListActivity case MSG_PROGRESS: boolean showProgress = (msg.arg1 != 0); if (showProgress) { - mRefreshButton.setVisibility(View.GONE); - mProgress.setVisibility(View.VISIBLE); + mProgressIcon.setVisibility(View.VISIBLE); } else { - mRefreshButton.setVisibility(View.VISIBLE); - mProgress.setVisibility(View.GONE); + mProgressIcon.setVisibility(View.GONE); } break; default: diff --git a/src/com/android/email/activity/MailboxList.java b/src/com/android/email/activity/MailboxList.java index 86839233b..f710dc87e 100644 --- a/src/com/android/email/activity/MailboxList.java +++ b/src/com/android/email/activity/MailboxList.java @@ -49,6 +49,7 @@ import android.widget.AdapterView; import android.widget.CursorAdapter; import android.widget.ImageView; import android.widget.ListView; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; @@ -62,10 +63,7 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On + " AND " + MailboxColumns.FLAG_VISIBLE + "=1"; // UI support private ListView mListView; - private TextView mAccountNameView; - private TextView mAccountStatusView; - private View mRefreshButton; - private View mProgress; + private ProgressBar mProgressIcon; private MailboxListAdapter mListAdapter; private MailboxListHandler mHandler = new MailboxListHandler(); @@ -115,16 +113,15 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On public void onCreate(Bundle icicle) { super.onCreate(icicle); - requestWindowFeature(Window.FEATURE_NO_TITLE); - + requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.mailbox_list); + getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, + R.layout.list_title); + + // Custom TItle + mProgressIcon = (ProgressBar) findViewById(R.id.title_progress_icon); + mListView = getListView(); - findViewById(R.id.button_compose).setOnClickListener(this); - mRefreshButton = findViewById(R.id.button_refresh); - mRefreshButton.setOnClickListener(this); - mAccountNameView = (TextView) findViewById(R.id.account_name); - mAccountStatusView = (TextView) findViewById(R.id.account_status); - mProgress = findViewById(R.id.progress); mListView.setOnItemClickListener(this); mListView.setItemsCanFocus(false); @@ -141,11 +138,7 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On finish(); } - // setup fat fitle - color chip, name, status, refresh/progress - int chipResId = mColorChipResIds[(int)mAccountId % mColorChipResIds.length]; - findViewById(R.id.chip).setBackgroundResource(chipResId); - mAccountStatusView.setVisibility(View.GONE); - mProgress.setVisibility(View.GONE); + ((TextView)findViewById(R.id.title_left_text)).setText(R.string.mailbox_list_title); // Go to the database for the account name new AsyncTask() { @@ -171,7 +164,7 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On // something is wrong with this account finish(); } - mAccountNameView.setText(result); + ((TextView)findViewById(R.id.title_right_text)).setText(result); } }.execute(); @@ -340,11 +333,9 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On case MSG_PROGRESS: boolean showProgress = (msg.arg1 != 0); if (showProgress) { - mRefreshButton.setVisibility(View.GONE); - mProgress.setVisibility(View.VISIBLE); + mProgressIcon.setVisibility(View.VISIBLE); } else { - mRefreshButton.setVisibility(View.VISIBLE); - mProgress.setVisibility(View.GONE); + mProgressIcon.setVisibility(View.GONE); } break; default: diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index 70ea693c8..759c00b33 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -43,6 +43,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -57,6 +58,7 @@ import android.widget.AdapterView; import android.widget.CursorAdapter; import android.widget.ImageView; import android.widget.ListView; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; @@ -101,6 +103,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On private MessageListHandler mHandler = new MessageListHandler(); private Controller mController = Controller.getInstance(getApplication()); private ControllerResults mControllerCallback = new ControllerResults(); + private TextView mLeftTitle; + private TextView mRightTitle; + private ProgressBar mProgressIcon; private static final int[] mColorChipResIds = new int[] { R.drawable.appointment_indicator_leftside_1, @@ -145,9 +150,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On }; private static final int MAILBOX_DISPLAY_NAME_COLUMN_ID = 0; - private static final int MAILBOX_ACCOUNT_KEY_ID = 1; + private static final int MAILBOX_ACCOUNT_KEY_COLUMN_ID = 1; private static final String[] MAILBOX_NAME_PROJECTION = new String[] { - MailboxColumns.DISPLAY_NAME, MailboxColumns.ACCOUNT_KEY }; + MailboxColumns.DISPLAY_NAME, MailboxColumns.ACCOUNT_KEY}; private static final int ACCOUNT_DISPLAY_NAME_COLUMN_ID = 0; private static final String[] ACCOUNT_NAME_PROJECTION = new String[] { @@ -223,15 +228,21 @@ public class MessageList extends ListActivity implements OnItemClickListener, On public void onCreate(Bundle icicle) { super.onCreate(icicle); - requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - + requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.message_list); + getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, + R.layout.list_title); + mListView = getListView(); mMultiSelectPanel = findViewById(R.id.footer_organize); mReadUnreadButton = findViewById(R.id.btn_read_unread); mFavoriteButton = findViewById(R.id.btn_multi_favorite); mDeleteButton = findViewById(R.id.btn_multi_delete); + mLeftTitle = (TextView) findViewById(R.id.title_left_text); + mRightTitle = (TextView) findViewById(R.id.title_right_text); + mProgressIcon = (ProgressBar) findViewById(R.id.title_progress_icon); + mReadUnreadButton.setOnClickListener(this); mFavoriteButton.setOnClickListener(this); mDeleteButton.setOnClickListener(this); @@ -515,7 +526,7 @@ public class MessageList extends ListActivity implements OnItemClickListener, On * @param selectedSet The current list of selected items */ private void onMultiToggleRead(Set selectedSet) { - int numChanged = toggleMultiple(selectedSet, new MultiToggleHelper() { + toggleMultiple(selectedSet, new MultiToggleHelper() { public boolean getField(long messageId, Cursor c) { return c.getInt(MessageListAdapter.COLUMN_READ) == 0; @@ -538,7 +549,7 @@ public class MessageList extends ListActivity implements OnItemClickListener, On * @param selectedSet The current list of selected items */ private void onMultiToggleFavorite(Set selectedSet) { - int numChanged = toggleMultiple(selectedSet, new MultiToggleHelper() { + toggleMultiple(selectedSet, new MultiToggleHelper() { public boolean getField(long messageId, Cursor c) { return c.getInt(MessageListAdapter.COLUMN_FAVORITE) != 0; @@ -951,6 +962,20 @@ public class MessageList extends ListActivity implements OnItemClickListener, On @Override protected String[] doInBackground(Void... params) { + // Check special Mailboxes + if (mMailboxKey == MessageList.QUERY_ALL_INBOXES) { + return new String[] {null, + getString(R.string.account_folder_list_summary_inbox)}; + } else if (mMailboxKey == MessageList.QUERY_ALL_FAVORITES) { + return new String[] {null, + getString(R.string.account_folder_list_summary_favorite)}; + } else if (mMailboxKey == MessageList.QUERY_ALL_DRAFTS) { + return new String[] {null, + getString(R.string.account_folder_list_summary_drafts)}; + } else if (mMailboxKey == MessageList.QUERY_ALL_OUTBOX) { + return new String[] {null, + getString(R.string.account_folder_list_summary_outbox)}; + } String accountName = null; String mailboxName = null; String accountKey = null; @@ -960,7 +985,7 @@ public class MessageList extends ListActivity implements OnItemClickListener, On try { if (c.moveToFirst()) { mailboxName = c.getString(MAILBOX_DISPLAY_NAME_COLUMN_ID); - accountKey = c.getString(MAILBOX_ACCOUNT_KEY_ID); + accountKey = c.getString(MAILBOX_ACCOUNT_KEY_COLUMN_ID); } } finally { c.close(); @@ -982,9 +1007,12 @@ public class MessageList extends ListActivity implements OnItemClickListener, On @Override protected void onPostExecute(String[] names) { - if (names[0] != null && names[1] != null) { - MessageList.this.setTitle(getString(R.string.message_list_title, names[0], - names[1])); + Log.d("MessageList", "ACCOUNT:" + names[0] + "MAILBOX" + names[1]); + if (names[0] != null) { + mRightTitle.setText(names[0]); + } + if (names[1] != null) { + mLeftTitle.setText(names[1]); } } } @@ -1001,7 +1029,11 @@ public class MessageList extends ListActivity implements OnItemClickListener, On switch (msg.what) { case MSG_PROGRESS: boolean visible = (msg.arg1 != 0); - setProgressBarIndeterminateVisibility(visible); + if (visible) { + mProgressIcon.setVisibility(View.VISIBLE); + } else { + mProgressIcon.setVisibility(View.GONE); + } if (mListFooterProgress != null) { mListFooterProgress.setVisibility(visible ? View.VISIBLE : View.GONE); }