OSDN Git Service

Make music notifications not dimmable
authorSelim Cinek <cinek@google.com>
Tue, 25 Apr 2017 05:18:48 +0000 (22:18 -0700)
committerSelim Cinek <cinek@google.com>
Thu, 27 Apr 2017 19:40:04 +0000 (12:40 -0700)
For contrast requirements and for the image effect
to work properly, music notifications should not be
dimmable.

Test: add music notification, look at lockscreen
Fixes: 36561228
Change-Id: I58313e1828c64d34737390ad03e1deef078a7059

packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java

index 469f3ad..d7eab97 100644 (file)
@@ -172,6 +172,11 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     private int mOverrideTint;
     private float mOverrideAmount;
     private boolean mShadowHidden;
+    private boolean mWasActivatedOnDown;
+    /**
+     * Similar to mDimmed but is also true if it's not dimmable but should be
+     */
+    private boolean mNeedsDimming;
 
     public ActivatableNotificationView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -223,7 +228,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
-        if (mDimmed && !mActivated && ev.getActionMasked() == MotionEvent.ACTION_DOWN
+        if (mNeedsDimming && !mActivated && ev.getActionMasked() == MotionEvent.ACTION_DOWN
                 && disallowSingleClick(ev) && !isTouchExplorationEnabled()) {
             return true;
         }
@@ -245,7 +250,10 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         boolean result;
-        if (mDimmed && !isTouchExplorationEnabled() && isInteractive()) {
+        if (event.getAction() == MotionEvent.ACTION_DOWN) {
+            mWasActivatedOnDown = mActivated;
+        }
+        if ((mNeedsDimming && !mActivated) && !isTouchExplorationEnabled() && isInteractive()) {
             boolean wasActivated = mActivated;
             result = handleTouchEventDimmed(event);
             if (wasActivated && result && event.getAction() == MotionEvent.ACTION_UP) {
@@ -282,9 +290,21 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     }
 
     private boolean handleTouchEventDimmed(MotionEvent event) {
+        if (mNeedsDimming && !mDimmed) {
+            // We're actually dimmed, but our content isn't dimmable, let's ensure we have a ripple
+            super.onTouchEvent(event);
+        }
         return mDoubleTapHelper.onTouchEvent(event, getActualHeight());
     }
 
+    @Override
+    public boolean performClick() {
+        if (mWasActivatedOnDown || !mNeedsDimming) {
+            return super.performClick();
+        }
+        return false;
+    }
+
     private void makeActive() {
         mFalsingManager.onNotificationActive();
         startActivateAnimation(false /* reverse */);
@@ -298,6 +318,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
         if (!isAttachedToWindow()) {
             return;
         }
+        if (!isDimmable()) {
+            return;
+        }
         int widthHalf = mBackgroundNormal.getWidth()/2;
         int heightHalf = mBackgroundNormal.getActualHeight()/2;
         float radius = (float) Math.sqrt(widthHalf*widthHalf + heightHalf*heightHalf);
@@ -371,6 +394,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     }
 
     public void setDimmed(boolean dimmed, boolean fade) {
+        mNeedsDimming = dimmed;
+        dimmed &= isDimmable();
         if (mDimmed != dimmed) {
             mDimmed = dimmed;
             resetBackgroundAlpha();
@@ -382,6 +407,10 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
         }
     }
 
+    public boolean isDimmable() {
+        return true;
+    }
+
     public void setDark(boolean dark, boolean fade, long delay) {
         super.setDark(dark, fade, delay);
         if (mDark == dark) {
index 5171cb1..4612735 100644 (file)
@@ -361,6 +361,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
         expandedIcon.setStaticDrawableColor(color);
     }
 
+    @Override
+    public boolean isDimmable() {
+        if (!getShowingLayout().isDimmable()) {
+            return false;
+        }
+        return super.isDimmable();
+    }
+
     private void updateLimits() {
         for (NotificationContentView l : mLayouts) {
             updateLimitsForView(l);
index 6098565..e7bf983 100644 (file)
@@ -1363,4 +1363,11 @@ public class NotificationContentView extends FrameLayout {
     public void setIsLowPriority(boolean isLowPriority) {
         mIsLowPriority = isLowPriority;
     }
+
+    public boolean isDimmable() {
+        if (!mContractedWrapper.isDimmable()) {
+            return false;
+        }
+        return true;
+    }
 }
index a2f488c..7fbee7d 100644 (file)
@@ -55,4 +55,9 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi
                     mActions);
         }
     }
+
+    @Override
+    public boolean isDimmable() {
+        return false;
+    }
 }
index f4db9a1..5cc39cc 100644 (file)
@@ -178,4 +178,8 @@ public abstract class NotificationViewWrapper implements TransformableView {
 
     public void setIsChildInGroup(boolean isChildInGroup) {
     }
+
+    public boolean isDimmable() {
+        return true;
+    }
 }