summaryrefslogtreecommitdiff
path: root/tests/WindowInsetsTests
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2020-01-20 17:24:51 +0100
committerJorim Jaggi <jjaggi@google.com>2020-01-23 00:36:28 +0100
commitdd3304ec3bb7ca651b79a2878149b47b95e1e521 (patch)
tree277241400e4127f0d3fa277899949ca514ca54ad /tests/WindowInsetsTests
parent0da8fd165fed21f26b2b10ddcf4bd1a89d9981c3 (diff)
Fix fraction, and other cleanup
Fraction is now from animation start to end state. This makes it more in line with other animation fraction meaning. Also, the app can figure out the animation direction on its own by inspecting the visibility state when the animation gets prepared. Also fix some other stuff in WindowInsetsAnimationCallback. Test: CTS coming soon Bug: 118118435 Change-Id: I81d36159817719a9b0ee25bb78cfbfddc2029270
Diffstat (limited to 'tests/WindowInsetsTests')
-rw-r--r--tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java24
1 files changed, 6 insertions, 18 deletions
diff --git a/tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java b/tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java
index f3c89d8addf6..01e212d01574 100644
--- a/tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java
+++ b/tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java
@@ -22,6 +22,7 @@ import android.animation.ValueAnimator;
import android.app.Activity;
import android.graphics.Insets;
import android.os.Bundle;
+import android.util.Log;
import android.util.Property;
import android.view.View;
import android.view.WindowInsets;
@@ -67,8 +68,8 @@ public class WindowInsetsActivity extends Activity {
}
};
- float showY;
- float hideY;
+ float startY;
+ float endY;
InsetsAnimation imeAnim;
@Override
@@ -84,16 +85,6 @@ public class WindowInsetsActivity extends Activity {
v.getWindowInsetsController().hide(Type.ime());
}
});
- mRoot.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
- if (imeAnim == null) {
- return;
- }
- if (mRoot.getRootWindowInsets().isVisible(Type.ime())) {
- showY = mButton.getTop();
- } else {
- hideY = mButton.getTop();
- }
- });
mRoot.setWindowInsetsAnimationCallback(new WindowInsetsAnimationCallback() {
@Override
@@ -106,22 +97,19 @@ public class WindowInsetsActivity extends Activity {
if ((animation.getTypeMask() & Type.ime()) != 0) {
imeAnim = animation;
}
- if (mRoot.getRootWindowInsets().isVisible(Type.ime())) {
- showY = mButton.getTop();
- } else {
- hideY = mButton.getTop();
- }
+ startY = mButton.getTop();
}
@Override
public WindowInsets onProgress(WindowInsets insets) {
- mButton.setY(hideY + (showY - hideY) * imeAnim.getInterpolatedFraction());
+ mButton.setY(startY + (endY - startY) * imeAnim.getInterpolatedFraction());
return insets;
}
@Override
public AnimationBounds onStart(InsetsAnimation animation,
AnimationBounds bounds) {
+ endY = mButton.getTop();
return bounds;
}