Merge "Set the default background color to ACTIVE" into sc-dev

This commit is contained in:
Fabian Kozynski
2021-05-07 14:11:32 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 6 deletions

View File

@@ -148,9 +148,11 @@ public interface QSTile {
@ProvidesInterface(version = State.VERSION) @ProvidesInterface(version = State.VERSION)
public static class State { public static class State {
public static final int VERSION = 1; public static final int VERSION = 1;
public static final int DEFAULT_STATE = Tile.STATE_ACTIVE;
public Icon icon; public Icon icon;
public Supplier<Icon> iconSupplier; public Supplier<Icon> iconSupplier;
public int state = Tile.STATE_ACTIVE; public int state = DEFAULT_STATE;
public CharSequence label; public CharSequence label;
public CharSequence secondaryLabel; public CharSequence secondaryLabel;
public CharSequence contentDescription; public CharSequence contentDescription;

View File

@@ -21,7 +21,6 @@ import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.Configuration import android.content.res.Configuration
import android.content.res.Resources.ID_NULL import android.content.res.Resources.ID_NULL
import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.RippleDrawable import android.graphics.drawable.RippleDrawable
import android.service.quicksettings.Tile import android.service.quicksettings.Tile
@@ -83,7 +82,7 @@ open class QSTileViewImpl @JvmOverloads constructor(
private lateinit var ripple: RippleDrawable private lateinit var ripple: RippleDrawable
private lateinit var colorBackgroundDrawable: Drawable private lateinit var colorBackgroundDrawable: Drawable
private var paintColor = Color.WHITE private var paintColor: Int = 0
private var paintAnimator: ValueAnimator? = null private var paintAnimator: ValueAnimator? = null
private var labelAnimator: ValueAnimator? = null private var labelAnimator: ValueAnimator? = null
private var secondaryLabelAnimator: ValueAnimator? = null private var secondaryLabelAnimator: ValueAnimator? = null
@@ -105,6 +104,8 @@ open class QSTileViewImpl @JvmOverloads constructor(
clipToPadding = false clipToPadding = false
isFocusable = true isFocusable = true
background = createTileBackground() background = createTileBackground()
paintColor = getCircleColor(QSTile.State.DEFAULT_STATE)
colorBackgroundDrawable.setTint(paintColor)
val padding = resources.getDimensionPixelSize(R.dimen.qs_tile_padding) val padding = resources.getDimensionPixelSize(R.dimen.qs_tile_padding)
val startPadding = resources.getDimensionPixelSize(R.dimen.qs_tile_start_padding) val startPadding = resources.getDimensionPixelSize(R.dimen.qs_tile_start_padding)
@@ -165,8 +166,8 @@ open class QSTileViewImpl @JvmOverloads constructor(
labelContainer.ignoreLastView = true labelContainer.ignoreLastView = true
secondaryLabel.alpha = 0f secondaryLabel.alpha = 0f
} }
label.setTextColor(getLabelColor(0)) // Default state label.setTextColor(getLabelColor(QSTile.State.DEFAULT_STATE))
secondaryLabel.setTextColor(getSecondaryLabelColor(0)) secondaryLabel.setTextColor(getSecondaryLabelColor(QSTile.State.DEFAULT_STATE))
addView(labelContainer) addView(labelContainer)
} }
@@ -314,7 +315,7 @@ open class QSTileViewImpl @JvmOverloads constructor(
// HANDLE STATE CHANGES RELATED METHODS // HANDLE STATE CHANGES RELATED METHODS
protected open fun handleStateChanged(state: QSTile.State) { protected open fun handleStateChanged(state: QSTile.State) {
val allowAnimations = animationsEnabled() && paintColor != Color.WHITE val allowAnimations = animationsEnabled()
showRippleEffect = state.showRippleEffect showRippleEffect = state.showRippleEffect
isClickable = state.state != Tile.STATE_UNAVAILABLE isClickable = state.state != Tile.STATE_UNAVAILABLE
isLongClickable = state.handlesLongClick isLongClickable = state.handlesLongClick