Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [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.systemui.stackdivider; |
| 18 | |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 19 | import static android.view.PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW; |
| 20 | import static android.view.PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW; |
| 21 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 22 | import android.animation.Animator; |
| 23 | import android.animation.AnimatorListenerAdapter; |
| 24 | import android.animation.ValueAnimator; |
| 25 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
| 26 | import android.annotation.Nullable; |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 27 | import android.app.ActivityManager.StackId; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 28 | import android.content.Context; |
| 29 | import android.content.res.Configuration; |
| 30 | import android.graphics.Rect; |
| 31 | import android.graphics.Region.Op; |
Filip Gruszczynski | f6d8e9e | 2015-11-12 13:39:20 -0800 | [diff] [blame] | 32 | import android.hardware.display.DisplayManager; |
Jorim Jaggi | 88afd02 | 2016-02-24 21:11:08 -0500 | [diff] [blame] | 33 | import android.os.Bundle; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 34 | import android.util.AttributeSet; |
Filip Gruszczynski | f6d8e9e | 2015-11-12 13:39:20 -0800 | [diff] [blame] | 35 | import android.view.Display; |
| 36 | import android.view.DisplayInfo; |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 37 | import android.view.GestureDetector; |
| 38 | import android.view.GestureDetector.OnDoubleTapListener; |
| 39 | import android.view.GestureDetector.SimpleOnGestureListener; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 40 | import android.view.MotionEvent; |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 41 | import android.view.PointerIcon; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 42 | import android.view.VelocityTracker; |
| 43 | import android.view.View; |
| 44 | import android.view.View.OnTouchListener; |
Jorim Jaggi | d8fb3ac | 2016-01-05 15:37:42 +0100 | [diff] [blame] | 45 | import android.view.ViewConfiguration; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 46 | import android.view.ViewTreeObserver.InternalInsetsInfo; |
| 47 | import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 48 | import android.view.ViewTreeObserver.OnGlobalLayoutListener; |
Jorim Jaggi | 81fe2d1 | 2015-12-21 14:45:18 +0100 | [diff] [blame] | 49 | import android.view.WindowInsets; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 50 | import android.view.WindowManager; |
Jorim Jaggi | 88afd02 | 2016-02-24 21:11:08 -0500 | [diff] [blame] | 51 | import android.view.accessibility.AccessibilityNodeInfo; |
| 52 | import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 53 | import android.view.animation.Interpolator; |
| 54 | import android.view.animation.PathInterpolator; |
| 55 | import android.widget.FrameLayout; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 56 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 57 | import com.android.internal.policy.DividerSnapAlgorithm; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 58 | import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget; |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 59 | import com.android.internal.policy.DockedDividerUtils; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 60 | import com.android.systemui.Interpolators; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 61 | import com.android.systemui.R; |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 62 | import com.android.systemui.recents.Recents; |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 63 | import com.android.systemui.recents.events.EventBus; |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 64 | import com.android.systemui.recents.events.activity.DockedTopTaskEvent; |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 65 | import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 66 | import com.android.systemui.recents.events.activity.UndockingTaskEvent; |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 67 | import com.android.systemui.recents.events.ui.RecentsDrawnEvent; |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 68 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 69 | import com.android.systemui.stackdivider.events.StartedDragingEvent; |
| 70 | import com.android.systemui.stackdivider.events.StoppedDragingEvent; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 71 | import com.android.systemui.statusbar.FlingAnimationUtils; |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 72 | import com.android.systemui.statusbar.phone.NavigationBarGestureHelper; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Docked stack divider. |
| 76 | */ |
| 77 | public class DividerView extends FrameLayout implements OnTouchListener, |
| 78 | OnComputeInternalInsetsListener { |
| 79 | |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 80 | static final long TOUCH_ANIMATION_DURATION = 150; |
| 81 | static final long TOUCH_RELEASE_ANIMATION_DURATION = 200; |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 82 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 83 | private static final String TAG = "DividerView"; |
| 84 | |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 85 | private static final int TASK_POSITION_SAME = Integer.MAX_VALUE; |
Jorim Jaggi | 6885598 | 2016-03-25 18:46:30 -0700 | [diff] [blame] | 86 | private static final boolean SWAPPING_ENABLED = false; |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 87 | |
Jorim Jaggi | 50cd636 | 2016-01-22 17:18:29 -0800 | [diff] [blame] | 88 | /** |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 89 | * How much the background gets scaled when we are in the minimized dock state. |
| 90 | */ |
| 91 | private static final float MINIMIZE_DOCK_SCALE = 0.375f; |
| 92 | |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 93 | private static final PathInterpolator SLOWDOWN_INTERPOLATOR = |
| 94 | new PathInterpolator(0.5f, 1f, 0.5f, 1f); |
Jorim Jaggi | 8f8155b | 2016-01-25 19:45:42 -0800 | [diff] [blame] | 95 | private static final PathInterpolator DIM_INTERPOLATOR = |
| 96 | new PathInterpolator(.23f, .87f, .52f, -0.11f); |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 97 | |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 98 | private DividerHandleView mHandle; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 99 | private View mBackground; |
| 100 | private int mStartX; |
| 101 | private int mStartY; |
| 102 | private int mStartPosition; |
| 103 | private int mDockSide; |
| 104 | private final int[] mTempInt2 = new int[2]; |
Jorim Jaggi | d8fb3ac | 2016-01-05 15:37:42 +0100 | [diff] [blame] | 105 | private boolean mMoving; |
| 106 | private int mTouchSlop; |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 107 | private boolean mBackgroundLifted; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 108 | |
| 109 | private int mDividerInsets; |
| 110 | private int mDisplayWidth; |
| 111 | private int mDisplayHeight; |
| 112 | private int mDividerWindowWidth; |
| 113 | private int mDividerSize; |
| 114 | private int mTouchElevation; |
| 115 | |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 116 | private final Rect mDockedRect = new Rect(); |
| 117 | private final Rect mDockedTaskRect = new Rect(); |
| 118 | private final Rect mOtherTaskRect = new Rect(); |
| 119 | private final Rect mOtherRect = new Rect(); |
| 120 | private final Rect mDockedInsetRect = new Rect(); |
| 121 | private final Rect mOtherInsetRect = new Rect(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 122 | private final Rect mLastResizeRect = new Rect(); |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 123 | private final Rect mDisplayRect = new Rect(); |
Jorim Jaggi | 870ab5a | 2015-12-02 18:37:54 -0800 | [diff] [blame] | 124 | private final WindowManagerProxy mWindowManagerProxy = WindowManagerProxy.getInstance(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 125 | private DividerWindowManager mWindowManager; |
| 126 | private VelocityTracker mVelocityTracker; |
| 127 | private FlingAnimationUtils mFlingAnimationUtils; |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 128 | private DividerSnapAlgorithm mSnapAlgorithm; |
Jorim Jaggi | 81fe2d1 | 2015-12-21 14:45:18 +0100 | [diff] [blame] | 129 | private final Rect mStableInsets = new Rect(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 130 | |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 131 | private boolean mAnimateAfterRecentsDrawn; |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 132 | private boolean mGrowAfterRecentsDrawn; |
| 133 | private boolean mGrowRecents; |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 134 | private ValueAnimator mCurrentAnimator; |
| 135 | private boolean mEntranceAnimationRunning; |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 136 | private GestureDetector mGestureDetector; |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 137 | |
Jorim Jaggi | 88afd02 | 2016-02-24 21:11:08 -0500 | [diff] [blame] | 138 | private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() { |
| 139 | @Override |
| 140 | public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { |
| 141 | super.onInitializeAccessibilityNodeInfo(host, info); |
| 142 | if (isHorizontalDivision()) { |
| 143 | info.addAction(new AccessibilityAction(R.id.action_move_up, |
| 144 | mContext.getString(R.string.accessibility_action_divider_move_up))); |
| 145 | info.addAction(new AccessibilityAction(R.id.action_move_down, |
| 146 | mContext.getString(R.string.accessibility_action_divider_move_down))); |
| 147 | } else { |
| 148 | info.addAction(new AccessibilityAction(R.id.action_move_left, |
| 149 | mContext.getString(R.string.accessibility_action_divider_move_left))); |
| 150 | info.addAction(new AccessibilityAction(R.id.action_move_right, |
| 151 | mContext.getString(R.string.accessibility_action_divider_move_right))); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public boolean performAccessibilityAction(View host, int action, Bundle args) { |
| 157 | if (action == R.id.action_move_up || action == R.id.action_move_down |
| 158 | || action == R.id.action_move_left || action == R.id.action_move_right) { |
| 159 | int position = getCurrentPosition(); |
| 160 | SnapTarget currentTarget = mSnapAlgorithm.calculateSnapTarget( |
| 161 | position, 0 /* velocity */); |
| 162 | SnapTarget nextTarget = |
| 163 | action == R.id.action_move_up || action == R.id.action_move_left |
| 164 | ? mSnapAlgorithm.getPreviousTarget(currentTarget) |
| 165 | : mSnapAlgorithm.getNextTarget(currentTarget); |
| 166 | startDragging(true /* animate */, false /* touching */); |
| 167 | stopDragging(getCurrentPosition(), nextTarget, 250, Interpolators.FAST_OUT_SLOW_IN); |
| 168 | return true; |
| 169 | } |
| 170 | return super.performAccessibilityAction(host, action, args); |
| 171 | } |
| 172 | }; |
| 173 | |
Jorim Jaggi | e661f40 | 2016-03-25 19:11:35 -0700 | [diff] [blame] | 174 | private final Runnable mResetBackgroundRunnable = new Runnable() { |
| 175 | @Override |
| 176 | public void run() { |
| 177 | resetBackground(); |
| 178 | } |
| 179 | }; |
| 180 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 181 | public DividerView(Context context) { |
| 182 | super(context); |
| 183 | } |
| 184 | |
| 185 | public DividerView(Context context, @Nullable AttributeSet attrs) { |
| 186 | super(context, attrs); |
| 187 | } |
| 188 | |
| 189 | public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { |
| 190 | super(context, attrs, defStyleAttr); |
| 191 | } |
| 192 | |
| 193 | public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, |
| 194 | int defStyleRes) { |
| 195 | super(context, attrs, defStyleAttr, defStyleRes); |
| 196 | } |
| 197 | |
| 198 | @Override |
| 199 | protected void onFinishInflate() { |
| 200 | super.onFinishInflate(); |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 201 | mHandle = (DividerHandleView) findViewById(R.id.docked_divider_handle); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 202 | mBackground = findViewById(R.id.docked_divider_background); |
| 203 | mHandle.setOnTouchListener(this); |
| 204 | mDividerWindowWidth = getResources().getDimensionPixelSize( |
| 205 | com.android.internal.R.dimen.docked_stack_divider_thickness); |
| 206 | mDividerInsets = getResources().getDimensionPixelSize( |
| 207 | com.android.internal.R.dimen.docked_stack_divider_insets); |
| 208 | mDividerSize = mDividerWindowWidth - 2 * mDividerInsets; |
| 209 | mTouchElevation = getResources().getDimensionPixelSize( |
| 210 | R.dimen.docked_stack_divider_lift_elevation); |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 211 | mGrowRecents = getResources().getBoolean(R.bool.recents_grow_in_multiwindow); |
Jorim Jaggi | d8fb3ac | 2016-01-05 15:37:42 +0100 | [diff] [blame] | 212 | mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 213 | mFlingAnimationUtils = new FlingAnimationUtils(getContext(), 0.3f); |
| 214 | updateDisplayInfo(); |
Jorim Jaggi | e48f428 | 2015-11-06 17:32:44 +0100 | [diff] [blame] | 215 | boolean landscape = getResources().getConfiguration().orientation |
| 216 | == Configuration.ORIENTATION_LANDSCAPE; |
Jun Mukai | d4eaef7 | 2015-10-30 15:54:33 -0700 | [diff] [blame] | 217 | mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), |
| 218 | landscape ? STYLE_HORIZONTAL_DOUBLE_ARROW : STYLE_VERTICAL_DOUBLE_ARROW)); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 219 | getViewTreeObserver().addOnComputeInternalInsetsListener(this); |
Jorim Jaggi | 88afd02 | 2016-02-24 21:11:08 -0500 | [diff] [blame] | 220 | mHandle.setAccessibilityDelegate(mHandleDelegate); |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 221 | mGestureDetector = new GestureDetector(mContext, new SimpleOnGestureListener() { |
| 222 | @Override |
| 223 | public boolean onSingleTapUp(MotionEvent e) { |
Jorim Jaggi | 6885598 | 2016-03-25 18:46:30 -0700 | [diff] [blame] | 224 | if (SWAPPING_ENABLED) { |
| 225 | updateDockSide(); |
| 226 | SystemServicesProxy ssp = Recents.getSystemServices(); |
| 227 | if (mDockSide != WindowManager.DOCKED_INVALID |
| 228 | && !ssp.isRecentsTopMost(ssp.getTopMostTask(), null /* isTopHome */)) { |
| 229 | mWindowManagerProxy.swapTasks(); |
| 230 | return true; |
| 231 | } |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 232 | } |
| 233 | return false; |
| 234 | } |
| 235 | }); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 236 | } |
| 237 | |
Jorim Jaggi | 81fe2d1 | 2015-12-21 14:45:18 +0100 | [diff] [blame] | 238 | @Override |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 239 | protected void onAttachedToWindow() { |
| 240 | super.onAttachedToWindow(); |
| 241 | EventBus.getDefault().register(this); |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 242 | getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { |
| 243 | |
| 244 | @Override |
| 245 | public void onGlobalLayout() { |
| 246 | getViewTreeObserver().removeOnGlobalLayoutListener(this); |
| 247 | mWindowManagerProxy.setTouchRegion(new Rect(mHandle.getLeft(), mHandle.getTop(), |
| 248 | mHandle.getLeft() + mHandle.getWidth(), |
| 249 | mHandle.getTop() + mHandle.getHeight())); |
| 250 | } |
| 251 | }); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | @Override |
| 255 | protected void onDetachedFromWindow() { |
| 256 | super.onDetachedFromWindow(); |
| 257 | EventBus.getDefault().unregister(this); |
| 258 | } |
| 259 | |
| 260 | @Override |
Jorim Jaggi | 81fe2d1 | 2015-12-21 14:45:18 +0100 | [diff] [blame] | 261 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Jorim Jaggi | 1b12ef5 | 2016-01-29 16:49:55 -0800 | [diff] [blame] | 262 | if (mStableInsets.left != insets.getStableInsetLeft() |
| 263 | || mStableInsets.top != insets.getStableInsetTop() |
| 264 | || mStableInsets.right != insets.getStableInsetRight() |
| 265 | || mStableInsets.bottom != insets.getStableInsetBottom()) { |
| 266 | mStableInsets.set(insets.getStableInsetLeft(), insets.getStableInsetTop(), |
| 267 | insets.getStableInsetRight(), insets.getStableInsetBottom()); |
| 268 | if (mSnapAlgorithm != null) { |
| 269 | mSnapAlgorithm = null; |
Jorim Jaggi | defd922 | 2016-02-03 18:28:49 -0800 | [diff] [blame] | 270 | initializeSnapAlgorithm(); |
Jorim Jaggi | 1b12ef5 | 2016-01-29 16:49:55 -0800 | [diff] [blame] | 271 | } |
| 272 | } |
Jorim Jaggi | 81fe2d1 | 2015-12-21 14:45:18 +0100 | [diff] [blame] | 273 | return super.onApplyWindowInsets(insets); |
| 274 | } |
| 275 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 276 | public void setWindowManager(DividerWindowManager windowManager) { |
| 277 | mWindowManager = windowManager; |
| 278 | } |
| 279 | |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 280 | public WindowManagerProxy getWindowManagerProxy() { |
| 281 | return mWindowManagerProxy; |
| 282 | } |
| 283 | |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 284 | public boolean startDragging(boolean animate, boolean touching) { |
Jorim Jaggi | 0c79041 | 2016-02-19 16:38:49 -0800 | [diff] [blame] | 285 | cancelFlingAnimation(); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 286 | if (touching) { |
| 287 | mHandle.setTouching(true, animate); |
| 288 | } |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 289 | mDockSide = mWindowManagerProxy.getDockSide(); |
Jorim Jaggi | defd922 | 2016-02-03 18:28:49 -0800 | [diff] [blame] | 290 | initializeSnapAlgorithm(); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 291 | mWindowManagerProxy.setResizing(true); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 292 | if (touching) { |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 293 | mWindowManager.setSlippery(false); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 294 | liftBackground(); |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 295 | } |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 296 | EventBus.getDefault().send(new StartedDragingEvent()); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 297 | return mDockSide != WindowManager.DOCKED_INVALID; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 298 | } |
| 299 | |
Jorim Jaggi | df012d5 | 2016-01-15 22:40:13 -0800 | [diff] [blame] | 300 | public void stopDragging(int position, float velocity, boolean avoidDismissStart) { |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 301 | mHandle.setTouching(false, true /* animate */); |
Jorim Jaggi | df012d5 | 2016-01-15 22:40:13 -0800 | [diff] [blame] | 302 | fling(position, velocity, avoidDismissStart); |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 303 | mWindowManager.setSlippery(true); |
| 304 | releaseBackground(); |
| 305 | } |
| 306 | |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 307 | public void stopDragging(int position, SnapTarget target, long duration, |
| 308 | Interpolator interpolator) { |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 309 | stopDragging(position, target, duration, 0 /* startDelay*/, interpolator); |
| 310 | } |
| 311 | |
| 312 | public void stopDragging(int position, SnapTarget target, long duration, long startDelay, |
| 313 | Interpolator interpolator) { |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 314 | mHandle.setTouching(false, true /* animate */); |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 315 | flingTo(position, target, duration, startDelay, interpolator); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 316 | mWindowManager.setSlippery(true); |
| 317 | releaseBackground(); |
| 318 | } |
| 319 | |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 320 | private void stopDragging() { |
| 321 | mHandle.setTouching(false, true /* animate */); |
| 322 | mWindowManager.setSlippery(true); |
| 323 | releaseBackground(); |
| 324 | } |
| 325 | |
| 326 | private void updateDockSide() { |
| 327 | mDockSide = mWindowManagerProxy.getDockSide(); |
| 328 | } |
| 329 | |
Jorim Jaggi | defd922 | 2016-02-03 18:28:49 -0800 | [diff] [blame] | 330 | private void initializeSnapAlgorithm() { |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 331 | if (mSnapAlgorithm == null) { |
| 332 | mSnapAlgorithm = new DividerSnapAlgorithm(getContext().getResources(), mDisplayWidth, |
| 333 | mDisplayHeight, mDividerSize, isHorizontalDivision(), mStableInsets); |
| 334 | } |
Jorim Jaggi | defd922 | 2016-02-03 18:28:49 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | public DividerSnapAlgorithm getSnapAlgorithm() { |
| 338 | initializeSnapAlgorithm(); |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 339 | return mSnapAlgorithm; |
| 340 | } |
| 341 | |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 342 | public int getCurrentPosition() { |
| 343 | getLocationOnScreen(mTempInt2); |
| 344 | if (isHorizontalDivision()) { |
| 345 | return mTempInt2[1] + mDividerInsets; |
| 346 | } else { |
| 347 | return mTempInt2[0] + mDividerInsets; |
| 348 | } |
| 349 | } |
| 350 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 351 | @Override |
| 352 | public boolean onTouch(View v, MotionEvent event) { |
| 353 | convertToScreenCoordinates(event); |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 354 | mGestureDetector.onTouchEvent(event); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 355 | final int action = event.getAction() & MotionEvent.ACTION_MASK; |
| 356 | switch (action) { |
| 357 | case MotionEvent.ACTION_DOWN: |
| 358 | mVelocityTracker = VelocityTracker.obtain(); |
| 359 | mVelocityTracker.addMovement(event); |
| 360 | mStartX = (int) event.getX(); |
| 361 | mStartY = (int) event.getY(); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 362 | boolean result = startDragging(true /* animate */, true /* touching */); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 363 | if (!result) { |
| 364 | |
| 365 | // Weren't able to start dragging successfully, so cancel it again. |
| 366 | stopDragging(); |
| 367 | } |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 368 | mStartPosition = getCurrentPosition(); |
Jorim Jaggi | d8fb3ac | 2016-01-05 15:37:42 +0100 | [diff] [blame] | 369 | mMoving = false; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 370 | return result; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 371 | case MotionEvent.ACTION_MOVE: |
| 372 | mVelocityTracker.addMovement(event); |
| 373 | int x = (int) event.getX(); |
| 374 | int y = (int) event.getY(); |
Jorim Jaggi | d8fb3ac | 2016-01-05 15:37:42 +0100 | [diff] [blame] | 375 | boolean exceededTouchSlop = |
| 376 | isHorizontalDivision() && Math.abs(y - mStartY) > mTouchSlop |
| 377 | || (!isHorizontalDivision() && Math.abs(x - mStartX) > mTouchSlop); |
| 378 | if (!mMoving && exceededTouchSlop) { |
| 379 | mStartX = x; |
| 380 | mStartY = y; |
| 381 | mMoving = true; |
| 382 | } |
| 383 | if (mMoving && mDockSide != WindowManager.DOCKED_INVALID) { |
Wale Ogunwale | ef676d8 | 2016-03-18 12:51:55 -0700 | [diff] [blame] | 384 | SnapTarget snapTarget = mSnapAlgorithm.calculateSnapTarget( |
| 385 | mStartPosition, 0 /* velocity */, false /* hardDismiss */); |
| 386 | resizeStack(calculatePosition(x, y), mStartPosition, snapTarget); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 387 | } |
| 388 | break; |
| 389 | case MotionEvent.ACTION_UP: |
| 390 | case MotionEvent.ACTION_CANCEL: |
| 391 | mVelocityTracker.addMovement(event); |
| 392 | |
| 393 | x = (int) event.getRawX(); |
| 394 | y = (int) event.getRawY(); |
| 395 | |
| 396 | mVelocityTracker.computeCurrentVelocity(1000); |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 397 | int position = calculatePosition(x, y); |
| 398 | stopDragging(position, isHorizontalDivision() ? mVelocityTracker.getYVelocity() |
Jorim Jaggi | df012d5 | 2016-01-15 22:40:13 -0800 | [diff] [blame] | 399 | : mVelocityTracker.getXVelocity(), false /* avoidDismissStart */); |
Jorim Jaggi | d8fb3ac | 2016-01-05 15:37:42 +0100 | [diff] [blame] | 400 | mMoving = false; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 401 | break; |
| 402 | } |
| 403 | return true; |
| 404 | } |
| 405 | |
| 406 | private void convertToScreenCoordinates(MotionEvent event) { |
| 407 | event.setLocation(event.getRawX(), event.getRawY()); |
| 408 | } |
| 409 | |
Jorim Jaggi | df012d5 | 2016-01-15 22:40:13 -0800 | [diff] [blame] | 410 | private void fling(int position, float velocity, boolean avoidDismissStart) { |
| 411 | SnapTarget snapTarget = mSnapAlgorithm.calculateSnapTarget(position, velocity); |
| 412 | if (avoidDismissStart && snapTarget == mSnapAlgorithm.getDismissStartTarget()) { |
| 413 | snapTarget = mSnapAlgorithm.getFirstSplitTarget(); |
| 414 | } |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 415 | ValueAnimator anim = getFlingAnimator(position, snapTarget); |
| 416 | mFlingAnimationUtils.apply(anim, position, snapTarget.position, velocity); |
| 417 | anim.start(); |
| 418 | } |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 419 | |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 420 | private void flingTo(int position, SnapTarget target, long duration, long startDelay, |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 421 | Interpolator interpolator) { |
| 422 | ValueAnimator anim = getFlingAnimator(position, target); |
| 423 | anim.setDuration(duration); |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 424 | anim.setStartDelay(startDelay); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 425 | anim.setInterpolator(interpolator); |
| 426 | anim.start(); |
| 427 | } |
| 428 | |
| 429 | private ValueAnimator getFlingAnimator(int position, final SnapTarget snapTarget) { |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 430 | ValueAnimator anim = ValueAnimator.ofInt(position, snapTarget.position); |
| 431 | anim.addUpdateListener(new AnimatorUpdateListener() { |
| 432 | @Override |
| 433 | public void onAnimationUpdate(ValueAnimator animation) { |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 434 | resizeStack((Integer) animation.getAnimatedValue(), |
| 435 | animation.getAnimatedFraction() == 1f |
| 436 | ? TASK_POSITION_SAME |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 437 | : snapTarget.position, snapTarget); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 438 | } |
| 439 | }); |
| 440 | anim.addListener(new AnimatorListenerAdapter() { |
| 441 | @Override |
| 442 | public void onAnimationEnd(Animator animation) { |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 443 | commitSnapFlags(snapTarget); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 444 | mWindowManagerProxy.setResizing(false); |
| 445 | mDockSide = WindowManager.DOCKED_INVALID; |
Jorim Jaggi | 0c79041 | 2016-02-19 16:38:49 -0800 | [diff] [blame] | 446 | mCurrentAnimator = null; |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 447 | mEntranceAnimationRunning = false; |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 448 | EventBus.getDefault().send(new StoppedDragingEvent()); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 449 | } |
| 450 | }); |
Jorim Jaggi | 0c79041 | 2016-02-19 16:38:49 -0800 | [diff] [blame] | 451 | mCurrentAnimator = anim; |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 452 | return anim; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 453 | } |
| 454 | |
Jorim Jaggi | 0c79041 | 2016-02-19 16:38:49 -0800 | [diff] [blame] | 455 | private void cancelFlingAnimation() { |
| 456 | if (mCurrentAnimator != null) { |
| 457 | mCurrentAnimator.cancel(); |
| 458 | } |
| 459 | } |
| 460 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 461 | private void commitSnapFlags(SnapTarget target) { |
| 462 | if (target.flag == SnapTarget.FLAG_NONE) { |
| 463 | return; |
| 464 | } |
| 465 | boolean dismissOrMaximize; |
| 466 | if (target.flag == SnapTarget.FLAG_DISMISS_START) { |
| 467 | dismissOrMaximize = mDockSide == WindowManager.DOCKED_LEFT |
| 468 | || mDockSide == WindowManager.DOCKED_TOP; |
| 469 | } else { |
| 470 | dismissOrMaximize = mDockSide == WindowManager.DOCKED_RIGHT |
| 471 | || mDockSide == WindowManager.DOCKED_BOTTOM; |
| 472 | } |
| 473 | if (dismissOrMaximize) { |
| 474 | mWindowManagerProxy.dismissDockedStack(); |
| 475 | } else { |
| 476 | mWindowManagerProxy.maximizeDockedStack(); |
| 477 | } |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 478 | mWindowManagerProxy.setResizeDimLayer(false, -1, 0f); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | private void liftBackground() { |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 482 | if (mBackgroundLifted) { |
| 483 | return; |
| 484 | } |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 485 | if (isHorizontalDivision()) { |
Jorim Jaggi | 79b39f0 | 2015-12-17 20:04:31 -0800 | [diff] [blame] | 486 | mBackground.animate().scaleY(1.4f); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 487 | } else { |
Jorim Jaggi | 79b39f0 | 2015-12-17 20:04:31 -0800 | [diff] [blame] | 488 | mBackground.animate().scaleX(1.4f); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 489 | } |
| 490 | mBackground.animate() |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 491 | .setInterpolator(Interpolators.TOUCH_RESPONSE) |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 492 | .setDuration(TOUCH_ANIMATION_DURATION) |
| 493 | .translationZ(mTouchElevation) |
| 494 | .start(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 495 | |
| 496 | // Lift handle as well so it doesn't get behind the background, even though it doesn't |
| 497 | // cast shadow. |
| 498 | mHandle.animate() |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 499 | .setInterpolator(Interpolators.TOUCH_RESPONSE) |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 500 | .setDuration(TOUCH_ANIMATION_DURATION) |
| 501 | .translationZ(mTouchElevation) |
| 502 | .start(); |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 503 | mBackgroundLifted = true; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | private void releaseBackground() { |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 507 | if (!mBackgroundLifted) { |
| 508 | return; |
| 509 | } |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 510 | mBackground.animate() |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 511 | .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 512 | .setDuration(TOUCH_RELEASE_ANIMATION_DURATION) |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 513 | .translationZ(0) |
| 514 | .scaleX(1f) |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 515 | .scaleY(1f) |
| 516 | .start(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 517 | mHandle.animate() |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 518 | .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) |
Jorim Jaggi | 514b2cf | 2016-01-04 13:06:34 +0100 | [diff] [blame] | 519 | .setDuration(TOUCH_RELEASE_ANIMATION_DURATION) |
| 520 | .translationZ(0) |
| 521 | .start(); |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 522 | mBackgroundLifted = false; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 523 | } |
| 524 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 525 | |
| 526 | public void setMinimizedDockStack(boolean minimized) { |
| 527 | updateDockSide(); |
| 528 | mHandle.setAlpha(minimized ? 0f : 1f); |
Jorim Jaggi | e661f40 | 2016-03-25 19:11:35 -0700 | [diff] [blame] | 529 | if (!minimized) { |
| 530 | resetBackground(); |
| 531 | } else if (mDockSide == WindowManager.DOCKED_TOP) { |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 532 | mBackground.setPivotY(0); |
Jorim Jaggi | e661f40 | 2016-03-25 19:11:35 -0700 | [diff] [blame] | 533 | mBackground.setScaleY(MINIMIZE_DOCK_SCALE); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 534 | } else if (mDockSide == WindowManager.DOCKED_LEFT |
| 535 | || mDockSide == WindowManager.DOCKED_RIGHT) { |
| 536 | mBackground.setPivotX(mDockSide == WindowManager.DOCKED_LEFT |
| 537 | ? 0 |
| 538 | : mBackground.getWidth()); |
Jorim Jaggi | e661f40 | 2016-03-25 19:11:35 -0700 | [diff] [blame] | 539 | mBackground.setScaleX(MINIMIZE_DOCK_SCALE); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
| 543 | public void setMinimizedDockStack(boolean minimized, long animDuration) { |
| 544 | updateDockSide(); |
| 545 | mHandle.animate() |
| 546 | .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) |
| 547 | .setDuration(animDuration) |
| 548 | .alpha(minimized ? 0f : 1f) |
| 549 | .start(); |
| 550 | if (mDockSide == WindowManager.DOCKED_TOP) { |
| 551 | mBackground.setPivotY(0); |
| 552 | mBackground.animate() |
| 553 | .scaleY(minimized ? MINIMIZE_DOCK_SCALE : 1f); |
| 554 | } else if (mDockSide == WindowManager.DOCKED_LEFT |
| 555 | || mDockSide == WindowManager.DOCKED_RIGHT) { |
| 556 | mBackground.setPivotX(mDockSide == WindowManager.DOCKED_LEFT |
| 557 | ? 0 |
| 558 | : mBackground.getWidth()); |
| 559 | mBackground.animate() |
| 560 | .scaleX(minimized ? MINIMIZE_DOCK_SCALE : 1f); |
| 561 | } |
Jorim Jaggi | e661f40 | 2016-03-25 19:11:35 -0700 | [diff] [blame] | 562 | if (!minimized) { |
| 563 | mBackground.animate().withEndAction(mResetBackgroundRunnable); |
| 564 | } |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 565 | mBackground.animate() |
| 566 | .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) |
| 567 | .setDuration(animDuration) |
| 568 | .start(); |
| 569 | } |
| 570 | |
Jorim Jaggi | e661f40 | 2016-03-25 19:11:35 -0700 | [diff] [blame] | 571 | private void resetBackground() { |
| 572 | mBackground.setPivotX(mBackground.getWidth() / 2); |
| 573 | mBackground.setPivotY(mBackground.getHeight() / 2); |
| 574 | mBackground.setScaleX(1f); |
| 575 | mBackground.setScaleY(1f); |
| 576 | } |
| 577 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 578 | @Override |
| 579 | protected void onConfigurationChanged(Configuration newConfig) { |
| 580 | super.onConfigurationChanged(newConfig); |
| 581 | updateDisplayInfo(); |
| 582 | } |
| 583 | |
| 584 | private void updateDisplayInfo() { |
Filip Gruszczynski | f6d8e9e | 2015-11-12 13:39:20 -0800 | [diff] [blame] | 585 | final DisplayManager displayManager = |
| 586 | (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE); |
| 587 | Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY); |
| 588 | final DisplayInfo info = new DisplayInfo(); |
| 589 | display.getDisplayInfo(info); |
| 590 | mDisplayWidth = info.logicalWidth; |
| 591 | mDisplayHeight = info.logicalHeight; |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 592 | mSnapAlgorithm = null; |
Jorim Jaggi | defd922 | 2016-02-03 18:28:49 -0800 | [diff] [blame] | 593 | initializeSnapAlgorithm(); |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | private int calculatePosition(int touchX, int touchY) { |
| 597 | return isHorizontalDivision() ? calculateYPosition(touchY) : calculateXPosition(touchX); |
| 598 | } |
| 599 | |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 600 | public boolean isHorizontalDivision() { |
| 601 | return getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | private int calculateXPosition(int touchX) { |
| 605 | return mStartPosition + touchX - mStartX; |
| 606 | } |
| 607 | |
| 608 | private int calculateYPosition(int touchY) { |
| 609 | return mStartPosition + touchY - mStartY; |
| 610 | } |
| 611 | |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 612 | private void alignTopLeft(Rect containingRect, Rect rect) { |
| 613 | int width = rect.width(); |
| 614 | int height = rect.height(); |
| 615 | rect.set(containingRect.left, containingRect.top, |
| 616 | containingRect.left + width, containingRect.top + height); |
| 617 | } |
| 618 | |
| 619 | private void alignBottomRight(Rect containingRect, Rect rect) { |
| 620 | int width = rect.width(); |
| 621 | int height = rect.height(); |
| 622 | rect.set(containingRect.right - width, containingRect.bottom - height, |
| 623 | containingRect.right, containingRect.bottom); |
| 624 | } |
| 625 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 626 | public void calculateBoundsForPosition(int position, int dockSide, Rect outRect) { |
| 627 | DockedDividerUtils.calculateBoundsForPosition(position, dockSide, outRect, mDisplayWidth, |
| 628 | mDisplayHeight, mDividerSize); |
| 629 | } |
| 630 | |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 631 | public void resizeStack(int position, int taskPosition, SnapTarget taskSnapTarget) { |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 632 | calculateBoundsForPosition(position, mDockSide, mDockedRect); |
| 633 | |
| 634 | if (mDockedRect.equals(mLastResizeRect)) { |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 635 | return; |
| 636 | } |
Jorim Jaggi | c97ba49 | 2015-11-06 22:00:18 +0100 | [diff] [blame] | 637 | |
| 638 | // Make sure shadows are updated |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 639 | if (mBackground.getZ() > 0f) { |
| 640 | mBackground.invalidate(); |
| 641 | } |
Jorim Jaggi | c97ba49 | 2015-11-06 22:00:18 +0100 | [diff] [blame] | 642 | |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 643 | mLastResizeRect.set(mDockedRect); |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 644 | if (mEntranceAnimationRunning && taskPosition != TASK_POSITION_SAME) { |
| 645 | if (mCurrentAnimator != null) { |
| 646 | calculateBoundsForPosition(taskPosition, mDockSide, mDockedTaskRect); |
| 647 | } else { |
| 648 | calculateBoundsForPosition(isHorizontalDivision() ? mDisplayHeight : mDisplayWidth, |
| 649 | mDockSide, mDockedTaskRect); |
| 650 | } |
| 651 | calculateBoundsForPosition(taskPosition, DockedDividerUtils.invertDockSide(mDockSide), |
| 652 | mOtherTaskRect); |
| 653 | mWindowManagerProxy.resizeDockedStack(mDockedRect, mDockedTaskRect, null, |
| 654 | mOtherTaskRect, null); |
| 655 | } else if (taskPosition != TASK_POSITION_SAME) { |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 656 | calculateBoundsForPosition(position, DockedDividerUtils.invertDockSide(mDockSide), |
| 657 | mOtherRect); |
| 658 | int dockSideInverted = DockedDividerUtils.invertDockSide(mDockSide); |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 659 | int taskPositionDocked = |
| 660 | restrictDismissingTaskPosition(taskPosition, mDockSide, taskSnapTarget); |
| 661 | int taskPositionOther = |
| 662 | restrictDismissingTaskPosition(taskPosition, dockSideInverted, taskSnapTarget); |
| 663 | calculateBoundsForPosition(taskPositionDocked, mDockSide, mDockedTaskRect); |
| 664 | calculateBoundsForPosition(taskPositionOther, dockSideInverted, mOtherTaskRect); |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 665 | mDisplayRect.set(0, 0, mDisplayWidth, mDisplayHeight); |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 666 | alignTopLeft(mDockedRect, mDockedTaskRect); |
| 667 | alignTopLeft(mOtherRect, mOtherTaskRect); |
| 668 | mDockedInsetRect.set(mDockedTaskRect); |
| 669 | mOtherInsetRect.set(mOtherTaskRect); |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 670 | if (dockSideTopLeft(mDockSide)) { |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 671 | alignTopLeft(mDisplayRect, mDockedInsetRect); |
| 672 | alignBottomRight(mDisplayRect, mOtherInsetRect); |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 673 | } else { |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 674 | alignBottomRight(mDisplayRect, mDockedInsetRect); |
| 675 | alignTopLeft(mDisplayRect, mOtherInsetRect); |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 676 | } |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 677 | applyDismissingParallax(mDockedTaskRect, mDockSide, taskSnapTarget, position, |
| 678 | taskPositionDocked); |
| 679 | applyDismissingParallax(mOtherTaskRect, dockSideInverted, taskSnapTarget, position, |
| 680 | taskPositionOther); |
Jorim Jaggi | dc249c4 | 2015-12-15 14:57:31 -0800 | [diff] [blame] | 681 | mWindowManagerProxy.resizeDockedStack(mDockedRect, mDockedTaskRect, mDockedInsetRect, |
| 682 | mOtherTaskRect, mOtherInsetRect); |
| 683 | } else { |
| 684 | mWindowManagerProxy.resizeDockedStack(mDockedRect, null, null, null, null); |
| 685 | } |
Jorim Jaggi | 1b12ef5 | 2016-01-29 16:49:55 -0800 | [diff] [blame] | 686 | SnapTarget closestDismissTarget = mSnapAlgorithm.getClosestDismissTarget(position); |
| 687 | float dimFraction = getDimFraction(position, closestDismissTarget); |
| 688 | mWindowManagerProxy.setResizeDimLayer(dimFraction != 0f, |
| 689 | getStackIdForDismissTarget(closestDismissTarget), |
| 690 | dimFraction); |
| 691 | } |
| 692 | |
| 693 | private float getDimFraction(int position, SnapTarget dismissTarget) { |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 694 | if (mEntranceAnimationRunning) { |
| 695 | return 0f; |
| 696 | } |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 697 | float fraction = mSnapAlgorithm.calculateDismissingFraction(position); |
Jorim Jaggi | 8f8155b | 2016-01-25 19:45:42 -0800 | [diff] [blame] | 698 | fraction = Math.max(0, Math.min(fraction, 1f)); |
| 699 | fraction = DIM_INTERPOLATOR.getInterpolation(fraction); |
Jorim Jaggi | 1b12ef5 | 2016-01-29 16:49:55 -0800 | [diff] [blame] | 700 | if (hasInsetsAtDismissTarget(dismissTarget)) { |
| 701 | |
| 702 | // Less darkening with system insets. |
| 703 | fraction *= 0.8f; |
| 704 | } |
| 705 | return fraction; |
| 706 | } |
| 707 | |
| 708 | /** |
| 709 | * @return true if and only if there are system insets at the location of the dismiss target |
| 710 | */ |
| 711 | private boolean hasInsetsAtDismissTarget(SnapTarget dismissTarget) { |
| 712 | if (isHorizontalDivision()) { |
| 713 | if (dismissTarget == mSnapAlgorithm.getDismissStartTarget()) { |
| 714 | return mStableInsets.top != 0; |
| 715 | } else { |
| 716 | return mStableInsets.bottom != 0; |
| 717 | } |
| 718 | } else { |
| 719 | if (dismissTarget == mSnapAlgorithm.getDismissStartTarget()) { |
| 720 | return mStableInsets.left != 0; |
| 721 | } else { |
| 722 | return mStableInsets.right != 0; |
| 723 | } |
| 724 | } |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 725 | } |
| 726 | |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 727 | /** |
| 728 | * When the snap target is dismissing one side, make sure that the dismissing side doesn't get |
| 729 | * 0 size. |
| 730 | */ |
| 731 | private int restrictDismissingTaskPosition(int taskPosition, int dockSide, |
| 732 | SnapTarget snapTarget) { |
| 733 | if (snapTarget.flag == SnapTarget.FLAG_DISMISS_START && dockSideTopLeft(dockSide)) { |
| 734 | return mSnapAlgorithm.getFirstSplitTarget().position; |
| 735 | } else if (snapTarget.flag == SnapTarget.FLAG_DISMISS_END |
| 736 | && dockSideBottomRight(dockSide)) { |
| 737 | return mSnapAlgorithm.getLastSplitTarget().position; |
| 738 | } else { |
| 739 | return taskPosition; |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | /** |
| 744 | * Applies a parallax to the task when dismissing. |
| 745 | */ |
| 746 | private void applyDismissingParallax(Rect taskRect, int dockSide, SnapTarget snapTarget, |
| 747 | int position, int taskPosition) { |
| 748 | float fraction = Math.min(1, Math.max(0, |
| 749 | mSnapAlgorithm.calculateDismissingFraction(position))); |
| 750 | SnapTarget dismissTarget = null; |
| 751 | SnapTarget splitTarget = null; |
Jorim Jaggi | 8dccd23 | 2016-03-25 18:10:14 -0700 | [diff] [blame] | 752 | int start = 0; |
| 753 | if (position <= mSnapAlgorithm.getLastSplitTarget().position |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 754 | && dockSideTopLeft(dockSide)) { |
| 755 | dismissTarget = mSnapAlgorithm.getDismissStartTarget(); |
| 756 | splitTarget = mSnapAlgorithm.getFirstSplitTarget(); |
Jorim Jaggi | 8dccd23 | 2016-03-25 18:10:14 -0700 | [diff] [blame] | 757 | start = taskPosition; |
| 758 | } else if (position >= mSnapAlgorithm.getLastSplitTarget().position |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 759 | && dockSideBottomRight(dockSide)) { |
| 760 | dismissTarget = mSnapAlgorithm.getDismissEndTarget(); |
| 761 | splitTarget = mSnapAlgorithm.getLastSplitTarget(); |
Jorim Jaggi | 8dccd23 | 2016-03-25 18:10:14 -0700 | [diff] [blame] | 762 | start = splitTarget.position; |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 763 | } |
| 764 | if (dismissTarget != null && fraction > 0f |
| 765 | && isDismissing(splitTarget, position, dockSide)) { |
Jorim Jaggi | 1b12ef5 | 2016-01-29 16:49:55 -0800 | [diff] [blame] | 766 | fraction = calculateParallaxDismissingFraction(fraction, dockSide); |
Jorim Jaggi | 8dccd23 | 2016-03-25 18:10:14 -0700 | [diff] [blame] | 767 | int offsetPosition = (int) (start + |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 768 | fraction * (dismissTarget.position - splitTarget.position)); |
| 769 | int width = taskRect.width(); |
| 770 | int height = taskRect.height(); |
| 771 | switch (dockSide) { |
| 772 | case WindowManager.DOCKED_LEFT: |
| 773 | taskRect.left = offsetPosition - width; |
| 774 | taskRect.right = offsetPosition; |
| 775 | break; |
| 776 | case WindowManager.DOCKED_RIGHT: |
| 777 | taskRect.left = offsetPosition + mDividerSize; |
| 778 | taskRect.right = offsetPosition + width + mDividerSize; |
| 779 | break; |
| 780 | case WindowManager.DOCKED_TOP: |
| 781 | taskRect.top = offsetPosition - height; |
| 782 | taskRect.bottom = offsetPosition; |
| 783 | break; |
| 784 | case WindowManager.DOCKED_BOTTOM: |
| 785 | taskRect.top = offsetPosition + mDividerSize; |
| 786 | taskRect.bottom = offsetPosition + height + mDividerSize; |
| 787 | break; |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | /** |
| 793 | * @return for a specified {@code fraction}, this returns an adjusted value that simulates a |
| 794 | * slowing down parallax effect |
| 795 | */ |
Jorim Jaggi | 1b12ef5 | 2016-01-29 16:49:55 -0800 | [diff] [blame] | 796 | private static float calculateParallaxDismissingFraction(float fraction, int dockSide) { |
| 797 | float result = SLOWDOWN_INTERPOLATOR.getInterpolation(fraction) / 3.5f; |
| 798 | |
| 799 | // Less parallax at the top, just because. |
| 800 | if (dockSide == WindowManager.DOCKED_TOP) { |
| 801 | result /= 2f; |
| 802 | } |
| 803 | return result; |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | private static boolean isDismissing(SnapTarget snapTarget, int position, int dockSide) { |
| 807 | if (dockSide == WindowManager.DOCKED_TOP || dockSide == WindowManager.DOCKED_LEFT) { |
| 808 | return position < snapTarget.position; |
| 809 | } else { |
| 810 | return position > snapTarget.position; |
| 811 | } |
| 812 | } |
| 813 | |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 814 | private int getStackIdForDismissTarget(SnapTarget dismissTarget) { |
Jorim Jaggi | 8dccd23 | 2016-03-25 18:10:14 -0700 | [diff] [blame] | 815 | if ((dismissTarget.flag == SnapTarget.FLAG_DISMISS_START && dockSideTopLeft(mDockSide)) |
| 816 | || (dismissTarget.flag == SnapTarget.FLAG_DISMISS_END |
| 817 | && dockSideBottomRight(mDockSide))) { |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 818 | return StackId.DOCKED_STACK_ID; |
| 819 | } else { |
Jorim Jaggi | 8dccd23 | 2016-03-25 18:10:14 -0700 | [diff] [blame] | 820 | return StackId.HOME_STACK_ID; |
Jorim Jaggi | 5098159 | 2015-12-29 17:54:12 +0100 | [diff] [blame] | 821 | } |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 822 | } |
| 823 | |
Jorim Jaggi | e435e98 | 2015-12-30 13:54:32 +0100 | [diff] [blame] | 824 | /** |
| 825 | * @return true if and only if {@code dockSide} is top or left |
| 826 | */ |
| 827 | private static boolean dockSideTopLeft(int dockSide) { |
| 828 | return dockSide == WindowManager.DOCKED_TOP || dockSide == WindowManager.DOCKED_LEFT; |
| 829 | } |
| 830 | |
| 831 | /** |
| 832 | * @return true if and only if {@code dockSide} is bottom or right |
| 833 | */ |
| 834 | private static boolean dockSideBottomRight(int dockSide) { |
| 835 | return dockSide == WindowManager.DOCKED_BOTTOM || dockSide == WindowManager.DOCKED_RIGHT; |
| 836 | } |
| 837 | |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 838 | @Override |
| 839 | public void onComputeInternalInsets(InternalInsetsInfo inoutInfo) { |
| 840 | inoutInfo.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION); |
| 841 | inoutInfo.touchableRegion.set(mHandle.getLeft(), mHandle.getTop(), mHandle.getRight(), |
| 842 | mHandle.getBottom()); |
| 843 | inoutInfo.touchableRegion.op(mBackground.getLeft(), mBackground.getTop(), |
| 844 | mBackground.getRight(), mBackground.getBottom(), Op.UNION); |
| 845 | } |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 846 | |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 847 | public final void onBusEvent(RecentsActivityStartingEvent recentsActivityStartingEvent) { |
| 848 | if (mGrowRecents && getWindowManagerProxy().getDockSide() == WindowManager.DOCKED_TOP |
| 849 | && getCurrentPosition() == getSnapAlgorithm().getLastSplitTarget().position) { |
| 850 | mGrowAfterRecentsDrawn = true; |
| 851 | startDragging(false /* animate */, false /* touching */); |
| 852 | } |
| 853 | } |
| 854 | |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 855 | public final void onBusEvent(DockedTopTaskEvent event) { |
| 856 | if (event.dragMode == NavigationBarGestureHelper.DRAG_MODE_NONE) { |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 857 | mGrowAfterRecentsDrawn = false; |
| 858 | mAnimateAfterRecentsDrawn = true; |
| 859 | startDragging(false /* animate */, false /* touching */); |
| 860 | } |
Jorim Jaggi | 899327f | 2016-02-25 20:44:18 -0500 | [diff] [blame] | 861 | updateDockSide(); |
| 862 | int position = DockedDividerUtils.calculatePositionForBounds(event.initialRect, |
| 863 | mDockSide, mDividerSize); |
| 864 | mEntranceAnimationRunning = true; |
| 865 | resizeStack(position, mSnapAlgorithm.getMiddleTarget().position, |
| 866 | mSnapAlgorithm.getMiddleTarget()); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | public final void onBusEvent(RecentsDrawnEvent drawnEvent) { |
| 870 | if (mAnimateAfterRecentsDrawn) { |
| 871 | mAnimateAfterRecentsDrawn = false; |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 872 | updateDockSide(); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 873 | stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 250, |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 874 | Interpolators.TOUCH_RESPONSE); |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 875 | } |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 876 | if (mGrowAfterRecentsDrawn) { |
| 877 | mGrowAfterRecentsDrawn = false; |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 878 | updateDockSide(); |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 879 | stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 250, |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 880 | Interpolators.TOUCH_RESPONSE); |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | public final void onBusEvent(UndockingTaskEvent undockingTaskEvent) { |
| 885 | int dockSide = mWindowManagerProxy.getDockSide(); |
| 886 | if (dockSide != WindowManager.DOCKED_INVALID) { |
| 887 | startDragging(false /* animate */, false /* touching */); |
| 888 | SnapTarget target = dockSideTopLeft(dockSide) |
| 889 | ? mSnapAlgorithm.getDismissEndTarget() |
| 890 | : mSnapAlgorithm.getDismissStartTarget(); |
| 891 | |
| 892 | // Don't start immediately - give a little bit time to settle the drag resize change. |
| 893 | stopDragging(getCurrentPosition(), target, 336 /* duration */, 100 /* startDelay */, |
| 894 | Interpolators.TOUCH_RESPONSE); |
Jorim Jaggi | cdb06ca | 2016-01-25 19:15:12 -0800 | [diff] [blame] | 895 | } |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 896 | } |
Jorim Jaggi | 1fcbab6 | 2015-11-04 16:39:50 +0100 | [diff] [blame] | 897 | } |