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

Commit b46df69a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move autofill focus triggers from TextView to View."

parents 1df8f1ea 2b004b3a
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;
@@ -6444,16 +6445,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) {
@@ -7089,6 +7097,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 */