diff options
| author | 2024-06-11 21:02:55 +0800 | |
|---|---|---|
| committer | 2024-06-11 13:22:39 +0000 | |
| commit | e96b939b83f334114847e2b1c258135f159792ad (patch) | |
| tree | 31cfc63507044cd8bccee066cebde39f00453e67 | |
| parent | 7c02512c27d20c628767c880e66fc928913e95e4 (diff) | |
Notify DecorContentParent about content change
ActionBarOverlayLayout which implements DecorContentParent would stop
dispatching the WindowInsets dispatched from its parent view, and then
will dispatch it during onMeasure when there is any insets change.
When the content view is changed, the ViewRootImpl will re-send the
WindowInsets to the hierarchy. However, ActionBarOverlayLayout would
stop dispatching it because the insets doesn't change. So that the new
content view won't have a chance to apply the insets.
This CL notifies ActionBarOverlayLayout when the content view is changed
and reset mLast[...]Insets used to compare the insets change.
Bug: 328745925
Flag: NA
Test: atest MagnifierTest
Change-Id: Iaf90447284f897fa2607984c36e12d596f7976c5
3 files changed, 30 insertions, 6 deletions
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 2194c897ff0d..40d760e0064e 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -537,8 +537,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } mContentParent.requestApplyInsets(); final Callback cb = getCallback(); - if (cb != null && !isDestroyed()) { - cb.onContentChanged(); + if (!isDestroyed()) { + if (cb != null) { + cb.onContentChanged(); + } + if (mDecorContentParent != null) { + mDecorContentParent.notifyContentChanged(); + } } mContentParentExplicitlySet = true; } @@ -568,8 +573,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } mContentParent.requestApplyInsets(); final Callback cb = getCallback(); - if (cb != null && !isDestroyed()) { - cb.onContentChanged(); + if (!isDestroyed()) { + if (cb != null) { + cb.onContentChanged(); + } + if (mDecorContentParent != null) { + mDecorContentParent.notifyContentChanged(); + } } mContentParentExplicitlySet = true; } @@ -586,8 +596,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mContentParent.addView(view, params); mContentParent.requestApplyInsets(); final Callback cb = getCallback(); - if (cb != null && !isDestroyed()) { - cb.onContentChanged(); + if (!isDestroyed()) { + if (cb != null) { + cb.onContentChanged(); + } + if (mDecorContentParent != null) { + mDecorContentParent.notifyContentChanged(); + } } } diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java index 68328252abaf..ff57fd4fe2ce 100644 --- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java +++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java @@ -898,6 +898,13 @@ public class ActionBarOverlayLayout extends ViewGroup implements DecorContentPar mDecorToolbar.dismissPopupMenus(); } + @Override + public void notifyContentChanged() { + mLastBaseContentInsets.setEmpty(); + mLastBaseInnerInsets = WindowInsets.CONSUMED; + mLastInnerInsets = WindowInsets.CONSUMED; + } + public static class LayoutParams extends MarginLayoutParams { public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); diff --git a/core/java/com/android/internal/widget/DecorContentParent.java b/core/java/com/android/internal/widget/DecorContentParent.java index ac524f929d1b..8d6cfd1018c0 100644 --- a/core/java/com/android/internal/widget/DecorContentParent.java +++ b/core/java/com/android/internal/widget/DecorContentParent.java @@ -22,6 +22,7 @@ import android.os.Parcelable; import android.util.SparseArray; import android.view.Menu; import android.view.Window; + import com.android.internal.view.menu.MenuPresenter; /** @@ -49,4 +50,5 @@ public interface DecorContentParent { void saveToolbarHierarchyState(SparseArray<Parcelable> toolbarStates); void restoreToolbarHierarchyState(SparseArray<Parcelable> toolbarStates); void dismissPopups(); + void notifyContentChanged(); } |