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; |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 20 | import android.app.TaskStackBuilder; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 21 | import android.content.Context; |
| 22 | import android.content.Intent; |
| 23 | import android.graphics.Bitmap; |
| 24 | import android.graphics.Canvas; |
| 25 | import android.graphics.Rect; |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 26 | import android.net.Uri; |
Kenny Guy | 94a07ac | 2014-08-07 15:34:38 +0100 | [diff] [blame] | 27 | import android.os.UserHandle; |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 28 | import android.provider.Settings; |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 29 | import android.util.AttributeSet; |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 30 | import android.view.LayoutInflater; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 31 | import android.view.View; |
Winson Chung | 653f70c2 | 2014-05-19 14:49:42 -0700 | [diff] [blame] | 32 | import android.view.WindowInsets; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 33 | import android.widget.FrameLayout; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 34 | import com.android.systemui.recents.Constants; |
| 35 | import com.android.systemui.recents.RecentsConfiguration; |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 36 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Winson Chung | f1fbd77 | 2014-06-24 18:06:58 -0700 | [diff] [blame] | 37 | import com.android.systemui.recents.model.RecentsPackageMonitor; |
| 38 | import com.android.systemui.recents.model.RecentsTaskLoader; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 39 | import com.android.systemui.recents.model.Task; |
| 40 | import com.android.systemui.recents.model.TaskStack; |
| 41 | |
| 42 | import java.util.ArrayList; |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame^] | 43 | import java.util.List; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 44 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 45 | /** |
| 46 | * This view is the the top level layout that contains TaskStacks (which are laid out according |
| 47 | * to their SpaceNode bounds. |
| 48 | */ |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 49 | public class RecentsView extends FrameLayout implements TaskStackView.TaskStackViewCallbacks, |
| 50 | RecentsPackageMonitor.PackageCallbacks { |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 51 | |
| 52 | /** The RecentsView callbacks */ |
| 53 | public interface RecentsViewCallbacks { |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 54 | public void onTaskViewClicked(); |
Winson Chung | 4e96eb7 | 2014-09-17 15:16:09 +0200 | [diff] [blame] | 55 | public void onTaskLaunchFailed(); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 56 | public void onAllTaskViewsDismissed(); |
Winson Chung | cdbbb7e | 2014-06-24 12:11:49 -0700 | [diff] [blame] | 57 | public void onExitToHomeAnimationTriggered(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 58 | public void onScreenPinningRequest(); |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 61 | RecentsConfiguration mConfig; |
| 62 | LayoutInflater mInflater; |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 63 | DebugOverlayView mDebugOverlay; |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 64 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 65 | ArrayList<TaskStack> mStacks; |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 66 | View mSearchBar; |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 67 | RecentsViewCallbacks mCb; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 68 | |
| 69 | public RecentsView(Context context) { |
| 70 | super(context); |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | public RecentsView(Context context, AttributeSet attrs) { |
| 74 | this(context, attrs, 0); |
| 75 | } |
| 76 | |
| 77 | public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) { |
| 78 | this(context, attrs, defStyleAttr, 0); |
| 79 | } |
| 80 | |
| 81 | public RecentsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 82 | super(context, attrs, defStyleAttr, defStyleRes); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 83 | mConfig = RecentsConfiguration.getInstance(); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 84 | mInflater = LayoutInflater.from(context); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 85 | } |
| 86 | |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 87 | /** Sets the callbacks */ |
| 88 | public void setCallbacks(RecentsViewCallbacks cb) { |
| 89 | mCb = cb; |
| 90 | } |
| 91 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 92 | /** Sets the debug overlay */ |
| 93 | public void setDebugOverlay(DebugOverlayView overlay) { |
| 94 | mDebugOverlay = overlay; |
| 95 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 96 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 97 | /** Set/get the bsp root node */ |
| 98 | public void setTaskStacks(ArrayList<TaskStack> stacks) { |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 99 | int numStacks = stacks.size(); |
| 100 | |
| 101 | // Make a list of the stack view children only |
| 102 | ArrayList<TaskStackView> stackViews = new ArrayList<TaskStackView>(); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 103 | int childCount = getChildCount(); |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 104 | for (int i = 0; i < childCount; i++) { |
| 105 | View child = getChildAt(i); |
| 106 | if (child != mSearchBar) { |
| 107 | stackViews.add((TaskStackView) child); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 108 | } |
| 109 | } |
| 110 | |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 111 | // Remove all/extra stack views |
| 112 | int numTaskStacksToKeep = 0; // Keep no tasks if we are recreating the layout |
| 113 | if (mConfig.launchedReuseTaskStackViews) { |
| 114 | numTaskStacksToKeep = Math.min(childCount, numStacks); |
| 115 | } |
| 116 | for (int i = stackViews.size() - 1; i >= numTaskStacksToKeep; i--) { |
| 117 | removeView(stackViews.get(i)); |
| 118 | stackViews.remove(i); |
| 119 | } |
| 120 | |
| 121 | // Update the stack views that we are keeping |
| 122 | for (int i = 0; i < numTaskStacksToKeep; i++) { |
Winson Chung | bc571a9 | 2014-11-19 17:09:03 -0800 | [diff] [blame] | 123 | TaskStackView tsv = stackViews.get(i); |
| 124 | // If onRecentsHidden is not triggered, we need to the stack view again here |
| 125 | tsv.reset(); |
| 126 | tsv.setStack(stacks.get(i)); |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | // Add remaining/recreate stack views |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 130 | mStacks = stacks; |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 131 | for (int i = stackViews.size(); i < numStacks; i++) { |
| 132 | TaskStack stack = stacks.get(i); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 133 | TaskStackView stackView = new TaskStackView(getContext(), stack); |
| 134 | stackView.setCallbacks(this); |
| 135 | addView(stackView); |
| 136 | } |
Winson Chung | 02d4927 | 2014-08-29 13:57:29 -0700 | [diff] [blame] | 137 | |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 138 | // Enable debug mode drawing on all the stacks if necessary |
| 139 | if (mConfig.debugModeEnabled) { |
| 140 | for (int i = childCount - 1; i >= 0; i--) { |
| 141 | View v = getChildAt(i); |
| 142 | if (v != mSearchBar) { |
| 143 | TaskStackView stackView = (TaskStackView) v; |
| 144 | stackView.setDebugOverlay(mDebugOverlay); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 149 | // Trigger a new layout |
| 150 | requestLayout(); |
Winson Chung | 19fc117 | 2014-07-31 18:40:03 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 153 | /** Launches the focused task from the first stack if possible */ |
| 154 | public boolean launchFocusedTask() { |
| 155 | // Get the first stack view |
| 156 | int childCount = getChildCount(); |
| 157 | for (int i = 0; i < childCount; i++) { |
| 158 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 159 | if (child != mSearchBar) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 160 | TaskStackView stackView = (TaskStackView) child; |
| 161 | TaskStack stack = stackView.mStack; |
| 162 | // Iterate the stack views and try and find the focused task |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame^] | 163 | List<TaskView> taskViews = stackView.getTaskViews(); |
| 164 | int taskViewCount = taskViews.size(); |
| 165 | for (int j = 0; j < taskViewCount; j++) { |
| 166 | TaskView tv = taskViews.get(j); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 167 | Task task = tv.getTask(); |
| 168 | if (tv.isFocusedTask()) { |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 169 | onTaskViewClicked(stackView, tv, stack, task, false); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 170 | return true; |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 175 | return false; |
| 176 | } |
| 177 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 178 | /** Launches the task that Recents was launched from, if possible */ |
| 179 | public boolean launchPreviousTask() { |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 180 | // Get the first stack view |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 181 | int childCount = getChildCount(); |
| 182 | for (int i = 0; i < childCount; i++) { |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 183 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 184 | if (child != mSearchBar) { |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 185 | TaskStackView stackView = (TaskStackView) child; |
| 186 | TaskStack stack = stackView.mStack; |
| 187 | ArrayList<Task> tasks = stack.getTasks(); |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 188 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 189 | // Find the launch task in the stack |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 190 | if (!tasks.isEmpty()) { |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 191 | int taskCount = tasks.size(); |
| 192 | for (int j = 0; j < taskCount; j++) { |
| 193 | if (tasks.get(j).isLaunchTarget) { |
| 194 | Task task = tasks.get(j); |
| 195 | TaskView tv = stackView.getChildViewForTask(task); |
| 196 | onTaskViewClicked(stackView, tv, stack, task, false); |
| 197 | return true; |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 198 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 199 | } |
| 200 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | return false; |
| 204 | } |
| 205 | |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 206 | /** Requests all task stacks to start their enter-recents animation */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 207 | public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) { |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 208 | // We have to increment/decrement the post animation trigger in case there are no children |
| 209 | // to ensure that it runs |
| 210 | ctx.postAnimationTrigger.increment(); |
| 211 | |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 212 | int childCount = getChildCount(); |
| 213 | for (int i = 0; i < childCount; i++) { |
| 214 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 215 | if (child != mSearchBar) { |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 216 | TaskStackView stackView = (TaskStackView) child; |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 217 | stackView.startEnterRecentsAnimation(ctx); |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 218 | } |
| 219 | } |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 220 | ctx.postAnimationTrigger.decrement(); |
Winson Chung | 24cf152 | 2014-05-29 12:03:33 -0700 | [diff] [blame] | 221 | } |
| 222 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 223 | /** Requests all task stacks to start their exit-recents animation */ |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 224 | public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 225 | // We have to increment/decrement the post animation trigger in case there are no children |
| 226 | // to ensure that it runs |
| 227 | ctx.postAnimationTrigger.increment(); |
Winson Chung | d7b2cb1 | 2014-06-26 15:08:50 -0700 | [diff] [blame] | 228 | int childCount = getChildCount(); |
| 229 | for (int i = 0; i < childCount; i++) { |
| 230 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 231 | if (child != mSearchBar) { |
Winson Chung | d7b2cb1 | 2014-06-26 15:08:50 -0700 | [diff] [blame] | 232 | TaskStackView stackView = (TaskStackView) child; |
| 233 | stackView.startExitToHomeAnimation(ctx); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 234 | } |
| 235 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 236 | ctx.postAnimationTrigger.decrement(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 237 | |
Winson Chung | 969f586 | 2014-06-16 17:08:24 -0700 | [diff] [blame] | 238 | // Notify of the exit animation |
Winson Chung | cdbbb7e | 2014-06-24 12:11:49 -0700 | [diff] [blame] | 239 | mCb.onExitToHomeAnimationTriggered(); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 242 | /** Adds the search bar */ |
| 243 | public void setSearchBar(View searchBar) { |
| 244 | // Create the search bar (and hide it if we have no recent tasks) |
Winson Chung | 814086d | 2014-05-07 15:01:14 -0700 | [diff] [blame] | 245 | if (Constants.DebugFlags.App.EnableSearchLayout) { |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 246 | // Remove the previous search bar if one exists |
| 247 | if (mSearchBar != null && indexOfChild(mSearchBar) > -1) { |
| 248 | removeView(mSearchBar); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 249 | } |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 250 | // Add the new search bar |
| 251 | if (searchBar != null) { |
| 252 | mSearchBar = searchBar; |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 253 | addView(mSearchBar); |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 254 | } |
| 255 | } |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 258 | /** Returns whether there is currently a search bar */ |
| 259 | public boolean hasSearchBar() { |
| 260 | return mSearchBar != null; |
| 261 | } |
| 262 | |
| 263 | /** Sets the visibility of the search bar */ |
| 264 | public void setSearchBarVisibility(int visibility) { |
| 265 | if (mSearchBar != null) { |
| 266 | mSearchBar.setVisibility(visibility); |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 267 | // Always bring the search bar to the top |
| 268 | mSearchBar.bringToFront(); |
Winson Chung | 772b6b1 | 2014-07-03 15:54:02 -0700 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 272 | /** |
| 273 | * This is called with the full size of the window since we are handling our own insets. |
| 274 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 275 | @Override |
| 276 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 277 | int width = MeasureSpec.getSize(widthMeasureSpec); |
| 278 | int height = MeasureSpec.getSize(heightMeasureSpec); |
Winson Chung | bd91297 | 2014-03-18 14:36:35 -0700 | [diff] [blame] | 279 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 280 | // Get the search bar bounds and measure the search bar layout |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 281 | if (mSearchBar != null) { |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 282 | Rect searchBarSpaceBounds = new Rect(); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 283 | mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds); |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 284 | mSearchBar.measure( |
| 285 | MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY), |
| 286 | MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY)); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 289 | Rect taskStackBounds = new Rect(); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 290 | mConfig.getTaskStackBounds(width, height, mConfig.systemInsets.top, |
| 291 | mConfig.systemInsets.right, taskStackBounds); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 292 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 293 | // Measure each TaskStackView with the full width and height of the window since the |
| 294 | // transition view is a child of that stack view |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 295 | int childCount = getChildCount(); |
| 296 | for (int i = 0; i < childCount; i++) { |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 297 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 298 | if (child != mSearchBar && child.getVisibility() != GONE) { |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 299 | TaskStackView tsv = (TaskStackView) child; |
| 300 | // Set the insets to be the top/left inset + search bounds |
| 301 | tsv.setStackInsetRect(taskStackBounds); |
| 302 | tsv.measure(widthMeasureSpec, heightMeasureSpec); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | |
| 306 | setMeasuredDimension(width, height); |
| 307 | } |
| 308 | |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 309 | /** |
| 310 | * This is called with the full size of the window since we are handling our own insets. |
| 311 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 312 | @Override |
| 313 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 314 | // Get the search bar bounds so that we lay it out |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 315 | if (mSearchBar != null) { |
Winson Chung | f7bca43 | 2014-04-30 17:11:13 -0700 | [diff] [blame] | 316 | Rect searchBarSpaceBounds = new Rect(); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 317 | mConfig.getSearchBarBounds(getMeasuredWidth(), getMeasuredHeight(), |
| 318 | mConfig.systemInsets.top, searchBarSpaceBounds); |
| 319 | mSearchBar.layout(searchBarSpaceBounds.left, searchBarSpaceBounds.top, |
| 320 | searchBarSpaceBounds.right, searchBarSpaceBounds.bottom); |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 323 | // Layout each TaskStackView with the full width and height of the window since the |
| 324 | // transition view is a child of that stack view |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 325 | int childCount = getChildCount(); |
| 326 | for (int i = 0; i < childCount; i++) { |
Winson Chung | ecd9b30 | 2014-04-16 17:07:18 -0700 | [diff] [blame] | 327 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 328 | if (child != mSearchBar && child.getVisibility() != GONE) { |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 329 | child.layout(left, top, left + child.getMeasuredWidth(), |
| 330 | top + child.getMeasuredHeight()); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 335 | @Override |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 336 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 337 | // Update the configuration with the latest system insets and trigger a relayout |
| 338 | mConfig.updateSystemInsets(insets.getSystemWindowInsets()); |
| 339 | requestLayout(); |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 340 | return insets.consumeSystemWindowInsets(); |
Winson Chung | 8eaeb7d | 2014-06-25 15:10:59 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 343 | /** Notifies each task view of the user interaction. */ |
| 344 | public void onUserInteraction() { |
| 345 | // Get the first stack view |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 346 | int childCount = getChildCount(); |
| 347 | for (int i = 0; i < childCount; i++) { |
| 348 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 349 | if (child != mSearchBar) { |
Winson Chung | a0e88b5 | 2014-08-11 19:25:42 -0700 | [diff] [blame] | 350 | TaskStackView stackView = (TaskStackView) child; |
Winson Chung | a26fb78 | 2014-06-12 17:52:39 -0700 | [diff] [blame] | 351 | stackView.onUserInteraction(); |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 356 | /** Focuses the next task in the first stack view */ |
| 357 | public void focusNextTask(boolean forward) { |
| 358 | // Get the first stack view |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 359 | int childCount = getChildCount(); |
| 360 | for (int i = 0; i < childCount; i++) { |
| 361 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 362 | if (child != mSearchBar) { |
Winson Chung | a0e88b5 | 2014-08-11 19:25:42 -0700 | [diff] [blame] | 363 | TaskStackView stackView = (TaskStackView) child; |
Winson Chung | d213a1e | 2014-10-02 11:18:30 -0700 | [diff] [blame] | 364 | stackView.focusNextTask(forward, true); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 365 | break; |
| 366 | } |
| 367 | } |
Winson Chung | a0e88b5 | 2014-08-11 19:25:42 -0700 | [diff] [blame] | 368 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 369 | |
Winson Chung | a0e88b5 | 2014-08-11 19:25:42 -0700 | [diff] [blame] | 370 | /** Dismisses the focused task. */ |
| 371 | public void dismissFocusedTask() { |
| 372 | // Get the first stack view |
| 373 | int childCount = getChildCount(); |
| 374 | for (int i = 0; i < childCount; i++) { |
| 375 | View child = getChildAt(i); |
| 376 | if (child != mSearchBar) { |
| 377 | TaskStackView stackView = (TaskStackView) child; |
| 378 | stackView.dismissFocusedTask(); |
| 379 | break; |
| 380 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 384 | /** Unfilters any filtered stacks */ |
| 385 | public boolean unfilterFilteredStacks() { |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 386 | if (mStacks != null) { |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 387 | // Check if there are any filtered stacks and unfilter them before we back out of Recents |
| 388 | boolean stacksUnfiltered = false; |
Winson Chung | dcfa797 | 2014-07-22 12:27:13 -0700 | [diff] [blame] | 389 | int numStacks = mStacks.size(); |
| 390 | for (int i = 0; i < numStacks; i++) { |
| 391 | TaskStack stack = mStacks.get(i); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 392 | if (stack.hasFilteredTasks()) { |
| 393 | stack.unfilterTasks(); |
| 394 | stacksUnfiltered = true; |
| 395 | } |
| 396 | } |
| 397 | return stacksUnfiltered; |
| 398 | } |
| 399 | return false; |
| 400 | } |
| 401 | |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 402 | /**** TaskStackView.TaskStackCallbacks Implementation ****/ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 403 | |
| 404 | @Override |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 405 | public void onTaskViewClicked(final TaskStackView stackView, final TaskView tv, |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 406 | final TaskStack stack, final Task task, final boolean lockToTask) { |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 407 | // Notify any callbacks of the launching of a new task |
| 408 | if (mCb != null) { |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 409 | mCb.onTaskViewClicked(); |
Winson Chung | 47c4c69 | 2014-03-17 10:17:11 -0700 | [diff] [blame] | 410 | } |
| 411 | |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 412 | // Upfront the processing of the thumbnail |
Winson Chung | ffa2ec6 | 2014-07-03 15:54:42 -0700 | [diff] [blame] | 413 | TaskViewTransform transform = new TaskViewTransform(); |
Jorim Jaggi | cb55703 | 2014-09-16 23:09:24 +0200 | [diff] [blame] | 414 | View sourceView; |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 415 | int offsetX = 0; |
| 416 | int offsetY = 0; |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 417 | float stackScroll = stackView.getScroller().getStackScroll(); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 418 | if (tv == null) { |
| 419 | // If there is no actual task view, then use the stack view as the source view |
| 420 | // and then offset to the expected transform rect, but bound this to just |
| 421 | // outside the display rect (to ensure we don't animate from too far away) |
| 422 | sourceView = stackView; |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 423 | transform = stackView.getStackAlgorithm().getStackTransform(task, stackScroll, transform, null); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 424 | offsetX = transform.rect.left; |
Winson Chung | e41ab84 | 2014-08-07 15:55:37 -0700 | [diff] [blame] | 425 | offsetY = mConfig.displayRect.height(); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 426 | } else { |
Jorim Jaggi | cb55703 | 2014-09-16 23:09:24 +0200 | [diff] [blame] | 427 | sourceView = tv.mThumbnailView; |
Winson Chung | 012ef36 | 2014-07-31 18:36:25 -0700 | [diff] [blame] | 428 | transform = stackView.getStackAlgorithm().getStackTransform(task, stackScroll, transform, null); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | // Compute the thumbnail to scale up from |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 432 | final SystemServicesProxy ssp = |
| 433 | RecentsTaskLoader.getInstance().getSystemServicesProxy(); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 434 | ActivityOptions opts = null; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 435 | if (task.thumbnail != null && task.thumbnail.getWidth() > 0 && |
| 436 | task.thumbnail.getHeight() > 0) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 437 | Bitmap b; |
| 438 | if (tv != null) { |
| 439 | // Disable any focused state before we draw the header |
| 440 | if (tv.isFocusedTask()) { |
| 441 | tv.unsetFocusedTask(); |
| 442 | } |
| 443 | |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 444 | float scale = tv.getScaleX(); |
| 445 | int fromHeaderWidth = (int) (tv.mHeaderView.getMeasuredWidth() * scale); |
| 446 | int fromHeaderHeight = (int) (tv.mHeaderView.getMeasuredHeight() * scale); |
| 447 | b = Bitmap.createBitmap(fromHeaderWidth, fromHeaderHeight, |
| 448 | Bitmap.Config.ARGB_8888); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 449 | if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) { |
| 450 | b.eraseColor(0xFFff0000); |
| 451 | } else { |
| 452 | Canvas c = new Canvas(b); |
| 453 | c.scale(tv.getScaleX(), tv.getScaleY()); |
| 454 | tv.mHeaderView.draw(c); |
| 455 | c.setBitmap(null); |
| 456 | } |
| 457 | } else { |
| 458 | // Notify the system to skip the thumbnail layer by using an ALPHA_8 bitmap |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 459 | b = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 460 | } |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 461 | ActivityOptions.OnAnimationStartedListener animStartedListener = null; |
| 462 | if (lockToTask) { |
| 463 | animStartedListener = new ActivityOptions.OnAnimationStartedListener() { |
| 464 | boolean mTriggered = false; |
| 465 | @Override |
| 466 | public void onAnimationStarted() { |
| 467 | if (!mTriggered) { |
| 468 | postDelayed(new Runnable() { |
| 469 | @Override |
| 470 | public void run() { |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 471 | mCb.onScreenPinningRequest(); |
Winson Chung | 1f24c7e | 2014-07-11 17:06:48 -0700 | [diff] [blame] | 472 | } |
| 473 | }, 350); |
| 474 | mTriggered = true; |
| 475 | } |
| 476 | } |
| 477 | }; |
| 478 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 479 | opts = ActivityOptions.makeThumbnailAspectScaleUpAnimation(sourceView, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 480 | b, offsetX, offsetY, transform.rect.width(), transform.rect.height(), |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 481 | sourceView.getHandler(), animStartedListener); |
Winson Chung | e0e45bc | 2014-06-17 17:56:17 -0700 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | final ActivityOptions launchOpts = opts; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 485 | final Runnable launchRunnable = new Runnable() { |
| 486 | @Override |
| 487 | public void run() { |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 488 | if (task.isActive) { |
| 489 | // Bring an active task to the foreground |
Craig Mautner | dc00cbe | 2014-07-20 17:48:47 -0700 | [diff] [blame] | 490 | ssp.moveTaskToFront(task.key.id, launchOpts); |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 491 | } else { |
Winson Chung | 4e96eb7 | 2014-09-17 15:16:09 +0200 | [diff] [blame] | 492 | if (ssp.startActivityFromRecents(getContext(), task.key.id, |
| 493 | task.activityLabel, launchOpts)) { |
Craig Mautner | dc00cbe | 2014-07-20 17:48:47 -0700 | [diff] [blame] | 494 | if (launchOpts == null && lockToTask) { |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 495 | mCb.onScreenPinningRequest(); |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 496 | } |
Winson Chung | 4e96eb7 | 2014-09-17 15:16:09 +0200 | [diff] [blame] | 497 | } else { |
| 498 | // Dismiss the task and return the user to home if we fail to |
| 499 | // launch the task |
| 500 | onTaskViewDismissed(task); |
| 501 | if (mCb != null) { |
| 502 | mCb.onTaskLaunchFailed(); |
| 503 | } |
Winson Chung | 4be0445 | 2014-03-24 17:22:30 -0700 | [diff] [blame] | 504 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 505 | } |
| 506 | } |
| 507 | }; |
| 508 | |
| 509 | // 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] | 510 | if (tv == null) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 511 | launchRunnable.run(); |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 512 | } else { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 513 | if (!task.group.isFrontMostTask(task)) { |
| 514 | // For affiliated tasks that are behind other tasks, we must animate the front cards |
| 515 | // out of view before starting the task transition |
Winson Chung | ebfc698 | 2014-08-26 12:25:34 -0700 | [diff] [blame] | 516 | stackView.startLaunchTaskAnimation(tv, launchRunnable, lockToTask); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 517 | } else { |
| 518 | // Otherwise, we can start the task transition immediately |
Winson Chung | ebfc698 | 2014-08-26 12:25:34 -0700 | [diff] [blame] | 519 | stackView.startLaunchTaskAnimation(tv, null, lockToTask); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 520 | launchRunnable.run(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 521 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 522 | } |
| 523 | } |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 524 | |
| 525 | @Override |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 526 | public void onTaskViewAppInfoClicked(Task t) { |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 527 | // Create a new task stack with the application info details activity |
| 528 | Intent baseIntent = t.key.baseIntent; |
| 529 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, |
| 530 | Uri.fromParts("package", baseIntent.getComponent().getPackageName(), null)); |
| 531 | intent.setComponent(intent.resolveActivity(getContext().getPackageManager())); |
| 532 | TaskStackBuilder.create(getContext()) |
Kenny Guy | 94a07ac | 2014-08-07 15:34:38 +0100 | [diff] [blame] | 533 | .addNextIntentWithParentStack(intent).startActivities(null, |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 534 | new UserHandle(t.key.userId)); |
Winson Chung | 9f9679d | 2014-04-11 16:49:09 -0700 | [diff] [blame] | 535 | } |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 536 | |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 537 | @Override |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 538 | public void onTaskViewDismissed(Task t) { |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 539 | // Remove any stored data from the loader. We currently don't bother notifying the views |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 540 | // that the data has been unloaded because at the point we call onTaskViewDismissed(), the views |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 541 | // either don't need to be updated, or have already been removed. |
| 542 | RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); |
| 543 | loader.deleteTaskData(t, false); |
| 544 | |
| 545 | // Remove the old task from activity manager |
Winson Chung | 2cf8b22 | 2015-01-20 11:44:05 -0800 | [diff] [blame] | 546 | loader.getSystemServicesProxy().removeTask(t.key.id); |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 549 | @Override |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame^] | 550 | public void onAllTaskViewsDismissed(ArrayList<Task> removedTasks) { |
| 551 | if (removedTasks != null) { |
| 552 | int taskCount = removedTasks.size(); |
| 553 | for (int i = 0; i < taskCount; i++) { |
| 554 | onTaskViewDismissed(removedTasks.get(i)); |
| 555 | } |
| 556 | } |
| 557 | |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 558 | mCb.onAllTaskViewsDismissed(); |
Winson Chung | d7b2cb1 | 2014-06-26 15:08:50 -0700 | [diff] [blame] | 559 | } |
| 560 | |
Winson Chung | b0a28ea | 2014-10-28 15:21:35 -0700 | [diff] [blame] | 561 | /** Final callback after Recents is finally hidden. */ |
| 562 | public void onRecentsHidden() { |
| 563 | // Notify each task stack view |
| 564 | int childCount = getChildCount(); |
| 565 | for (int i = 0; i < childCount; i++) { |
| 566 | View child = getChildAt(i); |
| 567 | if (child != mSearchBar) { |
| 568 | TaskStackView stackView = (TaskStackView) child; |
| 569 | stackView.onRecentsHidden(); |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
Winson Chung | d7b2cb1 | 2014-06-26 15:08:50 -0700 | [diff] [blame] | 574 | @Override |
Winson Chung | 8e548f7 | 2014-06-24 14:40:53 -0700 | [diff] [blame] | 575 | public void onTaskStackFilterTriggered() { |
| 576 | // Hide the search bar |
| 577 | if (mSearchBar != null) { |
| 578 | mSearchBar.animate() |
| 579 | .alpha(0f) |
| 580 | .setStartDelay(0) |
| 581 | .setInterpolator(mConfig.fastOutSlowInInterpolator) |
| 582 | .setDuration(mConfig.filteringCurrentViewsAnimDuration) |
| 583 | .withLayer() |
| 584 | .start(); |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | @Override |
| 589 | public void onTaskStackUnfilterTriggered() { |
| 590 | // Show the search bar |
| 591 | if (mSearchBar != null) { |
| 592 | mSearchBar.animate() |
| 593 | .alpha(1f) |
| 594 | .setStartDelay(0) |
| 595 | .setInterpolator(mConfig.fastOutSlowInInterpolator) |
| 596 | .setDuration(mConfig.filteringNewViewsAnimDuration) |
| 597 | .withLayer() |
| 598 | .start(); |
| 599 | } |
| 600 | } |
| 601 | |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 602 | /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/ |
| 603 | |
| 604 | @Override |
Winson Chung | 0440067 | 2014-10-17 14:53:30 -0700 | [diff] [blame] | 605 | public void onPackagesChanged(RecentsPackageMonitor monitor, String packageName, int userId) { |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 606 | // Propagate this event down to each task stack view |
| 607 | int childCount = getChildCount(); |
| 608 | for (int i = 0; i < childCount; i++) { |
| 609 | View child = getChildAt(i); |
Winson Chung | 7aceb9a | 2014-07-03 13:38:01 -0700 | [diff] [blame] | 610 | if (child != mSearchBar) { |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 611 | TaskStackView stackView = (TaskStackView) child; |
Winson Chung | 0440067 | 2014-10-17 14:53:30 -0700 | [diff] [blame] | 612 | stackView.onPackagesChanged(monitor, packageName, userId); |
Winson Chung | 9f49df9 | 2014-05-07 18:08:34 -0700 | [diff] [blame] | 613 | } |
| 614 | } |
| 615 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 616 | } |