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

Commit 0221887e authored by Felipe Leme's avatar Felipe Leme
Browse files

Get rid of VirtualViewDelegate.

VirtualViewDelegate was used by views providing virtual children to:
- auto-fill the chidren
- notify system about children changes

Since the notification logic moved to the AutoFillManager class, it's
kind of an overkill to provide a delegate just for autoFill(); instead,
it's simpler to add a new autoFillVirtual(virtualId, value) method on
View.

BUG: 31001899

Test: manual verification
Test: CtsAutoFillServiceTestCases passes

Change-Id: Ia7670aa665918496a009017a11c3de72c4ed3fa2
parent 1bdf3f07
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -44377,6 +44377,7 @@ package android.view {
    method public android.view.ViewPropertyAnimator animate();
    method public void announceForAccessibility(java.lang.CharSequence);
    method public void autoFill(android.view.autofill.AutoFillValue);
    method public void autoFillVirtual(int, android.view.autofill.AutoFillValue);
    method protected boolean awakenScrollBars();
    method protected boolean awakenScrollBars(int);
    method protected boolean awakenScrollBars(int, boolean);
@@ -44468,7 +44469,6 @@ package android.view {
    method public android.os.IBinder getApplicationWindowToken();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -46878,11 +46878,6 @@ package android.view.autofill {
    method public android.view.autofill.FillResponse.Builder setExtras(android.os.Bundle);
  }
  public abstract class VirtualViewDelegate {
    ctor public VirtualViewDelegate();
    method public abstract void autoFill(int, android.view.autofill.AutoFillValue);
  }
}
package android.view.inputmethod {
+1 −6
Original line number Diff line number Diff line
@@ -47784,6 +47784,7 @@ package android.view {
    method public android.view.ViewPropertyAnimator animate();
    method public void announceForAccessibility(java.lang.CharSequence);
    method public void autoFill(android.view.autofill.AutoFillValue);
    method public void autoFillVirtual(int, android.view.autofill.AutoFillValue);
    method protected boolean awakenScrollBars();
    method protected boolean awakenScrollBars(int);
    method protected boolean awakenScrollBars(int, boolean);
@@ -47875,7 +47876,6 @@ package android.view {
    method public android.os.IBinder getApplicationWindowToken();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -50288,11 +50288,6 @@ package android.view.autofill {
    method public android.view.autofill.FillResponse.Builder setExtras(android.os.Bundle);
  }
  public abstract class VirtualViewDelegate {
    ctor public VirtualViewDelegate();
    method public abstract void autoFill(int, android.view.autofill.AutoFillValue);
  }
}
package android.view.inputmethod {
+1 −6
Original line number Diff line number Diff line
@@ -44683,6 +44683,7 @@ package android.view {
    method public android.view.ViewPropertyAnimator animate();
    method public void announceForAccessibility(java.lang.CharSequence);
    method public void autoFill(android.view.autofill.AutoFillValue);
    method public void autoFillVirtual(int, android.view.autofill.AutoFillValue);
    method protected boolean awakenScrollBars();
    method protected boolean awakenScrollBars(int);
    method protected boolean awakenScrollBars(int, boolean);
@@ -44774,7 +44775,6 @@ package android.view {
    method public android.os.IBinder getApplicationWindowToken();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -47191,11 +47191,6 @@ package android.view.autofill {
    method public android.view.autofill.FillResponse.Builder setExtras(android.os.Bundle);
  }
  public abstract class VirtualViewDelegate {
    ctor public VirtualViewDelegate();
    method public abstract void autoFill(int, android.view.autofill.AutoFillValue);
  }
}
package android.view.inputmethod {
+44 −26
Original line number Diff line number Diff line
@@ -106,7 +106,6 @@ import android.view.animation.Transformation;
import android.view.autofill.AutoFillManager;
import android.view.autofill.AutoFillType;
import android.view.autofill.AutoFillValue;
import android.view.autofill.VirtualViewDelegate;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
@@ -6884,8 +6883,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * Called when assist structure is being retrieved from a view as part of an auto-fill request.
     *
     * <p>The structure must be filled according to the request type, which is set in the
     * {@code flags} parameter - see the documentation on each flag for more details.
     * <p>When implementing this method, subclasses must also:
     *
     * <ol>
     * <li>Implement {@link #autoFill(AutoFillValue)}, {@link #getAutoFillType()}
     * and {@link #getAutoFillValue()}.
     * <li>Call {@link android.view.autofill.AutoFillManager#virtualValueChanged(View, int,
     * AutoFillValue)} when its value changed.
     * </ol>
     *
     * @param structure Fill in with structured view data. The default implementation
     * fills in all data that can be inferred from the view itself.
@@ -6983,12 +6988,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Called when assist structure is being retrieved from a view as part of an auto-fill request
     * to generate additional virtual structure under this view.
     *
     * <p>The defaullt implementation uses {@link #getAccessibilityNodeProvider()} to try to
     * <p>The default implementation uses {@link #getAccessibilityNodeProvider()} to try to
     * generate this from the view's virtual accessibility nodes, if any. You can override this
     * for a more optimal implementation providing this data.
     *
     * <p>The structure must be filled according to the request type, which is set in the
     * {@code flags} parameter - see the documentation on each flag for more details.
     * <p>When implementing this method, subclasses must follow the rules below:
     *
     * <ol>
     * <li>Also implement {@link #autoFillVirtual(int, AutoFillValue)} to auto-fill the virtual
     * children.
     * <li>Call {@link android.view.autofill.AutoFillManager#virtualFocusChanged(View, int, Rect,
     * boolean)} when the focus inside the view changed.
     * <li>Call {@link android.view.autofill.AutoFillManager#virtualValueChanged(View, int,
     * AutoFillValue)} when the value of a child changed.
     * <li>Call {@link android.view.autofill.AutoFillManager#reset()} when the auto-fill context
     * of the view structure changed.
     * </ol>
     *
     * @param structure Fill in with structured view data.
     * @param flags optional flags (currently {@code 0}).
@@ -7011,29 +7026,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    /**
     * Gets the {@link VirtualViewDelegate} responsible for auto-filling the virtual children of
     * this view.
     *
     * <p>By default returns {@code null} but should be overridden when view provides a virtual
     * hierachy on {@link #onProvideAutoFillVirtualStructure(ViewStructure, int)}.
     */
    @Nullable
    public VirtualViewDelegate getAutoFillVirtualViewDelegate() {
        return null;
    }
    /**
     * Automatically fills the content of this view with the {@code value}.
     *
     * <p>By default does nothing, but views should override it (and {@link #getAutoFillType()
     * and #getAutoFillValue()} to support the AutoFill Framework.
     * <p>By default does nothing, but views should override it (and {@link #getAutoFillType()},
     * {@link #getAutoFillValue()}, and {@link #onProvideAutoFillStructure(ViewStructure, int)}
     * to support the AutoFill Framework.
     *
     * <p>Typically, it is implemented by:
     *
     * <ol>
     * <li>Call the proper getter method on {@link AutoFillValue} to fetch the actual value.
     * <li>Pass the actual value to the equivalent setter in the view.
     * <li>Calling the proper getter method on {@link AutoFillValue} to fetch the actual value.
     * <li>Passing the actual value to the equivalent setter in the view.
     * <ol>
     *
     * <p>For example, a text-field view would call:
@@ -7044,15 +7048,29 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *     setText(text);
     * }
     * </pre>
     *
     * @param value value to be auto-filled.
     */
    public void autoFill(@SuppressWarnings("unused") AutoFillValue value) {
    }
    /**
     * Describes the auto-fill type that should be used on calls to
     * {@link #autoFill(AutoFillValue)} and
     * {@link VirtualViewDelegate#autoFill(int, AutoFillValue)}.
     * Automatically fills the content of a virtual view with the {@code value}
     *
     * <p>See {@link #autoFill(AutoFillValue)} and
     * {@link #onProvideAutoFillVirtualStructure(ViewStructure, int)} for more info.
     *
     * @param value value to be auto-filled.
     * @param virtualId id identifying the virtual child inside the custom view.
     */
    public void autoFillVirtual(@SuppressWarnings("unused") int virtualId,
            @SuppressWarnings("unused") AutoFillValue value) {
    }
    /**
     * Describes the auto-fill type that should be used on calls to
     * {@link #autoFill(AutoFillValue)} and {@link #autoFillVirtual(int, AutoFillValue)}.
     * <p>By default returns {@code null}, but views should override it (and
     * {@link #autoFill(AutoFillValue)} to support the AutoFill Framework.
     */
+6 −9
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.os.Bundle;
import android.view.autofill.AutoFillId;
import android.view.autofill.AutoFillType;
import android.view.autofill.AutoFillValue;
import android.view.autofill.VirtualViewDelegate;

/**
 * Container for storing additional per-view data generated by {@link View#onProvideStructure
@@ -272,12 +271,11 @@ public abstract class ViewStructure {

    /**
     * Like {@link #newChild(int)}, but providing a {@code virtualId} to the child so it can be
     * auto-filled by {@link VirtualViewDelegate#autoFill(int, AutoFillValue)}.
     * auto-filled by {@link View#autoFillVirtual(int, AutoFillValue)}.
     *
     * @param index child index
     * @param virtualId child's id as defined by {@link VirtualViewDelegate#autoFill(int,
     * AutoFillValue)}.
     * @param flags currently either {@code 0} or {@link #AUTO_FILL_FLAG_SANITIZED}.
     * @param virtualId id identifying the virtual child inside the custom view.
     * @param flags currently {@code 0}.
     */
    // TODO(b/33197203, b/33802548): add CTS/unit test
    public abstract ViewStructure newChild(int index, int virtualId, int flags);
@@ -294,12 +292,11 @@ public abstract class ViewStructure {

    /**
     * Like {@link #asyncNewChild(int)}, but providing a {@code virtualId} to the child so it can be
     * auto-filled by {@link VirtualViewDelegate#autoFill(int, AutoFillValue)}.
     * auto-filled by {@link View#autoFillVirtual(int, AutoFillValue)}.
     *
     * @param index child index
     * @param virtualId child's id as defined by {@link VirtualViewDelegate#autoFill(int,
     * AutoFillValue)}.
     * @param flags currently either {@code 0} or {@link #AUTO_FILL_FLAG_SANITIZED}.
     * @param virtualId id identifying the virtual child inside the custom view.
     * @param flags currently {@code 0}.
     */
    // TODO(b/33197203, b/33802548): add CTS/unit test
    public abstract ViewStructure asyncNewChild(int index, int virtualId, int flags);
Loading