Search in sources :

Example 1 with ClipRectTBAnimation

use of com.android.server.wm.animation.ClipRectTBAnimation 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 2 with ClipRectTBAnimation

use of com.android.server.wm.animation.ClipRectTBAnimation in project android_frameworks_base by crdroidandroid.

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 3 with ClipRectTBAnimation

use of com.android.server.wm.animation.ClipRectTBAnimation in project platform_frameworks_base by android.

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 4 with ClipRectTBAnimation

use of com.android.server.wm.animation.ClipRectTBAnimation in project android_frameworks_base by ResurrectionRemix.

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)

Aggregations

AlphaAnimation (android.view.animation.AlphaAnimation)4 Animation (android.view.animation.Animation)4 AnimationSet (android.view.animation.AnimationSet)4 ClipRectAnimation (android.view.animation.ClipRectAnimation)4 ScaleAnimation (android.view.animation.ScaleAnimation)4 TranslateAnimation (android.view.animation.TranslateAnimation)4 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)4 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)4 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)4 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)4 WindowAnimation_launchTaskBehindSourceAnimation (com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation)4 WindowAnimation_launchTaskBehindTargetAnimation (com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation)4 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)4 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)4 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)4 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)4 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)4 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)4 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)4 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)4