From 05ceb4e0a6e5a986ddf665e9b52123a8c533d6b4 Mon Sep 17 00:00:00 2001 From: Andrew Solovay Date: Mon, 22 May 2017 15:36:11 -0700 Subject: [PATCH] docs: Clarifying code snippet for View.autoFill() Per bug, updating code snippet to clarify that it's an example of an implementation of the method. Oscar & Felipe, please check that I did it right! Also fixed a couple of HTML syntax errors while I had the file open (badly formatted escape-characters that Chrome figured out, but other browsers might choke on) and a spelling error. Revised Javadoc is staged to: http://go/dac-stage/reference/android/view/View.html#autofill(android.view.autofill.AutofillValue) Test: make ds-docs Bug: 38347106 Change-Id: I587a66c53fd5ebeeb6108529723d2d7a74c61cf7 --- core/java/android/view/View.java | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 5b51c16a1dfb4..11b55a8ba42cb 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -593,12 +593,12 @@ import java.util.function.Predicate; * a single tag using the {@link android.R.styleable#View_tag android:tag} * attribute or multiple tags using the {@code } child element: *
- *     <View ...
+ *     <View ...
  *           android:tag="@string/mytag_value" />
- *     <View ...>
- *         <tag android:id="@+id/mytag"
+ *     <View ...>
+ *         <tag android:id="@+id/mytag"
  *              android:value="@string/mytag_value" />
- *     </View>
+ *     </View>
  * 
*

*

@@ -628,11 +628,11 @@ import java.util.function.Predicate; * {@link android.R.styleable#Theme_colorAccent android:colorAccent} defined on * the inflation context's theme (e.g. the Activity theme) will be preserved. *

- *     <LinearLayout
+ *     <LinearLayout
  *             ...
  *             android:theme="@android:theme/ThemeOverlay.Material.Dark">
- *         <View ...>
- *     </LinearLayout>
+ *         <View ...>
+ *     </LinearLayout>
  * 
*

* @@ -7516,15 +7516,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback, *
  • Passing the actual value to the equivalent setter in the view. * * - *

    For example, a text-field view would call: + *

    For example, a text-field view could implement the method this way: + * *

    -     * CharSequence text = value.getTextValue();
    -     * if (text != null) {
    -     *     setText(text);
    +     * @Override
    +     * public void autofill(AutofillValue value) {
    +     *   if (!value.isText() || !this.isEditable()) {
    +     *      return;
    +     *   }
    +     *   CharSequence text = value.getTextValue();
    +     *   if (text != null) {
    +     *     this.setText(text);
    +     *   }
          * }
          * 
    * - *

    If the value is updated asyncronously the next call to + *

    If the value is updated asynchronously the next call to * {@link AutofillManager#notifyValueChanged(View)} must happen after the value was * changed to the autofilled value. If not, the view will not be considered autofilled. *