Remove opener IDs from message view fragment.

There are needed for the back navigation when a message
is opened from a deep link, but now that we always have a list context
they're not necessary.

Change-Id: Iba2d0b2f31f4539f6e872970b514574347e248c5
This commit is contained in:
Makoto Onuki 2011-06-29 14:41:49 -07:00
parent 87fce70d0f
commit 918860b8e0
3 changed files with 9 additions and 63 deletions

View File

@ -47,8 +47,6 @@ import android.widget.ImageView;
public class MessageViewFragment extends MessageViewFragmentBase
implements CheckBox.OnCheckedChangeListener, MoveMessageToDialog.Callback {
/** Argument name(s) */
private static final String ARG_OPENER_ACCOUNT_ID = "accountId";
private static final String ARG_OPENER_MAILBOX_ID = "mailboxId";
private static final String ARG_MESSAGE_ID = "messageId";
private ImageView mFavoriteIcon;
@ -132,32 +130,14 @@ public class MessageViewFragment extends MessageViewFragmentBase
*
* This fragment should be created only with this method. (Arguments should always be set.)
*
* @param openerAccountId account ID that's used in the UI that opened this fragment.
* The primary use is for the back navigation to determine which mailbox to show.
*
* Note this is not necessarily the same ID as the actual account ID for the message.
* If a message is opened on the combined view, the caller probably want to pass
* {@link Account#ACCOUNT_ID_COMBINED_VIEW} so that back will navigate to the
* combined view.
*
* @param openerMailboxId mailbox ID that's used in the UI that opened this fragment.
* The primary use is for the back navigation to determine which mailbox to show.
*
* Note this is not necessarily the same ID as the actual mailbox ID for the message.
* If a message is opened on the combined view, the caller probably want to pass
* a combined mailbox ID so that back will navigate to it.
*
* @param messageId ID of the message to open
*/
public static MessageViewFragment newInstance(long openerAccountId, long openerMailboxId,
long messageId) {
public static MessageViewFragment newInstance(long messageId) {
if (messageId == Message.NO_MESSAGE) {
throw new IllegalArgumentException();
}
final MessageViewFragment instance = new MessageViewFragment();
final Bundle args = new Bundle();
args.putLong(ARG_OPENER_ACCOUNT_ID, openerAccountId);
args.putLong(ARG_OPENER_MAILBOX_ID, openerMailboxId);
args.putLong(ARG_MESSAGE_ID, messageId);
instance.setArguments(args);
return instance;
@ -170,14 +150,10 @@ public class MessageViewFragment extends MessageViewFragmentBase
* constructs, this <em>must</em> be considered immutable.
*/
private Long mImmutableMessageId;
private Long mImmutableOpenerAccountId;
private Long mImmutableOpenerMailboxId;
private void initializeArgCache() {
if (mImmutableMessageId != null) return;
mImmutableMessageId = getArguments().getLong(ARG_MESSAGE_ID);
mImmutableOpenerAccountId = getArguments().getLong(ARG_OPENER_ACCOUNT_ID);
mImmutableOpenerMailboxId = getArguments().getLong(ARG_OPENER_MAILBOX_ID);
}
/**
@ -188,22 +164,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
return mImmutableMessageId;
}
/**
* @return the account ID passed to {@link #newInstance}. Safe to call even before onCreate.
*/
public long getOpenerAccountId() {
initializeArgCache();
return mImmutableOpenerAccountId;
}
/**
* @return the mailbox ID passed to {@link #newInstance}. Safe to call even before onCreate.
*/
public long getOpenerMailboxId() {
initializeArgCache();
return mImmutableOpenerMailboxId;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@ -45,8 +45,6 @@ import java.util.Set;
* so that we can easily switch between synchronous and asynchronous transactions.
*
* Major TODOs
* - TODO Remove MessageViewFragment.opener account/mailbox ID, and use the list context instead.
*
* - TODO Implement callbacks
*/
class UIControllerOnePane extends UIControllerBase {
@ -294,26 +292,18 @@ class UIControllerOnePane extends UIControllerBase {
@Override
public long getUIAccountId() {
// Get it from the visible fragment.
if (mListContext != null) {
return mListContext.mAccountId;
}
if (isMailboxListInstalled()) {
return getMailboxListFragment().getAccountId();
}
if (isMessageListInstalled()) {
return getMessageListFragment().getAccountId();
}
if (isMessageViewInstalled()) {
return getMessageViewFragment().getOpenerAccountId();
}
return Account.NO_ACCOUNT;
}
private long getMailboxId() {
// Get it from the visible fragment.
if (isMessageListInstalled()) {
return getMessageListFragment().getMailboxId();
}
if (isMessageViewInstalled()) {
return getMessageViewFragment().getOpenerMailboxId();
if (mListContext != null) {
return mListContext.getMailboxId();
}
return Mailbox.NO_MAILBOX;
}
@ -352,8 +342,7 @@ class UIControllerOnePane extends UIControllerBase {
if (DEBUG_FRAGMENTS) {
Log.d(Logging.LOG_TAG, this + " Back: Message view -> Message List");
}
openMailbox(getMessageViewFragment().getOpenerAccountId(),
getMessageViewFragment().getOpenerMailboxId());
openMailbox(mListContext.mAccountId, mListContext.getMailboxId());
return true;
}
return false;
@ -401,9 +390,7 @@ class UIControllerOnePane extends UIControllerBase {
}
private void openMessage(long messageId) {
long accountId = mListContext.mAccountId;
long mailboxId = mListContext.getMailboxId();
showFragment(MessageViewFragment.newInstance(accountId, mailboxId, messageId));
showFragment(MessageViewFragment.newInstance(messageId));
}
/**

View File

@ -463,8 +463,7 @@ class UIControllerTwoPane extends UIControllerBase implements
removeMessageViewFragment(ft);
ft.add(mThreePane.getRightPaneId(), MessageViewFragment.newInstance(
getUIAccountId(), getMessageListMailboxId(), messageId));
ft.add(mThreePane.getRightPaneId(), MessageViewFragment.newInstance(messageId));
}
/**