Search in sources :

Example 91 with AlphaAnimation

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

the class ZoomControls method fade.

private void fade(int visibility, float startAlpha, float endAlpha) {
    AlphaAnimation anim = new AlphaAnimation(startAlpha, endAlpha);
    anim.setDuration(500);
    startAnimation(anim);
    setVisibility(visibility);
}
Also used : AlphaAnimation(android.view.animation.AlphaAnimation)

Example 92 with AlphaAnimation

use of android.view.animation.AlphaAnimation 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 93 with AlphaAnimation

use of android.view.animation.AlphaAnimation 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 94 with AlphaAnimation

use of android.view.animation.AlphaAnimation 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)

Example 95 with AlphaAnimation

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

the class TransformsAndAnimationsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.transforms_and_animations);
    button1 = (Button) findViewById(R.id.button1);
    button2 = (Button) findViewById(R.id.button2);
    button3 = (Button) findViewById(R.id.button3);
    button1a = (Button) findViewById(R.id.button1a);
    button2a = (Button) findViewById(R.id.button2a);
    button3a = (Button) findViewById(R.id.button3a);
    button1b = (Button) findViewById(R.id.button1b);
    button2b = (Button) findViewById(R.id.button2b);
    button3b = (Button) findViewById(R.id.button3b);
    button4 = (Button) findViewById(R.id.button4);
    button5 = (Button) findViewById(R.id.button5);
    button6 = (Button) findViewById(R.id.button6);
    button7 = (Button) findViewById(R.id.button7);
    button8 = (Button) findViewById(R.id.button8);
    layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
    layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
    layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
    layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setLayerType(View.LAYER_TYPE_NONE);
                layersHardwareCB.setChecked(false);
                layersSoftwareCB.setChecked(false);
            }
        }
    });
    layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setLayerType(View.LAYER_TYPE_SOFTWARE);
                layersHardwareCB.setChecked(false);
                layersNoneCB.setChecked(false);
            }
        }
    });
    layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setLayerType(View.LAYER_TYPE_HARDWARE);
                layersNoneCB.setChecked(false);
                layersSoftwareCB.setChecked(false);
            }
        }
    });
    button1a.setAlpha(.5f);
    button2a.setAlpha(.5f);
    button3a.setAlpha(.5f);
    button3.setTranslationX(50);
    button7.setTranslationX(50);
    button8.setTranslationX(50);
    final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
    alphaAnim.setDuration(1000);
    alphaAnim.setRepeatCount(Animation.INFINITE);
    alphaAnim.setRepeatMode(Animation.REVERSE);
    final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
    transAnim.setDuration(1000);
    transAnim.setRepeatCount(Animation.INFINITE);
    transAnim.setRepeatMode(Animation.REVERSE);
    getWindow().getDecorView().postDelayed(new Runnable() {

        @Override
        public void run() {
            button1.startAnimation(alphaAnim);
            button2.startAnimation(alphaAnim);
            button3.startAnimation(alphaAnim);
            button1a.startAnimation(alphaAnim);
            button2a.startAnimation(alphaAnim);
            button3a.startAnimation(alphaAnim);
            button1b.startAnimation(alphaAnim);
            button2b.startAnimation(alphaAnim);
            button3b.startAnimation(alphaAnim);
            startAnimator(button1b);
            startAnimator(button2b);
            startAnimator(button3b);
            button7.startAnimation(transAnim);
            button8.startAnimation(transAnim);
        }
    }, 2000);
}
Also used : CheckBox(android.widget.CheckBox) TranslateAnimation(android.view.animation.TranslateAnimation) CompoundButton(android.widget.CompoundButton) AlphaAnimation(android.view.animation.AlphaAnimation)

Aggregations

AlphaAnimation (android.view.animation.AlphaAnimation)261 Animation (android.view.animation.Animation)111 TranslateAnimation (android.view.animation.TranslateAnimation)89 AnimationSet (android.view.animation.AnimationSet)78 ScaleAnimation (android.view.animation.ScaleAnimation)56 View (android.view.View)29 LinearInterpolator (android.view.animation.LinearInterpolator)26 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)26 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)26 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)26 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)26 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)26 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)26 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)26 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)26 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)26 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)26 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)26 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)26 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)26