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

Commit 2b004b3a authored by Jason Long's avatar Jason Long
Browse files

Move autofill focus triggers from TextView to View.

Bug: 31001899
Change-Id: I6fd01b86936b3140edf87ac63292c77015bb019d
Test: Manual
parent 31e89394
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ import android.view.accessibility.AccessibilityNodeProvider;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
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;
@@ -6433,16 +6434,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            if (isPressed()) {
                setPressed(false);
            }
            if (imm != null && mAttachInfo != null
                    && mAttachInfo.mHasWindowFocus) {
            if (imm != null && mAttachInfo != null && mAttachInfo.mHasWindowFocus) {
                imm.focusOut(this);
            }
            onFocusLost();
        } else if (imm != null && mAttachInfo != null
                && mAttachInfo.mHasWindowFocus) {
        } else if (imm != null && mAttachInfo != null && mAttachInfo.mHasWindowFocus) {
            imm.focusIn(this);
        }
        if (isAutoFillable()) {
            AutoFillManager afm = getAutoFillManager();
            if (afm != null) {
                afm.updateAutoFillInput(this, gainFocus
                        ? AutoFillManager.FLAG_UPDATE_UI_SHOW
                        : AutoFillManager.FLAG_UPDATE_UI_HIDE);
            }
        }
        invalidate(true);
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnFocusChangeListener != null) {
@@ -7078,6 +7086,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return null;
    }
    @Nullable
    private AutoFillManager getAutoFillManager() {
        return mContext.getSystemService(AutoFillManager.class);
    }
    private boolean isAutoFillable() {
        return getAutoFillType() != null && !isAutoFillBlocked();
    }
    private void populateVirtualStructure(ViewStructure structure,
            AccessibilityNodeProvider provider, AccessibilityNodeInfo info, int flags) {
        // NOTE: currently flags are only used for AutoFill; if they're used for Assist as well,
+2 −11
Original line number Diff line number Diff line
@@ -9028,14 +9028,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                Spannable sp = (Spannable) mText;
                MetaKeyKeyListener.resetMetaState(sp);
            }
        } else {
            final AutoFillManager afm = mContext.getSystemService(AutoFillManager.class);
            if (afm != null) {
                if (DEBUG_AUTOFILL) {
                    Log.v(LOG_TAG, "onFocusChanged(false): id=" + getAccessibilityViewId());
                }
                afm.updateAutoFillInput(this, AutoFillManager.FLAG_UPDATE_UI_HIDE);
            }
        }

        startStopMarquee(focused);
@@ -9767,10 +9759,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    @Override
    @Nullable
    public AutoFillType getAutoFillType() {
        // TODO(b/33197203): ideally it should return a constant, but value returned by
        // getInputType() can change.
        return AutoFillType.forText(getInputType());
        return isTextEditable() ? AutoFillType.forText(getInputType()) : null;
    }

    /** @hide */