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

Commit c6f25145 authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

Settings: Fix TouchInterceptor widget on tablets



Fix the x position of the dragging view to align to the item to be dragged. Actually, dragging view
is aligned to CENTER and is shown in the middle of the screen in tablets (or devices with tablets
fragments layouts)

Change-Id: I7a061df5a3d297c567103447555c6ecf4f3d836f
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent 5099b2d1
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -86,13 +86,17 @@ public class TouchInterceptor extends ListView {
                    // The dragger icon itself is quite small, so pretend the
                    // touch area is bigger
                    if (x < r.right * 2) {
                        // Fix x position while dragging
                        int[] itemPos = new int[2];
                        item.getLocationOnScreen(itemPos);

                        item.setDrawingCacheEnabled(true);
                        // Create a copy of the drawing cache so that it does
                        // not get recycled
                        // by the framework when the list tries to clean up
                        // memory
                        Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
                        startDragging(bitmap, y);
                        startDragging(bitmap, itemPos[0], y);
                        mDragPos = itemnum;
                        mFirstDragPos = mDragPos;
                        mHeight = getHeight();
@@ -292,12 +296,12 @@ public class TouchInterceptor extends ListView {
        return super.onTouchEvent(ev);
    }

    private void startDragging(Bitmap bm, int y) {
    private void startDragging(Bitmap bm, int x, int y) {
        stopDragging();

        mWindowParams = new WindowManager.LayoutParams();
        mWindowParams.gravity = Gravity.TOP;
        mWindowParams.x = 0;
        mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
        mWindowParams.x = x;
        mWindowParams.y = y - mDragPoint + mCoordOffset;

        mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;