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