summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2017-04-24 22:18:48 -0700
committer Selim Cinek <cinek@google.com> 2017-04-27 22:31:05 +0000
commit63edaf2a2c8fc1aeb71f05cbeb9a49e6b9534062 (patch)
tree4f8bb10f3059a5567d1291b040ef73e432bd9d5c
parent0847acd4d48deb716de99d259364bc99b592a8bc (diff)
Make music notifications not dimmable
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 Merged-In: I58313e1828c64d34737390ad03e1deef078a7059 Change-Id: I58313e1828c64d34737390ad03e1deef078a7059
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java33
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java4
5 files changed, 55 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 469f3ad45c56..d7eab9772677 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -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) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 16c53b87d321..8c1b334fe570 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -360,6 +360,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);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 609856522e75..e7bf98336e8c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -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;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
index ef5a25ca5262..8596cb3e2e9a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
@@ -56,4 +56,9 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi
mActions);
}
}
+
+ @Override
+ public boolean isDimmable() {
+ return false;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
index f4db9a1977f3..5cc39cc27b26 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
@@ -178,4 +178,8 @@ public abstract class NotificationViewWrapper implements TransformableView {
public void setIsChildInGroup(boolean isChildInGroup) {
}
+
+ public boolean isDimmable() {
+ return true;
+ }
}