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

Commit dc5bd6f5 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Fix battery chip screenshot test instability" into main

parents 87bbd1c2 dd5c04e7
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -47,9 +47,9 @@ import androidx.annotation.VisibleForTesting;

import com.android.app.animation.Interpolators;
import com.android.systemui.DualToneHandler;
import com.android.systemui.res.R;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.BatteryController;

import java.io.PrintWriter;
@@ -87,10 +87,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
    private Drawable mUnknownStateDrawable;

    private DualToneHandler mDualToneHandler;

    private int mNonAdaptedSingleToneColor;
    private int mNonAdaptedForegroundColor;
    private int mNonAdaptedBackgroundColor;
    private boolean mIsStaticColor = false;

    private BatteryEstimateFetcher mBatteryEstimateFetcher;

@@ -447,13 +444,18 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {

    @Override
    public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
        if (mIsStaticColor) return;
        float intensity = DarkIconDispatcher.isInAreas(areas, this) ? darkIntensity : 0;
        mNonAdaptedSingleToneColor = mDualToneHandler.getSingleColor(intensity);
        mNonAdaptedForegroundColor = mDualToneHandler.getFillColor(intensity);
        mNonAdaptedBackgroundColor = mDualToneHandler.getBackgroundColor(intensity);
        int nonAdaptedSingleToneColor = mDualToneHandler.getSingleColor(intensity);
        int nonAdaptedForegroundColor = mDualToneHandler.getFillColor(intensity);
        int nonAdaptedBackgroundColor = mDualToneHandler.getBackgroundColor(intensity);

        updateColors(nonAdaptedForegroundColor, nonAdaptedBackgroundColor,
                nonAdaptedSingleToneColor);
    }

        updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor,
                mNonAdaptedSingleToneColor);
    public void setStaticColor(boolean isStaticColor) {
        mIsStaticColor = isStaticColor;
    }

    /**
+4 −7
Original line number Diff line number Diff line
@@ -22,9 +22,8 @@ import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.LinearLayout
import com.android.settingslib.Utils
import com.android.systemui.res.R
import com.android.systemui.battery.BatteryMeterView
import com.android.systemui.res.R
import com.android.systemui.statusbar.events.BackgroundAnimatableView

class BatteryStatusChip @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
@@ -39,6 +38,9 @@ class BatteryStatusChip @JvmOverloads constructor(context: Context, attrs: Attri
        inflate(context, R.layout.battery_status_chip, this)
        roundedContainer = requireViewById(R.id.rounded_container)
        batteryMeterView = requireViewById(R.id.battery_meter_view)
        batteryMeterView.setStaticColor(true)
        val primaryColor = context.resources.getColor(android.R.color.black, context.theme)
        batteryMeterView.updateColors(primaryColor, primaryColor, primaryColor)
        updateResources()
    }

@@ -63,11 +65,6 @@ class BatteryStatusChip @JvmOverloads constructor(context: Context, attrs: Attri

    @SuppressLint("UseCompatLoadingForDrawables")
    private fun updateResources() {
        val primaryColor =
            Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary)
        val textColorSecondary =
            Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorSecondary)
        batteryMeterView.updateColors(primaryColor, textColorSecondary, primaryColor)
        roundedContainer.background = mContext.getDrawable(R.drawable.statusbar_chip_bg)
    }
}