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

Commit 0e3aab29 authored by Jason Monk's avatar Jason Monk
Browse files

Fix regression in launch settings performance

Cache a view so we aren't getting a hold of it every frame.

Test: android.platform.systemui.tests.jank
        .SystemUiJankTests#testLaunchSettings
Fixes: 70948188
Change-Id: I27c06155662b890c909b1ee74ce96844e20a3a1d
parent 588a06f5
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.IWallpaperVisibilityListener;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnLayoutChangeListener;

import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.Dependency;
@@ -41,6 +42,7 @@ public final class NavigationBarTransitions extends BarTransitions {

    private boolean mLightsOut;
    private boolean mAutoDim;
    private View mNavButtons;

    public NavigationBarTransitions(NavigationBarView view) {
        super(view, R.drawable.nav_background);
@@ -66,6 +68,18 @@ public final class NavigationBarTransitions extends BarTransitions {
                }, Display.DEFAULT_DISPLAY);
        } catch (RemoteException e) {
        }
        mView.addOnLayoutChangeListener(
                (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
                    View currentView = mView.getCurrentView();
                    if (currentView != null) {
                        mNavButtons = currentView.findViewById(R.id.nav_buttons);
                        applyLightsOut(false, true);
                    }
                });
        View currentView = mView.getCurrentView();
        if (currentView != null) {
            mNavButtons = currentView.findViewById(R.id.nav_buttons);
        }
    }

    public void init() {
@@ -105,21 +119,20 @@ public final class NavigationBarTransitions extends BarTransitions {
        if (!force && lightsOut == mLightsOut) return;

        mLightsOut = lightsOut;

        final View navButtons = mView.getCurrentView().findViewById(R.id.nav_buttons);
        if (mNavButtons == null) return;

        // ok, everyone, stop it right there
        navButtons.animate().cancel();
        mNavButtons.animate().cancel();

        // Bump percentage by 10% if dark.
        float darkBump = mLightTransitionsController.getCurrentDarkIntensity() / 10;
        final float navButtonsAlpha = lightsOut ? 0.6f + darkBump : 1f;

        if (!animate) {
            navButtons.setAlpha(navButtonsAlpha);
            mNavButtons.setAlpha(navButtonsAlpha);
        } else {
            final int duration = lightsOut ? LIGHTS_OUT_DURATION : LIGHTS_IN_DURATION;
            navButtons.animate()
            mNavButtons.animate()
                .alpha(navButtonsAlpha)
                .setDuration(duration)
                .start();