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);
@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;
}
@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) {
}
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 */);
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);
}
public void setDimmed(boolean dimmed, boolean fade) {
+ mNeedsDimming = dimmed;
+ dimmed &= isDimmable();
if (mDimmed != dimmed) {
mDimmed = dimmed;
resetBackgroundAlpha();
}
}
+ public boolean isDimmable() {
+ return true;
+ }
+
public void setDark(boolean dark, boolean fade, long delay) {
super.setDark(dark, fade, delay);
if (mDark == dark) {