From 3a43765f79ec8c5c8232849923f33b1104a45577 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Sun, 1 Dec 2024 13:29:33 +0100 Subject: [PATCH] Use colored rounded rect as button for opening color picker Matches the style of the color temperature picker Signed-off-by: Danny Baumann --- .../org/openhab/habdroid/ui/WidgetAdapter.kt | 6 ++++-- .../ic_palette_outline_themed_24dp.xml | 21 ------------------- .../layout/widgetlist_coloritem_buttons.xml | 10 +++++---- 3 files changed, 10 insertions(+), 27 deletions(-) delete mode 100644 mobile/src/main/res/drawable/ic_palette_outline_themed_24dp.xml diff --git a/mobile/src/main/java/org/openhab/habdroid/ui/WidgetAdapter.kt b/mobile/src/main/java/org/openhab/habdroid/ui/WidgetAdapter.kt index ac8352c0ec..608480ba6a 100644 --- a/mobile/src/main/java/org/openhab/habdroid/ui/WidgetAdapter.kt +++ b/mobile/src/main/java/org/openhab/habdroid/ui/WidgetAdapter.kt @@ -1647,7 +1647,7 @@ class WidgetAdapter( View.OnLongClickListener { private val upButton = itemView.findViewById(R.id.up_button) private val downButton = itemView.findViewById(R.id.down_button) - + private val selectColorButton = itemView.findViewById(R.id.select_color_button) data class UpDownButtonState( val item: Item?, val shortCommand: String, @@ -1660,7 +1660,6 @@ class WidgetAdapter( b.setOnClickListener(this) b.setOnLongClickListener(this) } - val selectColorButton = itemView.findViewById(R.id.select_color_button) selectColorButton.setOnClickListener { handleRowClick() } } @@ -1674,6 +1673,9 @@ class WidgetAdapter( downButton.tag = UpDownButtonState(widget.item, "OFF", "DECREASE") } super.bind(widget) + + val color = widget.state?.asHsv?.toColor() ?: Color.BLACK + selectColorButton.setImageDrawable(color.toColoredRoundedRect(selectColorButton.context)) } override fun onClick(view: View) { diff --git a/mobile/src/main/res/drawable/ic_palette_outline_themed_24dp.xml b/mobile/src/main/res/drawable/ic_palette_outline_themed_24dp.xml deleted file mode 100644 index d1bc2624c2..0000000000 --- a/mobile/src/main/res/drawable/ic_palette_outline_themed_24dp.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - diff --git a/mobile/src/main/res/layout/widgetlist_coloritem_buttons.xml b/mobile/src/main/res/layout/widgetlist_coloritem_buttons.xml index 2028638022..1744d3c2cf 100644 --- a/mobile/src/main/res/layout/widgetlist_coloritem_buttons.xml +++ b/mobile/src/main/res/layout/widgetlist_coloritem_buttons.xml @@ -9,11 +9,13 @@ android:contentDescription="@string/content_description_color_up" app:icon="@drawable/ic_keyboard_arrow_up_themed_24dp" /> -