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