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