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 | |
| 19 | import android.app.ActivityOptions; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 20 | import android.app.ActivityOptions.OnAnimationStartedListener; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 21 | import android.content.Context; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 22 | import android.graphics.Bitmap; |
| 23 | import android.graphics.Canvas; |
| 24 | import android.graphics.Rect; |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 25 | import android.graphics.drawable.Drawable; |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 26 | import android.os.Bundle; |
| 27 | import android.os.IRemoteCallback; |
| 28 | import android.os.RemoteException; |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 29 | import android.util.ArraySet; |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 30 | import android.util.AttributeSet; |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 31 | import android.util.Log; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 32 | import android.util.SparseArray; |
| 33 | import android.view.AppTransitionAnimationSpec; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 34 | import android.view.IAppTransitionAnimationSpecsFuture; |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 35 | import android.view.LayoutInflater; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 36 | import android.view.MotionEvent; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 37 | import android.view.View; |
Winson Chung | 653f70c2 | 2014-05-19 14:49:42 -0700 | [diff] [blame] | 38 | import android.view.WindowInsets; |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 39 | import android.view.WindowManagerGlobal; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 40 | import android.view.animation.AnimationUtils; |
| 41 | import android.view.animation.Interpolator; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 42 | import android.widget.FrameLayout; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 43 | |
| 44 | import com.android.internal.annotations.GuardedBy; |
Winson Chung | 5c9f4b9 | 2015-06-25 16:16:46 -0700 | [diff] [blame] | 45 | import com.android.internal.logging.MetricsLogger; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 46 | import com.android.systemui.R; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 47 | import com.android.systemui.recents.Constants; |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 48 | import com.android.systemui.recents.Recents; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 49 | import com.android.systemui.recents.RecentsActivity; |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 50 | import com.android.systemui.recents.RecentsActivityLaunchState; |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 51 | import com.android.systemui.recents.RecentsAppWidgetHostView; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 52 | import com.android.systemui.recents.RecentsConfiguration; |
Winson | 2536c7e | 2015-10-01 15:49:31 -0700 | [diff] [blame] | 53 | import com.android.systemui.recents.events.EventBus; |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 54 | import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent; |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 55 | import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted; |
| 56 | import com.android.systemui.recents.events.component.ScreenPinningRequestEvent; |
Winson | 0d14d4d | 2015-10-26 17:05:04 -0700 | [diff] [blame] | 57 | import com.android.systemui.recents.events.ui.DismissTaskViewEvent; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 58 | import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 59 | import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent; |
| 60 | import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent; |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 61 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 62 | import com.android.systemui.recents.model.Task; |
| 63 | import com.android.systemui.recents.model.TaskStack; |
| 64 | |
| 65 | import java.util.ArrayList; |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame] | 66 | import java.util.List; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 67 | |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 68 | import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; |
Winson | 1b58561 | 2015-11-06 09:16:26 -0800 | [diff] [blame] | 69 | import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 70 | import static android.app.ActivityManager.StackId.INVALID_STACK_ID; |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 71 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 72 | /** |
| 73 | * This view is the the top level layout that contains TaskStacks (which are laid out according |
| 74 | * to their SpaceNode bounds. |
| 75 | */ |
Winson | e6c9073 | 2015-09-24 16:06:29 -0700 | [diff] [blame] | 76 | public class RecentsView extends FrameLayout implements TaskStackView.TaskStackViewCallbacks { |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 77 | |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 78 | private static final String TAG = "RecentsView"; |
Winson | 0d14d4d | 2015-10-26 17:05:04 -0700 | [diff] [blame] | 79 | private static final boolean DEBUG = false; |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 80 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 81 | private static final boolean ADD_HEADER_BITMAP = true; |
Jorim Jaggi | 29deb33 | 2015-11-09 14:33:20 +0100 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Special value for {@link #mAppTransitionAnimationSpecs}: Indicate that we are currently |
| 85 | * waiting for the specs to be retrieved. |
| 86 | */ |
| 87 | private static final List<AppTransitionAnimationSpec> SPECS_WAITING = new ArrayList<>(); |
| 88 | |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 89 | private int mStackViewVisibility = View.VISIBLE; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 90 | |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 91 | /** The RecentsView callbacks */ |
| 92 | public interface RecentsViewCallbacks { |
Winson Chung | 4e96eb7 | 2014-09-17 15:16:09 +0200 | [diff] [blame] | 93 | public void onTaskLaunchFailed(); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 94 | public void onAllTaskViewsDismissed(); |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 97 | LayoutInflater mInflater; |
| 98 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 99 | ArrayList<TaskStack> mStacks; |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 100 | TaskStackView mTaskStackView; |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 101 | RecentsAppWidgetHostView mSearchBar; |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 102 | RecentsViewCallbacks mCb; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 103 | |
| 104 | RecentsViewTouchHandler mTouchHandler; |
| 105 | DragView mDragView; |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 106 | TaskStack.DockState[] mVisibleDockStates = { |
| 107 | TaskStack.DockState.LEFT, |
| 108 | TaskStack.DockState.TOP, |
| 109 | TaskStack.DockState.RIGHT, |
| 110 | TaskStack.DockState.BOTTOM, |
| 111 | }; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 112 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 113 | Interpolator mFastOutSlowInInterpolator; |
| 114 | |
| 115 | Rect mSystemInsets = new Rect(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 116 | |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 117 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 118 | @GuardedBy("this") |
Jorim Jaggi | 29deb33 | 2015-11-09 14:33:20 +0100 | [diff] [blame] | 119 | List<AppTransitionAnimationSpec> mAppTransitionAnimationSpecs = SPECS_WAITING; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 120 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 121 | public RecentsView(Context context) { |
| 122 | super(context); |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | public RecentsView(Context context, AttributeSet attrs) { |
| 126 | this(context, attrs, 0); |
| 127 | } |
| 128 | |
| 129 | public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) { |
| 130 | this(context, attrs, defStyleAttr, 0); |
| 131 | } |
| 132 | |
| 133 | public RecentsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 134 | super(context, attrs, defStyleAttr, defStyleRes); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 135 | setWillNotDraw(false); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 136 | mInflater = LayoutInflater.from(context); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 137 | mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 138 | com.android.internal.R.interpolator.fast_out_slow_in); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 139 | mTouchHandler = new RecentsViewTouchHandler(this); |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 142 | /** Sets the callbacks */ |
| 143 | public void setCallbacks(RecentsViewCallbacks cb) { |
| 144 | mCb = cb; |
| 145 | } |
| 146 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 147 | /** Set/get the bsp root node */ |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 148 | public void setTaskStack(TaskStack stack) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 149 | RecentsConfiguration config = Recents.getConfiguration(); |
| 150 | if (config.getLaunchState().launchedReuseTaskStackViews) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 151 | if (mTaskStackView != null) { |
| 152 | // If onRecentsHidden is not triggered, we need to the stack view again here |
| 153 | mTaskStackView.reset(); |
| 154 | mTaskStackView.setStack(stack); |
| 155 | } else { |
| 156 | mTaskStackView = new TaskStackView(getContext(), stack); |
| 157 | mTaskStackView.setCallbacks(this); |
| 158 | addView(mTaskStackView); |
| 159 | } |
| 160 | } else { |
| 161 | if (mTaskStackView != null) { |
| 162 | removeView(mTaskStackView); |
| 163 | } |
| 164 | mTaskStackView = new TaskStackView(getContext(), stack); |
| 165 | mTaskStackView.setCallbacks(this); |
| 166 | addView(mTaskStackView); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 167 | } |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 168 | mTaskStackView.setVisibility(mStackViewVisibility); |
Winson Chung | 02d4927 | 2014-08-29 13:57:29 -0700 | [diff] [blame] | 169 | |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 170 | // Trigger a new layout |
| 171 | requestLayout(); |
Winson Chung | 19fc117 | 2014-07-31 18:40:03 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 174 | /** Gets the next task in the stack - or if the last - the top task */ |
| 175 | public Task getNextTaskOrTopTask(Task taskToSearch) { |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 176 | Task returnTask = null; |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 177 | boolean found = false; |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 178 | if (mTaskStackView != null) { |
| 179 | TaskStack stack = mTaskStackView.getStack(); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 180 | ArrayList<Task> taskList = stack.getTasks(); |
| 181 | // Iterate the stack views and try and find the focused task |
| 182 | for (int j = taskList.size() - 1; j >= 0; --j) { |
| 183 | Task task = taskList.get(j); |
| 184 | // Return the next task in the line. |
| 185 | if (found) |
| 186 | return task; |
| 187 | // Remember the first possible task as the top task. |
| 188 | if (returnTask == null) |
| 189 | returnTask = task; |
| 190 | if (task == taskToSearch) |
| 191 | found = true; |
| 192 | } |
| 193 | } |
| 194 | return returnTask; |
| 195 | } |
| 196 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 197 | /** Launches the focused task from the first stack if possible */ |
| 198 | public boolean launchFocusedTask() { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 199 | if (mTaskStackView != null) { |
| 200 | TaskStack stack = mTaskStackView.getStack(); |
Winson | 142af42 | 2015-11-09 10:39:57 -0800 | [diff] [blame^] | 201 | Task task = mTaskStackView.getFocusedTask(); |
| 202 | if (task != null) { |
| 203 | TaskView taskView = mTaskStackView.getChildViewForTask(task); |
| 204 | onTaskViewClicked(mTaskStackView, taskView, stack, task, false, false, null, |
| 205 | INVALID_STACK_ID); |
| 206 | return true; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 207 | } |
| 208 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 209 | return false; |
| 210 | } |
| 211 | |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 212 | /** Launches a given task. */ |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 213 | public boolean launchTask(Task task, Rect taskBounds, int destinationStack) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 214 | if (mTaskStackView != null) { |
| 215 | TaskStack stack = mTaskStackView.getStack(); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 216 | // Iterate the stack views and try and find the given task. |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 217 | List<TaskView> taskViews = mTaskStackView.getTaskViews(); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 218 | int taskViewCount = taskViews.size(); |
| 219 | for (int j = 0; j < taskViewCount; j++) { |
| 220 | TaskView tv = taskViews.get(j); |
| 221 | if (tv.getTask() == task) { |
Winson | b1bbaed | 2015-09-23 15:45:11 -0700 | [diff] [blame] | 222 | onTaskViewClicked(mTaskStackView, tv, stack, task, false, taskBounds != null, |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 223 | taskBounds, destinationStack); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 224 | return true; |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | return false; |
| 229 | } |
| 230 | |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 231 | /** Requests all task stacks to start their enter-recents animation */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 232 | public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) { |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 233 | // We have to increment/decrement the post animation trigger in case there are no children |
| 234 | // to ensure that it runs |
| 235 | ctx.postAnimationTrigger.increment(); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 236 | if (mTaskStackView != null) { |
| 237 | mTaskStackView.startEnterRecentsAnimation(ctx); |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 238 | } |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 239 | ctx.postAnimationTrigger.decrement(); |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 242 | /** Requests all task stacks to start their exit-recents animation */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 243 | public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 244 | // We have to increment/decrement the post animation trigger in case there are no children |
| 245 | // to ensure that it runs |
| 246 | ctx.postAnimationTrigger.increment(); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 247 | if (mTaskStackView != null) { |
| 248 | mTaskStackView.startExitToHomeAnimation(ctx); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 249 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 250 | ctx.postAnimationTrigger.decrement(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 251 | |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 252 | // If we are going home, cancel the previous task's window transition |
| 253 | EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null)); |
| 254 | |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 255 | // Notify of the exit animation |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 256 | EventBus.getDefault().send(new DismissRecentsToHomeAnimationStarted()); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 259 | /** Adds the search bar */ |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 260 | public void setSearchBar(RecentsAppWidgetHostView searchBar) { |
Winson Chung | af3bb69 | 2015-06-03 17:31:39 -0700 | [diff] [blame] | 261 | // Remove the previous search bar if one exists |
| 262 | if (mSearchBar != null && indexOfChild(mSearchBar) > -1) { |
| 263 | removeView(mSearchBar); |
| 264 | } |
| 265 | // Add the new search bar |
| 266 | if (searchBar != null) { |
| 267 | mSearchBar = searchBar; |
| 268 | addView(mSearchBar); |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 269 | } |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 272 | /** Returns whether there is currently a search bar */ |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 273 | public boolean hasValidSearchBar() { |
| 274 | return mSearchBar != null && !mSearchBar.isReinflateRequired(); |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | /** Sets the visibility of the search bar */ |
| 278 | public void setSearchBarVisibility(int visibility) { |
| 279 | if (mSearchBar != null) { |
| 280 | mSearchBar.setVisibility(visibility); |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 281 | // Always bring the search bar to the top |
| 282 | mSearchBar.bringToFront(); |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 286 | @Override |
| 287 | protected void onAttachedToWindow() { |
| 288 | EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); |
| 289 | EventBus.getDefault().register(mTouchHandler, RecentsActivity.EVENT_BUS_PRIORITY + 1); |
| 290 | super.onAttachedToWindow(); |
| 291 | } |
| 292 | |
| 293 | @Override |
| 294 | protected void onDetachedFromWindow() { |
| 295 | super.onDetachedFromWindow(); |
| 296 | EventBus.getDefault().unregister(this); |
| 297 | EventBus.getDefault().unregister(mTouchHandler); |
| 298 | } |
| 299 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 300 | /** |
| 301 | * This is called with the full size of the window since we are handling our own insets. |
| 302 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 303 | @Override |
| 304 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 305 | RecentsConfiguration config = Recents.getConfiguration(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 306 | int width = MeasureSpec.getSize(widthMeasureSpec); |
| 307 | int height = MeasureSpec.getSize(heightMeasureSpec); |
Winson Chung | bd91297 | 2014-03-18 14:36:35 -0700 | [diff] [blame] | 308 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 309 | // Get the search bar bounds and measure the search bar layout |
Winson Chung | af3bb69 | 2015-06-03 17:31:39 -0700 | [diff] [blame] | 310 | Rect searchBarSpaceBounds = new Rect(); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 311 | if (mSearchBar != null) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 312 | config.getSearchBarBounds(new Rect(0, 0, width, height), mSystemInsets.top, |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 313 | searchBarSpaceBounds); |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 314 | mSearchBar.measure( |
| 315 | MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY), |
| 316 | MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY)); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 319 | Rect taskStackBounds = new Rect(); |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 320 | config.getTaskStackBounds(new Rect(0, 0, width, height), mSystemInsets.top, |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 321 | mSystemInsets.right, searchBarSpaceBounds, taskStackBounds); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 322 | if (mTaskStackView != null && mTaskStackView.getVisibility() != GONE) { |
Winson | 88f00ab | 2015-10-05 17:24:00 -0700 | [diff] [blame] | 323 | mTaskStackView.setTaskStackBounds(taskStackBounds, mSystemInsets); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 324 | mTaskStackView.measure(widthMeasureSpec, heightMeasureSpec); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 325 | } |
| 326 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 327 | if (mDragView != null) { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 328 | Rect taskRect = mTaskStackView.mLayoutAlgorithm.mTaskRect; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 329 | mDragView.measure( |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 330 | MeasureSpec.makeMeasureSpec(taskRect.width(), MeasureSpec.AT_MOST), |
| 331 | MeasureSpec.makeMeasureSpec(taskRect.height(), MeasureSpec.AT_MOST)); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 334 | setMeasuredDimension(width, height); |
| 335 | } |
| 336 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 337 | /** |
| 338 | * This is called with the full size of the window since we are handling our own insets. |
| 339 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 340 | @Override |
| 341 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 342 | RecentsConfiguration config = Recents.getConfiguration(); |
| 343 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 344 | // Get the search bar bounds so that we lay it out |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 345 | Rect measuredRect = new Rect(0, 0, getMeasuredWidth(), getMeasuredHeight()); |
| 346 | Rect searchBarSpaceBounds = new Rect(); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 347 | if (mSearchBar != null) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 348 | config.getSearchBarBounds(measuredRect, |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 349 | mSystemInsets.top, searchBarSpaceBounds); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 350 | mSearchBar.layout(searchBarSpaceBounds.left, searchBarSpaceBounds.top, |
| 351 | searchBarSpaceBounds.right, searchBarSpaceBounds.bottom); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 354 | if (mTaskStackView != null && mTaskStackView.getVisibility() != GONE) { |
| 355 | mTaskStackView.layout(left, top, left + getMeasuredWidth(), top + getMeasuredHeight()); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 356 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 357 | |
| 358 | if (mDragView != null) { |
| 359 | mDragView.layout(left, top, left + mDragView.getMeasuredWidth(), |
| 360 | top + mDragView.getMeasuredHeight()); |
| 361 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 362 | } |
| 363 | |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 364 | @Override |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 365 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 366 | mSystemInsets.set(insets.getSystemWindowInsets()); |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 367 | requestLayout(); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 368 | return insets.consumeSystemWindowInsets(); |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 369 | } |
| 370 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 371 | @Override |
| 372 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 373 | return mTouchHandler.onInterceptTouchEvent(ev); |
| 374 | } |
| 375 | |
| 376 | @Override |
| 377 | public boolean onTouchEvent(MotionEvent ev) { |
| 378 | return mTouchHandler.onTouchEvent(ev); |
| 379 | } |
| 380 | |
| 381 | @Override |
| 382 | protected void dispatchDraw(Canvas canvas) { |
| 383 | super.dispatchDraw(canvas); |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 384 | for (int i = mVisibleDockStates.length - 1; i >= 0; i--) { |
| 385 | Drawable d = mVisibleDockStates[i].viewState.dockAreaOverlay; |
| 386 | if (d.getAlpha() > 0) { |
| 387 | d.draw(canvas); |
| 388 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 392 | @Override |
| 393 | protected boolean verifyDrawable(Drawable who) { |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 394 | for (int i = mVisibleDockStates.length - 1; i >= 0; i--) { |
| 395 | Drawable d = mVisibleDockStates[i].viewState.dockAreaOverlay; |
| 396 | if (d == who) { |
| 397 | return true; |
| 398 | } |
| 399 | } |
| 400 | return super.verifyDrawable(who); |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 403 | /** Unfilters any filtered stacks */ |
| 404 | public boolean unfilterFilteredStacks() { |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 405 | if (mStacks != null) { |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 406 | // Check if there are any filtered stacks and unfilter them before we back out of Recents |
| 407 | boolean stacksUnfiltered = false; |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 408 | int numStacks = mStacks.size(); |
| 409 | for (int i = 0; i < numStacks; i++) { |
| 410 | TaskStack stack = mStacks.get(i); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 411 | if (stack.hasFilteredTasks()) { |
| 412 | stack.unfilterTasks(); |
| 413 | stacksUnfiltered = true; |
| 414 | } |
| 415 | } |
| 416 | return stacksUnfiltered; |
| 417 | } |
| 418 | return false; |
| 419 | } |
| 420 | |
Jorim Jaggi | 900fb48 | 2015-06-02 15:07:33 -0700 | [diff] [blame] | 421 | public void disableLayersForOneFrame() { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 422 | if (mTaskStackView != null) { |
| 423 | mTaskStackView.disableLayersForOneFrame(); |
Jorim Jaggi | 900fb48 | 2015-06-02 15:07:33 -0700 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 427 | private IAppTransitionAnimationSpecsFuture getAppTransitionFuture(final TaskStackView stackView, |
| 428 | final TaskView clickedTask, final int offsetX, final int offsetY, |
| 429 | final float stackScroll, final int destinationStack) { |
| 430 | return new IAppTransitionAnimationSpecsFuture.Stub() { |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 431 | @Override |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 432 | public AppTransitionAnimationSpec[] get() throws RemoteException { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 433 | post(new Runnable() { |
| 434 | @Override |
| 435 | public void run() { |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 436 | synchronized (RecentsView.this) { |
| 437 | mAppTransitionAnimationSpecs = getAppTransitionAnimationSpecs(stackView, |
| 438 | clickedTask, offsetX, offsetY, stackScroll, destinationStack); |
| 439 | RecentsView.this.notifyAll(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | }); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 443 | synchronized (RecentsView.this) { |
Jorim Jaggi | 29deb33 | 2015-11-09 14:33:20 +0100 | [diff] [blame] | 444 | while (mAppTransitionAnimationSpecs == SPECS_WAITING) { |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 445 | try { |
| 446 | RecentsView.this.wait(); |
| 447 | } catch (InterruptedException e) {} |
| 448 | } |
| 449 | if (mAppTransitionAnimationSpecs == null) { |
| 450 | return null; |
| 451 | } |
| 452 | AppTransitionAnimationSpec[] specs |
| 453 | = new AppTransitionAnimationSpec[mAppTransitionAnimationSpecs.size()]; |
Jorim Jaggi | 29deb33 | 2015-11-09 14:33:20 +0100 | [diff] [blame] | 454 | mAppTransitionAnimationSpecs.toArray(specs); |
| 455 | mAppTransitionAnimationSpecs = SPECS_WAITING; |
| 456 | return specs; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 457 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 458 | } |
| 459 | }; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | private List<AppTransitionAnimationSpec> getAppTransitionAnimationSpecs(TaskStackView stackView, |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 463 | TaskView clickedTask, int offsetX, int offsetY, float stackScroll, |
| 464 | int destinationStack) { |
| 465 | final int targetStackId = destinationStack != INVALID_STACK_ID ? |
| 466 | destinationStack : clickedTask.getTask().key.stackId; |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 467 | if (targetStackId != FREEFORM_WORKSPACE_STACK_ID |
| 468 | && targetStackId != FULLSCREEN_WORKSPACE_STACK_ID) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 469 | return null; |
| 470 | } |
| 471 | // If this is a full screen stack, the transition will be towards the single, full screen |
| 472 | // task. We only need the transition spec for this task. |
| 473 | List<AppTransitionAnimationSpec> specs = new ArrayList<>(); |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 474 | if (targetStackId == FULLSCREEN_WORKSPACE_STACK_ID) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 475 | specs.add(createThumbnailHeaderAnimationSpec( |
| 476 | stackView, offsetX, offsetY, stackScroll, clickedTask, |
| 477 | clickedTask.getTask().key.id, ADD_HEADER_BITMAP)); |
| 478 | return specs; |
| 479 | } |
| 480 | // This is a free form stack or full screen stack, so there will be multiple windows |
| 481 | // animating from thumbnails. We need transition animation specs for all of them. |
| 482 | |
| 483 | // We will use top and bottom task views as a base for tasks, that aren't visible on the |
| 484 | // screen. This is necessary for cascade recents list, where some of the tasks might be |
| 485 | // hidden. |
| 486 | List<TaskView> taskViews = stackView.getTaskViews(); |
| 487 | int childCount = taskViews.size(); |
| 488 | TaskView topChild = taskViews.get(0); |
| 489 | TaskView bottomChild = taskViews.get(childCount - 1); |
| 490 | SparseArray<TaskView> taskViewsByTaskId = new SparseArray<>(); |
| 491 | for (int i = 0; i < childCount; i++) { |
| 492 | TaskView taskView = taskViews.get(i); |
| 493 | taskViewsByTaskId.put(taskView.getTask().key.id, taskView); |
| 494 | } |
| 495 | |
| 496 | TaskStack stack = stackView.getStack(); |
| 497 | // We go through all tasks now and for each generate transition animation spec. If there is |
| 498 | // a view associated with a task, we use that view as a base for the animation. If there |
| 499 | // isn't, we use bottom or top view, depending on which one would be closer to the task |
| 500 | // view if it existed. |
| 501 | ArrayList<Task> tasks = stack.getTasks(); |
| 502 | boolean passedClickedTask = false; |
| 503 | for (int i = 0, n = tasks.size(); i < n; i++) { |
| 504 | Task task = tasks.get(i); |
| 505 | TaskView taskView = taskViewsByTaskId.get(task.key.id); |
| 506 | if (taskView != null) { |
| 507 | specs.add(createThumbnailHeaderAnimationSpec(stackView, offsetX, offsetY, |
| 508 | stackScroll, taskView, taskView.getTask().key.id, ADD_HEADER_BITMAP)); |
| 509 | if (taskView == clickedTask) { |
| 510 | passedClickedTask = true; |
| 511 | } |
| 512 | } else { |
| 513 | taskView = passedClickedTask ? bottomChild : topChild; |
| 514 | specs.add(createThumbnailHeaderAnimationSpec(stackView, offsetX, offsetY, |
| 515 | stackScroll, taskView, task.key.id, !ADD_HEADER_BITMAP)); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | return specs; |
| 520 | } |
| 521 | |
| 522 | private AppTransitionAnimationSpec createThumbnailHeaderAnimationSpec(TaskStackView stackView, |
| 523 | int offsetX, int offsetY, float stackScroll, TaskView tv, int taskId, |
| 524 | boolean addHeaderBitmap) { |
| 525 | // Disable any focused state before we draw the header |
| 526 | // Upfront the processing of the thumbnail |
| 527 | if (tv.isFocusedTask()) { |
Winson | 0d14d4d | 2015-10-26 17:05:04 -0700 | [diff] [blame] | 528 | tv.setFocusedState(false, false /* animated */, false /* requestViewFocus */); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 529 | } |
| 530 | TaskViewTransform transform = new TaskViewTransform(); |
| 531 | transform = stackView.getStackAlgorithm().getStackTransform(tv.mTask, stackScroll, |
| 532 | transform, null); |
| 533 | |
| 534 | float scale = tv.getScaleX(); |
| 535 | int fromHeaderWidth = (int) (tv.mHeaderView.getMeasuredWidth() * scale); |
| 536 | int fromHeaderHeight = (int) (tv.mHeaderView.getMeasuredHeight() * scale); |
| 537 | |
| 538 | Bitmap b = null; |
| 539 | if (addHeaderBitmap) { |
| 540 | b = Bitmap.createBitmap(fromHeaderWidth, fromHeaderHeight, |
| 541 | Bitmap.Config.ARGB_8888); |
| 542 | |
| 543 | if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) { |
| 544 | b.eraseColor(0xFFff0000); |
| 545 | } else { |
| 546 | Canvas c = new Canvas(b); |
| 547 | c.scale(tv.getScaleX(), tv.getScaleY()); |
| 548 | tv.mHeaderView.draw(c); |
| 549 | c.setBitmap(null); |
| 550 | |
| 551 | } |
| 552 | b = b.createAshmemBitmap(); |
| 553 | } |
| 554 | |
| 555 | int[] pts = new int[2]; |
| 556 | tv.getLocationOnScreen(pts); |
| 557 | |
| 558 | final int left = pts[0] + offsetX; |
| 559 | final int top = pts[1] + offsetY; |
Winson | 3150e57 | 2015-10-23 15:07:24 -0700 | [diff] [blame] | 560 | final Rect rect = new Rect(left, top, left + (int) transform.rect.width(), |
| 561 | top + (int) transform.rect.height()); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 562 | |
| 563 | return new AppTransitionAnimationSpec(taskId, b, rect); |
| 564 | } |
| 565 | |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 566 | /**** TaskStackView.TaskStackCallbacks Implementation ****/ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 567 | |
| 568 | @Override |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 569 | public void onTaskViewClicked(final TaskStackView stackView, final TaskView tv, |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 570 | final TaskStack stack, final Task task, final boolean lockToTask, |
| 571 | final boolean boundsValid, final Rect bounds, int destinationStack) { |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 572 | |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 573 | // Upfront the processing of the thumbnail |
Winson Chung | ffa2ec6 | 2014-07-03 15:54:42 -0700 | [diff] [blame] | 574 | TaskViewTransform transform = new TaskViewTransform(); |
Jorim Jaggi | cb55703 | 2014-09-16 23:09:24 +0200 | [diff] [blame] | 575 | View sourceView; |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 576 | int offsetX = 0; |
| 577 | int offsetY = 0; |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 578 | float stackScroll = stackView.getScroller().getStackScroll(); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 579 | if (tv == null) { |
| 580 | // If there is no actual task view, then use the stack view as the source view |
| 581 | // and then offset to the expected transform rect, but bound this to just |
| 582 | // outside the display rect (to ensure we don't animate from too far away) |
| 583 | sourceView = stackView; |
Winson | 3150e57 | 2015-10-23 15:07:24 -0700 | [diff] [blame] | 584 | offsetX = (int) transform.rect.left; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 585 | offsetY = getMeasuredHeight(); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 586 | } else { |
Jorim Jaggi | cb55703 | 2014-09-16 23:09:24 +0200 | [diff] [blame] | 587 | sourceView = tv.mThumbnailView; |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | // Compute the thumbnail to scale up from |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 591 | final SystemServicesProxy ssp = Recents.getSystemServices(); |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 592 | boolean screenPinningRequested = false; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 593 | ActivityOptions opts = ActivityOptions.makeBasic(); |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 594 | ActivityOptions.OnAnimationStartedListener animStartedListener = null; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 595 | final IAppTransitionAnimationSpecsFuture transitionFuture; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 596 | if (task.thumbnail != null && task.thumbnail.getWidth() > 0 && |
| 597 | task.thumbnail.getHeight() > 0) { |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 598 | animStartedListener = new ActivityOptions.OnAnimationStartedListener() { |
| 599 | @Override |
| 600 | public void onAnimationStarted() { |
| 601 | // If we are launching into another task, cancel the previous task's |
| 602 | // window transition |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 603 | EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task)); |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 604 | |
| 605 | if (lockToTask) { |
| 606 | // Request screen pinning after the animation runs |
| 607 | postDelayed(new Runnable() { |
| 608 | @Override |
| 609 | public void run() { |
| 610 | EventBus.getDefault().send(new ScreenPinningRequestEvent( |
| 611 | getContext(), ssp)); |
| 612 | } |
| 613 | }, 350); |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 614 | } |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 615 | } |
| 616 | }; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 617 | transitionFuture = getAppTransitionFuture(stackView, tv, offsetX, offsetY, stackScroll, |
| 618 | destinationStack); |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 619 | screenPinningRequested = true; |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 620 | } else { |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 621 | transitionFuture = null; |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 622 | } |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 623 | if (boundsValid) { |
Winson | b1bbaed | 2015-09-23 15:45:11 -0700 | [diff] [blame] | 624 | opts.setBounds(bounds.isEmpty() ? null : bounds); |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 625 | } |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 626 | final ActivityOptions launchOpts = opts; |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 627 | final boolean finalScreenPinningRequested = screenPinningRequested; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 628 | final OnAnimationStartedListener finalAnimStartedListener = animStartedListener; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 629 | final Runnable launchRunnable = new Runnable() { |
| 630 | @Override |
| 631 | public void run() { |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 632 | if (task.isActive) { |
| 633 | // Bring an active task to the foreground |
Craig Mautner | dc00cbe | 2014-07-20 17:48:47 -0700 | [diff] [blame] | 634 | ssp.moveTaskToFront(task.key.id, launchOpts); |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 635 | } else { |
Winson | c28098f | 2015-10-30 14:50:19 -0700 | [diff] [blame] | 636 | if (ssp.startActivityFromRecents(getContext(), task.key.id, task.activityLabel, |
| 637 | launchOpts)) { |
| 638 | if (!finalScreenPinningRequested) { |
| 639 | // If we have not requested this already to be run after the window |
| 640 | // transition, then just run it now |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 641 | EventBus.getDefault().send(new ScreenPinningRequestEvent( |
| 642 | getContext(), ssp)); |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 643 | } |
Winson Chung | 4e96eb7 | 2014-09-17 15:16:09 +0200 | [diff] [blame] | 644 | } else { |
| 645 | // Dismiss the task and return the user to home if we fail to |
| 646 | // launch the task |
Winson | 0d14d4d | 2015-10-26 17:05:04 -0700 | [diff] [blame] | 647 | EventBus.getDefault().send(new DismissTaskViewEvent(task, tv)); |
Winson Chung | 4e96eb7 | 2014-09-17 15:16:09 +0200 | [diff] [blame] | 648 | if (mCb != null) { |
| 649 | mCb.onTaskLaunchFailed(); |
| 650 | } |
Winson Chung | 5c9f4b9 | 2015-06-25 16:16:46 -0700 | [diff] [blame] | 651 | |
| 652 | // Keep track of failed launches |
| 653 | MetricsLogger.count(getContext(), "overview_task_launch_failed", 1); |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 654 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 655 | } |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 656 | if (transitionFuture != null) { |
| 657 | IRemoteCallback.Stub callback = new IRemoteCallback.Stub() { |
| 658 | @Override |
| 659 | public void sendResult(Bundle data) throws RemoteException { |
| 660 | post(new Runnable() { |
| 661 | @Override |
| 662 | public void run() { |
| 663 | if (finalAnimStartedListener != null) { |
| 664 | finalAnimStartedListener.onAnimationStarted(); |
| 665 | } |
| 666 | } |
| 667 | }); |
| 668 | } |
| 669 | }; |
| 670 | try { |
| 671 | WindowManagerGlobal.getWindowManagerService() |
| 672 | .overridePendingAppTransitionMultiThumbFuture(transitionFuture, |
| 673 | callback, true /* scaleUp */); |
| 674 | } catch (RemoteException e) { |
| 675 | Log.w(TAG, "Failed to override transition: " + e); |
| 676 | } |
| 677 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 678 | } |
| 679 | }; |
| 680 | |
Winson Chung | 5c9f4b9 | 2015-06-25 16:16:46 -0700 | [diff] [blame] | 681 | // Keep track of the index of the task launch |
| 682 | int taskIndexFromFront = 0; |
| 683 | int taskIndex = stack.indexOfTask(task); |
| 684 | if (taskIndex > -1) { |
| 685 | taskIndexFromFront = stack.getTaskCount() - taskIndex - 1; |
| 686 | } |
| 687 | MetricsLogger.histogram(getContext(), "overview_task_launch_index", taskIndexFromFront); |
| 688 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 689 | // Launch the app right away if there is no task view, otherwise, animate the icon out first |
Winson Chung | 814086d | 2014-05-07 15:01:14 -0700 | [diff] [blame] | 690 | if (tv == null) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 691 | launchRunnable.run(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 692 | } else { |
Winson Chung | e1e20e1 | 2015-06-02 14:11:49 -0700 | [diff] [blame] | 693 | if (task.group != null && !task.group.isFrontMostTask(task)) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 694 | // For affiliated tasks that are behind other tasks, we must animate the front cards |
| 695 | // out of view before starting the task transition |
Winson Chung | ebfc698 | 2014-08-26 12:25:34 -0700 | [diff] [blame] | 696 | stackView.startLaunchTaskAnimation(tv, launchRunnable, lockToTask); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 697 | } else { |
| 698 | // Otherwise, we can start the task transition immediately |
Winson Chung | ebfc698 | 2014-08-26 12:25:34 -0700 | [diff] [blame] | 699 | stackView.startLaunchTaskAnimation(tv, null, lockToTask); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 700 | launchRunnable.run(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 701 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 702 | } |
| 703 | } |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 704 | |
| 705 | @Override |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame] | 706 | public void onAllTaskViewsDismissed(ArrayList<Task> removedTasks) { |
Winson | 2536c7e | 2015-10-01 15:49:31 -0700 | [diff] [blame] | 707 | /* TODO: Not currently enabled |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame] | 708 | if (removedTasks != null) { |
| 709 | int taskCount = removedTasks.size(); |
| 710 | for (int i = 0; i < taskCount; i++) { |
| 711 | onTaskViewDismissed(removedTasks.get(i)); |
| 712 | } |
| 713 | } |
Winson | 2536c7e | 2015-10-01 15:49:31 -0700 | [diff] [blame] | 714 | */ |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame] | 715 | |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 716 | mCb.onAllTaskViewsDismissed(); |
Winson Chung | 5c9f4b9 | 2015-06-25 16:16:46 -0700 | [diff] [blame] | 717 | |
| 718 | // Keep track of all-deletions |
| 719 | MetricsLogger.count(getContext(), "overview_task_all_dismissed", 1); |
Winson Chung | d7b2cb1 | 2014-06-26 15:08:50 -0700 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | @Override |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 723 | public void onTaskStackFilterTriggered() { |
| 724 | // Hide the search bar |
| 725 | if (mSearchBar != null) { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 726 | int filterDuration = getResources().getInteger( |
| 727 | R.integer.recents_filter_animate_current_views_duration); |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 728 | mSearchBar.animate() |
| 729 | .alpha(0f) |
| 730 | .setStartDelay(0) |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 731 | .setInterpolator(mFastOutSlowInInterpolator) |
| 732 | .setDuration(filterDuration) |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 733 | .withLayer() |
| 734 | .start(); |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | @Override |
| 739 | public void onTaskStackUnfilterTriggered() { |
| 740 | // Show the search bar |
| 741 | if (mSearchBar != null) { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 742 | int filterDuration = getResources().getInteger( |
| 743 | R.integer.recents_filter_animate_new_views_duration); |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 744 | mSearchBar.animate() |
| 745 | .alpha(1f) |
| 746 | .setStartDelay(0) |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 747 | .setInterpolator(mFastOutSlowInInterpolator) |
| 748 | .setDuration(filterDuration) |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 749 | .withLayer() |
| 750 | .start(); |
| 751 | } |
| 752 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 753 | |
| 754 | /**** EventBus Events ****/ |
| 755 | |
| 756 | public final void onBusEvent(DragStartEvent event) { |
| 757 | // Add the drag view |
| 758 | mDragView = event.dragView; |
| 759 | addView(mDragView); |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 760 | |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 761 | updateVisibleDockRegions(mTouchHandler.getDockStatesForCurrentOrientation(), |
| 762 | TaskStack.DockState.NONE.viewState.dockAreaAlpha); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 763 | } |
| 764 | |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 765 | public final void onBusEvent(DragDropTargetChangedEvent event) { |
| 766 | if (event.dropTarget == null || !(event.dropTarget instanceof TaskStack.DockState)) { |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 767 | updateVisibleDockRegions(mTouchHandler.getDockStatesForCurrentOrientation(), |
| 768 | TaskStack.DockState.NONE.viewState.dockAreaAlpha); |
| 769 | } else { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 770 | final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget; |
| 771 | updateVisibleDockRegions(new TaskStack.DockState[] {dockState}, -1); |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 772 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | public final void onBusEvent(final DragEndEvent event) { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 776 | final Runnable cleanUpRunnable = new Runnable() { |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 777 | @Override |
| 778 | public void run() { |
| 779 | // Remove the drag view |
| 780 | removeView(mDragView); |
| 781 | mDragView = null; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 782 | } |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 783 | }; |
| 784 | |
| 785 | // Animate the overlay alpha back to 0 |
| 786 | updateVisibleDockRegions(null, -1); |
| 787 | |
| 788 | if (event.dropTarget == null) { |
| 789 | // No drop targets for hit, so just animate the task back to its place |
| 790 | event.postAnimationTrigger.increment(); |
| 791 | event.postAnimationTrigger.addLastDecrementRunnable(new Runnable() { |
| 792 | @Override |
| 793 | public void run() { |
| 794 | cleanUpRunnable.run(); |
| 795 | } |
| 796 | }); |
| 797 | // Animate the task back to where it was before then clean up afterwards |
| 798 | TaskViewTransform taskTransform = new TaskViewTransform(); |
| 799 | TaskStackLayoutAlgorithm layoutAlgorithm = mTaskStackView.getStackAlgorithm(); |
| 800 | layoutAlgorithm.getStackTransform(event.task, |
| 801 | mTaskStackView.getScroller().getStackScroll(), taskTransform, null); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 802 | event.dragView.animate() |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 803 | .scaleX(taskTransform.scale) |
| 804 | .scaleY(taskTransform.scale) |
| 805 | .translationX((layoutAlgorithm.mTaskRect.left - event.dragView.getLeft()) |
| 806 | + taskTransform.translationX) |
| 807 | .translationY((layoutAlgorithm.mTaskRect.top - event.dragView.getTop()) |
| 808 | + taskTransform.translationY) |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 809 | .setDuration(175) |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 810 | .setInterpolator(mFastOutSlowInInterpolator) |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 811 | .withEndAction(event.postAnimationTrigger.decrementAsRunnable()) |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 812 | .start(); |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 813 | |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 814 | } else if (event.dropTarget instanceof TaskStack.DockState) { |
| 815 | final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget; |
| 816 | |
| 817 | // For now, just remove the drag view and the original task |
| 818 | // TODO: Animate the task to the drop target rect before launching it above |
| 819 | cleanUpRunnable.run(); |
| 820 | |
| 821 | // Dock the task and launch it |
| 822 | SystemServicesProxy ssp = Recents.getSystemServices(); |
| 823 | ssp.startTaskInDockedMode(event.task.key.id, dockState.createMode); |
| 824 | launchTask(event.task, null, INVALID_STACK_ID); |
| 825 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 826 | } else { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 827 | // We dropped on another drop target, so just add the cleanup to the post animation |
| 828 | // trigger |
| 829 | event.postAnimationTrigger.addLastDecrementRunnable(new Runnable() { |
| 830 | @Override |
| 831 | public void run() { |
| 832 | cleanUpRunnable.run(); |
| 833 | } |
| 834 | }); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 835 | } |
| 836 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 837 | |
| 838 | /** |
| 839 | * Updates the dock region to match the specified dock state. |
| 840 | */ |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 841 | private void updateVisibleDockRegions(TaskStack.DockState[] newDockStates, int overrideAlpha) { |
| 842 | ArraySet<TaskStack.DockState> newDockStatesSet = new ArraySet<>(); |
| 843 | if (newDockStates != null) { |
| 844 | for (TaskStack.DockState dockState : newDockStates) { |
| 845 | newDockStatesSet.add(dockState); |
| 846 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 847 | } |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 848 | for (TaskStack.DockState dockState : mVisibleDockStates) { |
| 849 | TaskStack.DockState.ViewState viewState = dockState.viewState; |
| 850 | if (newDockStates == null || !newDockStatesSet.contains(dockState)) { |
| 851 | // This is no longer visible, so hide it |
| 852 | viewState.startAlphaAnimation(0, 150); |
| 853 | } else { |
| 854 | // This state is now visible, update the bounds and show it |
| 855 | int alpha = (overrideAlpha != -1 ? overrideAlpha : viewState.dockAreaAlpha); |
| 856 | viewState.dockAreaOverlay.setBounds( |
| 857 | dockState.getDockedBounds(getMeasuredWidth(), getMeasuredHeight())); |
| 858 | viewState.dockAreaOverlay.setCallback(this); |
| 859 | viewState.startAlphaAnimation(alpha, 150); |
| 860 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 861 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 862 | } |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 863 | |
| 864 | public void setStackViewVisibility(int stackViewVisibility) { |
| 865 | mStackViewVisibility = stackViewVisibility; |
| 866 | if (mTaskStackView != null) { |
| 867 | mTaskStackView.setVisibility(stackViewVisibility); |
| 868 | invalidate(); |
| 869 | } |
| 870 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 871 | } |