From 9c39deef4e513554e0f8564d5c2ef3deddc87793 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Mon, 8 Nov 2010 18:15:00 -0800 Subject: [PATCH] Code change for new mailbox list layout - Don't show a folder icon for regular mailboxes - Change the count look - Don't show counts for Sent/Trash. Bug 3137965 Bug 3073147 Change-Id: I8fc0af8fc2d51968605fe4b570e5704453092ac7 --- res/layout/mailbox_list_item.xml | 63 ++++++++----------- res/values/arrays.xml | 4 +- src/com/android/email/Utility.java | 10 +-- .../email/activity/MailboxListItem.java | 4 +- .../email/activity/MailboxesAdapter.java | 38 +++++------ 5 files changed, 50 insertions(+), 69 deletions(-) diff --git a/res/layout/mailbox_list_item.xml b/res/layout/mailbox_list_item.xml index 67a0c6412..2aa7aa8ec 100644 --- a/res/layout/mailbox_list_item.xml +++ b/res/layout/mailbox_list_item.xml @@ -14,57 +14,44 @@ limitations under the License. --> - + - - - - - + android:layout_width="32dip" + android:layout_height="32dip" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:paddingLeft="2dip" + /> + android:layout_alignParentRight="true" + android:layout_marginRight="12dip" + android:layout_centerVertical="true" + android:ellipsize="end" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="?android:attr/textColorPrimary" + /> + android:layout_toRightOf="@id/folder_icon" + android:layout_toLeftOf="@id/message_count" + android:layout_centerVertical="true" + android:ellipsize="end" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorPrimary" + /> diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 1fb8cc8f1..4df819e99 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -163,9 +163,9 @@ @drawable/ic_list_inbox - @drawable/ic_list_folder + - @drawable/ic_list_folder + @drawable/ic_list_drafts diff --git a/src/com/android/email/Utility.java b/src/com/android/email/Utility.java index 99e9903ab..775f18877 100644 --- a/src/com/android/email/Utility.java +++ b/src/com/android/email/Utility.java @@ -366,7 +366,6 @@ public class Utility { // Caches for frequently accessed resources. private final String[] mSpecialMailbox; private final TypedArray mSpecialMailboxDrawable; - private final Drawable mDefaultMailboxDrawable; private final Drawable mSummaryStarredMailboxDrawable; private final Drawable mSummaryCombinedInboxDrawable; @@ -381,8 +380,6 @@ public class Utility { } mSpecialMailboxDrawable = context.getResources().obtainTypedArray(R.array.mailbox_display_icons); - mDefaultMailboxDrawable = - context.getResources().getDrawable(R.drawable.ic_list_folder); mSummaryStarredMailboxDrawable = context.getResources().getDrawable(R.drawable.ic_list_starred); mSummaryCombinedInboxDrawable = @@ -447,9 +444,12 @@ public class Utility { return mSpecialMailboxDrawable.getDrawable(Mailbox.TYPE_OUTBOX); } if (0 <= type && type < mSpecialMailboxDrawable.length()) { - return mSpecialMailboxDrawable.getDrawable(type); + final int resId = mSpecialMailboxDrawable.getResourceId(type, -1); + if (resId != -1) { + return mContext.getResources().getDrawable(resId); + } } - return mDefaultMailboxDrawable; + return null; // No icon } } diff --git a/src/com/android/email/activity/MailboxListItem.java b/src/com/android/email/activity/MailboxListItem.java index c5dbe39f6..c55089bcf 100644 --- a/src/com/android/email/activity/MailboxListItem.java +++ b/src/com/android/email/activity/MailboxListItem.java @@ -22,9 +22,9 @@ import com.android.internal.util.ArrayUtils; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; -import android.widget.LinearLayout; +import android.widget.RelativeLayout; -public class MailboxListItem extends LinearLayout { +public class MailboxListItem extends RelativeLayout { // STOPSHIP Need final color/ui // Color used for valid drop targets private static final int DROP_AVAILABLE = 0xFFFFFF33; diff --git a/src/com/android/email/activity/MailboxesAdapter.java b/src/com/android/email/activity/MailboxesAdapter.java index 2d7173807..664f8d01f 100644 --- a/src/com/android/email/activity/MailboxesAdapter.java +++ b/src/com/android/email/activity/MailboxesAdapter.java @@ -220,41 +220,35 @@ import java.security.InvalidParameterException; nameView.setText(getDisplayName(context, cursor)); // Set count + boolean showCount = true; boolean useTotalCount = false; switch (type) { case Mailbox.TYPE_DRAFTS: case Mailbox.TYPE_OUTBOX: - case Mailbox.TYPE_SENT: - case Mailbox.TYPE_TRASH: useTotalCount = true; break; + case Mailbox.TYPE_SENT: + case Mailbox.TYPE_TRASH: + showCount = false; // Don't show count. + break; + } - final int count = cursor.getInt(useTotalCount ? COLUMN_MESSAGE_COUNT : COLUMN_UNREAD_COUNT); - final TextView unreadCountView = (TextView) view.findViewById(R.id.new_message_count); - final TextView allCountView = (TextView) view.findViewById(R.id.all_message_count); + final int count = + showCount ? cursor.getInt(useTotalCount ? COLUMN_MESSAGE_COUNT : COLUMN_UNREAD_COUNT) + : 0; + final TextView countView = (TextView) view.findViewById(R.id.message_count); // If the unread count is zero, not to show countView. if (count > 0) { - nameView.setTypeface(Typeface.DEFAULT_BOLD); - if (useTotalCount) { - unreadCountView.setVisibility(View.GONE); - allCountView.setVisibility(View.VISIBLE); - allCountView.setText(Integer.toString(count)); - } else { - allCountView.setVisibility(View.GONE); - unreadCountView.setVisibility(View.VISIBLE); - unreadCountView.setText(Integer.toString(count)); - } + countView.setVisibility(View.VISIBLE); + countView.setText(Integer.toString(count)); } else { - nameView.setTypeface(Typeface.DEFAULT); - allCountView.setVisibility(View.GONE); - unreadCountView.setVisibility(View.GONE); + countView.setVisibility(View.GONE); } // Set folder icon - ((ImageView) view.findViewById(R.id.folder_icon)) - .setImageDrawable(Utility.FolderProperties.getInstance(context) - .getIcon(type, mailboxId)); + ((ImageView) view.findViewById(R.id.folder_icon)).setImageDrawable( + Utility.FolderProperties.getInstance(context).getIcon(type, mailboxId)); } private View newViewNormalMode(Context context, Cursor cursor, ViewGroup parent) { @@ -401,7 +395,7 @@ import java.security.InvalidParameterException; Mailbox.QUERY_ALL_DRAFTS, Mailbox.TYPE_DRAFTS, Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_DRAFTS), false); - // Outbox -- # of sent messages + // Outbox -- # of outstanding messages addSummaryMailboxRow(context, cursor, Mailbox.QUERY_ALL_OUTBOX, Mailbox.TYPE_OUTBOX, Mailbox.getMessageCountByMailboxType(context, Mailbox.TYPE_OUTBOX), false);