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

Commit c2840f9f authored by Svet Ganov's avatar Svet Ganov Committed by android-build-merger
Browse files

Merge "Hide autofill popup if anchor removed" into oc-mr1-dev am: 8e5e30c5

am: 89934be6

Change-Id: Idc925398f0b28ffe7220634cd9b74fba22de7278
parents f39df68b 89934be6
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -47,6 +47,19 @@ public class AutofillPopupWindow extends PopupWindow {
    private final WindowPresenter mWindowPresenter;
    private WindowManager.LayoutParams mWindowLayoutParams;

    private final View.OnAttachStateChangeListener mOnAttachStateChangeListener =
            new View.OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow(View v) {
            /* ignore - handled by the super class */
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            dismiss();
        }
    };

    /**
     * Creates a popup window with a presenter owning the window and responsible for
     * showing/hiding/updating the backing window. This can be useful of the window is
@@ -208,7 +221,21 @@ public class AutofillPopupWindow extends PopupWindow {
        p.packageName = anchor.getContext().getPackageName();
        mWindowPresenter.show(p, getTransitionEpicenter(), isLayoutInsetDecor(),
                anchor.getLayoutDirection());
        return;
    }

    @Override
    protected void attachToAnchor(View anchor, int xoff, int yoff, int gravity) {
        super.attachToAnchor(anchor, xoff, yoff, gravity);
        anchor.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
    }

    @Override
    protected void detachFromAnchor() {
        final View anchor = getAnchor();
        if (anchor != null) {
            anchor.removeOnAttachStateChangeListener(mOnAttachStateChangeListener);
        }
        super.detachFromAnchor();
    }

    @Override
+8 −3
Original line number Diff line number Diff line
@@ -2296,8 +2296,8 @@ public class PopupWindow {
    }

    /** @hide */
    protected final void detachFromAnchor() {
        final View anchor = mAnchor != null ? mAnchor.get() : null;
    protected void detachFromAnchor() {
        final View anchor = getAnchor();
        if (anchor != null) {
            final ViewTreeObserver vto = anchor.getViewTreeObserver();
            vto.removeOnScrollChangedListener(mOnScrollChangedListener);
@@ -2316,7 +2316,7 @@ public class PopupWindow {
    }

    /** @hide */
    protected final void attachToAnchor(View anchor, int xoff, int yoff, int gravity) {
    protected void attachToAnchor(View anchor, int xoff, int yoff, int gravity) {
        detachFromAnchor();

        final ViewTreeObserver vto = anchor.getViewTreeObserver();
@@ -2339,6 +2339,11 @@ public class PopupWindow {
        mAnchoredGravity = gravity;
    }

    /** @hide */
    protected @Nullable View getAnchor() {
        return mAnchor != null ? mAnchor.get() : null;
    }

    private void alignToAnchor() {
        final View anchor = mAnchor != null ? mAnchor.get() : null;
        if (anchor != null && anchor.isAttachedToWindow() && hasDecorView()) {