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

Commit 5dee4a12 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fix issue with slow status bar tint transition"

parents b93bfa1d e89f4b5b
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ import javax.inject.Singleton;
/**
 */
@Singleton
public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher {
public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher,
        LightBarTransitionsController.DarkIntensityApplier {

    private final LightBarTransitionsController mTransitionsController;
    private final Rect mTintArea = new Rect();
@@ -54,8 +55,7 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher {
        mDarkModeIconColorSingleTone = context.getColor(R.color.dark_mode_icon_color_single_tone);
        mLightModeIconColorSingleTone = context.getColor(R.color.light_mode_icon_color_single_tone);

        mTransitionsController = new LightBarTransitionsController(context,
                this::setIconTintInternal);
        mTransitionsController = new LightBarTransitionsController(context, this);
    }

    public LightBarTransitionsController getTransitionsController() {
@@ -104,13 +104,19 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher {
        applyIconTint();
    }

    private void setIconTintInternal(float darkIntensity) {
    @Override
    public void applyDarkIntensity(float darkIntensity) {
        mDarkIntensity = darkIntensity;
        mIconTint = (int) ArgbEvaluator.getInstance().evaluate(darkIntensity,
                mLightModeIconColorSingleTone, mDarkModeIconColorSingleTone);
        applyIconTint();
    }

    @Override
    public int getTintAnimationDuration() {
        return LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION;
    }

    private void applyIconTint() {
        for (int i = 0; i < mReceivers.size(); i++) {
            mReceivers.valueAt(i).onDarkChanged(mTintArea, mDarkIntensity, mIconTint);
+4 −13
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package com.android.systemui.statusbar.phone;

import static com.android.systemui.statusbar.phone.NavBarTintController.DEFAULT_COLOR_ADAPT_TRANSITION_TIME;
import static com.android.systemui.statusbar.phone.NavBarTintController.MIN_COLOR_ADAPT_TRANSITION_TIME;

import android.animation.ValueAnimator;
import android.content.Context;
import android.os.Bundle;
@@ -52,7 +49,6 @@ public class LightBarTransitionsController implements Dumpable, Callbacks,
    private final DarkIntensityApplier mApplier;
    private final KeyguardMonitor mKeyguardMonitor;
    private final StatusBarStateController mStatusBarStateController;
    private NavBarTintController mColorAdaptionController;

    private boolean mTransitionDeferring;
    private long mTransitionDeferringStartTime;
@@ -118,7 +114,8 @@ public class LightBarTransitionsController implements Dumpable, Callbacks,
        }
        if (mTransitionPending && mTintChangePending) {
            mTintChangePending = false;
            animateIconTint(mPendingDarkIntensity, 0 /* delay */, getTintAnimationDuration());
            animateIconTint(mPendingDarkIntensity, 0 /* delay */,
                    mApplier.getTintAnimationDuration());
        }
        mTransitionPending = false;
    }
@@ -159,15 +156,8 @@ public class LightBarTransitionsController implements Dumpable, Callbacks,
                    Math.max(0, mTransitionDeferringStartTime - SystemClock.uptimeMillis()),
                    mTransitionDeferringDuration);
        } else {
            animateIconTint(dark ? 1.0f : 0.0f, 0 /* delay */, getTintAnimationDuration());
        }
    }

    public long getTintAnimationDuration() {
        if (NavBarTintController.isEnabled(mContext)) {
            return Math.max(DEFAULT_COLOR_ADAPT_TRANSITION_TIME, MIN_COLOR_ADAPT_TRANSITION_TIME);
            animateIconTint(dark ? 1.0f : 0.0f, 0 /* delay */, mApplier.getTintAnimationDuration());
        }
        return DEFAULT_TINT_ANIMATION_DURATION;
    }

    public float getCurrentDarkIntensity() {
@@ -243,5 +233,6 @@ public class LightBarTransitionsController implements Dumpable, Callbacks,
     */
    public interface DarkIntensityApplier {
        void applyDarkIntensity(float darkIntensity);
        int getTintAnimationDuration();
    }
}
+14 −3
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.systemui.statusbar.phone;

import static com.android.systemui.statusbar.phone.NavBarTintController.DEFAULT_COLOR_ADAPT_TRANSITION_TIME;
import static com.android.systemui.statusbar.phone.NavBarTintController.MIN_COLOR_ADAPT_TRANSITION_TIME;

import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
@@ -31,7 +34,8 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.Dependency;
import com.android.systemui.R;

public final class NavigationBarTransitions extends BarTransitions {
public final class NavigationBarTransitions extends BarTransitions implements
        LightBarTransitionsController.DarkIntensityApplier {

    private final NavigationBarView mView;
    private final IStatusBarService mBarService;
@@ -59,8 +63,7 @@ public final class NavigationBarTransitions extends BarTransitions {
        mView = view;
        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mLightTransitionsController = new LightBarTransitionsController(view.getContext(),
                this::applyDarkIntensity);
        mLightTransitionsController = new LightBarTransitionsController(view.getContext(), this);
        mAllowAutoDimWallpaperNotVisible = view.getContext().getResources()
                .getBoolean(R.bool.config_navigation_bar_enable_auto_dim_no_visible_wallpaper);

@@ -170,4 +173,12 @@ public final class NavigationBarTransitions extends BarTransitions {
        }
        mView.onDarkIntensityChange(darkIntensity);
    }

    @Override
    public int getTintAnimationDuration() {
        if (NavBarTintController.isEnabled(mView.getContext())) {
            return Math.max(DEFAULT_COLOR_ADAPT_TRANSITION_TIME, MIN_COLOR_ADAPT_TRANSITION_TIME);
        }
        return LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION;
    }
}