From da231361e70edaec329eede8c21a941794641f6c Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 3 Feb 2025 21:03:56 +0100 Subject: [PATCH] feat: add landscape option to spotlight (closes #219) --- app/src/main/java/com/bnyro/wallpaper/api/sp/SpApi.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/bnyro/wallpaper/api/sp/SpApi.kt b/app/src/main/java/com/bnyro/wallpaper/api/sp/SpApi.kt index 688cfb4..71ea354 100644 --- a/app/src/main/java/com/bnyro/wallpaper/api/sp/SpApi.kt +++ b/app/src/main/java/com/bnyro/wallpaper/api/sp/SpApi.kt @@ -17,7 +17,8 @@ class SpApi: Api() { override val icon = Icons.Default.LightMode override val filters: Map> = mapOf( - "country" to listOf("US") + Locale.getISOCountries().toList().filter { it != "US" }.sorted() + "country" to listOf("US") + Locale.getISOCountries().toList().filter { it != "US" }.sorted(), + "orientation" to listOf("portrait", "landscape") ) private val api = RetrofitHelper.create(baseUrl, Spotlight::class.java) @@ -31,7 +32,10 @@ class SpApi: Api() { return images.map { Wallpaper( title = it.ad.title, - imgSrc = it.ad.portraitImage.asset, + imgSrc = when (getQuery("orientation")) { + "portrait" -> it.ad.portraitImage.asset + else -> it.ad.landscapeImage.asset + }, author = it.ad.copyright, url = it.ad.ctaUri.replaceFirst("microsoft-edge:", ""), description = it.ad.description