Loading core/java/android/view/InsetsController.java +8 −6 Original line number Diff line number Diff line Loading @@ -575,21 +575,23 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting public boolean onStateChanged(InsetsState state) { boolean localStateChanged = !mState.equals(state, true /* excludingCaptionInsets */) boolean stateChanged = !mState.equals(state, true /* excludingCaptionInsets */, false /* excludeInvisibleIme */) || !captionInsetsUnchanged(); if (!localStateChanged && mLastDispatchedState.equals(state)) { if (!stateChanged && mLastDispatchedState.equals(state)) { return false; } if (DEBUG) Log.d(TAG, "onStateChanged: " + state); updateState(state); boolean localStateChanged = !mState.equals(mLastDispatchedState, true /* excludingCaptionInsets */, true /* excludeInvisibleIme */); mLastDispatchedState.set(state, true /* copySources */); applyLocalVisibilityOverride(); if (localStateChanged) { if (DEBUG) Log.d(TAG, "onStateChanged, notifyInsetsChanged"); if (DEBUG) Log.d(TAG, "onStateChanged, notifyInsetsChanged, send state to WM: " + mState); mHost.notifyInsetsChanged(); } if (!mState.equals(mLastDispatchedState, true /* excludingCaptionInsets */)) { if (DEBUG) Log.d(TAG, "onStateChanged, send state to WM: " + mState); updateRequestedState(); } return true; Loading core/java/android/view/InsetsSource.java +9 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,14 @@ public class InsetsSource implements Parcelable { @Override public boolean equals(Object o) { return equals(o, false); } /** * @param excludeInvisibleImeFrames If {@link InsetsState#ITYPE_IME} frames should be ignored * when IME is not visible. */ public boolean equals(Object o, boolean excludeInvisibleImeFrames) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Loading @@ -198,6 +206,7 @@ public class InsetsSource implements Parcelable { if (mType != that.mType) return false; if (mVisible != that.mVisible) return false; if (excludeInvisibleImeFrames && !mVisible && mType == ITYPE_IME) return true; if (!Objects.equals(mVisibleFrame, that.mVisibleFrame)) return false; return mFrame.equals(that.mFrame); } Loading core/java/android/view/InsetsState.java +6 −3 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ public class InsetsState implements Parcelable { @Override public boolean equals(Object o) { return equals(o, false); return equals(o, false, false); } /** Loading @@ -564,10 +564,13 @@ public class InsetsState implements Parcelable { * excluded. * @param excludingCaptionInsets {@code true} if we want to compare two InsetsState objects but * ignore the caption insets source value. * @param excludeInvisibleImeFrames If {@link #ITYPE_IME} frames should be ignored when IME is * not visible. * @return {@code true} if the two InsetsState objects are equal, {@code false} otherwise. */ @VisibleForTesting public boolean equals(Object o, boolean excludingCaptionInsets) { public boolean equals(Object o, boolean excludingCaptionInsets, boolean excludeInvisibleImeFrames) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Loading Loading @@ -598,7 +601,7 @@ public class InsetsState implements Parcelable { if (otherSource == null) { return false; } if (!otherSource.equals(source)) { if (!otherSource.equals(source, excludeInvisibleImeFrames)) { return false; } } Loading core/tests/coretests/src/android/view/InsetsControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -678,7 +678,8 @@ public class InsetsControllerTest { final InsetsState currentState = new InsetsState(mController.getState()); // The caption bar source should be synced with the info in mAttachInfo. assertEquals(captionFrame, currentState.peekSource(ITYPE_CAPTION_BAR).getFrame()); assertTrue(currentState.equals(state, true /* excludingCaptionInsets*/)); assertTrue(currentState.equals(state, true /* excludingCaptionInsets*/, true /* excludeInvisibleIme */)); mController.setCaptionInsetsHeight(0); mController.onStateChanged(state); // The caption bar source should not be there at all, because we don't add empty Loading core/tests/coretests/src/android/view/InsetsStateTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,15 @@ public class InsetsStateTest { assertEqualsAndHashCode(); } @Test public void testEquals_excludeInvisibleIme() { mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100)); mState.getSource(ITYPE_IME).setVisible(false); mState2.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 200)); mState2.getSource(ITYPE_IME).setVisible(false); assertTrue(mState2.equals(mState, true, true /* excludeInvisibleIme */)); } @Test public void testParcelUnparcel() { mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100)); Loading Loading
core/java/android/view/InsetsController.java +8 −6 Original line number Diff line number Diff line Loading @@ -575,21 +575,23 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting public boolean onStateChanged(InsetsState state) { boolean localStateChanged = !mState.equals(state, true /* excludingCaptionInsets */) boolean stateChanged = !mState.equals(state, true /* excludingCaptionInsets */, false /* excludeInvisibleIme */) || !captionInsetsUnchanged(); if (!localStateChanged && mLastDispatchedState.equals(state)) { if (!stateChanged && mLastDispatchedState.equals(state)) { return false; } if (DEBUG) Log.d(TAG, "onStateChanged: " + state); updateState(state); boolean localStateChanged = !mState.equals(mLastDispatchedState, true /* excludingCaptionInsets */, true /* excludeInvisibleIme */); mLastDispatchedState.set(state, true /* copySources */); applyLocalVisibilityOverride(); if (localStateChanged) { if (DEBUG) Log.d(TAG, "onStateChanged, notifyInsetsChanged"); if (DEBUG) Log.d(TAG, "onStateChanged, notifyInsetsChanged, send state to WM: " + mState); mHost.notifyInsetsChanged(); } if (!mState.equals(mLastDispatchedState, true /* excludingCaptionInsets */)) { if (DEBUG) Log.d(TAG, "onStateChanged, send state to WM: " + mState); updateRequestedState(); } return true; Loading
core/java/android/view/InsetsSource.java +9 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,14 @@ public class InsetsSource implements Parcelable { @Override public boolean equals(Object o) { return equals(o, false); } /** * @param excludeInvisibleImeFrames If {@link InsetsState#ITYPE_IME} frames should be ignored * when IME is not visible. */ public boolean equals(Object o, boolean excludeInvisibleImeFrames) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Loading @@ -198,6 +206,7 @@ public class InsetsSource implements Parcelable { if (mType != that.mType) return false; if (mVisible != that.mVisible) return false; if (excludeInvisibleImeFrames && !mVisible && mType == ITYPE_IME) return true; if (!Objects.equals(mVisibleFrame, that.mVisibleFrame)) return false; return mFrame.equals(that.mFrame); } Loading
core/java/android/view/InsetsState.java +6 −3 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ public class InsetsState implements Parcelable { @Override public boolean equals(Object o) { return equals(o, false); return equals(o, false, false); } /** Loading @@ -564,10 +564,13 @@ public class InsetsState implements Parcelable { * excluded. * @param excludingCaptionInsets {@code true} if we want to compare two InsetsState objects but * ignore the caption insets source value. * @param excludeInvisibleImeFrames If {@link #ITYPE_IME} frames should be ignored when IME is * not visible. * @return {@code true} if the two InsetsState objects are equal, {@code false} otherwise. */ @VisibleForTesting public boolean equals(Object o, boolean excludingCaptionInsets) { public boolean equals(Object o, boolean excludingCaptionInsets, boolean excludeInvisibleImeFrames) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Loading Loading @@ -598,7 +601,7 @@ public class InsetsState implements Parcelable { if (otherSource == null) { return false; } if (!otherSource.equals(source)) { if (!otherSource.equals(source, excludeInvisibleImeFrames)) { return false; } } Loading
core/tests/coretests/src/android/view/InsetsControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -678,7 +678,8 @@ public class InsetsControllerTest { final InsetsState currentState = new InsetsState(mController.getState()); // The caption bar source should be synced with the info in mAttachInfo. assertEquals(captionFrame, currentState.peekSource(ITYPE_CAPTION_BAR).getFrame()); assertTrue(currentState.equals(state, true /* excludingCaptionInsets*/)); assertTrue(currentState.equals(state, true /* excludingCaptionInsets*/, true /* excludeInvisibleIme */)); mController.setCaptionInsetsHeight(0); mController.onStateChanged(state); // The caption bar source should not be there at all, because we don't add empty Loading
core/tests/coretests/src/android/view/InsetsStateTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,15 @@ public class InsetsStateTest { assertEqualsAndHashCode(); } @Test public void testEquals_excludeInvisibleIme() { mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100)); mState.getSource(ITYPE_IME).setVisible(false); mState2.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 200)); mState2.getSource(ITYPE_IME).setVisible(false); assertTrue(mState2.equals(mState, true, true /* excludeInvisibleIme */)); } @Test public void testParcelUnparcel() { mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100)); Loading