Merge "Controls UI - Update bg color for Stateless templates" into rvc-dev am: 721a3ac836 am: 63d2c768b5 am: e333a8f703
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11870643 Change-Id: I2bbb60730e88f09ad375f0fe2827a3e0cf266f50
This commit is contained in:
@@ -238,7 +238,7 @@ internal class ControlHolder(
|
|||||||
updateFavorite(!favorite.isChecked)
|
updateFavorite(!favorite.isChecked)
|
||||||
favoriteCallback(wrapper.controlId, favorite.isChecked)
|
favoriteCallback(wrapper.controlId, favorite.isChecked)
|
||||||
}
|
}
|
||||||
applyRenderInfo(renderInfo)
|
applyRenderInfo(renderInfo, wrapper.deviceType)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateFavorite(favorite: Boolean) {
|
override fun updateFavorite(favorite: Boolean) {
|
||||||
@@ -254,14 +254,18 @@ internal class ControlHolder(
|
|||||||
return RenderInfo.lookup(itemView.context, component, deviceType)
|
return RenderInfo.lookup(itemView.context, component, deviceType)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyRenderInfo(ri: RenderInfo) {
|
private fun applyRenderInfo(ri: RenderInfo, @DeviceTypes.DeviceType deviceType: Int) {
|
||||||
val context = itemView.context
|
val context = itemView.context
|
||||||
val fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
|
val fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
|
||||||
|
|
||||||
icon.setImageDrawable(ri.icon)
|
icon.setImageDrawable(ri.icon)
|
||||||
|
|
||||||
|
// Do not color app icons
|
||||||
|
if (deviceType != DeviceTypes.TYPE_ROUTINE) {
|
||||||
icon.setImageTintList(fg)
|
icon.setImageTintList(fg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessibility delegate for [ControlHolder].
|
* Accessibility delegate for [ControlHolder].
|
||||||
|
|||||||
@@ -274,7 +274,6 @@ class ControlViewHolder(
|
|||||||
val ri = RenderInfo.lookup(context, cws.componentName, deviceTypeOrError, offset)
|
val ri = RenderInfo.lookup(context, cws.componentName, deviceTypeOrError, offset)
|
||||||
val fg = context.resources.getColorStateList(ri.foreground, context.theme)
|
val fg = context.resources.getColorStateList(ri.foreground, context.theme)
|
||||||
val newText = nextStatusText
|
val newText = nextStatusText
|
||||||
nextStatusText = ""
|
|
||||||
val control = cws.control
|
val control = cws.control
|
||||||
|
|
||||||
var shouldAnimate = animated
|
var shouldAnimate = animated
|
||||||
@@ -297,10 +296,8 @@ class ControlViewHolder(
|
|||||||
if (immediately) {
|
if (immediately) {
|
||||||
status.alpha = STATUS_ALPHA_ENABLED
|
status.alpha = STATUS_ALPHA_ENABLED
|
||||||
status.text = text
|
status.text = text
|
||||||
nextStatusText = ""
|
|
||||||
} else {
|
|
||||||
nextStatusText = text
|
|
||||||
}
|
}
|
||||||
|
nextStatusText = text
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun animateBackgroundChange(
|
private fun animateBackgroundChange(
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.graphics.drawable.LayerDrawable
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.service.controls.Control
|
import android.service.controls.Control
|
||||||
import android.service.controls.templates.ControlTemplate
|
import android.service.controls.templates.ControlTemplate
|
||||||
|
import android.service.controls.templates.StatelessTemplate
|
||||||
|
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
import com.android.systemui.controls.ui.ControlViewHolder.Companion.MAX_LEVEL
|
import com.android.systemui.controls.ui.ControlViewHolder.Companion.MAX_LEVEL
|
||||||
@@ -35,24 +36,44 @@ class TouchBehavior : Behavior {
|
|||||||
lateinit var template: ControlTemplate
|
lateinit var template: ControlTemplate
|
||||||
lateinit var control: Control
|
lateinit var control: Control
|
||||||
lateinit var cvh: ControlViewHolder
|
lateinit var cvh: ControlViewHolder
|
||||||
|
private var statelessTouch = false
|
||||||
|
private var lastColorOffset = 0
|
||||||
|
private val enabled: Boolean
|
||||||
|
get() = if (lastColorOffset > 0 || statelessTouch) true else false
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val STATELESS_ENABLE_TIMEOUT_IN_MILLIS = 3000L
|
||||||
|
}
|
||||||
|
|
||||||
override fun initialize(cvh: ControlViewHolder) {
|
override fun initialize(cvh: ControlViewHolder) {
|
||||||
this.cvh = cvh
|
this.cvh = cvh
|
||||||
|
|
||||||
cvh.layout.setOnClickListener(View.OnClickListener() {
|
cvh.layout.setOnClickListener(View.OnClickListener() {
|
||||||
cvh.controlActionCoordinator.touch(cvh, template.getTemplateId(), control)
|
cvh.controlActionCoordinator.touch(cvh, template.getTemplateId(), control)
|
||||||
|
|
||||||
|
// StatelessTemplates have no state, with no way to discern between enabled and
|
||||||
|
// disabled. Render an enabled state for a few moments to let the user know the
|
||||||
|
// action is in progress.
|
||||||
|
if (template is StatelessTemplate) {
|
||||||
|
statelessTouch = true
|
||||||
|
cvh.applyRenderInfo(enabled, lastColorOffset)
|
||||||
|
cvh.uiExecutor.executeDelayed({
|
||||||
|
statelessTouch = false
|
||||||
|
cvh.applyRenderInfo(enabled, lastColorOffset)
|
||||||
|
}, STATELESS_ENABLE_TIMEOUT_IN_MILLIS)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(cws: ControlWithState, colorOffset: Int) {
|
override fun bind(cws: ControlWithState, colorOffset: Int) {
|
||||||
this.control = cws.control!!
|
this.control = cws.control!!
|
||||||
|
lastColorOffset = colorOffset
|
||||||
cvh.setStatusText(control.getStatusText())
|
cvh.setStatusText(control.getStatusText())
|
||||||
template = control.getControlTemplate()
|
template = control.getControlTemplate()
|
||||||
|
|
||||||
val ld = cvh.layout.getBackground() as LayerDrawable
|
val ld = cvh.layout.getBackground() as LayerDrawable
|
||||||
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
|
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
|
||||||
|
|
||||||
val enabled = if (colorOffset > 0) true else false
|
|
||||||
clipLayer.setLevel(if (enabled) MAX_LEVEL else MIN_LEVEL)
|
clipLayer.setLevel(if (enabled) MAX_LEVEL else MIN_LEVEL)
|
||||||
cvh.applyRenderInfo(enabled, colorOffset)
|
cvh.applyRenderInfo(enabled, colorOffset)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user