From 6bbc689efcb33c74129493e7097aa4a485a7d7c1 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Wed, 19 Jan 2011 14:38:20 -0800 Subject: [PATCH] Implement final drag & drop spec Current specification calls for the following: * Droppable targets: do nothing * Not droppable targets: grey text (hex #999999) * Hover over droppable: use label/folder list pressed state * Hover over not droppable: do nothing * Destructive targets: background (hex #f10000) We need to copy the resource from the framework as there is no supported way to fetch the pressed state drawable during runtime. Adam filed bug 3370043 so we can specify a drag target state directly in the selector. bug 3154986 Change-Id: Ifd5c24a3dc46b5a1c64a149904657dda297ed047 --- res/drawable-hdpi/bg_dragdrop.9.png | Bin 0 -> 202 bytes res/drawable-hdpi/drag_background_holo.9.png | Bin 379 -> 0 bytes res/drawable-hdpi/list_activated_holo.9.png | Bin 0 -> 1058 bytes res/drawable-mdpi/bg_dragdrop.9.png | Bin 0 -> 193 bytes res/drawable-mdpi/drag_background_holo.9.png | Bin 270 -> 0 bytes res/drawable-mdpi/list_activated_holo.9.png | Bin 0 -> 1049 bytes res/values/colors.xml | 7 ++-- .../email/activity/MailboxListFragment.java | 11 ++++--- .../email/activity/MailboxListItem.java | 31 +++++++++++------- .../email/activity/MessageListFragment.java | 2 +- 10 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 res/drawable-hdpi/bg_dragdrop.9.png delete mode 100644 res/drawable-hdpi/drag_background_holo.9.png create mode 100644 res/drawable-hdpi/list_activated_holo.9.png create mode 100644 res/drawable-mdpi/bg_dragdrop.9.png delete mode 100644 res/drawable-mdpi/drag_background_holo.9.png create mode 100644 res/drawable-mdpi/list_activated_holo.9.png diff --git a/res/drawable-hdpi/bg_dragdrop.9.png b/res/drawable-hdpi/bg_dragdrop.9.png new file mode 100644 index 0000000000000000000000000000000000000000..b8c98ddd4cc7ed6f8b6f0f0a9b00704e55663bc6 GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|mSQK*5Dp-y;YjHK@;M7UB8wRq zxI00Z(fs7;wLrlfPZ!4!i{87FHu5$Y@UZ+3bn!l|!!t#5Mhj{lWvrCf3tF)G`YBMvOz$W^yw=3bB{{T{S3_7bKS{tng?G;;DQN% t#E+bNb1cI8@Lo1ArpT2~IHL4DG;;f-WM}>=Jr1;&!PC{xWt~$(69Bx|#HjrnJ*6$Dnb*kz@kJ+rG}=X&oM zGq=9~-M{?v?K3s&w(g6oU;01&{om;3_m5?#Kg>Vm!YQokGsPf~CXCWG+`Pwk3fZf@ zig<0<*ePJI<~2hjaZyXB5X~63j5mL?vwePCW9?@@+fV#!B!$=gIdOFZFfj9|J5Vn5c8U%_ z88TD8qFC5Xnz2nXa(#+snA~{eo7Nm6poV50FVFsbz0Cs0&a*etWmxt#)Nm%212nxn zS+$nuEZJtq$3QMpD1nQJ2_kpi3zaC(ws;k~kFPlvv`olco^3ldQ=S4E4iHEuVZwqL z2r_(<7gLfXT?7K;AqNGH7ZSXrh=Kwk=sYY{3+%d5(T$E4J>}U3A-=+K&1N&%6q7iZ z<#<_^V-7(`P>V#kylOI}D!&q7^Yhw65)>Y-Rg3y?{0P{nw@+W}JzOmNu1KG3Gq zpln)>7oX$uw4>Eg;M_*G5nvaz@~b!p=o?vy`YffO)Q-C#sfBEThcXn!q9n>}2W$UN z&N%7}7dOX0&C5Z`a=RtPiej9$gXdyuzNOx}^9N*^OzHpt literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/bg_dragdrop.9.png b/res/drawable-mdpi/bg_dragdrop.9.png new file mode 100644 index 0000000000000000000000000000000000000000..c0d46beb355d503ce38c8913dc786db422a3550e GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2?f#ZI0f96(URkTN0Pr$(Ai!OqMY<9hhkG@SUCi zG&z-nPrfQ}cB&k^IjP^)vuxe6sUiG-H;8`Up;u{j%h@;a#H(z_9*6nDjTOOhnSb|k iPGR{}^3W%aU#P6)f|M|WbB-3!ItEWyKbLh*2~7ZB|6H_V+Po~-c6>aczaSW-r_2!NtUyFhOYrwHLg5Um$U$O4-QEI(-!>jDR zKFjWhtT_%!#Gc4#RrTd}n31#9i=rQf$_-KtkT_M`gR(vzAF4GfG-EF1y~NDKsT zf}~^L+;T~UnUWIcj9Z%WPkf%VFrf{vj+38O9{+g$|B2M^zo+;4+?iV@@p!#ALm49* ZLtwXZ0B_2R5}?}|JYD@<);T3K0RUznTcQ8} diff --git a/res/drawable-mdpi/list_activated_holo.9.png b/res/drawable-mdpi/list_activated_holo.9.png new file mode 100644 index 0000000000000000000000000000000000000000..f162c9ac2deb60cb81da19bec54db4d908f24b32 GIT binary patch literal 1049 zcmbVL&ui0A91m`cF&KDI#GM`)I2>z|m!wG(R=2ciT*1uI7430p^4i8Nd0Fyi)18Lk zLEJ%a^E6P;f_U`cWe5Ei6h-|9^r)cBm;RU@#tsIO_aooW=kxvfU~TpK^wi80!!Xm; z6|+XyN&2#r6ZG3G9DJb5Wm0L7b=)FdCq|6n;U)srz-glza=hO5JG96!V=celAPxJ5 z?&5%RG8--pB8q01#icZI+)YG46Se)Y$bNhMh6TP?WN+tf!H&wPXfbOooY~DdSTo;vpyS zL6F7Ow@ye6{dMD1>!jX`5MM(H-icjWkJju6Omla(P-aNI(Qn2+EsC>cVs|G%A*q^0 zmj2;9-_uK`Rgs`38YNLs3J?}7MKl#TU&@P$CR>FO$7xtY5(}zq36>yLAT%vaGgQ-p zl2y)EN|Gv$u+=ajPUxbMu1|Fb*ot)~RxiiMAvmsMyfx~8wGJjY>EH;I*Ym)3TtCdt zS$PK0nke?~BF~C(0Q&jW{ZsViNR!yUxzHk0IK3*ErH#~2A>bO1r>gCnt zTW`;`o=ZQz){c&rnf>{_d1hkn{*})U7oL9ne)#C({ - #ffd9e3bd - #ffffffff - #ffbedc62 - #ffff0000 + #ff999999 + #00ffffff + #fff10000 #0d0d0d diff --git a/src/com/android/email/activity/MailboxListFragment.java b/src/com/android/email/activity/MailboxListFragment.java index 797486820..b1a20634f 100644 --- a/src/com/android/email/activity/MailboxListFragment.java +++ b/src/com/android/email/activity/MailboxListFragment.java @@ -33,6 +33,7 @@ import android.content.ClipDescription; import android.content.Loader; import android.content.res.Resources; import android.database.Cursor; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.util.Log; @@ -74,7 +75,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList // Colors used for drop targets private static Integer sDropTrashColor; - private static Integer sDropActiveColor; + private static Drawable sDropActiveDrawable; private long mLastLoadedAccountId = -1; private long mAccountId = -1; @@ -109,7 +110,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList private Utility.ListStateSaver mSavedListState; private MailboxesAdapter.Callback mMailboxesAdapterCallback = new MailboxesAdapter.Callback() { - @Override + @Override public void onSetDropTargetBackground(MailboxListItem listItem) { listItem.setDropTargetBackground(mDragInProgress, mDragItemMailboxId); } @@ -163,8 +164,8 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList } if (sDropTrashColor == null) { Resources res = getResources(); - sDropTrashColor = res.getColor(R.color.mailbox_drop_target_destructive_color); - sDropActiveColor = res.getColor(R.color.mailbox_drop_target_active_color); + sDropTrashColor = res.getColor(R.color.mailbox_drop_destructive_bg_color); + sDropActiveDrawable = res.getDrawable(R.drawable.list_activated_holo); } } @@ -508,7 +509,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList newTarget.setBackgroundColor(sDropTrashColor); } else if (newTarget.isDropTarget(mDragItemMailboxId)) { Log.d("onDragLocation", "=== Mailbox " + newTarget.mMailboxId + " TARGET"); - newTarget.setBackgroundColor(sDropActiveColor); + newTarget.setBackgroundDrawable(sDropActiveDrawable); } else { Log.d("onDragLocation", "=== Mailbox " + newTarget.mMailboxId + " (CALL)"); targetAdapterPosition = NO_DROP_TARGET; diff --git a/src/com/android/email/activity/MailboxListItem.java b/src/com/android/email/activity/MailboxListItem.java index 78414a60a..df656507d 100644 --- a/src/com/android/email/activity/MailboxListItem.java +++ b/src/com/android/email/activity/MailboxListItem.java @@ -25,17 +25,22 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.RelativeLayout; +import android.widget.TextView; public class MailboxListItem extends RelativeLayout { // Colors used for drop targets - private static Integer sDropAvailableColor; - private static Integer sDropUnavailableColor; + private static Integer sDropUnavailableFgColor; + private static Integer sDropAvailableBgColor; + private static Integer sTextPrimaryColor; + private static Integer sTextSecondaryColor; public long mMailboxId; public Integer mMailboxType; public MailboxesAdapter mAdapter; private Drawable mBackground; + private TextView mLabelName; + private TextView mLabelCount; public MailboxListItem(Context context) { super(context); @@ -53,11 +58,15 @@ public class MailboxListItem extends RelativeLayout { protected void onFinishInflate() { super.onFinishInflate(); mBackground = getBackground(); - if (sDropAvailableColor == null) { + if (sDropAvailableBgColor == null) { Resources res = getResources(); - sDropAvailableColor = res.getColor(R.color.mailbox_drop_available_color); - sDropUnavailableColor = res.getColor(R.color.mailbox_drop_unavailable_color); + sDropAvailableBgColor = res.getColor(R.color.mailbox_drop_available_bg_color); + sDropUnavailableFgColor = res.getColor(R.color.mailbox_drop_unavailable_fg_color); + sTextPrimaryColor = res.getColor(R.color.text_primary_color); + sTextSecondaryColor = res.getColor(R.color.text_secondary_color); } + mLabelName = (TextView)findViewById(R.id.mailbox_name); + mLabelCount = (TextView)findViewById(R.id.message_count); } public boolean isDropTarget(long itemMailbox) { @@ -67,18 +76,18 @@ public class MailboxListItem extends RelativeLayout { return !ArrayUtils.contains(Mailbox.INVALID_DROP_TARGETS, mMailboxType); } - public boolean setDropTargetBackground(boolean dragInProgress, long itemMailbox) { + public void setDropTargetBackground(boolean dragInProgress, long itemMailbox) { if (dragInProgress) { if (isDropTarget(itemMailbox)) { - setBackgroundColor(sDropAvailableColor); - return true; + setBackgroundColor(sDropAvailableBgColor); } else { - setBackgroundColor(sDropUnavailableColor); - return false; + mLabelName.setTextColor(sDropUnavailableFgColor); + mLabelCount.setTextColor(sDropUnavailableFgColor); } } else { + mLabelName.setTextColor(sTextPrimaryColor); + mLabelCount.setTextColor(sTextSecondaryColor); setBackgroundDrawable(mBackground); - return false; } } } diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index 40ad92b47..f02f4a079 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -504,7 +504,7 @@ public class MessageListFragment extends ListFragment if (sBackground == null || mOldOrientation != newOrientation) { mOldOrientation = newOrientation; - sBackground = res.getDrawable(R.drawable.drag_background_holo); + sBackground = res.getDrawable(R.drawable.bg_dragdrop); sBackground.setBounds(0, 0, mDragWidth, mDragHeight); sDragOffset = (int)res.getDimension(R.dimen.message_list_drag_offset);