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

Commit 74282f07 authored by Jiaquan He's avatar Jiaquan He Committed by android-build-merger
Browse files

Check state_focus in foreground.

am: 0bdf1c9c

Change-Id: Ie7b36dfa723a110d553c2f6a5926314758e0da53
parents 613ac936 0bdf1c9c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -45760,6 +45760,7 @@ package android.view {
    method public boolean isAttachedToWindow();
    method public boolean isClickable();
    method public boolean isContextClickable();
    method public boolean isDefaultFocusHighlightNeeded(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
    method public boolean isDirty();
    method public boolean isDrawingCacheEnabled();
    method public boolean isDuplicateParentStateEnabled();
+12 −6
Original line number Diff line number Diff line
@@ -19809,18 +19809,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Check whether we need to draw a default focus highlight when this view gets focused,
     * which requires:
     * <ul>
     *     <li>In the background, {@link android.R.attr#state_focused} is not defined.</li>
     *     <li>In both background and foreground, {@link android.R.attr#state_focused}
     *         is not defined.</li>
     *     <li>This view is not in touch mode.</li>
     *     <li>This view doesn't opt out for a default focus highlight, via
     *         {@link #setDefaultFocusHighlightEnabled(boolean)}.</li>
     *     <li>This view is attached to window.</li>
     * </ul>
     * @return {@code true} if a default focus highlight is needed.
     * @hide
     */
    private boolean isDefaultFocusHighlightNeeded(Drawable background) {
        final boolean hasFocusStateSpecified = background == null || !background.isStateful()
                || !background.hasFocusStateSpecified();
        return !isInTouchMode() && getDefaultFocusHighlightEnabled() && hasFocusStateSpecified
    @TestApi
    public boolean isDefaultFocusHighlightNeeded(Drawable background, Drawable foreground) {
        final boolean lackFocusState = (background == null || !background.isStateful()
                || !background.hasFocusStateSpecified())
                && (foreground == null || !foreground.isStateful()
                || !foreground.hasFocusStateSpecified());
        return !isInTouchMode() && getDefaultFocusHighlightEnabled() && lackFocusState
                && isAttachedToWindow() && sUseDefaultFocusHighlight;
    }
@@ -19832,7 +19837,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    private void switchDefaultFocusHighlight() {
        if (isFocused()) {
            final boolean needed = isDefaultFocusHighlightNeeded(mBackground);
            final boolean needed = isDefaultFocusHighlightNeeded(mBackground,
                    mForegroundInfo == null ? null : mForegroundInfo.mDrawable);
            final boolean active = mDefaultFocusHighlight != null;
            if (needed && !active) {
                setDefaultFocusHighlight(getDefaultFocusHighlightDrawable());