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 17package com.android.launcher3; 18 19import android.content.Context; 20import android.graphics.PointF; 21import 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 */ 27public class AnotherWindowDropTarget implements DropTarget { 28 final Launcher mLauncher; 29 30 public AnotherWindowDropTarget (Context context) { mLauncher = (Launcher) context; } 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