Merge "Fix & cleanup on EML viewer (MessageFileView)"
This commit is contained in:
commit
46e60b51e2
|
@ -70,50 +70,56 @@
|
|||
android:src="@drawable/presence_inactive"
|
||||
android:background="@drawable/quickcontact_presence_bg"
|
||||
/>
|
||||
<!-- reply, reply-all, forward, Star -->
|
||||
<ImageView
|
||||
android:id="@+id/favorite"
|
||||
<!--
|
||||
reply, reply-all, forward, Star
|
||||
They can all be gone; don't refer to them from other views. Instead refer to this outer
|
||||
layout.
|
||||
-->
|
||||
<LinearLayout
|
||||
android:id="@+id/forward_reply_buttons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/top_divider"
|
||||
android:layout_height="24dip"
|
||||
android:layout_alignRight="@id/subject"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/btn_star_big_buttonless_off"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/forward"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="24dip"
|
||||
android:layout_below="@id/top_divider"
|
||||
android:layout_toLeftOf="@id/favorite"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/forward"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/reply_all"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="24dip"
|
||||
android:layout_below="@id/top_divider"
|
||||
android:layout_toLeftOf="@id/forward"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/reply_all"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/reply"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="24dip"
|
||||
android:layout_below="@id/top_divider"
|
||||
android:layout_toLeftOf="@id/reply_all"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/reply"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/reply"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/reply"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/reply_all"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/reply_all"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/forward"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/forward"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/favorite"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="16dip"
|
||||
android:layout_marginLeft="16dip"
|
||||
android:src="@drawable/btn_star_big_buttonless_off"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Sender display name -->
|
||||
<TextView
|
||||
|
@ -122,7 +128,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/top_divider"
|
||||
android:layout_toRightOf="@id/presence"
|
||||
android:layout_toLeftOf="@id/reply"
|
||||
android:layout_toLeftOf="@id/forward_reply_buttons"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:singleLine="true"
|
||||
|
@ -135,8 +141,8 @@
|
|||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/presence"
|
||||
android:layout_below="@id/from_name"
|
||||
android:layout_toLeftOf="@id/reply"
|
||||
android:layout_below="@id/presence"
|
||||
android:layout_toLeftOf="@id/forward_reply_buttons"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_marginBottom="8dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
|
@ -190,6 +196,7 @@
|
|||
android:layout_below="@id/to_label"
|
||||
android:layout_alignLeft="@id/to_label"
|
||||
android:layout_alignRight="@id/subject"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -219,6 +226,7 @@
|
|||
android:layout_below="@id/cc_container"
|
||||
android:layout_alignLeft="@id/to_label"
|
||||
android:layout_alignRight="@id/subject"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -251,119 +259,114 @@
|
|||
style="@style/horizontalDivider"
|
||||
/>
|
||||
|
||||
<!-- Tabs -->
|
||||
<!--
|
||||
The rest: tab + body + command buttons. Use LinearLayout to easily hide part of them.
|
||||
-->
|
||||
<LinearLayout
|
||||
android:id="@+id/message_tabs_section"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dip"
|
||||
android:layout_below="@id/below_header_divider"
|
||||
android:layout_alignLeft="@id/below_header_divider"
|
||||
android:layout_alignRight="@id/below_header_divider"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="6dip"
|
||||
android:paddingRight="6dip"
|
||||
android:paddingTop="6dip"
|
||||
android:paddingBottom="6dip"
|
||||
>
|
||||
<Button
|
||||
android:id="@+id/show_message"
|
||||
android:text="@string/message_view_show_message_action"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<!--
|
||||
Even though the "invite" section is only for MessageViewFragment, it's managed
|
||||
by MessageViewFragmentBase for simplicity.
|
||||
-->
|
||||
<Button
|
||||
android:id="@+id/show_invite"
|
||||
android:text="@string/message_view_show_invite_action"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/show_attachments"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<View
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/show_pictures"
|
||||
android:text="@string/message_view_show_pictures_action"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Buttons at the bottom.
|
||||
Only MessageViewFragment uses these. MessageFileViewFragment doesn't. -->
|
||||
<include
|
||||
layout="@layout/message_command_button_view"
|
||||
android:id="@+id/message_command_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<!-- content area - only one of them is visible at a time -->
|
||||
<!-- Message body -->
|
||||
<WebView
|
||||
android:id="@+id/message_content"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
android:layout_below="@id/message_tabs_section"
|
||||
android:layout_alignLeft="@id/message_tabs_section"
|
||||
android:layout_alignRight="@id/message_tabs_section"
|
||||
android:layout_above="@id/message_command_buttons"
|
||||
android:background="#ffffffff"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<!-- Invite: Even though this section is only for MessageViewFragment,
|
||||
Its visibility is controlled by MessageViewFragmentBase for simplicity.
|
||||
MessageFileViewFragment shouldn't touch this. -->
|
||||
<ScrollView
|
||||
android:id="@+id/invite_scroll"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
android:layout_below="@id/message_tabs_section"
|
||||
android:layout_alignLeft="@id/message_tabs_section"
|
||||
android:layout_alignRight="@id/message_tabs_section"
|
||||
android:layout_above="@id/message_command_buttons"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<include layout="@layout/message_view_invitation" />
|
||||
</ScrollView>
|
||||
|
||||
<!-- Attachments -->
|
||||
<ScrollView
|
||||
android:id="@+id/attachments_scroll"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
android:layout_below="@id/message_tabs_section"
|
||||
android:layout_alignLeft="@id/message_tabs_section"
|
||||
android:layout_alignRight="@id/message_tabs_section"
|
||||
android:layout_above="@id/message_command_buttons"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<!-- Tabs -->
|
||||
<LinearLayout
|
||||
android:id="@+id/attachments"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/message_tabs_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip"
|
||||
android:background="#ffffff"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="6dip"
|
||||
android:paddingRight="6dip"
|
||||
android:paddingTop="6dip"
|
||||
android:paddingBottom="6dip"
|
||||
>
|
||||
<Button
|
||||
android:id="@+id/show_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/message_view_show_message_action"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/show_invite"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/message_view_show_invite_action"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/show_attachments"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
<!-- filler -->
|
||||
<View
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/show_pictures"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/message_view_show_pictures_action"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- content area - only one of them is visible at a time -->
|
||||
<!-- Message body -->
|
||||
<WebView
|
||||
android:id="@+id/message_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:background="#ffffffff"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</ScrollView>
|
||||
|
||||
<!-- Invite: Even though this section is only for MessageViewFragment,
|
||||
Its visibility is controlled by MessageViewFragmentBase for simplicity.
|
||||
MessageFileViewFragment shouldn't touch this. -->
|
||||
<ScrollView
|
||||
android:id="@+id/invite_scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<include layout="@layout/message_view_invitation" />
|
||||
</ScrollView>
|
||||
|
||||
<!-- Attachments -->
|
||||
<ScrollView
|
||||
android:id="@+id/attachments_scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<LinearLayout
|
||||
android:id="@+id/attachments"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip"
|
||||
android:background="#ffffff"
|
||||
/>
|
||||
</ScrollView>
|
||||
|
||||
<!-- Buttons at the bottom.
|
||||
Only MessageViewFragment uses these. MessageFileViewFragment doesn't. -->
|
||||
<include
|
||||
layout="@layout/message_command_button_view"
|
||||
android:id="@+id/message_command_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -14,17 +14,16 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white">
|
||||
android:background="@android:color/white"
|
||||
>
|
||||
<fragment
|
||||
android:id="@+id/message_file_view_fragment"
|
||||
class="com.android.email.activity.MessageFileViewFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
@ -53,7 +53,8 @@ public class MessageFileView extends MessageViewBase {
|
|||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
mFragment = (MessageFileViewFragment) findFragmentById(R.id.message_file_view_fragment);
|
||||
mFragment = (MessageFileViewFragment) getFragmentManager().findFragmentById(
|
||||
R.id.message_file_view_fragment);
|
||||
mFragment.setCallback(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
@ -65,14 +66,14 @@ public class MessageFileView extends MessageViewBase {
|
|||
}
|
||||
|
||||
// TODO set title here: "Viewing XXX.eml".
|
||||
|
||||
// Load message.
|
||||
getFragment().openMessage(mFileEmailUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// Note: We don't have to close the activity even if an account has been deleted,
|
||||
// unlike MessageView.
|
||||
getFragment().openMessage(mFileEmailUri);
|
||||
}
|
||||
|
||||
/** @return always -1, as no accounts are associated with EML files. */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.android.email.activity;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.R;
|
||||
import com.android.email.Utility;
|
||||
import com.android.email.provider.EmailContent.Message;
|
||||
|
@ -23,9 +24,7 @@ import com.android.email.provider.EmailContent.Message;
|
|||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.util.Log;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
|
@ -55,20 +54,6 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
|
|||
sFragmentCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the layout.
|
||||
*
|
||||
* This class uses the same layout as {@link MessageViewFragment}, but hides the star.
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
view.findViewById(R.id.favorite).setVisibility(View.GONE);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -82,6 +67,9 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
|
|||
|
||||
/** Called by activities with a URI to an EML file. */
|
||||
public void openMessage(Uri fileEmailUri) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Email.LOG_TAG, "MessageFileViewFragment openMessage");
|
||||
}
|
||||
if (fileEmailUri == null) {
|
||||
throw new InvalidParameterException();
|
||||
}
|
||||
|
@ -112,6 +100,9 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
|
|||
@Override
|
||||
protected Message openMessageSync(Activity activity) {
|
||||
synchronized (mLock) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Email.LOG_TAG, "MessageFileViewFragment openMessageSync");
|
||||
}
|
||||
Uri messageUri = mFileEmailUri;
|
||||
if (messageUri == null) {
|
||||
return null; // Called after clearContent().
|
||||
|
|
|
@ -167,6 +167,9 @@ public class MessageViewFragment extends MessageViewFragmentBase {
|
|||
mMeetingMaybe = (TextView) view.findViewById(R.id.maybe);
|
||||
mMeetingNo = (TextView) view.findViewById(R.id.decline);
|
||||
|
||||
// Star is only visible on this fragment (as opposed to MessageFileViewFragment.)
|
||||
view.findViewById(R.id.favorite).setVisibility(View.VISIBLE);
|
||||
|
||||
mFavoriteIcon.setOnClickListener(this);
|
||||
mReplyButton.setOnClickListener(this);
|
||||
mReplyAllButton.setOnClickListener(this);
|
||||
|
|
|
@ -1189,14 +1189,18 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
|||
protected void updateHeaderView(Message message) {
|
||||
mSubjectView.setText(message.mSubject);
|
||||
final Address from = Address.unpackFirst(message.mFrom);
|
||||
|
||||
// Set sender address/display name
|
||||
// Note we set " " for empty field, so TextView's won't get squashed.
|
||||
// Otherwise their height will be 0, which breaks the layout.
|
||||
if (from != null) {
|
||||
final String fromFriendly = from.toFriendly();
|
||||
final String fromAddress = from.getAddress();
|
||||
mFromNameView.setText(fromFriendly);
|
||||
mFromAddressView.setText(fromFriendly.equals(fromAddress) ? "" : fromAddress);
|
||||
mFromAddressView.setText(fromFriendly.equals(fromAddress) ? " " : fromAddress);
|
||||
} else {
|
||||
mFromNameView.setText("");
|
||||
mFromAddressView.setText("");
|
||||
mFromNameView.setText(" ");
|
||||
mFromAddressView.setText(" ");
|
||||
}
|
||||
Date date = new Date(message.mTimeStamp);
|
||||
// STOPSHIP Use the same format as MessageListItem uses
|
||||
|
|
Loading…
Reference in New Issue