Skip to content

Commit

Permalink
Fix icon placement for section switches (#3787)
Browse files Browse the repository at this point in the history
The 'automagic' skeleton addition caused two issues:
- Misplaced icon in section switches (#3773)
  This was caused by constraints in the widget's ConstraintLayout
  referencing the WidgetImageView's ID, which was no longer present
  after replacing it by the SkeletonLayout
- Skeleton and image shown at the same time (mentioned in #3786)
  This was caused by WidgetAdapter and SkeletonLayout both
  simultaneously modifying the visibility flag of the WidgetImageView,
  again caused by silent replacement of WidgetImageView by
  SkeletonLayout

Fix both issues by changing the approach: Instead of silently replacing
the view, make WidgetImageView inherit from SkeletonLayout and make it
redirect external calls to an internal ImageView instance.

Fixes #3773, #3786

Signed-off-by: Danny Baumann <[email protected]>
  • Loading branch information
maniac103 authored Jul 30, 2024
1 parent e7e75b2 commit c83c5d4
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 320 deletions.
11 changes: 6 additions & 5 deletions mobile/src/main/java/org/openhab/habdroid/ui/WidgetAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,12 @@ class WidgetAdapter(

// Make sure images fit into the content frame by scaling
// them at max 90% of the available height
if (initData.parent.height > 0) {
imageView.maxHeight = (0.9f * initData.parent.height).roundToInt()
} else {
imageView.maxHeight = Integer.MAX_VALUE
}
imageView.setMaxHeight(
when {
initData.parent.height > 0 -> (0.9f * initData.parent.height).roundToInt()
else -> Integer.MAX_VALUE
}
)
imageView.setImageScalingType(prefs.getImageWidgetScalingType())

if (value != null && value.matches("data:image/.*;base64,.*".toRegex())) {
Expand Down
Loading

0 comments on commit c83c5d4

Please sign in to comment.