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

Commit 0c0cf888 authored by Pablo Gamito's avatar Pablo Gamito Committed by Automerger Merge Worker
Browse files

Merge "Add API to specify background color for animations" into sc-qpr1-dev...

Merge "Add API to specify background color for animations" into sc-qpr1-dev am: 14886c50 am: bf8ed2a8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15836428

Change-Id: Ibe17e91bf2c847398db50f17248586fdc71ee9a7
parents bd7c8a4f bf8ed2a8
Loading
Loading
Loading
Loading
+14 −7
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view.animation;
import android.annotation.AnimRes;
import android.annotation.AnimRes;
import android.annotation.ColorInt;
import android.annotation.ColorInt;
import android.annotation.InterpolatorRes;
import android.annotation.InterpolatorRes;
import android.app.ActivityThread;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
@@ -258,8 +259,6 @@ public abstract class Animation implements Cloneable {


        setZAdjustment(a.getInt(com.android.internal.R.styleable.Animation_zAdjustment, ZORDER_NORMAL));
        setZAdjustment(a.getInt(com.android.internal.R.styleable.Animation_zAdjustment, ZORDER_NORMAL));


        setBackgroundColor(a.getInt(com.android.internal.R.styleable.Animation_background, 0));

        setDetachWallpaper(
        setDetachWallpaper(
                a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false));
                a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false));
        setShowWallpaper(
        setShowWallpaper(
@@ -271,6 +270,15 @@ public abstract class Animation implements Cloneable {


        a.recycle();
        a.recycle();


        Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
        TypedArray uiStyledAttrs = uiContext
                .obtainStyledAttributes(attrs, com.android.internal.R.styleable.Animation);

        setBackgroundColor(
                uiStyledAttrs.getColor(com.android.internal.R.styleable.Animation_background, 0));

        uiStyledAttrs.recycle();

        if (resID > 0) {
        if (resID > 0) {
            setInterpolator(context, resID);
            setInterpolator(context, resID);
        }
        }
@@ -632,16 +640,15 @@ public abstract class Animation implements Cloneable {
    }
    }


    /**
    /**
     * Set background behind animation.
     * Set background behind an animation.
     *
     *
     * @param bg The background color.  If 0, no background.  Currently must
     * @param bg The background color. If 0, no background.
     * be black, with any desired alpha level.
     *
     *
     * @deprecated None of window animations are running with background color.
     * @deprecated None of window animations are running with background color.
     */
     */
    @Deprecated
    @Deprecated
    public void setBackgroundColor(@ColorInt int bg) {
    public void setBackgroundColor(@ColorInt int bg) {
        // The background color is not needed any more, do nothing.
        mBackgroundColor = bg;
    }
    }


    /**
    /**
@@ -803,7 +810,7 @@ public abstract class Animation implements Cloneable {
    @Deprecated
    @Deprecated
    @ColorInt
    @ColorInt
    public int getBackgroundColor() {
    public int getBackgroundColor() {
        return 0;
        return mBackgroundColor;
    }
    }


    /**
    /**
+3 −4
Original line number Original line Diff line number Diff line
@@ -6822,9 +6822,8 @@
                 content for the duration of the animation. -->
                 content for the duration of the animation. -->
            <enum name="bottom" value="-1" />
            <enum name="bottom" value="-1" />
        </attr>
        </attr>
        <!-- Special background behind animation.  Only for use with window
        <!-- Special background behind animation. Only for use with task animations.
             animations.  Can only be a color, and only black.  If 0, the
             If 0, the default, there is no background. -->
             default, there is no background. -->
        <attr name="background" />
        <attr name="background" />
        <!-- Special option for window animations: if this window is on top
        <!-- Special option for window animations: if this window is on top
             of a wallpaper, don't animate the wallpaper with it. -->
             of a wallpaper, don't animate the wallpaper with it. -->
+11 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.server.wm;
package com.android.server.wm;


import android.annotation.ColorInt;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.SurfaceControl.Transaction;
@@ -106,4 +107,14 @@ interface AnimationAdapter {
    default boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) {
    default boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) {
        return false;
        return false;
    }
    }

    /**
     * Gets the background color to show behind an animation.
     *
     * @return The background color to show behind an animation (0 for no background color).
     */
    @ColorInt
    default int getBackgroundColor() {
        return 0;
    }
}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static com.android.server.wm.AnimationAdapterProto.LOCAL;
import static com.android.server.wm.AnimationAdapterProto.LOCAL;
import static com.android.server.wm.LocalAnimationAdapterProto.ANIMATION_SPEC;
import static com.android.server.wm.LocalAnimationAdapterProto.ANIMATION_SPEC;


import android.annotation.ColorInt;
import android.os.SystemClock;
import android.os.SystemClock;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
@@ -71,6 +72,12 @@ class LocalAnimationAdapter implements AnimationAdapter {
        return mSpec.calculateStatusBarTransitionStartTime();
        return mSpec.calculateStatusBarTransitionStartTime();
    }
    }


    @Override
    @ColorInt
    public int getBackgroundColor() {
        return mSpec.getBackgroundColor();
    }

    @Override
    @Override
    public void dump(PrintWriter pw, String prefix) {
    public void dump(PrintWriter pw, String prefix) {
        mSpec.dump(pw, prefix);
        mSpec.dump(pw, prefix);
@@ -149,5 +156,9 @@ class LocalAnimationAdapter implements AnimationAdapter {
        }
        }


        void dumpDebugInner(ProtoOutputStream proto);
        void dumpDebugInner(ProtoOutputStream proto);

        default int getBackgroundColor() {
            return 0;
        }
    }
    }
}
}
+7 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.server.wm.AnimationSpecProto.WINDOW;
import static com.android.server.wm.WindowAnimationSpecProto.ANIMATION;
import static com.android.server.wm.WindowAnimationSpecProto.ANIMATION;
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_NONE;
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_NONE;


import android.annotation.ColorInt;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.SystemClock;
import android.os.SystemClock;
@@ -84,6 +85,12 @@ public class WindowAnimationSpec implements AnimationSpec {
        return mAnimation.computeDurationHint();
        return mAnimation.computeDurationHint();
    }
    }


    @Override
    @ColorInt
    public int getBackgroundColor() {
        return mAnimation.getBackgroundColor();
    }

    @Override
    @Override
    public void apply(Transaction t, SurfaceControl leash, long currentPlayTime) {
    public void apply(Transaction t, SurfaceControl leash, long currentPlayTime) {
        final TmpValues tmp = mThreadLocalTmps.get();
        final TmpValues tmp = mThreadLocalTmps.get();