Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [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 Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 19 | import android.animation.ObjectAnimator; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 20 | import android.animation.TimeInterpolator; |
| 21 | import android.animation.ValueAnimator; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 22 | import android.content.Context; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 23 | import android.graphics.Canvas; |
Winson Chung | 96e3bc1 | 2014-05-06 16:44:12 -0700 | [diff] [blame] | 24 | import android.graphics.Outline; |
Winson Chung | c9567c0 | 2014-06-16 20:25:51 -0700 | [diff] [blame] | 25 | import android.graphics.Paint; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 26 | import android.graphics.Path; |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 27 | import android.graphics.Point; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 28 | import android.graphics.Rect; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 29 | import android.graphics.RectF; |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 30 | import android.util.AttributeSet; |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 31 | import android.view.MotionEvent; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 32 | import android.view.View; |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 33 | import android.view.ViewPropertyAnimator; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 34 | import android.view.animation.AccelerateInterpolator; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 35 | import android.widget.FrameLayout; |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 36 | import com.android.systemui.R; |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 37 | import com.android.systemui.recents.Console; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 38 | import com.android.systemui.recents.Constants; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 39 | import com.android.systemui.recents.RecentsConfiguration; |
| 40 | import com.android.systemui.recents.model.Task; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 41 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 42 | |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 43 | /* A task view */ |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 44 | public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.OnClickListener, |
| 45 | View.OnLongClickListener { |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 46 | /** The TaskView callbacks */ |
| 47 | interface TaskViewCallbacks { |
| 48 | public void onTaskIconClicked(TaskView tv); |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 49 | public void onTaskAppInfoClicked(TaskView tv); |
Winson Chung | 47a3e65 | 2014-05-21 16:03:42 -0700 | [diff] [blame] | 50 | public void onTaskFocused(TaskView tv); |
Winson Chung | 54e297a | 2014-05-09 17:15:32 -0700 | [diff] [blame] | 51 | public void onTaskDismissed(TaskView tv); |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 54 | RecentsConfiguration mConfig; |
| 55 | |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 56 | int mDim; |
| 57 | int mMaxDim; |
| 58 | TimeInterpolator mDimInterpolator = new AccelerateInterpolator(); |
| 59 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 60 | Task mTask; |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 61 | boolean mTaskDataLoaded; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 62 | boolean mIsFocused; |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 63 | boolean mClipViewInStack; |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 64 | Point mLastTouchDown = new Point(); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 65 | Path mRoundedRectClipPath = new Path(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 66 | Rect mTmpRect = new Rect(); |
Winson Chung | c9567c0 | 2014-06-16 20:25:51 -0700 | [diff] [blame] | 67 | Paint mLayerPaint = new Paint(); |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 68 | |
| 69 | TaskThumbnailView mThumbnailView; |
| 70 | TaskBarView mBarView; |
| 71 | TaskViewCallbacks mCb; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 72 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 73 | // Optimizations |
| 74 | ValueAnimator.AnimatorUpdateListener mUpdateDimListener = |
| 75 | new ValueAnimator.AnimatorUpdateListener() { |
| 76 | @Override |
| 77 | public void onAnimationUpdate(ValueAnimator animation) { |
| 78 | updateDimOverlayFromScale(); |
| 79 | } |
| 80 | }; |
Winson Chung | 743d5c9 | 2014-06-13 10:14:53 -0700 | [diff] [blame] | 81 | Runnable mEnableThumbnailClip = new Runnable() { |
| 82 | @Override |
| 83 | public void run() { |
| 84 | mThumbnailView.updateTaskBarClip(mBarView); |
| 85 | } |
| 86 | }; |
| 87 | Runnable mDisableThumbnailClip = new Runnable() { |
| 88 | @Override |
| 89 | public void run() { |
| 90 | mThumbnailView.disableClipTaskBarView(); |
| 91 | } |
| 92 | }; |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 93 | |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 94 | |
| 95 | public TaskView(Context context) { |
| 96 | this(context, null); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 97 | } |
| 98 | |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 99 | public TaskView(Context context, AttributeSet attrs) { |
| 100 | this(context, attrs, 0); |
| 101 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 102 | |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 103 | public TaskView(Context context, AttributeSet attrs, int defStyleAttr) { |
| 104 | this(context, attrs, defStyleAttr, 0); |
| 105 | } |
| 106 | |
| 107 | public TaskView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 108 | super(context, attrs, defStyleAttr, defStyleRes); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 109 | mConfig = RecentsConfiguration.getInstance(); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 110 | setWillNotDraw(false); |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 111 | setDim(getDim()); |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | @Override |
| 115 | protected void onFinishInflate() { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 116 | mMaxDim = mConfig.taskStackMaxDim; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 117 | |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 118 | // By default, all views are clipped to other views in their stack |
| 119 | mClipViewInStack = true; |
| 120 | |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 121 | // Bind the views |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 122 | mBarView = (TaskBarView) findViewById(R.id.task_view_bar); |
Winson Chung | 743d5c9 | 2014-06-13 10:14:53 -0700 | [diff] [blame] | 123 | mThumbnailView = (TaskThumbnailView) findViewById(R.id.task_view_thumbnail); |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 124 | |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 125 | if (mTaskDataLoaded) { |
| 126 | onTaskDataLoaded(false); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 130 | @Override |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 131 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 132 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 133 | |
| 134 | // Update the rounded rect clip path |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 135 | float radius = mConfig.taskViewRoundedCornerRadiusPx; |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 136 | mRoundedRectClipPath.reset(); |
| 137 | mRoundedRectClipPath.addRoundRect(new RectF(0, 0, getMeasuredWidth(), getMeasuredHeight()), |
| 138 | radius, radius, Path.Direction.CW); |
Winson Chung | 96e3bc1 | 2014-05-06 16:44:12 -0700 | [diff] [blame] | 139 | |
| 140 | // Update the outline |
| 141 | Outline o = new Outline(); |
Winson Chung | 602de03 | 2014-05-27 12:19:28 -0700 | [diff] [blame] | 142 | o.setRoundRect(0, 0, getMeasuredWidth(), getMeasuredHeight() - |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 143 | mConfig.taskViewShadowOutlineBottomInsetPx, radius); |
Winson Chung | 96e3bc1 | 2014-05-06 16:44:12 -0700 | [diff] [blame] | 144 | setOutline(o); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | @Override |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 148 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 149 | switch (ev.getAction()) { |
| 150 | case MotionEvent.ACTION_DOWN: |
| 151 | case MotionEvent.ACTION_MOVE: |
| 152 | mLastTouchDown.set((int) ev.getX(), (int) ev.getY()); |
| 153 | break; |
| 154 | } |
| 155 | return super.onInterceptTouchEvent(ev); |
| 156 | } |
| 157 | |
Winson Chung | 04dfe0d | 2014-03-14 14:06:29 -0700 | [diff] [blame] | 158 | /** Set callback */ |
| 159 | void setCallbacks(TaskViewCallbacks cb) { |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 160 | mCb = cb; |
| 161 | } |
| 162 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 163 | /** Gets the task */ |
| 164 | Task getTask() { |
| 165 | return mTask; |
| 166 | } |
| 167 | |
| 168 | /** Synchronizes this view's properties with the task's transform */ |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 169 | void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, int duration) { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 170 | if (Console.Enabled) { |
| 171 | Console.log(Constants.Log.UI.Draw, "[TaskView|updateViewPropertiesToTaskTransform]", |
| 172 | "duration: " + duration, Console.AnsiPurple); |
| 173 | } |
Winson Chung | 96e3bc1 | 2014-05-06 16:44:12 -0700 | [diff] [blame] | 174 | |
Winson Chung | 54e297a | 2014-05-09 17:15:32 -0700 | [diff] [blame] | 175 | // Update the bar view |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 176 | mBarView.updateViewPropertiesToTaskTransform(toTransform, duration); |
Winson Chung | 54e297a | 2014-05-09 17:15:32 -0700 | [diff] [blame] | 177 | |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 178 | // Check to see if any properties have changed, and update the task view |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 179 | if (duration > 0) { |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 180 | ViewPropertyAnimator anim = animate(); |
| 181 | boolean useLayers = false; |
| 182 | |
| 183 | // Animate to the final state |
| 184 | if (toTransform.hasTranslationYChangedFrom(getTranslationY())) { |
| 185 | anim.translationY(toTransform.translationY); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 186 | } |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 187 | if (Constants.DebugFlags.App.EnableShadows && |
| 188 | toTransform.hasTranslationZChangedFrom(getTranslationZ())) { |
| 189 | anim.translationZ(toTransform.translationZ); |
Winson Chung | 814086d | 2014-05-07 15:01:14 -0700 | [diff] [blame] | 190 | } |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 191 | if (toTransform.hasScaleChangedFrom(getScaleX())) { |
| 192 | anim.scaleX(toTransform.scale) |
Winson Chung | c6a1623 | 2014-04-01 14:04:48 -0700 | [diff] [blame] | 193 | .scaleY(toTransform.scale) |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 194 | .setUpdateListener(mUpdateDimListener); |
| 195 | useLayers = true; |
| 196 | } |
| 197 | if (toTransform.hasAlphaChangedFrom(getAlpha())) { |
| 198 | // Use layers if we animate alpha |
| 199 | anim.alpha(toTransform.alpha); |
| 200 | useLayers = true; |
| 201 | } |
| 202 | if (useLayers) { |
| 203 | anim.withLayer(); |
| 204 | } |
Winson Chung | 7ab650c | 2014-06-18 14:25:34 -0700 | [diff] [blame^] | 205 | anim.setStartDelay(toTransform.startDelay) |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 206 | .setDuration(duration) |
| 207 | .setInterpolator(mConfig.fastOutSlowInInterpolator) |
| 208 | .start(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 209 | } else { |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 210 | // Set the changed properties |
| 211 | if (toTransform.hasTranslationYChangedFrom(getTranslationY())) { |
| 212 | setTranslationY(toTransform.translationY); |
| 213 | } |
| 214 | if (Constants.DebugFlags.App.EnableShadows && |
| 215 | toTransform.hasTranslationZChangedFrom(getTranslationZ())) { |
Winson Chung | b13c46e | 2014-06-09 18:33:08 -0700 | [diff] [blame] | 216 | setTranslationZ(toTransform.translationZ); |
Winson Chung | 814086d | 2014-05-07 15:01:14 -0700 | [diff] [blame] | 217 | } |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 218 | if (toTransform.hasScaleChangedFrom(getScaleX())) { |
| 219 | setScaleX(toTransform.scale); |
| 220 | setScaleY(toTransform.scale); |
| 221 | updateDimOverlayFromScale(); |
| 222 | } |
| 223 | if (toTransform.hasAlphaChangedFrom(getAlpha())) { |
| 224 | setAlpha(toTransform.alpha); |
| 225 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 226 | } |
| 227 | } |
| 228 | |
| 229 | /** Resets this view's properties */ |
| 230 | void resetViewProperties() { |
| 231 | setTranslationX(0f); |
| 232 | setTranslationY(0f); |
Winson Chung | 814086d | 2014-05-07 15:01:14 -0700 | [diff] [blame] | 233 | if (Constants.DebugFlags.App.EnableShadows) { |
| 234 | setTranslationZ(0f); |
| 235 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 236 | setScaleX(1f); |
| 237 | setScaleY(1f); |
| 238 | setAlpha(1f); |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 239 | setDim(0); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 240 | invalidate(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 241 | } |
| 242 | |
Winson Chung | 11ca76a5 | 2014-04-10 17:29:13 -0700 | [diff] [blame] | 243 | /** |
| 244 | * When we are un/filtering, this method will set up the transform that we are animating to, |
| 245 | * in order to hide the task. |
| 246 | */ |
Winson Chung | c6a1623 | 2014-04-01 14:04:48 -0700 | [diff] [blame] | 247 | void prepareTaskTransformForFilterTaskHidden(TaskViewTransform toTransform) { |
| 248 | // Fade the view out and slide it away |
| 249 | toTransform.alpha = 0f; |
| 250 | toTransform.translationY += 200; |
Winson Chung | 7ab650c | 2014-06-18 14:25:34 -0700 | [diff] [blame^] | 251 | toTransform.translationZ = 0; |
Winson Chung | c6a1623 | 2014-04-01 14:04:48 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Winson Chung | 11ca76a5 | 2014-04-10 17:29:13 -0700 | [diff] [blame] | 254 | /** |
| 255 | * When we are un/filtering, this method will setup the transform that we are animating from, |
| 256 | * in order to show the task. |
| 257 | */ |
Winson Chung | c6a1623 | 2014-04-01 14:04:48 -0700 | [diff] [blame] | 258 | void prepareTaskTransformForFilterTaskVisible(TaskViewTransform fromTransform) { |
| 259 | // Fade the view in |
| 260 | fromTransform.alpha = 0f; |
| 261 | } |
| 262 | |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 263 | /** Prepares this task view for the enter-recents animations. This is called earlier in the |
| 264 | * first layout because the actual animation into recents may take a long time. */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 265 | public void prepareEnterRecentsAnimation(boolean isTaskViewFrontMost, int offsetY, int offscreenY, |
| 266 | Rect taskRect) { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 267 | if (mConfig.launchedFromAppWithScreenshot) { |
| 268 | if (isTaskViewFrontMost) { |
| 269 | // Hide the task view as we are going to animate the full screenshot into view |
| 270 | // and then replace it with this view once we are done |
| 271 | setVisibility(View.INVISIBLE); |
| 272 | // Also hide the front most task bar view so we can animate it in |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 273 | mBarView.prepareEnterRecentsAnimation(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 274 | } else { |
| 275 | // Top align the task views |
| 276 | setTranslationY(offsetY); |
| 277 | setScaleX(1f); |
| 278 | setScaleY(1f); |
| 279 | } |
| 280 | |
| 281 | } else if (mConfig.launchedFromAppWithThumbnail) { |
| 282 | if (isTaskViewFrontMost) { |
| 283 | // Hide the front most task bar view so we can animate it in |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 284 | mBarView.prepareEnterRecentsAnimation(); |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 285 | // Set the dim to 0 so we can animate it in |
| 286 | setDim(0); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | } else if (mConfig.launchedFromHome) { |
| 290 | // Move the task view off screen (below) so we can animate it in |
| 291 | setTranslationY(offscreenY); |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 292 | setTranslationZ(0); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 293 | setScaleX(1f); |
| 294 | setScaleY(1f); |
| 295 | } |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 298 | /** Animates this task view as it enters recents */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 299 | public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 300 | TaskViewTransform transform = ctx.transform; |
| 301 | |
| 302 | if (mConfig.launchedFromAppWithScreenshot) { |
| 303 | if (ctx.isFrontMost) { |
| 304 | // Animate the full screenshot down first, before swapping with this task view |
| 305 | ctx.fullScreenshot.animateOnEnterRecents(ctx, new Runnable() { |
| 306 | @Override |
| 307 | public void run() { |
| 308 | // Animate the task bar of the first task view |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 309 | mBarView.startEnterRecentsAnimation(0, mEnableThumbnailClip); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 310 | setVisibility(View.VISIBLE); |
| 311 | } |
| 312 | }); |
| 313 | } else { |
| 314 | // Animate the tasks down behind the full screenshot |
| 315 | animate() |
| 316 | .scaleX(transform.scale) |
| 317 | .scaleY(transform.scale) |
| 318 | .translationY(transform.translationY) |
| 319 | .setStartDelay(0) |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 320 | .setUpdateListener(null) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 321 | .setInterpolator(mConfig.linearOutSlowInInterpolator) |
| 322 | .setDuration(475) |
| 323 | .withLayer() |
Winson Chung | 743d5c9 | 2014-06-13 10:14:53 -0700 | [diff] [blame] | 324 | .withEndAction(mEnableThumbnailClip) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 325 | .start(); |
| 326 | } |
| 327 | |
| 328 | } else if (mConfig.launchedFromAppWithThumbnail) { |
| 329 | if (ctx.isFrontMost) { |
| 330 | // Animate the task bar of the first task view |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 331 | mBarView.startEnterRecentsAnimation(mConfig.taskBarEnterAnimDelay, mEnableThumbnailClip); |
Winson Chung | 743d5c9 | 2014-06-13 10:14:53 -0700 | [diff] [blame] | 332 | |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 333 | // Animate the dim into view as well |
| 334 | ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", getDimOverlayFromScale()); |
| 335 | anim.setStartDelay(mConfig.taskBarEnterAnimDelay); |
| 336 | anim.setDuration(mConfig.taskBarEnterAnimDuration); |
| 337 | anim.setInterpolator(mConfig.fastOutLinearInInterpolator); |
| 338 | anim.start(); |
Winson Chung | 743d5c9 | 2014-06-13 10:14:53 -0700 | [diff] [blame] | 339 | } else { |
| 340 | mEnableThumbnailClip.run(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | } else if (mConfig.launchedFromHome) { |
| 344 | // Animate the tasks up |
| 345 | int frontIndex = (ctx.stackViewCount - ctx.stackViewIndex - 1); |
| 346 | int delay = mConfig.taskBarEnterAnimDelay + |
| 347 | frontIndex * mConfig.taskViewEnterFromHomeDelay; |
| 348 | animate() |
| 349 | .scaleX(transform.scale) |
| 350 | .scaleY(transform.scale) |
| 351 | .translationY(transform.translationY) |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 352 | .translationZ(transform.translationZ) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 353 | .setStartDelay(delay) |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 354 | .setUpdateListener(null) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 355 | .setInterpolator(mConfig.quintOutInterpolator) |
| 356 | .setDuration(mConfig.taskViewEnterFromHomeDuration) |
| 357 | .withLayer() |
Winson Chung | 743d5c9 | 2014-06-13 10:14:53 -0700 | [diff] [blame] | 358 | .withEndAction(mEnableThumbnailClip) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 359 | .start(); |
| 360 | } |
| 361 | } |
| 362 | |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 363 | /** Animates this task view as it leaves recents by pressing home. */ |
| 364 | public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 365 | animate() |
| 366 | .translationY(ctx.offscreenTranslationY) |
| 367 | .setStartDelay(0) |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 368 | .setUpdateListener(null) |
Winson Chung | ad6f276 | 2014-06-13 09:41:09 -0700 | [diff] [blame] | 369 | .setInterpolator(mConfig.fastOutLinearInInterpolator) |
| 370 | .setDuration(mConfig.taskViewExitToHomeDuration) |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 371 | .withLayer() |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 372 | .withEndAction(ctx.postAnimationTrigger.decrementAsRunnable()) |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 373 | .start(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 374 | ctx.postAnimationTrigger.increment(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | /** Animates this task view as it exits recents */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 378 | public void startLaunchTaskAnimation(final Runnable r, boolean isLaunchingTask) { |
| 379 | if (isLaunchingTask) { |
| 380 | // Disable the thumbnail clip and animate the bar out |
| 381 | mBarView.startLaunchTaskAnimation(mDisableThumbnailClip, r); |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 382 | |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 383 | // Animate the dim |
| 384 | if (mDim > 0) { |
| 385 | ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", 0); |
| 386 | anim.setDuration(mConfig.taskBarExitAnimDuration); |
| 387 | anim.setInterpolator(mConfig.fastOutLinearInInterpolator); |
| 388 | anim.start(); |
| 389 | } |
| 390 | } else { |
| 391 | // Hide the dismiss button |
| 392 | mBarView.startLaunchTaskDismissAnimation(); |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 393 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 394 | } |
| 395 | |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 396 | /** Animates the deletion of this task view */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 397 | public void startDeleteTaskAnimation(final Runnable r) { |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 398 | // Disabling clipping with the stack while the view is animating away |
| 399 | setClipViewInStack(false); |
| 400 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 401 | animate().translationX(mConfig.taskViewRemoveAnimTranslationXPx) |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 402 | .alpha(0f) |
| 403 | .setStartDelay(0) |
Winson Chung | b5ddfc3 | 2014-06-13 17:23:12 -0700 | [diff] [blame] | 404 | .setUpdateListener(null) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 405 | .setInterpolator(mConfig.fastOutSlowInInterpolator) |
| 406 | .setDuration(mConfig.taskViewRemoveAnimDuration) |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 407 | .withLayer() |
| 408 | .withEndAction(new Runnable() { |
| 409 | @Override |
| 410 | public void run() { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 411 | // We just throw this into a runnable because starting a view property |
| 412 | // animation using layers can cause inconsisten results if we try and |
| 413 | // update the layers while the animation is running. In some cases, |
| 414 | // the runnabled passed in may start an animation which also uses layers |
| 415 | // so we defer all this by posting this. |
| 416 | r.run(); |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 417 | |
| 418 | // Re-enable clipping with the stack (we will reuse this view) |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 419 | setClipViewInStack(true); |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 420 | } |
| 421 | }) |
| 422 | .start(); |
| 423 | } |
| 424 | |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 425 | /** Animates this task view if the user does not interact with the stack after a certain time. */ |
| 426 | public void startNoUserInteractionAnimation() { |
| 427 | mBarView.startNoUserInteractionAnimation(); |
| 428 | } |
| 429 | |
| 430 | /** Mark this task view that the user does has not interacted with the stack after a certain time. */ |
| 431 | public void setNoUserInteractionState() { |
| 432 | mBarView.setNoUserInteractionState(); |
| 433 | } |
| 434 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 435 | /** Returns the rect we want to clip (it may not be the full rect) */ |
Winson Chung | 0d76755 | 2014-04-09 14:33:23 -0700 | [diff] [blame] | 436 | Rect getClippingRect(Rect outRect) { |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 437 | getHitRect(outRect); |
| 438 | // XXX: We should get the hit rect of the thumbnail view and intersect, but this is faster |
| 439 | outRect.right = outRect.left + mThumbnailView.getRight(); |
| 440 | outRect.bottom = outRect.top + mThumbnailView.getBottom(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 441 | return outRect; |
| 442 | } |
| 443 | |
| 444 | /** Enable the hw layers on this task view */ |
| 445 | void enableHwLayers() { |
Winson Chung | c9567c0 | 2014-06-16 20:25:51 -0700 | [diff] [blame] | 446 | mThumbnailView.setLayerType(View.LAYER_TYPE_HARDWARE, mLayerPaint); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 447 | mBarView.enableHwLayers(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | /** Disable the hw layers on this task view */ |
| 451 | void disableHwLayers() { |
Winson Chung | c9567c0 | 2014-06-16 20:25:51 -0700 | [diff] [blame] | 452 | mThumbnailView.setLayerType(View.LAYER_TYPE_NONE, mLayerPaint); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 453 | mBarView.disableHwLayers(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 454 | } |
| 455 | |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 456 | /** |
| 457 | * Returns whether this view should be clipped, or any views below should clip against this |
| 458 | * view. |
| 459 | */ |
| 460 | boolean shouldClipViewInStack() { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 461 | return mClipViewInStack && (getVisibility() == View.VISIBLE); |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /** Sets whether this view should be clipped, or clipped against. */ |
| 465 | void setClipViewInStack(boolean clip) { |
| 466 | if (clip != mClipViewInStack) { |
| 467 | mClipViewInStack = clip; |
| 468 | if (getParent() instanceof View) { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 469 | getHitRect(mTmpRect); |
| 470 | ((View) getParent()).invalidate(mTmpRect); |
Winson Chung | 5a9b0b0 | 2014-05-20 17:32:03 -0700 | [diff] [blame] | 471 | } |
| 472 | } |
| 473 | } |
| 474 | |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 475 | /** Returns the current dim. */ |
| 476 | public void setDim(int dim) { |
| 477 | mDim = dim; |
| 478 | postInvalidateOnAnimation(); |
| 479 | } |
| 480 | |
| 481 | /** Returns the current dim. */ |
| 482 | public int getDim() { |
| 483 | return mDim; |
| 484 | } |
| 485 | |
| 486 | /** Compute the dim as a function of the scale of this view. */ |
| 487 | int getDimOverlayFromScale() { |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 488 | float minScale = Constants.Values.TaskStackView.StackPeekMinScale; |
| 489 | float scaleRange = 1f - minScale; |
| 490 | float dim = (1f - getScaleX()) / scaleRange; |
| 491 | dim = mDimInterpolator.getInterpolation(Math.min(dim, 1f)); |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 492 | return Math.max(0, Math.min(mMaxDim, (int) (dim * 255))); |
| 493 | } |
| 494 | |
| 495 | /** Update the dim as a function of the scale of this view. */ |
| 496 | void updateDimOverlayFromScale() { |
| 497 | setDim(getDimOverlayFromScale()); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | @Override |
| 501 | public void draw(Canvas canvas) { |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 502 | int restoreCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 503 | // Apply the rounded rect clip path on the whole view |
| 504 | canvas.clipPath(mRoundedRectClipPath); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 505 | super.draw(canvas); |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 506 | canvas.restoreToCount(restoreCount); |
Winson Chung | 1492646 | 2014-04-14 18:57:14 -0700 | [diff] [blame] | 507 | |
| 508 | // Apply the dim if necessary |
| 509 | if (mDim > 0) { |
| 510 | canvas.drawColor(mDim << 24); |
| 511 | } |
| 512 | } |
| 513 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 514 | /** |
| 515 | * Sets the focused task explicitly. We need a separate flag because requestFocus() won't happen |
| 516 | * if the view is not currently visible, or we are in touch state (where we still want to keep |
| 517 | * track of focus). |
| 518 | */ |
| 519 | public void setFocusedTask() { |
| 520 | mIsFocused = true; |
| 521 | requestFocus(); |
Winson Chung | 47a3e65 | 2014-05-21 16:03:42 -0700 | [diff] [blame] | 522 | invalidate(); |
| 523 | mCb.onTaskFocused(this); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Updates the explicitly focused state when the view focus changes. |
| 528 | */ |
| 529 | @Override |
| 530 | protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { |
| 531 | super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); |
| 532 | if (!gainFocus) { |
| 533 | mIsFocused = false; |
Winson Chung | 47a3e65 | 2014-05-21 16:03:42 -0700 | [diff] [blame] | 534 | invalidate(); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * Returns whether we have explicitly been focused. |
| 540 | */ |
| 541 | public boolean isFocusedTask() { |
| 542 | return mIsFocused || isFocused(); |
| 543 | } |
| 544 | |
Winson Chung | 4d7b092 | 2014-03-13 17:14:17 -0700 | [diff] [blame] | 545 | /**** TaskCallbacks Implementation ****/ |
| 546 | |
Winson Chung | 04dfe0d | 2014-03-14 14:06:29 -0700 | [diff] [blame] | 547 | /** Binds this task view to the task */ |
| 548 | public void onTaskBound(Task t) { |
| 549 | mTask = t; |
| 550 | mTask.setCallbacks(this); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | @Override |
Winson Chung | 4c71aef | 2014-03-21 15:15:11 -0700 | [diff] [blame] | 554 | public void onTaskDataLoaded(boolean reloadingTaskData) { |
Winson Chung | 863db8a | 2014-05-20 14:27:39 -0700 | [diff] [blame] | 555 | if (mThumbnailView != null && mBarView != null) { |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 556 | // Bind each of the views to the new task data |
| 557 | mThumbnailView.rebindToTask(mTask, reloadingTaskData); |
| 558 | mBarView.rebindToTask(mTask, reloadingTaskData); |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 559 | // Rebind any listeners |
| 560 | mBarView.mApplicationIcon.setOnClickListener(this); |
Winson Chung | 54e297a | 2014-05-09 17:15:32 -0700 | [diff] [blame] | 561 | mBarView.mDismissButton.setOnClickListener(this); |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 562 | if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) { |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 563 | if (mConfig.developerOptionsEnabled) { |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 564 | mBarView.mApplicationIcon.setOnLongClickListener(this); |
| 565 | } |
| 566 | } |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 567 | } |
| 568 | mTaskDataLoaded = true; |
Winson Chung | 4d7b092 | 2014-03-13 17:14:17 -0700 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | @Override |
Winson Chung | 04dfe0d | 2014-03-14 14:06:29 -0700 | [diff] [blame] | 572 | public void onTaskDataUnloaded() { |
Winson Chung | 863db8a | 2014-05-20 14:27:39 -0700 | [diff] [blame] | 573 | if (mThumbnailView != null && mBarView != null) { |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 574 | // Unbind each of the views from the task data and remove the task callback |
| 575 | mTask.setCallbacks(null); |
| 576 | mThumbnailView.unbindFromTask(); |
| 577 | mBarView.unbindFromTask(); |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 578 | // Unbind any listeners |
| 579 | mBarView.mApplicationIcon.setOnClickListener(null); |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 580 | mBarView.mDismissButton.setOnClickListener(null); |
| 581 | if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) { |
| 582 | mBarView.mApplicationIcon.setOnLongClickListener(null); |
| 583 | } |
Winson Chung | 37c8d8e | 2014-03-24 14:53:07 -0700 | [diff] [blame] | 584 | } |
| 585 | mTaskDataLoaded = false; |
Winson Chung | 4d7b092 | 2014-03-13 17:14:17 -0700 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | @Override |
Winson Chung | 7ab650c | 2014-06-18 14:25:34 -0700 | [diff] [blame^] | 589 | public void onClick(final View v) { |
| 590 | // We purposely post the handler delayed to allow for the touch feedback to draw |
| 591 | final TaskView tv = this; |
| 592 | postDelayed(new Runnable() { |
| 593 | @Override |
| 594 | public void run() { |
| 595 | if (v == mBarView.mApplicationIcon) { |
| 596 | mCb.onTaskIconClicked(tv); |
| 597 | } else if (v == mBarView.mDismissButton) { |
| 598 | // Animate out the view and call the callback |
| 599 | startDeleteTaskAnimation(new Runnable() { |
| 600 | @Override |
| 601 | public void run() { |
| 602 | mCb.onTaskDismissed(tv); |
| 603 | } |
| 604 | }); |
Winson Chung | 54e297a | 2014-05-09 17:15:32 -0700 | [diff] [blame] | 605 | } |
Winson Chung | 7ab650c | 2014-06-18 14:25:34 -0700 | [diff] [blame^] | 606 | } |
| 607 | }, 125); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 608 | } |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 609 | |
| 610 | @Override |
| 611 | public boolean onLongClick(View v) { |
| 612 | if (v == mBarView.mApplicationIcon) { |
| 613 | mCb.onTaskAppInfoClicked(this); |
| 614 | return true; |
| 615 | } |
| 616 | return false; |
| 617 | } |
Winson Chung | 7bb1885 | 2014-05-20 23:25:41 +0000 | [diff] [blame] | 618 | } |