Merge "Read battery and icon colors from theme" into sc-dev

This commit is contained in:
Lucas Dupin
2021-02-10 22:30:50 +00:00
committed by Android (Google) Code Review
3 changed files with 19 additions and 64 deletions

View File

@@ -49,7 +49,6 @@ import android.widget.TextView;
import androidx.annotation.StyleRes;
import com.android.settingslib.Utils;
import com.android.settingslib.graph.ThemedBatteryDrawable;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher;
@@ -105,11 +104,6 @@ public class BatteryMeterView extends LinearLayout implements
private DualToneHandler mDualToneHandler;
private int mUser;
/**
* Whether we should use colors that adapt based on wallpaper/the scrim behind quick settings.
*/
private boolean mUseWallpaperTextColors;
private int mNonAdaptedSingleToneColor;
private int mNonAdaptedForegroundColor;
private int mNonAdaptedBackgroundColor;
@@ -242,31 +236,6 @@ public class BatteryMeterView extends LinearLayout implements
mIsSubscribedForTunerUpdates = false;
}
/**
* Sets whether the battery meter view uses the wallpaperTextColor. If we're not using it, we'll
* revert back to dark-mode-based/tinted colors.
*
* @param shouldUseWallpaperTextColor whether we should use wallpaperTextColor for all
* components
*/
public void useWallpaperTextColor(boolean shouldUseWallpaperTextColor) {
if (shouldUseWallpaperTextColor == mUseWallpaperTextColors) {
return;
}
mUseWallpaperTextColors = shouldUseWallpaperTextColor;
if (mUseWallpaperTextColors) {
updateColors(
Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor),
Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColorSecondary),
Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor));
} else {
updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor,
mNonAdaptedSingleToneColor);
}
}
public void setColorsFromContext(Context context) {
if (context == null) {
return;
@@ -476,13 +445,19 @@ public class BatteryMeterView extends LinearLayout implements
mNonAdaptedForegroundColor = mDualToneHandler.getFillColor(intensity);
mNonAdaptedBackgroundColor = mDualToneHandler.getBackgroundColor(intensity);
if (!mUseWallpaperTextColors) {
updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor,
mNonAdaptedSingleToneColor);
}
updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor,
mNonAdaptedSingleToneColor);
}
private void updateColors(int foregroundColor, int backgroundColor, int singleToneColor) {
/**
* Sets icon and text colors. This will be overridden by {@code onDarkChanged} events,
* if registered.
*
* @param foregroundColor
* @param backgroundColor
* @param singleToneColor
*/
public void updateColors(int foregroundColor, int backgroundColor, int singleToneColor) {
mDrawable.setColors(foregroundColor, backgroundColor, singleToneColor);
mTextColor = singleToneColor;
if (mBatteryPercentView != null) {

View File

@@ -29,7 +29,6 @@ import android.media.AudioManager;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.util.Pair;
import android.view.ContextThemeWrapper;
import android.view.DisplayCutout;
import android.view.View;
import android.view.ViewGroup;
@@ -48,7 +47,6 @@ import androidx.lifecycle.LifecycleRegistry;
import com.android.settingslib.Utils;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.DualToneHandler;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.privacy.OngoingPrivacyChip;
@@ -75,7 +73,6 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
protected QuickQSPanel mHeaderQsPanel;
private TouchAnimator mStatusIconsAlphaAnimator;
private TouchAnimator mHeaderTextContainerAlphaAnimator;
private DualToneHandler mDualToneHandler;
private View mSystemIconsView;
private View mQuickQsStatusIcons;
@@ -110,8 +107,6 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
super(context, attrs);
mDualToneHandler = new DualToneHandler(
new ContextThemeWrapper(context, R.style.QSHeaderTheme));
}
@Override
@@ -149,10 +144,8 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
}
void onAttach(TintedIconManager iconManager) {
int colorForeground = Utils.getColorAttrDefaultColor(getContext(),
android.R.attr.colorForeground);
float intensity = getColorIntensity(colorForeground);
int fillColor = mDualToneHandler.getSingleColor(intensity);
int fillColor = Utils.getColorAttrDefaultColor(getContext(),
android.R.attr.textColorPrimary);
// Set the correct tint for the status icons so they contrast
iconManager.setTint(fillColor);
@@ -271,14 +264,12 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
int textColor = Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorPrimary);
if (textColor != mTextColorPrimary) {
int textColorSecondary = Utils.getColorAttrDefaultColor(mContext,
android.R.attr.textColorSecondary);
mTextColorPrimary = textColor;
mClockView.setTextColor(textColor);
float intensity = getColorIntensity(textColor);
int fillColor = mDualToneHandler.getSingleColor(intensity);
Rect tintArea = new Rect(0, 0, 0, 0);
mBatteryRemainingIcon.onDarkChanged(tintArea, intensity, fillColor);
mBatteryRemainingIcon.updateColors(mTextColorPrimary, textColorSecondary,
mTextColorPrimary);
}
updateStatusIconAlphaAnimator();

View File

@@ -28,9 +28,7 @@ import android.widget.TextView;
import com.android.settingslib.Utils;
import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.DualToneHandler;
import com.android.systemui.R;
import com.android.systemui.qs.QuickStatusBarHeader;
import java.util.Objects;
@@ -40,9 +38,6 @@ public class QSCarrier extends LinearLayout {
private TextView mCarrierText;
private ImageView mMobileSignal;
private ImageView mMobileRoaming;
private DualToneHandler mDualToneHandler;
private ColorStateList mColorForegroundStateList;
private float mColorForegroundIntensity;
private CellSignalState mLastSignalState;
public QSCarrier(Context context) {
@@ -64,7 +59,6 @@ public class QSCarrier extends LinearLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mDualToneHandler = new DualToneHandler(getContext());
mMobileGroup = findViewById(R.id.mobile_combo);
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
mMobileRoaming = findViewById(R.id.mobile_roaming_large);
@@ -74,11 +68,6 @@ public class QSCarrier extends LinearLayout {
mMobileSignal = findViewById(R.id.mobile_signal);
mCarrierText = findViewById(R.id.qs_carrier_text);
mMobileSignal.setImageDrawable(new SignalDrawable(mContext));
int colorForeground = Utils.getColorAttrDefaultColor(mContext,
android.R.attr.colorForeground);
mColorForegroundStateList = ColorStateList.valueOf(colorForeground);
mColorForegroundIntensity = QuickStatusBarHeader.getColorIntensity(colorForeground);
}
/**
@@ -92,8 +81,8 @@ public class QSCarrier extends LinearLayout {
mMobileGroup.setVisibility(state.visible ? View.VISIBLE : View.GONE);
if (state.visible) {
mMobileRoaming.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
ColorStateList colorStateList = ColorStateList.valueOf(
mDualToneHandler.getSingleColor(mColorForegroundIntensity));
ColorStateList colorStateList = Utils.getColorAttr(mContext,
android.R.attr.textColorPrimary);
mMobileRoaming.setImageTintList(colorStateList);
mMobileSignal.setImageTintList(colorStateList);
mMobileSignal.setImageLevel(state.mobileSignalIconId);