Show message details inline, not in popup.

Fixes b/11576631. Code deletion CL is best CL.

Change-Id: I22b10b7078a4a8ae89fa3e7667d5dae191ad6f5f
diff --git a/src/com/android/mail/browse/MessageHeaderDetailsDialogFragment.java b/src/com/android/mail/browse/MessageHeaderDetailsDialogFragment.java
deleted file mode 100644
index 62099fc..0000000
--- a/src/com/android/mail/browse/MessageHeaderDetailsDialogFragment.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2013 Google Inc.
- * Licensed to The Android Open Source Project.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.mail.browse;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-
-import com.android.mail.R;
-import com.android.mail.providers.Account;
-import com.android.mail.providers.Address;
-import com.android.mail.utils.Utils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * {@link DialogFragment} used by secure conversation views to display
- * the expanded message details as a dialog.
- */
-public class MessageHeaderDetailsDialogFragment extends DialogFragment {
-
-    private static final String ARG_ACCOUNT = "account";
-    private static final String ARG_ADDRESS_CACHE = "addresses";
-    private static final String ARG_FROM = "from";
-    private static final String ARG_REPLY_TO = "replyto";
-    private static final String ARG_TO = "to";
-    private static final String ARG_CC = "cc";
-    private static final String ARG_BCC = "bcc";
-    private static final String ARG_RECEIVED_TIME = "received-timestamp";
-
-    // Public no-args constructor needed for fragment re-instantiation
-    public MessageHeaderDetailsDialogFragment() {}
-
-    /**
-     * Creates a new {@link MessageHeaderDetailsDialogFragment}.
-     * @param addressCache a mapping of RFC822 addresses as strings to {@link Address}.
-     * @param account {@link Account} used as the from address for any messages created
-     *                by tapping an email address.
-     * @param from from addresses for the message
-     * @param replyTo replyTo addresses for the message
-     * @param to to addresses for the message
-     * @param cc cc addresses for the message
-     * @param bcc bcc addresses for the message
-     * @return a newly created {@link MessageHeaderDetailsDialogFragment}
-     */
-    public static MessageHeaderDetailsDialogFragment newInstance(
-            Map<String, Address> addressCache, Account account, String[] from, String[] replyTo,
-            String[] to, String[] cc, String[] bcc, CharSequence receivedTimestamp) {
-        final MessageHeaderDetailsDialogFragment f = new MessageHeaderDetailsDialogFragment();
-
-        // Supply needed items as arguments
-        final Bundle args = new Bundle(7);
-        args.putParcelable(ARG_ACCOUNT, account);
-
-        final Bundle addresses = new Bundle();
-        addAddressesToBundle(addresses, addressCache, from);
-        addAddressesToBundle(addresses, addressCache, replyTo);
-        addAddressesToBundle(addresses, addressCache, to);
-        addAddressesToBundle(addresses, addressCache, cc);
-        addAddressesToBundle(addresses, addressCache, bcc);
-        args.putBundle(ARG_ADDRESS_CACHE, addresses);
-
-        args.putStringArray(ARG_FROM, from);
-        args.putStringArray(ARG_REPLY_TO, replyTo);
-        args.putStringArray(ARG_TO, to);
-        args.putStringArray(ARG_CC, cc);
-        args.putStringArray(ARG_BCC, bcc);
-        args.putCharSequence(ARG_RECEIVED_TIME, receivedTimestamp);
-        f.setArguments(args);
-
-        return f;
-    }
-
-    private static void addAddressesToBundle(
-            Bundle addresses, Map<String, Address> addressCache, String[] emails) {
-        for (final String email : emails) {
-            addresses.putParcelable(email, Utils.getAddress(addressCache, email));
-        }
-    }
-
-    @Override
-    public Dialog onCreateDialog(final Bundle onSavedInstanceState) {
-        final Context context = getActivity();
-        AlertDialog.Builder builder = new AlertDialog.Builder(context);
-        final View expandedDetails = MessageHeaderView.inflateExpandedDetails(
-                LayoutInflater.from(context));
-
-        final Bundle args = getArguments();
-
-        // turn bundle back into Map<String, Address>
-        final Bundle addresses = args.getBundle(ARG_ADDRESS_CACHE);
-        final Map<String, Address> addressCache = new HashMap<String, Address>();
-        for (String email : addresses.keySet()) {
-            addressCache.put(email, (Address) addresses.getParcelable(email));
-        }
-
-        MessageHeaderView.renderExpandedDetails(getResources(), expandedDetails, null,
-                addressCache, (Account) args.getParcelable(ARG_ACCOUNT), null,
-                args.getStringArray(ARG_FROM), args.getStringArray(ARG_REPLY_TO),
-                args.getStringArray(ARG_TO), args.getStringArray(ARG_CC),
-                args.getStringArray(ARG_BCC), args.getCharSequence(ARG_RECEIVED_TIME));
-
-        expandedDetails.findViewById(R.id.details_expander)
-                .setVisibility(View.GONE);
-        builder.setView(expandedDetails)
-                .setCancelable(true)
-                .setTitle(context.getString(R.string.message_details_title));
-        return builder.create();
-    }
-}
diff --git a/src/com/android/mail/browse/MessageHeaderView.java b/src/com/android/mail/browse/MessageHeaderView.java
index 3f41a13..c4e1341 100644
--- a/src/com/android/mail/browse/MessageHeaderView.java
+++ b/src/com/android/mail/browse/MessageHeaderView.java
@@ -16,7 +16,6 @@
 
 package com.android.mail.browse;
 
-import android.app.DialogFragment;
 import android.app.FragmentManager;
 import android.content.AsyncQueryHandler;
 import android.content.Context;
@@ -54,7 +53,6 @@
 import com.android.mail.compose.ComposeActivity;
 import com.android.mail.perf.Timer;
 import com.android.mail.photomanager.LetterTileProvider;
-import com.android.mail.preferences.AccountPreferences;
 import com.android.mail.print.PrintUtils;
 import com.android.mail.providers.Account;
 import com.android.mail.providers.Address;
@@ -99,14 +97,9 @@
 
     private static final String LOG_TAG = LogTag.getLogTag();
 
-    public static final int DEFAULT_MODE = 0;
-    public static final int POPUP_MODE = 1;
-
     // This is a debug only feature
     public static final boolean ENABLE_REPORT_RENDERING_PROBLEM = false;
 
-    private static final String DETAILS_DIALOG_TAG = "details-dialog";
-
     private MessageHeaderViewCallbacks mCallbacks;
 
     private ViewGroup mUpperHeaderView;
@@ -201,10 +194,6 @@
 
     private boolean mExpandable = true;
 
-    private int mExpandMode = DEFAULT_MODE;
-
-    private DialogFragment mDetailsPopup;
-
     private VeiledAddressMatcher mVeiledMatcher;
 
     private boolean mIsViewOnlyMode = false;
@@ -263,13 +252,6 @@
                 R.dimen.message_header_contact_photo_height);
     }
 
-    /**
-     * Expand mode is DEFAULT_MODE by default.
-     */
-    public void setExpandMode(int mode) {
-        mExpandMode = mode;
-    }
-
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
@@ -1078,22 +1060,14 @@
     }
 
     private void setMessageDetailsExpanded(boolean expand) {
-        if (mExpandMode == DEFAULT_MODE) {
-            if (expand) {
-                showExpandedDetails();
-                hideCollapsedDetails();
-            } else {
-                hideExpandedDetails();
-                showCollapsedDetails();
-            }
-        } else if (mExpandMode == POPUP_MODE) {
-            if (expand) {
-                showDetailsPopup();
-            } else {
-                hideDetailsPopup();
-                showCollapsedDetails();
-            }
+        if (expand) {
+            showExpandedDetails();
+            hideCollapsedDetails();
+        } else {
+            hideExpandedDetails();
+            showCollapsedDetails();
         }
+
         if (mMessageHeaderItem != null) {
             mMessageHeaderItem.detailsExpanded = expand;
         }
@@ -1419,24 +1393,6 @@
         }
     }
 
-    private void showDetailsPopup() {
-        final FragmentManager manager = mCallbacks.getFragmentManager();
-        mDetailsPopup = (DialogFragment) manager.findFragmentByTag(DETAILS_DIALOG_TAG);
-        if (mDetailsPopup == null) {
-            mDetailsPopup = MessageHeaderDetailsDialogFragment.newInstance(
-                    mAddressCache, getAccount(), mFrom, mReplyTo, mTo, mCc, mBcc,
-                    mMessageHeaderItem.getTimestampLong());
-            mDetailsPopup.show(manager, DETAILS_DIALOG_TAG);
-        }
-    }
-
-    private void hideDetailsPopup() {
-        if (mDetailsPopup != null) {
-            mDetailsPopup.dismiss();
-            mDetailsPopup = null;
-        }
-    }
-
     /**
      * Returns a short plaintext snippet generated from the given HTML message
      * body. Collapses whitespace, ignores '&lt;' and '&gt;' characters and
diff --git a/src/com/android/mail/ui/SecureConversationViewController.java b/src/com/android/mail/ui/SecureConversationViewController.java
index c462bbf..7f7d0f6 100644
--- a/src/com/android/mail/ui/SecureConversationViewController.java
+++ b/src/com/android/mail/ui/SecureConversationViewController.java
@@ -122,7 +122,6 @@
         mDateBuilder = new FormattedDateBuilder(fragment.getActivity());
         mMessageHeaderView.initialize(
                 mCallbacks.getConversationAccountController(), mCallbacks.getAddressCache());
-        mMessageHeaderView.setExpandMode(MessageHeaderView.POPUP_MODE);
         mMessageHeaderView.setContactInfoSource(mCallbacks.getContactInfoSource());
         mMessageHeaderView.setCallbacks(this);
         mMessageHeaderView.setExpandable(false);