OSDN Git Service

Make autofilled highlight an attribute
authorPhilip P. Moltmann <moltmann@google.com>
Fri, 28 Apr 2017 22:28:00 +0000 (15:28 -0700)
committerPhilip P. Moltmann <moltmann@google.com>
Fri, 28 Apr 2017 23:13:46 +0000 (16:13 -0700)
Fixes: 37738299
Test: - CtsAutoFillServiceTestCases
      - CtsUiRenderingTestCases:.testclasses.AutofillHighlightTests

Change-Id: I6106f7b2e44d18cd8c80c084f25737e43cbc44de

api/current.txt
api/system-current.txt
api/test-current.txt
core/java/android/view/View.java
core/res/res/values/attrs.xml
core/res/res/values/public.xml
core/res/res/values/symbols.xml
core/res/res/values/themes.xml

index c8bfa47..29cdd5b 100644 (file)
@@ -312,6 +312,7 @@ package android {
     field public static final int autoUrlDetect = 16843404; // 0x101028c
     field public static final int autoVerify = 16844014; // 0x10104ee
     field public static final int autofillHints = 16844121; // 0x1010559
+    field public static final int autofilledHighlight = 16844139; // 0x101056b
     field public static final int background = 16842964; // 0x10100d4
     field public static final int backgroundDimAmount = 16842802; // 0x1010032
     field public static final int backgroundDimEnabled = 16843295; // 0x101021f
@@ -1611,7 +1612,6 @@ package android {
     field public static final int alert_light_frame = 17301505; // 0x1080001
     field public static final int arrow_down_float = 17301506; // 0x1080002
     field public static final int arrow_up_float = 17301507; // 0x1080003
-    field public static final int autofilled_highlight = 17301684; // 0x10800b4
     field public static final int bottom_bar = 17301658; // 0x108009a
     field public static final int btn_default = 17301508; // 0x1080004
     field public static final int btn_default_small = 17301509; // 0x1080005
index 1696bfa..c656f95 100644 (file)
@@ -432,6 +432,7 @@ package android {
     field public static final int autoUrlDetect = 16843404; // 0x101028c
     field public static final int autoVerify = 16844014; // 0x10104ee
     field public static final int autofillHints = 16844121; // 0x1010559
+    field public static final int autofilledHighlight = 16844139; // 0x101056b
     field public static final int background = 16842964; // 0x10100d4
     field public static final int backgroundDimAmount = 16842802; // 0x1010032
     field public static final int backgroundDimEnabled = 16843295; // 0x101021f
@@ -1737,7 +1738,6 @@ package android {
     field public static final int alert_light_frame = 17301505; // 0x1080001
     field public static final int arrow_down_float = 17301506; // 0x1080002
     field public static final int arrow_up_float = 17301507; // 0x1080003
-    field public static final int autofilled_highlight = 17301684; // 0x10800b4
     field public static final int bottom_bar = 17301658; // 0x108009a
     field public static final int btn_default = 17301508; // 0x1080004
     field public static final int btn_default_small = 17301509; // 0x1080005
index a97f165..0f300b3 100644 (file)
@@ -312,6 +312,7 @@ package android {
     field public static final int autoUrlDetect = 16843404; // 0x101028c
     field public static final int autoVerify = 16844014; // 0x10104ee
     field public static final int autofillHints = 16844121; // 0x1010559
+    field public static final int autofilledHighlight = 16844139; // 0x101056b
     field public static final int background = 16842964; // 0x10100d4
     field public static final int backgroundDimAmount = 16842802; // 0x1010032
     field public static final int backgroundDimEnabled = 16843295; // 0x101021f
@@ -1611,7 +1612,6 @@ package android {
     field public static final int alert_light_frame = 17301505; // 0x1080001
     field public static final int arrow_down_float = 17301506; // 0x1080002
     field public static final int arrow_up_float = 17301507; // 0x1080003
-    field public static final int autofilled_highlight = 17301684; // 0x10800b4
     field public static final int bottom_bar = 17301658; // 0x108009a
     field public static final int btn_default = 17301508; // 0x1080004
     field public static final int btn_default_small = 17301509; // 0x1080005
index 4029a42..39f1170 100644 (file)
@@ -805,6 +805,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     public static final int LAST_APP_ACCESSIBILITY_ID = Integer.MAX_VALUE / 2;
 
     /**
+     * Attribute to find the autofilled highlight
+     *
+     * @see #getAutofilledDrawable()
+     */
+    private static final int[] AUTOFILL_HIGHLIGHT_ATTR =
+            new int[]{android.R.attr.autofilledHighlight};
+
+    /**
      * Signals that compatibility booleans have been initialized according to
      * target SDK versions.
      */
@@ -7471,10 +7479,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
      * <p>See {@link #autofill(AutofillValue)} and
      * {@link #onProvideAutofillVirtualStructure(ViewStructure, int)} for more info.
      * <p>To indicate that a virtual view was autofilled
-     * <code>@android:drawable/autofilled_highlight</code> should be drawn over it until the data
+     * <code>?android:attr/autofilledHighlight</code> should be drawn over it until the data
      * changes.
      *
      * @param values map of values to be autofilled, keyed by virtual child id.
+     *
+     * @attr ref android.R.styleable#Theme_autofilledHighlight
      */
     public void autofill(@NonNull @SuppressWarnings("unused") SparseArray<AutofillValue> values) {
     }
@@ -20406,15 +20416,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
      *
      * @throws IllegalStateException if the drawable could not be found.
      */
-    @NonNull private Drawable getAutofilledDrawable() {
+    @Nullable private Drawable getAutofilledDrawable() {
         // Lazily load the isAutofilled drawable.
         if (mAttachInfo.mAutofilledDrawable == null) {
-            mAttachInfo.mAutofilledDrawable = mContext.getDrawable(R.drawable.autofilled_highlight);
-
-            if (mAttachInfo.mAutofilledDrawable == null) {
-                throw new IllegalStateException(
-                        "Could not find android:drawable/autofilled_highlight");
-            }
+            TypedArray a = mContext.getTheme().obtainStyledAttributes(AUTOFILL_HIGHLIGHT_ATTR);
+            int attributeResourceId = a.getResourceId(0, 0);
+            mAttachInfo.mAutofilledDrawable = mContext.getDrawable(attributeResourceId);
+            a.recycle();
         }
 
         return mAttachInfo.mAutofilledDrawable;
@@ -20429,8 +20437,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         if (isAutofilled()) {
             Drawable autofilledHighlight = getAutofilledDrawable();
 
-            autofilledHighlight.setBounds(0, 0, getWidth(), getHeight());
-            autofilledHighlight.draw(canvas);
+            if (autofilledHighlight != null) {
+                autofilledHighlight.setBounds(0, 0, getWidth(), getHeight());
+                autofilledHighlight.draw(canvas);
+            }
         }
     }
 
index 3898cae..64c602a 100644 (file)
@@ -60,6 +60,9 @@
              mode. -->
         <attr name="colorMultiSelectHighlight" format="color" />
 
+        <!-- Drawable to be drawn over the view to mark it as autofilled-->
+        <attr name="autofilledHighlight" format="reference" />
+
         <!-- Default disabled alpha for widgets that set enabled/disabled alpha programmatically. -->
         <attr name="disabledAlpha" format="float" />
         <!-- The alpha applied to the foreground color to create the primary text color. -->
index e13026b..1e0762f 100644 (file)
         <!-- @hide @SystemApi -->
         <public name="requiredSystemPropertyValue" />
         <public name="justificationMode" />
+        <public name="autofilledHighlight" />
     </public-group>
 
     <public-group type="style" first-id="0x010302e0">
         <public name="autofill" />
     </public-group>
 
-    <public-group type="drawable" first-id="0x010800b4">
-        <public name="autofilled_highlight" />
+    <public-group type="drawable" first-id="0x010800b5">
+        <!-- 0x010800b4 was removed -->
         <public name="ic_picture_in_picture" />
     </public-group>
 
index 0ea9b39..1e529da 100644 (file)
   <java-symbol type="attr" name="windowFixedHeightMinor" />
   <java-symbol type="attr" name="accessibilityFocusedDrawable"/>
   <java-symbol type="attr" name="isLightTheme"/>
+  <java-symbol type="attr" name="autofilledHighlight"/>
 
   <java-symbol type="bool" name="action_bar_embed_tabs" />
   <java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
index a661b07..e8fbf34 100644 (file)
@@ -435,6 +435,9 @@ please see themes_device_defaults.xml.
         <!-- Accessibility focused drawable -->
         <item name="accessibilityFocusedDrawable">@drawable/view_accessibility_focused</item>
 
+        <!-- Autofilled highlight drawable -->
+        <item name="autofilledHighlight">@drawable/autofilled_highlight</item>
+
         <!-- Lighting and shadow properties -->
         <item name="lightY">@dimen/light_y</item>
         <item name="lightZ">@dimen/light_z</item>