Merge "Controls UI - Update bg color for Stateless templates" into rvc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt
index 26124f7..0543319 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt
@@ -238,7 +238,7 @@
updateFavorite(!favorite.isChecked)
favoriteCallback(wrapper.controlId, favorite.isChecked)
}
- applyRenderInfo(renderInfo)
+ applyRenderInfo(renderInfo, wrapper.deviceType)
}
override fun updateFavorite(favorite: Boolean) {
@@ -254,12 +254,16 @@
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 fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
icon.setImageDrawable(ri.icon)
- icon.setImageTintList(fg)
+
+ // Do not color app icons
+ if (deviceType != DeviceTypes.TYPE_ROUTINE) {
+ icon.setImageTintList(fg)
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
index ee02b85..e853027 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
@@ -274,7 +274,6 @@
val ri = RenderInfo.lookup(context, cws.componentName, deviceTypeOrError, offset)
val fg = context.resources.getColorStateList(ri.foreground, context.theme)
val newText = nextStatusText
- nextStatusText = ""
val control = cws.control
var shouldAnimate = animated
@@ -297,10 +296,8 @@
if (immediately) {
status.alpha = STATUS_ALPHA_ENABLED
status.text = text
- nextStatusText = ""
- } else {
- nextStatusText = text
}
+ nextStatusText = text
}
private fun animateBackgroundChange(
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
index 48f9458..9dd0f53 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
@@ -21,6 +21,7 @@
import android.view.View
import android.service.controls.Control
import android.service.controls.templates.ControlTemplate
+import android.service.controls.templates.StatelessTemplate
import com.android.systemui.R
import com.android.systemui.controls.ui.ControlViewHolder.Companion.MAX_LEVEL
@@ -35,24 +36,44 @@
lateinit var template: ControlTemplate
lateinit var control: Control
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) {
this.cvh = cvh
cvh.layout.setOnClickListener(View.OnClickListener() {
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) {
this.control = cws.control!!
+ lastColorOffset = colorOffset
cvh.setStatusText(control.getStatusText())
template = control.getControlTemplate()
val ld = cvh.layout.getBackground() as LayerDrawable
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
- val enabled = if (colorOffset > 0) true else false
clipLayer.setLevel(if (enabled) MAX_LEVEL else MIN_LEVEL)
cvh.applyRenderInfo(enabled, colorOffset)
}