Merge "Hide autofill popup if anchor removed" into oc-mr1-dev
am: 8e5e30c5eb
Change-Id: Idd876a073c90f1b87f23e09b1993dc723eb6bdd5
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user