diff options
author | Chet Haase <chet@google.com> | 2015-02-11 15:08:38 -0800 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2015-02-13 11:00:55 -0800 |
commit | 10e23ab61b820fb3149b2f89003753d98ebd6a80 (patch) | |
tree | 3559c25e9ecb3a11c69efe6275d90f9b179d2191 /core/java/android/view | |
parent | ae0fdaf5e864ab755e54243006e7116fbb375a7b (diff) | |
download | frameworks_base-10e23ab61b820fb3149b2f89003753d98ebd6a80.zip frameworks_base-10e23ab61b820fb3149b2f89003753d98ebd6a80.tar.gz frameworks_base-10e23ab61b820fb3149b2f89003753d98ebd6a80.tar.bz2 |
Add ClipReveal window transition for application launch
Issue #19362772 Better material launch animations
Change-Id: Ic94fde910b6b5554ee954dfbbf374949f9eb189d
Diffstat (limited to 'core/java/android/view')
8 files changed, 256 insertions, 17 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 743f6b7..8ac8bc5 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -91,6 +91,8 @@ interface IWindowManager IRemoteCallback startedCallback); void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, int startHeight); + void overridePendingAppTransitionClipReveal(int startX, int startY, + int startWidth, int startHeight); void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp); void overridePendingAppTransitionAspectScaledThumb(in Bitmap srcThumb, int startX, diff --git a/core/java/android/view/animation/ClipRectAnimation.java b/core/java/android/view/animation/ClipRectAnimation.java index 2361501..e194927 100644 --- a/core/java/android/view/animation/ClipRectAnimation.java +++ b/core/java/android/view/animation/ClipRectAnimation.java @@ -26,8 +26,8 @@ import android.graphics.Rect; * @hide */ public class ClipRectAnimation extends Animation { - private Rect mFromRect = new Rect(); - private Rect mToRect = new Rect(); + protected Rect mFromRect = new Rect(); + protected Rect mToRect = new Rect(); /** * Constructor to use when building a ClipRectAnimation from code @@ -43,6 +43,15 @@ public class ClipRectAnimation extends Animation { mToRect.set(toClip); } + /** + * Constructor to use when building a ClipRectAnimation from code + */ + public ClipRectAnimation(int fromL, int fromT, int fromR, int fromB, + int toL, int toT, int toR, int toB) { + mFromRect.set(fromL, fromT, fromR, fromB); + mToRect.set(toL, toT, toR, toB); + } + @Override protected void applyTransformation(float it, Transformation tr) { int l = mFromRect.left + (int) ((mToRect.left - mFromRect.left) * it); diff --git a/core/java/android/view/animation/ClipRectLRAnimation.java b/core/java/android/view/animation/ClipRectLRAnimation.java new file mode 100644 index 0000000..8993cd3 --- /dev/null +++ b/core/java/android/view/animation/ClipRectLRAnimation.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Rect; + +/** + * Special case of ClipRectAnimation that animates only the left/right + * dimensions of the clip, picking up the other dimensions from whatever is + * set on the transform already. + * + * @hide + */ +public class ClipRectLRAnimation extends ClipRectAnimation { + + /** + * Constructor. Passes in 0 for Top/Bottom parameters of ClipRectAnimation + */ + public ClipRectLRAnimation(int fromL, int fromR, int toL, int toR) { + super(fromL, 0, fromR, 0, toL, 0, toR, 0); + } + + /** + * Calculates and sets clip rect on given transformation. It uses existing values + * on the Transformation for Top/Bottom clip parameters. + */ + @Override + protected void applyTransformation(float it, Transformation tr) { + Rect oldClipRect = tr.getClipRect(); + tr.setClipRect(mFromRect.left + (int) ((mToRect.left - mFromRect.left) * it), + oldClipRect.top, + mFromRect.right + (int) ((mToRect.right - mFromRect.right) * it), + oldClipRect.bottom); + } +} diff --git a/core/java/android/view/animation/ClipRectTBAnimation.java b/core/java/android/view/animation/ClipRectTBAnimation.java new file mode 100644 index 0000000..06f86ce --- /dev/null +++ b/core/java/android/view/animation/ClipRectTBAnimation.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Rect; + +/** + * Special case of ClipRectAnimation that animates only the top/bottom + * dimensions of the clip, picking up the other dimensions from whatever is + * set on the transform already. + * + * @hide + */ +public class ClipRectTBAnimation extends ClipRectAnimation { + + /** + * Constructor. Passes in 0 for Left/Right parameters of ClipRectAnimation + */ + public ClipRectTBAnimation(int fromT, int fromB, int toT, int toB) { + super(0, fromT, 0, fromB, 0, toT, 0, toB); + } + + /** + * Calculates and sets clip rect on given transformation. It uses existing values + * on the Transformation for Left/Right clip parameters. + */ + @Override + protected void applyTransformation(float it, Transformation tr) { + Rect oldClipRect = tr.getClipRect(); + tr.setClipRect(oldClipRect.left, mFromRect.top + (int) ((mToRect.top - mFromRect.top) * it), + oldClipRect.right, + mFromRect.bottom + (int) ((mToRect.bottom - mFromRect.bottom) * it)); + } + +} diff --git a/core/java/android/view/animation/Transformation.java b/core/java/android/view/animation/Transformation.java index 2f4fe73..30c12ed 100644 --- a/core/java/android/view/animation/Transformation.java +++ b/core/java/android/view/animation/Transformation.java @@ -122,7 +122,13 @@ public class Transformation { mAlpha *= t.getAlpha(); mMatrix.preConcat(t.getMatrix()); if (t.mHasClipRect) { - setClipRect(t.getClipRect()); + Rect bounds = t.getClipRect(); + if (mHasClipRect) { + setClipRect(mClipRect.left + bounds.left, mClipRect.top + bounds.top, + mClipRect.right + bounds.right, mClipRect.bottom + bounds.bottom); + } else { + setClipRect(bounds); + } } } @@ -135,7 +141,13 @@ public class Transformation { mAlpha *= t.getAlpha(); mMatrix.postConcat(t.getMatrix()); if (t.mHasClipRect) { - setClipRect(t.getClipRect()); + Rect bounds = t.getClipRect(); + if (mHasClipRect) { + setClipRect(mClipRect.left + bounds.left, mClipRect.top + bounds.top, + mClipRect.right + bounds.right, mClipRect.bottom + bounds.bottom); + } else { + setClipRect(bounds); + } } } diff --git a/core/java/android/view/animation/TranslateAnimation.java b/core/java/android/view/animation/TranslateAnimation.java index d2ff754..216022b 100644 --- a/core/java/android/view/animation/TranslateAnimation.java +++ b/core/java/android/view/animation/TranslateAnimation.java @@ -24,7 +24,7 @@ import android.util.AttributeSet; * An animation that controls the position of an object. See the * {@link android.view.animation full package} description for details and * sample code. - * + * */ public class TranslateAnimation extends Animation { private int mFromXType = ABSOLUTE; @@ -33,20 +33,28 @@ public class TranslateAnimation extends Animation { private int mFromYType = ABSOLUTE; private int mToYType = ABSOLUTE; - private float mFromXValue = 0.0f; - private float mToXValue = 0.0f; - - private float mFromYValue = 0.0f; - private float mToYValue = 0.0f; - - private float mFromXDelta; - private float mToXDelta; - private float mFromYDelta; - private float mToYDelta; + /** @hide */ + protected float mFromXValue = 0.0f; + /** @hide */ + protected float mToXValue = 0.0f; + + /** @hide */ + protected float mFromYValue = 0.0f; + /** @hide */ + protected float mToYValue = 0.0f; + + /** @hide */ + protected float mFromXDelta; + /** @hide */ + protected float mToXDelta; + /** @hide */ + protected float mFromYDelta; + /** @hide */ + protected float mToYDelta; /** * Constructor used when a TranslateAnimation is loaded from a resource. - * + * * @param context Application context to use * @param attrs Attribute set from which to read values */ @@ -81,7 +89,7 @@ public class TranslateAnimation extends Animation { /** * Constructor to use when building a TranslateAnimation from code - * + * * @param fromXDelta Change in X coordinate to apply at the start of the * animation * @param toXDelta Change in X coordinate to apply at the end of the diff --git a/core/java/android/view/animation/TranslateXAnimation.java b/core/java/android/view/animation/TranslateXAnimation.java new file mode 100644 index 0000000..d75323f --- /dev/null +++ b/core/java/android/view/animation/TranslateXAnimation.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Matrix; + +/** + * Special case of TranslateAnimation that translates only horizontally, picking up the + * vertical values from whatever is set on the Transformation already. When used in + * conjunction with a TranslateYAnimation, allows independent animation of x and y + * position. + * @hide + */ +public class TranslateXAnimation extends TranslateAnimation { + float[] mTmpValues = new float[9]; + + /** + * Constructor. Passes in 0 for the y parameters of TranslateAnimation + */ + public TranslateXAnimation(float fromXDelta, float toXDelta) { + super(fromXDelta, toXDelta, 0, 0); + } + + /** + * Constructor. Passes in 0 for the y parameters of TranslateAnimation + */ + public TranslateXAnimation(int fromXType, float fromXValue, int toXType, float toXValue) { + super(fromXType, fromXValue, toXType, toXValue, ABSOLUTE, 0, ABSOLUTE, 0); + } + + /** + * Calculates and sets x translation values on given transformation. + */ + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + Matrix m = t.getMatrix(); + m.getValues(mTmpValues); + float dx = mFromXDelta + ((mToXDelta - mFromXDelta) * interpolatedTime); + t.getMatrix().setTranslate(dx, mTmpValues[Matrix.MTRANS_Y]); + } +} diff --git a/core/java/android/view/animation/TranslateYAnimation.java b/core/java/android/view/animation/TranslateYAnimation.java new file mode 100644 index 0000000..714558d --- /dev/null +++ b/core/java/android/view/animation/TranslateYAnimation.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Matrix; + +/** + * Special case of TranslateAnimation that translates only vertically, picking up the + * horizontal values from whatever is set on the Transformation already. When used in + * conjunction with a TranslateXAnimation, allows independent animation of x and y + * position. + * @hide + */ +public class TranslateYAnimation extends TranslateAnimation { + float[] mTmpValues = new float[9]; + + /** + * Constructor. Passes in 0 for the x parameters of TranslateAnimation + */ + public TranslateYAnimation(float fromYDelta, float toYDelta) { + super(0, 0, fromYDelta, toYDelta); + } + + /** + * Constructor. Passes in 0 for the x parameters of TranslateAnimation + */ + public TranslateYAnimation(int fromYType, float fromYValue, int toYType, float toYValue) { + super(ABSOLUTE, 0, ABSOLUTE, 0, fromYType, fromYValue, toYType, toYValue); + } + + /** + * Calculates and sets y translation values on given transformation. + */ + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + Matrix m = t.getMatrix(); + m.getValues(mTmpValues); + float dy = mFromYDelta + ((mToYDelta - mFromYDelta) * interpolatedTime); + t.getMatrix().setTranslate(mTmpValues[Matrix.MTRANS_X], dy); + } +} |