Skip to content

Commit

Permalink
Restrict Google's MultiWaveView animation to JB+
Browse files Browse the repository at this point in the history
Fixes signalapp#4203
// FREEBIE
  • Loading branch information
moxie0 committed Oct 4, 2015
1 parent 0225db9 commit 399dfb1
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/org/thoughtcrime/redphone/util/multiwaveview/MultiWaveView.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
* causes an event that can be caught by implementing OnTriggerListener.
*/
public class MultiWaveView extends View {

private static final int ANIMATION_VERSION = Build.VERSION_CODES.JELLY_BEAN;

private static final String TAG = "MultiWaveView";
private static final boolean DEBUG = false;

Expand Down Expand Up @@ -160,7 +163,7 @@ public MultiWaveView(Context context, AttributeSet attrs) {
this.mContext = context.getApplicationContext();
Resources res = context.getResources();

if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= ANIMATION_VERSION) {
animationsWrapper = new AnimationsWrapper();
}

Expand Down Expand Up @@ -308,7 +311,7 @@ private void switchToState(int state, float x, float y) {
* mFeedbackCount items in the order: left, right, top, bottom.
*/
private void startChevronAnimation() {
if (Build.VERSION.SDK_INT < 11) return;
if (Build.VERSION.SDK_INT < ANIMATION_VERSION) return;

final float r = mHandleDrawable.getWidth() * 0.4f;
final float chevronAnimationDistance = mOuterRadius * 0.9f;
Expand Down Expand Up @@ -347,7 +350,7 @@ private void startChevronAnimation() {
}

private void stopChevronAnimation() {
if (Build.VERSION.SDK_INT < 11) return;
if (Build.VERSION.SDK_INT < ANIMATION_VERSION) return;

for (Tweener anim : mChevronAnimations) {
anim.animator.end();
Expand All @@ -356,7 +359,7 @@ private void stopChevronAnimation() {
}

private void stopHandleAnimation() {
if (Build.VERSION.SDK_INT < 11) return;
if (Build.VERSION.SDK_INT < ANIMATION_VERSION) return;

if (mHandleAnimation != null) {
mHandleAnimation.animator.end();
Expand Down Expand Up @@ -422,7 +425,7 @@ private void doFinish() {
// Inform listener of any active targets. Typically only one will be active.
if (DEBUG) Log.v(TAG, "Finish with target hit = " + targetHit);
dispatchTriggerEvent(mActiveTarget);
if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= ANIMATION_VERSION) {
mHandleAnimation = Tweener.to(mHandleDrawable, 0,
"ease", Ease.Quart.easeOut,
"delay", RETURN_TO_HOME_DELAY,
Expand All @@ -438,7 +441,7 @@ private void doFinish() {
}
} else {
// Animate finger outline back to home position
if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= ANIMATION_VERSION) {
mHandleAnimation = Tweener.to(mHandleDrawable, RETURN_TO_HOME_DURATION,
"ease", Ease.Quart.easeOut,
"delay", 0,
Expand Down Expand Up @@ -473,7 +476,7 @@ private void hideTargets(boolean animate) {
// Note: these animations should complete at the same time so that we can swap out
// the target assets asynchronously from the setTargetResources() call.
mAnimatingTargets = animate;
if (animate && Build.VERSION.SDK_INT >= 11) {
if (animate && Build.VERSION.SDK_INT >= ANIMATION_VERSION) {
final int duration = animate ? HIDE_ANIMATION_DURATION : 0;
for (TargetDrawable target : mTargetDrawables) {
target.setState(TargetDrawable.STATE_INACTIVE);
Expand Down Expand Up @@ -501,7 +504,7 @@ private void showTargets(boolean animate) {
stopTargetAnimation();
}
mAnimatingTargets = animate;
if (animate && Build.VERSION.SDK_INT >= 11) {
if (animate && Build.VERSION.SDK_INT >= ANIMATION_VERSION) {
for (TargetDrawable target : mTargetDrawables) {
target.setState(TargetDrawable.STATE_INACTIVE);
mTargetAnimations.add(Tweener.to(target, SHOW_ANIMATION_DURATION,
Expand All @@ -524,7 +527,7 @@ private void showTargets(boolean animate) {
}

private void stopTargetAnimation() {
if (Build.VERSION.SDK_INT < 11) return;
if (Build.VERSION.SDK_INT < ANIMATION_VERSION) return;

for (Tweener anim : mTargetAnimations) {
anim.animator.end();
Expand Down Expand Up @@ -632,7 +635,7 @@ public void setVibrateEnabled(boolean enabled) {
*
*/
public void ping() {
if (Build.VERSION.SDK_INT >= 11) {
if (Build.VERSION.SDK_INT >= ANIMATION_VERSION) {
stopChevronAnimation();
startChevronAnimation();
}
Expand All @@ -654,7 +657,7 @@ public void reset(boolean animate) {
mHandleDrawable.setY(mWaveCenterY);
mHandleDrawable.setState(TargetDrawable.STATE_INACTIVE);

if (Build.VERSION.SDK_INT >= 11)
if (Build.VERSION.SDK_INT >= ANIMATION_VERSION)
Tweener.reset();
}

Expand Down

0 comments on commit 399dfb1

Please sign in to comment.