Skip to content

Commit

Permalink
Merge branch 'release-candidate' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Wei committed Dec 4, 2016
2 parents 4e19dc8 + 5165822 commit abcd178
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 85 deletions.
95 changes: 95 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,98 @@
# 2.1.0

## Breaking changes

## New deprecations

## New features

## Source changes

* [Remove need for explicit generic subclasses.](https://github.com/material-motion/family-tween-android/commit/e4e602a0f7cf1f7d6f51f1e0c6d2086c4488aa98) (Mark Wei)
* [Type safe tween plans.](https://github.com/material-motion/family-tween-android/commit/f5c2d09f116d9f99a865036e00c5f00cc9271415) (Mark Wei)
* [Support runtime 6.0.1](https://github.com/material-motion/family-tween-android/commit/339e293a8bca1d36559c9b9a2db317d22d63f076) (Mark Wei)

## API changes

Auto-generated by running:

apidiff origin/stable release-candidate android library

## ObjectTween<T,

*new* class: `ObjectTween<T,`

*new* field: `long delay`

*new* field: `long duration`

*new* field: `TimeInterpolator[] interTimingFunctions`

*new* field: `float[] offsets`

*new* field: `TweenProperty<? super`

*new* field: `TimeInterpolator timingFunction`

*new* field: `V[] values`


## Tween<V>

*new* constructor: `Tween(TweenProperty<? super View, V>, long, )`

*removed* constructor: `Tween(TweenProperty<?, V>, long, )`

*removed* field: `TweenProperty<?, V>`

*removed* field: `long delay`

*removed* field: `long duration`

*removed* field: `TimeInterpolator[] interTimingFunctions`

*removed* field: `float[] offsets`

*removed* field: `TimeInterpolator timingFunction`

*removed* field: `V[] values`

*removed* method: `Class<? extends Performer> getPerformerClass()`

*modified* class: `Tween<V>`

| From: | public class Tween<V> extends Plan |
| To: | public class Tween<V> extends ObjectTween<View, V> |


## TweenPerformer

*removed* class: `TweenPerformer`

*removed* constructor: `TweenPerformer()`

*removed* method: `void addPlan(BasePlan)`

*removed* method: `void setIsActiveTokenGenerator(IsActiveTokenGenerator)`


## TweenPerformer<T>

*new* class: `TweenPerformer<T>`

*new* constructor: `TweenPerformer()`

*new* method: `void addPlan(Plan<T>)`

*new* method: `void setIsActiveTokenGenerator(IsActiveTokenGenerator)`



## Non-source changes

* [Automatic changelog preparation for release.](https://github.com/material-motion/family-tween-android/commit/7558fab9910c5d507d50f979fe1bbad208319bd1) (Mark Wei)


# 2.0.0

## Breaking changes
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Tween's properties map to the following ObjectAnimator properties:
| interpolator | interpolator |

Learn more about the APIs defined in the library by reading our
[technical documentation](https://jitpack.io/com/github/material-motion/family-tween-android/2.0.0/javadoc/) and our
[technical documentation](https://jitpack.io/com/github/material-motion/family-tween-android/2.1.0/javadoc/) and our
[Starmap](https://material-motion.github.io/material-motion/starmap/).

## Installation
Expand All @@ -55,7 +55,7 @@ Take care to occasionally [check for updates](https://github.com/ben-manes/gradl

```gradle
dependencies {
compile 'com.github.material-motion:family-tween-android:2.0.0'
compile 'com.github.material-motion:family-tween-android:2.1.0'
}
```

Expand Down Expand Up @@ -119,7 +119,7 @@ To run all unit tests, run the following commands:
### How to animate a property with a Tween plan

```java
Tween tween = new Tween<>(property, duration, from, to);
Tween<Float> tween = new Tween<>(property, duration, from, to);
runtime.addPlan(tween, view);
```

Expand All @@ -129,7 +129,7 @@ runtime.addPlan(tween, view);
float[] values = new float[] {0f, .5f, 1f};
float[] offsets = new float[] {0f, .25f, 1f};

Tween tween = new Tween<>(property, duration, values);
Tween<Float> tween = new Tween<>(property, duration, values);
tween.offsets = offsets;
runtime.addPlan(tween, view);
```
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {

dependencies {
// If you are developing any dependencies locally, also list them in local.dependencies.
compile 'com.github.material-motion:material-motion-runtime-android:5.1.0'
compile 'com.github.material-motion:runtime-android:6.0.1'

testCompile 'com.google.truth:truth:0.28'
testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright 2016-present The Material Motion Authors. All Rights Reserved.
*
* 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 com.google.android.material.motion.family.tween;

import android.animation.TimeInterpolator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.animation.AccelerateDecelerateInterpolator;

import com.google.android.material.motion.runtime.Performer;
import com.google.android.material.motion.runtime.Plan;

/**
* Interpolate an object's {@link TweenProperty} from one value to another.
*/
public class ObjectTween<T, V> extends Plan<T> {

/**
* The property whose value will be tweened.
*/
public TweenProperty<? super T, V> property;

/**
* The duration of the animation in milliseconds.
*/
public long duration;
/**
* The start delay of the animation in milliseconds.
*/
public long delay;

/**
* An array of objects providing the value of the animation for each keyframe.
*/
public V[] values;

/**
* An optional array that defines the pacing of the animation. Each offset corresponds to its
* identically-indexed value in the {@link #values} array. Each offset is a floating point
* number in the range of [0,1] that defines the fraction of the {@link #duration} at which the
* corresponding value should apply. If null, each value is assumed to be evenly spaced.
*/
@Nullable
public float[] offsets;

/**
* An optional array that defines the timing functions to be used between any two values. If
* {@link #values} is of length n, then this should be of length n-1. If null, each timing
* function is assumed to be linear.
* <p>
* These timing functions composes with the {@link #timingFunction overall timing function}.
*/
@Nullable
public TimeInterpolator[] interTimingFunctions;

/**
* The overall timing function to apply to the animation. If null, the overall timing function
* is assumed to be {@link AccelerateDecelerateInterpolator}.
* <p>
* This timing function composes with the keyframe {@link #interTimingFunctions}.
*/
@Nullable
public TimeInterpolator timingFunction;

/**
* Initializes an ObjectTween plan for the given property with the values as the keyframes.
* <p>
* If {@code values.length == 1}, the sole value will be treated as the final value. The initial
* value will be calculated from the target.
*/
@SafeVarargs
protected ObjectTween(TweenProperty<? super T, V> property, long duration, @NonNull V... values) {
this.property = property;
this.duration = duration;
this.values = values;
}

@Override
protected Class<? extends Performer<T>> getPerformerClass() {
return (Class<? extends Performer<T>>) new TweenPerformer<T>().getClass();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 The Material Motion Authors. All Rights Reserved.
* Copyright 2016-present The Material Motion Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,68 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.android.material.motion.family.tween;

import android.animation.TimeInterpolator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.animation.AccelerateDecelerateInterpolator;

import com.google.android.material.motion.runtime.Performer;
import com.google.android.material.motion.runtime.Plan;
import android.view.View;

/**
* Interpolate a {@link TweenProperty} from one value to another.
* Interpolate a view's {@link TweenProperty} from one value to another.
*/
public class Tween<V> extends Plan {

/**
* The property whose value will be tweened.
*/
public TweenProperty<?, V> property;

/**
* The duration of the animation in milliseconds.
*/
public long duration;
/**
* The start delay of the animation in milliseconds.
*/
public long delay;

/**
* An array of objects providing the value of the animation for each keyframe.
*/
public V[] values;

/**
* An optional array that defines the pacing of the animation. Each offset corresponds to its
* identically-indexed value in the {@link #values} array. Each offset is a floating point
* number in the range of [0,1] that defines the fraction of the {@link #duration} at which the
* corresponding value should apply. If null, each value is assumed to be evenly spaced.
*/
@Nullable
public float[] offsets;

/**
* An optional array that defines the timing functions to be used between any two values. If
* {@link #values} is of length n, then this should be of length n-1. If null, each timing
* function is assumed to be linear.
* <p>
* These timing functions composes with the {@link #timingFunction overall timing function}.
*/
@Nullable
public TimeInterpolator[] interTimingFunctions;

/**
* The overall timing function to apply to the animation. If null, the overall timing function
* is assumed to be {@link AccelerateDecelerateInterpolator}.
* <p>
* This timing function composes with the keyframe {@link #interTimingFunctions}.
*/
@Nullable
public TimeInterpolator timingFunction;
public class Tween<V> extends ObjectTween<View, V> {

/**
* Initializes a Tween plan for the given property with the values as the keyframes.
Expand All @@ -83,14 +30,7 @@ public class Tween<V> extends Plan {
* value will be calculated from the target.
*/
@SafeVarargs
public Tween(TweenProperty<?, V> property, long duration, @NonNull V... values) {
this.property = property;
this.duration = duration;
this.values = values;
}

@Override
public Class<? extends Performer> getPerformerClass() {
return TweenPerformer.class;
public Tween(TweenProperty<? super View, V> property, long duration, @NonNull V... values) {
super(property, duration, values);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 The Material Motion Authors. All Rights Reserved.
* Copyright 2016-present The Material Motion Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,12 +24,12 @@

import com.google.android.material.motion.runtime.Performer;
import com.google.android.material.motion.runtime.PerformerFeatures.ContinuousPerforming;
import com.google.android.material.motion.runtime.PlanFeatures.BasePlan;
import com.google.android.material.motion.runtime.Plan;

/**
* A {@link Performer} for tween animations. Uses the {@link Animator} API to fulfil tweens.
* A {@link Performer} for object tween animations. Uses the {@link Animator} API to fulfil tweens.
*/
public class TweenPerformer extends Performer implements ContinuousPerforming {
public class TweenPerformer<T> extends Performer<T> implements ContinuousPerforming {

private IsActiveTokenGenerator isActiveTokenGenerator;

Expand All @@ -39,15 +39,15 @@ public void setIsActiveTokenGenerator(IsActiveTokenGenerator isActiveTokenGenera
}

@Override
public void addPlan(BasePlan plan) {
if (plan instanceof Tween) {
addTween((Tween) plan);
public void addPlan(Plan<T> plan) {
if (plan instanceof ObjectTween) {
addTween((ObjectTween<T, ?>) plan);
} else {
throw new IllegalArgumentException("Plan type not supported for " + plan);
}
}

private void addTween(Tween plan) {
private void addTween(ObjectTween<T, ?> plan) {
if (!validate(plan)) {
throw new IllegalArgumentException("Plan failed validation: " + plan);
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public void onAnimationEnd(Animator animation) {
animator.start();
}

private boolean validate(Tween plan) {
private boolean validate(ObjectTween<T, ?> plan) {
if (plan.values.length == 0) {
return false;
}
Expand All @@ -96,7 +96,7 @@ private boolean validate(Tween plan) {
return true;
}

private PropertyValuesHolder createPropertyValuesHolder(Tween plan) {
private PropertyValuesHolder createPropertyValuesHolder(ObjectTween<T, ?> plan) {
// Create keyframes.
Keyframe[] keyframes;
if (plan.values.length == 1) {
Expand Down
Loading

0 comments on commit abcd178

Please sign in to comment.