Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2d7fa3a authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Android (Google) Code Review
Browse files

Merge "Implement View.updateDragShadow"

parents 6e1a022f 4f639749
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36777,6 +36777,7 @@ package android.view {
    method public void stopNestedScroll();
    method public void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable);
    method public void unscheduleDrawable(android.graphics.drawable.Drawable);
    method public final void updateDragShadow(android.view.View.DragShadowBuilder);
    method protected boolean verifyDrawable(android.graphics.drawable.Drawable);
    method public boolean willNotCacheDrawing();
    method public boolean willNotDraw();
+1 −0
Original line number Diff line number Diff line
@@ -39100,6 +39100,7 @@ package android.view {
    method public void stopNestedScroll();
    method public void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable);
    method public void unscheduleDrawable(android.graphics.drawable.Drawable);
    method public final void updateDragShadow(android.view.View.DragShadowBuilder);
    method protected boolean verifyDrawable(android.graphics.drawable.Drawable);
    method public boolean willNotCacheDrawing();
    method public boolean willNotDraw();
+36 −10
Original line number Diff line number Diff line
@@ -19992,19 +19992,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            Log.d(VIEW_LOG_TAG, "drag shadow: width=" + shadowSize.x + " height=" + shadowSize.y
                    + " shadowX=" + shadowTouchPoint.x + " shadowY=" + shadowTouchPoint.y);
        }
        Surface surface = new Surface();
        if (mAttachInfo.mDragSurface != null) {
            mAttachInfo.mDragSurface.release();
        }
        mAttachInfo.mDragSurface = new Surface();
        try {
            mAttachInfo.mDragToken = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
                    flags, shadowSize.x, shadowSize.y, surface);
                    flags, shadowSize.x, shadowSize.y, mAttachInfo.mDragSurface);
            if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token="
                    + mAttachInfo.mDragToken + " surface=" + surface);
                    + mAttachInfo.mDragToken + " surface=" + mAttachInfo.mDragSurface);
            if (mAttachInfo.mDragToken != null) {
                Canvas canvas = surface.lockCanvas(null);
                Canvas canvas = mAttachInfo.mDragSurface.lockCanvas(null);
                try {
                    canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                    shadowBuilder.onDrawShadow(canvas);
                } finally {
                    surface.unlockCanvasAndPost(canvas);
                    mAttachInfo.mDragSurface.unlockCanvasAndPost(canvas);
                }
                final ViewRootImpl root = getViewRootImpl();
@@ -20019,14 +20022,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        shadowSize.x, shadowSize.y,
                        shadowTouchPoint.x, shadowTouchPoint.y, data);
                if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "performDrag returned " + okay);
                // Off and running!  Release our local surface instance; the drag
                // shadow surface is now managed by the system process.
                surface.release();
            }
        } catch (Exception e) {
            Log.e(VIEW_LOG_TAG, "Unable to initiate drag", e);
            surface.destroy();
            mAttachInfo.mDragSurface.destroy();
            mAttachInfo.mDragSurface = null;
        }
        return okay;
@@ -20065,6 +20065,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    public final void updateDragShadow(DragShadowBuilder shadowBuilder) {
        if (ViewDebug.DEBUG_DRAG) {
            Log.d(VIEW_LOG_TAG, "updateDragShadow");
        }
        if (mAttachInfo.mDragToken != null) {
            try {
                Canvas canvas = mAttachInfo.mDragSurface.lockCanvas(null);
                try {
                    canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                    shadowBuilder.onDrawShadow(canvas);
                } finally {
                    mAttachInfo.mDragSurface.unlockCanvasAndPost(canvas);
                }
            } catch (Exception e) {
                Log.e(VIEW_LOG_TAG, "Unable to update drag shadow", e);
            }
        } else {
            Log.e(VIEW_LOG_TAG, "No active drag");
        }
    }
    /**
     * Starts a move from {startX, startY}, the amount of the movement will be the offset
     * between {startX, startY} and the new cursor positon.
@@ -22355,6 +22376,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        IBinder mDragToken;
        /**
         * The drag shadow surface for the current drag operation.
         */
        public Surface mDragSurface;
        /**
         * Creates a new set of attachment information with the specified
         * events handler and thread.
+4 −0
Original line number Diff line number Diff line
@@ -5376,6 +5376,10 @@ public final class ViewRootImpl implements ViewParent,
                if (what == DragEvent.ACTION_DRAG_ENDED) {
                    setLocalDragState(null);
                    mAttachInfo.mDragToken = null;
                    if (mAttachInfo.mDragSurface != null) {
                        mAttachInfo.mDragSurface.release();
                        mAttachInfo.mDragSurface = null;
                    }
                }
            }
        }