Search in sources :

Example 96 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 97 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 98 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 99 with Animation

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

the class BitmapAjaxCallback method setBmAnimate.

private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation, float ratio, float anchor, int source) {
    bm = filter(iv, bm, fallback);
    if (bm == null) {
        iv.setImageBitmap(null);
        return;
    }
    Drawable d = makeDrawable(iv, bm, ratio, anchor);
    Animation anim = null;
    if (fadeIn(animation, source)) {
        if (preset == null) {
            anim = new AlphaAnimation(0, 1);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(FADE_DUR);
        } else {
            Drawable pd = makeDrawable(iv, preset, ratio, anchor);
            Drawable[] ds = new Drawable[] { pd, d };
            TransitionDrawable td = new TransitionDrawable(ds);
            td.setCrossFadeEnabled(true);
            td.startTransition(FADE_DUR);
            d = td;
        }
    } else if (animation > 0) {
        anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
    }
    iv.setImageDrawable(d);
    if (anim != null) {
        anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
        iv.startAnimation(anim);
    } else {
        iv.setAnimation(null);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Drawable(android.graphics.drawable.Drawable) RatioDrawable(com.androidquery.util.RatioDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 100 with Animation

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

the class AppTransition method createThumbnailEnterExitAnimationLocked.

/**
     * This animation is created when we are doing a thumbnail transition, for the activity that is
     * leaving, and the activity that is entering.
     */
Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame, int transit, int taskId) {
    final int appWidth = containingFrame.width();
    final int appHeight = containingFrame.height();
    Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
    Animation a;
    getDefaultNextAppTransitionStartRect(mTmpRect);
    final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    switch(thumbTransitState) {
        case THUMBNAIL_TRANSITION_ENTER_SCALE_UP:
            {
                // Entering app scales up with the thumbnail
                float scaleW = thumbWidth / appWidth;
                float scaleH = thumbHeight / appHeight;
                a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
                break;
            }
        case THUMBNAIL_TRANSITION_EXIT_SCALE_UP:
            {
                // Exiting app while the thumbnail is scaling up should fade or stay in place
                if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
                    // Fade out while bringing up selected activity. This keeps the
                    // current activity from showing through a launching wallpaper
                    // activity.
                    a = new AlphaAnimation(1, 0);
                } else {
                    // noop animation
                    a = new AlphaAnimation(1, 1);
                }
                break;
            }
        case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN:
            {
                // Entering the other app, it should just be visible while we scale the thumbnail
                // down above it
                a = new AlphaAnimation(1, 1);
                break;
            }
        case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN:
            {
                // Exiting the current app, the app should scale down with the thumbnail
                float scaleW = thumbWidth / appWidth;
                float scaleH = thumbHeight / appHeight;
                Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
                Animation alpha = new AlphaAnimation(1, 0);
                AnimationSet set = new AnimationSet(true);
                set.addAnimation(scale);
                set.addAnimation(alpha);
                set.setZAdjustment(Animation.ZORDER_TOP);
                a = set;
                break;
            }
        default:
            throw new RuntimeException("Invalid thumbnail transition state");
    }
    return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
Also used : Bitmap(android.graphics.Bitmap) ScaleAnimation(android.view.animation.ScaleAnimation) WindowAnimation_wallpaperCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation) CurvedTranslateAnimation(com.android.server.wm.animation.CurvedTranslateAnimation) WindowAnimation_activityOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation) WindowAnimation_wallpaperOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation) WindowAnimation_taskToBackEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation) WindowAnimation_activityOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ClipRectAnimation(android.view.animation.ClipRectAnimation) WindowAnimation_wallpaperOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation) WindowAnimation_launchTaskBehindTargetAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation) WindowAnimation_launchTaskBehindSourceAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation) WindowAnimation_taskCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) WindowAnimation_wallpaperIntraCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation) WindowAnimation_taskToBackExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation) WindowAnimation_activityCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation) WindowAnimation_taskCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation) WindowAnimation_taskOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation) WindowAnimation_wallpaperIntraCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation) ClipRectTBAnimation(com.android.server.wm.animation.ClipRectTBAnimation) WindowAnimation_taskOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation) ClipRectLRAnimation(com.android.server.wm.animation.ClipRectLRAnimation) WindowAnimation_activityCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation) WindowAnimation_taskToFrontEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation) WindowAnimation_wallpaperIntraOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation) WindowAnimation_wallpaperIntraOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation) WindowAnimation_taskToFrontExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation) WindowAnimation_wallpaperCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

Animation (android.view.animation.Animation)943 AlphaAnimation (android.view.animation.AlphaAnimation)241 TranslateAnimation (android.view.animation.TranslateAnimation)190 ScaleAnimation (android.view.animation.ScaleAnimation)146 Transformation (android.view.animation.Transformation)114 View (android.view.View)104 AnimationListener (android.view.animation.Animation.AnimationListener)98 AnimationSet (android.view.animation.AnimationSet)94 RotateAnimation (android.view.animation.RotateAnimation)63 ImageView (android.widget.ImageView)48 TextView (android.widget.TextView)47 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)43 Point (android.graphics.Point)40 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