From e4202e782c91075c09cd5c348517a90620622a7f Mon Sep 17 00:00:00 2001 From: Mindy Pereira Date: Fri, 18 Nov 2011 09:18:34 -0800 Subject: [PATCH] Make message items aware of the various modes. On two pane tablet in portrait mode, the message list items may not be wide enough to be considered "WIDE_MODE", however, when they are shown in the message list mode, they should ALWAYS use message list mode backgrounds. Fixes b/5641014 email portrait: missing the vertical divider between folders and messages Change-Id: Ied05386f1ab62c48b1824647c95a6f72baabc859 --- .../android/email/activity/MessageListFragment.java | 6 ++++++ src/com/android/email/activity/MessageListItem.java | 12 ++++++++---- .../email/activity/MessageListItemCoordinates.java | 4 ++++ src/com/android/email/activity/MessagesAdapter.java | 8 +++++++- .../android/email/activity/UIControllerTwoPane.java | 1 + 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index 4a3d48727..d6c304e99 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -372,6 +372,12 @@ public class MessageListFragment extends ListFragment return root; } + public void setLayout(ThreePaneLayout layout) { + if (UiUtilities.useTwoPane(mActivity)) { + mListAdapter.setLayout(layout); + } + } + private void initSearchHeader() { if (mSearchHeader == null) { ViewGroup root = (ViewGroup) getView(); diff --git a/src/com/android/email/activity/MessageListItem.java b/src/com/android/email/activity/MessageListItem.java index cb5635f85..34a029e87 100644 --- a/src/com/android/email/activity/MessageListItem.java +++ b/src/com/android/email/activity/MessageListItem.java @@ -56,6 +56,7 @@ public class MessageListItem extends View { /* package */ long mMailboxId; /* package */ long mAccountId; + private ThreePaneLayout mLayout; private MessagesAdapter mAdapter; private MessageListItemCoordinates mCoordinates; private Context mContext; @@ -272,8 +273,9 @@ public class MessageListItem extends View { private void updateBackground() { final Drawable newBackground; + boolean isMultiPane = MessageListItemCoordinates.isMultiPane(mContext); if (mRead) { - if (mMode == MODE_WIDE) { + if (isMultiPane && mLayout.isLeftPaneVisible()) { if (mWideReadSelector == null) { mWideReadSelector = getContext().getResources() .getDrawable(R.drawable.conversation_wide_read_selector); @@ -287,7 +289,7 @@ public class MessageListItem extends View { newBackground = mReadSelector; } } else { - if (mMode == MODE_WIDE) { + if (isMultiPane && mLayout.isLeftPaneVisible()) { if (mWideUnreadSelector == null) { mWideUnreadSelector = getContext().getResources().getDrawable( R.drawable.conversation_wide_unread_selector); @@ -496,13 +498,15 @@ public class MessageListItem extends View { * Called by the adapter at bindView() time * * @param adapter the adapter that creates this view + * @param layout If this is a three pane implementation, the + * ThreePaneLayout. Otherwise, null. */ - public void bindViewInit(MessagesAdapter adapter) { + public void bindViewInit(MessagesAdapter adapter, ThreePaneLayout layout) { + mLayout = layout; mAdapter = adapter; requestLayout(); } - private static final int TOUCH_SLOP = 24; private static int sScaledTouchSlop = -1; diff --git a/src/com/android/email/activity/MessageListItemCoordinates.java b/src/com/android/email/activity/MessageListItemCoordinates.java index 97ab04854..87e4d6c08 100644 --- a/src/com/android/email/activity/MessageListItemCoordinates.java +++ b/src/com/android/email/activity/MessageListItemCoordinates.java @@ -123,6 +123,10 @@ public class MessageListItemCoordinates { return mode; } + public static boolean isMultiPane(Context context) { + return UiUtilities.useTwoPane(context); + } + /** * Returns the layout id to be inflated in this mode. */ diff --git a/src/com/android/email/activity/MessagesAdapter.java b/src/com/android/email/activity/MessagesAdapter.java index 2e8b2ebc6..b9b2c2a39 100644 --- a/src/com/android/email/activity/MessagesAdapter.java +++ b/src/com/android/email/activity/MessagesAdapter.java @@ -98,6 +98,8 @@ import java.util.Set; private final Callback mCallback; + private ThreePaneLayout mLayout; + /** * The actual return type from the loader. */ @@ -134,6 +136,10 @@ import java.util.Set; mCallback = callback; } + public void setLayout(ThreePaneLayout layout) { + mLayout = layout; + } + public void onSaveInstanceState(Bundle outState) { outState.putLongArray(STATE_CHECKED_ITEMS, Utility.toPrimitiveLongArray(getSelectedSet())); } @@ -182,7 +188,7 @@ import java.util.Set; public void bindView(View view, Context context, Cursor cursor) { // Reset the view (in case it was recycled) and prepare for binding MessageListItem itemView = (MessageListItem) view; - itemView.bindViewInit(this); + itemView.bindViewInit(this, mLayout); // TODO: just move thise all to a MessageListItem.bindTo(cursor) so that the fields can // be private, and their inter-dependence when they change can be abstracted away. diff --git a/src/com/android/email/activity/UIControllerTwoPane.java b/src/com/android/email/activity/UIControllerTwoPane.java index 85a700d51..a67ba12ea 100644 --- a/src/com/android/email/activity/UIControllerTwoPane.java +++ b/src/com/android/email/activity/UIControllerTwoPane.java @@ -311,6 +311,7 @@ class UIControllerTwoPane extends UIControllerBase implements ThreePaneLayout.Ca if (isMailboxListInstalled()) { getMailboxListFragment().setHighlightedMailbox(fragment.getMailboxId()); } + getMessageListFragment().setLayout(mThreePane); } @Override