Merge changes Ic76d996f,Ib9eefacb,If1b63340,I399c66af into oc-dev am: 947be6bed9
am: c40344bf86

Change-Id: I849b78ceb45e22ab1b63bf4fbb88aac40625fd22
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index cab2114..602cccb 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3251,7 +3251,6 @@
          * However, for {@link MediaStyle} and {@link DecoratedMediaCustomViewStyle} notifications
          * that have a media session attached there is no such requirement.
          *
-         * @see Builder#setOngoing(boolean)
          * @see Builder#setColor(int)
          * @see MediaStyle#setMediaSession(MediaSession.Token)
          */
@@ -3742,6 +3741,11 @@
             return mActionBarColor;
         }
 
+        private int getActionBarColorDeEmphasized() {
+            int backgroundColor = getBackgroundColor();
+            return NotificationColorUtil.getShiftedColor(backgroundColor, 12);
+        }
+
         private void setTextViewColorSecondary(RemoteViews contentView, int id) {
             ensureColors();
             contentView.setTextColor(id, mSecondaryTextColor);
@@ -4316,8 +4320,13 @@
             // TODO: handle emphasized mode / actions right
             if (emphazisedMode) {
                 // change the background bgColor
-                int bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
-                        : R.color.notification_action_list_dark);
+                int bgColor;
+                if (isColorized()) {
+                    bgColor = oddAction ? getActionBarColor() : getActionBarColorDeEmphasized();
+                } else {
+                    bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
+                            : R.color.notification_action_list_dark);
+                }
                 button.setDrawableParameters(R.id.button_holder, true, -1, bgColor,
                         PorterDuff.Mode.SRC_ATOP, -1);
                 CharSequence title = action.title;
diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/NotificationColorUtil.java
index 44b21b4..5cb66e5 100644
--- a/core/java/com/android/internal/util/NotificationColorUtil.java
+++ b/core/java/com/android/internal/util/NotificationColorUtil.java
@@ -460,13 +460,25 @@
         if (backgroundColor == Notification.COLOR_DEFAULT) {
             return context.getColor(com.android.internal.R.color.notification_action_list);
         }
-        boolean useDark = shouldUseDark(backgroundColor);
+        return getShiftedColor(backgroundColor, 7);
+    }
+
+    /**
+     * Get a color that stays in the same tint, but darkens or lightens it by a certain
+     * amount.
+     * This also looks at the lightness of the provided color and shifts it appropriately.
+     *
+     * @param color the base color to use
+     * @param amount the amount from 1 to 100 how much to modify the color
+     * @return the now color that was modified
+     */
+    public static int getShiftedColor(int color, int amount) {
         final double[] result = ColorUtilsFromCompat.getTempDouble3Array();
-        ColorUtilsFromCompat.colorToLAB(backgroundColor, result);
-        if (useDark && result[0] < 97 || !useDark && result[0] < 4) {
-            result[0] = Math.min(100, result[0] + 7);
+        ColorUtilsFromCompat.colorToLAB(color, result);
+        if (result[0] >= 4) {
+            result[0] = Math.max(0, result[0] - amount);
         } else {
-            result[0] = Math.max(0, result[0] - 7);
+            result[0] = Math.min(100, result[0] + amount);
         }
         return ColorUtilsFromCompat.LABToColor(result[0], result[1], result[2]);
     }
diff --git a/core/java/com/android/internal/widget/NotificationExpandButton.java b/core/java/com/android/internal/widget/NotificationExpandButton.java
index c64ace4..b702898 100644
--- a/core/java/com/android/internal/widget/NotificationExpandButton.java
+++ b/core/java/com/android/internal/widget/NotificationExpandButton.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.graphics.Rect;
 import android.util.AttributeSet;
+import android.view.View;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.widget.Button;
 import android.widget.ImageView;
@@ -30,6 +31,8 @@
  */
 @RemoteViews.RemoteView
 public class NotificationExpandButton extends ImageView {
+    private View mLabeledBy;
+
     public NotificationExpandButton(Context context) {
         super(context);
     }
@@ -66,5 +69,12 @@
     public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
         super.onInitializeAccessibilityNodeInfo(info);
         info.setClassName(Button.class.getName());
+        if (mLabeledBy != null) {
+            info.setLabeledBy(mLabeledBy);
+        }
+    }
+
+    public void setLabeledBy(View labeledBy) {
+        mLabeledBy = labeledBy;
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/Interpolators.java b/packages/SystemUI/src/com/android/systemui/Interpolators.java
index 9b5577c..b8cfa3e 100644
--- a/packages/SystemUI/src/com/android/systemui/Interpolators.java
+++ b/packages/SystemUI/src/com/android/systemui/Interpolators.java
@@ -41,6 +41,8 @@
     public static final Interpolator CUSTOM_40_40 = new PathInterpolator(0.4f, 0f, 0.6f, 1f);
     public static final Interpolator HEADS_UP_APPEAR = new HeadsUpAppearInterpolator();
     public static final Interpolator ICON_OVERSHOT = new PathInterpolator(0.4f, 0f, 0.2f, 1.4f);
+    public static final Interpolator PANEL_CLOSE_ACCELERATED
+            = new PathInterpolator(0.3f, 0, 0.5f, 1);
 
     /**
      * Interpolator to be used when animating a move based on a click. Pair with enough duration.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
index 1ffc944..0b9244a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
@@ -29,6 +29,7 @@
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.android.internal.widget.NotificationExpandButton;
 import com.android.systemui.Interpolators;
 import com.android.systemui.ViewInvertHelper;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
@@ -54,7 +55,7 @@
     protected int mColor;
     private ImageView mIcon;
 
-    private ImageView mExpandButton;
+    private NotificationExpandButton mExpandButton;
     private NotificationHeaderView mNotificationHeader;
     private TextView mHeaderText;
     private ImageView mWorkProfileImage;
@@ -106,13 +107,13 @@
     }
 
     protected void resolveHeaderViews() {
-        mIcon = (ImageView) mView.findViewById(com.android.internal.R.id.icon);
-        mHeaderText = (TextView) mView.findViewById(com.android.internal.R.id.header_text);
-        mExpandButton = (ImageView) mView.findViewById(com.android.internal.R.id.expand_button);
-        mWorkProfileImage = (ImageView) mView.findViewById(com.android.internal.R.id.profile_badge);
+        mIcon = mView.findViewById(com.android.internal.R.id.icon);
+        mHeaderText = mView.findViewById(com.android.internal.R.id.header_text);
+        mExpandButton = mView.findViewById(com.android.internal.R.id.expand_button);
+        mExpandButton.setLabeledBy(mRow);
+        mWorkProfileImage = mView.findViewById(com.android.internal.R.id.profile_badge);
         mColor = resolveColor(mExpandButton);
-        mNotificationHeader = (NotificationHeaderView) mView.findViewById(
-                com.android.internal.R.id.notification_header);
+        mNotificationHeader = mView.findViewById(com.android.internal.R.id.notification_header);
         getDozer().setColor(mColor);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java
index 9206914..f216d6c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java
@@ -83,7 +83,7 @@
     /**
      * How much faster we collapse the lockscreen when authenticating with fingerprint.
      */
-    private static final float FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR = 1.3f;
+    private static final float FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR = 1.1f;
 
     private PowerManager mPowerManager;
     private Handler mHandler = new Handler();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index f1b4498..8a97be5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -2022,7 +2022,7 @@
     @Override
     protected boolean shouldUseDismissingAnimation() {
         return mStatusBarState != StatusBarState.SHADE
-                && !mStatusBar.isKeyguardCurrentlySecure();
+                && (!mStatusBar.isKeyguardCurrentlySecure() || !isTracking());
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 48a8329..e86fd48 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -725,8 +725,14 @@
             }
         } else {
             if (shouldUseDismissingAnimation()) {
-                mFlingAnimationUtilsDismissing.apply(animator, mExpandedHeight, target, vel,
-                        getHeight());
+                if (vel == 0) {
+                    animator.setInterpolator(Interpolators.PANEL_CLOSE_ACCELERATED);
+                    long duration = (long) (200 + mExpandedHeight / getHeight() * 100);
+                    animator.setDuration(duration);
+                } else {
+                    mFlingAnimationUtilsDismissing.apply(animator, mExpandedHeight, target, vel,
+                            getHeight());
+                }
             } else {
                 mFlingAnimationUtilsClosing
                         .apply(animator, mExpandedHeight, target, vel, getHeight());