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 ba4763bb19..33aa0b8fca 100644 --- a/mobile/src/main/java/org/openhab/habdroid/model/IconResource.kt +++ b/mobile/src/main/java/org/openhab/habdroid/model/IconResource.kt @@ -86,7 +86,7 @@ data class IconResource internal constructor( when (iconSource) { "if", "iconify" -> { builder.scheme("https") - .authority("api.iconify.design") + .authority(ICONIFY_API_URL) .path(iconSet) .appendPath("$iconName.svg") .appendQueryParameter("height", desiredSizePixels.toString()) @@ -121,6 +121,10 @@ data class IconResource internal constructor( fun withCustomState(state: String): IconResource { return IconResource(icon, isOh2, state) } + + companion object { + public const val ICONIFY_API_URL = "api.iconify.design" + } } fun SharedPreferences.getIconResource(key: String): IconResource? { diff --git a/mobile/src/main/java/org/openhab/habdroid/util/CacheManager.kt b/mobile/src/main/java/org/openhab/habdroid/util/CacheManager.kt index 0a79469a99..5391e2af5c 100644 --- a/mobile/src/main/java/org/openhab/habdroid/util/CacheManager.kt +++ b/mobile/src/main/java/org/openhab/habdroid/util/CacheManager.kt @@ -26,6 +26,7 @@ import okhttp3.Cache import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import org.openhab.habdroid.model.IconFormat +import org.openhab.habdroid.model.IconResource class CacheManager private constructor(appContext: Context) { val httpCache: Cache = Cache(File(appContext.cacheDir, "http"), (10 * 1024 * 1024).toLong()) @@ -61,7 +62,8 @@ class CacheManager private constructor(appContext: Context) { } } - private fun HttpUrl.isIconUrl() = pathSegments.firstOrNull() == "icon" && pathSegments[1].isNotEmpty() + private fun HttpUrl.isIconUrl() = host == IconResource.ICONIFY_API_URL || + (pathSegments.firstOrNull() == "icon" && pathSegments[1].isNotEmpty()) fun isBitmapCached(url: HttpUrl, @ColorInt fallbackColor: Int): Boolean { return getCachedBitmap(url, fallbackColor) != null