Search in sources :

Example 21 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

the class WindowStateAnimator method setMoveAnimation.

void setMoveAnimation(int left, int top) {
    final Animation a = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.window_move_from_decor);
    setAnimation(a);
    mAnimDx = mWin.mLastFrame.left - left;
    mAnimDy = mWin.mLastFrame.top - top;
    mAnimateMove = true;
}
Also used : AppWindowAnimator.sDummyAnimation(com.android.server.wm.AppWindowAnimator.sDummyAnimation) Animation(android.view.animation.Animation)

Example 22 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

the class WindowStateAnimator method applyAnimationLocked.

/**
     * Choose the correct animation and set it to the passed WindowState.
     * @param transit If AppTransition.TRANSIT_PREVIEW_DONE and the app window has been drawn
     *      then the animation will be app_starting_exit. Any other value loads the animation from
     *      the switch statement below.
     * @param isEntrance The animation type the last time this was called. Used to keep from
     *      loading the same animation twice.
     * @return true if an animation has been loaded.
     */
boolean applyAnimationLocked(int transit, boolean isEntrance) {
    if ((mLocalAnimating && mAnimationIsEntrance == isEntrance) || mKeyguardGoingAwayAnimation) {
        // keyguard exit animation such that it also fades out.
        if (mAnimation != null && mKeyguardGoingAwayAnimation && transit == WindowManagerPolicy.TRANSIT_PREVIEW_DONE) {
            applyFadeoutDuringKeyguardExitAnimation();
        }
        return true;
    }
    // Only apply an animation if the display isn't frozen.  If it is
    // frozen, there is no reason to animate and it can cause strange
    // artifacts when we unfreeze the display if some different animation
    // is running.
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "WSA#applyAnimationLocked");
    if (mService.okToDisplay()) {
        int anim = mPolicy.selectAnimationLw(mWin, transit);
        int attr = -1;
        Animation a = null;
        if (anim != 0) {
            a = anim != -1 ? AnimationUtils.loadAnimation(mContext, anim) : null;
        } else {
            switch(transit) {
                case WindowManagerPolicy.TRANSIT_ENTER:
                    attr = com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation;
                    break;
                case WindowManagerPolicy.TRANSIT_EXIT:
                    attr = com.android.internal.R.styleable.WindowAnimation_windowExitAnimation;
                    break;
                case WindowManagerPolicy.TRANSIT_SHOW:
                    attr = com.android.internal.R.styleable.WindowAnimation_windowShowAnimation;
                    break;
                case WindowManagerPolicy.TRANSIT_HIDE:
                    attr = com.android.internal.R.styleable.WindowAnimation_windowHideAnimation;
                    break;
            }
            if (attr >= 0) {
                a = mService.mAppTransition.loadAnimationAttr(mWin.mAttrs, attr);
            }
        }
        if (DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation: win=" + this + " anim=" + anim + " attr=0x" + Integer.toHexString(attr) + " a=" + a + " transit=" + transit + " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3));
        if (a != null) {
            if (DEBUG_ANIM)
                logWithStack(TAG, "Loaded animation " + a + " for " + this);
            setAnimation(a);
            mAnimationIsEntrance = isEntrance;
        }
    } else {
        clearAnimation();
    }
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    if (mWin.mAttrs.type == TYPE_INPUT_METHOD) {
        mService.adjustForImeIfNeeded(mWin.mDisplayContent);
        if (isEntrance) {
            mWin.setDisplayLayoutNeeded();
            mService.mWindowPlacerLocked.requestTraversal();
        }
    }
    return mAnimation != null;
}
Also used : AppWindowAnimator.sDummyAnimation(com.android.server.wm.AppWindowAnimator.sDummyAnimation) Animation(android.view.animation.Animation) Point(android.graphics.Point)

Example 23 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

the class WindowManagerService method applyAnimationLocked.

private boolean applyAnimationLocked(AppWindowToken atoken, WindowManager.LayoutParams lp, int transit, boolean enter, boolean isVoiceInteraction) {
    // Only apply an animation if the display isn't frozen.  If it is
    // frozen, there is no reason to animate and it can cause strange
    // artifacts when we unfreeze the display if some different animation
    // is running.
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "WM#applyAnimationLocked");
    if (okToDisplay()) {
        DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
        final int width = displayInfo.appWidth;
        final int height = displayInfo.appHeight;
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG_WM, "applyAnimation: atoken=" + atoken);
        // Determine the visible rect to calculate the thumbnail clip
        final WindowState win = atoken.findMainWindow();
        final Rect frame = new Rect(0, 0, width, height);
        final Rect displayFrame = new Rect(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
        final Rect insets = new Rect();
        Rect surfaceInsets = null;
        final boolean freeform = win != null && win.inFreeformWorkspace();
        if (win != null) {
            // the status bar). In that case we need to use the final frame.
            if (freeform) {
                frame.set(win.mFrame);
            } else {
                frame.set(win.mContainingFrame);
            }
            surfaceInsets = win.getAttrs().surfaceInsets;
            insets.set(win.mContentInsets);
        }
        if (atoken.mLaunchTaskBehind) {
            // Differentiate the two animations. This one which is briefly on the screen
            // gets the !enter animation, and the other activity which remains on the
            // screen gets the enter animation. Both appear in the mOpeningApps set.
            enter = false;
        }
        if (DEBUG_APP_TRANSITIONS)
            Slog.d(TAG_WM, "Loading animation for app transition." + " transit=" + AppTransition.appTransitionToString(transit) + " enter=" + enter + " frame=" + frame + " insets=" + insets + " surfaceInsets=" + surfaceInsets);
        Animation a = mAppTransition.loadAnimation(lp, transit, enter, mCurConfiguration.uiMode, mCurConfiguration.orientation, frame, displayFrame, insets, surfaceInsets, isVoiceInteraction, freeform, atoken.mTask.mTaskId);
        if (a != null) {
            if (DEBUG_ANIM)
                logWithStack(TAG, "Loaded animation " + a + " for " + atoken);
            final int containingWidth = frame.width();
            final int containingHeight = frame.height();
            atoken.mAppAnimator.setAnimation(a, containingWidth, containingHeight, mAppTransition.canSkipFirstFrame(), mAppTransition.getAppStackClipMode());
        }
    } else {
        atoken.mAppAnimator.clearAnimation();
    }
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    return atoken.mAppAnimator.animation != null;
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) Animation(android.view.animation.Animation) Point(android.graphics.Point)

Example 24 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

the class WindowStateAnimator method applyFadeoutDuringKeyguardExitAnimation.

private void applyFadeoutDuringKeyguardExitAnimation() {
    long startTime = mAnimation.getStartTime();
    long duration = mAnimation.getDuration();
    long elapsed = mLastAnimationTime - startTime;
    long fadeDuration = duration - elapsed;
    if (fadeDuration <= 0) {
        // Never mind, this would be no visible animation, so abort the animation change.
        return;
    }
    AnimationSet newAnimation = new AnimationSet(false);
    newAnimation.setDuration(duration);
    newAnimation.setStartTime(startTime);
    newAnimation.addAnimation(mAnimation);
    Animation fadeOut = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.app_starting_exit);
    fadeOut.setDuration(fadeDuration);
    fadeOut.setStartOffset(elapsed);
    newAnimation.addAnimation(fadeOut);
    newAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), mAnimDx, mAnimDy);
    mAnimation = newAnimation;
}
Also used : AppWindowAnimator.sDummyAnimation(com.android.server.wm.AppWindowAnimator.sDummyAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet)

Example 25 with Animation

use of android.view.animation.Animation in project Android-MaterialRefreshLayout by android-cjj.

the class MaterialProgressDrawable method setupAnimators.

private void setupAnimators() {
    final Ring ring = mRing;
    final Animation animation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            if (mFinishing) {
                applyFinishTranslation(interpolatedTime, ring);
            } else {
                // The minProgressArc is calculated from 0 to create an
                // angle that
                // matches the stroke width.
                final float minProgressArc = (float) Math.toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius()));
                final float startingEndTrim = ring.getStartingEndTrim();
                final float startingTrim = ring.getStartingStartTrim();
                final float startingRotation = ring.getStartingRotation();
                // Offset the minProgressArc to where the endTrim is
                // located.
                final float minArc = MAX_PROGRESS_ARC - minProgressArc;
                float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
                float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
                final float sweepTrim = endTrim - startTrim;
                //Avoid the ring to be a full circle
                if (Math.abs(sweepTrim) >= 1) {
                    endTrim = startTrim + 0.5f;
                }
                ring.setEndTrim(endTrim);
                ring.setStartTrim(startTrim);
                final float rotation = startingRotation + (0.25f * interpolatedTime);
                ring.setRotation(rotation);
                float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS));
                setRotation(groupRotation);
            }
        }
    };
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(LINEAR_INTERPOLATOR);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            mRotationCount = 0;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // do nothing
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            ring.storeOriginals();
            ring.goToNextColor();
            ring.setStartTrim(ring.getEndTrim());
            if (mFinishing) {
                // finished closing the last ring from the swipe gesture; go
                // into progress mode
                mFinishing = false;
                animation.setDuration(ANIMATION_DURATION);
                ring.setShowArrow(false);
            } else {
                mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
            }
        }
    });
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Aggregations

Animation (android.view.animation.Animation)620 AlphaAnimation (android.view.animation.AlphaAnimation)164 TranslateAnimation (android.view.animation.TranslateAnimation)125 ScaleAnimation (android.view.animation.ScaleAnimation)99 AnimationListener (android.view.animation.Animation.AnimationListener)80 AnimationSet (android.view.animation.AnimationSet)71 View (android.view.View)68 Transformation (android.view.animation.Transformation)62 RotateAnimation (android.view.animation.RotateAnimation)43 Point (android.graphics.Point)35 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)35 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)35 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)35 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)35 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)35 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)35 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)35 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)35 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)35 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)35