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

Commit 61707785 authored by Jiaquan He's avatar Jiaquan He
Browse files

Add a public API defaultFocusHighlightEnabled.

This commit adds a public API to turn on/off default
focus highlights. When a focused View is detected to
have no state_focused defined, we can use this API to
decide wether we should show a default highlight for it.

Test: cts-tradefed run singleCommand cts --skip-device-info
--skip-preconditions --abi armeabi-v7a -m CtsViewTestCases
-t android.view.cts.View_DefaultFocusHighlightTest
Bug: 35096940

Change-Id: I76b45d6bf5761641a0ed7f4d0b04cb325ed72b52
parent f380072e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -471,6 +471,7 @@ package android {
    field public static final deprecated int dayOfWeekBackground = 16843924; // 0x1010494
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final int debuggable = 16842767; // 0x101000f
    field public static final int defaultFocusHighlightEnabled = 16844133; // 0x1010565
    field public static final int defaultHeight = 16844021; // 0x10104f5
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultValue = 16843245; // 0x10101ed
@@ -45244,6 +45245,7 @@ package android.view {
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method public final boolean getDefaultFocusHighlightEnabled();
    method public static int getDefaultSize(int, int);
    method public android.view.Display getDisplay();
    method public final int[] getDrawableState();
@@ -45562,6 +45564,7 @@ package android.view {
    method public void setClipToOutline(boolean);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContextClickable(boolean);
    method public void setDefaultFocusHighlightEnabled(boolean);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
+3 −0
Original line number Diff line number Diff line
@@ -586,6 +586,7 @@ package android {
    field public static final deprecated int dayOfWeekBackground = 16843924; // 0x1010494
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final int debuggable = 16842767; // 0x101000f
    field public static final int defaultFocusHighlightEnabled = 16844133; // 0x1010565
    field public static final int defaultHeight = 16844021; // 0x10104f5
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultValue = 16843245; // 0x10101ed
@@ -48731,6 +48732,7 @@ package android.view {
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method public final boolean getDefaultFocusHighlightEnabled();
    method public static int getDefaultSize(int, int);
    method public android.view.Display getDisplay();
    method public final int[] getDrawableState();
@@ -49049,6 +49051,7 @@ package android.view {
    method public void setClipToOutline(boolean);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContextClickable(boolean);
    method public void setDefaultFocusHighlightEnabled(boolean);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
+4 −0
Original line number Diff line number Diff line
@@ -471,6 +471,7 @@ package android {
    field public static final deprecated int dayOfWeekBackground = 16843924; // 0x1010494
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final int debuggable = 16842767; // 0x101000f
    field public static final int defaultFocusHighlightEnabled = 16844133; // 0x1010565
    field public static final int defaultHeight = 16844021; // 0x10104f5
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultValue = 16843245; // 0x10101ed
@@ -13991,6 +13992,7 @@ package android.graphics.drawable {
    method public boolean getPadding(android.graphics.Rect);
    method public int[] getState();
    method public android.graphics.Region getTransparentRegion();
    method public boolean hasFocusStateSpecified();
    method public void inflate(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public void inflate(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method public void invalidateSelf();
@@ -45618,6 +45620,7 @@ package android.view {
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method public final boolean getDefaultFocusHighlightEnabled();
    method public static int getDefaultSize(int, int);
    method public android.view.Display getDisplay();
    method public final int[] getDrawableState();
@@ -45939,6 +45942,7 @@ package android.view {
    method public void setClipToOutline(boolean);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContextClickable(boolean);
    method public void setDefaultFocusHighlightEnabled(boolean);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
+38 −0
Original line number Diff line number Diff line
@@ -4080,6 +4080,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    int mNextClusterForwardId = View.NO_ID;
    /**
     * Whether this View should use a default focus highlight when it gets focused but doesn't
     * have {@link android.R.attr#state_focused} defined in its background.
     */
    boolean mDefaultFocusHighlightEnabled = true;
    private CheckForLongPress mPendingCheckForLongPress;
    private CheckForTap mPendingCheckForTap = null;
    private PerformClick mPerformClick;
@@ -5064,6 +5070,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        setImportantForAutofill(a.getInt(attr, IMPORTANT_FOR_AUTOFILL_AUTO));
                    }
                    break;
                case R.styleable.View_defaultFocusHighlightEnabled:
                    if (a.peekValue(attr) != null) {
                        setDefaultFocusHighlightEnabled(a.getBoolean(attr, true));
                    }
                    break;
            }
        }
@@ -9929,6 +9940,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return false;
    }
    /**
     * Sets whether this View should use a default focus highlight when it gets focused but doesn't
     * have {@link android.R.attr#state_focused} defined in its background.
     *
     * @param defaultFocusHighlightEnabled {@code true} to set this view to use a default focus
     *                                      highlight, {@code false} otherwise.
     *
     * @attr ref android.R.styleable#View_defaultFocusHighlightEnabled
     */
    public void setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled) {
        mDefaultFocusHighlightEnabled = defaultFocusHighlightEnabled;
    }
    /**
    /**
     * Returns whether this View should use a default focus highlight when it gets focused but
     * doesn't have {@link android.R.attr#state_focused} defined in its background.
     *
     * @return True if this View should use a default focus highlight.
     * @attr ref android.R.styleable#View_defaultFocusHighlightEnabled
     */
    @ViewDebug.ExportedProperty(category = "defaultFocusHighlightEnabled")
    public final boolean getDefaultFocusHighlightEnabled() {
        return mDefaultFocusHighlightEnabled;
    }
    /**
     * If a user manually specified the next view id for a particular direction,
     * use the root to look up the view.
+3 −0
Original line number Diff line number Diff line
@@ -2953,6 +2953,9 @@
             See {@link android.view.View#setFocusedByDefault(boolean)}. -->
        <attr name="focusedByDefault" format="boolean" />

        <!-- Whether this View should use a default focus highlight when it gets focused but
             doesn't have {@link android.R.attr#state_focused} defined in its background. -->
        <attr name="defaultFocusHighlightEnabled" format="boolean" />
    </declare-styleable>

    <!-- Attributes that can be assigned to a tag for a particular View. -->
Loading