Some drag and drop code refactor:

1) Adding DragOptions to easily extend drap functionality
2) Changing onDragStarted signature to send more information
3) Updating states for dropTargetButton based on drag event directly
4) Removing folder item based on onDragStarted and not startDrag

Change-Id: I65b684e092ddc081d086bfe2c8c1973ed170eaeb
This commit is contained in:
Sunny Goyal
2016-08-16 15:36:48 -07:00
parent 61bcfba335
commit 94b510cc68
14 changed files with 224 additions and 173 deletions

View File

@@ -43,6 +43,7 @@ import android.widget.TextView;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.util.Thunk;
@@ -199,8 +200,8 @@ public abstract class ButtonDropTarget extends TextView
}
@Override
public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
mActive = supportsDrop(source, info);
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
mActive = supportsDrop(dragObject.dragSource, dragObject.dragInfo);
mDrawable.setColorFilter(null);
if (mCurrentColorAnim != null) {
mCurrentColorAnim.cancel();
@@ -209,6 +210,9 @@ public abstract class ButtonDropTarget extends TextView
setTextColor(mOriginalTextColor);
(mHideParentOnDisable ? ((ViewGroup) getParent()) : this)
.setVisibility(mActive ? View.VISIBLE : View.GONE);
mAccessibleDrag = options.isAccessibleDrag;
setOnClickListener(mAccessibleDrag ? this : null);
}
@Override
@@ -227,6 +231,7 @@ public abstract class ButtonDropTarget extends TextView
@Override
public void onDragEnd() {
mActive = false;
setOnClickListener(null);
}
/**
@@ -308,11 +313,6 @@ public abstract class ButtonDropTarget extends TextView
return to;
}
public void enableAccessibleDrag(boolean enable) {
mAccessibleDrag = enable;
setOnClickListener(enable ? this : null);
}
@Override
public void onClick(View v) {
mLauncher.getAccessibilityDelegate().handleAccessibleDrop(this, null, null);