diff options
author | Romain Guy <> | 2009-03-24 22:45:53 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 22:45:53 -0700 |
commit | 97d00b3150df9eb434f51f486a6104bb16a16cec (patch) | |
tree | 24ba25c0bd2d56c9f8e1c464c0970149d5f33fd1 | |
parent | 2764f30a74484870de03fa1a2aca0c01f991c711 (diff) | |
download | frameworks_base-97d00b3150df9eb434f51f486a6104bb16a16cec.zip frameworks_base-97d00b3150df9eb434f51f486a6104bb16a16cec.tar.gz frameworks_base-97d00b3150df9eb434f51f486a6104bb16a16cec.tar.bz2 |
Automated import from //branches/donutburger/...@142465,142465
-rw-r--r-- | api/current.xml | 284 | ||||
-rw-r--r-- | core/java/android/view/animation/AccelerateDecelerateInterpolator.java | 1 | ||||
-rw-r--r-- | core/java/android/view/animation/AccelerateInterpolator.java | 15 | ||||
-rw-r--r-- | core/java/android/view/animation/AnimationUtils.java | 89 | ||||
-rw-r--r-- | core/java/android/view/animation/AnticipateInterpolator.java | 56 | ||||
-rw-r--r-- | core/java/android/view/animation/AnticipateOvershootInterpolator.java | 83 | ||||
-rw-r--r-- | core/java/android/view/animation/BounceInterpolator.java | 51 | ||||
-rw-r--r-- | core/java/android/view/animation/OvershootInterpolator.java | 59 | ||||
-rw-r--r-- | core/res/res/anim/anticipate_interpolator.xml | 21 | ||||
-rw-r--r-- | core/res/res/anim/anticipate_overshoot_interpolator.xml | 21 | ||||
-rw-r--r-- | core/res/res/anim/bounce_interpolator.xml | 21 | ||||
-rw-r--r-- | core/res/res/anim/overshoot_interpolator.xml | 21 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 21 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 16 |
14 files changed, 702 insertions, 57 deletions
diff --git a/api/current.xml b/api/current.xml index 2260abb..ab2857d 100644 --- a/api/current.xml +++ b/api/current.xml @@ -1361,6 +1361,39 @@ visibility="public" > </field> +<field name="anticipate_interpolator" + type="int" + transient="false" + volatile="false" + value="17432583" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="anticipate_overshoot_interpolator" + type="int" + transient="false" + volatile="false" + value="17432585" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="bounce_interpolator" + type="int" + transient="false" + volatile="false" + value="17432586" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="decelerate_interpolator" type="int" transient="false" @@ -1394,6 +1427,17 @@ visibility="public" > </field> +<field name="overshoot_interpolator" + type="int" + transient="false" + volatile="false" + value="17432584" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="slide_in_left" type="int" transient="false" @@ -3144,6 +3188,17 @@ visibility="public" > </field> +<field name="extraTension" + type="int" + transient="false" + volatile="false" + value="16843377" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="factor" type="int" transient="false" @@ -7159,6 +7214,17 @@ visibility="public" > </field> +<field name="tension" + type="int" + transient="false" + volatile="false" + value="16843376" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="text" type="int" transient="false" @@ -134171,6 +134237,170 @@ </parameter> </method> </class> +<class name="AnticipateInterpolator" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="android.view.animation.Interpolator"> +</implements> +<constructor name="AnticipateInterpolator" + type="android.view.animation.AnticipateInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<constructor name="AnticipateInterpolator" + type="android.view.animation.AnticipateInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="tension" type="float"> +</parameter> +</constructor> +<constructor name="AnticipateInterpolator" + type="android.view.animation.AnticipateInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="context" type="android.content.Context"> +</parameter> +<parameter name="attrs" type="android.util.AttributeSet"> +</parameter> +</constructor> +<method name="getInterpolation" + return="float" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="t" type="float"> +</parameter> +</method> +</class> +<class name="AnticipateOvershootInterpolator" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="android.view.animation.Interpolator"> +</implements> +<constructor name="AnticipateOvershootInterpolator" + type="android.view.animation.AnticipateOvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<constructor name="AnticipateOvershootInterpolator" + type="android.view.animation.AnticipateOvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="tension" type="float"> +</parameter> +</constructor> +<constructor name="AnticipateOvershootInterpolator" + type="android.view.animation.AnticipateOvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="tension" type="float"> +</parameter> +<parameter name="extraTension" type="float"> +</parameter> +</constructor> +<constructor name="AnticipateOvershootInterpolator" + type="android.view.animation.AnticipateOvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="context" type="android.content.Context"> +</parameter> +<parameter name="attrs" type="android.util.AttributeSet"> +</parameter> +</constructor> +<method name="getInterpolation" + return="float" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="t" type="float"> +</parameter> +</method> +</class> +<class name="BounceInterpolator" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="android.view.animation.Interpolator"> +</implements> +<constructor name="BounceInterpolator" + type="android.view.animation.BounceInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<constructor name="BounceInterpolator" + type="android.view.animation.BounceInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="context" type="android.content.Context"> +</parameter> +<parameter name="attrs" type="android.util.AttributeSet"> +</parameter> +</constructor> +<method name="getInterpolation" + return="float" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="t" type="float"> +</parameter> +</method> +</class> <class name="CycleInterpolator" extends="java.lang.Object" abstract="false" @@ -134974,6 +135204,60 @@ </parameter> </method> </class> +<class name="OvershootInterpolator" + extends="java.lang.Object" + abstract="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<implements name="android.view.animation.Interpolator"> +</implements> +<constructor name="OvershootInterpolator" + type="android.view.animation.OvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> +<constructor name="OvershootInterpolator" + type="android.view.animation.OvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="tension" type="float"> +</parameter> +</constructor> +<constructor name="OvershootInterpolator" + type="android.view.animation.OvershootInterpolator" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="context" type="android.content.Context"> +</parameter> +<parameter name="attrs" type="android.util.AttributeSet"> +</parameter> +</constructor> +<method name="getInterpolation" + return="float" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="t" type="float"> +</parameter> +</method> +</class> <class name="RotateAnimation" extends="android.view.animation.Animation" abstract="false" diff --git a/core/java/android/view/animation/AccelerateDecelerateInterpolator.java b/core/java/android/view/animation/AccelerateDecelerateInterpolator.java index fdb6f9d..158c56e 100644 --- a/core/java/android/view/animation/AccelerateDecelerateInterpolator.java +++ b/core/java/android/view/animation/AccelerateDecelerateInterpolator.java @@ -28,6 +28,7 @@ public class AccelerateDecelerateInterpolator implements Interpolator { public AccelerateDecelerateInterpolator() { } + @SuppressWarnings({"UnusedDeclaration"}) public AccelerateDecelerateInterpolator(Context context, AttributeSet attrs) { } diff --git a/core/java/android/view/animation/AccelerateInterpolator.java b/core/java/android/view/animation/AccelerateInterpolator.java index b9e293f..dcab743 100644 --- a/core/java/android/view/animation/AccelerateInterpolator.java +++ b/core/java/android/view/animation/AccelerateInterpolator.java @@ -26,7 +26,12 @@ import android.util.AttributeSet; * */ public class AccelerateInterpolator implements Interpolator { + private final float mFactor; + private final double mDoubleFactor; + public AccelerateInterpolator() { + mFactor = 1.0f; + mDoubleFactor = 2.0; } /** @@ -39,6 +44,7 @@ public class AccelerateInterpolator implements Interpolator { */ public AccelerateInterpolator(float factor) { mFactor = factor; + mDoubleFactor = 2 * mFactor; } public AccelerateInterpolator(Context context, AttributeSet attrs) { @@ -46,17 +52,16 @@ public class AccelerateInterpolator implements Interpolator { context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AccelerateInterpolator); mFactor = a.getFloat(com.android.internal.R.styleable.AccelerateInterpolator_factor, 1.0f); - + mDoubleFactor = 2 * mFactor; + a.recycle(); } public float getInterpolation(float input) { if (mFactor == 1.0f) { - return (float)(input * input); + return input * input; } else { - return (float)Math.pow(input, 2 * mFactor); + return (float)Math.pow(input, mDoubleFactor); } } - - private float mFactor = 1.0f; } diff --git a/core/java/android/view/animation/AnimationUtils.java b/core/java/android/view/animation/AnimationUtils.java index ce3cdc5..3088382 100644 --- a/core/java/android/view/animation/AnimationUtils.java +++ b/core/java/android/view/animation/AnimationUtils.java @@ -63,15 +63,13 @@ public class AnimationUtils { parser = context.getResources().getAnimation(id); return createAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { - NotFoundException rnf = new NotFoundException( - "Can't load animation resource ID #0x" - + Integer.toHexString(id)); + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { - NotFoundException rnf = new NotFoundException( - "Can't load animation resource ID #0x" - + Integer.toHexString(id)); + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { @@ -81,16 +79,17 @@ public class AnimationUtils { private static Animation createAnimationFromXml(Context c, XmlPullParser parser) throws XmlPullParserException, IOException { + return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser)); } - private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) - throws XmlPullParserException, IOException { + private static Animation createAnimationFromXml(Context c, XmlPullParser parser, + AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException { Animation anim = null; // Make sure we are on a start tag. - int type = parser.getEventType(); + int type; int depth = parser.getDepth(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) @@ -126,23 +125,21 @@ public class AnimationUtils { } - public static LayoutAnimationController loadLayoutAnimation( - Context context, int id) throws NotFoundException { + public static LayoutAnimationController loadLayoutAnimation(Context context, int id) + throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createLayoutAnimationFromXml(context, parser); } catch (XmlPullParserException ex) { - NotFoundException rnf = new NotFoundException( - "Can't load animation resource ID #0x" + - Integer.toHexString(id)); + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { - NotFoundException rnf = new NotFoundException( - "Can't load animation resource ID #0x" + - Integer .toHexString(id)); + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { @@ -150,24 +147,21 @@ public class AnimationUtils { } } - private static LayoutAnimationController createLayoutAnimationFromXml( - Context c, XmlPullParser parser) - throws XmlPullParserException, IOException { - return createLayoutAnimationFromXml(c, parser, - Xml.asAttributeSet(parser)); + private static LayoutAnimationController createLayoutAnimationFromXml(Context c, + XmlPullParser parser) throws XmlPullParserException, IOException { + + return createLayoutAnimationFromXml(c, parser, Xml.asAttributeSet(parser)); } - private static LayoutAnimationController createLayoutAnimationFromXml( - Context c, XmlPullParser parser, AttributeSet attrs) - throws XmlPullParserException, IOException { + private static LayoutAnimationController createLayoutAnimationFromXml(Context c, + XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { LayoutAnimationController controller = null; int type; int depth = parser.getDepth(); - while (((type = parser.next()) != XmlPullParser.END_TAG - || parser.getDepth() > depth) + while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { if (type != XmlPullParser.START_TAG) { @@ -181,8 +175,7 @@ public class AnimationUtils { } else if ("gridLayoutAnimation".equals(name)) { controller = new GridLayoutAnimationController(c, attrs); } else { - throw new RuntimeException("Unknown layout animation name: " + - name); + throw new RuntimeException("Unknown layout animation name: " + name); } } @@ -197,9 +190,7 @@ public class AnimationUtils { * @param fromLeft is the object to be animated coming from the left * @return The new animation */ - public static Animation makeInAnimation(Context c, boolean fromLeft) - { - + public static Animation makeInAnimation(Context c, boolean fromLeft) { Animation a; if (fromLeft) { a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_left); @@ -220,9 +211,7 @@ public class AnimationUtils { * @param toRight is the object to be animated exiting to the right * @return The new animation */ - public static Animation makeOutAnimation(Context c, boolean toRight) - { - + public static Animation makeOutAnimation(Context c, boolean toRight) { Animation a; if (toRight) { a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_out_right); @@ -243,9 +232,7 @@ public class AnimationUtils { * @param c Context for loading resources * @return The new animation */ - public static Animation makeInChildBottomAnimation(Context c) - { - + public static Animation makeInChildBottomAnimation(Context c) { Animation a; a = AnimationUtils.loadAnimation(c, com.android.internal.R.anim.slide_in_child_bottom); a.setInterpolator(new AccelerateInterpolator()); @@ -261,23 +248,19 @@ public class AnimationUtils { * @return The animation object reference by the specified id * @throws NotFoundException */ - public static Interpolator loadInterpolator(Context context, int id) - throws NotFoundException { - + public static Interpolator loadInterpolator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createInterpolatorFromXml(context, parser); } catch (XmlPullParserException ex) { - NotFoundException rnf = new NotFoundException( - "Can't load animation resource ID #0x" - + Integer.toHexString(id)); + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { - NotFoundException rnf = new NotFoundException( - "Can't load animation resource ID #0x" - + Integer.toHexString(id)); + NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" + + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { @@ -287,12 +270,12 @@ public class AnimationUtils { } private static Interpolator createInterpolatorFromXml(Context c, XmlPullParser parser) - throws XmlPullParserException, IOException { + throws XmlPullParserException, IOException { Interpolator interpolator = null; // Make sure we are on a start tag. - int type = parser.getEventType(); + int type; int depth = parser.getDepth(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) @@ -317,6 +300,14 @@ public class AnimationUtils { interpolator = new AccelerateDecelerateInterpolator(c, attrs); } else if (name.equals("cycleInterpolator")) { interpolator = new CycleInterpolator(c, attrs); + } else if (name.equals("anticipateInterpolator")) { + interpolator = new AnticipateInterpolator(c, attrs); + } else if (name.equals("overshootInterpolator")) { + interpolator = new OvershootInterpolator(c, attrs); + } else if (name.equals("anticipateOvershootInterpolator")) { + interpolator = new AnticipateOvershootInterpolator(c, attrs); + } else if (name.equals("bounceInterpolator")) { + interpolator = new BounceInterpolator(c, attrs); } else { throw new RuntimeException("Unknown interpolator name: " + parser.getName()); } diff --git a/core/java/android/view/animation/AnticipateInterpolator.java b/core/java/android/view/animation/AnticipateInterpolator.java new file mode 100644 index 0000000..a6f110e --- /dev/null +++ b/core/java/android/view/animation/AnticipateInterpolator.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 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.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; + +/** + * An interpolator where the change starts backward then flings forward. + */ +public class AnticipateInterpolator implements Interpolator { + private final float mTension; + + public AnticipateInterpolator() { + mTension = 2.0f; + } + + /** + * @param tension Amount of anticipation. When tension equals 0.0f, there is + * no anticipation and the interpolator becomes a simple + * acceleration interpolator. + */ + public AnticipateInterpolator(float tension) { + mTension = tension; + } + + public AnticipateInterpolator(Context context, AttributeSet attrs) { + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.AnticipateInterpolator); + + mTension = + a.getFloat(com.android.internal.R.styleable.AnticipateInterpolator_tension, 2.0f); + + a.recycle(); + } + + public float getInterpolation(float t) { + // a(t) = t * t * ((tension + 1) * t - tension) + return t * t * ((mTension + 1) * t - mTension); + } +} diff --git a/core/java/android/view/animation/AnticipateOvershootInterpolator.java b/core/java/android/view/animation/AnticipateOvershootInterpolator.java new file mode 100644 index 0000000..3dc9722 --- /dev/null +++ b/core/java/android/view/animation/AnticipateOvershootInterpolator.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 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.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_extraTension; +import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_tension; +import static com.android.internal.R.styleable.AnticipateOvershootInterpolator; + +/** + * An interpolator where the change starts backward then flings forward and overshoots + * the target value and finally goes back to the final value. + */ +public class AnticipateOvershootInterpolator implements Interpolator { + private final float mTension; + + public AnticipateOvershootInterpolator() { + mTension = 2.0f * 1.5f; + } + + /** + * @param tension Amount of anticipation/overshoot. When tension equals 0.0f, + * there is no anticipation/overshoot and the interpolator becomes + * a simple acceleration/deceleration interpolator. + */ + public AnticipateOvershootInterpolator(float tension) { + mTension = tension * 1.5f; + } + + /** + * @param tension Amount of anticipation/overshoot. When tension equals 0.0f, + * there is no anticipation/overshoot and the interpolator becomes + * a simple acceleration/deceleration interpolator. + * @param extraTension Amount by which to multiply the tension. For instance, + * to get the same overshoot as an OvershootInterpolator with + * a tension of 2.0f, you would use an extraTension of 1.5f. + */ + public AnticipateOvershootInterpolator(float tension, float extraTension) { + mTension = tension * extraTension; + } + + public AnticipateOvershootInterpolator(Context context, AttributeSet attrs) { + TypedArray a = context.obtainStyledAttributes(attrs, AnticipateOvershootInterpolator); + + mTension = a.getFloat(AnticipateOvershootInterpolator_tension, 2.0f) * + a.getFloat(AnticipateOvershootInterpolator_extraTension, 1.5f); + + a.recycle(); + } + + private static float a(float t, float s) { + return t * t * ((s + 1) * t - s); + } + + private static float o(float t, float s) { + return t * t * ((s + 1) * t + s); + } + + public float getInterpolation(float t) { + // a(t, s) = t * t * ((s + 1) * t - s) + // o(t, s) = t * t * ((s + 1) * t + s) + // f(t) = 0.5 * a(t * 2, tension * extraTension), when t < 0.5 + // f(t) = 0.5 * (o(t * 2 - 2, tension * extraTension) + 2), when t <= 1.0 + if (t < 0.5f) return 0.5f * a(t * 2.0f, mTension); + else return 0.5f * (o(t * 2.0f - 2.0f, mTension) + 2.0f); + } +} diff --git a/core/java/android/view/animation/BounceInterpolator.java b/core/java/android/view/animation/BounceInterpolator.java new file mode 100644 index 0000000..f79e730 --- /dev/null +++ b/core/java/android/view/animation/BounceInterpolator.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 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.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; + +/** + * An interpolator where the change bounces at the end. + */ +public class BounceInterpolator implements Interpolator { + public BounceInterpolator() { + } + + @SuppressWarnings({"UnusedDeclaration"}) + public BounceInterpolator(Context context, AttributeSet attrs) { + } + + private static float bounce(float t) { + return t * t * 8.0f; + } + + public float getInterpolation(float t) { + // _b(t) = t * t * 8 + // bs(t) = _b(t) for t < 0.3535 + // bs(t) = _b(t - 0.54719) + 0.7 for t < 0.7408 + // bs(t) = _b(t - 0.8526) + 0.9 for t < 0.9644 + // bs(t) = _b(t - 1.0435) + 0.95 for t <= 1.0 + // b(t) = bs(t * 1.1226) + t *= 1.1226f; + if (t < 0.3535f) return bounce(t); + else if (t < 0.7408f) return bounce(t - 0.54719f) + 0.7f; + else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f; + else return bounce(t - 1.0435f) + 0.95f; + } +}
\ No newline at end of file diff --git a/core/java/android/view/animation/OvershootInterpolator.java b/core/java/android/view/animation/OvershootInterpolator.java new file mode 100644 index 0000000..494f8ab --- /dev/null +++ b/core/java/android/view/animation/OvershootInterpolator.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 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.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; + +/** + * An interpolator where the change flings forward and overshoots the last value + * then comes back. + */ +public class OvershootInterpolator implements Interpolator { + private final float mTension; + + public OvershootInterpolator() { + mTension = 2.0f; + } + + /** + * @param tension Amount of overshoot. When tension equals 0.0f, there is + * no overshoot and the interpolator becomes a simple + * deceleration interpolator. + */ + public OvershootInterpolator(float tension) { + mTension = tension; + } + + public OvershootInterpolator(Context context, AttributeSet attrs) { + TypedArray a = context.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.OvershootInterpolator); + + mTension = + a.getFloat(com.android.internal.R.styleable.OvershootInterpolator_tension, 2.0f); + + a.recycle(); + } + + public float getInterpolation(float t) { + // _o(t) = t * t * ((tension + 1) * t + tension) + // o(t) = _o(t - 1) + 1 + t -= 1.0f; + return t * t * ((mTension + 1) * t + mTension) + 1.0f; + } +} diff --git a/core/res/res/anim/anticipate_interpolator.xml b/core/res/res/anim/anticipate_interpolator.xml new file mode 100644 index 0000000..50a555a --- /dev/null +++ b/core/res/res/anim/anticipate_interpolator.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, 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. +*/ +--> + +<anticipateInterpolator xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/core/res/res/anim/anticipate_overshoot_interpolator.xml b/core/res/res/anim/anticipate_overshoot_interpolator.xml new file mode 100644 index 0000000..440a899 --- /dev/null +++ b/core/res/res/anim/anticipate_overshoot_interpolator.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, 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. +*/ +--> + +<anticipateOvershootInterpolator xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/core/res/res/anim/bounce_interpolator.xml b/core/res/res/anim/bounce_interpolator.xml new file mode 100644 index 0000000..406fbb9 --- /dev/null +++ b/core/res/res/anim/bounce_interpolator.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, 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. +*/ +--> + +<bounceInterpolator xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/core/res/res/anim/overshoot_interpolator.xml b/core/res/res/anim/overshoot_interpolator.xml new file mode 100644 index 0000000..c614e0b --- /dev/null +++ b/core/res/res/anim/overshoot_interpolator.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, 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. +*/ +--> + +<overshootInterpolator xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 485edca..3109489 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2525,12 +2525,12 @@ </declare-styleable> <declare-styleable name="AccelerateInterpolator"> - <!-- This is the amount of deceleration to ad when easing in. --> + <!-- This is the amount of deceleration to add when easing in. --> <attr name="factor" format="float" /> </declare-styleable> <declare-styleable name="DecelerateInterpolator"> - <!-- This is the amount of acceleration to ad when easing out. --> + <!-- This is the amount of acceleration to add when easing out. --> <attr name="factor" /> </declare-styleable> @@ -2538,6 +2538,23 @@ <attr name="cycles" format="float" /> </declare-styleable> + <declare-styleable name="AnticipateInterpolator"> + <!-- This is the amount of tension. --> + <attr name="tension" format="float" /> + </declare-styleable> + + <declare-styleable name="OvershootInterpolator"> + <!-- This is the amount of tension. --> + <attr name="tension" /> + </declare-styleable> + + <declare-styleable name="AnticipateOvershootInterpolator"> + <!-- This is the amount of tension. --> + <attr name="tension" /> + <!-- This is the amount by which to multiply the tension. --> + <attr name="extraTension" format="float" /> + </declare-styleable> + <!-- ========================== --> <!-- State attributes --> <!-- ========================== --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index ed35986..09012c9 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1051,7 +1051,7 @@ <!-- View ID of the text editor inside of an extracted text layout. --> <public type="id" name="inputExtractEditText" id="0x01020025" /> - <!-- View ID of the {@link android.inputmethodservice.KeyboardView} within + <!-- View ID of the {@link android.inpUutmethodservice.KeyboardView} within an input method's input area. --> <public type="id" name="keyboardView" id="0x01020026" /> <!-- View ID of a {@link android.view.View} to close a popup keyboard --> @@ -1104,4 +1104,18 @@ <public type="integer" name="config_shortAnimTime" id="0x010e0000" /> <public type="integer" name="config_mediumAnimTime" id="0x010e0001" /> <public type="integer" name="config_longAnimTime" id="0x010e0002" /> + +<!-- =============================================================== + Resources added in version 4 of the platform. + =============================================================== --> + <eat-comment /> + + <public type="attr" name="tension" id="0x01010270" /> + <public type="attr" name="extraTension" id="0x01010271" /> + + <public type="anim" name="anticipate_interpolator" id="0x010a0007" /> + <public type="anim" name="overshoot_interpolator" id="0x010a0008" /> + <public type="anim" name="anticipate_overshoot_interpolator" id="0x010a0009" /> + <public type="anim" name="bounce_interpolator" id="0x010a000a" /> + </resources> |