fix expanded message details appearing above the message header
Updated to handle inflation in any order, as can happen when you
recycle previously collapsed headers.
Change-Id: I7d58c26513b7634f9e3400b0b0ef63f87be2310d
diff --git a/res/layout/conversation_message_details_header.xml b/res/layout/conversation_message_details_header.xml
index 4a7f5b4..0500e4b 100644
--- a/res/layout/conversation_message_details_header.xml
+++ b/res/layout/conversation_message_details_header.xml
@@ -15,32 +15,25 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
- <LinearLayout
- android:id="@+id/details_collapsed_content"
- android:layout_width="match_parent"
- android:layout_height="@dimen/message_details_header_collapsed_height"
- android:background="?android:attr/selectableItemBackground"
- android:paddingLeft="@dimen/message_details_header_padding_left"
- android:paddingRight="@dimen/message_details_header_padding_right"
- android:gravity="center_vertical">
- <TextView
- android:id="@+id/recipients_summary"
- android:layout_weight="1"
- android:layout_marginRight="16dip"
- android:singleLine="true"
- android:bufferType="spannable"
- style="@style/MessageHeaderSmallStyle" />
- <TextView
- android:id="@+id/date_summary"
- android:lines="1"
- style="@style/MessageHeaderDateTextStyle" />
- <ImageView
- style="@style/MessageHeaderExpanderMinimizedStyle" />
- </LinearLayout>
- <View
- android:id="@+id/details_bottom_border"
- android:layout_width="match_parent"
- android:layout_height="@dimen/message_details_header_bottom_border_height"
- android:background="@color/conv_subject_border" />
-</merge>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/details_collapsed_content"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/message_details_header_collapsed_height"
+ android:background="?android:attr/selectableItemBackground"
+ android:paddingLeft="@dimen/message_details_header_padding_left"
+ android:paddingRight="@dimen/message_details_header_padding_right"
+ android:gravity="center_vertical">
+ <TextView
+ android:id="@+id/recipients_summary"
+ android:layout_weight="1"
+ android:layout_marginRight="16dip"
+ android:singleLine="true"
+ android:bufferType="spannable"
+ style="@style/MessageHeaderSmallStyle" />
+ <TextView
+ android:id="@+id/date_summary"
+ android:lines="1"
+ style="@style/MessageHeaderDateTextStyle" />
+ <ImageView
+ style="@style/MessageHeaderExpanderMinimizedStyle" />
+</LinearLayout>
diff --git a/res/layout/conversation_message_header.xml b/res/layout/conversation_message_header.xml
index dcb370b..d14df48 100644
--- a/res/layout/conversation_message_header.xml
+++ b/res/layout/conversation_message_header.xml
@@ -27,4 +27,11 @@
<include layout="@layout/conversation_message_upper_header"
android:id="@+id/upper_header" />
+ <View
+ android:id="@+id/details_bottom_border"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/message_details_header_bottom_border_height"
+ android:visibility="gone"
+ android:background="@color/conv_subject_border" />
+
</com.android.mail.browse.MessageHeaderView>
diff --git a/src/com/android/mail/browse/MessageHeaderView.java b/src/com/android/mail/browse/MessageHeaderView.java
index 8187942..d9c3259 100644
--- a/src/com/android/mail/browse/MessageHeaderView.java
+++ b/src/com/android/mail/browse/MessageHeaderView.java
@@ -83,6 +83,7 @@
private MessageHeaderViewCallbacks mCallbacks;
+ private ViewGroup mUpperHeaderView;
private TextView mSenderNameView;
private TextView mSenderEmailView;
private QuickContactBadge mPhotoView;
@@ -185,6 +186,7 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ mUpperHeaderView = (ViewGroup) findViewById(R.id.upper_header);
mSenderNameView = (TextView) findViewById(R.id.sender_name);
mSenderEmailView = (TextView) findViewById(R.id.sender_email);
mPhotoView = (QuickContactBadge) findViewById(R.id.photo);
@@ -196,6 +198,8 @@
mTitleContainerCollapsedMarginRight = ((MarginLayoutParams) mTitleContainerView
.getLayoutParams()).rightMargin;
+ mBottomBorderView = findViewById(R.id.details_bottom_border);
+
setExpanded(true);
registerMessageClickTargets(R.id.reply, R.id.reply_all, R.id.forward, R.id.star,
@@ -939,20 +943,9 @@
*/
private void showCollapsedDetails() {
if (mCollapsedDetailsView == null) {
- // Collapsed details is a merge layout that also contains the bottom
- // border. The
- // assumption is that collapsed is inflated before expanded. If we
- // ever change this
- // so either may be inflated first, the bottom border should be
- // moved out into a
- // separate layout and inflated alongside either collapsed or
- // expanded, whichever is
- // first.
- mInflater.inflate(R.layout.conversation_message_details_header, this);
-
- mBottomBorderView = findViewById(R.id.details_bottom_border);
- mCollapsedDetailsView = (ViewGroup) findViewById(R.id.details_collapsed_content);
-
+ mCollapsedDetailsView = (ViewGroup) mInflater.inflate(
+ R.layout.conversation_message_details_header, this, false);
+ addView(mCollapsedDetailsView, indexOfChild(mUpperHeaderView) + 1);
mCollapsedDetailsView.setOnClickListener(this);
}
if (!mCollapsedDetailsValid) {
@@ -976,14 +969,7 @@
if (mExpandedDetailsView == null) {
View v = mInflater.inflate(R.layout.conversation_message_details_header_expanded,
this, false);
-
- // Insert expanded details into the parent linear layout immediately
- // after the
- // previously inflated collapsed details view, and above any other
- // optional views
- // like 'show pictures' or attachments.
- // we assume collapsed has been inflated by now
- addView(v, indexOfChild(mCollapsedDetailsView) + 1);
+ addView(v, indexOfChild(mUpperHeaderView) + 1);
v.setOnClickListener(this);
mExpandedDetailsView = (ViewGroup) v;