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

Commit 035a1fcd authored by Adam Powell's avatar Adam Powell
Browse files

View pressed state dispatching tweaks

Bugs 6075823, 6050563

Revise pressed state dispatch logic:

Only propagate pressed state to non-clickable views. This should
eliminate the "double glow" problem in some list items where a
clickable child button has a secondary glow along with a clickable
parent. This only applies to setPressed(true) calls; setPressed(false)
must propagate. Don't early-out in setPressed to support this use
case.

Change-Id: Ibbe2309f5030282fad8d23e4a9bc4616b3f5dc7c
parent 41c31ef3
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -5048,16 +5048,17 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     *        the View's internal state from a previously set "pressed" state.
     */
    public void setPressed(boolean pressed) {
        if (pressed == ((mPrivateFlags & PRESSED) == PRESSED)) {
            return;
        }
        final boolean needsRefresh = pressed != ((mPrivateFlags & PRESSED) == PRESSED);
        if (pressed) {
            mPrivateFlags |= PRESSED;
        } else {
            mPrivateFlags &= ~PRESSED;
        }
        if (needsRefresh) {
            refreshDrawableState();
        }
        dispatchSetPressed(pressed);
    }
+7 −1
Original line number Diff line number Diff line
@@ -2770,7 +2770,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        final View[] children = mChildren;
        final int count = mChildrenCount;
        for (int i = 0; i < count; i++) {
            children[i].setPressed(pressed);
            final View child = children[i];
            // Children that are clickable on their own should not
            // show a pressed state when their parent view does.
            // Clearing a pressed state always propagates.
            if (!pressed || (!child.isClickable() && !child.isLongClickable())) {
                child.setPressed(pressed);
            }
        }
    }