• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
AnotherWindowDropTarget(Context context)30     public AnotherWindowDropTarget (Context context) { mLauncher = (Launcher) context; }
31 
32     @Override
isDropEnabled()33     public boolean isDropEnabled() { return true; }
34 
35     @Override
onDrop(DragObject dragObject)36     public void onDrop(DragObject dragObject) {
37         dragObject.deferDragViewCleanupPostAnimation = false;
38         LauncherModel.deleteItemFromDatabase(mLauncher, (ShortcutInfo) dragObject.dragInfo);
39     }
40 
41     @Override
onDragEnter(DragObject dragObject)42     public void onDragEnter(DragObject dragObject) {}
43 
44     @Override
onDragOver(DragObject dragObject)45     public void onDragOver(DragObject dragObject) {}
46 
47     @Override
onDragExit(DragObject dragObject)48     public void onDragExit(DragObject dragObject) {}
49 
50     @Override
onFlingToDelete(DragObject dragObject, PointF vec)51     public void onFlingToDelete(DragObject dragObject, PointF vec) {}
52 
53     @Override
acceptDrop(DragObject dragObject)54     public boolean acceptDrop(DragObject dragObject) {
55         return dragObject.dragInfo instanceof ShortcutInfo;
56     }
57 
58     @Override
prepareAccessibilityDrop()59     public void prepareAccessibilityDrop() {}
60 
61     // These methods are implemented in Views
62     @Override
getHitRectRelativeToDragLayer(Rect outRect)63     public void getHitRectRelativeToDragLayer(Rect outRect) {}
64 }
65