diff --git a/res/layout/message_list_xl.xml b/res/layout/message_list_xl.xml
index ae2bf76b9..9813456da 100644
--- a/res/layout/message_list_xl.xml
+++ b/res/layout/message_list_xl.xml
@@ -23,12 +23,20 @@
+
+ android:layout_weight="2"
+ />
diff --git a/src/com/android/email/activity/MessageListXL.java b/src/com/android/email/activity/MessageListXL.java
index 50f094c13..6e6d2a8a8 100644
--- a/src/com/android/email/activity/MessageListXL.java
+++ b/src/com/android/email/activity/MessageListXL.java
@@ -112,6 +112,7 @@ public class MessageListXL extends Activity implements
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.message_list_xl);
+ mFragmentManager.onActivityViewReady();
final boolean isRestoring = (savedInstanceState != null);
diff --git a/src/com/android/email/activity/MessageListXLFragmentManager.java b/src/com/android/email/activity/MessageListXLFragmentManager.java
index d53aacbba..c8b872a0a 100644
--- a/src/com/android/email/activity/MessageListXLFragmentManager.java
+++ b/src/com/android/email/activity/MessageListXLFragmentManager.java
@@ -26,23 +26,17 @@ import android.app.FragmentTransaction;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
import java.security.InvalidParameterException;
import java.util.ArrayList;
-/*
- TODO: When opening a mailbox I see this:
-D Email : com.android.email.activity.MailboxListFragment openMailboxes
-D Email : com.android.email.activity.MailboxListFragment onCreate *1 <- Why second instance???
-D Email : com.android.email.activity.MailboxListFragment onActivityCreated
-D Email : com.android.email.activity.MailboxListFragment onStart
-D Email : com.android.email.activity.MailboxListFragment onResume
- */
-
/**
* A class manages what are showing on {@link MessageListXL} (i.e. account id, mailbox id, and
* message id), and show/hide fragments accordingly.
*
+ * TODO Highlight selected message on message list
+ *
* TODO: Test it. It's testable if we implement MockFragmentTransaction, which may be too early
* to do so at this point. (API may not be stable enough yet.)
*/
@@ -72,6 +66,10 @@ class MessageListXLFragmentManager {
/** Current message id. (-1 = not selected) */
private long mMessageId = -1;
+ private View mLeftPane;
+ private View mMiddlePane;
+ private View mRightPane;
+
private MailboxListFragment mMailboxListFragment;
private MessageListFragment mMessageListFragment;
private MessageViewFragment mMessageViewFragment;
@@ -105,6 +103,8 @@ class MessageListXLFragmentManager {
* Called when the current mailbox has changed.
*/
public void onMailboxChanged(long accountId, long newMailboxId);
+
+ public View findViewById(int id);
}
private final TargetActivity mTargetActivity;
@@ -116,6 +116,18 @@ class MessageListXLFragmentManager {
mFragmentManager = mTargetActivity.getFragmentManager();
}
+ /**
+ * Must be called just after the activity sets up the content view.
+ *
+ * (Due to the complexity regarding class/activity initialization order, we can't do this in
+ * the constructor.)
+ */
+ public void onActivityViewReady() {
+ mLeftPane = mTargetActivity.findViewById(R.id.left_pane);
+ mMiddlePane = mTargetActivity.findViewById(R.id.middle_pane);
+ mRightPane = mTargetActivity.findViewById(R.id.right_pane);
+ }
+
/** Set callback for fragment. */
public void setMailboxListFragmentCallback(
MailboxListFragment.Callback mailboxListFragmentCallback) {
@@ -324,6 +336,7 @@ class MessageListXLFragmentManager {
} else {
selectMailbox(mailboxId, byExplicitUserAction);
}
+ hideMessageView();
}
private void updateMailboxListFragment(MailboxListFragment fragment) {
@@ -339,6 +352,9 @@ class MessageListXLFragmentManager {
if (mMailboxId != -1) {
mMailboxListFragment.setSelectedMailbox(mMailboxId);
}
+ if (!isMessageSelected()) {
+ hideMessageView();
+ }
}
/**
@@ -346,6 +362,7 @@ class MessageListXLFragmentManager {
*/
public void goBackToMailbox() {
if (isMessageSelected()) {
+ hideMessageView();
selectMailbox(getMailboxId(), false);
}
}
@@ -367,7 +384,8 @@ class MessageListXLFragmentManager {
if (mailboxId == -1) {
throw new InvalidParameterException();
}
- if ((mMailboxId == mailboxId) && !isMessageSelected()) {
+
+ if (mMailboxId == mailboxId) {
return;
}
@@ -381,12 +399,15 @@ class MessageListXLFragmentManager {
if (byExplicitUserAction) {
f.doAutoRefresh();
}
- mFragmentManager.openTransaction().replace(R.id.right_pane, f).commit();
-
+ FragmentTransaction ft = mFragmentManager.openTransaction()
+ .replace(R.id.middle_pane, f);
if (mMessageViewFragment != null) {
// Message view will disappear.
+ ft.remove(mMessageViewFragment);
mMessageViewFragment = null;
}
+ ft.commit();
+
} else {
if (byExplicitUserAction) {
mMessageListFragment.doAutoRefresh();
@@ -411,6 +432,9 @@ class MessageListXLFragmentManager {
mMessageListFragment.openMailbox(mMailboxId);
restoreMesasgeListState();
mTargetActivity.onMailboxChanged(mAccountId, mMailboxId);
+ if (!isMessageSelected()) {
+ hideMessageView();
+ }
}
/**
@@ -445,7 +469,6 @@ class MessageListXLFragmentManager {
mFragmentManager.openTransaction().replace(R.id.right_pane, f)
// .addToBackStack(null)
.commit();
- mMessageListFragment = null;
} else {
updateMessageViewFragment(mMessageViewFragment);
}
@@ -461,6 +484,22 @@ class MessageListXLFragmentManager {
mMessageViewFragment = fragment;
fragment.setCallback(mMessageViewFragmentCallback);
fragment.openMessage(mMessageId);
+ hideMessageBoxList();
+ }
+
+ private void hideMessageBoxList() {
+ mLeftPane.setVisibility(View.GONE);
+ mRightPane.setVisibility(View.VISIBLE);
+ }
+
+ private void hideMessageView() {
+ mMessageId = -1;
+ mRightPane.setVisibility(View.GONE);
+ mLeftPane.setVisibility(View.VISIBLE);
+ if (mMessageViewFragment != null) {
+ mFragmentManager.openTransaction().remove(mMessageViewFragment).commit();
+ mMessageViewFragment = null;
+ }
}
private void startInboxLookup() {
diff --git a/src/com/android/email/activity/MessageViewFragmentBase.java b/src/com/android/email/activity/MessageViewFragmentBase.java
index 89c05b793..69adbb0b5 100644
--- a/src/com/android/email/activity/MessageViewFragmentBase.java
+++ b/src/com/android/email/activity/MessageViewFragmentBase.java
@@ -74,9 +74,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
// TODO Restore "Show pictures" state and scroll position on rotation.
-// TODO New UI allows MessageListFragment to toggle star while MessageViewFragment is shown, which
-// means this fragment needs to observe DB changes and refresh the UI.
-// (But what about "mark as unread"?)
+// TODO Interaction with MessageListFragment
+// Messages can now be moved, deleted, starred, and makred as unread at anytime, without this
+// fragment knowing it. Update (or close or whatever) the fragment as necessary.
/**
* Base class for {@link MessageViewFragment} and {@link MessageFileViewFragment}.