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

Commit b7daaf8b 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 4a81674b
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line 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 dayOfWeekBackground = 16843924; // 0x1010494
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final int debuggable = 16842767; // 0x101000f
    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 defaultHeight = 16844021; // 0x10104f5
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultValue = 16843245; // 0x10101ed
    field public static final int defaultValue = 16843245; // 0x10101ed
@@ -45331,6 +45332,7 @@ package android.view {
    method public java.lang.CharSequence getContentDescription();
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method public final boolean getDefaultFocusHighlightEnabled();
    method public static int getDefaultSize(int, int);
    method public static int getDefaultSize(int, int);
    method public android.view.Display getDisplay();
    method public android.view.Display getDisplay();
    method public final int[] getDrawableState();
    method public final int[] getDrawableState();
@@ -45649,6 +45651,7 @@ package android.view {
    method public void setClipToOutline(boolean);
    method public void setClipToOutline(boolean);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContextClickable(boolean);
    method public void setContextClickable(boolean);
    method public void setDefaultFocusHighlightEnabled(boolean);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
    method public void setDrawingCacheQuality(int);
+3 −0
Original line number Original line 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 dayOfWeekBackground = 16843924; // 0x1010494
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final int debuggable = 16842767; // 0x101000f
    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 defaultHeight = 16844021; // 0x10104f5
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultValue = 16843245; // 0x10101ed
    field public static final int defaultValue = 16843245; // 0x10101ed
@@ -48880,6 +48881,7 @@ package android.view {
    method public java.lang.CharSequence getContentDescription();
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method public final boolean getDefaultFocusHighlightEnabled();
    method public static int getDefaultSize(int, int);
    method public static int getDefaultSize(int, int);
    method public android.view.Display getDisplay();
    method public android.view.Display getDisplay();
    method public final int[] getDrawableState();
    method public final int[] getDrawableState();
@@ -49198,6 +49200,7 @@ package android.view {
    method public void setClipToOutline(boolean);
    method public void setClipToOutline(boolean);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContextClickable(boolean);
    method public void setContextClickable(boolean);
    method public void setDefaultFocusHighlightEnabled(boolean);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
    method public void setDrawingCacheQuality(int);
+4 −0
Original line number Original line 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 dayOfWeekBackground = 16843924; // 0x1010494
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
    field public static final int debuggable = 16842767; // 0x101000f
    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 defaultHeight = 16844021; // 0x10104f5
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
    field public static final int defaultValue = 16843245; // 0x10101ed
    field public static final int defaultValue = 16843245; // 0x10101ed
@@ -14034,6 +14035,7 @@ package android.graphics.drawable {
    method public boolean getPadding(android.graphics.Rect);
    method public boolean getPadding(android.graphics.Rect);
    method public int[] getState();
    method public int[] getState();
    method public android.graphics.Region getTransparentRegion();
    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) 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 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();
    method public void invalidateSelf();
@@ -45701,6 +45703,7 @@ package android.view {
    method public java.lang.CharSequence getContentDescription();
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
    method public final boolean getDefaultFocusHighlightEnabled();
    method public static int getDefaultSize(int, int);
    method public static int getDefaultSize(int, int);
    method public android.view.Display getDisplay();
    method public android.view.Display getDisplay();
    method public final int[] getDrawableState();
    method public final int[] getDrawableState();
@@ -46023,6 +46026,7 @@ package android.view {
    method public void setClipToOutline(boolean);
    method public void setClipToOutline(boolean);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setContextClickable(boolean);
    method public void setContextClickable(boolean);
    method public void setDefaultFocusHighlightEnabled(boolean);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheBackgroundColor(int);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheEnabled(boolean);
    method public void setDrawingCacheQuality(int);
    method public void setDrawingCacheQuality(int);
+38 −0
Original line number Original line Diff line number Diff line
@@ -4102,6 +4102,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
     */
    int mNextClusterForwardId = View.NO_ID;
    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 CheckForLongPress mPendingCheckForLongPress;
    private CheckForTap mPendingCheckForTap = null;
    private CheckForTap mPendingCheckForTap = null;
    private PerformClick mPerformClick;
    private PerformClick mPerformClick;
@@ -5086,6 +5092,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        setImportantForAutofill(a.getInt(attr, IMPORTANT_FOR_AUTOFILL_AUTO));
                        setImportantForAutofill(a.getInt(attr, IMPORTANT_FOR_AUTOFILL_AUTO));
                    }
                    }
                    break;
                    break;
                case R.styleable.View_defaultFocusHighlightEnabled:
                    if (a.peekValue(attr) != null) {
                        setDefaultFocusHighlightEnabled(a.getBoolean(attr, true));
                    }
                    break;
            }
            }
        }
        }
@@ -9985,6 +9996,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return false;
        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,
     * If a user manually specified the next view id for a particular direction,
     * use the root to look up the view.
     * use the root to look up the view.
+3 −0
Original line number Original line Diff line number Diff line
@@ -2953,6 +2953,9 @@
             See {@link android.view.View#setFocusedByDefault(boolean)}. -->
             See {@link android.view.View#setFocusedByDefault(boolean)}. -->
        <attr name="focusedByDefault" format="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>
    </declare-styleable>


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