diff options
author | Vadim Tryshev <vadimt@google.com> | 2015-07-08 13:40:14 -0700 |
---|---|---|
committer | Vadim Tryshev <vadimt@google.com> | 2015-07-30 13:06:25 -0700 |
commit | d6c8e7eeb13094ea1349897663ae28d8a3bf2773 (patch) | |
tree | b16f5c30f643136be27736847372fb50fd38d41a /src/com/android/launcher3/AnotherWindowDropTarget.java | |
parent | 1992d126f41268b8d55313d6de4d97ed05382cbf (diff) | |
download | android_packages_apps_Trebuchet-d6c8e7eeb13094ea1349897663ae28d8a3bf2773.tar.gz android_packages_apps_Trebuchet-d6c8e7eeb13094ea1349897663ae28d8a3bf2773.tar.bz2 android_packages_apps_Trebuchet-d6c8e7eeb13094ea1349897663ae28d8a3bf2773.zip |
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
Diffstat (limited to 'src/com/android/launcher3/AnotherWindowDropTarget.java')
-rw-r--r-- | src/com/android/launcher3/AnotherWindowDropTarget.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/com/android/launcher3/AnotherWindowDropTarget.java b/src/com/android/launcher3/AnotherWindowDropTarget.java new file mode 100644 index 000000000..aff36ae51 --- /dev/null +++ b/src/com/android/launcher3/AnotherWindowDropTarget.java @@ -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; } +} |