Actually draw the drag thumbnail
Now sets the layer and thumbnail dimensions correctly. Also removed the
leftover bits of the now-replaced thumbnail measurement/drawing mechanism.
Fixes bug 3077339
Change-Id: I02983648e0a7ce2ce5fee10825f744e20a3a5b8d
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7ee360d..8e4591a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2037,8 +2037,6 @@
*
*/
boolean mCanAcceptDrop;
- private int mThumbnailWidth;
- private int mThumbnailHeight;
/**
* Simple constructor to use when creating a view from code.
@@ -9921,10 +9919,14 @@
throw new IllegalStateException("Drag thumb dimensions must not be negative");
}
+ if (ViewDebug.DEBUG_DRAG) {
+ Log.d(VIEW_LOG_TAG, "drag thumb: width=" + thumbSize.x + " height=" + thumbSize.y
+ + " thumbX=" + thumbTouchPoint.x + " thumbY=" + thumbTouchPoint.y);
+ }
Surface surface = new Surface();
try {
IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
- myWindowOnly, mThumbnailWidth, mThumbnailHeight, surface);
+ myWindowOnly, thumbSize.x, thumbSize.y, surface);
if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token
+ " surface=" + surface);
if (token != null) {
@@ -9951,53 +9953,6 @@
return okay;
}
- private void measureThumbnail() {
- mPrivateFlags &= ~MEASURED_DIMENSION_SET;
-
- onMeasureDragThumbnail();
-
- // flag not set, setDragThumbnailDimension() was not invoked, we raise
- // an exception to warn the developer
- if ((mPrivateFlags & MEASURED_DIMENSION_SET) != MEASURED_DIMENSION_SET) {
- throw new IllegalStateException("onMeasureDragThumbnail() did not set the"
- + " measured dimension by calling setDragThumbnailDimension()");
- }
-
- if (ViewDebug.DEBUG_DRAG) {
- Log.d(VIEW_LOG_TAG, "Drag thumb measured: w=" + mThumbnailWidth
- + " h=" + mThumbnailHeight);
- }
- }
-
- /**
- * The View must call this method from onMeasureDragThumbnail() in order to
- * specify the dimensions of the drag thumbnail image.
- *
- * @param width The desired thumbnail width.
- * @param height The desired thumbnail height.
- */
- protected final void setDragThumbnailDimension(int width, int height) {
- mPrivateFlags |= MEASURED_DIMENSION_SET;
- mThumbnailWidth = width;
- mThumbnailHeight = height;
- }
-
- /**
- * The default implementation specifies a drag thumbnail that matches the
- * View's current size and appearance.
- */
- protected void onMeasureDragThumbnail() {
- setDragThumbnailDimension(getWidth(), getHeight());
- }
-
- /**
- * The default implementation just draws the current View appearance as the thumbnail
- * @param canvas
- */
- protected void onDrawDragThumbnail(Canvas canvas) {
- draw(canvas);
- }
-
/**
* Drag-and-drop event dispatch. The event.getAction() verb is one of the DragEvent
* constants DRAG_STARTED_EVENT, DRAG_EVENT, DROP_EVENT, and DRAG_ENDED_EVENT.