Refactors ButtonDropTarget to add extension data

Also fixes a bug where DeleteDropTarget was logging Remove instead of
Cancel.

Bug: 78793340
Test: Enable verbose logging and manual test
Change-Id: I0f0cfff070eab003ebb745292630bc6ce3243f4d
This commit is contained in:
Mehdi Alizadeh
2018-05-01 19:26:05 -07:00
parent 954157a228
commit bda47cf925
5 changed files with 32 additions and 11 deletions

View File

@@ -24,10 +24,14 @@ import android.view.View;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.logging.LoggerUtils;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
public class DeleteDropTarget extends ButtonDropTarget {
private int mControlType = ControlType.DEFAULT_CONTROLTYPE;
public DeleteDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -49,6 +53,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
super.onDragStart(dragObject, options);
setTextBasedOnDragSource(dragObject.dragInfo);
setControlTypeBasedOnDragSource(dragObject.dragInfo);
}
/**
@@ -83,6 +88,14 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
}
/**
* Set mControlType depending on the drag item.
*/
private void setControlTypeBasedOnDragSource(ItemInfo item) {
mControlType = item.id != ItemInfo.NO_ID ? ControlType.REMOVE_TARGET
: ControlType.CANCEL_TARGET;
}
@Override
public void completeDrop(DragObject d) {
ItemInfo item = d.dragInfo;
@@ -106,7 +119,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
@Override
public int getControlTypeForLogging() {
return ControlType.REMOVE_TARGET;
public Target getDropTargetForLogging() {
Target t = LoggerUtils.newTarget(Target.Type.CONTROL);
t.controlType = mControlType;
return t;
}
}