mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Support drag and drop from Taskbar
- Long clicking a BubbleTextView in Taskbar will start a system drag and drop operation, setting the original view invisible meanwhile. - Defer gesture navigation when starting over a Taskbar item, and cancel any started gesture if a Taskbar drag and drop starts. Bug: 171917176 Change-Id: If5049071fbf1755f545ee937daa4edabd869f00d
This commit is contained in:
@@ -26,6 +26,7 @@ import android.animation.Animator;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -59,6 +60,7 @@ public class TaskbarController {
|
||||
private final TaskbarStateHandler mTaskbarStateHandler;
|
||||
private final TaskbarVisibilityController mTaskbarVisibilityController;
|
||||
private final TaskbarHotseatController mHotseatController;
|
||||
private final TaskbarDragController mDragController;
|
||||
|
||||
// Initialized in init().
|
||||
private WindowManager.LayoutParams mWindowLayoutParams;
|
||||
@@ -77,6 +79,7 @@ public class TaskbarController {
|
||||
createTaskbarVisibilityControllerCallbacks());
|
||||
mHotseatController = new TaskbarHotseatController(mLauncher,
|
||||
createTaskbarHotseatControllerCallbacks());
|
||||
mDragController = new TaskbarDragController(mLauncher);
|
||||
}
|
||||
|
||||
private TaskbarVisibilityControllerCallbacks createTaskbarVisibilityControllerCallbacks() {
|
||||
@@ -100,6 +103,11 @@ public class TaskbarController {
|
||||
public View.OnClickListener getItemOnClickListener() {
|
||||
return ItemClickHandler.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View.OnLongClickListener getItemOnLongClickListener() {
|
||||
return mDragController::startDragOnLongClick;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -226,6 +234,18 @@ public class TaskbarController {
|
||||
mHotseatController.onHotseatUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ev MotionEvent in screen coordinates.
|
||||
* @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
|
||||
*/
|
||||
public boolean isEventOverAnyTaskbarItem(MotionEvent ev) {
|
||||
return mTaskbarView.isEventOverAnyItem(ev);
|
||||
}
|
||||
|
||||
public boolean isDraggingItem() {
|
||||
return mTaskbarView.isDraggingItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the given View is in the same window as Taskbar.
|
||||
*/
|
||||
@@ -254,6 +274,7 @@ public class TaskbarController {
|
||||
*/
|
||||
protected interface TaskbarViewCallbacks {
|
||||
View.OnClickListener getItemOnClickListener();
|
||||
View.OnLongClickListener getItemOnLongClickListener();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user