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 0f8e1e426c64c77e188da2034144dd184235a017..e1c04d98e371777d4f7278de0318ca78535a6841 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 getAppDetails(packageNameOrId: String): Any? + suspend fun getHomeScreenData(): Map> + 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 e4847beced933d98557325c576edf5aea4a854e1..beb4238d951e857f4963b51334a6afbc2441bdc0 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, @@ -61,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) @@ -190,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/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index 53a4024276f1a9cd564337967f7d6f1fecffd79b..6ed63a29c8319ef3ef640269c5cec955f80bead3 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 @@ -21,18 +21,14 @@ package foundation.e.apps.data.application.home import android.content.Context 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.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.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.handleNetworkResult @@ -44,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.Home as CleanApkHome class HomeApiImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -142,87 +136,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 +165,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) } @@ -277,5 +203,4 @@ class HomeApiImpl @Inject constructor( ) } } - } 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 5d9b3910bef7caa82031b8ba1bead5754d493cb9..b5c69ee734d5f01da702f5ddda33e2d0ec0089ce 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 3da3d4014c5d119b0b23b1d3bfb72832fe78f6e8..1e88833987942f8df0af439aecdabfd83bab0400 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 906d9b2d0a17384ff555de8830d6f01756472513..4ba0b0c7b5a79ad3296059d33a9b835bd1b2754e 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 86% 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 8e50e09c383b1ab92f15c25c3b7650a06a4e44dc..7118307bed1fb092e5a35f0e7c272d0949e5cd88 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,13 +21,11 @@ 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(), 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/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 27d0f7db4f115c2b493d5596a812f9c526054f4e..9c64a8a752248048f4340bdc6d7405f314facaea 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 8a5c09372f910939b95871f2dcf7cb156c8e75d9..b97b3ce301573483c072b9021990feda76ab1cdd 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,38 @@ package foundation.e.apps.data.cleanapk.repositories +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.data.application.data.Application 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.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkAppsRepository @Inject constructor( - private val cleanApkRetrofit: CleanApkRetrofit + private val cleanApkRetrofit: CleanApkRetrofit, + private val homeConverter: HomeConverter ) : 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 = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) + val map = mutableMapOf>() + listHome.forEach { + map[it.title] = it.list + } + + return map } override suspend fun getSearchResult(query: String, searchBy: String?): Response { @@ -74,8 +87,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 2f1f00dd2bc2eea51fb033b001b11c78497f2913..edf52f91e318cf10b35949471dc3d199e1600ec5 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,26 +18,40 @@ package foundation.e.apps.data.cleanapk.repositories +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.Application 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(): 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 = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) + val map = mutableMapOf>() + listHome.forEach { + map[it.title] = it.list + } + + return map } override suspend fun getSearchResult(query: String, searchBy: String?): Response { - return cleanAPKRetrofit.searchApps( + return cleanApkRetrofit.searchApps( query, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -48,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, @@ -58,17 +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): 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/cleanapk/repositories/HomeConverter.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt new file mode 100644 index 0000000000000000000000000000000000000000..a5ecafbfcbb06d7218a633e577c48883202406e2 --- /dev/null +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt @@ -0,0 +1,58 @@ +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) + } + + "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" 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 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 3065874e2ab39b15c2492d9d1cd4ad69f9461f80..22e0d88b7d49db73fbd94e3e992eb6db0b5c8b5e 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 @@ -20,7 +20,7 @@ package foundation.e.apps.data.playstore import android.content.Context 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 @@ -38,7 +38,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 +54,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() @@ -81,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) @@ -100,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) @@ -144,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) { @@ -175,13 +178,16 @@ class PlayStoreRepository @Inject constructor( type: TopChartsHelper.Type, chart: Chart, authData: AuthData - ): List { - val topApps = mutableListOf() + ): 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 6fbf75e992aecfa62bbfd5070412e21312e9db57..cdeb0e363459775920d9e9ad6dffd030804356fc 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 261a9270e025ca93826ed2ec60df0c9703f5ed35..09e7cd96a96abf7461a9cc7ed64e0511802a311e 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 @@ -143,7 +141,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 +202,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 ac9f8f58659b636eafdd00914d8ae24164f5a6a9..5e80a9a8b34b05bc374d9464841ef8a661a43dea 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 @@ -144,7 +142,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 +200,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 c254423c87db3d8e86f49e1d4c740dfcd0cd4b4b..ad26a3cfbe04e0c71cdc87dcbe1a0761d72a4a17 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 @@ -146,7 +144,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 +168,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 4540074cb786664817228f9b38b9c73a4f52652c..c5f7fe1f20693cd7ade12257f753b63494fe9d59 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 @@ -141,7 +139,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 +200,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 8999fff64b5384b4d1330294bdd932d8dd03d2a2..05fdf538a3aadd6566a3412fee956f39c072a17d 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 @@ -134,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 @@ -204,4 +201,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 d5505806e1d19b2075318f6b11152fac47740507..fdee09cffa96d6323a8976a91b079df5628ada6b 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 @@ -153,7 +151,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 +200,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 cb3ade70cc24cb026de6a77960adef04248ccf98..4ad70dd981e159fbad82b96942d569655c251f8b 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. @@ -164,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. @@ -202,4 +199,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 35a1480f330d0e4f0fb67936f3fd648967e21583..b8887c22fd8f9b585961de8e78c50b8e6eb0b2e2 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 @@ -152,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...). @@ -204,4 +201,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 32c8bdcb9d47031fe0f3747b7bc6695f5a7481c9..827fb00d85242c0836e4373bc057436629e7d7bf 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -118,12 +118,9 @@ Топ бесплатных приложений Популярные PWA игры Популярные PWA приложения - Популярные Open Source игры за последние 24 часа - Популярные Open Source приложения за последние 24 часа Топ Open Source обновленных игр Топ обновленных Open Source приложений Откройте для себя - Откройте для себя PWA Обновление %1$s не произошло из-за поддержки (местоположения, версии ОС...). Из-за временного сбоя все ваши приложения не могут быть обновлены. Пожалуйста, повторите попытку позже. Обновить всё не удалось. Выполняются автоматические повторные попытки. @@ -204,4 +201,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 ba3250eab292960ca315774c229cf6d73e6d5e96..aa11e72a775f610cfca6777ab8197f3d4c78473f 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -110,9 +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 Populära PWA-spel Hämtningar @@ -204,4 +201,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 e11370dde7d72d87fcb736922f710a13138cc272..c8afa6a5e4c8e1554e9ae8b2507a66403246570a 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -85,11 +85,8 @@ 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 - Son 24 Saatin Popüler Açık Kaynak Oyunları PWA popüler uygulamalar PWA Popüler Uygulamalar En Çok Kazanan Uygulamalar @@ -187,4 +184,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 c40f460a8a0ce83df6f29105774f149f6a92ce9a..a02f1f8a6a7635f65400ef2ffc74dd455c525a8f 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 оновлення застосунку доступне @@ -122,8 +121,6 @@ Топ безкоштовних ігор Популярні прогресивні веб-ігри Популярні прогресивні веб-застосунки - Популярні ігри з відкритим кодом за останню добу - Популярні додатки з відкритим кодом за останню добу Топ оновлених Ігор з відкритим кодом Топ оновлених додатків з відкритим кодом Оновлення %1$s не вдалося з причини підтримки (наприклад місцезнаходження, версія ОС…). @@ -174,4 +171,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 fa41bcdf6112f70981e43b1cec523b8900253c62..94f39e423e88aba14fa953f2acf380f485b46b09 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,11 +147,8 @@ 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 - Open Source Popular Games In Last 24 Hours PWA Popular Apps PWA Popular Games Top Free Apps 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 1dc1ce734813fa78f25a9775186b49a4d20b7b8e..8cda6e3cff0d20e7da276b0d901644618b302273 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 3337aea51549988eb66ec6f5c348bcdee7765129..3bb56cea6c3ac1584290c6e5dc02cdcac6167195 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 19642007134249d0916386548d7c784e4ccdf8c3..ab9348c9713c72b360e316edad42050b292c02ce 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,19 +112,19 @@ 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") 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(