Added border to focus state

Change-Id: I3bed773f922217163c81cba8c1ecc62db6a3e96e
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 92a31cc..f523376 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -26,7 +26,6 @@
     <color name="notification_panel_solid_background">#ff000000</color>
     <drawable name="status_bar_recents_app_thumbnail_background">#88000000</drawable>
     <color name="status_bar_recents_app_label_color">#ffffffff</color>
-    <color name="status_bar_recents_focus_color">#ff009688</color>
     <drawable name="status_bar_notification_row_background_color">#ff090909</drawable>
     <color name="notification_list_shadow_top">#80000000</color>
     <drawable name="recents_callout_line">#99ffffff</drawable>
@@ -57,6 +56,8 @@
     <!-- Tint color for the content on the notification overflow card. -->
     <color name="keyguard_overflow_content_color">#ff686868</color>
 
+    <!-- The focus color for a task. -->
+    <color name="recents_focus_color">#ff009688</color>
     <!-- The default recents task bar background color. -->
     <color name="recents_task_bar_default_background_color">#ffe6e6e6</color>
     <!-- The recents task bar light text color to be drawn on top of dark backgrounds. -->
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 03ea73c..11ae070 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -244,6 +244,9 @@
     <!-- The height of the search bar space. -->
     <dimen name="recents_search_bar_space_height">64dp</dimen>
 
+    <!-- Size of border for focus state -->
+    <dimen name="recents_border_size">6dip</dimen>
+
     <!-- The side padding for the task stack as a percentage of the width. -->
     <item name="recents_stack_width_padding_percentage" format="float" type="dimen">0.03333</item>
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 571a9ef..8c49ff4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -1310,7 +1310,8 @@
         RecentsTaskLoader.getInstance().loadTaskData(task);
 
         // If the doze trigger has already fired, then update the state for this task view
-        if (mConfig.multiStackEnabled || mUIDozeTrigger.hasTriggered()) {
+        if (mConfig.launchedWithAltTab ||
+                mConfig.multiStackEnabled || mUIDozeTrigger.hasTriggered()) {
             tv.setNoUserInteractionState();
         }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index d67ea46..f3be678 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -22,6 +22,7 @@
 import android.animation.ValueAnimator;
 import android.content.Context;
 import android.graphics.*;
+import android.graphics.Bitmap.Config;
 import android.util.AttributeSet;
 import android.view.accessibility.AccessibilityManager;
 import android.view.View;
@@ -83,7 +84,8 @@
     float mFocusProgress;
     Paint mFocusPaint = new Paint();
     int mFocusColor = 0xff009688;
-    int mFocusAlpha = 0x50;
+    int mFocusAlpha = 0x40;
+    int mFocusBorderAlpha = 0xde;
     static Interpolator sFocusInInterpolator = new OvershootInterpolator(2);
     static Interpolator sFocusInRadiusInterpolator = new DecelerateInterpolator();
     static Interpolator sFocusOutInterpolator = new DecelerateInterpolator();
@@ -95,6 +97,7 @@
     int mFocusInCircleAlpha;
     int mFocusOutFillAlpha;
     boolean mFocusAnimatorWasTriggered;
+    int mFocusBorderSize;
 
     // Optimizations
     ValueAnimator.AnimatorUpdateListener mUpdateDimListener =
@@ -139,8 +142,10 @@
         });
 
         mFocusColor =
-                context.getResources().getColor(R.color.status_bar_recents_focus_color);
+                context.getResources().getColor(R.color.recents_focus_color);
         mFocusPaint.setColor(mFocusColor);
+        mFocusBorderSize =
+                context.getResources().getDimensionPixelSize(R.dimen.recents_border_size);
     }
 
     /** Set callback */
@@ -557,6 +562,19 @@
 
     @Override
     public void dispatchDraw(Canvas canvas) {
+        if (mIsFocused && mFocusAnimatorWasTriggered) {
+            canvas.save(Canvas.CLIP_SAVE_FLAG);
+            mFocusPaint.setAlpha(mFocusBorderAlpha);
+            canvas.clipRect(-mFocusBorderSize, -mFocusBorderSize,
+                    getWidth() + mFocusBorderSize, getHeight() + mFocusBorderSize,
+                    Region.Op.REPLACE);
+            canvas.drawRoundRect(-mFocusBorderSize, -mFocusBorderSize,
+                    getWidth() + mFocusBorderSize, getHeight() + mFocusBorderSize,
+                    mConfig.taskViewRoundedCornerRadiusPx,
+                    mConfig.taskViewRoundedCornerRadiusPx, mFocusPaint);
+            canvas.restore();
+        }
+
         super.dispatchDraw(canvas);
 
         if (mFocusAnimatorWasTriggered) {
@@ -588,6 +606,7 @@
             mFocusInCircleAlpha = (int) (mFocusAlpha * interpolatedProgress);
             mFocusInFillAlpha =
                     (mFocusAlpha / 4) + (int) ((mFocusAlpha / 2) * interpolatedProgress);
+            mFocusBorderAlpha = mFocusAlpha + (int) ((mFocusAlpha * 1.5f) * interpolatedProgress);
         } else {
             final float interpolatedProgress = sFocusOutInterpolator.getInterpolation(progress);
             mFocusOutFillAlpha = (int) (mFocusAlpha * (1 - interpolatedProgress));