Merge "Replace details dialog with expando subheader"

This commit is contained in:
Ben Komalo 2011-06-27 09:58:30 -07:00 committed by Android (Google) Code Review
commit ca22a51a9c
7 changed files with 199 additions and 282 deletions

View File

@ -238,7 +238,8 @@ public class Address {
StringBuffer sb = new StringBuffer(addresses[0].toString());
for (int i = 1; i < addresses.length; i++) {
sb.append(separator);
sb.append(addresses[i].toString());
// TODO: investigate why this .trim() is needed.
sb.append(addresses[i].toString().trim());
}
return sb.toString();
}

View File

@ -179,58 +179,21 @@
</LinearLayout>
<!-- Addresses, timestamp -->
<Button
android:id="@+id/show_details"
android:layout_width="wrap_content"
android:layout_height="48dip"
<FrameLayout
android:id="@+id/message_view_subheader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dip"
android:layout_marginRight="32dip"
android:layout_below="@id/header_background"
android:layout_alignRight="@id/header_background"
android:layout_marginRight="14dip"
style="@android:style/Widget.Holo.Button.Borderless"
android:padding="0dip"
android:gravity="center_vertical"
android:text="@string/message_view_show_details"
android:textSize="14dip"
android:textColor="@color/text_ternary_color"
android:textStyle="bold"
android:singleLine="true"
/>
<TextView
android:id="@+id/datetime"
android:layout_width="wrap_content"
android:layout_height="48dip"
android:layout_below="@id/header_background"
android:layout_alignRight="@id/header_background"
android:layout_toLeftOf="@id/show_details"
android:layout_marginRight="156dip"
android:gravity="center_vertical"
android:textSize="14dip"
android:textColor="@color/text_ternary_color"
android:singleLine="true"
/>
<!-- To, Cc, Bcc addresses -->
<TextView
android:id="@+id/addresses"
android:layout_width="0dip"
android:layout_height="48dip"
android:layout_below="@id/header_background"
android:layout_alignLeft="@id/badge"
android:layout_toLeftOf="@id/datetime"
android:layout_marginRight="16dip"
android:layout_marginLeft="14dip"
android:gravity="center_vertical"
android:textSize="14dip"
android:textColor="@color/text_ternary_color"
android:singleLine="true"
android:ellipsize="end"
/>
>
<include layout="@layout/message_view_subheader" />
</FrameLayout>
<View
android:id="@+id/address_divider"
android:layout_width="0dip"
android:layout_below="@id/show_details"
android:layout_below="@id/message_view_subheader"
android:layout_alignLeft="@id/badge"
android:layout_alignRight="@id/header_background"
style="@style/message_view_horizontal_divider"

View File

@ -14,95 +14,82 @@
limitations under the License.
-->
<ScrollView
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/show_details"
android:orientation="vertical"
android:stretchColumns="2"
android:shrinkColumns="2"
>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:stretchColumns="2"
android:shrinkColumns="2"
<TableRow
android:id="@+id/date_row"
>
<TableRow
android:id="@+id/subject_row"
<TextView
android:layout_column="1"
android:text="@string/message_view_date_label"
style="@style/message_details_label"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_subject_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/subject"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/from_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_from_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/from"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/date_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_date_label"
style="@style/message_details_label"
<ImageView
android:id="@+id/show_details"
android:src="@drawable/ic_menu_expander_maximized_holo_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
/>
<TextView
android:id="@+id/date"
android:layout_toLeftOf="@+id/show_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/to_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_to_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/to"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/cc_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_cc_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/cc"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/bcc_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_bcc_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/bcc"
style="@style/message_details_value"
/>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
</TableRow>
<TableRow
android:id="@+id/to_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_to_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/to"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/cc_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_cc_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/cc"
style="@style/message_details_value"
/>
</TableRow>
<TableRow
android:id="@+id/bcc_row"
>
<TextView
android:layout_column="1"
android:text="@string/message_view_bcc_label"
style="@style/message_details_label"
/>
<TextView
android:id="@+id/bcc"
style="@style/message_details_value"
/>
</TableRow>
</TableLayout>

View File

@ -127,42 +127,15 @@
</LinearLayout>
<!-- Addresses, timestamp, "show details" -->
<LinearLayout
<FrameLayout
android:id="@+id/message_view_subheader"
android:layout_width="match_parent"
android:layout_height="48dip"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip"
>
<!-- To, Cc, Bcc addresses -->
<TextView
android:id="@+id/addresses"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="24dip"
android:singleLine="true"
android:ellipsize="end"
style="@style/message_view_text"
/>
<TextView
android:id="@+id/datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:singleLine="true"
style="@style/message_view_text"
/>
<!-- Set proper background to reflect selected state -->
<ImageView
android:id="@+id/show_details"
android:src="@drawable/ic_menu_expander_minimized_holo_light"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginLeft="4dip"
android:layout_marginRight="16dip"
android:gravity="center"
android:background="?android:attr/selectableItemBackground"
/>
</LinearLayout>
<include layout="@layout/message_view_subheader" />
</FrameLayout>
<!-- divider -->
<View

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 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.
-->
<!-- The expandable list of recipient addressese and date information at
the top of a message view -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Collapsed version -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sub_header_contents_collapsed"
android:layout_width="match_parent"
android:layout_height="48dip"
android:gravity="center_vertical"
>
<!-- To, Cc, Bcc addresses -->
<TextView
android:id="@+id/addresses"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="4dip"
android:singleLine="true"
android:ellipsize="end"
style="@style/message_view_text"
/>
<TextView
android:id="@+id/datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:singleLine="true"
style="@style/message_view_text"
/>
<!-- Set proper background to reflect selected state -->
<ImageView
android:id="@+id/show_details"
android:src="@drawable/ic_menu_expander_minimized_holo_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dip"
android:gravity="center"
android:background="?android:attr/selectableItemBackground"
/>
</LinearLayout>
<!-- Expanded version -->
<include layout="@layout/message_view_details"
android:id="@+id/sub_header_contents_expanded"
android:visibility="gone" />
</merge>

View File

@ -120,7 +120,9 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
private ImageView mSenderPresenceView;
private View mMainView;
private View mLoadingProgress;
private View mShowDetailsButton;
private View mDetailsCollapsed;
private View mDetailsExpanded;
private boolean mDetailsFilled;
private TextView mMessageTab;
private TextView mAttachmentTab;
@ -145,8 +147,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
// contains the HTML content as set in WebView.
private String mHtmlTextWebView;
private boolean mResumed;
private boolean mIsMessageLoadedForTest;
private MessageObserver mMessageObserver;
@ -299,7 +299,8 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
mSenderPresenceView = (ImageView) UiUtilities.getView(view, R.id.presence);
mMainView = UiUtilities.getView(view, R.id.main_panel);
mLoadingProgress = UiUtilities.getView(view, R.id.loading_progress);
mShowDetailsButton = UiUtilities.getView(view, R.id.show_details);
mDetailsCollapsed = UiUtilities.getView(view, R.id.sub_header_contents_collapsed);
mDetailsExpanded = UiUtilities.getView(view, R.id.sub_header_contents_expanded);
mFromNameView.setOnClickListener(this);
mFromAddressView.setOnClickListener(this);
@ -316,7 +317,8 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
mAttachmentTab.setOnClickListener(this);
mShowPicturesTab.setOnClickListener(this);
mInviteTab.setOnClickListener(this);
mShowDetailsButton.setOnClickListener(this);
mDetailsCollapsed.setOnClickListener(this);
mDetailsExpanded.setOnClickListener(this);
mAttachmentsScroll = UiUtilities.getView(view, R.id.attachments_scroll);
mInviteScroll = UiUtilities.getView(view, R.id.invite_scroll);
@ -360,8 +362,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
}
super.onResume();
mResumed = true;
// We might have comes back from other full-screen activities. If so, we need to update
// the attachment tab as system settings may have been updated that affect which
// options are available to the user.
@ -373,7 +373,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, this + " onPause");
}
mResumed = false;
super.onPause();
}
@ -890,21 +889,42 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
}
}
private void onShowDetails() {
if (!isMessageOpen()) return;
String subject = mMessage.mSubject;
String date = formatDate(mMessage.mTimeStamp, true);
private void showDetails() {
if (!isMessageOpen()) {
return;
}
final String SEPARATOR = "\n";
String from = Address.toString(Address.unpack(mMessage.mFrom), SEPARATOR);
String to = Address.toString(Address.unpack(mMessage.mTo), SEPARATOR);
String cc = Address.toString(Address.unpack(mMessage.mCc), SEPARATOR);
String bcc = Address.toString(Address.unpack(mMessage.mBcc), SEPARATOR);
MessageViewMessageDetailsDialog dialog = MessageViewMessageDetailsDialog.newInstance(
getActivity(), subject, date, from, to, cc, bcc);
dialog.show(getActivity().getFragmentManager(), null);
if (!mDetailsFilled) {
String date = formatDate(mMessage.mTimeStamp, true);
final String SEPARATOR = "\n";
String to = Address.toString(Address.unpack(mMessage.mTo), SEPARATOR);
String cc = Address.toString(Address.unpack(mMessage.mCc), SEPARATOR);
String bcc = Address.toString(Address.unpack(mMessage.mBcc), SEPARATOR);
setDetailsRow(mDetailsExpanded, date, R.id.date, R.id.date_row);
setDetailsRow(mDetailsExpanded, to, R.id.to, R.id.to_row);
setDetailsRow(mDetailsExpanded, cc, R.id.cc, R.id.cc_row);
setDetailsRow(mDetailsExpanded, bcc, R.id.bcc, R.id.bcc_row);
mDetailsFilled = true;
}
mDetailsCollapsed.setVisibility(View.GONE);
mDetailsExpanded.setVisibility(View.VISIBLE);
}
private void hideDetails() {
mDetailsCollapsed.setVisibility(View.VISIBLE);
mDetailsExpanded.setVisibility(View.GONE);
}
private static void setDetailsRow(View root, String text, int textViewId, int rowViewId) {
if (TextUtils.isEmpty(text)) {
root.findViewById(rowViewId).setVisibility(View.GONE);
return;
}
((TextView) UiUtilities.getView(root, textViewId)).setText(text);
}
@Override
public void onClick(View view) {
if (!isMessageOpen()) {
@ -944,8 +964,11 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
case R.id.show_pictures:
onShowPicturesInHtml();
break;
case R.id.show_details:
onShowDetails();
case R.id.sub_header_contents_collapsed:
showDetails();
break;
case R.id.sub_header_contents_expanded:
hideDetails();
break;
}
}

View File

@ -1,97 +0,0 @@
/*
* Copyright (C) 2011 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.email.activity;
import com.android.email.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
/**
* "Message Details" dialog box.
*/
public class MessageViewMessageDetailsDialog extends DialogFragment {
private static final String BUNDLE_SUBJECT = "subject";
private static final String BUNDLE_DATE = "date";
private static final String BUNDLE_FROM = "from";
private static final String BUNDLE_TO = "to";
private static final String BUNDLE_CC = "cc";
private static final String BUNDLE_BCC = "bcc";
public static MessageViewMessageDetailsDialog newInstance(Activity parent, String subject,
String date, String from, String to, String cc, String bcc) {
MessageViewMessageDetailsDialog dialog = new MessageViewMessageDetailsDialog();
Bundle args = new Bundle();
args.putString(BUNDLE_SUBJECT, subject);
args.putString(BUNDLE_DATE, date);
args.putString(BUNDLE_FROM, from);
args.putString(BUNDLE_TO, to);
args.putString(BUNDLE_CC, cc);
args.putString(BUNDLE_BCC, bcc);
dialog.setArguments(args);
return dialog;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Activity activity = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(
activity.getResources().getString(
R.string.message_view_message_details_dialog_title));
builder.setNegativeButton(R.string.close_action, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
builder.setView(initView());
return builder.show();
}
private View initView() {
View root = getActivity().getLayoutInflater().inflate(R.layout.message_view_details, null);
Bundle args = getArguments();
setText(root, args.getString(BUNDLE_SUBJECT), R.id.subject, R.id.subject_row);
setText(root, args.getString(BUNDLE_DATE), R.id.date, R.id.date_row);
setText(root, args.getString(BUNDLE_FROM), R.id.from, R.id.from_row);
setText(root, args.getString(BUNDLE_TO), R.id.to, R.id.to_row);
setText(root, args.getString(BUNDLE_CC), R.id.cc, R.id.cc_row);
setText(root, args.getString(BUNDLE_BCC), R.id.bcc, R.id.bcc_row);
setText(root, args.getString(BUNDLE_BCC), R.id.bcc, R.id.bcc_row);
return root;
}
private static void setText(View root, String text, int textViewId, int rowViewId) {
if (TextUtils.isEmpty(text)) {
root.findViewById(rowViewId).setVisibility(View.GONE);
return;
}
((TextView) root.findViewById(textViewId)).setText(text);
}
}