OSDN Git Service

Bug fixes and cleanup
authorWinson Chung <winsonc@google.com>
Thu, 3 Jul 2014 20:38:01 +0000 (13:38 -0700)
committerWinson Chung <winsonc@google.com>
Thu, 3 Jul 2014 20:39:33 +0000 (13:39 -0700)
- Don't reinflate the search bar view every time you return to recents
- Fixing an issue where the default thumbnail was not being used when querying the thumbnail cache (thought WM still seems to not be giving us screenshots in many cases)
- Fixing an issue where an invisible header bar color was used instead of the default header bar color
- Fixing an issue where swipe-to-dismiss logic was running before the animation back into place
- Using outline clipping instead of doing it ourselves for the rounded TaskView
- Small optimization in finding the visible range
- Renaming some of the callbacks to make them more clear
- Removing some unused code

12 files changed:
packages/SystemUI/src/com/android/systemui/recents/Console.java
packages/SystemUI/src/com/android/systemui/recents/Constants.java
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
packages/SystemUI/src/com/android/systemui/recents/views/TaskBarView.java
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java

index 33e05dd..0cb74b9 100644 (file)
@@ -43,7 +43,7 @@ public class Console {
     public static final String AnsiWhite = "\u001B[37m";
 
     // Console enabled state
-    public static final boolean Enabled = false;
+    public static boolean Enabled = false;
 
     /** Logs a key */
     public static void log(String key) {
index 4fb1918..7a49a04 100644 (file)
@@ -55,9 +55,9 @@ public class Constants {
             public static final String TimeRecentsStartupKey = "startup";
             public static final String TimeRecentsLaunchKey = "launchTask";
             public static final String TimeRecentsScreenshotTransitionKey = "screenshot";
-            public static final boolean TimeRecentsStartup = true;
-            public static final boolean TimeRecentsLaunchTask = true;
-            public static final boolean TimeRecentsScreenshotTransition = true;
+            public static final boolean TimeRecentsStartup = false;
+            public static final boolean TimeRecentsLaunchTask = false;
+            public static final boolean TimeRecentsScreenshotTransition = false;
 
 
             public static final boolean RecentsComponent = false;
index 4c52b24..c42e227 100644 (file)
@@ -65,7 +65,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
     AppWidgetHostView mSearchAppWidgetHostView;
 
     boolean mVisible;
-    boolean mTaskLaunched;
 
     // Runnables to finish the Recents activity
     FinishRecentsRunnable mFinishRunnable = new FinishRecentsRunnable(true);
@@ -198,9 +197,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
                 AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
         mConfig.launchedWithNoRecentTasks = !root.hasTasks();
 
-        // Show the scrim if we animate into Recents without window transitions
-        mScrimViews.prepareEnterRecentsAnimation();
-
         // Add the default no-recents layout
         if (mEmptyView == null) {
             mEmptyView = mEmptyViewStub.inflate();
@@ -210,6 +206,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
         } else {
             mEmptyView.setVisibility(View.GONE);
         }
+
+        // Show the scrim if we animate into Recents without window transitions
+        mScrimViews.prepareEnterRecentsAnimation();
     }
 
     /** Attempts to allocate and bind the search bar app widget */
@@ -355,13 +354,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
         // Update the recent tasks
         updateRecentsTasks(getIntent());
 
-        // Prepare the screenshot transition if necessary
-        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
-            mFullScreenOverlayView = (FullscreenTransitionOverlayView) mFullscreenOverlayStub.inflate();
-            mFullScreenOverlayView.setCallbacks(this);
-            mFullScreenOverlayView.prepareAnimateOnEnterRecents(AlternateRecentsComponent.getLastScreenshot());
-        }
-
         // Bind the search app widget when we first start up
         bindSearchBarAppWidget();
         // Add the search bar layout
@@ -390,6 +382,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
         } catch (InvocationTargetException e) {
             e.printStackTrace();
         }
+
+        // Prepare the screenshot transition if necessary
+        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
+            mFullScreenOverlayView = (FullscreenTransitionOverlayView) mFullscreenOverlayStub.inflate();
+            mFullScreenOverlayView.setCallbacks(this);
+            mFullScreenOverlayView.prepareAnimateOnEnterRecents(AlternateRecentsComponent.getLastScreenshot());
+        }
     }
 
     void onConfigurationChange() {
@@ -404,8 +403,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
     @Override
     protected void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
-        // Reset the task launched flag if we encounter an onNewIntent() before onStop()
-        mTaskLaunched = false;
 
         if (Console.Enabled) {
             Console.logDivider(Constants.Log.App.SystemUIHandshake);
@@ -426,9 +423,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
         if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
             mFullScreenOverlayView.prepareAnimateOnEnterRecents(AlternateRecentsComponent.getLastScreenshot());
         }
-
-        // Don't attempt to rebind the search bar widget, but just add the search bar layout
-        addSearchBarAppWidgetView();
     }
 
     @Override
@@ -509,7 +503,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
         }
 
         mVisible = false;
-        mTaskLaunched = false;
     }
 
     @Override
@@ -632,15 +625,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
     }
 
     @Override
-    public void onTaskLaunching() {
-        mTaskLaunched = true;
-
+    public void onTaskViewClicked() {
         // Mark recents as no longer visible
         AlternateRecentsComponent.notifyVisibilityChanged(false);
     }
 
     @Override
-    public void onLastTaskRemoved() {
+    public void onAllTaskViewsDismissed() {
         mFinishLaunchHomeRunnable.run();
     }
 
index d57f779..3041a3c 100644 (file)
@@ -149,6 +149,9 @@ public class RecentsConfiguration {
 
         // Debug mode
         debugModeEnabled = settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false);
+        if (debugModeEnabled) {
+            Console.Enabled = true;
+        }
 
         // Animations
         animationPxMovementPerSecond =
index b6895d1..49149a6 100644 (file)
@@ -69,7 +69,7 @@ class SystemUIMessageHandler extends Handler {
                 // since that is done when we compute the animation itself in the Recents component
 
                 // Create a dummy task stack & compute the rect for the thumbnail to animate to
-                TaskStack stack = new TaskStack(context);
+                TaskStack stack = new TaskStack();
                 TaskStackView tsv = new TaskStackView(context, stack);
                 TaskStackViewLayoutAlgorithm algo = tsv.getStackAlgorithm();
                 Bundle replyData = new Bundle();
index 15f4a76..9d8d746 100644 (file)
@@ -239,13 +239,14 @@ class TaskResourceLoader implements Runnable {
                                 }
                                 thumbnail.setHasAlpha(false);
                                 loadThumbnail = thumbnail;
-                                mThumbnailCache.put(t.key, thumbnail);
                             } else {
                                 loadThumbnail = mDefaultThumbnail;
                                 Console.logError(mContext,
                                         "Failed to load task top thumbnail for: " +
                                                 t.key.baseIntent.getComponent().getPackageName());
                             }
+                            // We put the default thumbnail in the cache anyways
+                            mThumbnailCache.put(t.key, loadThumbnail);
                         }
                     }
                     if (!mCancelled) {
@@ -321,6 +322,17 @@ public class RecentsTaskLoader {
                     " iconCache: " + iconCacheSize);
         }
 
+        // Create the default assets
+        Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
+        icon.eraseColor(0x00000000);
+        mDefaultThumbnail = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
+        mDefaultThumbnail.setHasAlpha(false);
+        mDefaultThumbnail.eraseColor(0xFFffffff);
+        mLoadingThumbnail = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
+        mLoadingThumbnail.setHasAlpha(false);
+        mLoadingThumbnail.eraseColor(0xFFffffff);
+        mDefaultApplicationIcon = new BitmapDrawable(context.getResources(), icon);
+
         // Initialize the proxy, cache and loaders
         mSystemServicesProxy = new SystemServicesProxy(context);
         mPackageMonitor = new RecentsPackageMonitor();
@@ -330,14 +342,6 @@ public class RecentsTaskLoader {
         mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache,
                 mDefaultThumbnail);
 
-        // Create the default assets
-        Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
-        icon.eraseColor(0x00000000);
-        mDefaultThumbnail = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
-        mDefaultThumbnail.eraseColor(0xFFffffff);
-        mLoadingThumbnail = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
-        mLoadingThumbnail.eraseColor(0x00000000);
-        mDefaultApplicationIcon = new BitmapDrawable(context.getResources(), icon);
         if (Console.Enabled) {
             Console.log(Constants.Log.App.TaskDataLoader,
                     "[RecentsTaskLoader|defaultBitmaps]",
@@ -392,7 +396,7 @@ public class RecentsTaskLoader {
         RecentsConfiguration config = RecentsConfiguration.getInstance();
         Resources res = context.getResources();
         ArrayList<Task> tasksToForceLoad = new ArrayList<Task>();
-        TaskStack stack = new TaskStack(context);
+        TaskStack stack = new TaskStack();
         SpaceNode root = new SpaceNode(context);
         root.setStack(stack);
 
@@ -416,7 +420,9 @@ public class RecentsTaskLoader {
                 activityLabel = (av.getLabel() != null ? av.getLabel() : ssp.getActivityLabel(info));
                 activityIcon = (av.getIcon() != null) ?
                         ssp.getBadgedIcon(new BitmapDrawable(res, av.getIcon()), t.userId) : null;
-                activityColor = av.getPrimaryColor();
+                if (av.getPrimaryColor() != 0) {
+                    activityColor = av.getPrimaryColor();
+                }
             } else {
                 activityLabel = ssp.getActivityLabel(info);
             }
@@ -464,10 +470,10 @@ public class RecentsTaskLoader {
                         task.thumbnail = ssp.getTaskThumbnail(task.key.id);
                         if (task.thumbnail != null) {
                             task.thumbnail.setHasAlpha(false);
-                            mThumbnailCache.put(task.key, task.thumbnail);
                         } else {
                             task.thumbnail = mDefaultThumbnail;
                         }
+                        mThumbnailCache.put(task.key, task.thumbnail);
                     } else {
                         // Either the task has updated, or we haven't cached any information for the
                         // task, so reload it
index d2de185..24e01bd 100644 (file)
@@ -139,13 +139,10 @@ public class TaskStack {
         public void onStackUnfiltered(TaskStack newStack, ArrayList<Task> curTasks);
     }
 
-    Context mContext;
-
     FilteredTaskList mTaskList = new FilteredTaskList();
     TaskStackCallbacks mCb;
 
-    public TaskStack(Context context) {
-        mContext = context;
+    public TaskStack() {
     }
 
     /** Sets the callbacks for this task stack */
index b5b9cb5..5efbb60 100644 (file)
@@ -55,8 +55,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
 
     /** The RecentsView callbacks */
     public interface RecentsViewCallbacks {
-        public void onTaskLaunching();
-        public void onLastTaskRemoved();
+        public void onTaskViewClicked();
+        public void onAllTaskViewsDismissed();
         public void onExitToHomeAnimationTriggered();
     }
 
@@ -100,9 +100,17 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
     public void setBSP(SpaceNode n) {
         mBSP = n;
 
+        // Remove all TaskStackViews (but leave the search bar)
+        int childCount = getChildCount();
+        for (int i = childCount - 1; i >= 0; i--) {
+            View v = getChildAt(i);
+            if (v != mSearchBar) {
+                removeViewAt(i);
+            }
+        }
+
         // Create and add all the stacks for this partition of space.
         mHasTasks = false;
-        removeAllViews();
         ArrayList<TaskStack> stacks = mBSP.getStacks();
         for (TaskStack stack : stacks) {
             TaskStackView stackView = new TaskStackView(getContext(), stack);
@@ -127,7 +135,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 TaskStackView stackView = (TaskStackView) child;
                 TaskStack stack = stackView.mStack;
                 // Iterate the stack views and try and find the focused task
@@ -140,7 +148,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                             Console.log(Constants.Log.UI.Focus, "[RecentsView|launchFocusedTask]",
                                     "Found focused Task");
                         }
-                        onTaskLaunched(stackView, tv, stack, task);
+                        onTaskViewClicked(stackView, tv, stack, task);
                         return true;
                     }
                 }
@@ -159,7 +167,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 TaskStackView stackView = (TaskStackView) child;
                 TaskStack stack = stackView.mStack;
                 ArrayList<Task> tasks = stack.getTasks();
@@ -176,7 +184,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                             tv = stv;
                         }
                     }
-                    onTaskLaunched(stackView, tv, stack, task);
+                    onTaskViewClicked(stackView, tv, stack, task);
                     return true;
                 }
             }
@@ -193,7 +201,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 TaskStackView stackView = (TaskStackView) child;
                 stackView.startEnterRecentsAnimation(ctx);
             }
@@ -213,7 +221,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 TaskStackView stackView = (TaskStackView) child;
                 stackView.startExitToHomeAnimation(ctx);
             }
@@ -289,7 +297,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView && child.getVisibility() != GONE) {
+            if (child != mSearchBar && child.getVisibility() != GONE) {
                 child.measure(MeasureSpec.makeMeasureSpec(childWidth, widthMode),
                         MeasureSpec.makeMeasureSpec(childHeight, heightMode));
             }
@@ -333,7 +341,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView && child.getVisibility() != GONE) {
+            if (child != mSearchBar && child.getVisibility() != GONE) {
                 TaskStackView tsv = (TaskStackView) child;
                 child.layout(left, top, left + tsv.getMeasuredWidth(), top + tsv.getMeasuredHeight());
             }
@@ -370,7 +378,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 stackView = (TaskStackView) child;
                 stackView.onUserInteraction();
             }
@@ -384,7 +392,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 stackView = (TaskStackView) child;
                 break;
             }
@@ -415,11 +423,11 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
     /**** TaskStackView.TaskStackCallbacks Implementation ****/
 
     @Override
-    public void onTaskLaunched(final TaskStackView stackView, final TaskView tv,
-                               final TaskStack stack, final Task task) {
+    public void onTaskViewClicked(final TaskStackView stackView, final TaskView tv,
+                                  final TaskStack stack, final Task task) {
         // Notify any callbacks of the launching of a new task
         if (mCb != null) {
-            mCb.onTaskLaunching();
+            mCb.onTaskViewClicked();
         }
 
         // Upfront the processing of the thumbnail
@@ -491,7 +499,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                     }
 
                     // And clean up the old task
-                    onTaskRemoved(task);
+                    onTaskViewDismissed(task);
                 }
 
                 if (Console.Enabled) {
@@ -515,7 +523,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
     }
 
     @Override
-    public void onTaskAppInfoLaunched(Task t) {
+    public void onTaskViewAppInfoClicked(Task t) {
         // Create a new task stack with the application info details activity
         Intent baseIntent = t.key.baseIntent;
         Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
@@ -526,9 +534,9 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
     }
 
     @Override
-    public void onTaskRemoved(Task t) {
+    public void onTaskViewDismissed(Task t) {
         // Remove any stored data from the loader.  We currently don't bother notifying the views
-        // that the data has been unloaded because at the point we call onTaskRemoved(), the views
+        // that the data has been unloaded because at the point we call onTaskViewDismissed(), the views
         // either don't need to be updated, or have already been removed.
         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
         loader.deleteTaskData(t, false);
@@ -542,8 +550,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
     }
 
     @Override
-    public void onLastTaskRemoved() {
-        mCb.onLastTaskRemoved();
+    public void onAllTaskViewsDismissed() {
+        mCb.onAllTaskViewsDismissed();
     }
 
     @Override
@@ -582,7 +590,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
-            if (child instanceof TaskStackView) {
+            if (child != mSearchBar) {
                 TaskStackView stackView = (TaskStackView) child;
                 stackView.onComponentRemoved(cns);
             }
index 2c0dea3..9c60603 100644 (file)
@@ -92,7 +92,6 @@ class TaskBarView extends FrameLayout {
     public boolean onTouchEvent(MotionEvent event) {
         // We ignore taps on the task bar except on the filter and dismiss buttons
         if (!Constants.DebugFlags.App.EnableTaskBarTouchEvents) return true;
-        if (mConfig.debugModeEnabled) return true;
 
         return super.onTouchEvent(event);
     }
index 2c05daa..dd47fdd 100644 (file)
@@ -53,10 +53,10 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
 
     /** The TaskView callbacks */
     interface TaskStackViewCallbacks {
-        public void onTaskLaunched(TaskStackView stackView, TaskView tv, TaskStack stack, Task t);
-        public void onTaskAppInfoLaunched(Task t);
-        public void onTaskRemoved(Task t);
-        public void onLastTaskRemoved();
+        public void onTaskViewClicked(TaskStackView stackView, TaskView tv, TaskStack stack, Task t);
+        public void onTaskViewAppInfoClicked(Task t);
+        public void onTaskViewDismissed(Task t);
+        public void onAllTaskViewsDismissed();
         public void onTaskStackFilterTriggered();
         public void onTaskStackUnfilterTriggered();
     }
@@ -69,7 +69,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
     TaskStackViewTouchHandler mTouchHandler;
     TaskStackViewCallbacks mCb;
     ViewPool<TaskView, Task> mViewPool;
-    ArrayList<TaskViewTransform> mTaskTransforms = new ArrayList<TaskViewTransform>();
+    ArrayList<TaskViewTransform> mCurrentTaskTransforms = new ArrayList<TaskViewTransform>();
     DozeTrigger mUIDozeTrigger;
 
     // The virtual stack scroll that we use for the card layout
@@ -205,12 +205,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                                        int stackScroll,
                                        int[] visibleRangeOut,
                                        boolean boundTranslationsToRect) {
-        // XXX: Optimization: Use binary search to find the visible range
+        // XXX: We should be intelligent about where to look for the visible stack range using the
+        //      current stack scroll.
 
         int taskTransformCount = taskTransforms.size();
         int taskCount = tasks.size();
-        int firstVisibleIndex = -1;
-        int lastVisibleIndex = -1;
+        int frontMostVisibleIndex = -1;
+        int backMostVisibleIndex = -1;
 
         // We can reuse the task transforms where possible to reduce object allocation
         if (taskTransformCount < taskCount) {
@@ -224,14 +225,24 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
         }
 
         // Update the stack transforms
-        for (int i = 0; i < taskCount; i++) {
+        for (int i = taskCount - 1; i >= 0; i--) {
             TaskViewTransform transform = mStackAlgorithm.getStackTransform(i, stackScroll,
                     taskTransforms.get(i));
             if (transform.visible) {
-                if (firstVisibleIndex < 0) {
-                    firstVisibleIndex = i;
+                if (frontMostVisibleIndex < 0) {
+                    frontMostVisibleIndex = i;
+                }
+                backMostVisibleIndex = i;
+            } else {
+                if (backMostVisibleIndex != -1) {
+                    // We've reached the end of the visible range, so going down the rest of the
+                    // stack, we can just reset the transforms accordingly
+                    while (i >= 0) {
+                        taskTransforms.get(i).reset();
+                        i--;
+                    }
+                    break;
                 }
-                lastVisibleIndex = i;
             }
 
             if (boundTranslationsToRect) {
@@ -240,8 +251,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
             }
         }
         if (visibleRangeOut != null) {
-            visibleRangeOut[0] = firstVisibleIndex;
-            visibleRangeOut[1] = lastVisibleIndex;
+            visibleRangeOut[0] = frontMostVisibleIndex;
+            visibleRangeOut[1] = backMostVisibleIndex;
         }
     }
 
@@ -275,13 +286,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
             int[] visibleRange = mTmpVisibleRange;
             int stackScroll = getStackScroll();
             ArrayList<Task> tasks = mStack.getTasks();
-            updateStackTransforms(mTaskTransforms, tasks, stackScroll, visibleRange, false);
+            updateStackTransforms(mCurrentTaskTransforms, tasks, stackScroll, visibleRange, false);
 
             // Update the visible state of all the tasks
             int taskCount = tasks.size();
             for (int i = 0; i < taskCount; i++) {
                 Task task = tasks.get(i);
-                TaskViewTransform transform = mTaskTransforms.get(i);
+                TaskViewTransform transform = mCurrentTaskTransforms.get(i);
                 TaskView tv = getChildViewForTask(task);
 
                 if (transform.visible) {
@@ -290,8 +301,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                         // When we are picking up a new view from the view pool, prepare it for any
                         // following animation by putting it in a reasonable place
                         if (mStackViewsAnimationDuration > 0 && i != 0) {
-                            int fromIndex = (transform.t < 0) ? (visibleRange[0] - 1) :
-                                    (visibleRange[1] + 1);
+                            int fromIndex = (transform.t < 0) ?
+                                    Math.max(0, (visibleRange[1] - 1)) :
+                                    Math.min(taskCount - 1, (visibleRange[0] + 1));
                             tv.updateViewPropertiesToTaskTransform(
                                     mStackAlgorithm.getStackTransform(fromIndex, stackScroll), 0);
                         }
@@ -310,10 +322,10 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                 TaskView tv = (TaskView) getChildAt(i);
                 Task task = tv.getTask();
                 int taskIndex = mStack.indexOfTask(task);
-                if (taskIndex < 0 || !mTaskTransforms.get(taskIndex).visible) {
+                if (taskIndex < 0 || !mCurrentTaskTransforms.get(taskIndex).visible) {
                     mViewPool.returnViewToPool(tv);
                 } else {
-                    tv.updateViewPropertiesToTaskTransform(mTaskTransforms.get(taskIndex),
+                    tv.updateViewPropertiesToTaskTransform(mCurrentTaskTransforms.get(taskIndex),
                             mStackViewsAnimationDuration);
                 }
             }
@@ -769,9 +781,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
             if (mConfig.launchedWithAltTab) {
                 // When alt-tabbing, we focus the next previous task
                 focusTask(Math.max(0, mStack.getTaskCount() - 2), false);
-            } else {
-                // Normally we just focus the front task
-                focusTask(Math.max(0, mStack.getTaskCount() - 1), false);
             }
         }
     }
@@ -864,7 +873,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
         }
 
         // Notify the callback that we've removed the task and it can clean up after it
-        mCb.onTaskRemoved(t);
+        mCb.onTaskViewDismissed(t);
 
         // Update the min/max scroll and animate other task views into their new positions
         updateMinMaxScroll(true);
@@ -880,7 +889,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                 shouldFinishActivity = (mStack.getTaskCount() == 0);
             }
             if (shouldFinishActivity) {
-                mCb.onLastTaskRemoved();
+                mCb.onAllTaskViewsDismissed();
             }
         }
     }
@@ -1033,7 +1042,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
     /**** TaskViewCallbacks Implementation ****/
 
     @Override
-    public void onTaskIconClicked(TaskView tv) {
+    public void onTaskViewAppIconClicked(TaskView tv) {
         if (Console.Enabled) {
             Console.log(Constants.Log.UI.ClickEvents, "[TaskStack|Clicked|Icon]",
                     tv.getTask() + " is currently filtered: " + mStack.hasFilteredTasks(),
@@ -1049,19 +1058,14 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
     }
 
     @Override
-    public void onTaskAppInfoClicked(TaskView tv) {
+    public void onTaskViewAppInfoClicked(TaskView tv) {
         if (mCb != null) {
-            mCb.onTaskAppInfoLaunched(tv.getTask());
+            mCb.onTaskViewAppInfoClicked(tv.getTask());
         }
     }
 
     @Override
-    public void onTaskFocused(TaskView tv) {
-        // Do nothing
-    }
-
-    @Override
-    public void onTaskDismissed(TaskView tv) {
+    public void onTaskViewDismissed(TaskView tv) {
         Task task = tv.getTask();
         // Remove the task from the view
         mStack.removeTask(task);
@@ -1082,7 +1086,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
         mUIDozeTrigger.stopDozing();
 
         if (mCb != null) {
-            mCb.onTaskLaunched(this, tv, mStack, task);
+            mCb.onTaskViewClicked(this, tv, mStack, task);
         }
     }
 
index 51f994e..304d45c 100644 (file)
@@ -400,16 +400,11 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
         // Re-enable clipping with the stack (we will reuse this view)
         tv.setClipViewInStack(true);
         // Remove the task view from the stack
-        mSv.onTaskDismissed(tv);
+        mSv.onTaskViewDismissed(tv);
     }
 
     @Override
     public void onSnapBackCompleted(View v) {
-        onDragCancelled(v);
-    }
-
-    @Override
-    public void onDragCancelled(View v) {
         TaskView tv = (TaskView) v;
         // Disable HW layers on that task
         if (mSv.mHwLayersTrigger.getCount() == 0) {
@@ -420,4 +415,9 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
         // Re-enable touch events from this task view
         mSv.setTouchOnTaskView(tv, true);
     }
+
+    @Override
+    public void onDragCancelled(View v) {
+        // Do nothing
+    }
 }
index c6bacbd..6b06945 100644 (file)
@@ -47,10 +47,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
         View.OnLongClickListener {
     /** The TaskView callbacks */
     interface TaskViewCallbacks {
-        public void onTaskIconClicked(TaskView tv);
-        public void onTaskAppInfoClicked(TaskView tv);
-        public void onTaskFocused(TaskView tv);
-        public void onTaskDismissed(TaskView tv);
+        public void onTaskViewAppIconClicked(TaskView tv);
+        public void onTaskViewAppInfoClicked(TaskView tv);
+        public void onTaskViewDismissed(TaskView tv);
     }
 
     RecentsConfiguration mConfig;
@@ -63,8 +62,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
     boolean mTaskDataLoaded;
     boolean mIsFocused;
     boolean mClipViewInStack;
-    Point mLastTouchDown = new Point();
-    Path mRoundedRectClipPath = new Path();
     Rect mTmpRect = new Rect();
     Paint mLayerPaint = new Paint();
 
@@ -110,6 +107,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
         super(context, attrs, defStyleAttr, defStyleRes);
         mConfig = RecentsConfiguration.getInstance();
         setWillNotDraw(false);
+        setClipToOutline(true);
         setDim(getDim());
     }
 
@@ -133,30 +131,13 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
-        // Update the rounded rect clip path
-        float radius = mConfig.taskViewRoundedCornerRadiusPx;
-        mRoundedRectClipPath.reset();
-        mRoundedRectClipPath.addRoundRect(new RectF(0, 0, getMeasuredWidth(), getMeasuredHeight()),
-                radius, radius, Path.Direction.CW);
-
         // Update the outline
         Outline o = new Outline();
         o.setRoundRect(0, 0, getMeasuredWidth(), getMeasuredHeight() -
-                mConfig.taskViewShadowOutlineBottomInsetPx, radius);
+                mConfig.taskViewShadowOutlineBottomInsetPx, mConfig.taskViewRoundedCornerRadiusPx);
         setOutline(o);
     }
 
-    @Override
-    public boolean onInterceptTouchEvent(MotionEvent ev) {
-        switch (ev.getAction()) {
-            case MotionEvent.ACTION_DOWN:
-            case MotionEvent.ACTION_MOVE:
-                mLastTouchDown.set((int) ev.getX(), (int) ev.getY());
-                break;
-        }
-        return super.onInterceptTouchEvent(ev);
-    }
-
     /** Set callback */
     void setCallbacks(TaskViewCallbacks cb) {
         mCb = cb;
@@ -291,7 +272,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
         } else if (mConfig.launchedFromHome) {
             // Move the task view off screen (below) so we can animate it in
             setTranslationY(offscreenY);
-            setTranslationZ(0);
+            if (Constants.DebugFlags.App.EnableShadows) {
+                setTranslationZ(0);
+            }
             setScaleX(1f);
             setScaleY(1f);
         }
@@ -365,11 +348,13 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
             int frontIndex = (ctx.stackViewCount - ctx.stackViewIndex - 1);
             int delay = mConfig.taskBarEnterAnimDelay +
                     frontIndex * mConfig.taskViewEnterFromHomeDelay;
+            if (Constants.DebugFlags.App.EnableShadows) {
+                animate().translationZ(transform.translationZ);
+            }
             animate()
                     .scaleX(transform.scale)
                     .scaleY(transform.scale)
                     .translationY(transform.translationY)
-                    .translationZ(transform.translationZ)
                     .setStartDelay(delay)
                     .setUpdateListener(null)
                     .setInterpolator(mConfig.quintOutInterpolator)
@@ -385,6 +370,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
                     })
                     .start();
             ctx.postAnimationTrigger.increment();
+        } else {
+            // Otherwise, just enable the thumbnail clip
+            mEnableThumbnailClip.run();
         }
     }
 
@@ -527,11 +515,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
 
     @Override
     public void draw(Canvas canvas) {
-        int restoreCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
-        // Apply the rounded rect clip path on the whole view
-        canvas.clipPath(mRoundedRectClipPath);
         super.draw(canvas);
-        canvas.restoreToCount(restoreCount);
 
         // Apply the dim if necessary
         if (mDim > 0) {
@@ -553,7 +537,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
         requestFocus();
         setFocusableInTouchMode(false);
         invalidate();
-        mCb.onTaskFocused(this);
     }
 
     /**
@@ -626,13 +609,13 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
             @Override
             public void run() {
                 if (v == mBarView.mApplicationIcon) {
-                    mCb.onTaskIconClicked(tv);
+                    mCb.onTaskViewAppIconClicked(tv);
                 } else if (v == mBarView.mDismissButton) {
                     // Animate out the view and call the callback
                     startDeleteTaskAnimation(new Runnable() {
                         @Override
                         public void run() {
-                            mCb.onTaskDismissed(tv);
+                            mCb.onTaskViewDismissed(tv);
                         }
                     });
                 }
@@ -643,7 +626,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
     @Override
     public boolean onLongClick(View v) {
         if (v == mBarView.mApplicationIcon) {
-            mCb.onTaskAppInfoClicked(this);
+            mCb.onTaskViewAppInfoClicked(this);
             return true;
         }
         return false;