am 6bbc689e: Implement final drag & drop spec

* commit '6bbc689efcb33c74129493e7097aa4a485a7d7c1':
  Implement final drag & drop spec
This commit is contained in:
Todd Kennedy 2011-01-20 08:47:07 -08:00 committed by Android Git Automerger
commit fab451d972
10 changed files with 30 additions and 21 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -49,10 +49,9 @@
<!-- Drop target colors -->
<!-- STOPSHIP Replace with final colors -->
<color name="mailbox_drop_available_color">#ffd9e3bd</color>
<color name="mailbox_drop_unavailable_color">#ffffffff</color>
<color name="mailbox_drop_target_active_color">#ffbedc62</color>
<color name="mailbox_drop_target_destructive_color">#ffff0000</color>
<color name="mailbox_drop_unavailable_fg_color">#ff999999</color>
<color name="mailbox_drop_available_bg_color">#00ffffff</color>
<color name="mailbox_drop_destructive_bg_color">#fff10000</color>
<!-- Widget colors -->
<color name="widget_label_shadow_color">#0d0d0d</color>

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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);