Repository: openhab/openhab-android (language: kotlin)

Issue:
Support missing for icon value like oh:humidity
The Android app already correctly renders icons "temperature" and "oh:classic:pressure".
It would be great if "oh:humidity" could be also supported.
In case no icon set is provided by the user,, the app should consider by default the "classic" icon set.


Discussion hints:
I don't know how the app is requesting the icon, but for "oh:humidity", either you have to set properly the request parameter "iconset" (to "classic") or you have to not set it at all in that case and the OH server will then consider the "classic" icon set by default.
The current workaround is to not use this syntax and rather use just "humidity".

Pull request: Fix icon name parsing
Closes #3342

Test command: ./gradlew :mobile:testFossBetaDebugUnitTest --tests "org.openhab.habdroid.model.WidgetTest"

Fix patch:
diff --git a/mobile/src/main/java/org/openhab/habdroid/model/IconResource.kt b/mobile/src/main/java/org/openhab/habdroid/model/IconResource.kt
index 17b1c89f9e..0d5c98e50c 100644
--- a/mobile/src/main/java/org/openhab/habdroid/model/IconResource.kt
+++ b/mobile/src/main/java/org/openhab/habdroid/model/IconResource.kt
@@ -51,8 +51,10 @@ data class IconResource internal constructor(
         when (segments.size) {
             1 -> iconName = segments[0]
             2 -> {
-                iconSet = segments[0]
-                iconName = segments[1]
+                // Keep iconName=none for unsupported icon sources
+                if (segments[0] == "oh") {
+                    iconName = segments[1]
+                }
             }
             3 -> {
                 // Keep iconName=none for unsupported icon sources


Test patch:
diff --git a/mobile/src/test/java/org/openhab/habdroid/model/WidgetTest.kt b/mobile/src/test/java/org/openhab/habdroid/model/WidgetTest.kt
index 4a2f275c25..ea580ea019 100644
--- a/mobile/src/test/java/org/openhab/habdroid/model/WidgetTest.kt
+++ b/mobile/src/test/java/org/openhab/habdroid/model/WidgetTest.kt
@@ -81,7 +81,7 @@ class WidgetTest {
         )
         assertEquals(
             "Iconset must be extracted from icon name",
-            "icon/frame?format=SVG&anyFormat=true&iconset=mdi",
+            "icon/frame?format=SVG&anyFormat=true&iconset=classic",
             sut3[0].icon?.toUrl(false, IconFormat.Svg)
         )
         assertEquals(
@@ -367,7 +367,7 @@ class WidgetTest {
                   'widgetId': '0202_0',
                   'type': 'Frame',
                   'label': 'Percent-based Widgets',
-                  'icon': 'mdi:frame',
+                  'icon': 'oh:frame',
                   'mappings': [],
                   'widgets': [ {
                     'widgetId': '0202_0_0',