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

Commit 3e874741 authored by Winson's avatar Winson
Browse files

Improving drag and drop animations.

- Expanding drop targets to indicate the size of the to-be docked window
- Fixing animation when dropping task
- Fixing drag view z order
- Fixes issue where the dock divider position in WM is not exact
- Requiring user to move the slop distance before accepting drops

Change-Id: I2f6eab504db7126c19e0c680629e89a39e7512e3
parent 5d125f2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1333,9 +1333,9 @@ public interface WindowManagerPolicy {
     * Calculates the stable insets without running a layout.
     *
     * @param displayRotation the current display rotation
     * @param outInsets the insets to return
     * @param displayWidth the current display width
     * @param displayHeight the current display height
     * @param outInsets the insets to return
     */
    public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
            Rect outInsets);
+2 −6
Original line number Diff line number Diff line
@@ -209,12 +209,8 @@ public class DividerSnapAlgorithm {
    }

    private void addMiddleTarget(boolean isHorizontalDivision) {
        int start = isHorizontalDivision ? mInsets.top : mInsets.left;
        int end = isHorizontalDivision
                ? mDisplayHeight - mInsets.bottom
                : mDisplayWidth - mInsets.right;
        mTargets.add(new SnapTarget(start + (end - start) / 2 - mDividerSize / 2,
                SnapTarget.FLAG_NONE));
        mTargets.add(new SnapTarget(DockedDividerUtils.calculateMiddlePosition(isHorizontalDivision,
                mInsets, mDisplayWidth, mDisplayHeight, mDividerSize), SnapTarget.FLAG_NONE));
    }

    public SnapTarget getMiddleTarget() {
+46 −0
Original line number Diff line number Diff line
@@ -19,6 +19,11 @@ package com.android.internal.policy;
import android.graphics.Rect;
import android.view.WindowManager;

import static android.view.WindowManager.DOCKED_BOTTOM;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.DOCKED_TOP;

/**
 * Utility functions for docked stack divider used by both window manager and System UI.
 *
@@ -71,4 +76,45 @@ public class DockedDividerUtils {
                return 0;
        }
    }

    public static int calculateMiddlePosition(boolean isHorizontalDivision, Rect insets,
            int displayWidth, int displayHeight, int dividerSize) {
        int start = isHorizontalDivision ? insets.top : insets.left;
        int end = isHorizontalDivision
                ? displayHeight - insets.bottom
                : displayWidth - insets.right;
        return start + (end - start) / 2 - dividerSize / 2;
    }

    public static int getDockSideFromCreatedMode(boolean dockOnTopOrLeft,
            boolean isHorizontalDivision) {
        if (dockOnTopOrLeft) {
            if (isHorizontalDivision) {
                return DOCKED_TOP;
            } else {
                return DOCKED_LEFT;
            }
        } else {
            if (isHorizontalDivision) {
                return DOCKED_BOTTOM;
            } else {
                return DOCKED_RIGHT;
            }
        }
    }

    public static int invertDockSide(int dockSide) {
        switch (dockSide) {
            case WindowManager.DOCKED_LEFT:
                return WindowManager.DOCKED_RIGHT;
            case WindowManager.DOCKED_TOP:
                return WindowManager.DOCKED_BOTTOM;
            case WindowManager.DOCKED_RIGHT:
                return WindowManager.DOCKED_LEFT;
            case WindowManager.DOCKED_BOTTOM:
                return WindowManager.DOCKED_TOP;
            default:
                return WindowManager.DOCKED_INVALID;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ public class RecentsConfiguration {
        } else {
            // In portrait, the search bar appears on the top (which already has the inset)
            int top = searchBarBounds.isEmpty() ? topInset : 0;
            taskStackBounds.set(windowBounds.left, searchBarBounds.bottom + top,
            taskStackBounds.set(windowBounds.left, windowBounds.top + searchBarBounds.bottom + top,
                    windowBounds.right - rightInset, windowBounds.bottom);
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.recents.views.DropTarget;
 */
public class DragDropTargetChangedEvent extends EventBus.Event {

    // The task that is currently being dragged
    public final Task task;
    public final DropTarget dropTarget;

Loading