use of android.view.animation.AnimationSet in project platform_frameworks_base by android.
the class WindowStateAnimator method applyFadeoutDuringKeyguardExitAnimation.
private void applyFadeoutDuringKeyguardExitAnimation() {
long startTime = mAnimation.getStartTime();
long duration = mAnimation.getDuration();
long elapsed = mLastAnimationTime - startTime;
long fadeDuration = duration - elapsed;
if (fadeDuration <= 0) {
// Never mind, this would be no visible animation, so abort the animation change.
return;
}
AnimationSet newAnimation = new AnimationSet(false);
newAnimation.setDuration(duration);
newAnimation.setStartTime(startTime);
newAnimation.addAnimation(mAnimation);
Animation fadeOut = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.app_starting_exit);
fadeOut.setDuration(fadeDuration);
fadeOut.setStartOffset(elapsed);
newAnimation.addAnimation(fadeOut);
newAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), mAnimDx, mAnimDy);
mAnimation = newAnimation;
}
use of android.view.animation.AnimationSet in project platform_frameworks_base by android.
the class PhoneWindowManager method createForceHideEnterAnimation.
@Override
public Animation createForceHideEnterAnimation(boolean onWallpaper, boolean goingToNotificationShade) {
if (goingToNotificationShade) {
return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_behind_enter_fade_in);
}
AnimationSet set = (AnimationSet) AnimationUtils.loadAnimation(mContext, onWallpaper ? R.anim.lock_screen_behind_enter_wallpaper : R.anim.lock_screen_behind_enter);
// TODO: Use XML interpolators when we have log interpolators available in XML.
final List<Animation> animations = set.getAnimations();
for (int i = animations.size() - 1; i >= 0; --i) {
animations.get(i).setInterpolator(mLogDecelerateInterpolator);
}
return set;
}
use of android.view.animation.AnimationSet in project platform_frameworks_base by android.
the class AppTransition method createThumbnailEnterExitAnimationLocked.
/**
* This animation is created when we are doing a thumbnail transition, for the activity that is
* leaving, and the activity that is entering.
*/
Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame, int transit, int taskId) {
final int appWidth = containingFrame.width();
final int appHeight = containingFrame.height();
Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
Animation a;
getDefaultNextAppTransitionStartRect(mTmpRect);
final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
switch(thumbTransitState) {
case THUMBNAIL_TRANSITION_ENTER_SCALE_UP:
{
// Entering app scales up with the thumbnail
float scaleW = thumbWidth / appWidth;
float scaleH = thumbHeight / appHeight;
a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
break;
}
case THUMBNAIL_TRANSITION_EXIT_SCALE_UP:
{
// Exiting app while the thumbnail is scaling up should fade or stay in place
if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
// Fade out while bringing up selected activity. This keeps the
// current activity from showing through a launching wallpaper
// activity.
a = new AlphaAnimation(1, 0);
} else {
// noop animation
a = new AlphaAnimation(1, 1);
}
break;
}
case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN:
{
// Entering the other app, it should just be visible while we scale the thumbnail
// down above it
a = new AlphaAnimation(1, 1);
break;
}
case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN:
{
// Exiting the current app, the app should scale down with the thumbnail
float scaleW = thumbWidth / appWidth;
float scaleH = thumbHeight / appHeight;
Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
Animation alpha = new AlphaAnimation(1, 0);
AnimationSet set = new AnimationSet(true);
set.addAnimation(scale);
set.addAnimation(alpha);
set.setZAdjustment(Animation.ZORDER_TOP);
a = set;
break;
}
default:
throw new RuntimeException("Invalid thumbnail transition state");
}
return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
use of android.view.animation.AnimationSet in project platform_frameworks_base by android.
the class AppTransition method createAspectScaledThumbnailFreeformAnimationLocked.
private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) {
final float sourceWidth = sourceFrame.width();
final float sourceHeight = sourceFrame.height();
final float destWidth = destFrame.width();
final float destHeight = destFrame.height();
final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth;
final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight;
AnimationSet set = new AnimationSet(true);
final int surfaceInsetsH = surfaceInsets == null ? 0 : surfaceInsets.left + surfaceInsets.right;
final int surfaceInsetsV = surfaceInsets == null ? 0 : surfaceInsets.top + surfaceInsets.bottom;
// We want the scaling to happen from the center of the surface. In order to achieve that,
// we need to account for surface insets that will be used to enlarge the surface.
final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2;
final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2;
final ScaleAnimation scale = enter ? new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter);
final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2;
final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2;
final int destHCenter = destFrame.left + destFrame.width() / 2;
final int destVCenter = destFrame.top + destFrame.height() / 2;
final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter;
final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter;
final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) : new TranslateAnimation(0, fromX, 0, fromY);
set.addAnimation(scale);
set.addAnimation(translation);
final IRemoteCallback callback = mAnimationFinishedCallback;
if (callback != null) {
set.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
return set;
}
use of android.view.animation.AnimationSet in project platform_frameworks_base by android.
the class AppTransition method createRelaunchAnimation.
private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) {
getDefaultNextAppTransitionStartRect(mTmpFromClipRect);
final int left = mTmpFromClipRect.left;
final int top = mTmpFromClipRect.top;
mTmpFromClipRect.offset(-left, -top);
// TODO: Isn't that strange that we ignore exact position of the containingFrame?
mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height());
AnimationSet set = new AnimationSet(true);
float fromWidth = mTmpFromClipRect.width();
float toWidth = mTmpToClipRect.width();
float fromHeight = mTmpFromClipRect.height();
// While the window might span the whole display, the actual content will be cropped to the
// system decoration frame, for example when the window is docked. We need to take into
// account the visible height when constructing the animation.
float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom;
int translateAdjustment = 0;
if (fromWidth <= toWidth && fromHeight <= toHeight) {
// The final window is larger in both dimensions than current window (e.g. we are
// maximizing), so we can simply unclip the new window and there will be no disappearing
// frame.
set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect));
} else {
// The disappearing window has one larger dimension. We need to apply scaling, so the
// first frame of the entry animation matches the old window.
set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1));
// We might not be going exactly full screen, but instead be aligned under the status
// bar using cropping. We still need to account for the cropped part, which will also
// be scaled.
translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight);
}
// We animate the translation from the old position of the removed window, to the new
// position of the added window. The latter might not be full screen, for example docked for
// docked windows.
TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left, 0, top - containingFrame.top - translateAdjustment, 0);
set.addAnimation(translate);
set.setDuration(DEFAULT_APP_TRANSITION_DURATION);
set.setZAdjustment(Animation.ZORDER_TOP);
return set;
}
Aggregations