From 2313f48bdc34409a1d17bd841d440d8215eb9528 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Tue, 2 Aug 2011 12:40:10 -0700 Subject: [PATCH] Minor visual fixes in message list - changed activated font to white - ensure activated bg is set even for wide (as it shows for a split second when you select a message right before the slide animation) - attempt to make the animation not so abrupt Bug: 5110992 Change-Id: Ie05e0a6a09afb97155b26d28672d4a2fb79cc563 --- .../message_list_wide_read_selector.xml | 5 ++ .../message_list_wide_unread_selector.xml | 5 ++ .../email/activity/MessageListItem.java | 68 ++++++++++++------- .../activity/MessageListItemCoordinates.java | 5 -- .../email/activity/MessagesAdapter.java | 6 +- .../email/activity/ThreePaneLayout.java | 4 +- 6 files changed, 58 insertions(+), 35 deletions(-) diff --git a/res/drawable/message_list_wide_read_selector.xml b/res/drawable/message_list_wide_read_selector.xml index c523a09d7..4577018a6 100644 --- a/res/drawable/message_list_wide_read_selector.xml +++ b/res/drawable/message_list_wide_read_selector.xml @@ -19,5 +19,10 @@ android:drawable="@drawable/list_wide_read_pressed_holo" /> + + diff --git a/res/drawable/message_list_wide_unread_selector.xml b/res/drawable/message_list_wide_unread_selector.xml index 5d817fdd6..446358e78 100644 --- a/res/drawable/message_list_wide_unread_selector.xml +++ b/res/drawable/message_list_wide_unread_selector.xml @@ -19,5 +19,10 @@ android:drawable="@drawable/list_wide_unread_pressed_holo" /> + + diff --git a/src/com/android/email/activity/MessageListItem.java b/src/com/android/email/activity/MessageListItem.java index ef78ed74b..64d1ca5bd 100644 --- a/src/com/android/email/activity/MessageListItem.java +++ b/src/com/android/email/activity/MessageListItem.java @@ -109,7 +109,6 @@ public class MessageListItem extends View { private String mSubjectAndDescription; private StaticLayout mSubjectLayout; public boolean mRead; - public long mTimestamp; public boolean mHasAttachment = false; public boolean mHasInvite = true; public boolean mIsFavorite = false; @@ -132,7 +131,7 @@ public class MessageListItem extends View { private Drawable mWideReadSelector; private Drawable mWideUnreadSelector; - public int mSnippetLineCount = NEEDS_LAYOUT; + private int mSnippetLineCount = NEEDS_LAYOUT; private CharSequence mFormattedSender; private CharSequence mFormattedDate; @@ -179,13 +178,44 @@ public class MessageListItem extends View { } /** - * Sets message subject safely, ensuring the cache is invalidated. + * Sets message subject and snippet safely, ensuring the cache is invalidated. */ - public void setSubject(String subject) { + public void setText(String subject, String snippet) { + boolean changed = false; if (!Objects.equal(mSubject, subject)) { mSubject = subject; + changed = true; mSubjectAndDescription = null; } + + if (!Objects.equal(mSnippet, snippet)) { + mSnippet = snippet; + mSnippetLineCount = MessageListItem.NEEDS_LAYOUT; + changed = true; + } + + if (changed) { + SpannableStringBuilder ssb = new SpannableStringBuilder(); + boolean hasSubject = false; + if (!TextUtils.isEmpty(mSubject)) { + SpannableString ss = new SpannableString(mSubject); + ss.setSpan(new StyleSpan(mRead ? Typeface.NORMAL : Typeface.BOLD), 0, ss.length(), + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + ssb.append(ss); + hasSubject = true; + } + if (!TextUtils.isEmpty(mSnippet)) { + if (hasSubject) { + ssb.append(sSubjectSnippetDivider); + } + ssb.append(mSnippet); + } + mText = ssb; + } + } + + public void setTimestamp(long timestamp) { + mFormattedDate = DateUtils.getRelativeTimeSpanString(mContext, timestamp).toString(); } /** @@ -239,24 +269,9 @@ public class MessageListItem extends View { } private void calculateDrawingData() { - SpannableStringBuilder ssb = new SpannableStringBuilder(); - boolean hasSubject = false; - if (!TextUtils.isEmpty(mSubject)) { - SpannableString ss = new SpannableString(mSubject); - ss.setSpan(new StyleSpan(mRead ? Typeface.NORMAL : Typeface.BOLD), 0, ss.length(), - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - ssb.append(ss); - hasSubject = true; - } - if (!TextUtils.isEmpty(mSnippet)) { - if (hasSubject) { - ssb.append(sSubjectSnippetDivider); - } - ssb.append(mSnippet); - } - mText = ssb; - sDefaultPaint.setTextSize(mCoordinates.subjectFontSize); + sDefaultPaint.setColor(mContext.getResources().getColor( + isActivated() ? android.R.color.white : android.R.color.black)); mSubjectLayout = new StaticLayout(mText, sDefaultPaint, mCoordinates.subjectWidth, Alignment.ALIGN_NORMAL, 1, 0, false /* includePad */); if (mCoordinates.subjectLineCount < mSubjectLayout.getLineCount()) { @@ -277,8 +292,6 @@ public class MessageListItem extends View { mFormattedSender = TextUtils.ellipsize(mSender, senderPaint, senderWidth, TruncateAt.END); } - // Get a nicely formatted date string (relative to today) - mFormattedDate = DateUtils.getRelativeTimeSpanString(getContext(), mTimestamp).toString(); } @Override @@ -357,14 +370,19 @@ public class MessageListItem extends View { mColorChipPaint); } + int fontColor = mContext.getResources().getColor( + (isActivated() || isPressed()) ? android.R.color.white : android.R.color.black); + // Draw the checkbox canvas.drawBitmap(mAdapter.isSelected(this) ? sSelectedIconOn : sSelectedIconOff, mCoordinates.checkmarkX, mCoordinates.checkmarkY, null); // Draw the sender name + Paint senderPaint = mRead ? sDefaultPaint : sBoldPaint; + senderPaint.setColor(fontColor); canvas.drawText(mFormattedSender, 0, mFormattedSender.length(), mCoordinates.sendersX, mCoordinates.sendersY - mCoordinates.sendersAscent, - mRead ? sDefaultPaint : sBoldPaint); + senderPaint); // Draw the reply state. Draw nothing if neither replied nor forwarded. if (mHasBeenRepliedTo && mHasBeenForwarded) { @@ -381,6 +399,7 @@ public class MessageListItem extends View { // Subject and snippet. sDefaultPaint.setTextSize(mCoordinates.subjectFontSize); sDefaultPaint.setTypeface(Typeface.DEFAULT); + sDefaultPaint.setColor(fontColor); canvas.save(); canvas.translate( mCoordinates.subjectX, @@ -390,6 +409,7 @@ public class MessageListItem extends View { // Draw the date sDatePaint.setTextSize(mCoordinates.dateFontSize); + sDatePaint.setColor(fontColor); int dateX = mCoordinates.dateXEnd - (int) sDatePaint.measureText(mFormattedDate, 0, mFormattedDate.length()); diff --git a/src/com/android/email/activity/MessageListItemCoordinates.java b/src/com/android/email/activity/MessageListItemCoordinates.java index c961aa308..b10953ebd 100644 --- a/src/com/android/email/activity/MessageListItemCoordinates.java +++ b/src/com/android/email/activity/MessageListItemCoordinates.java @@ -52,7 +52,6 @@ public class MessageListItemCoordinates { int checkmarkX; int checkmarkY; int checkmarkWidthIncludingMargins; - int checkmarkHeightIncludingMargins; // Reply and forward state. int stateX; @@ -67,7 +66,6 @@ public class MessageListItemCoordinates { int sendersY; int sendersWidth; int sendersLineCount; - int sendersLineHeight; int sendersFontSize; int sendersAscent; @@ -76,7 +74,6 @@ public class MessageListItemCoordinates { int subjectY; int subjectWidth; int subjectLineCount; - int subjectLineHeight; int subjectFontSize; int subjectAscent; @@ -270,7 +267,6 @@ public class MessageListItemCoordinates { coordinates.sendersY = getY(senders); coordinates.sendersWidth = getWidth(senders, false); coordinates.sendersLineCount = getLineCount(senders); - coordinates.sendersLineHeight = senders.getLineHeight(); coordinates.sendersFontSize = (int) senders.getTextSize(); coordinates.sendersAscent = Math.round(senders.getPaint().ascent()); @@ -279,7 +275,6 @@ public class MessageListItemCoordinates { coordinates.subjectY = getY(subject); coordinates.subjectWidth = getWidth(subject, false); coordinates.subjectLineCount = getLineCount(subject); - coordinates.subjectLineHeight = subject.getLineHeight(); coordinates.subjectFontSize = (int) subject.getTextSize(); coordinates.subjectAscent = Math.round(subject.getPaint().ascent()); diff --git a/src/com/android/email/activity/MessagesAdapter.java b/src/com/android/email/activity/MessagesAdapter.java index dc0b6e1ae..5586f9e26 100644 --- a/src/com/android/email/activity/MessagesAdapter.java +++ b/src/com/android/email/activity/MessagesAdapter.java @@ -196,11 +196,9 @@ import java.util.Set; itemView.mHasBeenRepliedTo = (flags & Message.FLAG_REPLIED_TO) != 0; itemView.mHasBeenForwarded = (flags & Message.FLAG_FORWARDED) != 0; itemView.mHasAttachment = cursor.getInt(COLUMN_ATTACHMENTS) != 0; - itemView.mTimestamp = cursor.getLong(COLUMN_DATE); + itemView.setTimestamp(cursor.getLong(COLUMN_DATE)); itemView.mSender = cursor.getString(COLUMN_DISPLAY_NAME); - itemView.mSnippet = cursor.getString(COLUMN_SNIPPET); - itemView.setSubject(cursor.getString(COLUMN_SUBJECT)); - itemView.mSnippetLineCount = MessageListItem.NEEDS_LAYOUT; + itemView.setText(cursor.getString(COLUMN_SUBJECT), cursor.getString(COLUMN_SNIPPET)); itemView.mColorChipPaint = mShowColorChips ? mResourceHelper.getAccountColorPaint(accountId) : null; diff --git a/src/com/android/email/activity/ThreePaneLayout.java b/src/com/android/email/activity/ThreePaneLayout.java index 26f724f8c..4564494a8 100644 --- a/src/com/android/email/activity/ThreePaneLayout.java +++ b/src/com/android/email/activity/ThreePaneLayout.java @@ -47,8 +47,8 @@ import com.android.emailcommon.Logging; public class ThreePaneLayout extends LinearLayout implements View.OnClickListener { private static final boolean ANIMATION_DEBUG = false; // DON'T SUBMIT WITH true - private static final int ANIMATION_DURATION = ANIMATION_DEBUG ? 1000 : 80; - private static final TimeInterpolator INTERPOLATOR = new DecelerateInterpolator(1.5f); + private static final int ANIMATION_DURATION = ANIMATION_DEBUG ? 1000 : 150; + private static final TimeInterpolator INTERPOLATOR = new DecelerateInterpolator(1.75f); /** Uninitialized state -- {@link #changePaneState} hasn't been called yet. */ private static final int STATE_UNINITIALIZED = -1;