Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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.systemui.recents.views; |
| 18 | |
Winson | c694a50 | 2016-03-10 16:35:03 -0800 | [diff] [blame] | 19 | import android.app.ActivityManager; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 20 | import android.graphics.Point; |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 21 | import android.graphics.Rect; |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 22 | import android.view.InputDevice; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 23 | import android.view.MotionEvent; |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 24 | import android.view.PointerIcon; |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 25 | import android.view.View; |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 26 | import android.view.ViewConfiguration; |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 27 | import android.view.ViewDebug; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 28 | |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 29 | import com.android.internal.policy.DividerSnapAlgorithm; |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 30 | import com.android.systemui.recents.Recents; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 31 | import com.android.systemui.recents.events.EventBus; |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 32 | import com.android.systemui.recents.events.activity.ConfigurationChangedEvent; |
Matthew Ng | 3975de5 | 2016-10-21 14:53:18 -0700 | [diff] [blame] | 33 | import com.android.systemui.recents.events.activity.HideRecentsEvent; |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 34 | import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent; |
Winson | 9b00139 | 2016-04-08 14:54:02 -0700 | [diff] [blame] | 35 | import com.android.systemui.recents.events.ui.HideIncompatibleAppOverlayEvent; |
| 36 | import com.android.systemui.recents.events.ui.ShowIncompatibleAppOverlayEvent; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 37 | import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 38 | import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent; |
| 39 | import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 40 | import com.android.systemui.recents.events.ui.dragndrop.DragStartInitializeDropTargetsEvent; |
Winson | d759a71 | 2015-11-30 18:43:43 -0800 | [diff] [blame] | 41 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Winson Chung | 6519c1b | 2017-10-13 17:12:56 -0700 | [diff] [blame] | 42 | import com.android.systemui.shared.recents.model.Task; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 43 | |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 44 | import java.util.ArrayList; |
| 45 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 46 | /** |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 47 | * Handles touch events for a RecentsView. |
| 48 | */ |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 49 | public class RecentsViewTouchHandler { |
| 50 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 51 | private RecentsView mRv; |
| 52 | |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 53 | @ViewDebug.ExportedProperty(deepExport=true, prefix="drag_task") |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 54 | private Task mDragTask; |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 55 | @ViewDebug.ExportedProperty(deepExport=true, prefix="drag_task_view_") |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 56 | private TaskView mTaskView; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 57 | |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 58 | @ViewDebug.ExportedProperty(category="recents") |
Winson | 479f744 | 2015-11-25 15:16:27 -0800 | [diff] [blame] | 59 | private Point mTaskViewOffset = new Point(); |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 60 | @ViewDebug.ExportedProperty(category="recents") |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 61 | private Point mDownPos = new Point(); |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 62 | @ViewDebug.ExportedProperty(category="recents") |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 63 | private boolean mDragRequested; |
Winson | 231bc9c | 2016-02-09 12:31:00 -0800 | [diff] [blame] | 64 | @ViewDebug.ExportedProperty(category="recents") |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 65 | private boolean mIsDragging; |
| 66 | private float mDragSlop; |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 67 | private int mDeviceId = -1; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 68 | |
| 69 | private DropTarget mLastDropTarget; |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 70 | private DividerSnapAlgorithm mDividerSnapAlgorithm; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 71 | private ArrayList<DropTarget> mDropTargets = new ArrayList<>(); |
Winson Chung | 6519c1b | 2017-10-13 17:12:56 -0700 | [diff] [blame] | 72 | private ArrayList<DockState> mVisibleDockStates = new ArrayList<>(); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 73 | |
| 74 | public RecentsViewTouchHandler(RecentsView rv) { |
| 75 | mRv = rv; |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 76 | mDragSlop = ViewConfiguration.get(rv.getContext()).getScaledTouchSlop(); |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 77 | updateSnapAlgorithm(); |
| 78 | } |
| 79 | |
| 80 | private void updateSnapAlgorithm() { |
| 81 | Rect insets = new Rect(); |
| 82 | SystemServicesProxy.getInstance(mRv.getContext()).getStableInsets(insets); |
| 83 | mDividerSnapAlgorithm = DividerSnapAlgorithm.create(mRv.getContext(), insets); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 86 | /** |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 87 | * Registers a new drop target for the current drag only. |
| 88 | */ |
| 89 | public void registerDropTargetForCurrentDrag(DropTarget target) { |
| 90 | mDropTargets.add(target); |
| 91 | } |
| 92 | |
| 93 | /** |
Winson | 036693c | 2016-01-14 17:16:06 -0800 | [diff] [blame] | 94 | * Returns the set of visible dock states for this current drag. |
| 95 | */ |
Winson Chung | 6519c1b | 2017-10-13 17:12:56 -0700 | [diff] [blame] | 96 | public ArrayList<DockState> getVisibleDockStates() { |
Winson | 036693c | 2016-01-14 17:16:06 -0800 | [diff] [blame] | 97 | return mVisibleDockStates; |
| 98 | } |
| 99 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 100 | /** Touch preprocessing for handling below */ |
| 101 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 102 | return handleTouchEvent(ev) || mDragRequested; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /** Handles touch events once we have intercepted them */ |
| 106 | public boolean onTouchEvent(MotionEvent ev) { |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 107 | handleTouchEvent(ev); |
Winson Chung | 2cf6ad8 | 2017-11-09 17:36:59 -0800 | [diff] [blame] | 108 | if (ev.getAction() == MotionEvent.ACTION_UP && mRv.getStack().getTaskCount() == 0) { |
Matthew Ng | 3975de5 | 2016-10-21 14:53:18 -0700 | [diff] [blame] | 109 | EventBus.getDefault().send(new HideRecentsEvent(false, true)); |
| 110 | } |
| 111 | return true; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /**** Events ****/ |
| 115 | |
| 116 | public final void onBusEvent(DragStartEvent event) { |
Winson | d759a71 | 2015-11-30 18:43:43 -0800 | [diff] [blame] | 117 | SystemServicesProxy ssp = Recents.getSystemServices(); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 118 | mRv.getParent().requestDisallowInterceptTouchEvent(true); |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 119 | mDragRequested = true; |
| 120 | // We defer starting the actual drag handling until the user moves past the drag slop |
| 121 | mIsDragging = false; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 122 | mDragTask = event.task; |
| 123 | mTaskView = event.taskView; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 124 | mDropTargets.clear(); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 125 | |
Winson | 479f744 | 2015-11-25 15:16:27 -0800 | [diff] [blame] | 126 | int[] recentsViewLocation = new int[2]; |
| 127 | mRv.getLocationInWindow(recentsViewLocation); |
| 128 | mTaskViewOffset.set(mTaskView.getLeft() - recentsViewLocation[0] + event.tlOffset.x, |
| 129 | mTaskView.getTop() - recentsViewLocation[1] + event.tlOffset.y); |
Matthew Ng | b7035f3 | 2017-01-19 11:04:50 -0800 | [diff] [blame] | 130 | |
| 131 | // Change space coordinates relative to the view to RecentsView when user initiates a touch |
| 132 | if (event.isUserTouchInitiated) { |
| 133 | float x = mDownPos.x - mTaskViewOffset.x; |
| 134 | float y = mDownPos.y - mTaskViewOffset.y; |
| 135 | mTaskView.setTranslationX(x); |
| 136 | mTaskView.setTranslationY(y); |
| 137 | } |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 138 | |
Winson | 036693c | 2016-01-14 17:16:06 -0800 | [diff] [blame] | 139 | mVisibleDockStates.clear(); |
Erik Wolsheimer | 9be3a06 | 2017-05-31 14:59:57 -0700 | [diff] [blame] | 140 | if (ActivityManager.supportsMultiWindow(mRv.getContext()) && !ssp.hasDockedTask() |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 141 | && mDividerSnapAlgorithm.isSplitScreenFeasible()) { |
Winson | f21c3dac | 2016-04-13 18:24:12 -0700 | [diff] [blame] | 142 | Recents.logDockAttempt(mRv.getContext(), event.task.getTopComponent(), |
| 143 | event.task.resizeMode); |
Winson | 931845f | 2016-02-24 19:38:41 -0800 | [diff] [blame] | 144 | if (!event.task.isDockable) { |
Winson | 9b00139 | 2016-04-08 14:54:02 -0700 | [diff] [blame] | 145 | EventBus.getDefault().send(new ShowIncompatibleAppOverlayEvent()); |
Winson | 931845f | 2016-02-24 19:38:41 -0800 | [diff] [blame] | 146 | } else { |
| 147 | // Add the dock state drop targets (these take priority) |
Winson Chung | 6519c1b | 2017-10-13 17:12:56 -0700 | [diff] [blame] | 148 | DockState[] dockStates = Recents.getConfiguration() |
Matthew Ng | b7035f3 | 2017-01-19 11:04:50 -0800 | [diff] [blame] | 149 | .getDockStatesForCurrentOrientation(); |
Winson Chung | 6519c1b | 2017-10-13 17:12:56 -0700 | [diff] [blame] | 150 | for (DockState dockState : dockStates) { |
Winson | 931845f | 2016-02-24 19:38:41 -0800 | [diff] [blame] | 151 | registerDropTargetForCurrentDrag(dockState); |
Winson | 99ef458 | 2016-04-18 16:57:27 -0700 | [diff] [blame] | 152 | dockState.update(mRv.getContext()); |
Winson | 931845f | 2016-02-24 19:38:41 -0800 | [diff] [blame] | 153 | mVisibleDockStates.add(dockState); |
| 154 | } |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | |
| 158 | // Request other drop targets to register themselves |
Winson | d952961 | 2016-01-28 13:29:49 -0800 | [diff] [blame] | 159 | EventBus.getDefault().send(new DragStartInitializeDropTargetsEvent(event.task, |
| 160 | event.taskView, this)); |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 161 | if (mDeviceId != -1) { |
Winson Chung | df42455 | 2017-03-03 11:17:14 -0800 | [diff] [blame] | 162 | InputDevice device = InputDevice.getDevice(mDeviceId); |
| 163 | if (device != null) { |
| 164 | device.setPointerType(PointerIcon.TYPE_GRABBING); |
| 165 | } |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 166 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | public final void onBusEvent(DragEndEvent event) { |
Winson | 9b00139 | 2016-04-08 14:54:02 -0700 | [diff] [blame] | 170 | if (!mDragTask.isDockable) { |
| 171 | EventBus.getDefault().send(new HideIncompatibleAppOverlayEvent()); |
| 172 | } |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 173 | mDragRequested = false; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 174 | mDragTask = null; |
| 175 | mTaskView = null; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 176 | mLastDropTarget = null; |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 179 | public final void onBusEvent(ConfigurationChangedEvent event) { |
Winson | 9832f8f | 2016-04-26 11:30:59 -0700 | [diff] [blame] | 180 | if (event.fromDisplayDensityChange || event.fromDeviceOrientationChange) { |
Jorim Jaggi | 25160db | 2016-04-18 16:03:36 -0700 | [diff] [blame] | 181 | updateSnapAlgorithm(); |
| 182 | } |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 185 | void cancelStackActionButtonClick() { |
| 186 | mRv.getStackActionButton().setPressed(false); |
| 187 | } |
| 188 | |
| 189 | private boolean isWithinStackActionButton(float x, float y) { |
| 190 | Rect rect = mRv.getStackActionButtonBoundsFromStackLayout(); |
| 191 | return mRv.getStackActionButton().getVisibility() == View.VISIBLE && |
| 192 | mRv.getStackActionButton().pointInView(x - rect.left, y - rect.top, 0 /* slop */); |
| 193 | } |
| 194 | |
| 195 | private void changeStackActionButtonDrawableHotspot(float x, float y) { |
| 196 | Rect rect = mRv.getStackActionButtonBoundsFromStackLayout(); |
| 197 | mRv.getStackActionButton().drawableHotspotChanged(x - rect.left, y - rect.top); |
| 198 | } |
| 199 | |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 200 | /** |
| 201 | * Handles dragging touch events |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 202 | */ |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 203 | private boolean handleTouchEvent(MotionEvent ev) { |
Jorim Jaggi | a20eeda | 2016-04-21 00:07:29 -0700 | [diff] [blame] | 204 | int action = ev.getActionMasked(); |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 205 | boolean consumed = false; |
| 206 | float evX = ev.getX(); |
| 207 | float evY = ev.getY(); |
Jorim Jaggi | a20eeda | 2016-04-21 00:07:29 -0700 | [diff] [blame] | 208 | switch (action) { |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 209 | case MotionEvent.ACTION_DOWN: |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 210 | mDownPos.set((int) evX, (int) evY); |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 211 | mDeviceId = ev.getDeviceId(); |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 212 | |
| 213 | if (isWithinStackActionButton(evX, evY)) { |
| 214 | changeStackActionButtonDrawableHotspot(evX, evY); |
| 215 | mRv.getStackActionButton().setPressed(true); |
| 216 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 217 | break; |
| 218 | case MotionEvent.ACTION_MOVE: { |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 219 | float x = evX - mTaskViewOffset.x; |
| 220 | float y = evY - mTaskViewOffset.y; |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 221 | |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 222 | if (mRv.getStackActionButton().isPressed() && isWithinStackActionButton(evX, evY)) { |
| 223 | changeStackActionButtonDrawableHotspot(evX, evY); |
| 224 | } |
| 225 | |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 226 | if (mDragRequested) { |
| 227 | if (!mIsDragging) { |
| 228 | mIsDragging = Math.hypot(evX - mDownPos.x, evY - mDownPos.y) > mDragSlop; |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 229 | } |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 230 | if (mIsDragging) { |
| 231 | int width = mRv.getMeasuredWidth(); |
| 232 | int height = mRv.getMeasuredHeight(); |
| 233 | |
| 234 | DropTarget currentDropTarget = null; |
| 235 | |
| 236 | // Give priority to the current drop target to retain the touch handling |
| 237 | if (mLastDropTarget != null) { |
| 238 | if (mLastDropTarget.acceptsDrop((int) evX, (int) evY, width, height, |
Winson | 08deff0 | 2016-08-05 13:58:31 -0700 | [diff] [blame] | 239 | mRv.mSystemInsets, true /* isCurrentTarget */)) { |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 240 | currentDropTarget = mLastDropTarget; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | // Otherwise, find the next target to handle this event |
| 245 | if (currentDropTarget == null) { |
| 246 | for (DropTarget target : mDropTargets) { |
| 247 | if (target.acceptsDrop((int) evX, (int) evY, width, height, |
Winson | 08deff0 | 2016-08-05 13:58:31 -0700 | [diff] [blame] | 248 | mRv.mSystemInsets, false /* isCurrentTarget */)) { |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 249 | currentDropTarget = target; |
| 250 | break; |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | if (mLastDropTarget != currentDropTarget) { |
| 255 | mLastDropTarget = currentDropTarget; |
| 256 | EventBus.getDefault().send(new DragDropTargetChangedEvent(mDragTask, |
| 257 | currentDropTarget)); |
| 258 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 259 | } |
Winson | 479f744 | 2015-11-25 15:16:27 -0800 | [diff] [blame] | 260 | mTaskView.setTranslationX(x); |
| 261 | mTaskView.setTranslationY(y); |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 262 | } |
| 263 | break; |
| 264 | } |
| 265 | case MotionEvent.ACTION_UP: |
| 266 | case MotionEvent.ACTION_CANCEL: { |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 267 | if (mRv.getStackActionButton().isPressed() && isWithinStackActionButton(evX, evY)) { |
| 268 | EventBus.getDefault().send(new DismissAllTaskViewsEvent()); |
| 269 | consumed = true; |
| 270 | } |
| 271 | cancelStackActionButtonClick(); |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 272 | if (mDragRequested) { |
Jorim Jaggi | f300bad | 2016-04-25 13:00:27 -0700 | [diff] [blame] | 273 | boolean cancelled = action == MotionEvent.ACTION_CANCEL; |
| 274 | if (cancelled) { |
| 275 | EventBus.getDefault().send(new DragDropTargetChangedEvent(mDragTask, null)); |
| 276 | } |
Winson | 479f744 | 2015-11-25 15:16:27 -0800 | [diff] [blame] | 277 | EventBus.getDefault().send(new DragEndEvent(mDragTask, mTaskView, |
Jorim Jaggi | f300bad | 2016-04-25 13:00:27 -0700 | [diff] [blame] | 278 | !cancelled ? mLastDropTarget : null)); |
Winson | 09d8a18 | 2015-10-10 14:50:23 -0700 | [diff] [blame] | 279 | break; |
| 280 | } |
Winson | 131d53a | 2016-06-14 13:51:59 -0700 | [diff] [blame] | 281 | mDeviceId = -1; |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
Matthew Ng | 9e177f0 | 2017-09-21 11:10:32 -0700 | [diff] [blame] | 284 | return consumed; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 285 | } |
| 286 | } |