From c1c44c7ecc27f671e7fb2b2e3d231a1b97920f76 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 22 Oct 2024 08:26:22 +0200 Subject: [PATCH 1/6] Sanitize getHomeScreen() calls --- .../foundation/e/apps/data/StoreRepository.kt | 4 +- .../apps/data/application/apps/AppsApiImpl.kt | 3 +- .../apps/data/application/home/HomeApiImpl.kt | 150 +++++++++--------- .../data/cleanapk/ApplicationDeserializer.kt | 16 +- .../e/apps/data/cleanapk/CleanApkRetrofit.kt | 8 +- ...{Application.kt => CleanApkApplication.kt} | 6 +- .../data/home/{Home.kt => CleanApkHome.kt} | 2 +- .../{HomeScreen.kt => HomeScreenResponse.kt} | 4 +- .../repositories/CleanApkAppsRepository.kt | 91 ++++++++++- .../repositories/CleanApkPwaRepository.kt | 88 +++++++++- .../data/playstore/PlayStoreRepository.kt | 14 +- .../e/apps/di/network/NetworkModule.kt | 4 +- app/src/main/res/values-de/strings.xml | 3 +- app/src/main/res/values-es/strings.xml | 3 +- app/src/main/res/values-fi/strings.xml | 3 +- app/src/main/res/values-fr/strings.xml | 3 +- app/src/main/res/values-is/strings.xml | 3 +- app/src/main/res/values-it/strings.xml | 3 +- app/src/main/res/values-nb-rNO/strings.xml | 3 +- app/src/main/res/values-nl/strings.xml | 3 +- app/src/main/res/values-ru/strings.xml | 3 +- app/src/main/res/values-sv/strings.xml | 3 +- app/src/main/res/values-tr/strings.xml | 3 +- app/src/main/res/values-uk/strings.xml | 3 +- app/src/main/res/values/strings.xml | 1 - .../foundation/e/apps/home/HomeApiTest.kt | 12 +- 26 files changed, 292 insertions(+), 147 deletions(-) rename app/src/main/java/foundation/e/apps/data/cleanapk/data/app/{Application.kt => CleanApkApplication.kt} (81%) rename app/src/main/java/foundation/e/apps/data/cleanapk/data/home/{Home.kt => CleanApkHome.kt} (96%) rename app/src/main/java/foundation/e/apps/data/cleanapk/data/home/{HomeScreen.kt => HomeScreenResponse.kt} (89%) diff --git a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt index 0f8e1e426..4a9930756 100644 --- a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt @@ -18,7 +18,9 @@ package foundation.e.apps.data +import foundation.e.apps.data.application.data.Application + interface StoreRepository { - suspend fun getHomeScreenData(): Any + suspend fun getHomeScreenData(): Map> suspend fun getAppDetails(packageNameOrId: String): Any? } diff --git a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt index e4847bece..835c3babe 100644 --- a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt @@ -21,7 +21,6 @@ package foundation.e.apps.data.application.apps import android.content.Context import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData -import com.aurora.gplayapi.data.models.ContentRating import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.application.ApplicationDataManager @@ -38,7 +37,7 @@ import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import retrofit2.Response import javax.inject.Inject -import foundation.e.apps.data.cleanapk.data.app.Application as CleanApkApplication +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication class AppsApiImpl @Inject constructor( @ApplicationContext private val context: Context, diff --git a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index 53a402427..56e2fd965 100644 --- a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt @@ -19,6 +19,7 @@ package foundation.e.apps.data.application.home import android.content.Context +import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.liveData import com.aurora.gplayapi.data.models.App @@ -28,11 +29,12 @@ import foundation.e.apps.R import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.application.search.FusedHomeDeferred import foundation.e.apps.data.application.search.SearchApi import foundation.e.apps.data.application.utils.toApplication -import foundation.e.apps.data.cleanapk.data.home.HomeScreen +import foundation.e.apps.data.cleanapk.data.home.HomeScreenResponse import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.handleNetworkResult @@ -47,7 +49,7 @@ import kotlinx.coroutines.launch import retrofit2.Response import timber.log.Timber import javax.inject.Inject -import foundation.e.apps.data.cleanapk.data.home.Home as CleanApkHome +import foundation.e.apps.data.cleanapk.data.home.CleanApkHome class HomeApiImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -142,87 +144,19 @@ class HomeApiImpl @Inject constructor( priorList: MutableList, appType: String ): MutableList { - val response = if (appType == SearchApi.APP_TYPE_OPEN) { - (appSources.cleanApkAppsRepo.getHomeScreenData() as Response).body() + val homes = if (appType == SearchApi.APP_TYPE_OPEN) { + appSources.cleanApkAppsRepo.getHomeScreenData() } else { - (appSources.cleanApkPWARepo.getHomeScreenData() as Response).body() + appSources.cleanApkPWARepo.getHomeScreenData() } - response?.home?.let { - priorList.addAll(generateCleanAPKHome(it, appType)) + homes.forEach { (title, list) -> + priorList.add(Home(title, list, appType)) } return priorList } - private suspend fun generateCleanAPKHome(home: CleanApkHome, appType: String): List { - val list = mutableListOf() - val headings = if (appType == SearchApi.APP_TYPE_OPEN) { - getOpenSourceHomeCategories() - } else { - getPWAHomeCategories() - } - - headings.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(home.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(home.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(home.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(home.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - home.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - home.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(home.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - - private fun getPWAHomeCategories() = mapOf( - "popular_apps" to context.getString(R.string.popular_apps), - "popular_games" to context.getString(R.string.popular_games), - "discover" to context.getString(R.string.discover_pwa) - ) - - private fun getOpenSourceHomeCategories() = mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "discover" to context.getString(R.string.discover) - ) - private fun setHomeErrorMessage(apiStatus: ResultStatus, source: Source) { if (apiStatus != ResultStatus.OK) { apiStatus.message = when (source) { @@ -239,11 +173,11 @@ class HomeApiImpl @Inject constructor( priorList: MutableList ): List { val list = mutableListOf() - val gplayHomeData = - appSources.gplayRepo.getHomeScreenData() as Map> + val gplayHomeData = appSources.gplayRepo.getHomeScreenData() + gplayHomeData.map { val fusedApps = it.value.map { app -> - app.toApplication(context).apply { + app.apply { applicationDataManager.updateStatus(this) applicationDataManager.updateFilterLevel(authData, this) } @@ -278,4 +212,64 @@ class HomeApiImpl @Inject constructor( } } + private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { + val list = mutableListOf() + + openSourceCategories.forEach { (key, value) -> + when (key) { + "top_updated_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) + } + + "top_updated_games" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) + } + + "popular_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) + } + + "popular_games" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) + } + + "popular_apps_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_apps_in_last_24_hours, + list, + value + ) + } + + "popular_games_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_games_in_last_24_hours, + list, + value + ) + } + + "discover" -> { + applicationDataManager.prepareApps(cleanApkHome.discover, list, value) + } + } + } + + return list.map { + it.source = appType + it + } + } + + private val openSourceCategories: Map by lazy { + mapOf( + "top_updated_apps" to context.getString(R.string.top_updated_apps), + "top_updated_games" to context.getString(R.string.top_updated_games), + "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), + "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), + "popular_apps" to context.getString(R.string.popular_apps), + "popular_games" to context.getString(R.string.popular_games), + "discover" to context.getString(R.string.discover) + ) + } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt index 5d9b3910b..b5c69ee73 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt @@ -22,22 +22,22 @@ import com.google.gson.Gson import com.google.gson.JsonDeserializationContext import com.google.gson.JsonDeserializer import com.google.gson.JsonElement -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication -class ApplicationDeserializer : JsonDeserializer { +class ApplicationDeserializer : JsonDeserializer { override fun deserialize( json: JsonElement?, typeOfT: java.lang.reflect.Type?, context: JsonDeserializationContext? - ): Application { + ): CleanApkApplication { val gson = Gson() - val application = gson.fromJson(json?.asJsonObject?.toString(), Application::class.java) - val lastUpdate = application.app.latest_downloaded_version + val cleanApkApplication = gson.fromJson(json?.asJsonObject?.toString(), CleanApkApplication::class.java) + val lastUpdate = cleanApkApplication.app.latest_downloaded_version val lastUpdateJson = json?.asJsonObject?.get("app")?.asJsonObject?.get(lastUpdate)?.asJsonObject val lastUpdatedOn = lastUpdateJson ?.asJsonObject?.get("update_on")?.asString ?: "" - application.app.updatedOn = lastUpdatedOn - application.app.latest_version_code = lastUpdateJson?.get("version_code")?.asInt ?: -1 - return application + cleanApkApplication.app.updatedOn = lastUpdatedOn + cleanApkApplication.app.latest_version_code = lastUpdateJson?.get("version_code")?.asInt ?: -1 + return cleanApkApplication } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt index 3da3d4014..1e8883398 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt @@ -18,10 +18,10 @@ package foundation.e.apps.data.cleanapk -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.download.Download -import foundation.e.apps.data.cleanapk.data.home.HomeScreen +import foundation.e.apps.data.cleanapk.data.home.HomeScreenResponse import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import retrofit2.http.GET @@ -48,7 +48,7 @@ interface CleanApkRetrofit { suspend fun getHomeScreenData( @Query("type") type: String = APP_TYPE_ANY, @Query("source") source: String = APP_SOURCE_ANY, - ): Response + ): Response // TODO: Reminder that this function is for search App and PWA both @GET("apps?action=app_detail") @@ -56,7 +56,7 @@ interface CleanApkRetrofit { @Query("id") id: String, @Query("architectures") architectures: List? = null, @Query("type") type: String? = null - ): Response + ): Response @GET("apps?action=search") suspend fun searchApps( diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/Application.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/CleanApkApplication.kt similarity index 81% rename from app/src/main/java/foundation/e/apps/data/cleanapk/data/app/Application.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/data/app/CleanApkApplication.kt index 906d9b2d0..4ba0b0c7b 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/CleanApkApplication.kt @@ -18,9 +18,9 @@ package foundation.e.apps.data.cleanapk.data.app -import foundation.e.apps.data.application.data.Application as AppLoungeApplication +import foundation.e.apps.data.application.data.Application -data class Application( - val app: AppLoungeApplication = AppLoungeApplication(), +data class CleanApkApplication( + val app: Application = Application(), val success: Boolean = false ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/Home.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt similarity index 96% rename from app/src/main/java/foundation/e/apps/data/cleanapk/data/home/Home.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt index 8e50e09c3..1647a00eb 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/Home.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt @@ -21,7 +21,7 @@ package foundation.e.apps.data.cleanapk.data.home import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.application.data.Application -data class Home( +data class CleanApkHome( val top_updated_apps: List = emptyList(), val top_updated_games: List = emptyList(), val popular_apps: List = emptyList(), diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreen.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreenResponse.kt similarity index 89% rename from app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreen.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreenResponse.kt index 27d0f7db4..9c64a8a75 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreen.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreenResponse.kt @@ -18,7 +18,7 @@ package foundation.e.apps.data.cleanapk.data.home -data class HomeScreen( - val home: Home = Home(), +data class HomeScreenResponse( + val home: CleanApkHome = CleanApkHome(), val success: Boolean = false ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index 8a5c09372..d17eb49b5 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -18,25 +18,94 @@ package foundation.e.apps.data.cleanapk.repositories +import android.content.Context +import android.util.Log +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.R +import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Application +import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.download.Download -import foundation.e.apps.data.cleanapk.data.home.HomeScreen +import foundation.e.apps.data.cleanapk.data.home.CleanApkHome import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkAppsRepository @Inject constructor( - private val cleanApkRetrofit: CleanApkRetrofit + private val cleanApkRetrofit: CleanApkRetrofit, + private val applicationDataManager: ApplicationDataManager, + @ApplicationContext val context: Context ) : CleanApkRepository, CleanApkDownloadInfoFetcher { - override suspend fun getHomeScreenData(): Response { - return cleanApkRetrofit.getHomeScreenData( + override suspend fun getHomeScreenData(): Map> { + + val response = cleanApkRetrofit.getHomeScreenData( CleanApkRetrofit.APP_TYPE_ANY, CleanApkRetrofit.APP_SOURCE_FOSS ) + + val home = response.body()?.home ?: throw IllegalStateException("No home data found") + + val listHome = toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) + val map = mutableMapOf>() + listHome.forEach { + map[it.title] = it.list + } + + return map + } + + private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { + val list = mutableListOf() + + openSourceCategories.forEach { (key, value) -> + when (key) { + "top_updated_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) + } + + "top_updated_games" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) + } + + "popular_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) + } + + "popular_games" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) + } + + "popular_apps_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_apps_in_last_24_hours, + list, + value + ) + } + + "popular_games_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_games_in_last_24_hours, + list, + value + ) + } + + "discover" -> { + applicationDataManager.prepareApps(cleanApkHome.discover, list, value) + } + } + } + + return list.map { + it.source = appType + it + } } override suspend fun getSearchResult(query: String, searchBy: String?): Response { @@ -74,7 +143,7 @@ class CleanApkAppsRepository @Inject constructor( return cleanApkRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { + override suspend fun getAppDetails(packageNameOrId: String): Response { return cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) } @@ -82,4 +151,14 @@ class CleanApkAppsRepository @Inject constructor( val version = versionCode?.let { it as String } return cleanApkRetrofit.getDownloadInfo(idOrPackageName, version, null) } + + private val openSourceCategories: Map by lazy { + mapOf( + "top_updated_apps" to context.getString(R.string.top_updated_apps), + "top_updated_games" to context.getString(R.string.top_updated_games), + "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), + "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), + "discover" to context.getString(R.string.discover) + ) + } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index 2f1f00dd2..85485bfb1 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -18,22 +18,90 @@ package foundation.e.apps.data.cleanapk.repositories +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.R +import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Application +import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories +import foundation.e.apps.data.cleanapk.data.home.CleanApkHome import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkPwaRepository @Inject constructor( - private val cleanAPKRetrofit: CleanApkRetrofit + private val cleanAPKRetrofit: CleanApkRetrofit, + private val applicationDataManager: ApplicationDataManager, + @ApplicationContext val context: Context ) : CleanApkRepository { - override suspend fun getHomeScreenData(): Any { - return cleanAPKRetrofit.getHomeScreenData( + override suspend fun getHomeScreenData(): Map> { + val response = cleanAPKRetrofit.getHomeScreenData( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) + + val home = response.body()?.home ?: throw IllegalStateException("No home data found") + + val listHome = toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) + val map = mutableMapOf>() + listHome.forEach { + map[it.title] = it.list + } + + return map + } + + private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { + val list = mutableListOf() + + openSourceCategories.forEach { (key, value) -> + when (key) { + "top_updated_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) + } + + "top_updated_games" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) + } + + "popular_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) + } + + "popular_games" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) + } + + "popular_apps_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_apps_in_last_24_hours, + list, + value + ) + } + + "popular_games_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_games_in_last_24_hours, + list, + value + ) + } + + "discover" -> { + applicationDataManager.prepareApps(cleanApkHome.discover, list, value) + } + } + } + + return list.map { + it.source = appType + it + } } override suspend fun getSearchResult(query: String, searchBy: String?): Response { @@ -68,7 +136,17 @@ class CleanApkPwaRepository @Inject constructor( return cleanAPKRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { + override suspend fun getAppDetails(packageNameOrId: String): Response { return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) } + + private val openSourceCategories: Map by lazy { + mapOf( + "top_updated_apps" to context.getString(R.string.top_updated_apps), + "top_updated_games" to context.getString(R.string.top_updated_games), + "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), + "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), + "discover" to context.getString(R.string.discover) + ) + } } diff --git a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt index 3065874e2..5b7b650a8 100644 --- a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt @@ -19,6 +19,7 @@ package foundation.e.apps.data.playstore import android.content.Context +import android.util.Log import com.aurora.gplayapi.SearchSuggestEntry import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData @@ -38,7 +39,9 @@ import com.aurora.gplayapi.helpers.TopChartsHelper import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.R import foundation.e.apps.data.StoreRepository +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.utils.CategoryType +import foundation.e.apps.data.application.utils.toApplication import foundation.e.apps.data.login.AuthenticatorRepository import foundation.e.apps.data.playstore.utils.GPlayHttpClient import kotlinx.coroutines.Dispatchers @@ -52,8 +55,8 @@ class PlayStoreRepository @Inject constructor( private val authenticatorRepository: AuthenticatorRepository ) : StoreRepository { - override suspend fun getHomeScreenData(): Any { - val homeScreenData = mutableMapOf>() + override suspend fun getHomeScreenData(): Map> { + val homeScreenData = mutableMapOf>() val homeElements = createTopChartElements() val authData = authenticatorRepository.getGPlayAuthOrThrow() @@ -175,13 +178,16 @@ class PlayStoreRepository @Inject constructor( type: TopChartsHelper.Type, chart: Chart, authData: AuthData - ): List { + ): List { val topApps = mutableListOf() withContext(Dispatchers.IO) { val topChartsHelper = TopChartsHelper(authData).using(gPlayHttpClient) topApps.addAll(topChartsHelper.getCluster(type, chart).clusterAppList) } - return topApps + + return topApps.map { + it.toApplication(context) + } } suspend fun getDownloadInfo( diff --git a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt index 6fbf75e99..cdeb0e363 100644 --- a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt @@ -29,7 +29,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import foundation.e.apps.data.cleanapk.ApplicationDeserializer -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import okhttp3.Cache import okhttp3.Interceptor import okhttp3.OkHttpClient @@ -58,7 +58,7 @@ object NetworkModule { @Named("gsonCustomAdapter") fun getGson(): Gson { return GsonBuilder() - .registerTypeAdapter(Application::class.java, ApplicationDeserializer()) + .registerTypeAdapter(CleanApkApplication::class.java, ApplicationDeserializer()) .enableComplexMapKeySerialization() .create() } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 261a9270e..d9183a225 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -143,7 +143,6 @@ App Lounge-Version Über Bitte wähle mindestens eine Quelle von Apps aus. - Entdecke PWA\'s Anonymer Login ist fehlgeschlagen! Das kann verursacht sein, weil ein Server nicht funktioniert. \n @@ -205,4 +204,4 @@ System-App Achtung – Aktualisierung! App Lounge wird vom System beendet, um eine Aktualisierung durchzuführen. Bitte führen Sie keine anderen Aktionen aus, bis App Lounge aktualisert und beendet ist. - \ No newline at end of file + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index ac9f8f586..d33937af0 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -144,7 +144,6 @@ ¡Límite de tiempo buscando aplicaciones! No hay información de rastreo disponible para esta aplicación. Actualización de %1$s aplicaciones completada en %2$s. - Explorar PWA La actualización de %1$s ha fallado debido a una regla de soporte (ubicación, versión del sistema operativo...). Debido a un fallo temporal, no se pueden actualizar todas tus aplicaciones. Vuelve a intentarlo más tarde. Actualizar todo ha fallado. Se harán reintentos automáticos. @@ -203,4 +202,4 @@ Recopilando la clasificación de contenido de todas las aplicaciones que has instalado. Advertencia del contenido La aplicación puede contener desnudos, blasfemias, insultos, violencia, sexualidad intensa, incorrección política u otros temas potencialmente perturbadores. Esto es especialmente importante en entornos como lugares de trabajo, escuelas, entornos religiosos y familiares. - \ No newline at end of file + diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index c254423c8..d5c9371ec 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -146,7 +146,6 @@ \n \nAvaa asetukset ja etsi vain avoimen lähdekoodin sovelluksia tai PWA:ita. Aikakatkaisu sovellusten hakemisessa! - Tutustu PWA:n Päivitysvirhe! Päivitystä ei voida suorittaa koska allekirjoitus on ristiriidassa %1$s ja puhelimeesi asennetun version välillä. Voit korjata tämän poistamalla %1$s ja asentamalla se uudestaan App Loungesta.

Huomautus: Tämä viesti ei tule näkyviin uudelleen.
Google Play -sovelluksia ei voida näyttää, kun vain avoimen lähdekoodin sovellukset ovat valittuna. @@ -171,4 +170,4 @@ PWA ja avoimen lähdekoodin sovellukset Tili ei ole käytettävissä Jakaa - \ No newline at end of file + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 4540074cb..9648fdd15 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -141,7 +141,6 @@ \nOuvrez les paramètres pour n\'afficher que les applications Open Source et PWA.
Expiration du délai de récupération des applications ! Aucune information concernant les pisteurs pour cette application. - PWA à découvrir Erreur lors de la mise à jour ! La mise à jour ne peut être appliquée car la signature de la mise à jour de %1$s ne correspond pas à la signature de la version installée sur votre téléphone. Pour y remédier vous pouvez désinstaller %1$s puis la réinstaller depuis App Lounge.

Note : Ce message ne s\'affichera plus.
Il est impossible d\'afficher les applications Google Play quand seules les applications Open Source sont sélectionnées. @@ -203,4 +202,4 @@ Cliquer sur \"%1$s\" ouvrira un onglet dans votre navigateur avec le nom du paquet de l\'application pré-rempli.<br /><br /> Cliquez sur \"Perform analysis\" pour lancer l\'analyse par Exodus.<br /><br /> Quand le bouton \"See the report\" apparaît (cela peut prendre un moment selon l\'application) vous pouvez fermer l\'onglet et retourner sur la description de l\'application dans %2$s où vous devriez voir la note de Confidentialité. Parfois Exodus peut échouer à analyser l\'application.<br /><br />NB : cela peut prendre jusqu\'à 10 min pour que le score apparaisse dans la description de l\'application. RENOUVELER LA SESSION Application système - \ No newline at end of file + diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 8999fff64..895970e54 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -120,7 +120,6 @@ Af hverju sé ég opnu hugbúnaðarútgáfuna\? Forrit með opinn grunnkóða Öll forrit eru af nýjustu útgáfu - Kynntu þér PWA-vefforrit Vinsæl PWA-vefforrit Vinsælir PWA-leikir Næ ekki að tengjast! Athugaðu internettenginguna þína og prófaðu svo aftur @@ -204,4 +203,4 @@ Kerfisforrit Aðvörun vegna uppfærslu! App Lounge verður lokað af kerfinu á meðan það uppfærir sjálft sig. Vertu helst ekki að gera neitt annað þangað til uppfærslu App Lounge er lokið. - \ No newline at end of file + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d5505806e..d7ad59044 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -153,7 +153,6 @@ \nPuoi riprovare adesso o più tardi. Si è verificato un errore durante il caricamento delle App. Maggiori informazioni - Scopri le PWA Non posso avviare l\'App Google Play se sono permesse solo App open source. Chiudi Mensilmente @@ -203,4 +202,4 @@ Avviso sui contenuti App Lounge verrà chiusa dal sistema mentre installa l\'aggiornamento. Si prega di non effettuare alcuna attività su App Lounge finchè non sarà aggiornata e chiusa. Avviso sull\'aggiornamento! - \ No newline at end of file + diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index cb3ade70c..31cafe15c 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -52,7 +52,6 @@ Applikasjonsoppdateringer vil bli installert automatisk Oppdateringer Nedlastinger - Oppdag PWA Oppdag %1$s sin oppdatering har mislyktes på grunn av et misforhold (lokasjon, operativsystemversjon…). På gunn av en midlertidig feil kan ikke alle dine applikasjoner bli oppdatert. Prøv igjen senere. @@ -202,4 +201,4 @@ Systemapplikasjon Innholdsvarsel Samler innholdsvurdering for alle applikasjonene du har installert. - \ No newline at end of file + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 35a1480f3..34d1afb76 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -47,7 +47,6 @@ Top Gratis Apps PWA Populaire Spellen PWA Populaire Apps - Ontdek PWA Ontdek Update Fout! Alle apps zijn up-to-date @@ -204,4 +203,4 @@ Deze app kan naaktheid, godslastering, laster, geweld, seksualiteit, politieke incorrectheid of andere mogelijk ongepaste onderwerpen bevatten. Dit is voornamelijk relevant in omgevingen als werkplekken, scholen, religieuze instellingen en gezinnen. Attentie, update! App Lounge zal door het systeem afgesloten worden tijdens zijn update. Voer a.u.b. geen andere taken uit totdat App Lounge geüpdatet en afgesloten is. - \ No newline at end of file + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 32c8bdcb9..81bd63daa 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -123,7 +123,6 @@ Топ Open Source обновленных игр Топ обновленных Open Source приложений Откройте для себя - Откройте для себя PWA Обновление %1$s не произошло из-за поддержки (местоположения, версии ОС...). Из-за временного сбоя все ваши приложения не могут быть обновлены. Пожалуйста, повторите попытку позже. Обновить всё не удалось. Выполняются автоматические повторные попытки. @@ -204,4 +203,4 @@ Запросить исходный отчёт Анонимная учетная запись, которую вы используете в данный момент, недоступна. Пожалуйста, обновите сессию, чтобы получить другую. ОБНОВИТЬ СЕССИИ - \ No newline at end of file + diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ba3250eab..b8b30a5cd 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -110,7 +110,6 @@ Välj åtminstone en källa av applikationer. Integritetsanalys Har du problem\? - Upptäck PWA Populäraste apparna de senaste 24 timmarna med öppen källkod Populäraste spelen de senaste 24 timmarna med öppen källkod Populära PWA-appar @@ -204,4 +203,4 @@ Systemapp Varning för uppdatering! Systemet kommer stänga App Lounge medan uppdatering installeras för App Lounge. Undvik att något annat tills App Lounge är uppdaterat och har stängts. - \ No newline at end of file + diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index e11370dde..f880ad516 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -85,7 +85,6 @@ Geçici bir arıza nedeniyle uygulamalarınızın tümü güncellenemiyor. Lütfen daha sonra tekrar deneyin. %1$s güncellemesi bir destek kuralı (konum, işletim sistemi sürümü...) nedeniyle başarısız oldu. Keşfet - PWA\'ları keşfedin Açık Kaynaklı Tutan Güncel Oyunlar Açık Kaynaklı Tutan Güncel Uygulamalar Son 24 Saatte Açık Kaynaklı Popüler Uygulamalar @@ -187,4 +186,4 @@ \n \nTekrar denemek için Yeniden Dene\'ye basın. %s ekstra modüller yüklemek istiyor. Bunları yükleyebilmek için AppLounge\'da tekrar oturum açmalısınız. - \ No newline at end of file + diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index c40f460a8..48ad42615 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -97,7 +97,6 @@ Оновлення не вдалося. Автоматичні повторні спроби уже в процесі. Трендові додатки в Топі Безкоштовні ігри в Топі - Дослідити PWA Дослідити %1$d оновлення застосунку доступне @@ -174,4 +173,4 @@ Зареєструватися Обліковий запис недоступний Поділитися - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa41bcdf6..417781487 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,7 +147,6 @@ App Lounge will be closed by the system while installing its own update. Kindly refrain from doing any other task till App Lounge is updated and closed. Discover - Discover PWA Open Source Top Updated Apps Open Source Top Updated Games Open Source Popular Apps In Last 24 Hours diff --git a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt index 196420071..8ba827284 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -21,11 +21,11 @@ package foundation.e.apps.home import android.content.Context import android.text.format.Formatter import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.home.HomeApi import foundation.e.apps.data.application.home.HomeApiImpl import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository @@ -112,13 +112,13 @@ class HomeApiTest { @Test fun testHomeScreenDataWhenDataIsLimited() = runTest { - val newAppList = mutableListOf( - App("foundation.e.demoone"), - App("foundation.e.demotwo"), - App("foundation.e.demothree"), + val newAppList = mutableListOf( + Application("foundation.e.demoone"), + Application("foundation.e.demotwo"), + Application("foundation.e.demothree"), ) - var newHomeData = mapOf>(Pair("Top Free Apps", newAppList)) + val newHomeData = mapOf>(Pair("Top Free Apps", newAppList)) preferenceManagerModule.isGplaySelectedFake = true formatterMocked.`when` { Formatter.formatFileSize(any(), any()) }.thenReturn("15MB") -- GitLab From 865c4604849b24c6ab9efbe8fc4047788944496c Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 22 Oct 2024 11:51:57 +0200 Subject: [PATCH 2/6] Introduce HomeConverter --- .../apps/data/application/home/HomeApiImpl.kt | 69 ----------------- .../repositories/CleanApkAppsRepository.kt | 69 +---------------- .../repositories/CleanApkPwaRepository.kt | 67 +--------------- .../cleanapk/repositories/HomeConverter.kt | 76 +++++++++++++++++++ 4 files changed, 80 insertions(+), 201 deletions(-) create mode 100644 app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt diff --git a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index 56e2fd965..6ed63a29c 100644 --- a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt @@ -19,22 +19,16 @@ package foundation.e.apps.data.application.home import android.content.Context -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.liveData -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.application.ApplicationDataManager -import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.application.search.FusedHomeDeferred import foundation.e.apps.data.application.search.SearchApi -import foundation.e.apps.data.application.utils.toApplication -import foundation.e.apps.data.cleanapk.data.home.HomeScreenResponse import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.handleNetworkResult @@ -46,10 +40,8 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch -import retrofit2.Response import timber.log.Timber import javax.inject.Inject -import foundation.e.apps.data.cleanapk.data.home.CleanApkHome class HomeApiImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -211,65 +203,4 @@ class HomeApiImpl @Inject constructor( ) } } - - private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { - val list = mutableListOf() - - openSourceCategories.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(cleanApkHome.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - - private val openSourceCategories: Map by lazy { - mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "popular_apps" to context.getString(R.string.popular_apps), - "popular_games" to context.getString(R.string.popular_games), - "discover" to context.getString(R.string.discover) - ) - } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index d17eb49b5..1085c9dd6 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -19,25 +19,20 @@ package foundation.e.apps.data.cleanapk.repositories import android.content.Context -import android.util.Log import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R -import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.data.Application -import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.download.Download -import foundation.e.apps.data.cleanapk.data.home.CleanApkHome import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkAppsRepository @Inject constructor( private val cleanApkRetrofit: CleanApkRetrofit, - private val applicationDataManager: ApplicationDataManager, + private val homeConverter: HomeConverter, @ApplicationContext val context: Context ) : CleanApkRepository, CleanApkDownloadInfoFetcher { @@ -49,8 +44,7 @@ class CleanApkAppsRepository @Inject constructor( ) val home = response.body()?.home ?: throw IllegalStateException("No home data found") - - val listHome = toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) + val listHome = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) val map = mutableMapOf>() listHome.forEach { map[it.title] = it.list @@ -59,55 +53,6 @@ class CleanApkAppsRepository @Inject constructor( return map } - private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { - val list = mutableListOf() - - openSourceCategories.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(cleanApkHome.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - override suspend fun getSearchResult(query: String, searchBy: String?): Response { return cleanApkRetrofit.searchApps( query, @@ -151,14 +96,4 @@ class CleanApkAppsRepository @Inject constructor( val version = versionCode?.let { it as String } return cleanApkRetrofit.getDownloadInfo(idOrPackageName, version, null) } - - private val openSourceCategories: Map by lazy { - mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "discover" to context.getString(R.string.discover) - ) - } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index 85485bfb1..cf235f30f 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -20,21 +20,17 @@ package foundation.e.apps.data.cleanapk.repositories import android.content.Context import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R -import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.data.Application -import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories -import foundation.e.apps.data.cleanapk.data.home.CleanApkHome import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkPwaRepository @Inject constructor( private val cleanAPKRetrofit: CleanApkRetrofit, - private val applicationDataManager: ApplicationDataManager, + private val homeConverter: HomeConverter, @ApplicationContext val context: Context ) : CleanApkRepository { @@ -46,7 +42,7 @@ class CleanApkPwaRepository @Inject constructor( val home = response.body()?.home ?: throw IllegalStateException("No home data found") - val listHome = toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) + val listHome = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) val map = mutableMapOf>() listHome.forEach { map[it.title] = it.list @@ -55,55 +51,6 @@ class CleanApkPwaRepository @Inject constructor( return map } - private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { - val list = mutableListOf() - - openSourceCategories.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(cleanApkHome.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - override suspend fun getSearchResult(query: String, searchBy: String?): Response { return cleanAPKRetrofit.searchApps( query, @@ -139,14 +86,4 @@ class CleanApkPwaRepository @Inject constructor( override suspend fun getAppDetails(packageNameOrId: String): Response { return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) } - - private val openSourceCategories: Map by lazy { - mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "discover" to context.getString(R.string.discover) - ) - } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt new file mode 100644 index 000000000..d2bfc0dab --- /dev/null +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt @@ -0,0 +1,76 @@ +package foundation.e.apps.data.cleanapk.repositories + +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.R +import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Home +import foundation.e.apps.data.cleanapk.data.home.CleanApkHome +import javax.inject.Inject + +class HomeConverter @Inject constructor( + @ApplicationContext val context: Context, + private val applicationDataManager: ApplicationDataManager +) { + + suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { + val list = mutableListOf() + + openSourceCategories.forEach { (key, value) -> + when (key) { + "top_updated_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) + } + + "top_updated_games" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) + } + + "popular_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) + } + + "popular_games" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) + } + + "popular_apps_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_apps_in_last_24_hours, + list, + value + ) + } + + "popular_games_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_games_in_last_24_hours, + list, + value + ) + } + + "discover" -> { + applicationDataManager.prepareApps(cleanApkHome.discover, list, value) + } + } + } + + return list.map { + it.source = appType + it + } + } + + private val openSourceCategories: Map by lazy { + mapOf( + "top_updated_apps" to context.getString(R.string.top_updated_apps), + "top_updated_games" to context.getString(R.string.top_updated_games), + "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), + "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), + "popular_apps" to context.getString(R.string.popular_apps), + "popular_games" to context.getString(R.string.popular_games), + "discover" to context.getString(R.string.discover) + ) + } +} \ No newline at end of file -- GitLab From c6c6f12207b96404caa2ca0e63afa9d06d765145 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 23 Oct 2024 08:47:27 +0200 Subject: [PATCH 3/6] Sanitize getAppDetails() calls --- .../foundation/e/apps/data/StoreRepository.kt | 2 +- .../apps/data/application/apps/AppsApiImpl.kt | 13 +++++------- .../repositories/CleanApkAppsRepository.kt | 5 +++-- .../repositories/CleanApkPwaRepository.kt | 5 +++-- .../data/playstore/PlayStoreRepository.kt | 20 +++++++++---------- .../foundation/e/apps/apps/AppsApiTest.kt | 17 ++++++++-------- .../e/apps/fused/SearchApiImplTest.kt | 10 +++++----- .../foundation/e/apps/home/HomeApiTest.kt | 2 +- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt index 4a9930756..e1c04d98e 100644 --- a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt @@ -22,5 +22,5 @@ import foundation.e.apps.data.application.data.Application interface StoreRepository { suspend fun getHomeScreenData(): Map> - suspend fun getAppDetails(packageNameOrId: String): Any? + suspend fun getAppDetails(packageNameOrId: String): Application } diff --git a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt index 835c3babe..beb4238d9 100644 --- a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt @@ -60,8 +60,7 @@ class AppsApiImpl @Inject constructor( if (result?.hasSingleResult() == true) { application = - (appSources.cleanApkAppsRepo.getAppDetails(result.apps[0]._id) - as Response).body()?.app ?: Application() + appSources.cleanApkAppsRepo.getAppDetails(result.apps[0]._id) } application.updateFilterLevel(null) @@ -189,18 +188,16 @@ class AppsApiImpl @Inject constructor( authData: AuthData, origin: Origin ): Pair { - var application: Application? + var application: Application val result = handleNetworkResult { application = if (origin == Origin.CLEANAPK) { - (appSources.cleanApkAppsRepo.getAppDetails(id) - as Response).body()?.app + appSources.cleanApkAppsRepo.getAppDetails(id) } else { - val app = appSources.gplayRepo.getAppDetails(packageName) as App? - app?.toApplication(context) + appSources.gplayRepo.getAppDetails(packageName) } - application?.let { + application.let { applicationDataManager.updateStatus(it) it.updateType() it.updateSource(context) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index 1085c9dd6..813dd90c4 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -88,8 +88,9 @@ class CleanApkAppsRepository @Inject constructor( return cleanApkRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + override suspend fun getAppDetails(packageNameOrId: String): Application { + val response = cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return response.body()?.app ?: throw IllegalStateException("No app data found") } override suspend fun getDownloadInfo(idOrPackageName: String, versionCode: Any?): Response { diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index cf235f30f..70da71375 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -83,7 +83,8 @@ class CleanApkPwaRepository @Inject constructor( return cleanAPKRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + override suspend fun getAppDetails(packageNameOrId: String): Application { + val response = cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return response.body()?.app ?: throw IllegalStateException("No app data found") } } diff --git a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt index 5b7b650a8..22e0d88b7 100644 --- a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt @@ -19,9 +19,8 @@ package foundation.e.apps.data.playstore import android.content.Context -import android.util.Log import com.aurora.gplayapi.SearchSuggestEntry -import com.aurora.gplayapi.data.models.App +import com.aurora.gplayapi.data.models.App as GplayApp import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.data.models.Category import com.aurora.gplayapi.data.models.ContentRating @@ -84,7 +83,7 @@ class PlayStoreRepository @Inject constructor( fun getSearchResult( query: String, subBundle: MutableSet? - ): Pair, MutableSet> { + ): Pair, MutableSet> { val authData = authenticatorRepository.getGPlayAuthOrThrow() val searchHelper = SearchHelper(authData).using(gPlayHttpClient) @@ -103,7 +102,7 @@ class PlayStoreRepository @Inject constructor( private fun getSearchResultPair( searchBundle: SearchBundle, query: String - ): Pair, MutableSet> { + ): Pair, MutableSet> { val apps = searchBundle.appList Timber.d("Found ${apps.size} apps for query, $query") return Pair(apps, searchBundle.subBundles) @@ -147,19 +146,20 @@ class PlayStoreRepository @Inject constructor( return categoryList } - override suspend fun getAppDetails(packageNameOrId: String): App? { - var appDetails: App? + override suspend fun getAppDetails(packageNameOrId: String): Application { + var appDetails: GplayApp? val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) } - return appDetails + + return appDetails?.toApplication(context) ?: Application() } - suspend fun getAppsDetails(packageNamesOrIds: List): List { - val appDetailsList = mutableListOf() + suspend fun getAppsDetails(packageNamesOrIds: List): List { + val appDetailsList = mutableListOf() val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { @@ -179,7 +179,7 @@ class PlayStoreRepository @Inject constructor( chart: Chart, authData: AuthData ): List { - val topApps = mutableListOf() + val topApps = mutableListOf() withContext(Dispatchers.IO) { val topChartsHelper = TopChartsHelper(authData).using(gPlayHttpClient) topApps.addAll(topChartsHelper.getCluster(type, chart).clusterAppList) diff --git a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt index 1dc1ce734..8cda6e3cf 100644 --- a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt +++ b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt @@ -22,7 +22,6 @@ import android.content.Context import android.text.format.Formatter import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.aurora.gplayapi.Constants -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer @@ -121,7 +120,7 @@ class AppsApiTest { @Test fun `is any app updated when new list is empty`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -155,7 +154,7 @@ class AppsApiTest { @Test fun `is any app updated when any app is uninstalled`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -176,7 +175,7 @@ class AppsApiTest { ) ) - val newAppList = mutableListOf( + val newAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -203,7 +202,7 @@ class AppsApiTest { @Test fun `has any app install status changed when changed`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -264,7 +263,7 @@ class AppsApiTest { @Test fun `has any app install status changed when not changed`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -325,7 +324,7 @@ class AppsApiTest { @Test fun `has any app install status changed when installation_issue`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.INSTALLATION_ISSUE, @@ -492,7 +491,7 @@ class AppsApiTest { } Mockito.`when`(gPlayAPIRepository.getAppDetails(fusedApp.package_name)) - .thenReturn(App(fusedApp.package_name)) + .thenReturn(Application(fusedApp.package_name)) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( @@ -534,7 +533,7 @@ class AppsApiTest { } Mockito.`when`(gPlayAPIRepository.getAppDetails(fusedApp.package_name)) - .thenReturn(App(fusedApp.package_name)) + .thenReturn(Application(fusedApp.package_name)) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( diff --git a/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt b/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt index 3337aea51..3bb56cea6 100644 --- a/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt +++ b/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt @@ -148,7 +148,7 @@ class SearchApiImplTest { @Ignore("Dependencies are not mockable") @Test fun `getSearchResult When all sources are selected`() = runTest { - val appList = mutableListOf( + val appList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -174,7 +174,7 @@ class SearchApiImplTest { val searchResult = Search(apps = appList, numberOfResults = 3, success = true) val packageNameSearchResponse = Response.success(searchResult) - val gplayPackageResult = App("com.search.package") + val gplayPackageResult = Application("com.search.package") preferenceManagerModule.isPWASelectedFake = true preferenceManagerModule.isOpenSourceelectedFake = true @@ -196,7 +196,7 @@ class SearchApiImplTest { private suspend fun setupMockingSearchApp( packageNameSearchResponse: Response?, - gplayPackageResult: App, + gplayPackageResult: Application, gplayLivedata: Pair, MutableSet>, willThrowException: Boolean = false ) { @@ -231,7 +231,7 @@ class SearchApiImplTest { ).thenReturn(packageNameSearchResponse) Mockito.`when`(cleanApkAppsRepository.getAppDetails(any())) - .thenReturn(Response.error(404, "".toResponseBody())) + .thenReturn(Application()) Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null)) .thenReturn(gplayLivedata) @@ -266,7 +266,7 @@ class SearchApiImplTest { val searchResult = Search(apps = appList, numberOfResults = 1, success = true) val packageNameSearchResponse = Response.success(searchResult) - val gplayPackageResult = App("com.search.package") + val gplayPackageResult = Application("com.search.package") val gplayFlow: Pair, MutableSet> = Pair( listOf(App("a.b.c"), App("c.d.e"), App("d.e.f"), App("d.e.g")), mutableSetOf() diff --git a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt index 8ba827284..ab9348c97 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -124,7 +124,7 @@ class HomeApiTest { formatterMocked.`when` { Formatter.formatFileSize(any(), any()) }.thenReturn("15MB") Mockito.`when`(gPlayAPIRepository.getHomeScreenData()).thenReturn(newHomeData) Mockito.`when`(gPlayAPIRepository.getAppDetails(ArgumentMatchers.anyString())).thenReturn( - App("foundation.e.demothree") + Application("foundation.e.demothree") ) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( -- GitLab From ec72e191e8185a558ed949b18214d75ccaed65c1 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 24 Oct 2024 11:38:20 +0200 Subject: [PATCH 4/6] Some renaming --- .../repositories/CleanApkPwaRepository.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index 70da71375..edf52f91e 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -22,20 +22,19 @@ import android.content.Context import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkPwaRepository @Inject constructor( - private val cleanAPKRetrofit: CleanApkRetrofit, + private val cleanApkRetrofit: CleanApkRetrofit, private val homeConverter: HomeConverter, @ApplicationContext val context: Context ) : CleanApkRepository { override suspend fun getHomeScreenData(): Map> { - val response = cleanAPKRetrofit.getHomeScreenData( + val response = cleanApkRetrofit.getHomeScreenData( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) @@ -52,7 +51,7 @@ class CleanApkPwaRepository @Inject constructor( } override suspend fun getSearchResult(query: String, searchBy: String?): Response { - return cleanAPKRetrofit.searchApps( + return cleanApkRetrofit.searchApps( query, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -63,7 +62,7 @@ class CleanApkPwaRepository @Inject constructor( } override suspend fun getAppsByCategory(category: String, paginationParameter: Any?): Response { - return cleanAPKRetrofit.listApps( + return cleanApkRetrofit.listApps( category, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -73,18 +72,18 @@ class CleanApkPwaRepository @Inject constructor( } override suspend fun getCategories(): Response { - return cleanAPKRetrofit.getCategoriesList( + return cleanApkRetrofit.getCategoriesList( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) } override suspend fun checkAvailablePackages(packageNames: List): Response { - return cleanAPKRetrofit.checkAvailablePackages(packageNames) + return cleanApkRetrofit.checkAvailablePackages(packageNames) } override suspend fun getAppDetails(packageNameOrId: String): Application { - val response = cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + val response = cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) return response.body()?.app ?: throw IllegalStateException("No app data found") } } -- GitLab From a6827ab7cc4f42f9910ebb6e8cd4467df0b6f813 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 25 Oct 2024 13:37:29 +0200 Subject: [PATCH 5/6] Remove useless context parameter --- .../apps/data/cleanapk/repositories/CleanApkAppsRepository.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index 813dd90c4..b97b3ce30 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -32,8 +32,7 @@ import javax.inject.Inject class CleanApkAppsRepository @Inject constructor( private val cleanApkRetrofit: CleanApkRetrofit, - private val homeConverter: HomeConverter, - @ApplicationContext val context: Context + private val homeConverter: HomeConverter ) : CleanApkRepository, CleanApkDownloadInfoFetcher { override suspend fun getHomeScreenData(): Map> { -- GitLab From 178cb995cb58477b37cd6cc5faf546abf8d28cdf Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 25 Oct 2024 14:42:08 +0200 Subject: [PATCH 6/6] Remove useless empty catogories on home page --- .../data/cleanapk/data/home/CleanApkHome.kt | 2 -- .../cleanapk/repositories/HomeConverter.kt | 18 ------------------ app/src/main/res/values-de/strings.xml | 2 -- app/src/main/res/values-es/strings.xml | 2 -- app/src/main/res/values-fi/strings.xml | 2 -- app/src/main/res/values-fr/strings.xml | 2 -- app/src/main/res/values-is/strings.xml | 2 -- app/src/main/res/values-it/strings.xml | 2 -- app/src/main/res/values-nb-rNO/strings.xml | 2 -- app/src/main/res/values-nl/strings.xml | 2 -- app/src/main/res/values-ru/strings.xml | 2 -- app/src/main/res/values-sv/strings.xml | 2 -- app/src/main/res/values-tr/strings.xml | 2 -- app/src/main/res/values-uk/strings.xml | 2 -- app/src/main/res/values/strings.xml | 2 -- 15 files changed, 46 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt index 1647a00eb..7118307be 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt @@ -26,8 +26,6 @@ data class CleanApkHome( val top_updated_games: List = emptyList(), val popular_apps: List = emptyList(), val popular_games: List = emptyList(), - val popular_apps_in_last_24_hours: List = emptyList(), - val popular_games_in_last_24_hours: List = emptyList(), val discover: List = emptyList(), var origin: Origin = Origin.CLEANAPK // Origin ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt index d2bfc0dab..a5ecafbfc 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt @@ -34,22 +34,6 @@ class HomeConverter @Inject constructor( applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) } - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - "discover" -> { applicationDataManager.prepareApps(cleanApkHome.discover, list, value) } @@ -66,8 +50,6 @@ class HomeConverter @Inject constructor( mapOf( "top_updated_apps" to context.getString(R.string.top_updated_apps), "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), "popular_apps" to context.getString(R.string.popular_apps), "popular_games" to context.getString(R.string.popular_games), "discover" to context.getString(R.string.discover) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index d9183a225..09e7cd96a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -72,8 +72,6 @@ Entdecke Top quelloffene aktualisierte Apps Top quelloffene aktualisierte Spiele - Beliebteste quelloffene Apps in den letzten 24 Stunden - Beliebteste quelloffene Spiele in den letzten 24 Stunden PWA beliebteste Apps PWA beliebteste Spiele Top kostenlose Apps diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d33937af0..5e80a9a8b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -76,8 +76,6 @@ Explorar Aplicaciones de código abierto más actualizadas Juegos de código abierto más actualizados - Juegos de código abierto más populares en las últimas 24 horas - Aplicaciones de código abierto más populares en las últimas 24 horas Aplicaciones PWA populares Juegos PWA populares Las mejores aplicaciones gratuitas diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index d5c9371ec..ad26a3cfb 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -110,8 +110,6 @@ Top ilmaiset sovellukset PWA Suositut pelit PWA Suositut sovellukset - Suosittuja avoimen lähdekoodin pelejä viimeisen 24 tunnin aikana - Suosittuja avoimen lähdekoodin sovelluksia viimeisen 24 tunnin aikana Avoimen lähdekoodin päivitettyjen pelien Top lista Avoimen lähdekoodin päivitettyjen sovellusten Top lista Tutustu diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9648fdd15..c5f7fe1f2 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -71,8 +71,6 @@ Découvrir Top des apps Open Source mises à jour Top des jeux Open Source mis à jour - Jeux populaires Open Source dans les dernières 24h - Apps populaires Open Source dans les dernières 24 h Apps PWA populaires Jeux PWA populaires Top des apps gratuites diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 895970e54..05fdf538a 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -133,8 +133,6 @@ Vinsælustu uppfærðu forritin með opinn grunnkóða Vinsælustu uppfærðir leikir með opinn grunnkóða Vinsælustu ókeypis og frjálsu forritin - Vinsæl forrit síðasta sólahring með opinn grunnkóða - Vinsæla leiki síðasta sólahring með opinn grunnkóða Vinsælustu ókeypis og frjálsu leikirnir Forrit með mestu innkomuna Leikir með mestu innkomuna diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d7ad59044..fdee09cff 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -75,8 +75,6 @@ Errore sconosciuto! Aggiorna tutto Scopri - App Open Source più richieste nelle ultime 24 ore - Giochi Open Source più richiesti nelle ultime 24 ore App PWA più richieste Giochi PWA più richiesti Migliori App Open Source aggiornate diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 31cafe15c..4ad70dd98 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -163,9 +163,7 @@ Topp gratis applikasjoner Mest populære spill Topp gratis spill - Populære åpen kildekode-applikasjoner de siste 24 timer Populære PWA spill - Populære åpen kildekode-spill de siste 24 timer Mest innbringende applikasjoner Mest innbringende spill Ingen sporingsinformasjon tilgjengelig for denne applikasjonen. diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 34d1afb76..b8887c22f 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -151,8 +151,6 @@ Geen \"runtime android\" machtiging gevonden! Top Populaire Games Top Populaire Apps - Open Source Populaire Games van de laatste 24 uur - Open Source Populaire Apps van de laatste 24 uur Open Source Top Geüpdatete Games Open Source Top Geüpdatet Apps De update voor %1$s is niet door een ondersteuning regel (locatie, OS versie...). diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 81bd63daa..827fb00d8 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -118,8 +118,6 @@ Топ бесплатных приложений Популярные PWA игры Популярные PWA приложения - Популярные Open Source игры за последние 24 часа - Популярные Open Source приложения за последние 24 часа Топ Open Source обновленных игр Топ обновленных Open Source приложений Откройте для себя diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b8b30a5cd..aa11e72a7 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -110,8 +110,6 @@ Välj åtminstone en källa av applikationer. Integritetsanalys Har du problem\? - Populäraste apparna de senaste 24 timmarna med öppen källkod - Populäraste spelen de senaste 24 timmarna med öppen källkod Populära PWA-appar Populära PWA-spel Hämtningar diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index f880ad516..c8afa6a5e 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -87,8 +87,6 @@ Keşfet Açık Kaynaklı Tutan Güncel Oyunlar Açık Kaynaklı Tutan Güncel Uygulamalar - Son 24 Saatte Açık Kaynaklı Popüler Uygulamalar - Son 24 Saatin Popüler Açık Kaynak Oyunları PWA popüler uygulamalar PWA Popüler Uygulamalar En Çok Kazanan Uygulamalar diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 48ad42615..a02f1f8a6 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -121,8 +121,6 @@ Топ безкоштовних ігор Популярні прогресивні веб-ігри Популярні прогресивні веб-застосунки - Популярні ігри з відкритим кодом за останню добу - Популярні додатки з відкритим кодом за останню добу Топ оновлених Ігор з відкритим кодом Топ оновлених додатків з відкритим кодом Оновлення %1$s не вдалося з причини підтримки (наприклад місцезнаходження, версія ОС…). diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 417781487..94f39e423 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,8 +149,6 @@ Discover Open Source Top Updated Apps Open Source Top Updated Games - Open Source Popular Apps In Last 24 Hours - Open Source Popular Games In Last 24 Hours PWA Popular Apps PWA Popular Games Top Free Apps -- GitLab