Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe24fb71 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where the notification wasn't clickable

An earlier implementation of suppressing the ripple didn't
work properly since it could also suppress the click.
We're now suppressing it by removing the pressed state
from the drawable state.

Test: add notification, draw down on it and tap close to the action button a few times, normal launch observed
Change-Id: Icc0efe16125375eaf18ec0df7236faab1232d512
Fixes: 73106085
parent f297b8d7
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -308,6 +308,10 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        }
        }
    }
    }


    public void setRippleAllowed(boolean allowed) {
        mBackgroundNormal.setPressedAllowed(allowed);
    }

    private boolean handleTouchEventDimmed(MotionEvent event) {
    private boolean handleTouchEventDimmed(MotionEvent event) {
        if (mNeedsDimming && !mDimmed) {
        if (mNeedsDimming && !mDimmed) {
            // We're actually dimmed, but our content isn't dimmable, let's ensure we have a ripple
            // We're actually dimmed, but our content isn't dimmable, let's ensure we have a ripple
+8 −8
Original line number Original line Diff line number Diff line
@@ -370,14 +370,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mNotificationInflater.inflateNotificationViews();
        mNotificationInflater.inflateNotificationViews();
    }
    }


    @Override
    public void setPressed(boolean pressed) {
        if (isOnKeyguard() || mEntry.notification.getNotification().contentIntent == null) {
            // We're dropping the ripple if we have a collapse / launch animation
            super.setPressed(pressed);
        }
    }

    public void onNotificationUpdated() {
    public void onNotificationUpdated() {
        for (NotificationContentView l : mLayouts) {
        for (NotificationContentView l : mLayouts) {
            l.onNotificationUpdated(mEntry);
            l.onNotificationUpdated(mEntry);
@@ -407,6 +399,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView


        showBlockingHelper(mEntry.userSentiment ==
        showBlockingHelper(mEntry.userSentiment ==
                NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE);
                NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE);
        updateRippleAllowed();
    }
    }


    @VisibleForTesting
    @VisibleForTesting
@@ -1805,6 +1798,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf);
                mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf);
            }
            }
        }
        }
        updateRippleAllowed();
    }

    private void updateRippleAllowed() {
        boolean allowed = isOnKeyguard()
                || mEntry.notification.getNotification().contentIntent == null;
        setRippleAllowed(allowed);
    }
    }


    /**
    /**
+14 −8
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.View;


import com.android.internal.util.ArrayUtils;
import com.android.systemui.Interpolators;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
@@ -50,6 +51,7 @@ public class NotificationBackgroundView extends View {
    private boolean mExpandAnimationRunning;
    private boolean mExpandAnimationRunning;
    private float mActualWidth;
    private float mActualWidth;
    private int mDrawableAlpha = 255;
    private int mDrawableAlpha = 255;
    private boolean mIsPressedAllowed;


    public NotificationBackgroundView(Context context, AttributeSet attrs) {
    public NotificationBackgroundView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
@@ -94,13 +96,7 @@ public class NotificationBackgroundView extends View {


    @Override
    @Override
    protected void drawableStateChanged() {
    protected void drawableStateChanged() {
        drawableStateChanged(mBackground);
        setState(getDrawableState());
    }

    private void drawableStateChanged(Drawable d) {
        if (d != null && d.isStateful()) {
            d.setState(getDrawableState());
        }
    }
    }


    @Override
    @Override
@@ -177,8 +173,14 @@ public class NotificationBackgroundView extends View {
    }
    }


    public void setState(int[] drawableState) {
    public void setState(int[] drawableState) {
        if (mBackground != null && mBackground.isStateful()) {
            if (!mIsPressedAllowed) {
                drawableState = ArrayUtils.removeInt(drawableState,
                        com.android.internal.R.attr.state_pressed);
            }
            mBackground.setState(drawableState);
            mBackground.setState(drawableState);
        }
        }
    }


    public void setRippleColor(int color) {
    public void setRippleColor(int color) {
        if (mBackground instanceof RippleDrawable) {
        if (mBackground instanceof RippleDrawable) {
@@ -258,4 +260,8 @@ public class NotificationBackgroundView extends View {
        }
        }
        invalidate();
        invalidate();
    }
    }

    public void setPressedAllowed(boolean allowed) {
        mIsPressedAllowed = allowed;
    }
}
}