Skip to content

Commit

Permalink
Fix issues with WidgetImageView skeleton placeholder
Browse files Browse the repository at this point in the history
The 'automagic' skeleton addition caused two issues:
- Misplaced icon in section switches (openhab#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 openhab#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 openhab#3773, openhab#3786

Signed-off-by: Danny Baumann <[email protected]>
  • Loading branch information
maniac103 committed Jul 30, 2024
1 parent f23ebe4 commit 201d492
Show file tree
Hide file tree
Showing 3 changed files with 351 additions and 322 deletions.
9 changes: 4 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 @@ -1037,11 +1037,10 @@ 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 201d492

Please sign in to comment.