Fixup cc/bcc behavior on rotation.
Make sure we properly show/ hide the +cc/bcc button
and change the text to +bcc when necessary
Change-Id: I57c8f14c1abf204520a45cec6bb6281c80163fc9
diff --git a/src/com/android/mail/compose/CcBccView.java b/src/com/android/mail/compose/CcBccView.java
index 63f27ad..124be79 100644
--- a/src/com/android/mail/compose/CcBccView.java
+++ b/src/com/android/mail/compose/CcBccView.java
@@ -101,4 +101,18 @@
transitionSet.playSequentially(heightAnimator, fadeAnimation);
transitionSet.start();
}
+
+ /**
+ * @return whether the CC field is visible
+ */
+ public boolean isCcVisible() {
+ return mCc.getVisibility() == View.VISIBLE;
+ }
+
+ /**
+ * @return whether the BCC field is visible
+ */
+ public boolean isBccVisible() {
+ return mBcc.getVisibility() == View.VISIBLE;
+ }
}
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index 05aad9a..97dca1f 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -108,7 +108,8 @@
// Integer extra holding one of the above compose action
private static final String EXTRA_ACTION = "action";
- private static final String EXTRA_SHOW_CC_BCC = "showCcBcc";
+ private static final String EXTRA_SHOW_CC = "showCc";
+ private static final String EXTRA_SHOW_BCC = "showBcc";
private static final String UTF8_ENCODING_NAME = "UTF-8";
@@ -302,6 +303,7 @@
showCcBcc(savedInstanceState);
} else if (action == EDIT_DRAFT) {
initFromDraftMessage(message);
+ showCcBcc(message);
// Update the action to the draft type of the previous draft
switch (message.draftType) {
case UIProvider.DraftType.REPLY:
@@ -322,6 +324,7 @@
} else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) {
if (mRefMessage != null) {
initFromRefMessage(action, mAccount.name);
+ showCcBcc(mRefMessage);
}
} else {
initFromExtras(intent);
@@ -337,6 +340,7 @@
action);
initChangeListeners();
setFocus(action);
+ updateHideOrShowCcBcc();
}
private void setFocus(int action) {
@@ -479,7 +483,8 @@
if (mRefMessage != null) {
state.putParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE, mRefMessage);
}
- state.putBoolean(EXTRA_SHOW_CC_BCC, mCcBccView.isVisible());
+ state.putBoolean(EXTRA_SHOW_CC, mCcBccView.isCcVisible());
+ state.putBoolean(EXTRA_SHOW_BCC, mCcBccView.isBccVisible());
}
private int getMode() {
@@ -609,7 +614,7 @@
public ReplyFromAccount getReplyFromAccount(Account account, Message refMessage) {
// First see if we are supposed to use the default address or
// the address it was sentTo.
- if (false) { //mCachedSettings.forceReplyFromDefault) {
+ if (mCachedSettings.forceReplyFromDefault) {
return getDefaultReplyFromAccount(account);
} else {
// If we aren't explicityly told which account to look for, look at
@@ -769,7 +774,6 @@
if (action == ComposeActivity.FORWARD || mAttachmentsChanged) {
initAttachments(mRefMessage);
}
- updateHideOrShowCcBcc();
}
private void initFromDraftMessage(Message message) {
@@ -868,21 +872,6 @@
setBody(text, true /* with signature */);
}
}
-
- updateHideOrShowCcBcc();
- }
-
- private void initFromMessageInIntent(Message message) {
- mTo.append(message.to);
- mCc.append(message.cc);
- mBcc.append(message.bcc);
- mBodyView.setText(message.bodyText);
- mSubject.setText(message.subject);
- List<Attachment> attachments = message.getAttachments();
- for (Attachment a : attachments) {
- mAttachmentsView.addAttachment(a);
- }
- mQuotedTextView.updateCheckedState(message.appendRefMessageContent);
}
@VisibleForTesting
@@ -953,8 +942,6 @@
LogUtils.e(LOG_TAG, "%s while decoding body '%s'", e.getMessage(), body);
}
}
-
- updateHideOrShowCcBcc();
}
private void initAttachments(Message refMessage) {
@@ -1029,15 +1016,12 @@
private void updateHideOrShowCcBcc() {
// Its possible there is a menu item OR a button.
- boolean ccVisible = !TextUtils.isEmpty(mCc.getText());
- boolean bccVisible = !TextUtils.isEmpty(mBcc.getText());
- if (ccVisible || bccVisible) {
- mCcBccView.show(false, ccVisible, bccVisible);
- }
+ boolean ccVisible = mCcBccView.isCcVisible();
+ boolean bccVisible = mCcBccView.isBccVisible();
if (mCcBccButton != null) {
- if (!mCc.isShown() || !mBcc.isShown()) {
+ if (!ccVisible || !bccVisible) {
mCcBccButton.setVisibility(View.VISIBLE);
- mCcBccButton.setText(getString(!mCc.isShown() ? R.string.add_cc_label
+ mCcBccButton.setText(getString(!ccVisible ? R.string.add_cc_label
: R.string.add_bcc_label));
} else {
mCcBccButton.setVisibility(View.GONE);
@@ -1046,14 +1030,26 @@
}
private void showCcBcc(Bundle state) {
- if (state != null && state.containsKey(EXTRA_SHOW_CC_BCC)) {
- boolean show = state.getBoolean(EXTRA_SHOW_CC_BCC);
- if (show) {
- mCcBccView.show(false, show, show);
+ if (state != null && state.containsKey(EXTRA_SHOW_CC)) {
+ boolean showCc = state.getBoolean(EXTRA_SHOW_CC);
+ boolean showBcc = state.getBoolean(EXTRA_SHOW_BCC);
+ if (showCc || showBcc) {
+ mCcBccView.show(false, showCc, showBcc);
}
}
}
+ private void showCcBcc(Message refMessage) {
+ if (refMessage != null) {
+ boolean showCc = !TextUtils.isEmpty(refMessage.cc);
+ boolean showBcc = !TextUtils.isEmpty(refMessage.bcc);
+ if (showCc || showBcc) {
+ mCcBccView.show(false, showCc, showBcc);
+ }
+ }
+ updateHideOrShowCcBcc();
+ }
+
/**
* Add attachment and update the compose area appropriately.
* @param data