Skip to content

Commit

Permalink
Use colored rounded rect as button for opening color picker
Browse files Browse the repository at this point in the history
Matches the style of the color temperature picker

Signed-off-by: Danny Baumann <[email protected]>
  • Loading branch information
maniac103 committed Dec 1, 2024
1 parent a523f8c commit 3a43765
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
6 changes: 4 additions & 2 deletions mobile/src/main/java/org/openhab/habdroid/ui/WidgetAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ class WidgetAdapter(
View.OnLongClickListener {
private val upButton = itemView.findViewById<View>(R.id.up_button)
private val downButton = itemView.findViewById<View>(R.id.down_button)

private val selectColorButton = itemView.findViewById<ImageView>(R.id.select_color_button)
data class UpDownButtonState(
val item: Item?,
val shortCommand: String,
Expand All @@ -1660,7 +1660,6 @@ class WidgetAdapter(
b.setOnClickListener(this)
b.setOnLongClickListener(this)
}
val selectColorButton = itemView.findViewById<View>(R.id.select_color_button)
selectColorButton.setOnClickListener { handleRowClick() }
}

Expand All @@ -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) {
Expand Down
21 changes: 0 additions & 21 deletions mobile/src/main/res/drawable/ic_palette_outline_themed_24dp.xml

This file was deleted.

10 changes: 6 additions & 4 deletions mobile/src/main/res/layout/widgetlist_coloritem_buttons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
android:contentDescription="@string/content_description_color_up"
app:icon="@drawable/ic_keyboard_arrow_up_themed_24dp" />

<Button
style="@style/openHAB.ActionButton"
<ImageView
android:id="@+id/select_color_button"
android:contentDescription="@string/content_description_open_color_wheel"
app:icon="@drawable/ic_palette_outline_themed_24dp" />
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:padding="8dp"
android:contentDescription="@string/content_description_open_color_wheel" />

<Button
style="@style/openHAB.ActionButton"
Expand Down

0 comments on commit 3a43765

Please sign in to comment.