Code to enable dragging to System UI shelf.

This CL doesn’t let the new code run, it’s under a compile-time flag,
and the behavior should be same as before.

The change introduces a concept of a DragDriver, which encapsulates
behavior of the existing DND (InternalDragDriver) or the framework-
driven DND (SystemDragDriver).

An instance of DragDriver gets created by DragController for the time
while a DND operation is in progress, and it takes care of translating
DND events for DragController.

Also did some cleanups, like removing meaningless fields etc.

Plans for future: keep working in Burnaby, and:
* Perhaps, better separate DragDriver from DragController
* Detect fling gesture for system DND
* Look at accessibility
* Polish animations and appearance
* Fix dragging from folders
* Support cancelling DND

Then, it will become possible to enable new dragging (based on Android
version).

Bug: 22028725
Change-Id: I41b40e9d512d83937f5b101ac8e3e8e7e807c269
This commit is contained in:
Vadim Tryshev
2015-07-08 13:40:14 -07:00
parent 1992d126f4
commit d6c8e7eeb1
6 changed files with 458 additions and 132 deletions

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
/**
* Drop target used when another window (i.e. another process) has accepted a global system drag.
* If the accepted item was a shortcut, we delete it from Launcher.
*/
public class AnotherWindowDropTarget implements DropTarget {
final Launcher mLauncher;
AnotherWindowDropTarget (Context context) { mLauncher = (Launcher) context; }
@Override
public boolean isDropEnabled() { return true; }
@Override
public void onDrop(DragObject dragObject) {
dragObject.deferDragViewCleanupPostAnimation = false;
LauncherModel.deleteItemFromDatabase(mLauncher, (ShortcutInfo) dragObject.dragInfo);
}
@Override
public void onDragEnter(DragObject dragObject) {}
@Override
public void onDragOver(DragObject dragObject) {}
@Override
public void onDragExit(DragObject dragObject) {}
@Override
public void onFlingToDelete(DragObject dragObject, PointF vec) {}
@Override
public boolean acceptDrop(DragObject dragObject) {
return dragObject.dragInfo instanceof ShortcutInfo;
}
@Override
public void prepareAccessibilityDrop() {}
// These methods are implemented in Views
@Override
public void getHitRectRelativeToDragLayer(Rect outRect) {}
@Override
public void getLocationInDragLayer(int[] loc) {}
@Override
public int getLeft() { return 0; }
@Override
public int getTop() { return 0; }
}