summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2020-02-12 15:05:27 -0800
committerJorim Jaggi <jjaggi@google.com>2020-02-17 14:30:25 +0100
commitdb5b0c232140c7e9481e0b5648592cdaf03e169e (patch)
treeeedafab624e0da435104f8983cd1e747935189f0 /tests
parente96570e2915247f85c43925acbdb75dbe502cd16 (diff)
WindowInsetsAnimation: Clean up API
Fixes issues the app developers have raised with the WindowInsetsAnimation API: - it really makes more sense to have the Animation as the outer class, and the Callback nested within - it was not obvious previously that multiple animations could be running at the same time. A new argument to onProgress now makes this abundantly clear by passing in the list of running animations. - The dispatch mode really fits better as a final property on the callback, rather than it being queried once from a getter. Also fixes lint warnings. Fixes: 143556682 Test: make checkapi; atest WindowInsetsControllerTests Change-Id: I8cd8faac70dd5a15d779d2c983f0a0ea5d6bbd8e
Diffstat (limited to 'tests')
-rw-r--r--tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java29
1 files changed, 14 insertions, 15 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 01e212d01574..b9f5ac0270b2 100644
--- a/tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java
+++ b/tests/WindowInsetsTests/src/com/google/android/test/windowinsetstests/WindowInsetsActivity.java
@@ -16,24 +16,26 @@
package com.google.android.test.windowinsetstests;
+import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP;
+
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
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;
import android.view.WindowInsets.Type;
-import android.view.WindowInsetsAnimationCallback;
-import android.view.WindowInsetsAnimationCallback.InsetsAnimation;
+import android.view.WindowInsetsAnimation;
import android.view.WindowInsetsAnimationControlListener;
import android.view.WindowInsetsAnimationController;
import com.google.android.test.windowinsetstests.R;
+import java.util.List;
+
public class WindowInsetsActivity extends Activity {
private View mRoot;
@@ -70,7 +72,7 @@ public class WindowInsetsActivity extends Activity {
float startY;
float endY;
- InsetsAnimation imeAnim;
+ WindowInsetsAnimation imeAnim;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -85,15 +87,11 @@ public class WindowInsetsActivity extends Activity {
v.getWindowInsetsController().hide(Type.ime());
}
});
- mRoot.setWindowInsetsAnimationCallback(new WindowInsetsAnimationCallback() {
-
- @Override
- public int getDispatchMode() {
- return DISPATCH_MODE_STOP;
- }
+ mRoot.setWindowInsetsAnimationCallback(new WindowInsetsAnimation.Callback(
+ DISPATCH_MODE_STOP) {
@Override
- public void onPrepare(InsetsAnimation animation) {
+ public void onPrepare(WindowInsetsAnimation animation) {
if ((animation.getTypeMask() & Type.ime()) != 0) {
imeAnim = animation;
}
@@ -101,20 +99,21 @@ public class WindowInsetsActivity extends Activity {
}
@Override
- public WindowInsets onProgress(WindowInsets insets) {
+ public WindowInsets onProgress(WindowInsets insets,
+ List<WindowInsetsAnimation> runningAnimations) {
mButton.setY(startY + (endY - startY) * imeAnim.getInterpolatedFraction());
return insets;
}
@Override
- public AnimationBounds onStart(InsetsAnimation animation,
- AnimationBounds bounds) {
+ public WindowInsetsAnimation.Bounds onStart(WindowInsetsAnimation animation,
+ WindowInsetsAnimation.Bounds bounds) {
endY = mButton.getTop();
return bounds;
}
@Override
- public void onFinish(InsetsAnimation animation) {
+ public void onEnd(WindowInsetsAnimation animation) {
imeAnim = null;
}
});