Search in sources :

Example 61 with Animation

use of android.view.animation.Animation in project CreditCardView by Movile.

the class CreditCardFragment method showPaymentLayout.

private void showPaymentLayout() {
    Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.trans_left_out);
    anim.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            layoutData.setVisibility(View.GONE);
            btPay.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.pop_bounce_show));
            pageChanged();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    layoutData.startAnimation(anim);
    Animation anim2 = AnimationUtils.loadAnimation(getActivity(), R.anim.trans_left_in);
    layoutPayment.startAnimation(anim2);
    layoutPayment.setVisibility(View.VISIBLE);
    hideKeyboard();
}
Also used : Animation(android.view.animation.Animation)

Example 62 with Animation

use of android.view.animation.Animation in project android_frameworks_base by DirtyUnicorns.

the class AppTransition method createClipRevealAnimationLocked.

private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame, Rect displayFrame) {
    final Animation anim;
    if (enter) {
        final int appWidth = appFrame.width();
        final int appHeight = appFrame.height();
        // mTmpRect will contain an area around the launcher icon that was pressed. We will
        // clip reveal from that area in the final area of the app.
        getDefaultNextAppTransitionStartRect(mTmpRect);
        float t = 0f;
        if (appHeight > 0) {
            t = (float) mTmpRect.top / displayFrame.height();
        }
        int translationY = mClipRevealTranslationY + (int) (displayFrame.height() / 7f * t);
        int translationX = 0;
        int translationYCorrection = translationY;
        int centerX = mTmpRect.centerX();
        int centerY = mTmpRect.centerY();
        int halfWidth = mTmpRect.width() / 2;
        int halfHeight = mTmpRect.height() / 2;
        int clipStartX = centerX - halfWidth - appFrame.left;
        int clipStartY = centerY - halfHeight - appFrame.top;
        boolean cutOff = false;
        // and extending the clip rect from that edge.
        if (appFrame.top > centerY - halfHeight) {
            translationY = (centerY - halfHeight) - appFrame.top;
            translationYCorrection = 0;
            clipStartY = 0;
            cutOff = true;
        }
        if (appFrame.left > centerX - halfWidth) {
            translationX = (centerX - halfWidth) - appFrame.left;
            clipStartX = 0;
            cutOff = true;
        }
        if (appFrame.right < centerX + halfWidth) {
            translationX = (centerX + halfWidth) - appFrame.right;
            clipStartX = appWidth - mTmpRect.width();
            cutOff = true;
        }
        final long duration = calculateClipRevealTransitionDuration(cutOff, translationX, translationY, displayFrame);
        // Clip third of the from size of launch icon, expand to full width/height
        Animation clipAnimLR = new ClipRectLRAnimation(clipStartX, clipStartX + mTmpRect.width(), 0, appWidth);
        clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
        clipAnimLR.setDuration((long) (duration / 2.5f));
        TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0);
        translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR : mLinearOutSlowInInterpolator);
        translate.setDuration(duration);
        Animation clipAnimTB = new ClipRectTBAnimation(clipStartY, clipStartY + mTmpRect.height(), 0, appHeight, translationYCorrection, 0, mLinearOutSlowInInterpolator);
        clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
        clipAnimTB.setDuration(duration);
        // Quick fade-in from icon to app window
        final long alphaDuration = duration / 4;
        AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
        alpha.setDuration(alphaDuration);
        alpha.setInterpolator(mLinearOutSlowInInterpolator);
        AnimationSet set = new AnimationSet(false);
        set.addAnimation(clipAnimLR);
        set.addAnimation(clipAnimTB);
        set.addAnimation(translate);
        set.addAnimation(alpha);
        set.setZAdjustment(Animation.ZORDER_TOP);
        set.initialize(appWidth, appHeight, appWidth, appHeight);
        anim = set;
        mLastHadClipReveal = true;
        mLastClipRevealTransitionDuration = duration;
        // If the start rect was full inside the target rect (cutOff == false), we don't need
        // to store the translation, because it's only used if cutOff == true.
        mLastClipRevealMaxTranslation = cutOff ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0;
    } else {
        final long duration;
        switch(transit) {
            case TRANSIT_ACTIVITY_OPEN:
            case TRANSIT_ACTIVITY_CLOSE:
                duration = mConfigShortAnimTime;
                break;
            default:
                duration = DEFAULT_APP_TRANSITION_DURATION;
                break;
        }
        if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
            // If we are on top of the wallpaper, we need an animation that
            // correctly handles the wallpaper staying static behind all of
            // the animated elements.  To do this, will just have the existing
            // element fade out.
            anim = new AlphaAnimation(1, 0);
            anim.setDetachWallpaper(true);
        } else {
            // For normal animations, the exiting element just holds in place.
            anim = new AlphaAnimation(1, 1);
        }
        anim.setInterpolator(mDecelerateInterpolator);
        anim.setDuration(duration);
        anim.setFillAfter(true);
    }
    return anim;
}
Also used : ClipRectLRAnimation(com.android.server.wm.animation.ClipRectLRAnimation) ClipRectTBAnimation(com.android.server.wm.animation.ClipRectTBAnimation) 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) CurvedTranslateAnimation(com.android.server.wm.animation.CurvedTranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 63 with Animation

use of android.view.animation.Animation in project android_frameworks_base by DirtyUnicorns.

the class AppTransition method loadAnimation.

/**
     *
     * @param frame These are the bounds of the window when it finishes the animation. This is where
     *              the animation must usually finish in entrance animation, as the next frame will
     *              display the window at these coordinates. In case of exit animation, this is
     *              where the animation must start, as the frame before the animation is displaying
     *              the window at these bounds.
     * @param insets Knowing where the window will be positioned is not enough. Some parts of the
     *               window might be obscured, usually by the system windows (status bar and
     *               navigation bar) and we use content insets to convey that information. This
     *               usually affects the animation aspects vertically, as the system decoration is
     *               at the top and the bottom. For example when we animate from full screen to
     *               recents, we want to exclude the covered parts, because they won't match the
     *               thumbnail after the last frame is executed.
     * @param surfaceInsets In rare situation the surface is larger than the content and we need to
     *                      know about this to make the animation frames match. We currently use
     *                      this for freeform windows, which have larger surfaces to display
     *                      shadows. When we animate them from recents, we want to match the content
     *                      to the recents thumbnail and hence need to account for the surface being
     *                      bigger.
     */
Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, int uiMode, int orientation, Rect frame, Rect displayFrame, Rect insets, @Nullable Rect surfaceInsets, boolean isVoiceInteraction, boolean freeform, int taskId) {
    Animation a;
    if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN || transit == TRANSIT_TASK_OPEN || transit == TRANSIT_TASK_TO_FRONT)) {
        a = loadAnimationRes(lp, enter ? com.android.internal.R.anim.voice_activity_open_enter : com.android.internal.R.anim.voice_activity_open_exit);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation voice:" + " anim=" + a + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
    } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE || transit == TRANSIT_TASK_CLOSE || transit == TRANSIT_TASK_TO_BACK)) {
        a = loadAnimationRes(lp, enter ? com.android.internal.R.anim.voice_activity_close_enter : com.android.internal.R.anim.voice_activity_close_exit);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation voice:" + " anim=" + a + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
    } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) {
        a = createRelaunchAnimation(frame, insets);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=" + mNextAppTransition + " transit=" + appTransitionToString(transit) + " Callers=" + Debug.getCallers(3));
    } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
        a = loadAnimationRes(mNextAppTransitionPackage, enter ? mNextAppTransitionEnter : mNextAppTransitionExit);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=ANIM_CUSTOM" + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
    } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
        a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE" + " transit=" + appTransitionToString(transit) + " Callers=" + Debug.getCallers(3));
    } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) {
        a = createClipRevealAnimationLocked(transit, enter, frame, displayFrame);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL" + " transit=" + appTransitionToString(transit) + " Callers=" + Debug.getCallers(3));
    } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
        a = createScaleUpAnimationLocked(transit, enter, frame);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP" + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
    } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
        mNextAppTransitionScaleUp = (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
        a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter), frame, transit, taskId);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
            String animName = mNextAppTransitionScaleUp ? "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=" + animName + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
        }
    } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) {
        mNextAppTransitionScaleUp = (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP);
        a = createAspectScaledThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter), uiMode, orientation, transit, frame, insets, surfaceInsets, freeform, taskId);
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
            String animName = mNextAppTransitionScaleUp ? "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN";
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " nextAppTransition=" + animName + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
        }
    } else {
        int animAttr = 0;
        switch(transit) {
            case TRANSIT_ACTIVITY_OPEN:
                animAttr = enter ? WindowAnimation_activityOpenEnterAnimation : WindowAnimation_activityOpenExitAnimation;
                break;
            case TRANSIT_ACTIVITY_CLOSE:
                animAttr = enter ? WindowAnimation_activityCloseEnterAnimation : WindowAnimation_activityCloseExitAnimation;
                break;
            case TRANSIT_DOCK_TASK_FROM_RECENTS:
            case TRANSIT_TASK_OPEN:
                animAttr = enter ? WindowAnimation_taskOpenEnterAnimation : WindowAnimation_taskOpenExitAnimation;
                break;
            case TRANSIT_TASK_CLOSE:
                animAttr = enter ? WindowAnimation_taskCloseEnterAnimation : WindowAnimation_taskCloseExitAnimation;
                break;
            case TRANSIT_TASK_TO_FRONT:
                animAttr = enter ? WindowAnimation_taskToFrontEnterAnimation : WindowAnimation_taskToFrontExitAnimation;
                break;
            case TRANSIT_TASK_TO_BACK:
                animAttr = enter ? WindowAnimation_taskToBackEnterAnimation : WindowAnimation_taskToBackExitAnimation;
                break;
            case TRANSIT_WALLPAPER_OPEN:
                animAttr = enter ? WindowAnimation_wallpaperOpenEnterAnimation : WindowAnimation_wallpaperOpenExitAnimation;
                break;
            case TRANSIT_WALLPAPER_CLOSE:
                animAttr = enter ? WindowAnimation_wallpaperCloseEnterAnimation : WindowAnimation_wallpaperCloseExitAnimation;
                break;
            case TRANSIT_WALLPAPER_INTRA_OPEN:
                animAttr = enter ? WindowAnimation_wallpaperIntraOpenEnterAnimation : WindowAnimation_wallpaperIntraOpenExitAnimation;
                break;
            case TRANSIT_WALLPAPER_INTRA_CLOSE:
                animAttr = enter ? WindowAnimation_wallpaperIntraCloseEnterAnimation : WindowAnimation_wallpaperIntraCloseExitAnimation;
                break;
            case TRANSIT_TASK_OPEN_BEHIND:
                animAttr = enter ? WindowAnimation_launchTaskBehindSourceAnimation : WindowAnimation_launchTaskBehindTargetAnimation;
        }
        a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null;
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG, "applyAnimation:" + " anim=" + a + " animAttr=0x" + Integer.toHexString(animAttr) + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
    }
    return a;
}
Also used : 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)

Example 64 with Animation

use of android.view.animation.Animation in project android_frameworks_base by DirtyUnicorns.

the class AppTransition method createThumbnailScaleAnimationLocked.

/**
     * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
     * when a thumbnail is specified with the pending animation override.
     */
Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, Bitmap thumbnailHeader) {
    Animation a;
    getDefaultNextAppTransitionStartRect(mTmpRect);
    final int thumbWidthI = thumbnailHeader.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = thumbnailHeader.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    if (mNextAppTransitionScaleUp) {
        // Animation for the thumbnail zooming from its initial size to the full screen
        float scaleW = appWidth / thumbWidth;
        float scaleH = appHeight / thumbHeight;
        Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
        scale.setInterpolator(mDecelerateInterpolator);
        Animation alpha = new AlphaAnimation(1, 0);
        alpha.setInterpolator(mThumbnailFadeOutInterpolator);
        // This AnimationSet uses the Interpolators assigned above.
        AnimationSet set = new AnimationSet(false);
        set.addAnimation(scale);
        set.addAnimation(alpha);
        a = set;
    } else {
        // Animation for the thumbnail zooming down from the full screen to its final size
        float scaleW = appWidth / thumbWidth;
        float scaleH = appHeight / thumbHeight;
        a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
    }
    return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
Also used : 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)

Example 65 with Animation

use of android.view.animation.Animation in project android_frameworks_base by DirtyUnicorns.

the class WindowAnimator method updateWindowsLocked.

private void updateWindowsLocked(final int displayId) {
    ++mAnimTransactionSequence;
    final WindowList windows = mService.getWindowListLocked(displayId);
    final boolean keyguardGoingAwayToShade = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0;
    final boolean keyguardGoingAwayNoAnimation = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0;
    final boolean keyguardGoingAwayWithWallpaper = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0;
    if (mKeyguardGoingAway) {
        for (int i = windows.size() - 1; i >= 0; i--) {
            WindowState win = windows.get(i);
            if (!mPolicy.isKeyguardHostWindow(win.mAttrs)) {
                continue;
            }
            final WindowStateAnimator winAnimator = win.mWinAnimator;
            if ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
                if (!winAnimator.mAnimating) {
                    if (DEBUG_KEYGUARD)
                        Slog.d(TAG, "updateWindowsLocked: creating delay animation");
                    // Create a new animation to delay until keyguard is gone on its own.
                    winAnimator.mAnimation = new AlphaAnimation(1.0f, 1.0f);
                    winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
                    winAnimator.mAnimationIsEntrance = false;
                    winAnimator.mAnimationStartTime = -1;
                    winAnimator.mKeyguardGoingAwayAnimation = true;
                    winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
                }
            } else {
                if (DEBUG_KEYGUARD)
                    Slog.d(TAG, "updateWindowsLocked: StatusBar is no longer keyguard");
                mKeyguardGoingAway = false;
                winAnimator.clearAnimation();
            }
            break;
        }
    }
    mForceHiding = KEYGUARD_NOT_SHOWN;
    boolean wallpaperInUnForceHiding = false;
    boolean startingInUnForceHiding = false;
    ArrayList<WindowStateAnimator> unForceHiding = null;
    WindowState wallpaper = null;
    final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
    for (int i = windows.size() - 1; i >= 0; i--) {
        WindowState win = windows.get(i);
        WindowStateAnimator winAnimator = win.mWinAnimator;
        final int flags = win.mAttrs.flags;
        boolean canBeForceHidden = mPolicy.canBeForceHidden(win, win.mAttrs);
        boolean shouldBeForceHidden = shouldForceHide(win);
        if (winAnimator.hasSurface()) {
            final boolean wasAnimating = winAnimator.mWasAnimating;
            final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
            winAnimator.mWasAnimating = nowAnimating;
            orAnimating(nowAnimating);
            if (DEBUG_WALLPAPER) {
                Slog.v(TAG, win + ": wasAnimating=" + wasAnimating + ", nowAnimating=" + nowAnimating);
            }
            if (wasAnimating && !winAnimator.mAnimating && wallpaperController.isWallpaperTarget(win)) {
                mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
                setPendingLayoutChanges(Display.DEFAULT_DISPLAY, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                if (DEBUG_LAYOUT_REPEATS) {
                    mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2", getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
                }
            }
            if (mPolicy.isForceHiding(win.mAttrs)) {
                if (!wasAnimating && nowAnimating) {
                    if (DEBUG_KEYGUARD || DEBUG_ANIM || DEBUG_VISIBILITY)
                        Slog.v(TAG, "Animation started that could impact force hide: " + win);
                    mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED;
                    setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                    if (DEBUG_LAYOUT_REPEATS) {
                        mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3", getPendingLayoutChanges(displayId));
                    }
                    mService.mFocusMayChange = true;
                } else if (mKeyguardGoingAway && !nowAnimating) {
                    // Timeout!!
                    Slog.e(TAG, "Timeout waiting for animation to startup");
                    mPolicy.startKeyguardExitAnimation(0, 0);
                    mKeyguardGoingAway = false;
                }
                if (win.isReadyForDisplay()) {
                    if (nowAnimating && win.mWinAnimator.mKeyguardGoingAwayAnimation) {
                        mForceHiding = KEYGUARD_ANIMATING_OUT;
                    } else {
                        mForceHiding = win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
                    }
                }
                if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
                    Slog.v(TAG, "Force hide " + forceHidingToString() + " hasSurface=" + win.mHasSurface + " policyVis=" + win.mPolicyVisibility + " destroying=" + win.mDestroying + " attHidden=" + win.mAttachedHidden + " vis=" + win.mViewVisibility + " hidden=" + win.mRootToken.hidden + " anim=" + win.mWinAnimator.mAnimation);
            } else if (canBeForceHidden) {
                if (shouldBeForceHidden) {
                    if (!win.hideLw(false, false)) {
                        // Was already hidden
                        continue;
                    }
                    if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
                        Slog.v(TAG, "Now policy hidden: " + win);
                } else {
                    boolean applyExistingExitAnimation = mPostKeyguardExitAnimation != null && !mPostKeyguardExitAnimation.hasEnded() && !winAnimator.mKeyguardGoingAwayAnimation && win.hasDrawnLw() && win.mAttachedWindow == null && !win.mIsImWindow && displayId == Display.DEFAULT_DISPLAY;
                    // Keyguard exit animation, skip.
                    if (!win.showLw(false, false) && !applyExistingExitAnimation) {
                        continue;
                    }
                    final boolean visibleNow = win.isVisibleNow();
                    if (!visibleNow) {
                        // Couldn't really show, must showLw() again when win becomes visible.
                        win.hideLw(false, false);
                        continue;
                    }
                    if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
                        Slog.v(TAG, "Now policy shown: " + win);
                    if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.mAttachedWindow == null) {
                        if (unForceHiding == null) {
                            unForceHiding = new ArrayList<>();
                        }
                        unForceHiding.add(winAnimator);
                        if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                            wallpaperInUnForceHiding = true;
                        }
                        if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
                            startingInUnForceHiding = true;
                        }
                    } else if (applyExistingExitAnimation) {
                        // animation to bring in this window.
                        if (DEBUG_KEYGUARD)
                            Slog.v(TAG, "Applying existing Keyguard exit animation to new window: win=" + win);
                        Animation a = mPolicy.createForceHideEnterAnimation(false, keyguardGoingAwayToShade);
                        winAnimator.setAnimation(a, mPostKeyguardExitAnimation.getStartTime(), STACK_CLIP_BEFORE_ANIM);
                        winAnimator.mKeyguardGoingAwayAnimation = true;
                        winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
                    }
                    final WindowState currentFocus = mService.mCurrentFocus;
                    if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
                        // sure it is correct.
                        if (DEBUG_FOCUS_LIGHT)
                            Slog.v(TAG, "updateWindowsLocked: setting mFocusMayChange true");
                        mService.mFocusMayChange = true;
                    }
                }
                if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                    mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
                    setPendingLayoutChanges(Display.DEFAULT_DISPLAY, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                    if (DEBUG_LAYOUT_REPEATS) {
                        mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4", getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
                    }
                }
            }
        } else // policy visibility.
        if (canBeForceHidden) {
            if (shouldBeForceHidden) {
                win.hideLw(false, false);
            } else {
                win.showLw(false, false);
            }
        }
        final AppWindowToken atoken = win.mAppToken;
        if (winAnimator.mDrawState == READY_TO_SHOW) {
            if (atoken == null || atoken.allDrawn) {
                if (winAnimator.performShowLocked()) {
                    setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
                    if (DEBUG_LAYOUT_REPEATS) {
                        mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5", getPendingLayoutChanges(displayId));
                    }
                }
            }
        }
        final AppWindowAnimator appAnimator = winAnimator.mAppAnimator;
        if (appAnimator != null && appAnimator.thumbnail != null) {
            if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) {
                appAnimator.thumbnailTransactionSeq = mAnimTransactionSequence;
                appAnimator.thumbnailLayer = 0;
            }
            if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) {
                appAnimator.thumbnailLayer = winAnimator.mAnimLayer;
            }
        }
        if (win.mIsWallpaper) {
            wallpaper = win;
        }
    }
    // disabled.
    if (unForceHiding != null) {
        if (!keyguardGoingAwayNoAnimation) {
            boolean first = true;
            for (int i = unForceHiding.size() - 1; i >= 0; i--) {
                final WindowStateAnimator winAnimator = unForceHiding.get(i);
                Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding, keyguardGoingAwayToShade);
                if (a != null) {
                    if (DEBUG_KEYGUARD)
                        Slog.v(TAG, "Starting keyguard exit animation on window " + winAnimator.mWin);
                    winAnimator.setAnimation(a, STACK_CLIP_BEFORE_ANIM);
                    winAnimator.mKeyguardGoingAwayAnimation = true;
                    winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
                    if (first) {
                        mPostKeyguardExitAnimation = a;
                        mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
                        first = false;
                    }
                }
            }
        } else if (mKeyguardGoingAway) {
            mPolicy.startKeyguardExitAnimation(mCurrentTime, 0);
            mKeyguardGoingAway = false;
        }
        // Wallpaper is going away in un-force-hide motion, animate it as well.
        if (!wallpaperInUnForceHiding && wallpaper != null && !keyguardGoingAwayNoAnimation) {
            if (DEBUG_KEYGUARD)
                Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
            Animation a = mPolicy.createForceHideWallpaperExitAnimation(keyguardGoingAwayToShade);
            if (a != null) {
                wallpaper.mWinAnimator.setAnimation(a);
            }
        }
    }
    if (mPostKeyguardExitAnimation != null) {
        // We're in the midst of a keyguard exit animation.
        if (mKeyguardGoingAway) {
            mPolicy.startKeyguardExitAnimation(mCurrentTime + mPostKeyguardExitAnimation.getStartOffset(), mPostKeyguardExitAnimation.getDuration());
            mKeyguardGoingAway = false;
        } else // ended normally and cancelled case, and check the time for the "orphaned" case.
        if (mPostKeyguardExitAnimation.hasEnded() || mCurrentTime - mPostKeyguardExitAnimation.getStartTime() > mPostKeyguardExitAnimation.getDuration()) {
            // Done with the animation, reset.
            if (DEBUG_KEYGUARD)
                Slog.v(TAG, "Done with Keyguard exit animations.");
            mPostKeyguardExitAnimation = null;
        }
    }
    final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw();
    if (winShowWhenLocked != null) {
        mLastShowWinWhenLocked = winShowWhenLocked;
    }
}
Also used : ArrayList(java.util.ArrayList) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AlphaAnimation(android.view.animation.AlphaAnimation)

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