Don't pass ACCOUNT_ID_COMBINED_VIEW to message compose.
If you do so, MessageCompose won't be able to restore an account, so it'll use null account... Bug 3324472 Change-Id: Ic0e615b31e21246e41f6f2c709a8422bef230040
This commit is contained in:
parent
1dde2253cb
commit
f29ce4d37b
|
@ -268,13 +268,14 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAccount(Account account) {
|
private void setAccount(Account account) {
|
||||||
mAccount = account;
|
if (account == null) {
|
||||||
if (account != null) {
|
throw new IllegalArgumentException();
|
||||||
mFromView.setText(account.mEmailAddress);
|
|
||||||
mAddressAdapterTo.setAccount(account);
|
|
||||||
mAddressAdapterCc.setAccount(account);
|
|
||||||
mAddressAdapterBcc.setAccount(account);
|
|
||||||
}
|
}
|
||||||
|
mAccount = account;
|
||||||
|
mFromView.setText(account.mEmailAddress);
|
||||||
|
mAddressAdapterTo.setAccount(account);
|
||||||
|
mAddressAdapterCc.setAccount(account);
|
||||||
|
mAddressAdapterBcc.setAccount(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -467,7 +467,7 @@ public class MessageListXL extends Activity implements
|
||||||
@Override
|
@Override
|
||||||
public boolean onUrlInMessageClicked(String url) {
|
public boolean onUrlInMessageClicked(String url) {
|
||||||
return ActivityHelper.openUrlInMessage(MessageListXL.this, url,
|
return ActivityHelper.openUrlInMessage(MessageListXL.this, url,
|
||||||
mFragmentManager.getAccountId());
|
mFragmentManager.getActualAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -632,7 +632,7 @@ public class MessageListXL extends Activity implements
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (accountsCursor.moveToNext()) {
|
while (accountsCursor.moveToNext()) {
|
||||||
final long accountId = AccountSelectorAdapter.getAccountId(accountsCursor);
|
final long accountId = AccountSelectorAdapter.getAccountId(accountsCursor);
|
||||||
if (accountId == mFragmentManager.getAccountId()) {
|
if (accountId == mFragmentManager.getUIAccountId()) {
|
||||||
defaultSelection = i;
|
defaultSelection = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -703,8 +703,7 @@ public class MessageListXL extends Activity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldShowRefreshButton() {
|
private boolean shouldShowRefreshButton() {
|
||||||
final long accountId = mFragmentManager.getAccountId();
|
return -1 != mFragmentManager.getActualAccountId();
|
||||||
return (accountId != -1) && (accountId != Account.ACCOUNT_ID_COMBINED_VIEW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -729,19 +728,19 @@ public class MessageListXL extends Activity implements
|
||||||
if (!mFragmentManager.isAccountSelected()) {
|
if (!mFragmentManager.isAccountSelected()) {
|
||||||
return false; // this shouldn't really happen
|
return false; // this shouldn't really happen
|
||||||
}
|
}
|
||||||
MessageCompose.actionCompose(this, mFragmentManager.getAccountId());
|
MessageCompose.actionCompose(this, mFragmentManager.getActualAccountId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onAccountSettings() {
|
private boolean onAccountSettings() {
|
||||||
AccountSettingsXL.actionSettings(this, mFragmentManager.getAccountId());
|
AccountSettingsXL.actionSettings(this, mFragmentManager.getActualAccountId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onRefresh() {
|
private void onRefresh() {
|
||||||
// Cancel previously running instance if any.
|
// Cancel previously running instance if any.
|
||||||
Utility.cancelTaskInterrupt(mRefreshTask);
|
Utility.cancelTaskInterrupt(mRefreshTask);
|
||||||
mRefreshTask = new RefreshTask(this, mFragmentManager.getAccountId(),
|
mRefreshTask = new RefreshTask(this, mFragmentManager.getActualAccountId(),
|
||||||
mFragmentManager.getMailboxId());
|
mFragmentManager.getMailboxId());
|
||||||
mRefreshTask.execute();
|
mRefreshTask.execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,10 +167,25 @@ class MessageListXLFragmentManager {
|
||||||
mMessageViewFragment.setCallback(messageViewFragmentCallback);
|
mMessageViewFragment.setCallback(messageViewFragmentCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAccountId() {
|
/**
|
||||||
|
* @return the currently selected account ID, *or* {@link Account#ACCOUNT_ID_COMBINED_VIEW}.
|
||||||
|
*
|
||||||
|
* @see #getActualAccountId()
|
||||||
|
*/
|
||||||
|
public long getUIAccountId() {
|
||||||
return mAccountId;
|
return mAccountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the currently selected account ID. If the current view is the combined view,
|
||||||
|
* it'll return -1.
|
||||||
|
*
|
||||||
|
* @see #getUIAccountId()
|
||||||
|
*/
|
||||||
|
public long getActualAccountId() {
|
||||||
|
return mAccountId == Account.ACCOUNT_ID_COMBINED_VIEW ? -1 : mAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
public long getMailboxId() {
|
public long getMailboxId() {
|
||||||
return mMailboxId;
|
return mMailboxId;
|
||||||
}
|
}
|
||||||
|
@ -179,8 +194,11 @@ class MessageListXLFragmentManager {
|
||||||
return mMessageId;
|
return mMessageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if an account is selected, or the current view is the combined view.
|
||||||
|
*/
|
||||||
public boolean isAccountSelected() {
|
public boolean isAccountSelected() {
|
||||||
return getAccountId() != -1;
|
return getUIAccountId() != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMailboxSelected() {
|
public boolean isMailboxSelected() {
|
||||||
|
|
Loading…
Reference in New Issue