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 | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 19 | import android.content.Context; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 20 | import android.content.res.Resources; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 21 | import android.graphics.Canvas; |
| 22 | import android.graphics.Rect; |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 23 | import android.graphics.drawable.Drawable; |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 24 | import android.os.Handler; |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 25 | import android.util.ArraySet; |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 26 | import android.util.AttributeSet; |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 27 | import android.view.LayoutInflater; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 28 | import android.view.MotionEvent; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 29 | import android.view.View; |
Winson Chung | 653f70c2 | 2014-05-19 14:49:42 -0700 | [diff] [blame] | 30 | import android.view.WindowInsets; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 31 | import android.view.animation.AnimationUtils; |
| 32 | import android.view.animation.Interpolator; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 33 | import android.widget.FrameLayout; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 34 | import com.android.systemui.R; |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 35 | import com.android.systemui.recents.Recents; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 36 | import com.android.systemui.recents.RecentsActivity; |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 37 | import com.android.systemui.recents.RecentsActivityLaunchState; |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 38 | import com.android.systemui.recents.RecentsAppWidgetHostView; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 39 | import com.android.systemui.recents.RecentsConfiguration; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 40 | import com.android.systemui.recents.RecentsDebugFlags; |
Winson | 2536c7e | 2015-10-01 15:49:31 -0700 | [diff] [blame] | 41 | import com.android.systemui.recents.events.EventBus; |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 42 | import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 43 | import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent; |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 44 | import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 45 | import com.android.systemui.recents.events.activity.HideHistoryButtonEvent; |
| 46 | import com.android.systemui.recents.events.activity.HideHistoryEvent; |
| 47 | import com.android.systemui.recents.events.activity.ShowHistoryButtonEvent; |
| 48 | import com.android.systemui.recents.events.activity.ShowHistoryEvent; |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 49 | import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 50 | import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent; |
| 51 | import com.android.systemui.recents.events.ui.DraggingInRecentsEvent; |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 52 | import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 53 | import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent; |
| 54 | import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent; |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 55 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 56 | import com.android.systemui.recents.model.Task; |
| 57 | import com.android.systemui.recents.model.TaskStack; |
| 58 | |
| 59 | import java.util.ArrayList; |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame] | 60 | import java.util.List; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 61 | |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 62 | import static android.app.ActivityManager.StackId.INVALID_STACK_ID; |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 63 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 64 | /** |
| 65 | * This view is the the top level layout that contains TaskStacks (which are laid out according |
| 66 | * to their SpaceNode bounds. |
| 67 | */ |
Winson | e6c9073 | 2015-09-24 16:06:29 -0700 | [diff] [blame] | 68 | public class RecentsView extends FrameLayout implements TaskStackView.TaskStackViewCallbacks { |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 69 | |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 70 | private static final String TAG = "RecentsView"; |
Winson | 0d14d4d | 2015-10-26 17:05:04 -0700 | [diff] [blame] | 71 | private static final boolean DEBUG = false; |
Jorim Jaggi | 6e18e00 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 72 | |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 73 | Handler mHandler; |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 74 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 75 | TaskStack mStack; |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 76 | TaskStackView mTaskStackView; |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 77 | RecentsAppWidgetHostView mSearchBar; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 78 | View mHistoryButton; |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 79 | boolean mAwaitingFirstLayout = true; |
| 80 | boolean mLastTaskLaunchedWasFreeform; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 81 | |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 82 | RecentsTransitionHelper mTransitionHelper; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 83 | RecentsViewTouchHandler mTouchHandler; |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 84 | TaskStack.DockState[] mVisibleDockStates = { |
| 85 | TaskStack.DockState.LEFT, |
| 86 | TaskStack.DockState.TOP, |
| 87 | TaskStack.DockState.RIGHT, |
| 88 | TaskStack.DockState.BOTTOM, |
| 89 | }; |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 90 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 91 | private Interpolator mFastOutSlowInInterpolator; |
| 92 | private Interpolator mFastOutLinearInInterpolator; |
| 93 | private int mHistoryTransitionDuration; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 94 | |
| 95 | Rect mSystemInsets = new Rect(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 96 | |
| 97 | public RecentsView(Context context) { |
| 98 | super(context); |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | public RecentsView(Context context, AttributeSet attrs) { |
| 102 | this(context, attrs, 0); |
| 103 | } |
| 104 | |
| 105 | public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) { |
| 106 | this(context, attrs, defStyleAttr, 0); |
| 107 | } |
| 108 | |
| 109 | public RecentsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 110 | super(context, attrs, defStyleAttr, defStyleRes); |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 111 | Resources res = context.getResources(); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 112 | setWillNotDraw(false); |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 113 | mHandler = new Handler(); |
| 114 | mTransitionHelper = new RecentsTransitionHelper(getContext(), mHandler); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 115 | mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 116 | com.android.internal.R.interpolator.fast_out_slow_in); |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 117 | mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context, |
| 118 | com.android.internal.R.interpolator.fast_out_linear_in); |
| 119 | mHistoryTransitionDuration = res.getInteger(R.integer.recents_history_transition_duration); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 120 | mTouchHandler = new RecentsViewTouchHandler(this); |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 121 | |
| 122 | LayoutInflater inflater = LayoutInflater.from(context); |
| 123 | mHistoryButton = inflater.inflate(R.layout.recents_history_button, this, false); |
| 124 | mHistoryButton.setOnClickListener(new View.OnClickListener() { |
| 125 | @Override |
| 126 | public void onClick(View v) { |
| 127 | EventBus.getDefault().send(new ShowHistoryEvent()); |
| 128 | } |
| 129 | }); |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 130 | } |
| 131 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 132 | /** Set/get the bsp root node */ |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 133 | public void setTaskStack(TaskStack stack) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 134 | RecentsConfiguration config = Recents.getConfiguration(); |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 135 | mStack = stack; |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 136 | if (config.getLaunchState().launchedReuseTaskStackViews) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 137 | if (mTaskStackView != null) { |
| 138 | // If onRecentsHidden is not triggered, we need to the stack view again here |
| 139 | mTaskStackView.reset(); |
| 140 | mTaskStackView.setStack(stack); |
| 141 | } else { |
| 142 | mTaskStackView = new TaskStackView(getContext(), stack); |
| 143 | mTaskStackView.setCallbacks(this); |
| 144 | addView(mTaskStackView); |
| 145 | } |
| 146 | } else { |
| 147 | if (mTaskStackView != null) { |
| 148 | removeView(mTaskStackView); |
| 149 | } |
| 150 | mTaskStackView = new TaskStackView(getContext(), stack); |
| 151 | mTaskStackView.setCallbacks(this); |
| 152 | addView(mTaskStackView); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 153 | } |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 154 | if (indexOfChild(mHistoryButton) == -1) { |
| 155 | addView(mHistoryButton); |
| 156 | } else { |
| 157 | mHistoryButton.bringToFront(); |
| 158 | } |
Winson Chung | 02d4927 | 2014-08-29 13:57:29 -0700 | [diff] [blame] | 159 | |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 160 | // Trigger a new layout |
| 161 | requestLayout(); |
Winson Chung | 19fc117 | 2014-07-31 18:40:03 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 164 | /** |
| 165 | * Returns whether the last task launched was in the freeform stack or not. |
| 166 | */ |
| 167 | public boolean isLastTaskLaunchedFreeform() { |
| 168 | return mLastTaskLaunchedWasFreeform; |
| 169 | } |
| 170 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 171 | /** |
| 172 | * Returns the currently set task stack. |
| 173 | */ |
| 174 | public TaskStack getTaskStack() { |
| 175 | return mStack; |
| 176 | } |
| 177 | |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 178 | /** Gets the next task in the stack - or if the last - the top task */ |
| 179 | public Task getNextTaskOrTopTask(Task taskToSearch) { |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 180 | Task returnTask = null; |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 181 | boolean found = false; |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 182 | if (mTaskStackView != null) { |
| 183 | TaskStack stack = mTaskStackView.getStack(); |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 184 | ArrayList<Task> taskList = stack.getStackTasks(); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 185 | // Iterate the stack views and try and find the focused task |
| 186 | for (int j = taskList.size() - 1; j >= 0; --j) { |
| 187 | Task task = taskList.get(j); |
| 188 | // Return the next task in the line. |
| 189 | if (found) |
| 190 | return task; |
| 191 | // Remember the first possible task as the top task. |
| 192 | if (returnTask == null) |
| 193 | returnTask = task; |
| 194 | if (task == taskToSearch) |
| 195 | found = true; |
| 196 | } |
| 197 | } |
| 198 | return returnTask; |
| 199 | } |
| 200 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 201 | /** Launches the focused task from the first stack if possible */ |
| 202 | public boolean launchFocusedTask() { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 203 | if (mTaskStackView != null) { |
| 204 | TaskStack stack = mTaskStackView.getStack(); |
Winson | 142af42 | 2015-11-09 10:39:57 -0800 | [diff] [blame] | 205 | Task task = mTaskStackView.getFocusedTask(); |
| 206 | if (task != null) { |
| 207 | TaskView taskView = mTaskStackView.getChildViewForTask(task); |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 208 | onTaskViewClicked(mTaskStackView, taskView, stack, task, false, null, |
Winson | 142af42 | 2015-11-09 10:39:57 -0800 | [diff] [blame] | 209 | INVALID_STACK_ID); |
| 210 | return true; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 211 | } |
| 212 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 213 | return false; |
| 214 | } |
| 215 | |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 216 | /** Launches a given task. */ |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 217 | public boolean launchTask(Task task, Rect taskBounds, int destinationStack) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 218 | if (mTaskStackView != null) { |
| 219 | TaskStack stack = mTaskStackView.getStack(); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 220 | // Iterate the stack views and try and find the given task. |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 221 | List<TaskView> taskViews = mTaskStackView.getTaskViews(); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 222 | int taskViewCount = taskViews.size(); |
| 223 | for (int j = 0; j < taskViewCount; j++) { |
| 224 | TaskView tv = taskViews.get(j); |
| 225 | if (tv.getTask() == task) { |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 226 | onTaskViewClicked(mTaskStackView, tv, stack, task, false, |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 227 | taskBounds, destinationStack); |
Skuhne | 8aa7d16 | 2015-03-20 13:40:53 -0700 | [diff] [blame] | 228 | return true; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | return false; |
| 233 | } |
| 234 | |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 235 | /** Requests all task stacks to start their enter-recents animation */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 236 | public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) { |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 237 | // We have to increment/decrement the post animation trigger in case there are no children |
| 238 | // to ensure that it runs |
| 239 | ctx.postAnimationTrigger.increment(); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 240 | if (mTaskStackView != null) { |
| 241 | mTaskStackView.startEnterRecentsAnimation(ctx); |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 242 | } |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 243 | ctx.postAnimationTrigger.decrement(); |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 246 | /** Requests all task stacks to start their exit-recents animation */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 247 | public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 248 | // We have to increment/decrement the post animation trigger in case there are no children |
| 249 | // to ensure that it runs |
| 250 | ctx.postAnimationTrigger.increment(); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 251 | if (mTaskStackView != null) { |
| 252 | mTaskStackView.startExitToHomeAnimation(ctx); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 253 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 254 | ctx.postAnimationTrigger.decrement(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 255 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 256 | // Hide the history button |
| 257 | int taskViewExitToHomeDuration = getResources().getInteger( |
| 258 | R.integer.recents_task_exit_to_home_duration); |
| 259 | hideHistoryButton(taskViewExitToHomeDuration); |
| 260 | |
Winson | 13d3066 | 2015-11-06 15:30:29 -0800 | [diff] [blame] | 261 | // If we are going home, cancel the previous task's window transition |
| 262 | EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null)); |
| 263 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 264 | // Notify sof the exit animation |
Winson | 412e180 | 2015-10-20 16:57:57 -0700 | [diff] [blame] | 265 | EventBus.getDefault().send(new DismissRecentsToHomeAnimationStarted()); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 268 | /** Adds the search bar */ |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 269 | public void setSearchBar(RecentsAppWidgetHostView searchBar) { |
Winson Chung | af3bb69 | 2015-06-03 17:31:39 -0700 | [diff] [blame] | 270 | // Remove the previous search bar if one exists |
| 271 | if (mSearchBar != null && indexOfChild(mSearchBar) > -1) { |
| 272 | removeView(mSearchBar); |
| 273 | } |
| 274 | // Add the new search bar |
| 275 | if (searchBar != null) { |
| 276 | mSearchBar = searchBar; |
| 277 | addView(mSearchBar); |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 278 | } |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 281 | /** Returns whether there is currently a search bar */ |
Winson Chung | aee097c | 2015-04-02 18:16:02 -0700 | [diff] [blame] | 282 | public boolean hasValidSearchBar() { |
| 283 | return mSearchBar != null && !mSearchBar.isReinflateRequired(); |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | /** Sets the visibility of the search bar */ |
| 287 | public void setSearchBarVisibility(int visibility) { |
| 288 | if (mSearchBar != null) { |
| 289 | mSearchBar.setVisibility(visibility); |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 290 | // Always bring the search bar to the top |
| 291 | mSearchBar.bringToFront(); |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 295 | /** |
| 296 | * Returns the last known system insets. |
| 297 | */ |
| 298 | public Rect getSystemInsets() { |
| 299 | return mSystemInsets; |
| 300 | } |
| 301 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 302 | @Override |
| 303 | protected void onAttachedToWindow() { |
| 304 | EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); |
| 305 | EventBus.getDefault().register(mTouchHandler, RecentsActivity.EVENT_BUS_PRIORITY + 1); |
| 306 | super.onAttachedToWindow(); |
| 307 | } |
| 308 | |
| 309 | @Override |
| 310 | protected void onDetachedFromWindow() { |
| 311 | super.onDetachedFromWindow(); |
| 312 | EventBus.getDefault().unregister(this); |
| 313 | EventBus.getDefault().unregister(mTouchHandler); |
| 314 | } |
| 315 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 316 | /** |
| 317 | * This is called with the full size of the window since we are handling our own insets. |
| 318 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 319 | @Override |
| 320 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 321 | RecentsConfiguration config = Recents.getConfiguration(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 322 | int width = MeasureSpec.getSize(widthMeasureSpec); |
| 323 | int height = MeasureSpec.getSize(heightMeasureSpec); |
Winson Chung | bd91297 | 2014-03-18 14:36:35 -0700 | [diff] [blame] | 324 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 325 | // Get the search bar bounds and measure the search bar layout |
Winson Chung | af3bb69 | 2015-06-03 17:31:39 -0700 | [diff] [blame] | 326 | Rect searchBarSpaceBounds = new Rect(); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 327 | if (mSearchBar != null) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 328 | config.getSearchBarBounds(new Rect(0, 0, width, height), mSystemInsets.top, |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 329 | searchBarSpaceBounds); |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 330 | mSearchBar.measure( |
| 331 | MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY), |
| 332 | MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY)); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 335 | Rect taskStackBounds = new Rect(); |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 336 | config.getTaskStackBounds(new Rect(0, 0, width, height), mSystemInsets.top, |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 337 | mSystemInsets.right, searchBarSpaceBounds, taskStackBounds); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 338 | if (mTaskStackView != null && mTaskStackView.getVisibility() != GONE) { |
Winson | 88f00ab | 2015-10-05 17:24:00 -0700 | [diff] [blame] | 339 | mTaskStackView.setTaskStackBounds(taskStackBounds, mSystemInsets); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 340 | mTaskStackView.measure(widthMeasureSpec, heightMeasureSpec); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 341 | } |
| 342 | |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 343 | // Measure the history button with the full space above the stack, but width-constrained |
| 344 | // to the stack |
Winson | 387aac6 | 2015-11-25 11:18:56 -0800 | [diff] [blame] | 345 | Rect historyButtonRect = mTaskStackView.mLayoutAlgorithm.mHistoryButtonRect; |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 346 | measureChild(mHistoryButton, |
Winson | 387aac6 | 2015-11-25 11:18:56 -0800 | [diff] [blame] | 347 | MeasureSpec.makeMeasureSpec(historyButtonRect.width(), MeasureSpec.EXACTLY), |
| 348 | MeasureSpec.makeMeasureSpec(historyButtonRect.height(), |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 349 | MeasureSpec.EXACTLY)); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 350 | setMeasuredDimension(width, height); |
| 351 | } |
| 352 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 353 | /** |
| 354 | * This is called with the full size of the window since we are handling our own insets. |
| 355 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 356 | @Override |
| 357 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 358 | RecentsConfiguration config = Recents.getConfiguration(); |
| 359 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 360 | // Get the search bar bounds so that we lay it out |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 361 | Rect measuredRect = new Rect(0, 0, getMeasuredWidth(), getMeasuredHeight()); |
| 362 | Rect searchBarSpaceBounds = new Rect(); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 363 | if (mSearchBar != null) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 364 | config.getSearchBarBounds(measuredRect, |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 365 | mSystemInsets.top, searchBarSpaceBounds); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 366 | mSearchBar.layout(searchBarSpaceBounds.left, searchBarSpaceBounds.top, |
| 367 | searchBarSpaceBounds.right, searchBarSpaceBounds.bottom); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 370 | if (mTaskStackView != null && mTaskStackView.getVisibility() != GONE) { |
| 371 | mTaskStackView.layout(left, top, left + getMeasuredWidth(), top + getMeasuredHeight()); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 372 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 373 | |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 374 | // Layout the history button left-aligned with the stack, but offset from the top of the |
| 375 | // view |
Winson | 387aac6 | 2015-11-25 11:18:56 -0800 | [diff] [blame] | 376 | Rect historyButtonRect = mTaskStackView.mLayoutAlgorithm.mHistoryButtonRect; |
| 377 | mHistoryButton.layout(historyButtonRect.left, historyButtonRect.top, |
| 378 | historyButtonRect.right, historyButtonRect.bottom); |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 379 | |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 380 | if (mAwaitingFirstLayout) { |
| 381 | mAwaitingFirstLayout = false; |
| 382 | |
| 383 | // If launched via dragging from the nav bar, then we should translate the whole view |
| 384 | // down offscreen |
| 385 | RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState(); |
| 386 | if (launchState.launchedViaDragGesture) { |
| 387 | setTranslationY(getMeasuredHeight()); |
| 388 | } |
| 389 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 390 | } |
| 391 | |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 392 | @Override |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 393 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 394 | mSystemInsets.set(insets.getSystemWindowInsets()); |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 395 | requestLayout(); |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 396 | return insets; |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 399 | @Override |
| 400 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 401 | return mTouchHandler.onInterceptTouchEvent(ev); |
| 402 | } |
| 403 | |
| 404 | @Override |
| 405 | public boolean onTouchEvent(MotionEvent ev) { |
| 406 | return mTouchHandler.onTouchEvent(ev); |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | protected void dispatchDraw(Canvas canvas) { |
| 411 | super.dispatchDraw(canvas); |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 412 | for (int i = mVisibleDockStates.length - 1; i >= 0; i--) { |
| 413 | Drawable d = mVisibleDockStates[i].viewState.dockAreaOverlay; |
| 414 | if (d.getAlpha() > 0) { |
| 415 | d.draw(canvas); |
| 416 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 417 | } |
| 418 | } |
| 419 | |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 420 | @Override |
| 421 | protected boolean verifyDrawable(Drawable who) { |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 422 | for (int i = mVisibleDockStates.length - 1; i >= 0; i--) { |
| 423 | Drawable d = mVisibleDockStates[i].viewState.dockAreaOverlay; |
| 424 | if (d == who) { |
| 425 | return true; |
| 426 | } |
| 427 | } |
| 428 | return super.verifyDrawable(who); |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Jorim Jaggi | 900fb48 | 2015-06-02 15:07:33 -0700 | [diff] [blame] | 431 | public void disableLayersForOneFrame() { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 432 | if (mTaskStackView != null) { |
| 433 | mTaskStackView.disableLayersForOneFrame(); |
Jorim Jaggi | 900fb48 | 2015-06-02 15:07:33 -0700 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 437 | /**** TaskStackView.TaskStackCallbacks Implementation ****/ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 438 | |
| 439 | @Override |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 440 | public void onTaskViewClicked(final TaskStackView stackView, final TaskView tv, |
Filip Gruszczynski | f48b585 | 2015-10-13 10:28:22 -0700 | [diff] [blame] | 441 | final TaskStack stack, final Task task, final boolean lockToTask, |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 442 | final Rect bounds, int destinationStack) { |
Winson | 387aac6 | 2015-11-25 11:18:56 -0800 | [diff] [blame] | 443 | mLastTaskLaunchedWasFreeform = task.isFreeformTask(); |
Winson | 83c1b07 | 2015-11-09 10:48:04 -0800 | [diff] [blame] | 444 | mTransitionHelper.launchTaskFromRecents(stack, task, stackView, tv, lockToTask, bounds, |
| 445 | destinationStack); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 446 | } |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 447 | |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 448 | /**** EventBus Events ****/ |
| 449 | |
| 450 | public final void onBusEvent(DragStartEvent event) { |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 451 | updateVisibleDockRegions(mTouchHandler.getDockStatesForCurrentOrientation(), |
| 452 | TaskStack.DockState.NONE.viewState.dockAreaAlpha); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 455 | public final void onBusEvent(DragDropTargetChangedEvent event) { |
| 456 | if (event.dropTarget == null || !(event.dropTarget instanceof TaskStack.DockState)) { |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 457 | updateVisibleDockRegions(mTouchHandler.getDockStatesForCurrentOrientation(), |
| 458 | TaskStack.DockState.NONE.viewState.dockAreaAlpha); |
| 459 | } else { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 460 | final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget; |
| 461 | updateVisibleDockRegions(new TaskStack.DockState[] {dockState}, -1); |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 462 | } |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | public final void onBusEvent(final DragEndEvent event) { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 466 | // Animate the overlay alpha back to 0 |
| 467 | updateVisibleDockRegions(null, -1); |
| 468 | |
Winson | 479f744 | 2015-11-25 15:16:27 -0800 | [diff] [blame] | 469 | // Handle the case where we drop onto a dock region |
| 470 | if (event.dropTarget instanceof TaskStack.DockState) { |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 471 | final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget; |
| 472 | |
Winson | a0a8ae4 | 2015-12-01 10:43:02 -0800 | [diff] [blame^] | 473 | // Remove the task after it is docked |
| 474 | if (event.taskView.isFocusedTask()) { |
| 475 | mTaskStackView.resetFocusedTask(); |
| 476 | } |
| 477 | event.taskView.animate() |
| 478 | .alpha(0f) |
| 479 | .setDuration(150) |
| 480 | .setInterpolator(mFastOutLinearInInterpolator) |
| 481 | .setUpdateListener(null) |
| 482 | .setListener(null) |
| 483 | .withEndAction(new Runnable() { |
| 484 | @Override |
| 485 | public void run() { |
| 486 | mTaskStackView.getStack().removeTask(event.task); |
| 487 | } |
| 488 | }) |
| 489 | .withLayer() |
| 490 | .start(); |
| 491 | |
Winson | eca4ab6 | 2015-11-04 10:50:28 -0800 | [diff] [blame] | 492 | // Dock the task and launch it |
| 493 | SystemServicesProxy ssp = Recents.getSystemServices(); |
| 494 | ssp.startTaskInDockedMode(event.task.key.id, dockState.createMode); |
| 495 | launchTask(event.task, null, INVALID_STACK_ID); |
Winson | be7607a | 2015-10-01 17:24:51 -0700 | [diff] [blame] | 496 | } |
| 497 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 498 | |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 499 | public final void onBusEvent(DraggingInRecentsEvent event) { |
Jorim Jaggi | 54b1a6d | 2015-11-24 17:48:26 -0800 | [diff] [blame] | 500 | if (mTaskStackView.getTaskViews().size() > 0) { |
| 501 | setTranslationY(event.distanceFromTop - mTaskStackView.getTaskViews().get(0).getY()); |
| 502 | } |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | public final void onBusEvent(DraggingInRecentsEndedEvent event) { |
| 506 | animate().translationY(0f); |
| 507 | } |
| 508 | |
Winson | c29ff00 | 2015-11-20 16:00:45 -0800 | [diff] [blame] | 509 | public final void onBusEvent(ShowHistoryEvent event) { |
| 510 | // Hide the history button when the history view is shown |
| 511 | hideHistoryButton(mHistoryTransitionDuration); |
| 512 | } |
| 513 | |
| 514 | public final void onBusEvent(HideHistoryEvent event) { |
| 515 | // Show the history button when the history view is hidden |
| 516 | showHistoryButton(mHistoryTransitionDuration); |
| 517 | } |
| 518 | |
| 519 | public final void onBusEvent(ShowHistoryButtonEvent event) { |
| 520 | showHistoryButton(150); |
| 521 | } |
| 522 | |
| 523 | public final void onBusEvent(HideHistoryButtonEvent event) { |
| 524 | hideHistoryButton(100); |
| 525 | } |
| 526 | |
| 527 | public final void onBusEvent(DebugFlagsChangedEvent event) { |
| 528 | RecentsDebugFlags debugFlags = Recents.getDebugFlags(); |
| 529 | if (!debugFlags.isHistoryEnabled()) { |
| 530 | hideHistoryButton(100); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Shows the history button. |
| 536 | */ |
| 537 | private void showHistoryButton(int duration) { |
| 538 | RecentsDebugFlags debugFlags = Recents.getDebugFlags(); |
| 539 | if (!debugFlags.isHistoryEnabled()) { |
| 540 | return; |
| 541 | } |
| 542 | |
| 543 | mHistoryButton.setVisibility(View.VISIBLE); |
| 544 | mHistoryButton.animate() |
| 545 | .alpha(1f) |
| 546 | .setDuration(duration) |
| 547 | .setInterpolator(mFastOutSlowInInterpolator) |
| 548 | .withLayer() |
| 549 | .start(); |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * Hides the history button. |
| 554 | */ |
| 555 | private void hideHistoryButton(int duration) { |
| 556 | mHistoryButton.animate() |
| 557 | .alpha(0f) |
| 558 | .setDuration(duration) |
| 559 | .setInterpolator(mFastOutLinearInInterpolator) |
| 560 | .withEndAction(new Runnable() { |
| 561 | @Override |
| 562 | public void run() { |
| 563 | mHistoryButton.setVisibility(View.INVISIBLE); |
| 564 | } |
| 565 | }) |
| 566 | .withLayer() |
| 567 | .start(); |
| 568 | } |
| 569 | |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 570 | /** |
| 571 | * Updates the dock region to match the specified dock state. |
| 572 | */ |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 573 | private void updateVisibleDockRegions(TaskStack.DockState[] newDockStates, int overrideAlpha) { |
| 574 | ArraySet<TaskStack.DockState> newDockStatesSet = new ArraySet<>(); |
| 575 | if (newDockStates != null) { |
| 576 | for (TaskStack.DockState dockState : newDockStates) { |
| 577 | newDockStatesSet.add(dockState); |
| 578 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 579 | } |
Winson | 882072b | 2015-10-12 11:26:33 -0700 | [diff] [blame] | 580 | for (TaskStack.DockState dockState : mVisibleDockStates) { |
| 581 | TaskStack.DockState.ViewState viewState = dockState.viewState; |
| 582 | if (newDockStates == null || !newDockStatesSet.contains(dockState)) { |
| 583 | // This is no longer visible, so hide it |
| 584 | viewState.startAlphaAnimation(0, 150); |
| 585 | } else { |
| 586 | // This state is now visible, update the bounds and show it |
| 587 | int alpha = (overrideAlpha != -1 ? overrideAlpha : viewState.dockAreaAlpha); |
| 588 | viewState.dockAreaOverlay.setBounds( |
| 589 | dockState.getDockedBounds(getMeasuredWidth(), getMeasuredHeight())); |
| 590 | viewState.dockAreaOverlay.setCallback(this); |
| 591 | viewState.startAlphaAnimation(alpha, 150); |
| 592 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 593 | } |
Winson | 4165d336 | 2015-10-10 14:40:35 -0700 | [diff] [blame] | 594 | } |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 595 | |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 596 | public final void onBusEvent(RecentsVisibilityChangedEvent event) { |
| 597 | if (!event.visible) { |
| 598 | // Reset the view state |
| 599 | mAwaitingFirstLayout = true; |
| 600 | mLastTaskLaunchedWasFreeform = false; |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 601 | } |
| 602 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 603 | } |