Vadim Tryshev | d6c8e7e | 2015-07-08 13:40:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.launcher3; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.graphics.PointF; |
| 21 | import android.graphics.Rect; |
| 22 | |
| 23 | /** |
| 24 | * Drop target used when another window (i.e. another process) has accepted a global system drag. |
| 25 | * If the accepted item was a shortcut, we delete it from Launcher. |
| 26 | */ |
| 27 | public class AnotherWindowDropTarget implements DropTarget { |
| 28 | final Launcher mLauncher; |
| 29 | |
Vadim Tryshev | fedca43 | 2015-08-19 17:55:02 -0700 | [diff] [blame^] | 30 | public AnotherWindowDropTarget (Context context) { mLauncher = (Launcher) context; } |
Vadim Tryshev | d6c8e7e | 2015-07-08 13:40:14 -0700 | [diff] [blame] | 31 | |
| 32 | @Override |
| 33 | public boolean isDropEnabled() { return true; } |
| 34 | |
| 35 | @Override |
| 36 | public void onDrop(DragObject dragObject) { |
| 37 | dragObject.deferDragViewCleanupPostAnimation = false; |
| 38 | LauncherModel.deleteItemFromDatabase(mLauncher, (ShortcutInfo) dragObject.dragInfo); |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public void onDragEnter(DragObject dragObject) {} |
| 43 | |
| 44 | @Override |
| 45 | public void onDragOver(DragObject dragObject) {} |
| 46 | |
| 47 | @Override |
| 48 | public void onDragExit(DragObject dragObject) {} |
| 49 | |
| 50 | @Override |
| 51 | public void onFlingToDelete(DragObject dragObject, PointF vec) {} |
| 52 | |
| 53 | @Override |
| 54 | public boolean acceptDrop(DragObject dragObject) { |
| 55 | return dragObject.dragInfo instanceof ShortcutInfo; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public void prepareAccessibilityDrop() {} |
| 60 | |
| 61 | // These methods are implemented in Views |
| 62 | @Override |
| 63 | public void getHitRectRelativeToDragLayer(Rect outRect) {} |
| 64 | |
| 65 | @Override |
| 66 | public void getLocationInDragLayer(int[] loc) {} |
| 67 | |
| 68 | @Override |
| 69 | public int getLeft() { return 0; } |
| 70 | |
| 71 | @Override |
| 72 | public int getTop() { return 0; } |
| 73 | } |