From 67ab650b081f5e1603172a4516dd7ec4b1b1c3dc Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Fri, 6 May 2022 08:39:35 +0600 Subject: [PATCH] App Lounge: fixed category icon for different language --- .../java/foundation/e/apps/AppLoungeApplication.kt | 2 +- .../java/foundation/e/apps/api/fused/FusedAPIImpl.kt | 12 ++++++++++-- .../e/apps/api/fused/utils/CategoryUtils.kt | 4 ++-- .../java/foundation/e/apps/utils/enums/AppTag.kt | 9 ++++----- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt index 21d6f5c59..f33fe1e91 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -24,9 +24,9 @@ import androidx.work.Configuration import dagger.hilt.android.HiltAndroidApp import foundation.e.apps.manager.pkg.PkgManagerBR import foundation.e.apps.manager.pkg.PkgManagerModule +import foundation.e.apps.manager.workmanager.InstallWorkManager import foundation.e.apps.setup.tos.TOS_VERSION import foundation.e.apps.utils.modules.DataStoreModule -import foundation.e.apps.manager.workmanager.InstallWorkManager import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index bbdce8fb3..377d0be8a 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt @@ -232,7 +232,10 @@ class FusedAPIImpl @Inject constructor( return gPlayAPIRepository.listAppCategoryUrls(browseUrl, authData) } - suspend fun getAppsAndNextClusterUrl(browseUrl: String, authData: AuthData): Pair, String> { + suspend fun getAppsAndNextClusterUrl( + browseUrl: String, + authData: AuthData + ): Pair, String> { return gPlayAPIRepository.getAppsAndNextClusterUrl(browseUrl, authData).let { Pair(it.first.map { app -> app.transformToFusedApp() }, it.second) } @@ -366,7 +369,10 @@ class FusedAPIImpl @Inject constructor( } private fun getCategoryIconName(category: FusedCategory): String { - var categoryTitle = category.title + var categoryTitle = if (category.tag.getOperationalTag() + .contentEquals(AppTag.GPlay().getOperationalTag()) + ) category.id else category.title + if (categoryTitle.contains(CATEGORY_TITLE_REPLACEABLE_CONJUNCTION)) { categoryTitle = categoryTitle.replace(CATEGORY_TITLE_REPLACEABLE_CONJUNCTION, "and") } @@ -468,7 +474,9 @@ class FusedAPIImpl @Inject constructor( } private fun Category.transformToFusedCategory(): FusedCategory { + val id = this.browseUrl.substringAfter("cat=").substringBefore("&c=") return FusedCategory( + id = id.lowercase(), title = this.title, browseUrl = this.browseUrl, imageUrl = this.imageUrl, diff --git a/app/src/main/java/foundation/e/apps/api/fused/utils/CategoryUtils.kt b/app/src/main/java/foundation/e/apps/api/fused/utils/CategoryUtils.kt index a4647c52b..f3dfe82af 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/utils/CategoryUtils.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/utils/CategoryUtils.kt @@ -167,9 +167,9 @@ object CategoryUtils { R.drawable.ic_cat_travel "pwa_business" -> R.drawable.ic_business - "watch_faces" -> + "watch_face" -> R.drawable.ic_watchface - "watch_apps" -> + "android_wear" -> R.drawable.ic_watch_apps else -> R.drawable.ic_cat_default diff --git a/app/src/main/java/foundation/e/apps/utils/enums/AppTag.kt b/app/src/main/java/foundation/e/apps/utils/enums/AppTag.kt index 0f13ea18c..5a5361dd8 100644 --- a/app/src/main/java/foundation/e/apps/utils/enums/AppTag.kt +++ b/app/src/main/java/foundation/e/apps/utils/enums/AppTag.kt @@ -26,9 +26,9 @@ package foundation.e.apps.utils.enums * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5364 */ sealed class AppTag(val displayTag: String) { - class OpenSource(displayTag: String): AppTag(displayTag) - class PWA(displayTag: String): AppTag(displayTag) - class GPlay(displayTag: String = ""): AppTag(displayTag) + class OpenSource(displayTag: String) : AppTag(displayTag) + class PWA(displayTag: String) : AppTag(displayTag) + class GPlay(displayTag: String = "") : AppTag(displayTag) /** * In many places in the code, checks are for hard coded string "Open Source". @@ -38,5 +38,4 @@ sealed class AppTag(val displayTag: String) { return if (this is OpenSource) "Open Source" else this::class.java.simpleName } - -} \ No newline at end of file +} -- GitLab