Search in sources :

Example 86 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class GlobalScreenshot method createScreenshotDropOutAnimation.

private ValueAnimator createScreenshotDropOutAnimation(int w, int h, boolean statusBarVisible, boolean navBarVisible) {
    ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
    anim.setStartDelay(SCREENSHOT_DROP_OUT_DELAY);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mBackgroundView.setVisibility(View.GONE);
            mScreenshotView.setVisibility(View.GONE);
            mScreenshotView.setLayerType(View.LAYER_TYPE_NONE, null);
        }
    });
    if (!statusBarVisible || !navBarVisible) {
        // There is no status bar/nav bar, so just fade the screenshot away in place
        anim.setDuration(SCREENSHOT_FAST_DROP_OUT_DURATION);
        anim.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float t = (Float) animation.getAnimatedValue();
                float scaleT = (SCREENSHOT_DROP_IN_MIN_SCALE + mBgPaddingScale) - t * (SCREENSHOT_DROP_IN_MIN_SCALE - SCREENSHOT_FAST_DROP_OUT_MIN_SCALE);
                mBackgroundView.setAlpha((1f - t) * BACKGROUND_ALPHA);
                mScreenshotView.setAlpha(1f - t);
                mScreenshotView.setScaleX(scaleT);
                mScreenshotView.setScaleY(scaleT);
            }
        });
    } else {
        // In the case where there is a status bar, animate to the origin of the bar (top-left)
        final float scaleDurationPct = (float) SCREENSHOT_DROP_OUT_SCALE_DURATION / SCREENSHOT_DROP_OUT_DURATION;
        final Interpolator scaleInterpolator = new Interpolator() {

            @Override
            public float getInterpolation(float x) {
                if (x < scaleDurationPct) {
                    // Decelerate, and scale the input accordingly
                    return (float) (1f - Math.pow(1f - (x / scaleDurationPct), 2f));
                }
                return 1f;
            }
        };
        // Determine the bounds of how to scale
        float halfScreenWidth = (w - 2f * mBgPadding) / 2f;
        float halfScreenHeight = (h - 2f * mBgPadding) / 2f;
        final float offsetPct = SCREENSHOT_DROP_OUT_MIN_SCALE_OFFSET;
        final PointF finalPos = new PointF(-halfScreenWidth + (SCREENSHOT_DROP_OUT_MIN_SCALE + offsetPct) * halfScreenWidth, -halfScreenHeight + (SCREENSHOT_DROP_OUT_MIN_SCALE + offsetPct) * halfScreenHeight);
        // Animate the screenshot to the status bar
        anim.setDuration(SCREENSHOT_DROP_OUT_DURATION);
        anim.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float t = (Float) animation.getAnimatedValue();
                float scaleT = (SCREENSHOT_DROP_IN_MIN_SCALE + mBgPaddingScale) - scaleInterpolator.getInterpolation(t) * (SCREENSHOT_DROP_IN_MIN_SCALE - SCREENSHOT_DROP_OUT_MIN_SCALE);
                mBackgroundView.setAlpha((1f - t) * BACKGROUND_ALPHA);
                mScreenshotView.setAlpha(1f - scaleInterpolator.getInterpolation(t));
                mScreenshotView.setScaleX(scaleT);
                mScreenshotView.setScaleY(scaleT);
                mScreenshotView.setTranslationX(t * finalPos.x);
                mScreenshotView.setTranslationY(t * finalPos.y);
            }
        });
    }
    return anim;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PointF(android.graphics.PointF) Interpolator(android.view.animation.Interpolator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 87 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class GlobalScreenshot method startAnimation.

/**
     * Starts the animation after taking the screenshot
     */
private void startAnimation(final Runnable finisher, int w, int h, boolean statusBarVisible, boolean navBarVisible) {
    // Add the view for the animation
    mScreenshotView.setImageBitmap(mScreenBitmap);
    mScreenshotLayout.requestFocus();
    // Setup the animation with the screenshot just taken
    if (mScreenshotAnimation != null) {
        if (mScreenshotAnimation.isStarted()) {
            mScreenshotAnimation.end();
        }
        mScreenshotAnimation.removeAllListeners();
    }
    mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams);
    ValueAnimator screenshotDropInAnim = createScreenshotDropInAnimation();
    ValueAnimator screenshotFadeOutAnim = createScreenshotDropOutAnimation(w, h, statusBarVisible, navBarVisible);
    mScreenshotAnimation = new AnimatorSet();
    mScreenshotAnimation.playSequentially(screenshotDropInAnim, screenshotFadeOutAnim);
    mScreenshotAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            // Save the screenshot once we have a bit of time now
            saveScreenshotInWorkerThread(finisher);
            mWindowManager.removeView(mScreenshotLayout);
            // Clear any references to the bitmap
            mScreenBitmap = null;
            mScreenshotView.setImageBitmap(null);
        }
    });
    mScreenshotLayout.post(new Runnable() {

        @Override
        public void run() {
            if (mCameraSound != null) {
                // Play the shutter sound to notify that we've taken a screenshot
                mCameraSound.play(MediaActionSound.SHUTTER_CLICK);
            }
            mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            mScreenshotView.buildLayer();
            mScreenshotAnimation.start();
        }
    });
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator)

Example 88 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class DozeScrimController method startScrimAnimation.

private void startScrimAnimation(final boolean inFront, float target, long duration, Interpolator interpolator, final Runnable endRunnable) {
    Animator current = getCurrentAnimator(inFront);
    if (current != null) {
        float currentTarget = getCurrentTarget(inFront);
        if (currentTarget == target) {
            return;
        }
        current.cancel();
    }
    ValueAnimator anim = ValueAnimator.ofFloat(getDozeAlpha(inFront), target);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            setDozeAlpha(inFront, value);
        }
    });
    anim.setInterpolator(interpolator);
    anim.setDuration(duration);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            setCurrentAnimator(inFront, null);
            if (endRunnable != null) {
                endRunnable.run();
            }
        }
    });
    anim.start();
    setCurrentAnimator(inFront, anim);
    setCurrentTarget(inFront, target);
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 89 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class KeyguardAffordanceHelper method getAnimatorToRadius.

private ValueAnimator getAnimatorToRadius(final boolean right, int radius) {
    final KeyguardAffordanceView targetView = right ? mRightIcon : mLeftIcon;
    ValueAnimator animator = ValueAnimator.ofFloat(targetView.getCircleRadius(), radius);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float newRadius = (float) animation.getAnimatedValue();
            targetView.setCircleRadiusWithoutAnimation(newRadius);
            float translation = getTranslationFromRadius(newRadius);
            mTranslation = right ? -translation : translation;
            updateIconsFromTranslation(targetView);
        }
    });
    return animator;
}
Also used : KeyguardAffordanceView(com.android.systemui.statusbar.KeyguardAffordanceView) ValueAnimator(android.animation.ValueAnimator)

Example 90 with ValueAnimator

use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.

the class KeyguardAffordanceHelper method startHintAnimationPhase1.

private void startHintAnimationPhase1(final boolean right, final Runnable onFinishedListener) {
    final KeyguardAffordanceView targetView = right ? mRightIcon : mLeftIcon;
    ValueAnimator animator = getAnimatorToRadius(right, mHintGrowAmount);
    animator.addListener(new AnimatorListenerAdapter() {

        private boolean mCancelled;

        @Override
        public void onAnimationCancel(Animator animation) {
            mCancelled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mCancelled) {
                mSwipeAnimator = null;
                mTargetedView = null;
                onFinishedListener.run();
            } else {
                startUnlockHintAnimationPhase2(right, onFinishedListener);
            }
        }
    });
    animator.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN);
    animator.setDuration(HINT_PHASE1_DURATION);
    animator.start();
    mSwipeAnimator = animator;
    mTargetedView = targetView;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) KeyguardAffordanceView(com.android.systemui.statusbar.KeyguardAffordanceView) ValueAnimator(android.animation.ValueAnimator)

Aggregations

ValueAnimator (android.animation.ValueAnimator)1224 Animator (android.animation.Animator)625 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)455 ObjectAnimator (android.animation.ObjectAnimator)187 ArrayList (java.util.ArrayList)128 Paint (android.graphics.Paint)124 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)111 LinearInterpolator (android.view.animation.LinearInterpolator)102 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)91 View (android.view.View)90 AnimatorSet (android.animation.AnimatorSet)87 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)74 ArgbEvaluator (android.animation.ArgbEvaluator)57 ViewGroup (android.view.ViewGroup)44 TextView (android.widget.TextView)44 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)40 PropertyValuesHolder (android.animation.PropertyValuesHolder)36 ImageView (android.widget.ImageView)34 Interpolator (android.view.animation.Interpolator)31 SuppressLint (android.annotation.SuppressLint)25