Fixup cc/bcc buttons / menus.
Just combined this all into 1 activity.
If there is a menu, change the text.
If there is a button, change the text there instead.
Change-Id: I4a9f54a54cf2cb236f46c3a39e04b5a0d072271e
diff --git a/src/com/android/email/compose/ComposeActivity.java b/src/com/android/email/compose/ComposeActivity.java
index 2568435..38a449d 100644
--- a/src/com/android/email/compose/ComposeActivity.java
+++ b/src/com/android/email/compose/ComposeActivity.java
@@ -456,7 +456,18 @@
}
private void updateHideOrShowCcBcc() {
- // TODO
+ // Its possible there is a menu item OR a button.
+ mCc.setVisibility(TextUtils.isEmpty(mCc.getText()) ? View.GONE : View.VISIBLE);
+ mBcc.setVisibility(TextUtils.isEmpty(mCc.getText()) ? View.GONE : View.VISIBLE);
+ if (mCcBccButton != null) {
+ if (!mCc.isShown() || !mBcc.isShown()) {
+ mCcBccButton.setVisibility(View.VISIBLE);
+ mCcBccButton.setText(getString(!mCc.isShown() ? R.string.add_cc_label
+ : R.string.add_bcc_label));
+ } else {
+ mCcBccButton.setVisibility(View.GONE);
+ }
+ }
}
public void removeAllAttachments() {
@@ -691,6 +702,24 @@
}
@Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ MenuItem ccBcc = menu.findItem(R.id.add_cc_bcc);
+ if (ccBcc != null) {
+ // Its possible there is a menu item OR a button.
+ boolean ccFieldVisible = mCc.isShown();
+ boolean bccFieldVisible = mBcc.isShown();
+ if (!ccFieldVisible || !bccFieldVisible) {
+ ccBcc.setVisible(true);
+ ccBcc.setTitle(getString(!ccFieldVisible ? R.string.add_cc_label
+ : R.string.add_bcc_label));
+ } else {
+ ccBcc.setVisible(false);
+ }
+ }
+ return true;
+ }
+
+ @Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
boolean handled = false;
@@ -703,15 +732,21 @@
attachment.originExtras = "";
mAttachmentsView.addAttachment(attachment);
break;
- case R.id.add_cc:
- case R.id.add_bcc:
- mCcBccView.show();
+ case R.id.add_cc_bcc:
+ showCcBccViews();
handled = true;
break;
}
return !handled ? super.onOptionsItemSelected(item) : handled;
}
+ private void showCcBccViews() {
+ mCcBccView.show();
+ if (mCcBccButton != null) {
+ mCcBccButton.setVisibility(View.GONE);
+ }
+ }
+
@Override
public boolean onNavigationItemSelected(int position, long itemId) {
if (position == ComposeActivity.REPLY) {