Merge "Revert "Re-enabling fade-in of header bar icons.""
diff --git a/packages/SystemUI/res/drawable/recents_button_bg.xml b/packages/SystemUI/res/drawable/recents_button_bg.xml
new file mode 100644
index 0000000..7456365
--- /dev/null
+++ b/packages/SystemUI/res/drawable/recents_button_bg.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="#40ffffff">
+</ripple>
diff --git a/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml b/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml
new file mode 100644
index 0000000..745af33
--- /dev/null
+++ b/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?android:attr/colorControlHighlight">
+    <item android:drawable="@android:color/transparent" />
+</ripple>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/recents_task_view_header_bg_color.xml b/packages/SystemUI/res/drawable/recents_task_view_header_bg_color.xml
new file mode 100644
index 0000000..5f9341c
--- /dev/null
+++ b/packages/SystemUI/res/drawable/recents_task_view_header_bg_color.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+       android:shape="rectangle">
+    <corners android:topLeftRadius="@dimen/recents_task_view_rounded_corners_radius"
+             android:topRightRadius="@dimen/recents_task_view_rounded_corners_radius"/>
+    <solid android:color="#00000000" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/recents_task_view_header.xml b/packages/SystemUI/res/layout/recents_task_view_header.xml
index deb8e91..5c67f80 100644
--- a/packages/SystemUI/res/layout/recents_task_view_header.xml
+++ b/packages/SystemUI/res/layout/recents_task_view_header.xml
@@ -49,9 +49,8 @@
         android:layout_marginEnd="@dimen/recents_task_view_header_button_width"
         android:layout_gravity="center_vertical|end"
         android:padding="15dp"
+        android:background="@drawable/recents_button_bg"
         android:src="@drawable/star"
-        android:background="?android:selectableItemBackground"
-        android:alpha="0"
         android:visibility="gone" />
     <com.android.systemui.recents.views.FixedSizeImageView
         android:id="@+id/dismiss_task"
@@ -59,10 +58,9 @@
         android:layout_height="@dimen/recents_task_view_header_button_height"
         android:layout_gravity="center_vertical|end"
         android:padding="15dp"
-        android:src="@drawable/recents_dismiss_light"
-        android:background="?android:selectableItemBackground"
-        android:alpha="0"
-        android:visibility="gone" />
+        android:background="@drawable/recents_button_bg"
+        android:visibility="invisible"
+        android:src="@drawable/recents_dismiss_light" />
 
     <!-- The progress indicator shows if auto-paging is enabled -->
     <ViewStub android:id="@+id/focus_timer_indicator_stub"
diff --git a/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml b/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml
index 10659a3..dabfc80 100644
--- a/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml
+++ b/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml
@@ -45,6 +45,6 @@
         android:layout_height="@dimen/recents_task_bar_height"
         android:layout_gravity="center_vertical|end"
         android:padding="15dp"
-        android:background="?android:selectableItemBackground"
+        android:background="@drawable/recents_button_bg"
         android:src="@drawable/recents_info_light" />
 </FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index 5a60a19..35e97e5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -806,7 +806,7 @@
                 } else {
                     Canvas c = new Canvas(thumbnail);
                     c.scale(toTransform.scale, toTransform.scale);
-                    mHeaderBar.rebindToTask(toTask, false /* touchExplorationEnabled */);
+                    mHeaderBar.rebindToTask(toTask);
                     mHeaderBar.draw(c);
                     c.setBitmap(null);
                 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index d22cd53..ecf8ecb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -256,6 +256,8 @@
      * Returns whether this device has freeform workspaces.
      */
     public boolean hasFreeformWorkspaceSupport() {
+        if (mPm == null) return false;
+
         return mHasFreeformWorkspaceSupport;
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java b/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java
index d3b5e47..f5ab01f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java
@@ -20,14 +20,13 @@
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
-
-import com.android.systemui.statusbar.AlphaOptimizedImageView;
+import android.widget.ImageView;
 
 /**
  * This is an optimized ImageView that does not trigger a <code>requestLayout()</code> or
  * <code>invalidate()</code> when setting the image to <code>null</code>.
  */
-public class FixedSizeImageView extends AlphaOptimizedImageView {
+public class FixedSizeImageView extends ImageView {
 
     private boolean mAllowRelayout = true;
     private boolean mAllowInvalidate = true;
@@ -74,4 +73,9 @@
         mAllowRelayout = true;
         mAllowInvalidate = true;
     }
+
+    @Override
+    public boolean hasOverlappingRendering() {
+        return false;
+    }
 }
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 232b416..7079ff44 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -233,8 +233,8 @@
     @Override
     protected void onAttachedToWindow() {
         EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1);
-        super.onAttachedToWindow();
         readSystemFlags();
+        super.onAttachedToWindow();
     }
 
     @Override
@@ -1418,9 +1418,7 @@
         Recents.getTaskLoader().loadTaskData(task, true /* fetchAndInvalidateThumbnails */);
 
         // If the doze trigger has already fired, then update the state for this task view
-        if (mUIDozeTrigger.hasTriggered()) {
-            tv.setNoUserInteractionState();
-        }
+        tv.setNoUserInteractionState();
 
         // Set the new state for this view, including the callbacks and view clipping
         tv.setCallbacks(this);
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 853f868..2e8e665 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -29,7 +29,6 @@
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffColorFilter;
 import android.graphics.Rect;
-import android.provider.Settings;
 import android.util.AttributeSet;
 import android.util.FloatProperty;
 import android.util.IntProperty;
@@ -115,7 +114,6 @@
     Task mTask;
     boolean mTaskDataLoaded;
     boolean mClipViewInStack = true;
-    boolean mTouchExplorationEnabled;
     AnimateableViewBounds mViewBounds;
 
     private AnimatorSet mTransformAnimation;
@@ -164,7 +162,6 @@
     void reset() {
         resetViewProperties();
         resetNoUserInteractionState();
-        readSystemFlags();
         setClipViewInStack(false);
         setCallbacks(null);
     }
@@ -180,12 +177,6 @@
     }
 
     @Override
-    protected void onAttachedToWindow() {
-        super.onAttachedToWindow();
-        readSystemFlags();
-    }
-
-    @Override
     protected void onFinishInflate() {
         // Bind the views
         mContent = findViewById(R.id.task_view_content);
@@ -554,7 +545,7 @@
     public void onTaskDataLoaded(Task task) {
         // Bind each of the views to the new task data
         mThumbnailView.rebindToTask(mTask);
-        mHeaderView.rebindToTask(mTask, mTouchExplorationEnabled);
+        mHeaderView.rebindToTask(mTask);
         mTaskDataLoaded = true;
     }
 
@@ -563,13 +554,13 @@
         // Unbind each of the views from the task data and remove the task callback
         mTask.removeCallback(this);
         mThumbnailView.unbindFromTask();
-        mHeaderView.unbindFromTask(mTouchExplorationEnabled);
+        mHeaderView.unbindFromTask();
         mTaskDataLoaded = false;
     }
 
     @Override
     public void onTaskStackIdChanged() {
-        mHeaderView.rebindToTask(mTask, mTouchExplorationEnabled);
+        mHeaderView.rebindToTask(mTask);
     }
 
     /**** View.OnClickListener Implementation ****/
@@ -624,12 +615,4 @@
         }
         EventBus.getDefault().unregister(this);
     }
-
-    /**
-     * Reads current system flags related to accessibility and screen pinning.
-     */
-    private void readSystemFlags() {
-        SystemServicesProxy ssp = Recents.getSystemServices();
-        mTouchExplorationEnabled = ssp.isTouchExplorationEnabled();
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index 5e17b90..408ffb4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -214,18 +214,14 @@
 
     @Override
     protected void onFinishInflate() {
-        SystemServicesProxy ssp = Recents.getSystemServices();
-
         // Initialize the icon and description views
         mIconView = (ImageView) findViewById(R.id.icon);
         mIconView.setClickable(false);
         mIconView.setOnLongClickListener(this);
         mTitleView = (TextView) findViewById(R.id.title);
         mDismissButton = (ImageView) findViewById(R.id.dismiss_task);
-        if (ssp.hasFreeformWorkspaceSupport()) {
-            mMoveTaskButton = (ImageView) findViewById(R.id.move_task);
-            mMoveTaskButton.setVisibility(View.VISIBLE);
-        }
+        mDismissButton.setOnClickListener(this);
+        mMoveTaskButton = (ImageView) findViewById(R.id.move_task);
         mFocusTimerIndicatorStub = (ViewStub) findViewById(R.id.focus_timer_indicator_stub);
         mAppOverlayViewStub = (ViewStub) findViewById(R.id.app_overlay_stub);
     }
@@ -343,6 +339,7 @@
     void setDimAlpha(float dimAlpha) {
         mDimAlpha = dimAlpha;
         updateBackgroundColor(dimAlpha);
+        invalidate();
     }
 
     /**
@@ -356,12 +353,11 @@
             mTmpHSL[2] = Math.min(1f, mTmpHSL[2] + OVERLAY_LIGHTNESS_INCREMENT * (1.0f - dimAlpha));
             mOverlayBackground.setColorAndDim(ColorUtils.HSLToColor(mTmpHSL), dimAlpha);
             mDimLayerPaint.setAlpha((int) (dimAlpha * 255));
-            invalidate();
         }
     }
 
     /** Binds the bar view to the task */
-    public void rebindToTask(Task t, boolean touchExplorationEnabled) {
+    public void rebindToTask(Task t) {
         SystemServicesProxy ssp = Recents.getSystemServices();
         mTask = t;
 
@@ -395,6 +391,10 @@
                         ? mLightFreeformIcon
                         : mDarkFreeformIcon);
             }
+            if (mMoveTaskButton.getVisibility() != View.VISIBLE) {
+                mMoveTaskButton.setVisibility(View.VISIBLE);
+            }
+            mMoveTaskButton.setOnClickListener(this);
         }
 
         if (Recents.getDebugFlags().isFastToggleRecentsEnabled()) {
@@ -408,37 +408,32 @@
         }
 
         // In accessibility, a single click on the focused app info button will show it
-        if (touchExplorationEnabled) {
+        if (ssp.isTouchExplorationEnabled()) {
             mIconView.setOnClickListener(this);
         }
     }
 
     /** Unbinds the bar view from the task */
-    void unbindFromTask(boolean touchExplorationEnabled) {
+    void unbindFromTask() {
         mTask = null;
         mIconView.setImageDrawable(null);
-        if (touchExplorationEnabled) {
-            mIconView.setOnClickListener(null);
-        }
+        mIconView.setOnClickListener(null);
+        mMoveTaskButton.setOnClickListener(null);
     }
 
     /** Animates this task bar if the user does not interact with the stack after a certain time. */
     void startNoUserInteractionAnimation() {
-        int duration = getResources().getInteger(R.integer.recents_task_enter_from_app_duration);
-        mDismissButton.setOnClickListener(this);
-        mDismissButton.setVisibility(View.VISIBLE);
-        mDismissButton.animate()
-                .alpha(1f)
-                .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN)
-                .setDuration(duration)
-                .start();
-        mMoveTaskButton.setOnClickListener(this);
-        mMoveTaskButton.setVisibility(View.VISIBLE);
-        mMoveTaskButton.animate()
-                .alpha(1f)
-                .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN)
-                .setDuration(duration)
-                .start();
+        if (mDismissButton.getVisibility() != View.VISIBLE) {
+            mDismissButton.setVisibility(View.VISIBLE);
+            mDismissButton.setAlpha(0f);
+            mDismissButton.animate()
+                    .alpha(1f)
+                    .setStartDelay(0)
+                    .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN)
+                    .setDuration(getResources().getInteger(
+                            R.integer.recents_task_enter_from_app_duration))
+                    .start();
+        }
     }
 
     /**
@@ -446,14 +441,11 @@
      * time.
      */
     void setNoUserInteractionState() {
-        mDismissButton.setVisibility(View.VISIBLE);
-        mDismissButton.animate().cancel();
-        mDismissButton.setAlpha(1f);
-        mDismissButton.setOnClickListener(this);
-        mMoveTaskButton.setVisibility(View.VISIBLE);
-        mMoveTaskButton.animate().cancel();
-        mMoveTaskButton.setAlpha(1f);
-        mMoveTaskButton.setOnClickListener(this);
+        if (mDismissButton.getVisibility() != View.VISIBLE) {
+            mDismissButton.animate().cancel();
+            mDismissButton.setVisibility(View.VISIBLE);
+            mDismissButton.setAlpha(1f);
+        }
     }
 
     /**
@@ -462,11 +454,6 @@
      */
     void resetNoUserInteractionState() {
         mDismissButton.setVisibility(View.INVISIBLE);
-        mDismissButton.setAlpha(0f);
-        mDismissButton.setOnClickListener(null);
-        mMoveTaskButton.setVisibility(View.INVISIBLE);
-        mMoveTaskButton.setAlpha(0f);
-        mMoveTaskButton.setOnClickListener(null);
     }
 
     @Override
@@ -480,8 +467,11 @@
     @Override
     public void onClick(View v) {
         if (v == mIconView) {
-            // In accessibility, a single click on the focused app info button will show it
-            EventBus.getDefault().send(new ShowApplicationInfoEvent(mTask));
+            SystemServicesProxy ssp = Recents.getSystemServices();
+            if (ssp.isTouchExplorationEnabled()) {
+                // In accessibility, a single click on the focused app info button will show it
+                EventBus.getDefault().send(new ShowApplicationInfoEvent(mTask));
+            }
         } else if (v == mDismissButton) {
             TaskView tv = Utilities.findParent(this, TaskView.class);
             tv.dismissTask();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
index f90951e..ea40644 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java
@@ -93,6 +93,7 @@
 
         mTaskViewRect.set(0, 0, width, height);
         updateThumbnailScale();
+        invalidate();
     }
 
     @Override
@@ -119,6 +120,7 @@
             mDrawPaint.setShader(null);
             mThumbnailRect.setEmpty();
         }
+        invalidate();
     }
 
     /** Updates the paint to draw the thumbnail. */
@@ -136,9 +138,7 @@
             mDrawPaint.setColorFilter(null);
             mDrawPaint.setColor(Color.argb(255, grey, grey, grey));
         }
-        if (!mInvisible) {
-            invalidate();
-        }
+        invalidate();
     }
 
     /**