summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Taylor <tomtaylor@google.com>2011-06-29 15:56:57 -0700
committerTom Taylor <tomtaylor@google.com>2011-06-29 15:56:57 -0700
commit3fb271abe0c478d0ea8432830589774182079c86 (patch)
tree62a093fb8887f145a5563e76394d6bfd7e5ef819
parentdca923722b6eb0bb3cd8ca1d4d7b478c2fa4352b (diff)
downloadMms-3fb271abe0c478d0ea8432830589774182079c86.tar.gz
New UI look for Messaging
Changes include left and right avatars for sender/recipient in message items, an icon (instead of text) for the send button. Change-Id: I4a112ee656a38476a5238d680b59bf6c52dfa2ca
-rw-r--r--res/drawable-hdpi/ic_send_holo_light.pngbin0 -> 1213 bytes
-rw-r--r--res/drawable-mdpi/ic_send_holo_light.pngbin0 -> 894 bytes
-rw-r--r--res/layout/compose_message_activity.xml15
-rw-r--r--res/layout/conversation_list_actionbar.xml1
-rw-r--r--res/layout/conversation_list_item.xml19
-rw-r--r--res/layout/message_list_item.xml48
-rw-r--r--res/values/colors.xml2
-rw-r--r--res/values/dimens.xml9
-rw-r--r--res/values/strings.xml10
-rw-r--r--src/com/android/mms/ui/ComposeMessageActivity.java22
-rw-r--r--src/com/android/mms/ui/ConversationListItem.java26
-rw-r--r--src/com/android/mms/ui/MessageItem.java23
-rw-r--r--src/com/android/mms/ui/MessageListItem.java157
13 files changed, 170 insertions, 162 deletions
diff --git a/res/drawable-hdpi/ic_send_holo_light.png b/res/drawable-hdpi/ic_send_holo_light.png
new file mode 100644
index 00000000..60c4ac38
--- /dev/null
+++ b/res/drawable-hdpi/ic_send_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_send_holo_light.png b/res/drawable-mdpi/ic_send_holo_light.png
new file mode 100644
index 00000000..50ad566b
--- /dev/null
+++ b/res/drawable-mdpi/ic_send_holo_light.png
Binary files differ
diff --git a/res/layout/compose_message_activity.xml b/res/layout/compose_message_activity.xml
index 90bfebe8..b12d1894 100644
--- a/res/layout/compose_message_activity.xml
+++ b/res/layout/compose_message_activity.xml
@@ -171,16 +171,19 @@
android:layout_width="wrap_content"
android:layout_height="match_parent" >
- <Button
+ <EditText
android:id="@+id/send_button"
- android:layout_marginLeft="5dip"
+ style="?android:attr/borderlessButtonStyle"
+ android:drawableTop="@drawable/ic_send_holo_light"
+ android:drawablePadding="0dip"
android:layout_width="wrap_content"
+ android:textSize="11sp"
android:layout_height="0dip"
android:layout_weight="1.0"
- style="?android:attr/buttonStyle"
- android:nextFocusLeft="@+id/embedded_text_editor"
- android:text="@string/send"
- />
+ android:layout_marginTop="@dimen/send_button_top_margin_no_mms"
+ android:layout_marginLeft="5dip"
+ android:editable="false"
+ android:nextFocusLeft="@+id/embedded_text_editor" />
<TextView
android:id="@+id/text_counter"
diff --git a/res/layout/conversation_list_actionbar.xml b/res/layout/conversation_list_actionbar.xml
index 1908d9e1..01695daf 100644
--- a/res/layout/conversation_list_actionbar.xml
+++ b/res/layout/conversation_list_actionbar.xml
@@ -31,6 +31,7 @@
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18pt"
+ android:paddingBottom="8dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
diff --git a/res/layout/conversation_list_item.xml b/res/layout/conversation_list_item.xml
index 34bc4f38..9011c306 100644
--- a/res/layout/conversation_list_item.xml
+++ b/res/layout/conversation_list_item.xml
@@ -29,18 +29,7 @@
android:visibility="gone"
android:layout_marginLeft="7dip"
android:layout_centerVertical="true"
- style="?android:attr/quickContactBadgeStyleWindowSmall" />
-
- <ImageView
- android:id="@+id/presence"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="5dip"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:paddingBottom="20dip"
- />
+ style="?android:attr/quickContactBadgeStyleWindowLarge" />
<TextView android:id="@+id/from"
android:layout_width="wrap_content"
@@ -49,10 +38,9 @@
android:singleLine="true"
android:layout_marginTop="6dip"
android:layout_marginRight="5dip"
- android:layout_marginLeft="7dip"
+ android:layout_marginLeft="10dip"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/avatar"
- android:layout_toLeftOf="@id/presence"
android:layout_alignWithParentIfMissing="true"
android:ellipsize="marquee" />
@@ -60,6 +48,7 @@
android:layout_marginTop="2dip"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
+ android:layout_marginRight="10dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
@@ -91,7 +80,7 @@
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:layout_marginBottom="10dip"
- android:layout_marginLeft="7dip"
+ android:layout_marginLeft="10dip"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/avatar"
android:layout_alignWithParentIfMissing="true"
diff --git a/res/layout/message_list_item.xml b/res/layout/message_list_item.xml
index 490df205..0b1cad0b 100644
--- a/res/layout/message_list_item.xml
+++ b/res/layout/message_list_item.xml
@@ -42,35 +42,58 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
- <TextView android:id="@+id/text_view"
- android:autoLink="all"
- android:paddingTop="6dip"
- android:paddingBottom="3dip"
+ <ImageView
+ android:id="@+id/bar"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_height="1dip"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:linksClickable="false"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="#ff000000"
- android:textSize="18sp" />
+ android:background="@color/text_hairline" />
<android.widget.QuickContactBadge
android:layout_marginLeft="0dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
+ android:layout_alignParentLeft="true"
+ android:layout_width="64dip"
android:id="@+id/avatar"
style="?android:attr/quickContactBadgeStyleWindowSmall" />
+ <TextView android:id="@+id/text_view"
+ android:autoLink="all"
+ android:paddingTop="6dip"
+ android:paddingBottom="3dip"
+ android:paddingRight="10dip"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_toRightOf="@id/avatar"
+ android:linksClickable="false"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="#ff000000"
+ android:textSize="18sp" />
+
<View
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_below="@id/avatar" />
- <LinearLayout android:id="@+id/status_icons"
+ <TextView android:id="@+id/date_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignBottom="@id/text_view"
- android:layout_alignParentRight="true"
+ android:layout_toLeftOf="@+id/status_icons"
+ android:layout_below="@id/text_view"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingRight="10dip"
+ android:paddingTop="1dip"
+ android:textColor="#ffc1c1c1" />
+
+ <LinearLayout android:id="@id/status_icons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/text_view"
android:layout_marginBottom="8dip"
android:orientation="horizontal" >
@@ -99,7 +122,6 @@
</RelativeLayout>
</LinearLayout>
-
<ViewStub android:id="@+id/mms_downloading_view_stub"
android:layout="@layout/mms_downloading_view"
android:layout_gravity="center_vertical"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e549ce7c..9766f554 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -30,6 +30,8 @@
<drawable name="text_color_red">#ffff0000</drawable>
<drawable name="text_color_black">#ff000000</drawable>
<drawable name="text_color_offwhite">#55ffffff</drawable>
+ <drawable name="text_color_blue">#ff78b2ea</drawable>
+ <color name="text_hairline">#ffc1c1c1</color>
<!-- Chat "sent time" text background -->
<color name="timestamp_color">#bf000000</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 00000000..af5c07ff
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2011 Google Inc.
+All Rights Reserved. -->
+<resources>
+ <dimen name="send_button_top_margin_no_mms">7dip</dimen>
+ <dimen name="send_button_top_margin_with_mms">0dip</dimen>
+
+ <dimen name="message_item_avatar_on_right_text_indent">50dip</dimen>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 02aa1f3c..a5e75f22 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -774,7 +774,7 @@
<string name="me">Me</string>
<!-- Brief small label shown to right of message when it is being sent. -->
- <string name="sending_message">Sending\u2026</string>
+ <string name="sending_message">SENDING\u2026</string>
<!-- Title of progress dialog for picker -->
<string name="pick_too_many_recipients">Too many recipients</string>
@@ -782,6 +782,14 @@
<!-- Message of progress dialog for picker -->
<string name="adding_recipients">Adding recipients\u2026</string>
+ <!-- In conversation list items, this is the separator between a contact's name
+ and the draft stamp [CHAR LIMIT=5] -->
+ <string name="draft_separator">,\u2002</string>
+
+ <!-- In conversation list items, this comes after the receipient's name and contains
+ the number of messages in the thread [CHAR LIMIT=5] -->
+ <string name="message_count_format">\u00a0(<xliff:g id="number" example="1">%1$s</xliff:g>)</string>
+
<!-- For debugging: Dialog box title indicating there's a situation where data has unexpectedly
changed -->
<string name="error_state">Inconsistent state</string>
diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java
index 536d8855..96c942c6 100644
--- a/src/com/android/mms/ui/ComposeMessageActivity.java
+++ b/src/com/android/mms/ui/ComposeMessageActivity.java
@@ -116,6 +116,7 @@ import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.CursorAdapter;
@@ -236,7 +237,7 @@ public class ComposeMessageActivity extends Activity
private View mBottomPanel; // View containing the text editor, send button, ec.
private EditText mTextEditor; // Text editor to type your message into
private TextView mTextCounter; // Shows the number of characters used in text editor
- private Button mSendButton; // Press to detonate
+ private EditText mSendButton; // Press to detonate
private EditText mSubjectTextEditor; // Text editor for MMS subject
private AttachmentEditor mAttachmentEditor;
@@ -2227,17 +2228,16 @@ public class ComposeMessageActivity extends Activity
}
private void setSendButtonText(boolean isMms) {
- Button sendButton = mSendButton;
- sendButton.setText(R.string.send);
-
+ LayoutParams layout = (LayoutParams)mSendButton.getLayoutParams();
if (isMms) {
- // Create and append the "MMS" text in a smaller font than the "Send" text.
- sendButton.append("\n");
- SpannableString spannable = new SpannableString(getString(R.string.mms));
- int mmsTextSize = (int) (sendButton.getTextSize() * 0.75f);
- spannable.setSpan(new AbsoluteSizeSpan(mmsTextSize), 0, spannable.length(), 0);
- sendButton.append(spannable);
+ mSendButton.setText(R.string.mms);
+ layout.topMargin =
+ getResources().getDimensionPixelOffset(R.dimen.send_button_top_margin_with_mms);
mTextCounter.setText("");
+ } else {
+ layout.topMargin =
+ getResources().getDimensionPixelOffset(R.dimen.send_button_top_margin_no_mms);
+ mSendButton.setText(null);
}
}
@@ -3063,7 +3063,7 @@ public class ComposeMessageActivity extends Activity
mTextEditor.setFilters(new InputFilter[] {
new LengthFilter(MmsConfig.getMaxTextLimit())});
mTextCounter = (TextView) findViewById(R.id.text_counter);
- mSendButton = (Button) findViewById(R.id.send_button);
+ mSendButton = (EditText) findViewById(R.id.send_button);
mSendButton.setOnClickListener(this);
mTopPanel = findViewById(R.id.recipients_subject_linear);
mTopPanel.setFocusable(false);
diff --git a/src/com/android/mms/ui/ConversationListItem.java b/src/com/android/mms/ui/ConversationListItem.java
index d17c02bd..0212b96d 100644
--- a/src/com/android/mms/ui/ConversationListItem.java
+++ b/src/com/android/mms/ui/ConversationListItem.java
@@ -51,7 +51,6 @@ public class ConversationListItem extends RelativeLayout implements Contact.Upda
private TextView mDateView;
private View mAttachmentView;
private View mErrorIndicator;
- private ImageView mPresenceView;
private QuickContactBadge mAvatarView;
static private Drawable sDefaultContactImage;
@@ -85,19 +84,9 @@ public class ConversationListItem extends RelativeLayout implements Contact.Upda
mDateView = (TextView) findViewById(R.id.date);
mAttachmentView = findViewById(R.id.attachment);
mErrorIndicator = findViewById(R.id.error);
- mPresenceView = (ImageView) findViewById(R.id.presence);
mAvatarView = (QuickContactBadge) findViewById(R.id.avatar);
}
- public void setPresenceIcon(int iconId) {
- if (iconId == 0) {
- mPresenceView.setVisibility(View.GONE);
- } else {
- mPresenceView.setImageResource(iconId);
- mPresenceView.setVisibility(View.VISIBLE);
- }
- }
-
public ConversationListItemData getConversationHeader() {
return mConversationHeader;
}
@@ -115,24 +104,25 @@ public class ConversationListItem extends RelativeLayout implements Contact.Upda
}
private CharSequence formatMessage(ConversationListItemData ch) {
- final int size = android.R.style.TextAppearance_Small;
final int color = android.R.styleable.Theme_textColorSecondary;
String from = ch.getFrom();
SpannableStringBuilder buf = new SpannableStringBuilder(from);
if (ch.getMessageCount() > 1) {
- buf.append(" (" + ch.getMessageCount() + ") ");
+ buf.append(mContext.getResources().getString(R.string.message_count_format,
+ ch.getMessageCount()));
}
-
- int before = buf.length();
if (ch.hasDraft()) {
- buf.append(" ");
+ buf.append(mContext.getResources().getString(R.string.draft_separator));
+ int before = buf.length();
+ int size;
buf.append(mContext.getResources().getString(R.string.has_draft));
+ size = android.R.style.TextAppearance_Small;
buf.setSpan(new TextAppearanceSpan(mContext, size, color), before,
buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
buf.setSpan(new ForegroundColorSpan(
- mContext.getResources().getColor(R.drawable.text_color_red)),
+ mContext.getResources().getColor(R.drawable.text_color_blue)),
before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
@@ -170,7 +160,6 @@ public class ConversationListItem extends RelativeLayout implements Contact.Upda
ConversationListItemData ch = mConversationHeader;
ch.updateRecipients();
mFromView.setText(formatMessage(ch));
- setPresenceIcon(ch.getContacts().getPresenceResId());
updateAvatarView();
}
@@ -218,7 +207,6 @@ public class ConversationListItem extends RelativeLayout implements Contact.Upda
if (DEBUG) Log.v(TAG, "bind: contacts.addListeners " + this);
Contact.addListener(this);
- setPresenceIcon(contacts.getPresenceResId());
// Subject
mSubjectView.setText(ch.getSubject());
diff --git a/src/com/android/mms/ui/MessageItem.java b/src/com/android/mms/ui/MessageItem.java
index 0ede313d..a9413842 100644
--- a/src/com/android/mms/ui/MessageItem.java
+++ b/src/com/android/mms/ui/MessageItem.java
@@ -138,10 +138,7 @@ public class MessageItem {
if (!isOutgoingMessage()) {
// Set "received" or "sent" time stamp
long date = cursor.getLong(columnsMap.mColumnSmsDate);
- String label = context.getString(
- Sms.isOutgoingFolder(mBoxId) ? R.string.sent_on : R.string.received_on);
- mTimestamp = String.format(label,
- MessageUtils.formatTimeStampString(context, date));
+ mTimestamp = MessageUtils.formatTimeStampString(context, date);
}
mLocked = cursor.getInt(columnsMap.mColumnSmsLocked) != 0;
@@ -235,8 +232,12 @@ public class MessageItem {
}
if (!isOutgoingMessage()) {
- mTimestamp = context.getString(getTimestampStrId(),
- MessageUtils.formatTimeStampString(context, timestamp));
+ if (PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND == mMessageType) {
+ mTimestamp = context.getString(R.string.expire_on,
+ MessageUtils.formatTimeStampString(context, timestamp));
+ } else {
+ mTimestamp = MessageUtils.formatTimeStampString(context, timestamp);
+ }
}
} else {
throw new MmsException("Unknown type of the message: " + type);
@@ -256,16 +257,6 @@ public class MessageItem {
mContact = TextUtils.isEmpty(mAddress) ? "" : Contact.get(mAddress, false).getName();
}
- private int getTimestampStrId() {
- if (PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND == mMessageType) {
- return R.string.expire_on;
- } else if (PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF == mMessageType) {
- return R.string.received_on;
- } else {
- return R.string.sent_on;
- }
- }
-
public boolean isMms() {
return mType.equals("mms");
}
diff --git a/src/com/android/mms/ui/MessageListItem.java b/src/com/android/mms/ui/MessageListItem.java
index 231a61f9..92bfd2f7 100644
--- a/src/com/android/mms/ui/MessageListItem.java
+++ b/src/com/android/mms/ui/MessageListItem.java
@@ -27,8 +27,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.drawable.Drawable;
@@ -37,24 +35,21 @@ import android.os.Handler;
import android.os.Message;
import android.provider.Browser;
import android.provider.Telephony.Mms;
-import android.provider.Telephony.MmsSms;
import android.provider.Telephony.Sms;
import android.telephony.PhoneNumberUtils;
-import android.telephony.TelephonyManager;
import android.text.Html;
-import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.HideReturnsTransformationMethod;
import android.text.style.ForegroundColorSpan;
-import android.text.style.LeadingMarginSpan;
import android.text.style.LineHeightSpan;
import android.text.style.StyleSpan;
import android.text.style.TextAppearanceSpan;
import android.text.style.URLSpan;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
@@ -64,6 +59,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.QuickContactBadge;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.mms.MmsApp;
@@ -104,6 +100,8 @@ public class MessageListItem extends LinearLayout implements
private Handler mHandler;
private MessageItem mMessageItem;
private String mDefaultCountryIso;
+ private TextView mDateView;
+ private LinearLayout mStatusIcons;
public MessageListItem(Context context) {
super(context);
@@ -124,34 +122,12 @@ public class MessageListItem extends LinearLayout implements
mMsgListItem = findViewById(R.id.msg_list_item);
mBodyTextView = (TextView) findViewById(R.id.text_view);
+ mDateView = (TextView) findViewById(R.id.date_view);
mLockedIndicator = (ImageView) findViewById(R.id.locked_indicator);
mDeliveredIndicator = (ImageView) findViewById(R.id.delivered_indicator);
mDetailsIndicator = (ImageView) findViewById(R.id.details_indicator);
mAvatar = (QuickContactBadge) findViewById(R.id.avatar);
-
- ViewGroup.MarginLayoutParams badgeParams = (MarginLayoutParams)mAvatar.getLayoutParams();
- final int badgeWidth = badgeParams.width + badgeParams.rightMargin + badgeParams.leftMargin;
-
- int lineHeight = mBodyTextView.getLineHeight();
- int effectiveBadgeHeight = badgeParams.height + badgeParams.topMargin - mBodyTextView.getPaddingTop();
- final int indentLineCount = (int) ((effectiveBadgeHeight-1) / lineHeight) + 1;
-
- mLeadingMarginSpan = new LeadingMarginSpan.LeadingMarginSpan2() {
- public void drawLeadingMargin(Canvas c, Paint p, int x, int dir,
- int top, int baseline, int bottom, CharSequence text,
- int start, int end, boolean first, Layout layout) {
- // no op
- }
-
- public int getLeadingMargin(boolean first) {
- return first ? badgeWidth : 0;
- }
-
- public int getLeadingMarginLineCount() {
- return indentLineCount;
- }
- };
-
+ mStatusIcons = (LinearLayout) findViewById(R.id.status_icons);
}
public void bind(MessageListAdapter.AvatarCache avatarCache, MessageItem msgItem) {
@@ -185,9 +161,10 @@ public class MessageListItem extends LinearLayout implements
+ mContext.getString(R.string.kilobyte);
mBodyTextView.setText(formatMessage(msgItem, msgItem.mContact, null, msgItem.mSubject,
- msgSizeText + "\n" + msgItem.mTimestamp,
msgItem.mHighlight, msgItem.mTextContentType));
+ mDateView.setText(msgSizeText + " " + msgItem.mTimestamp);
+
int state = DownloadManager.getInstance().getState(msgItem.mMessageUri);
switch (state) {
case DownloadManager.STATE_DOWNLOADING:
@@ -221,11 +198,10 @@ public class MessageListItem extends LinearLayout implements
mLockedIndicator.setVisibility(View.GONE);
mDeliveredIndicator.setVisibility(View.GONE);
mDetailsIndicator.setVisibility(View.GONE);
-
- drawLeftStatusIndicator(msgItem.mBoxId);
}
- private void bindCommonMessage(final MessageListAdapter.AvatarCache avatarCache, final MessageItem msgItem) {
+ private void bindCommonMessage(final MessageListAdapter.AvatarCache avatarCache,
+ final MessageItem msgItem) {
if (mDownloadButton != null) {
mDownloadButton.setVisibility(View.GONE);
mDownloadingLabel.setVisibility(View.GONE);
@@ -265,11 +241,17 @@ public class MessageListItem extends LinearLayout implements
CharSequence formattedMessage = msgItem.getCachedFormattedMessage();
if (formattedMessage == null) {
formattedMessage = formatMessage(msgItem, msgItem.mContact, msgItem.mBody,
- msgItem.mSubject, msgItem.mTimestamp,
+ msgItem.mSubject,
msgItem.mHighlight, msgItem.mTextContentType);
}
mBodyTextView.setText(formattedMessage);
+ // If we're in the process of sending a message (i.e. pending), then we show a "SENDING..."
+ // string in place of the timestamp.
+ mDateView.setText(msgItem.isSending() ?
+ mContext.getResources().getString(R.string.sending_message) :
+ msgItem.mTimestamp);
+
if (msgItem.isSms()) {
hideMmsViewIfNeeded();
} else {
@@ -288,12 +270,68 @@ public class MessageListItem extends LinearLayout implements
}
}
- drawLeftStatusIndicator(msgItem.mBoxId);
+ adjustLayoutItems(msgItem);
drawRightStatusIndicator(msgItem);
requestLayout();
}
+ private void adjustLayoutItems(final MessageItem msgItem) {
+ // Put the avatar on the left or right
+ RelativeLayout.LayoutParams avatarLayout =
+ (RelativeLayout.LayoutParams)mAvatar.getLayoutParams();
+ RelativeLayout.LayoutParams textLayout =
+ (RelativeLayout.LayoutParams)mBodyTextView.getLayoutParams();
+ RelativeLayout.LayoutParams dateLayout =
+ (RelativeLayout.LayoutParams)mDateView.getLayoutParams();
+ RelativeLayout.LayoutParams statusIconsLayout =
+ (RelativeLayout.LayoutParams)mStatusIcons.getLayoutParams();
+
+ if (msgItem.mBoxId == Mms.MESSAGE_BOX_INBOX) {
+ // Avatar on left, text adjusted left
+ // undo the old rules first
+ textLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
+ textLayout.addRule(RelativeLayout.LEFT_OF, 0);
+ avatarLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
+ statusIconsLayout.addRule(RelativeLayout.LEFT_OF, 0);
+ dateLayout.addRule(RelativeLayout.LEFT_OF, 0);
+
+ // set the new rules
+ avatarLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ textLayout.addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
+ textLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ dateLayout.addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
+ statusIconsLayout.addRule(RelativeLayout.RIGHT_OF, R.id.date_view);
+
+ mBodyTextView.setPadding(0, 6, 0, 3);
+ mBodyTextView.setGravity(Gravity.LEFT);
+ avatarLayout.rightMargin = 5;
+ avatarLayout.leftMargin = 0;
+ } else {
+ // Avatar on right, text adjusted right
+ // undo the old rules first
+ avatarLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
+ textLayout.addRule(RelativeLayout.RIGHT_OF, 0);
+ textLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
+ dateLayout.addRule(RelativeLayout.RIGHT_OF, 0);
+ statusIconsLayout.addRule(RelativeLayout.RIGHT_OF, 0);
+
+ // set the new rules
+ textLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ textLayout.addRule(RelativeLayout.LEFT_OF, R.id.avatar);
+ avatarLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ statusIconsLayout.addRule(RelativeLayout.LEFT_OF, R.id.date_view);
+ dateLayout.addRule(RelativeLayout.LEFT_OF, R.id.avatar);
+
+ mBodyTextView.setPadding(mContext.getResources()
+ .getDimensionPixelOffset(R.dimen.message_item_avatar_on_right_text_indent),
+ 6, 10, 3);
+ mBodyTextView.setGravity(Gravity.RIGHT);
+ avatarLayout.rightMargin = 0;
+ avatarLayout.leftMargin = 5;
+ }
+ }
+
private void hideMmsViewIfNeeded() {
if (mMmsView != null) {
mMmsView.setVisibility(View.GONE);
@@ -347,7 +385,6 @@ public class MessageListItem extends LinearLayout implements
}
}
- private LeadingMarginSpan mLeadingMarginSpan;
private LineHeightSpan mSpan = new LineHeightSpan() {
public void chooseHeight(CharSequence text, int start,
@@ -362,13 +399,9 @@ public class MessageListItem extends LinearLayout implements
ForegroundColorSpan mColorSpan = null; // set in ctor
private CharSequence formatMessage(MessageItem msgItem, String contact, String body,
- String subject, String timestamp, Pattern highlight,
+ String subject, Pattern highlight,
String contentType) {
- CharSequence template = mContext.getResources().getText(R.string.name_colon);
- SpannableStringBuilder buf =
- new SpannableStringBuilder(TextUtils.replace(template,
- new String[] { "%s" },
- new CharSequence[] { contact }));
+ SpannableStringBuilder buf = new SpannableStringBuilder();
boolean hasSubject = !TextUtils.isEmpty(subject);
if (hasSubject) {
@@ -388,24 +421,6 @@ public class MessageListItem extends LinearLayout implements
buf.append(parser.addSmileySpans(body));
}
}
- // If we're in the process of sending a message (i.e. pending), then we show a "Sending..."
- // string in place of the timestamp.
- if (msgItem.isSending()) {
- timestamp = mContext.getResources().getString(R.string.sending_message);
- }
- // We always show two lines because the optional icon bottoms are aligned with the
- // bottom of the text field, assuming there are two lines for the message and the sent time.
- buf.append("\n");
- int startOffset = buf.length();
-
- startOffset = buf.length();
- buf.append(TextUtils.isEmpty(timestamp) ? " " : timestamp);
-
- buf.setSpan(mTextSmallSpan, startOffset, buf.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- buf.setSpan(mSpan, startOffset+1, buf.length(), 0);
-
- // Make the timestamp text not as dark
- buf.setSpan(mColorSpan, startOffset, buf.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
if (highlight != null) {
Matcher m = highlight.matcher(buf.toString());
@@ -413,7 +428,6 @@ public class MessageListItem extends LinearLayout implements
buf.setSpan(new StyleSpan(Typeface.BOLD), m.start(), m.end(), 0);
}
}
- buf.setSpan(mLeadingMarginSpan, 0, buf.length(), 0);
return buf;
}
@@ -550,25 +564,6 @@ public class MessageListItem extends LinearLayout implements
}
}
- private void drawLeftStatusIndicator(int msgBoxId) {
- switch (msgBoxId) {
- case Mms.MESSAGE_BOX_INBOX:
- mMsgListItem.setBackgroundResource(R.drawable.listitem_background_lightblue);
- break;
-
- case Mms.MESSAGE_BOX_DRAFTS:
- case Sms.MESSAGE_TYPE_FAILED:
- case Sms.MESSAGE_TYPE_QUEUED:
- case Mms.MESSAGE_BOX_OUTBOX:
- mMsgListItem.setBackgroundResource(R.drawable.listitem_background);
- break;
-
- default:
- mMsgListItem.setBackgroundResource(R.drawable.listitem_background);
- break;
- }
- }
-
private void setErrorIndicatorClickListener(final MessageItem msgItem) {
String type = msgItem.mType;
final int what;