Further search result design adjustments
This commit is contained in:
@@ -16,10 +16,10 @@ import java.util.concurrent.ExecutionException
|
||||
internal data class WebsiteImpl(
|
||||
override val label: String,
|
||||
override val url: String,
|
||||
override val description: String,
|
||||
override val imageUrl: String,
|
||||
override val faviconUrl: String,
|
||||
override val color: Int,
|
||||
override val description: String?,
|
||||
override val imageUrl: String?,
|
||||
override val faviconUrl: String?,
|
||||
override val color: Int?,
|
||||
override val labelOverride: String? = null,
|
||||
) : Website {
|
||||
|
||||
@@ -38,7 +38,7 @@ internal data class WebsiteImpl(
|
||||
size: Int,
|
||||
themed: Boolean,
|
||||
): LauncherIcon? {
|
||||
if (faviconUrl.isEmpty()) return null
|
||||
if (faviconUrl == null) return null
|
||||
try {
|
||||
val request = ImageRequest.Builder(context)
|
||||
.data(faviconUrl)
|
||||
@@ -61,7 +61,7 @@ internal data class WebsiteImpl(
|
||||
}
|
||||
|
||||
override fun getPlaceholderIcon(context: Context): StaticLauncherIcon {
|
||||
val color = if (color != 0) color else 0xFFF76F8E.toInt()
|
||||
val color = color ?: 0xFFF76F8E.toInt()
|
||||
if (label.isNotBlank()) {
|
||||
return StaticLauncherIcon(
|
||||
foregroundLayer = TextLayer(text = label[0].toString(), color = color),
|
||||
|
||||
@@ -95,10 +95,10 @@ internal class WebsiteRepository(
|
||||
return@withContext WebsiteImpl(
|
||||
label = title,
|
||||
url = url,
|
||||
description = description,
|
||||
imageUrl = image,
|
||||
faviconUrl = favicon,
|
||||
color = color
|
||||
description = description.takeIf { it.isNotBlank() },
|
||||
imageUrl = image.takeIf { it.isNotBlank() },
|
||||
faviconUrl = favicon.takeIf { it.isNotBlank() },
|
||||
color = color.takeIf { it != 0 }
|
||||
)
|
||||
} catch (e: IOException) {
|
||||
//Ignore. Not a HTML page or no connection. No result for this query
|
||||
|
||||
@@ -28,11 +28,11 @@ class WebsiteDeserializer: SearchableDeserializer {
|
||||
val json = JSONObject(serialized)
|
||||
return WebsiteImpl(
|
||||
label = json.getString("label"),
|
||||
faviconUrl = json.getString("favicon"),
|
||||
imageUrl = json.getString("image"),
|
||||
description = json.getString("description"),
|
||||
faviconUrl = json.getString("favicon").takeIf { it.isNotBlank() },
|
||||
imageUrl = json.getString("image").takeIf { it.isNotBlank() },
|
||||
description = json.getString("description").takeIf { it.isNotBlank() },
|
||||
url = json.getString("url"),
|
||||
color = json.getInt("color")
|
||||
color = json.getInt("color").takeIf { it != 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user