summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Pietal <mpietal@google.com> 2020-06-22 15:11:26 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-06-22 15:11:26 +0000
commitc472565de65f5bb3d185a5dc19d1969dc8df8071 (patch)
tree49660b02e85947146400bd5488a23942d3a9ada4
parentee9ca628caa790c923269da5388cc00dcafb8780 (diff)
parenta2e2085cb3adbe387db6a14959deda876a18d561 (diff)
Merge "Controls UI - Use custom icon for favoriting" into rvc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/ControlStatus.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt16
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt6
3 files changed, 20 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ControlStatus.kt b/packages/SystemUI/src/com/android/systemui/controls/ControlStatus.kt
index 5891a7f705c8..f0356d038065 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ControlStatus.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ControlStatus.kt
@@ -17,6 +17,7 @@
package com.android.systemui.controls
import android.content.ComponentName
+import android.graphics.drawable.Icon
import android.service.controls.Control
import android.service.controls.DeviceTypes
@@ -28,6 +29,7 @@ interface ControlInterface {
val subtitle: CharSequence
val removed: Boolean
get() = false
+ val customIcon: Icon?
@DeviceTypes.DeviceType val deviceType: Int
}
@@ -46,6 +48,9 @@ data class ControlStatus(
override val subtitle: CharSequence
get() = control.subtitle
+ override val customIcon: Icon?
+ get() = control.customIcon
+
@DeviceTypes.DeviceType override val deviceType: Int
get() = control.deviceType
}
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 05433197799e..c683a87d6282 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 @@ internal class ControlHolder(
updateFavorite(!favorite.isChecked)
favoriteCallback(wrapper.controlId, favorite.isChecked)
}
- applyRenderInfo(renderInfo, wrapper.deviceType)
+ applyRenderInfo(renderInfo, wrapper)
}
override fun updateFavorite(favorite: Boolean) {
@@ -254,15 +254,19 @@ internal class ControlHolder(
return RenderInfo.lookup(itemView.context, component, deviceType)
}
- private fun applyRenderInfo(ri: RenderInfo, @DeviceTypes.DeviceType deviceType: Int) {
+ private fun applyRenderInfo(ri: RenderInfo, ci: ControlInterface) {
val context = itemView.context
val fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
- icon.setImageDrawable(ri.icon)
+ ci.customIcon?.let {
+ icon.setImageIcon(it)
+ } ?: run {
+ icon.setImageDrawable(ri.icon)
- // Do not color app icons
- if (deviceType != DeviceTypes.TYPE_ROUTINE) {
- icon.setImageTintList(fg)
+ // Do not color app icons
+ if (ci.deviceType != DeviceTypes.TYPE_ROUTINE) {
+ icon.setImageTintList(fg)
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt
index 254395368bf9..4ef64a5cddbf 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsModel.kt
@@ -17,6 +17,7 @@
package com.android.systemui.controls.management
import android.content.ComponentName
+import android.graphics.drawable.Icon
import androidx.recyclerview.widget.RecyclerView
import com.android.systemui.controls.ControlInterface
import com.android.systemui.controls.ControlStatus
@@ -126,9 +127,12 @@ data class ControlInfoWrapper(
get() = controlInfo.controlSubtitle
override val deviceType: Int
get() = controlInfo.deviceType
+ override val customIcon: Icon?
+ // Will need to address to support for edit activity
+ get() = null
}
data class DividerWrapper(
var showNone: Boolean = false,
var showDivider: Boolean = false
-) : ElementWrapper() \ No newline at end of file
+) : ElementWrapper()