Fixes for floating search bar (e.g. background protection).

- Adds background protection for the search bar
 - Views animating based on keyboard now support manual swipes.

Bug: 213954333
Bug: 259004115
Bug: 251460671
Test: Manual
Change-Id: I055766126fb46a8e8b48907e442c9e54aaa4badf
This commit is contained in:
Andy Wickham
2022-11-18 00:36:08 -08:00
parent 9adbab96b7
commit 493831af1a
6 changed files with 67 additions and 32 deletions

View File

@@ -53,10 +53,21 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba
mView.setTranslationY(mInitialTranslation);
return windowInsets;
}
float progress = list.get(0).getInterpolatedFraction();
WindowInsetsAnimation animation = list.get(0);
mView.setTranslationY(
Utilities.mapRange(progress, mInitialTranslation, mTerminalTranslation));
if (animation.getDurationMillis() > -1) {
float progress = animation.getInterpolatedFraction();
mView.setTranslationY(
Utilities.mapRange(progress, mInitialTranslation, mTerminalTranslation));
} else {
// Manually controlled animation: Set translation to keyboard height.
int translationY = -windowInsets.getInsets(WindowInsets.Type.ime()).bottom;
if (mView.getParent() instanceof View) {
// Offset any translation of the parent (e.g. All Apps parallax).
translationY -= ((View) mView.getParent()).getTranslationY();
}
mView.setTranslationY(translationY);
}
return windowInsets;
}
@@ -73,6 +84,7 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba
@Override
public void onEnd(WindowInsetsAnimation animation) {
mView.setTranslationY(mTerminalTranslation);
if (mView instanceof KeyboardInsetListener) {
((KeyboardInsetListener) mView).onTranslationEnd();
}