From 662145424de004320d63128486acc8e55b1e1d3e Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 16 Oct 2024 14:39:26 +0200 Subject: [PATCH 01/17] Rename consistently --- ...leanApkAppsRepositoryImpl.kt => CleanApkAppsRepository.kt} | 2 +- .../main/java/foundation/e/apps/di/NamedRepositoryModule.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename app/src/main/java/foundation/e/apps/data/cleanapk/repositories/{CleanApkAppsRepositoryImpl.kt => CleanApkAppsRepository.kt} (98%) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt similarity index 98% rename from app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepositoryImpl.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index e51a82823..e06125ad4 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepositoryImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -28,7 +28,7 @@ import foundation.e.apps.data.cleanapk.data.home.HomeScreen import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response -class CleanApkAppsRepositoryImpl( +class CleanApkAppsRepository( private val cleanApkRetrofit: CleanApkRetrofit, private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit ) : CleanApkRepository, CleanApkDownloadInfoFetcher { diff --git a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt index e3d60030b..ba3802f48 100644 --- a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt +++ b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt @@ -26,7 +26,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepositoryImpl +import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository import foundation.e.apps.data.playstore.PlayStoreRepository @@ -57,7 +57,7 @@ object NamedRepositoryModule { cleanAPKRetrofit: CleanApkRetrofit, cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit ): CleanApkRepository { - return CleanApkAppsRepositoryImpl(cleanAPKRetrofit, cleanApkAppDetailsRetrofit) + return CleanApkAppsRepository(cleanAPKRetrofit, cleanApkAppDetailsRetrofit) } @Singleton -- GitLab From 3db7b0978cc510acb31669225700ce7c24788d02 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 16 Oct 2024 15:29:09 +0200 Subject: [PATCH 02/17] Use Gson converter consistently for cleanapk --- .../cleanapk/CleanApkAppDetailsRetrofit.kt | 36 ------------------- .../repositories/CleanApkAppsRepository.kt | 6 ++-- .../repositories/CleanApkPWARepository.kt | 6 ++-- .../e/apps/di/NamedRepositoryModule.kt | 11 +++--- .../e/apps/di/network/RetrofitApiModule.kt | 19 +++------- 5 files changed, 12 insertions(+), 66 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkAppDetailsRetrofit.kt diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkAppDetailsRetrofit.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkAppDetailsRetrofit.kt deleted file mode 100644 index 69574481d..000000000 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkAppDetailsRetrofit.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright ECORP SAS 2022 - * * Apps Quickly and easily install Android apps onto your device! - * * - * * This program is free software: you can redistribute it and/or modify - * * it under the terms of the GNU General Public License as published by - * * the Free Software Foundation, either version 3 of the License, or - * * (at your option) any later version. - * * - * * This program is distributed in the hope that it will be useful, - * * but WITHOUT ANY WARRANTY; without even the implied warranty of - * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * * GNU General Public License for more details. - * * - * * You should have received a copy of the GNU General Public License - * * along with this program. If not, see . - * - */ - -package foundation.e.apps.data.cleanapk - -import foundation.e.apps.data.cleanapk.data.app.Application -import retrofit2.Response -import retrofit2.http.GET -import retrofit2.http.Query - -interface CleanApkAppDetailsRetrofit { - - @GET("apps?action=app_detail") - suspend fun getAppOrPWADetailsByID( - @Query("id") id: String, - @Query("architectures") architectures: List? = null, - @Query("type") type: String? = null - ): Response -} 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 e06125ad4..4a8a2dc02 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,7 +18,6 @@ package foundation.e.apps.data.cleanapk.repositories -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.data.app.Application @@ -29,8 +28,7 @@ import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response class CleanApkAppsRepository( - private val cleanApkRetrofit: CleanApkRetrofit, - private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit + private val cleanApkRetrofit: CleanApkRetrofit ) : CleanApkRepository, CleanApkDownloadInfoFetcher { override suspend fun getHomeScreenData(): Response { @@ -76,7 +74,7 @@ class CleanApkAppsRepository( } override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) } 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 8e8f84f6a..1731e3cb3 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,7 +18,6 @@ package foundation.e.apps.data.cleanapk.repositories -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit 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 @@ -26,8 +25,7 @@ import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response class CleanApkPWARepository( - private val cleanAPKRetrofit: CleanApkRetrofit, - private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit + private val cleanAPKRetrofit: CleanApkRetrofit ) : CleanApkRepository { override suspend fun getHomeScreenData(): Any { @@ -70,6 +68,6 @@ class CleanApkPWARepository( } override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) } } diff --git a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt index ba3802f48..892fa69b0 100644 --- a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt +++ b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt @@ -24,7 +24,6 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository @@ -54,19 +53,17 @@ object NamedRepositoryModule { @Provides @Named("cleanApkAppsRepository") fun getCleanApkAppsRepository( - cleanAPKRetrofit: CleanApkRetrofit, - cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit + cleanAPKRetrofit: CleanApkRetrofit ): CleanApkRepository { - return CleanApkAppsRepository(cleanAPKRetrofit, cleanApkAppDetailsRetrofit) + return CleanApkAppsRepository(cleanAPKRetrofit) } @Singleton @Provides @Named("cleanApkPWARepository") fun getCleanApkPWARepository( - cleanAPKRetrofit: CleanApkRetrofit, - cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit + cleanAPKRetrofit: CleanApkRetrofit ): CleanApkRepository { - return CleanApkPWARepository(cleanAPKRetrofit, cleanApkAppDetailsRetrofit) + return CleanApkPWARepository(cleanAPKRetrofit) } } diff --git a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt index 136add811..2d6adc3e8 100644 --- a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt @@ -24,7 +24,6 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.ecloud.EcloudApiInterface import foundation.e.apps.data.exodus.ExodusTrackerApi @@ -48,27 +47,17 @@ import javax.inject.Singleton class RetrofitApiModule { @Singleton @Provides - fun provideCleanApkApi(okHttpClient: OkHttpClient, moshi: Moshi): CleanApkRetrofit { - return Retrofit.Builder() - .baseUrl(CleanApkRetrofit.BASE_URL) - .client(okHttpClient) - .addConverterFactory(MoshiConverterFactory.create(moshi)) - .build() - .create(CleanApkRetrofit::class.java) - } - - @Singleton - @Provides - fun provideCleanApkAppDetailsApi( + fun provideCleanApkApi( okHttpClient: OkHttpClient, @Named("gsonCustomAdapter") gson: Gson - ): CleanApkAppDetailsRetrofit { + ): CleanApkRetrofit + { return Retrofit.Builder() .baseUrl(CleanApkRetrofit.BASE_URL) .client(okHttpClient) .addConverterFactory(GsonConverterFactory.create(gson)) .build() - .create(CleanApkAppDetailsRetrofit::class.java) + .create(CleanApkRetrofit::class.java) } @Singleton -- GitLab From 922ebeb70c255df5b4752706abc2bc3d5dc20135 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 10:04:16 +0200 Subject: [PATCH 03/17] Remove useless PlayStoreRepository interface --- .../e/apps/data/AppSourcesContainer.kt | 2 +- .../application/ApplicationDataManager.kt | 2 +- .../data/playstore/PlayStoreRepository.kt | 213 +++++++++++++++- .../data/playstore/PlayStoreRepositoryImpl.kt | 241 ------------------ .../e/apps/data/updates/UpdatesManagerImpl.kt | 1 - .../e/apps/di/NamedRepositoryModule.kt | 16 -- .../foundation/e/apps/di/RepositoryModule.kt | 6 - .../e/apps/ui/AppInfoFetchViewModel.kt | 2 +- 8 files changed, 204 insertions(+), 279 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepositoryImpl.kt diff --git a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt index f6735a117..14e2453c7 100644 --- a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt +++ b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt @@ -27,7 +27,7 @@ import javax.inject.Singleton @Singleton class AppSourcesContainer @Inject constructor( - @Named("gplayRepository") val gplayRepo: PlayStoreRepository, + val gplayRepo: PlayStoreRepository, @Named("cleanApkAppsRepository") val cleanApkAppsRepo: CleanApkRepository, @Named("cleanApkPWARepository") val cleanApkPWARepo: CleanApkRepository ) diff --git a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt index 7fafbccd5..ec63aec86 100644 --- a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt +++ b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt @@ -34,7 +34,7 @@ import javax.inject.Singleton @Singleton class ApplicationDataManager @Inject constructor( - @Named("gplayRepository") private val gplayRepository: PlayStoreRepository, + private val gplayRepository: PlayStoreRepository, private val appLoungePackageManager: AppLoungePackageManager, private val pwaManager: PWAManager ) { 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 03733b0d2..a8d3e9785 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 @@ -18,36 +18,225 @@ 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.AuthData import com.aurora.gplayapi.data.models.Category import com.aurora.gplayapi.data.models.ContentRating import com.aurora.gplayapi.data.models.File import com.aurora.gplayapi.data.models.SearchBundle +import com.aurora.gplayapi.data.models.StreamCluster +import com.aurora.gplayapi.helpers.AppDetailsHelper +import com.aurora.gplayapi.helpers.CategoryAppsHelper +import com.aurora.gplayapi.helpers.CategoryHelper +import com.aurora.gplayapi.helpers.Chart +import com.aurora.gplayapi.helpers.ContentRatingHelper +import com.aurora.gplayapi.helpers.PurchaseHelper +import com.aurora.gplayapi.helpers.SearchHelper +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.utils.CategoryType +import foundation.e.apps.data.login.AuthenticatorRepository +import foundation.e.apps.data.playstore.utils.GPlayHttpClient +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import timber.log.Timber +import javax.inject.Inject + +class PlayStoreRepository @Inject constructor( + @ApplicationContext private val context: Context, + private val gPlayHttpClient: GPlayHttpClient, + private val authenticatorRepository: AuthenticatorRepository +) : StoreRepository { + + override suspend fun getHomeScreenData(): Any { + val homeScreenData = mutableMapOf>() + val homeElements = createTopChartElements() + val authData = authenticatorRepository.gplayAuth!! + + homeElements.forEach { + val chart = it.value.keys.iterator().next() + val type = it.value.values.iterator().next() + val result = getTopApps(type, chart, authData) + homeScreenData[it.key] = result + } + + return homeScreenData + } + + private fun createTopChartElements() = mutableMapOf( + context.getString(R.string.topselling_free_apps) to mapOf(Chart.TOP_SELLING_FREE to TopChartsHelper.Type.APPLICATION), + context.getString(R.string.topselling_free_games) to mapOf(Chart.TOP_SELLING_FREE to TopChartsHelper.Type.GAME), + context.getString(R.string.topgrossing_apps) to mapOf(Chart.TOP_GROSSING to TopChartsHelper.Type.APPLICATION), + context.getString(R.string.topgrossing_games) to mapOf(Chart.TOP_GROSSING to TopChartsHelper.Type.GAME), + context.getString(R.string.movers_shakers_apps) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.APPLICATION), + context.getString(R.string.movers_shakers_games) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME), + ) + + suspend fun getSearchResult( + query: String, + subBundle: MutableSet? + ): Pair, MutableSet> { + val authData = authenticatorRepository.gplayAuth!! + val searchHelper = SearchHelper(authData).using(gPlayHttpClient) + + Timber.d("Fetching search result for $query, subBundle: $subBundle") + + subBundle?.let { + val searchResult = searchHelper.next(it) + Timber.d("fetching next page search data...") + return getSearchResultPair(searchResult, query) + } + + val searchResult = searchHelper.searchResults(query) + return getSearchResultPair(searchResult, query) + } + + private fun getSearchResultPair( + searchBundle: SearchBundle, + query: String + ): Pair, MutableSet> { + val apps = searchBundle.appList + Timber.d("Found ${apps.size} apps for query, $query") + return Pair(apps, searchBundle.subBundles) + } + + suspend fun getSearchSuggestions(query: String): List { + val authData = authenticatorRepository.gplayAuth!! + + val searchData = mutableListOf() + withContext(Dispatchers.IO) { + val searchHelper = SearchHelper(authData).using(gPlayHttpClient) + searchData.addAll(searchHelper.searchSuggestions(query)) + } + return searchData.filter { it.suggestedQuery.isNotBlank() } + } + + suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { + val authData = authenticatorRepository.gplayAuth!! + + val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) + + if (!pageUrl.isNullOrEmpty()) { + return subCategoryHelper.next(pageUrl) + } + + return subCategoryHelper.getCategoryAppsList(category.uppercase()) + } + + suspend fun getCategories(type: CategoryType?): List { + val categoryList = mutableListOf() + if (type == null) { + return categoryList + } + + val authData = authenticatorRepository.gplayAuth!! + + withContext(Dispatchers.IO) { + val categoryHelper = CategoryHelper(authData).using(gPlayHttpClient) + categoryList.addAll(categoryHelper.getAllCategoriesList(getCategoryType(type))) + } + return categoryList + } + + override suspend fun getAppDetails(packageNameOrId: String): App? { + var appDetails: App? + val authData = authenticatorRepository.gplayAuth!! + + withContext(Dispatchers.IO) { + val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) + appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) + } + return appDetails + } + + suspend fun getAppsDetails(packageNamesOrIds: List): List { + val appDetailsList = mutableListOf() + val authData = authenticatorRepository.gplayAuth!! + + withContext(Dispatchers.IO) { + val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) + appDetailsList.addAll(appDetailsHelper.getAppByPackageName(packageNamesOrIds)) + } + return appDetailsList + } + + private fun getCategoryType(type: CategoryType): Category.Type { + return if (type == CategoryType.APPLICATION) Category.Type.APPLICATION + else Category.Type.GAME + } + + private suspend fun getTopApps( + type: TopChartsHelper.Type, + chart: Chart, + authData: AuthData + ): List { + val topApps = mutableListOf() + withContext(Dispatchers.IO) { + val topChartsHelper = TopChartsHelper(authData).using(gPlayHttpClient) + topApps.addAll(topChartsHelper.getCluster(type, chart).clusterAppList) + } + return topApps + } -interface PlayStoreRepository : StoreRepository { - suspend fun getSearchResult(query: String, subBundle: MutableSet?): Pair, MutableSet> - suspend fun getSearchSuggestions(query: String): List - suspend fun getAppsByCategory(category: String, pageUrl: String? = null): Any - suspend fun getCategories(type: CategoryType? = null): List - suspend fun getAppsDetails(packageNamesOrIds: List): List suspend fun getDownloadInfo( idOrPackageName: String, - versionCode: Any? = null, - offerType: Int = -1 - ): List + versionCode: Any?, + offerType: Int + ): List { + val downloadData = mutableListOf() + val authData = authenticatorRepository.gplayAuth!! + + withContext(Dispatchers.IO) { + val version = versionCode?.let { it as Int } ?: -1 + val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) + downloadData.addAll(purchaseHelper.purchase(idOrPackageName, version, offerType)) + } + return downloadData + } + suspend fun getOnDemandModule( packageName: String, moduleName: String, versionCode: Int, offerType: Int - ): List + ): List { + val downloadData = mutableListOf() + val authData = authenticatorRepository.gplayAuth!! + + withContext(Dispatchers.IO) { + val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) + downloadData.addAll( + purchaseHelper.getOnDemandModule(packageName, moduleName, versionCode, offerType) + ) + } + return downloadData + } suspend fun getContentRatingWithId( appPackage: String, contentRating: ContentRating - ): ContentRating - suspend fun getEnglishContentRating(packageName: String): ContentRating? + ): ContentRating { + val authData = authenticatorRepository.gplayAuth!! + val contentRatingHelper = ContentRatingHelper(authData) + + return withContext(Dispatchers.IO) { + contentRatingHelper.updateContentRatingWithId( + appPackage, + contentRating + ) + } + } + + suspend fun getEnglishContentRating(packageName: String): ContentRating? { + val authData = authenticatorRepository.gplayAuth ?: return null + val contentRatingHelper = ContentRatingHelper(authData) + + return withContext(Dispatchers.IO) { + contentRatingHelper.getEnglishContentRating(packageName) + } + } } diff --git a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepositoryImpl.kt deleted file mode 100644 index 9ea9db7b9..000000000 --- a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepositoryImpl.kt +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2024 MURENA SAS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -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.AuthData -import com.aurora.gplayapi.data.models.Category -import com.aurora.gplayapi.data.models.ContentRating -import com.aurora.gplayapi.data.models.File -import com.aurora.gplayapi.data.models.SearchBundle -import com.aurora.gplayapi.data.models.StreamCluster -import com.aurora.gplayapi.helpers.AppDetailsHelper -import com.aurora.gplayapi.helpers.CategoryAppsHelper -import com.aurora.gplayapi.helpers.CategoryHelper -import com.aurora.gplayapi.helpers.Chart -import com.aurora.gplayapi.helpers.ContentRatingHelper -import com.aurora.gplayapi.helpers.PurchaseHelper -import com.aurora.gplayapi.helpers.SearchHelper -import com.aurora.gplayapi.helpers.TopChartsHelper -import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R -import foundation.e.apps.data.application.utils.CategoryType -import foundation.e.apps.data.login.AuthenticatorRepository -import foundation.e.apps.data.playstore.utils.GPlayHttpClient -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import timber.log.Timber -import javax.inject.Inject - -class PlayStoreRepositoryImpl @Inject constructor( - @ApplicationContext private val context: Context, - private val gPlayHttpClient: GPlayHttpClient, - private val authenticatorRepository: AuthenticatorRepository -) : PlayStoreRepository { - - override suspend fun getHomeScreenData(): Any { - val homeScreenData = mutableMapOf>() - val homeElements = createTopChartElements() - val authData = authenticatorRepository.gplayAuth!! - - homeElements.forEach { - val chart = it.value.keys.iterator().next() - val type = it.value.values.iterator().next() - val result = getTopApps(type, chart, authData) - homeScreenData[it.key] = result - } - - return homeScreenData - } - - private fun createTopChartElements() = mutableMapOf( - context.getString(R.string.topselling_free_apps) to mapOf(Chart.TOP_SELLING_FREE to TopChartsHelper.Type.APPLICATION), - context.getString(R.string.topselling_free_games) to mapOf(Chart.TOP_SELLING_FREE to TopChartsHelper.Type.GAME), - context.getString(R.string.topgrossing_apps) to mapOf(Chart.TOP_GROSSING to TopChartsHelper.Type.APPLICATION), - context.getString(R.string.topgrossing_games) to mapOf(Chart.TOP_GROSSING to TopChartsHelper.Type.GAME), - context.getString(R.string.movers_shakers_apps) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.APPLICATION), - context.getString(R.string.movers_shakers_games) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME), - ) - - override suspend fun getSearchResult( - query: String, - subBundle: MutableSet? - ): Pair, MutableSet> { - val authData = authenticatorRepository.gplayAuth!! - val searchHelper = SearchHelper(authData).using(gPlayHttpClient) - - Timber.d("Fetching search result for $query, subBundle: $subBundle") - - subBundle?.let { - val searchResult = searchHelper.next(it) - Timber.d("fetching next page search data...") - return getSearchResultPair(searchResult, query) - } - - val searchResult = searchHelper.searchResults(query) - return getSearchResultPair(searchResult, query) - } - - private fun getSearchResultPair( - searchBundle: SearchBundle, - query: String - ): Pair, MutableSet> { - val apps = searchBundle.appList - Timber.d("Found ${apps.size} apps for query, $query") - return Pair(apps, searchBundle.subBundles) - } - - override suspend fun getSearchSuggestions(query: String): List { - val authData = authenticatorRepository.gplayAuth!! - - val searchData = mutableListOf() - withContext(Dispatchers.IO) { - val searchHelper = SearchHelper(authData).using(gPlayHttpClient) - searchData.addAll(searchHelper.searchSuggestions(query)) - } - return searchData.filter { it.suggestedQuery.isNotBlank() } - } - - override suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { - val authData = authenticatorRepository.gplayAuth!! - - val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) - - if (!pageUrl.isNullOrEmpty()) { - return subCategoryHelper.next(pageUrl) - } - - return subCategoryHelper.getCategoryAppsList(category.uppercase()) - } - - override suspend fun getCategories(type: CategoryType?): List { - val categoryList = mutableListOf() - if (type == null) { - return categoryList - } - - val authData = authenticatorRepository.gplayAuth!! - - withContext(Dispatchers.IO) { - val categoryHelper = CategoryHelper(authData).using(gPlayHttpClient) - categoryList.addAll(categoryHelper.getAllCategoriesList(getCategoryType(type))) - } - return categoryList - } - - override suspend fun getAppDetails(packageNameOrId: String): App? { - var appDetails: App? - val authData = authenticatorRepository.gplayAuth!! - - withContext(Dispatchers.IO) { - val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) - appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) - } - return appDetails - } - - override suspend fun getAppsDetails(packageNamesOrIds: List): List { - val appDetailsList = mutableListOf() - val authData = authenticatorRepository.gplayAuth!! - - withContext(Dispatchers.IO) { - val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) - appDetailsList.addAll(appDetailsHelper.getAppByPackageName(packageNamesOrIds)) - } - return appDetailsList - } - - private fun getCategoryType(type: CategoryType): Category.Type { - return if (type == CategoryType.APPLICATION) Category.Type.APPLICATION - else Category.Type.GAME - } - - private suspend fun getTopApps( - type: TopChartsHelper.Type, - chart: Chart, - authData: AuthData - ): List { - val topApps = mutableListOf() - withContext(Dispatchers.IO) { - val topChartsHelper = TopChartsHelper(authData).using(gPlayHttpClient) - topApps.addAll(topChartsHelper.getCluster(type, chart).clusterAppList) - } - return topApps - } - - override suspend fun getDownloadInfo( - idOrPackageName: String, - versionCode: Any?, - offerType: Int - ): List { - val downloadData = mutableListOf() - val authData = authenticatorRepository.gplayAuth!! - - withContext(Dispatchers.IO) { - val version = versionCode?.let { it as Int } ?: -1 - val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) - downloadData.addAll(purchaseHelper.purchase(idOrPackageName, version, offerType)) - } - return downloadData - } - - override suspend fun getOnDemandModule( - packageName: String, - moduleName: String, - versionCode: Int, - offerType: Int - ): List { - val downloadData = mutableListOf() - val authData = authenticatorRepository.gplayAuth!! - - withContext(Dispatchers.IO) { - val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) - downloadData.addAll( - purchaseHelper.getOnDemandModule(packageName, moduleName, versionCode, offerType) - ) - } - return downloadData - } - - override suspend fun getContentRatingWithId( - appPackage: String, - contentRating: ContentRating - ): ContentRating { - val authData = authenticatorRepository.gplayAuth!! - val contentRatingHelper = ContentRatingHelper(authData) - - return withContext(Dispatchers.IO) { - contentRatingHelper.updateContentRatingWithId( - appPackage, - contentRating - ) - } - } - - override suspend fun getEnglishContentRating(packageName: String): ContentRating? { - val authData = authenticatorRepository.gplayAuth ?: return null - val contentRatingHelper = ContentRatingHelper(authData) - - return withContext(Dispatchers.IO) { - contentRatingHelper.getEnglishContentRating(packageName) - } - } -} diff --git a/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt b/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt index 4cf3cd31a..4629fb420 100644 --- a/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt @@ -30,7 +30,6 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.isUnFiltered import foundation.e.apps.data.faultyApps.FaultyAppRepository import foundation.e.apps.data.fdroid.FdroidRepository -import foundation.e.apps.data.playstore.PlayStoreRepositoryImpl import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.search.SearchApi.Companion.APP_TYPE_ANY import foundation.e.apps.data.application.data.Application diff --git a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt index 892fa69b0..87d507c6d 100644 --- a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt +++ b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt @@ -18,36 +18,20 @@ package foundation.e.apps.di -import android.content.Context import dagger.Module import dagger.Provides import dagger.hilt.InstallIn -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository -import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.data.playstore.PlayStoreRepositoryImpl -import foundation.e.apps.data.playstore.utils.GPlayHttpClient -import foundation.e.apps.data.login.AuthenticatorRepository import javax.inject.Named import javax.inject.Singleton @InstallIn(SingletonComponent::class) @Module object NamedRepositoryModule { - @Singleton - @Provides - @Named("gplayRepository") - fun getGplayRepository( - @ApplicationContext context: Context, - gPlayHttpClient: GPlayHttpClient, - authenticatorRepository: AuthenticatorRepository - ): PlayStoreRepository { - return PlayStoreRepositoryImpl(context, gPlayHttpClient, authenticatorRepository) - } @Singleton @Provides diff --git a/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt index 7d548e66a..caa2532d2 100644 --- a/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt +++ b/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt @@ -28,8 +28,6 @@ import foundation.e.apps.data.exodus.repositories.PrivacyScoreRepository import foundation.e.apps.data.exodus.repositories.PrivacyScoreRepositoryImpl import foundation.e.apps.data.fdroid.FdroidRepository import foundation.e.apps.data.fdroid.IFdroidRepository -import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.data.playstore.PlayStoreRepositoryImpl import foundation.e.apps.data.install.AppManagerImpl import foundation.e.apps.data.install.AppManager import javax.inject.Singleton @@ -52,8 +50,4 @@ interface RepositoryModule { @Singleton @Binds fun getPrivacyScoreRepository(privacyScoreRepositoryImpl: PrivacyScoreRepositoryImpl): PrivacyScoreRepository - - @Singleton - @Binds - fun getPlayStoreRepository(playStoreRepository: PlayStoreRepositoryImpl): PlayStoreRepository } diff --git a/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt b/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt index a4fd28790..012b54801 100644 --- a/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt @@ -18,7 +18,7 @@ import javax.inject.Named @HiltViewModel class AppInfoFetchViewModel @Inject constructor( private val fdroidRepository: FdroidRepository, - @Named("gplayRepository") private val gplayRepository: PlayStoreRepository, + private val gplayRepository: PlayStoreRepository, private val faultyAppRepository: FaultyAppRepository, private val blockedAppRepository: BlockedAppRepository, ) : ViewModel() { -- GitLab From f3cc5125c0c190d45751a6e8d837c2653c8920a6 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 10:55:30 +0200 Subject: [PATCH 04/17] Remove useless NamedRepositoryModule class --- .../e/apps/data/AppSourcesContainer.kt | 7 +-- .../repositories/CleanApkAppsRepository.kt | 3 +- .../repositories/CleanApkPWARepository.kt | 3 +- .../e/apps/di/NamedRepositoryModule.kt | 53 ------------------- .../foundation/e/apps/apps/AppsApiTest.kt | 7 +-- .../e/apps/category/CategoryApiTest.kt | 9 ++-- .../e/apps/fused/SearchApiImplTest.kt | 9 ++-- .../foundation/e/apps/home/HomeApiTest.kt | 9 ++-- 8 files changed, 27 insertions(+), 73 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt diff --git a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt index 14e2453c7..f04274cbd 100644 --- a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt +++ b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt @@ -19,7 +19,8 @@ package foundation.e.apps.data -import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.playstore.PlayStoreRepository import javax.inject.Inject import javax.inject.Named @@ -28,6 +29,6 @@ import javax.inject.Singleton @Singleton class AppSourcesContainer @Inject constructor( val gplayRepo: PlayStoreRepository, - @Named("cleanApkAppsRepository") val cleanApkAppsRepo: CleanApkRepository, - @Named("cleanApkPWARepository") val cleanApkPWARepo: CleanApkRepository + val cleanApkAppsRepo: CleanApkAppsRepository, + val cleanApkPWARepo: CleanApkPWARepository ) 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 4a8a2dc02..8a5c09372 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 @@ -26,8 +26,9 @@ 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( +class CleanApkAppsRepository @Inject constructor( private val cleanApkRetrofit: CleanApkRetrofit ) : CleanApkRepository, CleanApkDownloadInfoFetcher { 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 1731e3cb3..21420b33d 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 @@ -23,8 +23,9 @@ 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( +class CleanApkPWARepository @Inject constructor( private val cleanAPKRetrofit: CleanApkRetrofit ) : CleanApkRepository { diff --git a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt deleted file mode 100644 index 87d507c6d..000000000 --- a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright MURENA SAS 2023 - * Apps Quickly and easily install Android apps onto your device! - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package foundation.e.apps.di - -import dagger.Module -import dagger.Provides -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository -import javax.inject.Named -import javax.inject.Singleton - -@InstallIn(SingletonComponent::class) -@Module -object NamedRepositoryModule { - - @Singleton - @Provides - @Named("cleanApkAppsRepository") - fun getCleanApkAppsRepository( - cleanAPKRetrofit: CleanApkRetrofit - ): CleanApkRepository { - return CleanApkAppsRepository(cleanAPKRetrofit) - } - - @Singleton - @Provides - @Named("cleanApkPWARepository") - fun getCleanApkPWARepository( - cleanAPKRetrofit: CleanApkRetrofit - ): CleanApkRepository { - return CleanApkPWARepository(cleanAPKRetrofit) - } -} 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 861cacf8e..cf72bd490 100644 --- a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt +++ b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt @@ -26,7 +26,6 @@ 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.cleanapk.repositories.CleanApkRepository import foundation.e.apps.data.enums.FilterLevel import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.Status @@ -34,6 +33,8 @@ import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.apps.AppsApi import foundation.e.apps.data.application.apps.AppsApiImpl import foundation.e.apps.data.application.data.Application +import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.install.pkg.PWAManager import foundation.e.apps.install.pkg.AppLoungePackageManager @@ -76,10 +77,10 @@ class AppsApiTest { private lateinit var context: Context @Mock - private lateinit var cleanApkAppsRepository: CleanApkRepository + private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkRepository + private lateinit var cleanApkPWARepository: CleanApkPWARepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository diff --git a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt index e6a96d7e2..6dcc81106 100644 --- a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt +++ b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt @@ -29,7 +29,8 @@ import foundation.e.apps.data.application.category.CategoryApi import foundation.e.apps.data.application.category.CategoryApiImpl import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.cleanapk.data.categories.Categories -import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.install.pkg.PWAManager @@ -70,10 +71,10 @@ class CategoryApiTest { private lateinit var appLoungePackageManager: AppLoungePackageManager @Mock - private lateinit var cleanApkAppsRepository: CleanApkRepository + private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkRepository + private lateinit var cleanApkPWARepository: CleanApkPWARepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository @@ -210,4 +211,4 @@ class CategoryApiTest { Assert.assertEquals("getCategory", 11, categoryListResponse.first.size) } -} \ No newline at end of file +} 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 117b5cc9f..a2466a0e4 100644 --- a/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt +++ b/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt @@ -26,7 +26,6 @@ import com.aurora.gplayapi.data.models.SearchBundle import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.cleanapk.data.search.Search -import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.search.SearchApiImpl @@ -34,6 +33,8 @@ import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.apps.AppsApi import foundation.e.apps.data.application.apps.AppsApiImpl import foundation.e.apps.data.application.data.Application +import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.install.pkg.PWAManager import foundation.e.apps.install.pkg.AppLoungePackageManager @@ -85,10 +86,10 @@ class SearchApiImplTest { private lateinit var context: Context @Mock - private lateinit var cleanApkAppsRepository: CleanApkRepository + private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkRepository + private lateinit var cleanApkPWARepository: CleanApkPWARepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository @@ -231,7 +232,7 @@ class SearchApiImplTest { ).thenReturn(packageNameSearchResponse) Mockito.`when`(cleanApkAppsRepository.getAppDetails(any())) - .thenReturn(Response.error(404, "".toResponseBody())) + .thenReturn(Response.error(404, "".toResponseBody())) Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null)) .thenReturn(gplayLivedata) 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 34ad19888..39c859aa1 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -28,7 +28,8 @@ import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.home.HomeApi import foundation.e.apps.data.application.home.HomeApiImpl -import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository import foundation.e.apps.data.enums.Status import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.install.pkg.PWAManager @@ -76,10 +77,10 @@ class HomeApiTest { private lateinit var context: Context @Mock - private lateinit var cleanApkAppsRepository: CleanApkRepository + private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkRepository + private lateinit var cleanApkPWARepository: CleanApkPWARepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository @@ -148,4 +149,4 @@ class HomeApiTest { assert(hasLimitedDataFound) } -} \ No newline at end of file +} -- GitLab From 864c9efacc9dff8b67fb2e9745f717bd2b55c7ab Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 14:41:05 +0200 Subject: [PATCH 05/17] Introduce getGPlayAuthOrThrow() method To remove !! operator and to make it explicit for the calling method that an exception can be thrown. --- .../data/login/AuthenticatorRepository.kt | 15 ++++++++--- .../data/playstore/PlayStoreRepository.kt | 26 +++++++++---------- .../splitinstall/SplitInstallBinder.kt | 6 +---- .../e/apps/provider/AgeRatingProvider.kt | 5 ++-- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/login/AuthenticatorRepository.kt b/app/src/main/java/foundation/e/apps/data/login/AuthenticatorRepository.kt index 2e4bc761d..fccc0b15a 100644 --- a/app/src/main/java/foundation/e/apps/data/login/AuthenticatorRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/login/AuthenticatorRepository.kt @@ -31,8 +31,15 @@ class AuthenticatorRepository @Inject constructor( private val authenticators: List, ) { - var gplayAuth: AuthData? = null - get() = field ?: throw GPlayLoginException(false, "AuthData is not available!", getUserType()) + private var gPlayAuth: AuthData? = null + + fun getGPlayAuthOrThrow(): AuthData { + return gPlayAuth ?: throw GPlayLoginException(false, "AuthData is not available!", getUserType()) + } + + fun setGPlayAuth(auth: AuthData) { + gPlayAuth = auth + } suspend fun getAuthObjects(clearAuthTypes: List = listOf()): List { @@ -48,7 +55,7 @@ class AuthenticatorRepository @Inject constructor( authObjectsLocal.add(authObject) if (authObject is AuthObject.GPlayAuth) { - gplayAuth = authObject.result.data + gPlayAuth = authObject.result.data } } @@ -74,7 +81,7 @@ class AuthenticatorRepository @Inject constructor( suspend fun getValidatedAuthData(): ResultSupreme { val authDataValidator = (authenticators.find { it is AuthDataValidator } as AuthDataValidator) val validateAuthData = authDataValidator.validateAuthData() - this.gplayAuth = validateAuthData.data + this.gPlayAuth = validateAuthData.data return validateAuthData } 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 a8d3e9785..db207b049 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 @@ -55,7 +55,7 @@ class PlayStoreRepository @Inject constructor( override suspend fun getHomeScreenData(): Any { val homeScreenData = mutableMapOf>() val homeElements = createTopChartElements() - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() homeElements.forEach { val chart = it.value.keys.iterator().next() @@ -76,11 +76,11 @@ class PlayStoreRepository @Inject constructor( context.getString(R.string.movers_shakers_games) to mapOf(Chart.MOVERS_SHAKERS to TopChartsHelper.Type.GAME), ) - suspend fun getSearchResult( + fun getSearchResult( query: String, subBundle: MutableSet? ): Pair, MutableSet> { - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() val searchHelper = SearchHelper(authData).using(gPlayHttpClient) Timber.d("Fetching search result for $query, subBundle: $subBundle") @@ -105,7 +105,7 @@ class PlayStoreRepository @Inject constructor( } suspend fun getSearchSuggestions(query: String): List { - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() val searchData = mutableListOf() withContext(Dispatchers.IO) { @@ -116,7 +116,7 @@ class PlayStoreRepository @Inject constructor( } suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) @@ -133,7 +133,7 @@ class PlayStoreRepository @Inject constructor( return categoryList } - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val categoryHelper = CategoryHelper(authData).using(gPlayHttpClient) @@ -144,7 +144,7 @@ class PlayStoreRepository @Inject constructor( override suspend fun getAppDetails(packageNameOrId: String): App? { var appDetails: App? - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) @@ -155,7 +155,7 @@ class PlayStoreRepository @Inject constructor( suspend fun getAppsDetails(packageNamesOrIds: List): List { val appDetailsList = mutableListOf() - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) @@ -188,7 +188,7 @@ class PlayStoreRepository @Inject constructor( offerType: Int ): List { val downloadData = mutableListOf() - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val version = versionCode?.let { it as Int } ?: -1 @@ -205,7 +205,7 @@ class PlayStoreRepository @Inject constructor( offerType: Int ): List { val downloadData = mutableListOf() - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val purchaseHelper = PurchaseHelper(authData).using(gPlayHttpClient) @@ -220,7 +220,7 @@ class PlayStoreRepository @Inject constructor( appPackage: String, contentRating: ContentRating ): ContentRating { - val authData = authenticatorRepository.gplayAuth!! + val authData = authenticatorRepository.getGPlayAuthOrThrow() val contentRatingHelper = ContentRatingHelper(authData) return withContext(Dispatchers.IO) { @@ -231,8 +231,8 @@ class PlayStoreRepository @Inject constructor( } } - suspend fun getEnglishContentRating(packageName: String): ContentRating? { - val authData = authenticatorRepository.gplayAuth ?: return null + suspend fun getEnglishContentRating(packageName: String): ContentRating { + val authData = authenticatorRepository.getGPlayAuthOrThrow() val contentRatingHelper = ContentRatingHelper(authData) return withContext(Dispatchers.IO) { diff --git a/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt b/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt index 8e5e5da16..a3e0c7684 100644 --- a/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt +++ b/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt @@ -71,11 +71,7 @@ class SplitInstallBinder( coroutineScope.launch { try { authenticatorRepository.getValidatedAuthData() - if (authenticatorRepository.gplayAuth == null) { - Timber.w(AUTH_DATA_ERROR_MESSAGE) - handleError(packageName) - return@launch - } + authenticatorRepository.getGPlayAuthOrThrow() downloadModule(packageName, moduleName) } catch (exception: GPlayLoginException) { Timber.w("$AUTH_DATA_ERROR_MESSAGE $exception") diff --git a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt index f3bf8552e..752202e18 100644 --- a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt +++ b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt @@ -201,7 +201,7 @@ class AgeRatingProvider : ContentProvider() { private fun canSetupAuthData() { val authData = dataStoreManager.getAuthData() if (authData.email.isNotBlank() && authData.authToken.isNotBlank()) { - authenticatorRepository.gplayAuth = authData + authenticatorRepository.setGPlayAuth(authData) } } @@ -286,7 +286,8 @@ class AgeRatingProvider : ContentProvider() { private fun hasAuthData(): Boolean { return try { - authenticatorRepository.gplayAuth != null + authenticatorRepository.getGPlayAuthOrThrow() + true } catch (e: GPlayLoginException) { Timber.e("No AuthData to check content rating") false -- GitLab From 672048175913a6cdf0b0a5d3ad0a1a39900cf588 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 14:44:11 +0200 Subject: [PATCH 06/17] Handle NoSuchElementException case --- .../foundation/e/apps/data/playstore/PlayStoreRepository.kt | 2 ++ 1 file changed, 2 insertions(+) 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 db207b049..768b7759e 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 @@ -58,6 +58,8 @@ class PlayStoreRepository @Inject constructor( val authData = authenticatorRepository.getGPlayAuthOrThrow() homeElements.forEach { + if (it.value.isEmpty()) return@forEach + val chart = it.value.keys.iterator().next() val type = it.value.values.iterator().next() val result = getTopApps(type, chart, authData) -- GitLab From 211474df92df8a6485a7abfb4ac7fc3ef0e00add Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 14:51:39 +0200 Subject: [PATCH 07/17] Improve getSearchResult() with a unique return --- .../e/apps/data/playstore/PlayStoreRepository.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 768b7759e..b3a502f97 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 @@ -87,13 +87,13 @@ class PlayStoreRepository @Inject constructor( Timber.d("Fetching search result for $query, subBundle: $subBundle") - subBundle?.let { - val searchResult = searchHelper.next(it) + val searchResult = if (subBundle != null) { Timber.d("fetching next page search data...") - return getSearchResultPair(searchResult, query) + searchHelper.next(subBundle) + } else { + searchHelper.searchResults(query) } - val searchResult = searchHelper.searchResults(query) return getSearchResultPair(searchResult, query) } -- GitLab From 11f616b695f8207262d73ae49ec51be9feb9f492 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 15:02:01 +0200 Subject: [PATCH 08/17] Rename canSetupAuthData() to initAuthData() --- .../main/java/foundation/e/apps/provider/AgeRatingProvider.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt index 752202e18..0ed06df83 100644 --- a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt +++ b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt @@ -138,7 +138,7 @@ class AgeRatingProvider : ContentProvider() { withContext(IO) { try { if (packageNames.isEmpty()) return@withContext cursor - canSetupAuthData() + initAuthData() ensureAgeGroupDataExists() compileAppBlockList(cursor, packageNames) @@ -198,7 +198,7 @@ class AgeRatingProvider : ContentProvider() { * Setup AuthData for other APIs to access, * if user has logged in with Google or Anonymous mode. */ - private fun canSetupAuthData() { + private fun initAuthData() { val authData = dataStoreManager.getAuthData() if (authData.email.isNotBlank() && authData.authToken.isNotBlank()) { authenticatorRepository.setGPlayAuth(authData) -- GitLab From 8f2c77db0b34a1b8f4dde69e5c58149402739995 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 17 Oct 2024 15:04:17 +0200 Subject: [PATCH 09/17] getAppsByCategory is not a suspending function --- .../foundation/e/apps/data/playstore/PlayStoreRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b3a502f97..3065874e2 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 @@ -117,7 +117,7 @@ class PlayStoreRepository @Inject constructor( return searchData.filter { it.suggestedQuery.isNotBlank() } } - suspend fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { + fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { val authData = authenticatorRepository.getGPlayAuthOrThrow() val subCategoryHelper = CategoryAppsHelper(authData).using(gPlayHttpClient) -- GitLab From 1b2b71836c326964aec99f42b3a613b24fcab07f Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 24 Oct 2024 08:26:54 +0200 Subject: [PATCH 10/17] Some minor renaming --- app/src/main/AndroidManifest.xml | 2 +- .../foundation/e/apps/data/AppSourcesContainer.kt | 5 ++--- .../e/apps/data/application/ApplicationDataManager.kt | 11 +++++------ ...anApkPWARepository.kt => CleanApkPwaRepository.kt} | 2 +- .../{FdroidRepository.kt => FDroidRepository.kt} | 4 ++-- .../e/apps/data/fdroid/IFdroidRepository.kt | 2 +- .../foundation/e/apps/data/install/AppManagerImpl.kt | 4 ++-- .../e/apps/data/install/AppManagerWrapper.kt | 8 ++++---- .../e/apps/data/updates/UpdatesManagerImpl.kt | 6 +++--- .../java/foundation/e/apps/di/RepositoryModule.kt | 4 ++-- .../e/apps/install/download/DownloadManagerUtils.kt | 2 +- .../apps/install/pkg/{PWAManager.kt => PwaManager.kt} | 2 +- ...erStatusReceiver.kt => PwaPlayerStatusReceiver.kt} | 2 +- .../foundation/e/apps/ui/AppInfoFetchViewModel.kt | 11 +++++------ .../foundation/e/apps/ui/MainActivityViewModel.kt | 4 ++-- .../e/apps/ui/application/ApplicationFragment.kt | 4 ++-- .../ui/applicationlist/ApplicationListFragment.kt | 4 ++-- .../java/foundation/e/apps/ui/home/HomeFragment.kt | 4 ++-- .../foundation/e/apps/ui/search/SearchFragment.kt | 4 ++-- .../foundation/e/apps/ui/updates/UpdatesFragment.kt | 4 ++-- .../java/foundation/e/apps/UpdateManagerImptTest.kt | 6 +++--- .../test/java/foundation/e/apps/apps/AppsApiTest.kt | 8 ++++---- .../foundation/e/apps/category/CategoryApiTest.kt | 8 ++++---- .../java/foundation/e/apps/fused/SearchApiImplTest.kt | 9 ++++----- .../e/apps/fusedManager/AppManagerWrapperTest.kt | 4 ++-- .../test/java/foundation/e/apps/home/HomeApiTest.kt | 8 ++++---- .../apps/installProcessor/AppInstallProcessorTest.kt | 8 +++----- .../e/apps/installProcessor/FakeAppManagerWrapper.kt | 6 +++--- 28 files changed, 70 insertions(+), 76 deletions(-) rename app/src/main/java/foundation/e/apps/data/cleanapk/repositories/{CleanApkPWARepository.kt => CleanApkPwaRepository.kt} (98%) rename app/src/main/java/foundation/e/apps/data/fdroid/{FdroidRepository.kt => FDroidRepository.kt} (95%) rename app/src/main/java/foundation/e/apps/install/pkg/{PWAManager.kt => PwaManager.kt} (99%) rename app/src/main/java/foundation/e/apps/install/receiver/{PWAPlayerStatusReceiver.kt => PwaPlayerStatusReceiver.kt} (98%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4b789577b..a66085688 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -124,7 +124,7 @@ - diff --git a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt index f04274cbd..c32a2fe17 100644 --- a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt +++ b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt @@ -20,15 +20,14 @@ package foundation.e.apps.data import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.playstore.PlayStoreRepository import javax.inject.Inject -import javax.inject.Named import javax.inject.Singleton @Singleton class AppSourcesContainer @Inject constructor( val gplayRepo: PlayStoreRepository, val cleanApkAppsRepo: CleanApkAppsRepository, - val cleanApkPWARepo: CleanApkPWARepository + val cleanApkPWARepo: CleanApkPwaRepository ) diff --git a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt index ec63aec86..8885da06f 100644 --- a/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt +++ b/app/src/main/java/foundation/e/apps/data/application/ApplicationDataManager.kt @@ -26,17 +26,16 @@ import foundation.e.apps.data.enums.FilterLevel import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.Status import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import javax.inject.Inject -import javax.inject.Named import javax.inject.Singleton @Singleton class ApplicationDataManager @Inject constructor( - private val gplayRepository: PlayStoreRepository, + private val gPlayRepository: PlayStoreRepository, private val appLoungePackageManager: AppLoungePackageManager, - private val pwaManager: PWAManager + private val pwaManager: PwaManager ) { suspend fun updateFilterLevel(authData: AuthData?, application: Application) { application.filterLevel = getAppFilterLevel(application, authData) @@ -81,7 +80,7 @@ class ApplicationDataManager @Inject constructor( * Example: com.skype.m2 */ private suspend fun isApplicationVisible(application: Application): Boolean { - return kotlin.runCatching { gplayRepository.getAppDetails(application.package_name) }.isSuccess + return kotlin.runCatching { gPlayRepository.getAppDetails(application.package_name) }.isSuccess } /* @@ -90,7 +89,7 @@ class ApplicationDataManager @Inject constructor( */ private suspend fun isDownloadable(application: Application): Boolean { return kotlin.runCatching { - gplayRepository.getDownloadInfo( + gPlayRepository.getDownloadInfo( application.package_name, application.latest_version_code, application.offer_type, 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 similarity index 98% rename from app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPWARepository.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index 21420b33d..2f1f00dd2 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 @@ -25,7 +25,7 @@ import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject -class CleanApkPWARepository @Inject constructor( +class CleanApkPwaRepository @Inject constructor( private val cleanAPKRetrofit: CleanApkRetrofit ) : CleanApkRepository { diff --git a/app/src/main/java/foundation/e/apps/data/fdroid/FdroidRepository.kt b/app/src/main/java/foundation/e/apps/data/fdroid/FDroidRepository.kt similarity index 95% rename from app/src/main/java/foundation/e/apps/data/fdroid/FdroidRepository.kt rename to app/src/main/java/foundation/e/apps/data/fdroid/FDroidRepository.kt index 978b36e05..34fd7c4dd 100644 --- a/app/src/main/java/foundation/e/apps/data/fdroid/FdroidRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/fdroid/FDroidRepository.kt @@ -10,7 +10,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class FdroidRepository @Inject constructor( +class FDroidRepository @Inject constructor( private val fdroidApi: FdroidApiInterface, private val fdroidDao: FdroidDao, ) : IFdroidRepository { @@ -54,7 +54,7 @@ class FdroidRepository @Inject constructor( return result?.authorName ?: FdroidEntity.DEFAULT_FDROID_AUTHOR_NAME } - override suspend fun isFdroidApplicationSigned(context: Context, packageName: String, apkFilePath: String, signature: String): Boolean { + override suspend fun isFDroidApplicationSigned(context: Context, packageName: String, apkFilePath: String, signature: String): Boolean { if (isFdroidApplication(packageName)) { return ApkSignatureManager.verifyFdroidSignature(context, apkFilePath, signature, packageName) } diff --git a/app/src/main/java/foundation/e/apps/data/fdroid/IFdroidRepository.kt b/app/src/main/java/foundation/e/apps/data/fdroid/IFdroidRepository.kt index 51bdaefab..84f411e44 100644 --- a/app/src/main/java/foundation/e/apps/data/fdroid/IFdroidRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/fdroid/IFdroidRepository.kt @@ -33,7 +33,7 @@ interface IFdroidRepository { suspend fun getAuthorName(application: Application): String - suspend fun isFdroidApplicationSigned( + suspend fun isFDroidApplicationSigned( context: Context, packageName: String, apkFilePath: String, diff --git a/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt b/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt index 94f2b2f61..183a65d08 100644 --- a/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/install/AppManagerImpl.kt @@ -35,7 +35,7 @@ import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.parentalcontrol.ContentRatingDao import foundation.e.apps.data.parentalcontrol.ContentRatingEntity import foundation.e.apps.install.download.data.DownloadProgressLD -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.sync.Mutex @@ -53,7 +53,7 @@ class AppManagerImpl @Inject constructor( private val downloadManager: DownloadManager, private val notificationManager: NotificationManager, private val appInstallRepository: AppInstallRepository, - private val pwaManager: PWAManager, + private val pwaManager: PwaManager, private val appLoungePackageManager: AppLoungePackageManager, @Named("download") private val downloadNotificationChannel: NotificationChannel, @Named("update") private val updateNotificationChannel: NotificationChannel, diff --git a/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt b/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt index 359681c6c..119b5653a 100644 --- a/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt +++ b/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt @@ -6,7 +6,7 @@ import androidx.annotation.RequiresApi import androidx.lifecycle.LiveData import foundation.e.apps.OpenForTesting import foundation.e.apps.data.enums.Status -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.install.download.data.DownloadProgress @@ -18,7 +18,7 @@ import javax.inject.Singleton @OpenForTesting class AppManagerWrapper @Inject constructor( private val appManager: AppManager, - private val fdroidRepository: FdroidRepository + private val fDroidRepository: FDroidRepository ) { fun createNotificationChannels() { @@ -182,9 +182,9 @@ class AppManagerWrapper @Inject constructor( return null } - suspend fun isFdroidApplicationSigned(context: Context, appInstall: AppInstall): Boolean { + suspend fun isFDroidApplicationSigned(context: Context, appInstall: AppInstall): Boolean { val apkFilePath = appManager.getBaseApkPath(appInstall) - return fdroidRepository.isFdroidApplicationSigned(context, appInstall.packageName, apkFilePath, appInstall.signature) + return fDroidRepository.isFDroidApplicationSigned(context, appInstall.packageName, apkFilePath, appInstall.signature) } fun isFusedDownloadInstalled(appInstall: AppInstall): Boolean { diff --git a/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt b/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt index 4629fb420..89628886b 100644 --- a/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/updates/UpdatesManagerImpl.kt @@ -29,7 +29,7 @@ import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.isUnFiltered import foundation.e.apps.data.faultyApps.FaultyAppRepository -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.search.SearchApi.Companion.APP_TYPE_ANY import foundation.e.apps.data.application.data.Application @@ -51,7 +51,7 @@ class UpdatesManagerImpl @Inject constructor( private val applicationRepository: ApplicationRepository, private val faultyAppRepository: FaultyAppRepository, private val appLoungePreference: AppLoungePreference, - private val fdroidRepository: FdroidRepository, + private val fDroidRepository: FDroidRepository, private val blockedAppRepository: BlockedAppRepository, private val systemAppsUpdatesRepository: SystemAppsUpdatesRepository, ) { @@ -416,7 +416,7 @@ class UpdatesManagerImpl @Inject constructor( // Received list has build info of the latest version at the bottom. // We want it at the top. val builds = handleNetworkResult { - fdroidRepository.getBuildVersionInfo(packageName)?.asReversed() ?: listOf() + fDroidRepository.getBuildVersionInfo(packageName)?.asReversed() ?: listOf() }.data val matchingIndex = builds?.find { diff --git a/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt index caa2532d2..0eb1d9a69 100644 --- a/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt +++ b/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt @@ -26,7 +26,7 @@ import foundation.e.apps.data.exodus.repositories.AppPrivacyInfoRepositoryImpl import foundation.e.apps.data.exodus.repositories.IAppPrivacyInfoRepository import foundation.e.apps.data.exodus.repositories.PrivacyScoreRepository import foundation.e.apps.data.exodus.repositories.PrivacyScoreRepositoryImpl -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.fdroid.IFdroidRepository import foundation.e.apps.data.install.AppManagerImpl import foundation.e.apps.data.install.AppManager @@ -45,7 +45,7 @@ interface RepositoryModule { @Singleton @Binds - fun getFdroidRepository(fusedManagerImpl: FdroidRepository): IFdroidRepository + fun getFdroidRepository(fusedManagerImpl: FDroidRepository): IFdroidRepository @Singleton @Binds diff --git a/app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt b/app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt index 2a8a45056..689f70343 100644 --- a/app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt +++ b/app/src/main/java/foundation/e/apps/install/download/DownloadManagerUtils.kt @@ -164,7 +164,7 @@ class DownloadManagerUtils @Inject constructor( } private suspend fun checkCleanApkSignatureOK(appInstall: AppInstall): Boolean { - if (appInstall.origin != Origin.CLEANAPK || appManagerWrapper.isFdroidApplicationSigned( + if (appInstall.origin != Origin.CLEANAPK || appManagerWrapper.isFDroidApplicationSigned( context, appInstall ) ) { diff --git a/app/src/main/java/foundation/e/apps/install/pkg/PWAManager.kt b/app/src/main/java/foundation/e/apps/install/pkg/PwaManager.kt similarity index 99% rename from app/src/main/java/foundation/e/apps/install/pkg/PWAManager.kt rename to app/src/main/java/foundation/e/apps/install/pkg/PwaManager.kt index ccb37248b..b1ea00b57 100644 --- a/app/src/main/java/foundation/e/apps/install/pkg/PWAManager.kt +++ b/app/src/main/java/foundation/e/apps/install/pkg/PwaManager.kt @@ -27,7 +27,7 @@ import javax.inject.Singleton @Singleton @OpenForTesting -class PWAManager @Inject constructor( +class PwaManager @Inject constructor( @ApplicationContext private val context: Context, private val appInstallRepository: AppInstallRepository, ) { diff --git a/app/src/main/java/foundation/e/apps/install/receiver/PWAPlayerStatusReceiver.kt b/app/src/main/java/foundation/e/apps/install/receiver/PwaPlayerStatusReceiver.kt similarity index 98% rename from app/src/main/java/foundation/e/apps/install/receiver/PWAPlayerStatusReceiver.kt rename to app/src/main/java/foundation/e/apps/install/receiver/PwaPlayerStatusReceiver.kt index 9b3ed0267..1339877ce 100644 --- a/app/src/main/java/foundation/e/apps/install/receiver/PWAPlayerStatusReceiver.kt +++ b/app/src/main/java/foundation/e/apps/install/receiver/PwaPlayerStatusReceiver.kt @@ -39,7 +39,7 @@ import javax.inject.Inject */ @AndroidEntryPoint @DelicateCoroutinesApi -class PWAPlayerStatusReceiver : BroadcastReceiver() { +class PwaPlayerStatusReceiver : BroadcastReceiver() { companion object { const val ACTION_PWA_ADDED = "foundation.e.pwaplayer.PWA_ADDED" diff --git a/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt b/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt index 012b54801..1630c4d67 100644 --- a/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/AppInfoFetchViewModel.kt @@ -6,32 +6,31 @@ import androidx.lifecycle.liveData import dagger.hilt.android.lifecycle.HiltViewModel import foundation.e.apps.data.blockedApps.BlockedAppRepository import foundation.e.apps.data.faultyApps.FaultyAppRepository -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.playstore.PlayStoreRepository import javax.inject.Inject -import javax.inject.Named /** * */ @HiltViewModel class AppInfoFetchViewModel @Inject constructor( - private val fdroidRepository: FdroidRepository, - private val gplayRepository: PlayStoreRepository, + private val fDroidRepository: FDroidRepository, + private val gPlayRepository: PlayStoreRepository, private val faultyAppRepository: FaultyAppRepository, private val blockedAppRepository: BlockedAppRepository, ) : ViewModel() { fun getAuthorName(application: Application) = liveData { - val authorName = fdroidRepository.getAuthorName(application) + val authorName = fDroidRepository.getAuthorName(application) emit(authorName) } fun isAppPurchased(app: Application): LiveData { return liveData { try { - gplayRepository.getDownloadInfo( + gPlayRepository.getDownloadInfo( app.package_name, app.latest_version_code, app.offer_type, diff --git a/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt index e1b754c20..b06e667e2 100644 --- a/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt @@ -47,7 +47,7 @@ import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingRepos import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.data.preference.getSync import foundation.e.apps.install.pkg.AppLoungePackageManager -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.workmanager.AppInstallProcessor import foundation.e.apps.utils.NetworkStatusManager import kotlinx.coroutines.Dispatchers @@ -60,7 +60,7 @@ class MainActivityViewModel @Inject constructor( private val applicationRepository: ApplicationRepository, private val appManagerWrapper: AppManagerWrapper, private val appLoungePackageManager: AppLoungePackageManager, - private val pwaManager: PWAManager, + private val pwaManager: PwaManager, private val ecloudRepository: EcloudRepository, private val blockedAppRepository: BlockedAppRepository, private val gPlayContentRatingRepository: GPlayContentRatingRepository, diff --git a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt index 126bc7d0e..c4bde026c 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt @@ -67,7 +67,7 @@ import foundation.e.apps.di.CommonUtilsModule.LIST_OF_NULL import foundation.e.apps.domain.ValidateAppAgeLimitUseCase.Companion.KEY_ANTI_FEATURES_NSFW import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.pkg.AppLoungePackageManager -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.ui.AppInfoFetchViewModel import foundation.e.apps.ui.MainActivity import foundation.e.apps.ui.MainActivityViewModel @@ -130,7 +130,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { lateinit var appLoungePackageManager: AppLoungePackageManager @Inject - lateinit var pwaManager: PWAManager + lateinit var pwaManager: PwaManager private val applicationViewModel: ApplicationViewModel by viewModels() private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels() diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt index 909c6a896..ef7aa73a6 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt @@ -39,7 +39,7 @@ import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.GPlayLoginException import foundation.e.apps.databinding.FragmentApplicationListBinding import foundation.e.apps.install.download.data.DownloadProgress -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.ui.AppInfoFetchViewModel import foundation.e.apps.ui.AppProgressViewModel @@ -62,7 +62,7 @@ class ApplicationListFragment : lateinit var appLoungePackageManager: AppLoungePackageManager @Inject - lateinit var pwaManager: PWAManager + lateinit var pwaManager: PwaManager // protected to avoid SyntheticAccessor protected val viewModel: ApplicationListViewModel by viewModels() diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt index 91ac8ad0e..7c5e7c9fc 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeFragment.kt @@ -38,7 +38,7 @@ import foundation.e.apps.data.login.exceptions.GPlayLoginException import foundation.e.apps.databinding.FragmentHomeBinding import foundation.e.apps.di.CommonUtilsModule.safeNavigate import foundation.e.apps.install.download.data.DownloadProgress -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.ui.AppInfoFetchViewModel import foundation.e.apps.ui.AppProgressViewModel import foundation.e.apps.ui.MainActivityViewModel @@ -67,7 +67,7 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall private val appInfoFetchViewModel: AppInfoFetchViewModel by viewModels() @Inject - lateinit var pwaManager: PWAManager + lateinit var pwaManager: PwaManager companion object { private const val SCROLL_DELAY_IN_MILLIS = 500L diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt index f81383409..c84b019d8 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt @@ -52,7 +52,7 @@ import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.GPlayLoginException import foundation.e.apps.databinding.FragmentSearchBinding import foundation.e.apps.install.download.data.DownloadProgress -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.ui.AppInfoFetchViewModel import foundation.e.apps.ui.AppProgressViewModel import foundation.e.apps.ui.MainActivityViewModel @@ -75,7 +75,7 @@ class SearchFragment : ApplicationInstaller { @Inject - lateinit var pwaManager: PWAManager + lateinit var pwaManager: PwaManager private var _binding: FragmentSearchBinding? = null private val binding get() = _binding!! diff --git a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt index 9ba5a6fee..941ec2f11 100644 --- a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesFragment.kt @@ -47,7 +47,7 @@ import foundation.e.apps.data.login.exceptions.GPlayLoginException import foundation.e.apps.databinding.FragmentUpdatesBinding import foundation.e.apps.di.CommonUtilsModule.safeNavigate import foundation.e.apps.install.download.data.DownloadProgress -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.updates.UpdatesWorkManager import foundation.e.apps.install.workmanager.InstallWorkManager.INSTALL_WORK_NAME import foundation.e.apps.ui.AppInfoFetchViewModel @@ -73,7 +73,7 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI private val binding get() = _binding!! @Inject - lateinit var pwaManager: PWAManager + lateinit var pwaManager: PwaManager private val updatesViewModel: UpdatesViewModel by viewModels() private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels() diff --git a/app/src/test/java/foundation/e/apps/UpdateManagerImptTest.kt b/app/src/test/java/foundation/e/apps/UpdateManagerImptTest.kt index d483c05c5..eb5c7090f 100644 --- a/app/src/test/java/foundation/e/apps/UpdateManagerImptTest.kt +++ b/app/src/test/java/foundation/e/apps/UpdateManagerImptTest.kt @@ -26,7 +26,7 @@ import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status import foundation.e.apps.data.faultyApps.FaultyAppRepository -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.search.SearchApi import foundation.e.apps.data.application.data.Application @@ -77,7 +77,7 @@ class UpdateManagerImptTest { private lateinit var blockedAppRepository: BlockedAppRepository @Mock - private lateinit var fdroidRepository: FdroidRepository + private lateinit var fDroidRepository: FDroidRepository @Mock private lateinit var systemAppsUpdatesRepository: SystemAppsUpdatesRepository @@ -96,7 +96,7 @@ class UpdateManagerImptTest { applicationRepository, faultyAppRepository, preferenceModule, - fdroidRepository, + fDroidRepository, blockedAppRepository, systemAppsUpdatesRepository, ) 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 cf72bd490..1dc1ce734 100644 --- a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt +++ b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt @@ -34,9 +34,9 @@ import foundation.e.apps.data.application.apps.AppsApi import foundation.e.apps.data.application.apps.AppsApiImpl import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -68,7 +68,7 @@ class AppsApiTest { var mainCoroutineRule = MainCoroutineRule() @Mock - private lateinit var pwaManager: PWAManager + private lateinit var pwaManager: PwaManager @Mock private lateinit var appLoungePackageManager: AppLoungePackageManager @@ -80,7 +80,7 @@ class AppsApiTest { private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkPWARepository + private lateinit var cleanApkPWARepository: CleanApkPwaRepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository diff --git a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt index 6dcc81106..ddf7a556a 100644 --- a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt +++ b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt @@ -30,10 +30,10 @@ import foundation.e.apps.data.application.category.CategoryApiImpl import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -65,7 +65,7 @@ class CategoryApiTest { private lateinit var context: Context @Mock - private lateinit var pwaManager: PWAManager + private lateinit var pwaManager: PwaManager @Mock private lateinit var appLoungePackageManager: AppLoungePackageManager @@ -74,7 +74,7 @@ class CategoryApiTest { private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkPWARepository + private lateinit var cleanApkPWARepository: CleanApkPwaRepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository 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 a2466a0e4..3337aea51 100644 --- a/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt +++ b/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt @@ -34,9 +34,9 @@ import foundation.e.apps.data.application.apps.AppsApi import foundation.e.apps.data.application.apps.AppsApiImpl import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import foundation.e.apps.utils.eventBus.EventBus @@ -44,7 +44,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest -import okhttp3.ResponseBody import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Assert.assertEquals @@ -77,7 +76,7 @@ class SearchApiImplTest { private lateinit var fusedAPIImpl: SearchApiImpl @Mock - private lateinit var pwaManager: PWAManager + private lateinit var pwaManager: PwaManager @Mock private lateinit var appLoungePackageManager: AppLoungePackageManager @@ -89,7 +88,7 @@ class SearchApiImplTest { private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkPWARepository + private lateinit var cleanApkPWARepository: CleanApkPwaRepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository diff --git a/app/src/test/java/foundation/e/apps/fusedManager/AppManagerWrapperTest.kt b/app/src/test/java/foundation/e/apps/fusedManager/AppManagerWrapperTest.kt index 4fe3108f5..fb77fcfce 100644 --- a/app/src/test/java/foundation/e/apps/fusedManager/AppManagerWrapperTest.kt +++ b/app/src/test/java/foundation/e/apps/fusedManager/AppManagerWrapperTest.kt @@ -21,7 +21,7 @@ package foundation.e.apps.fusedManager import android.app.Application import androidx.arch.core.executor.testing.InstantTaskExecutorRule import foundation.e.apps.data.enums.Status -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.install.AppManagerWrapper import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.install.workmanager.InstallWorkManager @@ -58,7 +58,7 @@ class AppManagerWrapperTest { private lateinit var application: Application @Mock - private lateinit var fdroidRepository: FdroidRepository + private lateinit var fdroidRepository: FDroidRepository private lateinit var appManagerWrapper: AppManagerWrapper 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 39c859aa1..196420071 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -29,10 +29,10 @@ import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.home.HomeApi import foundation.e.apps.data.application.home.HomeApiImpl import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository -import foundation.e.apps.data.cleanapk.repositories.CleanApkPWARepository +import foundation.e.apps.data.cleanapk.repositories.CleanApkPwaRepository import foundation.e.apps.data.enums.Status import foundation.e.apps.data.playstore.PlayStoreRepository -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import foundation.e.apps.util.getOrAwaitValue @@ -68,7 +68,7 @@ class HomeApiTest { private lateinit var applicationDataManager: ApplicationDataManager @Mock - private lateinit var pwaManager: PWAManager + private lateinit var pwaManager: PwaManager @Mock private lateinit var appLoungePackageManager: AppLoungePackageManager @@ -80,7 +80,7 @@ class HomeApiTest { private lateinit var cleanApkAppsRepository: CleanApkAppsRepository @Mock - private lateinit var cleanApkPWARepository: CleanApkPWARepository + private lateinit var cleanApkPWARepository: CleanApkPwaRepository @Mock private lateinit var gPlayAPIRepository: PlayStoreRepository diff --git a/app/src/test/java/foundation/e/apps/installProcessor/AppInstallProcessorTest.kt b/app/src/test/java/foundation/e/apps/installProcessor/AppInstallProcessorTest.kt index 5d893eb60..28d386f68 100644 --- a/app/src/test/java/foundation/e/apps/installProcessor/AppInstallProcessorTest.kt +++ b/app/src/test/java/foundation/e/apps/installProcessor/AppInstallProcessorTest.kt @@ -21,10 +21,9 @@ package foundation.e.apps.installProcessor import android.content.Context import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.aurora.gplayapi.data.models.AuthData -import com.aurora.gplayapi.data.models.ContentRating import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.Status -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.install.AppInstallRepository @@ -47,7 +46,6 @@ import org.junit.Test import org.mockito.Mock import org.mockito.Mockito import org.mockito.MockitoAnnotations -import kotlin.reflect.jvm.internal.ReflectProperties.Val @OptIn(ExperimentalCoroutinesApi::class) class AppInstallProcessorTest { @@ -69,7 +67,7 @@ class AppInstallProcessorTest { private lateinit var fakeFusedManager: AppManager @Mock - private lateinit var fakeFdroidRepository: FdroidRepository + private lateinit var fakeFDroidRepository: FDroidRepository @Mock private lateinit var context: Context @@ -94,7 +92,7 @@ class AppInstallProcessorTest { fakeFusedDownloadDAO = FakeAppInstallDAO() appInstallRepository = AppInstallRepository(fakeFusedDownloadDAO) fakeFusedManagerRepository = - FakeAppManagerWrapper(fakeFusedDownloadDAO, fakeFusedManager, fakeFdroidRepository) + FakeAppManagerWrapper(fakeFusedDownloadDAO, fakeFusedManager, fakeFDroidRepository) val appInstallComponents = AppInstallComponents(appInstallRepository, fakeFusedManagerRepository) diff --git a/app/src/test/java/foundation/e/apps/installProcessor/FakeAppManagerWrapper.kt b/app/src/test/java/foundation/e/apps/installProcessor/FakeAppManagerWrapper.kt index eb026c5ba..3099e0914 100644 --- a/app/src/test/java/foundation/e/apps/installProcessor/FakeAppManagerWrapper.kt +++ b/app/src/test/java/foundation/e/apps/installProcessor/FakeAppManagerWrapper.kt @@ -19,7 +19,7 @@ package foundation.e.apps.installProcessor import foundation.e.apps.data.enums.Status -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.install.AppManagerWrapper import foundation.e.apps.data.install.AppManager import foundation.e.apps.data.install.models.AppInstall @@ -28,8 +28,8 @@ import kotlinx.coroutines.delay class FakeAppManagerWrapper( private val fusedDownloadDAO: FakeAppInstallDAO, fusedManager: AppManager, - fdroidRepository: FdroidRepository, -) : AppManagerWrapper(fusedManager, fdroidRepository) { + fDroidRepository: FDroidRepository, +) : AppManagerWrapper(fusedManager, fDroidRepository) { var isAppInstalled = false var installationStatus = Status.INSTALLED var willDownloadFail = false -- GitLab From b177ea1d6e9bb334c5fc5c55f52b5bcdb6e95ef4 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 22 Oct 2024 08:26:22 +0200 Subject: [PATCH 11/17] 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 | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fi/strings.xml | 3 +- app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-is/strings.xml | 3 +- app/src/main/res/values-it/strings.xml | 1 - 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, 288 insertions(+), 143 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 399766b08..4bfa880f9 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 diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6d29329f5..2fe4bb098 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. 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 f81846411..dee5855bb 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. diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 10f3aeb51..23264fbe6 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 @@ -208,4 +207,4 @@ Villa kom upp við að hlaða inn forritum með opnum grunnkóða og PWA. Aðeins algeng forrit eru tiltæk í augnablikinu. Algeng forrit óaðgengileg Villa kom upp við að hlaða inn algengum forritum. Aðeins forrit með opnum grunnkóða og PWA eru tiltæk í augnablikinu. - \ 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 34663ceda..33096a51d 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 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 2ab9f4a3a..6486fd89c 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 07ac8f5062048b55670b0ece1dc5cfd157bd6ad5 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 22 Oct 2024 11:51:57 +0200 Subject: [PATCH 12/17] 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 21ca7c6f8fef167e7c088c23708b2a5175fb8acc Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 23 Oct 2024 08:47:27 +0200 Subject: [PATCH 13/17] 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 77787fe1e26f15adb2bf8f4f2914b6f72e6b98bf Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 24 Oct 2024 11:38:20 +0200 Subject: [PATCH 14/17] 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 ba69e4fbff50dd934bc58838efe24737188d4cd2 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 25 Oct 2024 13:37:29 +0200 Subject: [PATCH 15/17] 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 0c8c8e986de7e7d05145490a2bfbb4e8727b8f87 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 25 Oct 2024 14:42:08 +0200 Subject: [PATCH 16/17] 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 4bfa880f9..6224e03eb 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 2fe4bb098..7ddd324cf 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 dee5855bb..044f24249 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 23264fbe6..073464ad2 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 33096a51d..b95a1a5cb 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 6486fd89c..e6cd00689 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 From 185971a31bb6bd3a19297dd3bf7ea061576f0eed Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 29 Oct 2024 13:33:22 +0100 Subject: [PATCH 17/17] Allow release & debug flavor to cohabite together --- app/src/main/AndroidManifest.xml | 6 +++--- lint.xml | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a66085688..fe79aa093 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ xmlns:tools="http://schemas.android.com/tools"> @@ -175,8 +175,8 @@ diff --git a/lint.xml b/lint.xml index bfd91922c..9debeab74 100644 --- a/lint.xml +++ b/lint.xml @@ -34,6 +34,9 @@ + + + -- GitLab