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

Commit cea62bb7 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Move ActivityLaunchAnimator in its own lib. (1/n)

Bug: 184121838
Test: Manual
Change-Id: Ib979fed2f59d9dbf5f0696edb5fcb4956600e6e0
parent a7e6b948
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ android_library {
    ],
    static_libs: [
        "WindowManager-Shell",
        "SystemUIAnimationLib",
        "SystemUIPluginLib",
        "SystemUISharedLib",
        "SystemUI-statsd",
@@ -139,6 +140,7 @@ android_library {
        "src/**/I*.aidl",
    ],
    static_libs: [
        "SystemUIAnimationLib",
        "SystemUIPluginLib",
        "SystemUISharedLib",
        "SystemUI-statsd",
+38 −0
Original line number Diff line number Diff line
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_packages_SystemUI_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
}

java_library {

    name: "SystemUIAnimationLib",

    srcs: [
        "src/**/*.java",
        "src/**/*.kt",
    ],

    static_libs: [
        "PluginCoreLib",
        "SystemUI-sensors",
    ],

}
+6 −13
Original line number Diff line number Diff line
package com.android.systemui.plugins.animation
package com.android.systemui.animation

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
@@ -16,7 +16,6 @@ import android.view.RemoteAnimationTarget
import android.view.SyncRtSurfaceTransactionApplier
import android.view.View
import android.view.WindowManager
import android.view.animation.LinearInterpolator
import android.view.animation.PathInterpolator
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.policy.ScreenDecorationsUtils
@@ -37,13 +36,6 @@ class ActivityLaunchAnimator {
                ANIMATION_DURATION - ANIMATION_DURATION_NAV_FADE_IN
        private const val LAUNCH_TIMEOUT = 1000L

        // TODO(b/184121838): Use android.R.interpolator.fast_out_extra_slow_in instead.
        // TODO(b/184121838): Move com.android.systemui.Interpolators in an animation library we can
        // reuse here.
        private val ANIMATION_INTERPOLATOR = PathInterpolator(0.4f, 0f, 0.2f, 1f)
        private val LINEAR_INTERPOLATOR = LinearInterpolator()
        private val ALPHA_IN_INTERPOLATOR = PathInterpolator(0.4f, 0f, 1f, 1f)
        private val ALPHA_OUT_INTERPOLATOR = PathInterpolator(0f, 0f, 0.8f, 1f)
        private val NAV_FADE_IN_INTERPOLATOR = PathInterpolator(0f, 0f, 0f, 1f)
        private val NAV_FADE_OUT_INTERPOLATOR = PathInterpolator(0.2f, 0f, 1f, 1f)

@@ -349,7 +341,7 @@ class ActivityLaunchAnimator {
            val animator = ValueAnimator.ofFloat(0f, 1f)
            this.animator = animator
            animator.duration = ANIMATION_DURATION
            animator.interpolator = LINEAR_INTERPOLATOR
            animator.interpolator = Interpolators.LINEAR

            animator.addListener(object : AnimatorListenerAdapter() {
                override fun onAnimationStart(animation: Animator?, isReverse: Boolean) {
@@ -367,8 +359,9 @@ class ActivityLaunchAnimator {
                    return@addUpdateListener
                }

                // TODO(b/184121838): Use android.R.interpolator.fast_out_extra_slow_in instead.
                val linearProgress = animation.animatedFraction
                val progress = ANIMATION_INTERPOLATOR.getInterpolation(linearProgress)
                val progress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(linearProgress)

                state.top = lerp(startTop, endTop, progress).roundToInt()
                state.bottom = lerp(startBottom, endBottom, progress).roundToInt()
@@ -382,12 +375,12 @@ class ActivityLaunchAnimator {
                val contentAlphaProgress = getProgress(linearProgress, 0,
                        ANIMATION_DURATION_FADE_OUT_CONTENT)
                state.contentAlpha =
                        1 - ALPHA_OUT_INTERPOLATOR.getInterpolation(contentAlphaProgress)
                        1 - Interpolators.ALPHA_OUT.getInterpolation(contentAlphaProgress)

                val backgroundAlphaProgress = getProgress(linearProgress,
                        ANIMATION_DURATION_FADE_OUT_CONTENT, ANIMATION_DURATION_FADE_IN_WINDOW)
                state.backgroundAlpha =
                        1 - ALPHA_IN_INTERPOLATOR.getInterpolation(backgroundAlphaProgress)
                        1 - Interpolators.ALPHA_IN.getInterpolation(backgroundAlphaProgress)

                applyStateToWindow(window, state)
                navigationBar?.let { applyStateToNavigationBar(it, state, linearProgress) }
+1 −1
Original line number Diff line number Diff line
package com.android.systemui.plugins.animation
package com.android.systemui.animation

import android.graphics.Canvas
import android.graphics.ColorFilter
+6 −9
Original line number Diff line number Diff line
@@ -11,10 +11,10 @@
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 * limitations under the License.
 */

package com.android.systemui;
package com.android.systemui.animation;

import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
@@ -24,8 +24,6 @@ import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.PathInterpolator;

import com.android.systemui.statusbar.notification.stack.HeadsUpAppearInterpolator;

/**
 * Utility class to receive interpolators from
 */
@@ -48,12 +46,11 @@ public class Interpolators {
    public static final Interpolator ACCELERATE_DECELERATE = new AccelerateDecelerateInterpolator();
    public static final Interpolator DECELERATE_QUINT = new DecelerateInterpolator(2.5f);
    public static final Interpolator CUSTOM_40_40 = new PathInterpolator(0.4f, 0f, 0.6f, 1f);
    public static final Interpolator HEADS_UP_APPEAR = new HeadsUpAppearInterpolator();
    public static final Interpolator ICON_OVERSHOT = new PathInterpolator(0.4f, 0f, 0.2f, 1.4f);
    public static final Interpolator ICON_OVERSHOT_LESS
            = new PathInterpolator(0.4f, 0f, 0.2f, 1.1f);
    public static final Interpolator PANEL_CLOSE_ACCELERATED
            = new PathInterpolator(0.3f, 0, 0.5f, 1);
    public static final Interpolator ICON_OVERSHOT_LESS = new PathInterpolator(0.4f, 0f, 0.2f,
            1.1f);
    public static final Interpolator PANEL_CLOSE_ACCELERATED = new PathInterpolator(0.3f, 0, 0.5f,
            1);
    public static final Interpolator BOUNCE = new BounceInterpolator();
    /**
     * For state transitions on the control panel that lives in GlobalActions.
Loading