Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20e6b3d0 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Tweak duration of bars fade animation for orientation change

The default fade_out uses config_longAnimTime=500.
The default fade_in uses config_mediumAnimTime=400.
Which are too long for app switch transition.
If the app transition finishes earlier, the bar may show its
content with new orientation on old side.

Programmatic animation creation is also 10 times faster than
creating from resources.

Bug: 364551522
Flag: EXEMPT bugfix
Test: Swipe landscape pip-able app to portrait home.
Change-Id: I310d2c855e6b6c9844b120f74dbd55c370f9ba09
parent c05c4e0e
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -29,9 +29,6 @@ import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.android.internal.R;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -687,11 +684,12 @@ class AsyncRotationController extends FadeAnimationController implements Consume

    @Override
    public Animation getFadeInAnimation() {
        final Animation anim = super.getFadeInAnimation();
        if (mHasScreenRotationAnimation) {
            // Use a shorter animation so it is easier to align with screen rotation animation.
            return AnimationUtils.loadAnimation(mContext, R.anim.screen_rotate_0_enter);
            anim.setDuration(getScaledDuration(SHORT_DURATION_MS));
        }
        return super.getFadeInAnimation();
        return anim;
    }

    @Override
+18 −8
Original line number Diff line number Diff line
@@ -20,41 +20,51 @@ import static com.android.server.wm.AnimationSpecProto.WINDOW;
import static com.android.server.wm.WindowAnimationSpecProto.ANIMATION;

import android.annotation.NonNull;
import android.content.Context;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Transformation;

import com.android.internal.R;

import java.io.PrintWriter;

/**
 * An animation controller to fade-in/out for a window token.
 */
public class FadeAnimationController {
    static final int SHORT_DURATION_MS = 200;
    static final int MEDIUM_DURATION_MS = 350;

    protected final DisplayContent mDisplayContent;
    protected final Context mContext;

    public FadeAnimationController(DisplayContent displayContent) {
        mDisplayContent = displayContent;
        mContext = displayContent.mWmService.mContext;
    }

    /**
     * @return a fade-in Animation.
     */
    public Animation getFadeInAnimation() {
        return AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
        final AlphaAnimation anim = new AlphaAnimation(0f, 1f);
        anim.setDuration(getScaledDuration(MEDIUM_DURATION_MS));
        anim.setInterpolator(new DecelerateInterpolator());
        return anim;
    }

    /**
     * @return a fade-out Animation.
     */
    public Animation getFadeOutAnimation() {
        return AnimationUtils.loadAnimation(mContext, R.anim.fade_out);
        final AlphaAnimation anim = new AlphaAnimation(1f, 0f);
        anim.setDuration(getScaledDuration(SHORT_DURATION_MS));
        anim.setInterpolator(new AccelerateInterpolator());
        return anim;
    }

    long getScaledDuration(int durationMs) {
        return (long) (durationMs * mDisplayContent.mWmService.getWindowAnimationScaleLocked());
    }

    /** Run the fade in/out animation for a window token. */