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

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

Note : Ce message ne s\'affichera plus.
Il est impossible d\'afficher les applications Google Play quand seules les applications Open Source sont sélectionnées. @@ -203,4 +202,4 @@ Cliquer sur \"%1$s\" ouvrira un onglet dans votre navigateur avec le nom du paquet de l\'application pré-rempli.<br /><br /> Cliquez sur \"Perform analysis\" pour lancer l\'analyse par Exodus.<br /><br /> Quand le bouton \"See the report\" apparaît (cela peut prendre un moment selon l\'application) vous pouvez fermer l\'onglet et retourner sur la description de l\'application dans %2$s où vous devriez voir la note de Confidentialité. Parfois Exodus peut échouer à analyser l\'application.<br /><br />NB : cela peut prendre jusqu\'à 10 min pour que le score apparaisse dans la description de l\'application. RENOUVELER LA SESSION Application système - \ No newline at end of file + diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 8999fff64..895970e54 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -120,7 +120,6 @@ Af hverju sé ég opnu hugbúnaðarútgáfuna\? Forrit með opinn grunnkóða Öll forrit eru af nýjustu útgáfu - Kynntu þér PWA-vefforrit Vinsæl PWA-vefforrit Vinsælir PWA-leikir Næ ekki að tengjast! Athugaðu internettenginguna þína og prófaðu svo aftur @@ -204,4 +203,4 @@ Kerfisforrit Aðvörun vegna uppfærslu! App Lounge verður lokað af kerfinu á meðan það uppfærir sjálft sig. Vertu helst ekki að gera neitt annað þangað til uppfærslu App Lounge er lokið. - \ No newline at end of file + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d5505806e..d7ad59044 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -153,7 +153,6 @@ \nPuoi riprovare adesso o più tardi.
Si è verificato un errore durante il caricamento delle App. Maggiori informazioni - Scopri le PWA Non posso avviare l\'App Google Play se sono permesse solo App open source. Chiudi Mensilmente @@ -203,4 +202,4 @@ Avviso sui contenuti App Lounge verrà chiusa dal sistema mentre installa l\'aggiornamento. Si prega di non effettuare alcuna attività su App Lounge finchè non sarà aggiornata e chiusa. Avviso sull\'aggiornamento! - \ No newline at end of file + diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index cb3ade70c..31cafe15c 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -52,7 +52,6 @@ Applikasjonsoppdateringer vil bli installert automatisk Oppdateringer Nedlastinger - Oppdag PWA Oppdag %1$s sin oppdatering har mislyktes på grunn av et misforhold (lokasjon, operativsystemversjon…). På gunn av en midlertidig feil kan ikke alle dine applikasjoner bli oppdatert. Prøv igjen senere. @@ -202,4 +201,4 @@ Systemapplikasjon Innholdsvarsel Samler innholdsvurdering for alle applikasjonene du har installert. - \ No newline at end of file + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 35a1480f3..34d1afb76 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -47,7 +47,6 @@ Top Gratis Apps PWA Populaire Spellen PWA Populaire Apps - Ontdek PWA Ontdek Update Fout! Alle apps zijn up-to-date @@ -204,4 +203,4 @@ Deze app kan naaktheid, godslastering, laster, geweld, seksualiteit, politieke incorrectheid of andere mogelijk ongepaste onderwerpen bevatten. Dit is voornamelijk relevant in omgevingen als werkplekken, scholen, religieuze instellingen en gezinnen. Attentie, update! App Lounge zal door het systeem afgesloten worden tijdens zijn update. Voer a.u.b. geen andere taken uit totdat App Lounge geüpdatet en afgesloten is. - \ No newline at end of file + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 32c8bdcb9..81bd63daa 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -123,7 +123,6 @@ Топ Open Source обновленных игр Топ обновленных Open Source приложений Откройте для себя - Откройте для себя PWA Обновление %1$s не произошло из-за поддержки (местоположения, версии ОС...). Из-за временного сбоя все ваши приложения не могут быть обновлены. Пожалуйста, повторите попытку позже. Обновить всё не удалось. Выполняются автоматические повторные попытки. @@ -204,4 +203,4 @@ Запросить исходный отчёт Анонимная учетная запись, которую вы используете в данный момент, недоступна. Пожалуйста, обновите сессию, чтобы получить другую. ОБНОВИТЬ СЕССИИ - \ No newline at end of file + diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ba3250eab..b8b30a5cd 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -110,7 +110,6 @@ Välj åtminstone en källa av applikationer. Integritetsanalys Har du problem\? - Upptäck PWA Populäraste apparna de senaste 24 timmarna med öppen källkod Populäraste spelen de senaste 24 timmarna med öppen källkod Populära PWA-appar @@ -204,4 +203,4 @@ Systemapp Varning för uppdatering! Systemet kommer stänga App Lounge medan uppdatering installeras för App Lounge. Undvik att något annat tills App Lounge är uppdaterat och har stängts. - \ No newline at end of file + diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index e11370dde..f880ad516 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -85,7 +85,6 @@ Geçici bir arıza nedeniyle uygulamalarınızın tümü güncellenemiyor. Lütfen daha sonra tekrar deneyin. %1$s güncellemesi bir destek kuralı (konum, işletim sistemi sürümü...) nedeniyle başarısız oldu. Keşfet - PWA\'ları keşfedin Açık Kaynaklı Tutan Güncel Oyunlar Açık Kaynaklı Tutan Güncel Uygulamalar Son 24 Saatte Açık Kaynaklı Popüler Uygulamalar @@ -187,4 +186,4 @@ \n \nTekrar denemek için Yeniden Dene\'ye basın.
%s ekstra modüller yüklemek istiyor. Bunları yükleyebilmek için AppLounge\'da tekrar oturum açmalısınız. - \ No newline at end of file + diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index c40f460a8..48ad42615 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -97,7 +97,6 @@ Оновлення не вдалося. Автоматичні повторні спроби уже в процесі. Трендові додатки в Топі Безкоштовні ігри в Топі - Дослідити PWA Дослідити %1$d оновлення застосунку доступне @@ -174,4 +173,4 @@ Зареєструватися Обліковий запис недоступний Поділитися - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa41bcdf6..417781487 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,7 +147,6 @@ App Lounge will be closed by the system while installing its own update. Kindly refrain from doing any other task till App Lounge is updated and closed. Discover - Discover PWA Open Source Top Updated Apps Open Source Top Updated Games Open Source Popular Apps In Last 24 Hours diff --git a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt index 196420071..8ba827284 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -21,11 +21,11 @@ package foundation.e.apps.home import android.content.Context import android.text.format.Formatter import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.home.HomeApi import foundation.e.apps.data.application.home.HomeApiImpl import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepository @@ -112,13 +112,13 @@ class HomeApiTest { @Test fun testHomeScreenDataWhenDataIsLimited() = runTest { - val newAppList = mutableListOf( - App("foundation.e.demoone"), - App("foundation.e.demotwo"), - App("foundation.e.demothree"), + val newAppList = mutableListOf( + Application("foundation.e.demoone"), + Application("foundation.e.demotwo"), + Application("foundation.e.demothree"), ) - var newHomeData = mapOf>(Pair("Top Free Apps", newAppList)) + val newHomeData = mapOf>(Pair("Top Free Apps", newAppList)) preferenceManagerModule.isGplaySelectedFake = true formatterMocked.`when` { Formatter.formatFileSize(any(), any()) }.thenReturn("15MB") -- GitLab From 865c4604849b24c6ab9efbe8fc4047788944496c Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 22 Oct 2024 11:51:57 +0200 Subject: [PATCH 12/19] Introduce HomeConverter --- .../apps/data/application/home/HomeApiImpl.kt | 69 ----------------- .../repositories/CleanApkAppsRepository.kt | 69 +---------------- .../repositories/CleanApkPwaRepository.kt | 67 +--------------- .../cleanapk/repositories/HomeConverter.kt | 76 +++++++++++++++++++ 4 files changed, 80 insertions(+), 201 deletions(-) create mode 100644 app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt diff --git a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index 56e2fd965..6ed63a29c 100644 --- a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt @@ -19,22 +19,16 @@ package foundation.e.apps.data.application.home import android.content.Context -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.liveData -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.application.ApplicationDataManager -import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.application.search.FusedHomeDeferred import foundation.e.apps.data.application.search.SearchApi -import foundation.e.apps.data.application.utils.toApplication -import foundation.e.apps.data.cleanapk.data.home.HomeScreenResponse import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.handleNetworkResult @@ -46,10 +40,8 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch -import retrofit2.Response import timber.log.Timber import javax.inject.Inject -import foundation.e.apps.data.cleanapk.data.home.CleanApkHome class HomeApiImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -211,65 +203,4 @@ class HomeApiImpl @Inject constructor( ) } } - - private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { - val list = mutableListOf() - - openSourceCategories.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(cleanApkHome.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - - private val openSourceCategories: Map by lazy { - mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "popular_apps" to context.getString(R.string.popular_apps), - "popular_games" to context.getString(R.string.popular_games), - "discover" to context.getString(R.string.discover) - ) - } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index d17eb49b5..1085c9dd6 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -19,25 +19,20 @@ package foundation.e.apps.data.cleanapk.repositories import android.content.Context -import android.util.Log import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R -import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.data.Application -import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.download.Download -import foundation.e.apps.data.cleanapk.data.home.CleanApkHome import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkAppsRepository @Inject constructor( private val cleanApkRetrofit: CleanApkRetrofit, - private val applicationDataManager: ApplicationDataManager, + private val homeConverter: HomeConverter, @ApplicationContext val context: Context ) : CleanApkRepository, CleanApkDownloadInfoFetcher { @@ -49,8 +44,7 @@ class CleanApkAppsRepository @Inject constructor( ) val home = response.body()?.home ?: throw IllegalStateException("No home data found") - - val listHome = toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) + val listHome = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) val map = mutableMapOf>() listHome.forEach { map[it.title] = it.list @@ -59,55 +53,6 @@ class CleanApkAppsRepository @Inject constructor( return map } - private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { - val list = mutableListOf() - - openSourceCategories.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(cleanApkHome.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - override suspend fun getSearchResult(query: String, searchBy: String?): Response { return cleanApkRetrofit.searchApps( query, @@ -151,14 +96,4 @@ class CleanApkAppsRepository @Inject constructor( val version = versionCode?.let { it as String } return cleanApkRetrofit.getDownloadInfo(idOrPackageName, version, null) } - - private val openSourceCategories: Map by lazy { - mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "discover" to context.getString(R.string.discover) - ) - } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index 85485bfb1..cf235f30f 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -20,21 +20,17 @@ package foundation.e.apps.data.cleanapk.repositories import android.content.Context import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R -import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.data.Application -import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories -import foundation.e.apps.data.cleanapk.data.home.CleanApkHome import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkPwaRepository @Inject constructor( private val cleanAPKRetrofit: CleanApkRetrofit, - private val applicationDataManager: ApplicationDataManager, + private val homeConverter: HomeConverter, @ApplicationContext val context: Context ) : CleanApkRepository { @@ -46,7 +42,7 @@ class CleanApkPwaRepository @Inject constructor( val home = response.body()?.home ?: throw IllegalStateException("No home data found") - val listHome = toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) + val listHome = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) val map = mutableMapOf>() listHome.forEach { map[it.title] = it.list @@ -55,55 +51,6 @@ class CleanApkPwaRepository @Inject constructor( return map } - private suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { - val list = mutableListOf() - - openSourceCategories.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(cleanApkHome.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - override suspend fun getSearchResult(query: String, searchBy: String?): Response { return cleanAPKRetrofit.searchApps( query, @@ -139,14 +86,4 @@ class CleanApkPwaRepository @Inject constructor( override suspend fun getAppDetails(packageNameOrId: String): Response { return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) } - - private val openSourceCategories: Map by lazy { - mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "discover" to context.getString(R.string.discover) - ) - } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt new file mode 100644 index 000000000..d2bfc0dab --- /dev/null +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt @@ -0,0 +1,76 @@ +package foundation.e.apps.data.cleanapk.repositories + +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.R +import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Home +import foundation.e.apps.data.cleanapk.data.home.CleanApkHome +import javax.inject.Inject + +class HomeConverter @Inject constructor( + @ApplicationContext val context: Context, + private val applicationDataManager: ApplicationDataManager +) { + + suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { + val list = mutableListOf() + + openSourceCategories.forEach { (key, value) -> + when (key) { + "top_updated_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) + } + + "top_updated_games" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) + } + + "popular_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) + } + + "popular_games" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) + } + + "popular_apps_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_apps_in_last_24_hours, + list, + value + ) + } + + "popular_games_in_last_24_hours" -> { + applicationDataManager.prepareApps( + cleanApkHome.popular_games_in_last_24_hours, + list, + value + ) + } + + "discover" -> { + applicationDataManager.prepareApps(cleanApkHome.discover, list, value) + } + } + } + + return list.map { + it.source = appType + it + } + } + + private val openSourceCategories: Map by lazy { + mapOf( + "top_updated_apps" to context.getString(R.string.top_updated_apps), + "top_updated_games" to context.getString(R.string.top_updated_games), + "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), + "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), + "popular_apps" to context.getString(R.string.popular_apps), + "popular_games" to context.getString(R.string.popular_games), + "discover" to context.getString(R.string.discover) + ) + } +} \ No newline at end of file -- GitLab From c6c6f12207b96404caa2ca0e63afa9d06d765145 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 23 Oct 2024 08:47:27 +0200 Subject: [PATCH 13/19] Sanitize getAppDetails() calls --- .../foundation/e/apps/data/StoreRepository.kt | 2 +- .../apps/data/application/apps/AppsApiImpl.kt | 13 +++++------- .../repositories/CleanApkAppsRepository.kt | 5 +++-- .../repositories/CleanApkPwaRepository.kt | 5 +++-- .../data/playstore/PlayStoreRepository.kt | 20 +++++++++---------- .../foundation/e/apps/apps/AppsApiTest.kt | 17 ++++++++-------- .../e/apps/fused/SearchApiImplTest.kt | 10 +++++----- .../foundation/e/apps/home/HomeApiTest.kt | 2 +- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt index 4a9930756..e1c04d98e 100644 --- a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt @@ -22,5 +22,5 @@ import foundation.e.apps.data.application.data.Application interface StoreRepository { suspend fun getHomeScreenData(): Map> - suspend fun getAppDetails(packageNameOrId: String): Any? + suspend fun getAppDetails(packageNameOrId: String): Application } diff --git a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt index 835c3babe..beb4238d9 100644 --- a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt @@ -60,8 +60,7 @@ class AppsApiImpl @Inject constructor( if (result?.hasSingleResult() == true) { application = - (appSources.cleanApkAppsRepo.getAppDetails(result.apps[0]._id) - as Response).body()?.app ?: Application() + appSources.cleanApkAppsRepo.getAppDetails(result.apps[0]._id) } application.updateFilterLevel(null) @@ -189,18 +188,16 @@ class AppsApiImpl @Inject constructor( authData: AuthData, origin: Origin ): Pair { - var application: Application? + var application: Application val result = handleNetworkResult { application = if (origin == Origin.CLEANAPK) { - (appSources.cleanApkAppsRepo.getAppDetails(id) - as Response).body()?.app + appSources.cleanApkAppsRepo.getAppDetails(id) } else { - val app = appSources.gplayRepo.getAppDetails(packageName) as App? - app?.toApplication(context) + appSources.gplayRepo.getAppDetails(packageName) } - application?.let { + application.let { applicationDataManager.updateStatus(it) it.updateType() it.updateSource(context) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index 1085c9dd6..813dd90c4 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -88,8 +88,9 @@ class CleanApkAppsRepository @Inject constructor( return cleanApkRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + override suspend fun getAppDetails(packageNameOrId: String): Application { + val response = cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return response.body()?.app ?: throw IllegalStateException("No app data found") } override suspend fun getDownloadInfo(idOrPackageName: String, versionCode: Any?): Response { diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index cf235f30f..70da71375 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -83,7 +83,8 @@ class CleanApkPwaRepository @Inject constructor( return cleanAPKRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + override suspend fun getAppDetails(packageNameOrId: String): Application { + val response = cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return response.body()?.app ?: throw IllegalStateException("No app data found") } } diff --git a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt index 5b7b650a8..22e0d88b7 100644 --- a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt @@ -19,9 +19,8 @@ package foundation.e.apps.data.playstore import android.content.Context -import android.util.Log import com.aurora.gplayapi.SearchSuggestEntry -import com.aurora.gplayapi.data.models.App +import com.aurora.gplayapi.data.models.App as GplayApp import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.data.models.Category import com.aurora.gplayapi.data.models.ContentRating @@ -84,7 +83,7 @@ class PlayStoreRepository @Inject constructor( fun getSearchResult( query: String, subBundle: MutableSet? - ): Pair, MutableSet> { + ): Pair, MutableSet> { val authData = authenticatorRepository.getGPlayAuthOrThrow() val searchHelper = SearchHelper(authData).using(gPlayHttpClient) @@ -103,7 +102,7 @@ class PlayStoreRepository @Inject constructor( private fun getSearchResultPair( searchBundle: SearchBundle, query: String - ): Pair, MutableSet> { + ): Pair, MutableSet> { val apps = searchBundle.appList Timber.d("Found ${apps.size} apps for query, $query") return Pair(apps, searchBundle.subBundles) @@ -147,19 +146,20 @@ class PlayStoreRepository @Inject constructor( return categoryList } - override suspend fun getAppDetails(packageNameOrId: String): App? { - var appDetails: App? + override suspend fun getAppDetails(packageNameOrId: String): Application { + var appDetails: GplayApp? val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) } - return appDetails + + return appDetails?.toApplication(context) ?: Application() } - suspend fun getAppsDetails(packageNamesOrIds: List): List { - val appDetailsList = mutableListOf() + suspend fun getAppsDetails(packageNamesOrIds: List): List { + val appDetailsList = mutableListOf() val authData = authenticatorRepository.getGPlayAuthOrThrow() withContext(Dispatchers.IO) { @@ -179,7 +179,7 @@ class PlayStoreRepository @Inject constructor( chart: Chart, authData: AuthData ): List { - val topApps = mutableListOf() + val topApps = mutableListOf() withContext(Dispatchers.IO) { val topChartsHelper = TopChartsHelper(authData).using(gPlayHttpClient) topApps.addAll(topChartsHelper.getCluster(type, chart).clusterAppList) diff --git a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt index 1dc1ce734..8cda6e3cf 100644 --- a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt +++ b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt @@ -22,7 +22,6 @@ import android.content.Context import android.text.format.Formatter import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.aurora.gplayapi.Constants -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer @@ -121,7 +120,7 @@ class AppsApiTest { @Test fun `is any app updated when new list is empty`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -155,7 +154,7 @@ class AppsApiTest { @Test fun `is any app updated when any app is uninstalled`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -176,7 +175,7 @@ class AppsApiTest { ) ) - val newAppList = mutableListOf( + val newAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -203,7 +202,7 @@ class AppsApiTest { @Test fun `has any app install status changed when changed`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -264,7 +263,7 @@ class AppsApiTest { @Test fun `has any app install status changed when not changed`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -325,7 +324,7 @@ class AppsApiTest { @Test fun `has any app install status changed when installation_issue`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.INSTALLATION_ISSUE, @@ -492,7 +491,7 @@ class AppsApiTest { } Mockito.`when`(gPlayAPIRepository.getAppDetails(fusedApp.package_name)) - .thenReturn(App(fusedApp.package_name)) + .thenReturn(Application(fusedApp.package_name)) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( @@ -534,7 +533,7 @@ class AppsApiTest { } Mockito.`when`(gPlayAPIRepository.getAppDetails(fusedApp.package_name)) - .thenReturn(App(fusedApp.package_name)) + .thenReturn(Application(fusedApp.package_name)) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( diff --git a/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt b/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt index 3337aea51..3bb56cea6 100644 --- a/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt +++ b/app/src/test/java/foundation/e/apps/fused/SearchApiImplTest.kt @@ -148,7 +148,7 @@ class SearchApiImplTest { @Ignore("Dependencies are not mockable") @Test fun `getSearchResult When all sources are selected`() = runTest { - val appList = mutableListOf( + val appList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -174,7 +174,7 @@ class SearchApiImplTest { val searchResult = Search(apps = appList, numberOfResults = 3, success = true) val packageNameSearchResponse = Response.success(searchResult) - val gplayPackageResult = App("com.search.package") + val gplayPackageResult = Application("com.search.package") preferenceManagerModule.isPWASelectedFake = true preferenceManagerModule.isOpenSourceelectedFake = true @@ -196,7 +196,7 @@ class SearchApiImplTest { private suspend fun setupMockingSearchApp( packageNameSearchResponse: Response?, - gplayPackageResult: App, + gplayPackageResult: Application, gplayLivedata: Pair, MutableSet>, willThrowException: Boolean = false ) { @@ -231,7 +231,7 @@ class SearchApiImplTest { ).thenReturn(packageNameSearchResponse) Mockito.`when`(cleanApkAppsRepository.getAppDetails(any())) - .thenReturn(Response.error(404, "".toResponseBody())) + .thenReturn(Application()) Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null)) .thenReturn(gplayLivedata) @@ -266,7 +266,7 @@ class SearchApiImplTest { val searchResult = Search(apps = appList, numberOfResults = 1, success = true) val packageNameSearchResponse = Response.success(searchResult) - val gplayPackageResult = App("com.search.package") + val gplayPackageResult = Application("com.search.package") val gplayFlow: Pair, MutableSet> = Pair( listOf(App("a.b.c"), App("c.d.e"), App("d.e.f"), App("d.e.g")), mutableSetOf() diff --git a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt index 8ba827284..ab9348c97 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -124,7 +124,7 @@ class HomeApiTest { formatterMocked.`when` { Formatter.formatFileSize(any(), any()) }.thenReturn("15MB") Mockito.`when`(gPlayAPIRepository.getHomeScreenData()).thenReturn(newHomeData) Mockito.`when`(gPlayAPIRepository.getAppDetails(ArgumentMatchers.anyString())).thenReturn( - App("foundation.e.demothree") + Application("foundation.e.demothree") ) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( -- GitLab From ec72e191e8185a558ed949b18214d75ccaed65c1 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 24 Oct 2024 11:38:20 +0200 Subject: [PATCH 14/19] Some renaming --- .../repositories/CleanApkPwaRepository.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt index 70da71375..edf52f91e 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -22,20 +22,19 @@ import android.content.Context import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import javax.inject.Inject class CleanApkPwaRepository @Inject constructor( - private val cleanAPKRetrofit: CleanApkRetrofit, + private val cleanApkRetrofit: CleanApkRetrofit, private val homeConverter: HomeConverter, @ApplicationContext val context: Context ) : CleanApkRepository { override suspend fun getHomeScreenData(): Map> { - val response = cleanAPKRetrofit.getHomeScreenData( + val response = cleanApkRetrofit.getHomeScreenData( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) @@ -52,7 +51,7 @@ class CleanApkPwaRepository @Inject constructor( } override suspend fun getSearchResult(query: String, searchBy: String?): Response { - return cleanAPKRetrofit.searchApps( + return cleanApkRetrofit.searchApps( query, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -63,7 +62,7 @@ class CleanApkPwaRepository @Inject constructor( } override suspend fun getAppsByCategory(category: String, paginationParameter: Any?): Response { - return cleanAPKRetrofit.listApps( + return cleanApkRetrofit.listApps( category, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -73,18 +72,18 @@ class CleanApkPwaRepository @Inject constructor( } override suspend fun getCategories(): Response { - return cleanAPKRetrofit.getCategoriesList( + return cleanApkRetrofit.getCategoriesList( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) } override suspend fun checkAvailablePackages(packageNames: List): Response { - return cleanAPKRetrofit.checkAvailablePackages(packageNames) + return cleanApkRetrofit.checkAvailablePackages(packageNames) } override suspend fun getAppDetails(packageNameOrId: String): Application { - val response = cleanAPKRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + val response = cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) return response.body()?.app ?: throw IllegalStateException("No app data found") } } -- GitLab From a6827ab7cc4f42f9910ebb6e8cd4467df0b6f813 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 25 Oct 2024 13:37:29 +0200 Subject: [PATCH 15/19] Remove useless context parameter --- .../apps/data/cleanapk/repositories/CleanApkAppsRepository.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt index 813dd90c4..b97b3ce30 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt @@ -32,8 +32,7 @@ import javax.inject.Inject class CleanApkAppsRepository @Inject constructor( private val cleanApkRetrofit: CleanApkRetrofit, - private val homeConverter: HomeConverter, - @ApplicationContext val context: Context + private val homeConverter: HomeConverter ) : CleanApkRepository, CleanApkDownloadInfoFetcher { override suspend fun getHomeScreenData(): Map> { -- GitLab From 178cb995cb58477b37cd6cc5faf546abf8d28cdf Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Fri, 25 Oct 2024 14:42:08 +0200 Subject: [PATCH 16/19] Remove useless empty catogories on home page --- .../data/cleanapk/data/home/CleanApkHome.kt | 2 -- .../cleanapk/repositories/HomeConverter.kt | 18 ------------------ app/src/main/res/values-de/strings.xml | 2 -- app/src/main/res/values-es/strings.xml | 2 -- app/src/main/res/values-fi/strings.xml | 2 -- app/src/main/res/values-fr/strings.xml | 2 -- app/src/main/res/values-is/strings.xml | 2 -- app/src/main/res/values-it/strings.xml | 2 -- app/src/main/res/values-nb-rNO/strings.xml | 2 -- app/src/main/res/values-nl/strings.xml | 2 -- app/src/main/res/values-ru/strings.xml | 2 -- app/src/main/res/values-sv/strings.xml | 2 -- app/src/main/res/values-tr/strings.xml | 2 -- app/src/main/res/values-uk/strings.xml | 2 -- app/src/main/res/values/strings.xml | 2 -- 15 files changed, 46 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt index 1647a00eb..7118307be 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt @@ -26,8 +26,6 @@ data class CleanApkHome( val top_updated_games: List = emptyList(), val popular_apps: List = emptyList(), val popular_games: List = emptyList(), - val popular_apps_in_last_24_hours: List = emptyList(), - val popular_games_in_last_24_hours: List = emptyList(), val discover: List = emptyList(), var origin: Origin = Origin.CLEANAPK // Origin ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt index d2bfc0dab..a5ecafbfc 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt @@ -34,22 +34,6 @@ class HomeConverter @Inject constructor( applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) } - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - cleanApkHome.popular_games_in_last_24_hours, - list, - value - ) - } - "discover" -> { applicationDataManager.prepareApps(cleanApkHome.discover, list, value) } @@ -66,8 +50,6 @@ class HomeConverter @Inject constructor( mapOf( "top_updated_apps" to context.getString(R.string.top_updated_apps), "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), "popular_apps" to context.getString(R.string.popular_apps), "popular_games" to context.getString(R.string.popular_games), "discover" to context.getString(R.string.discover) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index d9183a225..09e7cd96a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -72,8 +72,6 @@ Entdecke Top quelloffene aktualisierte Apps Top quelloffene aktualisierte Spiele - Beliebteste quelloffene Apps in den letzten 24 Stunden - Beliebteste quelloffene Spiele in den letzten 24 Stunden PWA beliebteste Apps PWA beliebteste Spiele Top kostenlose Apps diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d33937af0..5e80a9a8b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -76,8 +76,6 @@ Explorar Aplicaciones de código abierto más actualizadas Juegos de código abierto más actualizados - Juegos de código abierto más populares en las últimas 24 horas - Aplicaciones de código abierto más populares en las últimas 24 horas Aplicaciones PWA populares Juegos PWA populares Las mejores aplicaciones gratuitas diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index d5c9371ec..ad26a3cfb 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -110,8 +110,6 @@ Top ilmaiset sovellukset PWA Suositut pelit PWA Suositut sovellukset - Suosittuja avoimen lähdekoodin pelejä viimeisen 24 tunnin aikana - Suosittuja avoimen lähdekoodin sovelluksia viimeisen 24 tunnin aikana Avoimen lähdekoodin päivitettyjen pelien Top lista Avoimen lähdekoodin päivitettyjen sovellusten Top lista Tutustu diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9648fdd15..c5f7fe1f2 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -71,8 +71,6 @@ Découvrir Top des apps Open Source mises à jour Top des jeux Open Source mis à jour - Jeux populaires Open Source dans les dernières 24h - Apps populaires Open Source dans les dernières 24 h Apps PWA populaires Jeux PWA populaires Top des apps gratuites diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 895970e54..05fdf538a 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -133,8 +133,6 @@ Vinsælustu uppfærðu forritin með opinn grunnkóða Vinsælustu uppfærðir leikir með opinn grunnkóða Vinsælustu ókeypis og frjálsu forritin - Vinsæl forrit síðasta sólahring með opinn grunnkóða - Vinsæla leiki síðasta sólahring með opinn grunnkóða Vinsælustu ókeypis og frjálsu leikirnir Forrit með mestu innkomuna Leikir með mestu innkomuna diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d7ad59044..fdee09cff 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -75,8 +75,6 @@ Errore sconosciuto! Aggiorna tutto Scopri - App Open Source più richieste nelle ultime 24 ore - Giochi Open Source più richiesti nelle ultime 24 ore App PWA più richieste Giochi PWA più richiesti Migliori App Open Source aggiornate diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 31cafe15c..4ad70dd98 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -163,9 +163,7 @@ Topp gratis applikasjoner Mest populære spill Topp gratis spill - Populære åpen kildekode-applikasjoner de siste 24 timer Populære PWA spill - Populære åpen kildekode-spill de siste 24 timer Mest innbringende applikasjoner Mest innbringende spill Ingen sporingsinformasjon tilgjengelig for denne applikasjonen. diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 34d1afb76..b8887c22f 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -151,8 +151,6 @@ Geen \"runtime android\" machtiging gevonden! Top Populaire Games Top Populaire Apps - Open Source Populaire Games van de laatste 24 uur - Open Source Populaire Apps van de laatste 24 uur Open Source Top Geüpdatete Games Open Source Top Geüpdatet Apps De update voor %1$s is niet door een ondersteuning regel (locatie, OS versie...). diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 81bd63daa..827fb00d8 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -118,8 +118,6 @@ Топ бесплатных приложений Популярные PWA игры Популярные PWA приложения - Популярные Open Source игры за последние 24 часа - Популярные Open Source приложения за последние 24 часа Топ Open Source обновленных игр Топ обновленных Open Source приложений Откройте для себя diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b8b30a5cd..aa11e72a7 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -110,8 +110,6 @@ Välj åtminstone en källa av applikationer. Integritetsanalys Har du problem\? - Populäraste apparna de senaste 24 timmarna med öppen källkod - Populäraste spelen de senaste 24 timmarna med öppen källkod Populära PWA-appar Populära PWA-spel Hämtningar diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index f880ad516..c8afa6a5e 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -87,8 +87,6 @@ Keşfet Açık Kaynaklı Tutan Güncel Oyunlar Açık Kaynaklı Tutan Güncel Uygulamalar - Son 24 Saatte Açık Kaynaklı Popüler Uygulamalar - Son 24 Saatin Popüler Açık Kaynak Oyunları PWA popüler uygulamalar PWA Popüler Uygulamalar En Çok Kazanan Uygulamalar diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 48ad42615..a02f1f8a6 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -121,8 +121,6 @@ Топ безкоштовних ігор Популярні прогресивні веб-ігри Популярні прогресивні веб-застосунки - Популярні ігри з відкритим кодом за останню добу - Популярні додатки з відкритим кодом за останню добу Топ оновлених Ігор з відкритим кодом Топ оновлених додатків з відкритим кодом Оновлення %1$s не вдалося з причини підтримки (наприклад місцезнаходження, версія ОС…). diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 417781487..94f39e423 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,8 +149,6 @@ Discover Open Source Top Updated Apps Open Source Top Updated Games - Open Source Popular Apps In Last 24 Hours - Open Source Popular Games In Last 24 Hours PWA Popular Apps PWA Popular Games Top Free Apps -- GitLab From e7bf3e5fc26fe8ae65708d6685e5aaa802430225 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 29 Oct 2024 13:33:22 +0100 Subject: [PATCH 17/19] 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 From ce9480e022db61063e5803e31bd37fe251f1cda4 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 30 Oct 2024 15:02:20 +0100 Subject: [PATCH 18/19] Introduce CustomException --- .../foundation/e/apps/data/NetworkHandler.kt | 12 ++- .../foundation/e/apps/data/ResultSupreme.kt | 9 ++- .../e/apps/data/login/AuthObject.kt | 16 ++-- .../data/login/AuthenticatorRepository.kt | 9 ++- .../data/login/api/PlayStoreLoginWrapper.kt | 46 ++++++++++-- .../login/exceptions/CleanApkException.kt | 26 ------- ...idationException.kt => CustomException.kt} | 31 +++++--- .../data/login/exceptions/GPlayException.kt | 26 ------- .../login/exceptions/GPlayLoginException.kt | 31 -------- .../data/login/exceptions/LoginException.kt | 24 ------ .../exceptions/UnknownSourceException.kt | 23 ------ .../splitinstall/SplitInstallBinder.kt | 5 +- .../e/apps/provider/AgeRatingProvider.kt | 5 +- .../java/foundation/e/apps/ui/MainActivity.kt | 4 +- .../ui/application/ApplicationFragment.kt | 8 +- .../ui/application/ApplicationViewModel.kt | 23 +++--- .../ApplicationListFragment.kt | 8 +- .../ApplicationListViewModel.kt | 28 ++++--- .../e/apps/ui/categories/AppsFragment.kt | 8 +- .../apps/ui/categories/CategoriesViewModel.kt | 19 ++--- .../e/apps/ui/categories/GamesFragment.kt | 8 +- .../foundation/e/apps/ui/home/HomeFragment.kt | 29 +++----- .../e/apps/ui/home/HomeViewModel.kt | 20 ++--- .../ui/parentFragment/LoadingViewModel.kt | 11 ++- .../apps/ui/parentFragment/TimeoutFragment.kt | 74 +++++++------------ .../e/apps/ui/search/SearchFragment.kt | 8 +- .../e/apps/ui/search/SearchViewModel.kt | 28 +++---- .../e/apps/ui/updates/UpdatesFragment.kt | 22 ++++-- .../e/apps/ui/updates/UpdatesViewModel.kt | 23 +++--- 29 files changed, 237 insertions(+), 347 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/data/login/exceptions/CleanApkException.kt rename app/src/main/java/foundation/e/apps/data/login/exceptions/{GPlayValidationException.kt => CustomException.kt} (63%) delete mode 100644 app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayException.kt delete mode 100644 app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayLoginException.kt delete mode 100644 app/src/main/java/foundation/e/apps/data/login/exceptions/LoginException.kt delete mode 100644 app/src/main/java/foundation/e/apps/data/login/exceptions/UnknownSourceException.kt diff --git a/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt b/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt index f5c5cdd50..5b13f5591 100644 --- a/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt +++ b/app/src/main/java/foundation/e/apps/data/NetworkHandler.kt @@ -18,9 +18,9 @@ package foundation.e.apps.data +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.data.playstore.utils.GPlayHttpClient import foundation.e.apps.data.playstore.utils.GplayHttpRequestException -import foundation.e.apps.data.login.exceptions.GPlayException import kotlinx.coroutines.delay import timber.log.Timber import java.net.SocketTimeoutException @@ -55,9 +55,15 @@ private fun handleSocketTimeoutException(e: SocketTimeoutException): ResultS private fun resultSupremeGplayHttpRequestException(e: GplayHttpRequestException): ResultSupreme { val message = extractErrorMessage(e) - val exception = GPlayException(e.status == GPlayHttpClient.STATUS_CODE_TIMEOUT, message) + val error = if (e.status == GPlayHttpClient.STATUS_CODE_TIMEOUT) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + + val exception = CustomException(error, message) - return if (exception.isTimeout) { + return if (error == CustomException.Error.TIMEOUT_ERROR) { ResultSupreme.Timeout(exception = exception) } else { ResultSupreme.Error(message, exception) diff --git a/app/src/main/java/foundation/e/apps/data/ResultSupreme.kt b/app/src/main/java/foundation/e/apps/data/ResultSupreme.kt index a7a773f60..70eb4ff6e 100644 --- a/app/src/main/java/foundation/e/apps/data/ResultSupreme.kt +++ b/app/src/main/java/foundation/e/apps/data/ResultSupreme.kt @@ -18,6 +18,7 @@ package foundation.e.apps.data import foundation.e.apps.data.enums.ResultStatus +import foundation.e.apps.data.login.exceptions.CustomException import java.util.concurrent.TimeoutException private const val UNKNOWN_ERROR = "Unknown error!" @@ -60,7 +61,7 @@ sealed class ResultSupreme { data?.let { setData(it) } - this.exception = exception + this.exception?.encapsulatedException = exception } } @@ -76,7 +77,7 @@ sealed class ResultSupreme { */ constructor(message: String, exception: Exception? = null) : this() { this.message = message - this.exception = exception + this.exception?.encapsulatedException = exception } /** @@ -111,7 +112,7 @@ sealed class ResultSupreme { /** * Exception from try-catch block for error cases. */ - var exception: Exception? = null + var exception: CustomException? = null fun isValidData() = data != null @@ -155,7 +156,7 @@ sealed class ResultSupreme { this.data = data } else { this.message = message.ifBlank { status.message } - this.exception = exception + this.exception?.encapsulatedException = exception } } return resultObject diff --git a/app/src/main/java/foundation/e/apps/data/login/AuthObject.kt b/app/src/main/java/foundation/e/apps/data/login/AuthObject.kt index e63f051de..7d2eb7cf7 100644 --- a/app/src/main/java/foundation/e/apps/data/login/AuthObject.kt +++ b/app/src/main/java/foundation/e/apps/data/login/AuthObject.kt @@ -21,8 +21,7 @@ import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.User import foundation.e.apps.data.login.AuthObject.GPlayAuth -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayValidationException +import foundation.e.apps.data.login.exceptions.CustomException /** * Auth objects define which sources data is to be loaded from, for each source, also provides @@ -48,10 +47,12 @@ sealed class AuthObject { return GPlayAuth( ResultSupreme.Error( message = message, - exception = GPlayValidationException( + exception = CustomException( + CustomException.Error.AUTHENTICATION_ERROR, message, this.user, 401, + CustomException.Type.GOOGLE_PLAY ) ).apply { otherPayload = this@GPlayAuth.result.otherPayload @@ -66,14 +67,15 @@ sealed class AuthObject { return CleanApk( ResultSupreme.Error( message = "Unauthorized", - exception = CleanApkException( - isTimeout = false, - message = "Unauthorized", + exception = CustomException( + CustomException.Error.AUTHENTICATION_ERROR, + "Unauthorized", + this.user ) ), this.user, ) } } - // Add more auth types here + } 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 fccc0b15a..1533dd498 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 @@ -20,7 +20,7 @@ package foundation.e.apps.data.login import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.User -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import javax.inject.Inject import javax.inject.Singleton @@ -34,7 +34,12 @@ class AuthenticatorRepository @Inject constructor( private var gPlayAuth: AuthData? = null fun getGPlayAuthOrThrow(): AuthData { - return gPlayAuth ?: throw GPlayLoginException(false, "AuthData is not available!", getUserType()) + return gPlayAuth ?: throw CustomException( + CustomException.Error.AUTHENTICATION_ERROR, + "AuthData is not available!", + getUserType(), + type = CustomException.Type.GOOGLE_PLAY + ) } fun setGPlayAuth(auth: AuthData) { diff --git a/app/src/main/java/foundation/e/apps/data/login/api/PlayStoreLoginWrapper.kt b/app/src/main/java/foundation/e/apps/data/login/api/PlayStoreLoginWrapper.kt index 4d013b2f0..c1604c3a4 100644 --- a/app/src/main/java/foundation/e/apps/data/login/api/PlayStoreLoginWrapper.kt +++ b/app/src/main/java/foundation/e/apps/data/login/api/PlayStoreLoginWrapper.kt @@ -23,7 +23,7 @@ import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.enums.User import foundation.e.apps.data.playstore.utils.AC2DMUtil import foundation.e.apps.data.handleNetworkResult -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.utils.eventBus.AppEvent import foundation.e.apps.utils.eventBus.EventBus import java.util.Locale @@ -52,8 +52,20 @@ class PlayStoreLoginWrapper constructor( return result.apply { this.data?.locale = locale this.exception = when (result) { - is ResultSupreme.Timeout -> GPlayLoginException(true, "GPlay API timeout", user) - is ResultSupreme.Error -> GPlayLoginException(false, result.message, user) + is ResultSupreme.Timeout -> + CustomException( + CustomException.Error.TIMEOUT_ERROR, + "GPlay API timeout", + user, + type = CustomException.Type.GOOGLE_PLAY + ) + is ResultSupreme.Error -> + CustomException( + CustomException.Error.AUTHENTICATION_ERROR, + result.message, + user, + type = CustomException.Type.GOOGLE_PLAY + ) else -> { EventBus.invokeEvent(AppEvent.SuccessfulLogin(user)) null @@ -82,8 +94,19 @@ class PlayStoreLoginWrapper constructor( } return ResultSupreme.replicate(result, response).apply { this.exception = when (result) { - is ResultSupreme.Timeout -> GPlayLoginException(true, "GPlay API timeout", user) - is ResultSupreme.Error -> GPlayLoginException(false, result.message, user) + is ResultSupreme.Timeout -> + CustomException( + CustomException.Error.TIMEOUT_ERROR, + "GPlay API timeout", + user, + type = CustomException.Type.GOOGLE_PLAY + ) + is ResultSupreme.Error -> CustomException( + CustomException.Error.AUTHENTICATION_ERROR, + result.message, + user, + type = CustomException.Type.GOOGLE_PLAY + ) else -> null } } @@ -129,8 +152,17 @@ class PlayStoreLoginWrapper constructor( } return result.apply { this.exception = when (result) { - is ResultSupreme.Timeout -> GPlayLoginException(true, "GPlay API timeout", User.GOOGLE) - is ResultSupreme.Error -> GPlayLoginException(false, result.message, User.GOOGLE) + is ResultSupreme.Timeout -> CustomException( + CustomException.Error.TIMEOUT_ERROR, + "GPlay API timeout", + User.GOOGLE, + type = CustomException.Type.GOOGLE_PLAY + ) + is ResultSupreme.Error -> CustomException( + CustomException.Error.AUTHENTICATION_ERROR, + result.message, + User.GOOGLE, + type = CustomException.Type.GOOGLE_PLAY) else -> null } } diff --git a/app/src/main/java/foundation/e/apps/data/login/exceptions/CleanApkException.kt b/app/src/main/java/foundation/e/apps/data/login/exceptions/CleanApkException.kt deleted file mode 100644 index 293819914..000000000 --- a/app/src/main/java/foundation/e/apps/data/login/exceptions/CleanApkException.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019-2022 E FOUNDATION - * - * 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.login.exceptions - -/** - * This exception is for all CleanApk data loading exceptions. - */ -class CleanApkException( - val isTimeout: Boolean, - message: String? = null, -) : LoginException(message) diff --git a/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayValidationException.kt b/app/src/main/java/foundation/e/apps/data/login/exceptions/CustomException.kt similarity index 63% rename from app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayValidationException.kt rename to app/src/main/java/foundation/e/apps/data/login/exceptions/CustomException.kt index 5b4322a4c..271a29bce 100644 --- a/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayValidationException.kt +++ b/app/src/main/java/foundation/e/apps/data/login/exceptions/CustomException.kt @@ -19,14 +19,23 @@ package foundation.e.apps.data.login.exceptions import foundation.e.apps.data.enums.User -/** - * This exception is specifically used when a GPlay auth data could not be validated. - * This is not the case as timeout, this exception usually means the server informed that the - * current auth data is not valid. - * Use [networkCode] to be sure that the server call was successful (should be 200). - */ -class GPlayValidationException( - message: String, - user: User, - val networkCode: Int, -) : GPlayLoginException(false, message, user) +class CustomException( + val error: Error? = null, + override val message: String? = null, + val user: User? = null, + val networkCode: Int = -1, + val type: Type? = null, + var encapsulatedException: Exception? = null +) : Exception(message) { + + enum class Error { + TIMEOUT_ERROR, + AUTHENTICATION_ERROR, + UNKNOWN_ERROR + } + + enum class Type { + GOOGLE_PLAY, + CLEAN_PK + } +} diff --git a/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayException.kt b/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayException.kt deleted file mode 100644 index 345208778..000000000 --- a/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayException.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2019-2022 E FOUNDATION - * - * 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.login.exceptions - -/** - * This exception is for all Google Play network calls or other GPlay related exceptions. - */ -open class GPlayException( - val isTimeout: Boolean, - message: String? = null, -) : LoginException(message) diff --git a/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayLoginException.kt b/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayLoginException.kt deleted file mode 100644 index d6a64a7bb..000000000 --- a/app/src/main/java/foundation/e/apps/data/login/exceptions/GPlayLoginException.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2019-2022 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.login.exceptions - -import foundation.e.apps.data.enums.User - -/** - * Parent class for all GPlay login related errors. - * Examples: - * unable to get anonymous token, AuthData validation failed, aasToken error etc. - */ -open class GPlayLoginException( - isTimeout: Boolean, - message: String? = null, - val user: User, -) : GPlayException(isTimeout, message) diff --git a/app/src/main/java/foundation/e/apps/data/login/exceptions/LoginException.kt b/app/src/main/java/foundation/e/apps/data/login/exceptions/LoginException.kt deleted file mode 100644 index e69cb47b5..000000000 --- a/app/src/main/java/foundation/e/apps/data/login/exceptions/LoginException.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2019-2022 E FOUNDATION - * - * 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.login.exceptions - -/** - * Super class for all Login related exceptions. - * https://gitlab.e.foundation/e/backlog/-/issues/5680 - */ -open class LoginException(message: String?) : Exception(message) diff --git a/app/src/main/java/foundation/e/apps/data/login/exceptions/UnknownSourceException.kt b/app/src/main/java/foundation/e/apps/data/login/exceptions/UnknownSourceException.kt deleted file mode 100644 index 3c881d9f6..000000000 --- a/app/src/main/java/foundation/e/apps/data/login/exceptions/UnknownSourceException.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2019-2022 E FOUNDATION - * - * 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.login.exceptions - -/** - * Generic exception class - used to define unknown errors. - */ -class UnknownSourceException : LoginException("") 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 a3e0c7684..6d61487dc 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 @@ -26,7 +26,6 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.pm.PackageManager -import android.os.Build import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat @@ -37,7 +36,7 @@ import foundation.e.apps.R import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.login.AuthenticatorRepository -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -73,7 +72,7 @@ class SplitInstallBinder( authenticatorRepository.getValidatedAuthData() authenticatorRepository.getGPlayAuthOrThrow() downloadModule(packageName, moduleName) - } catch (exception: GPlayLoginException) { + } catch (exception: CustomException) { Timber.w("$AUTH_DATA_ERROR_MESSAGE $exception") handleError(packageName) } 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 0ed06df83..0a72459d0 100644 --- a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt +++ b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt @@ -26,7 +26,6 @@ import android.content.UriMatcher import android.database.Cursor import android.database.MatrixCursor import android.net.Uri -import android.os.Build import androidx.core.app.NotificationCompat import dagger.hilt.EntryPoint import dagger.hilt.InstallIn @@ -44,7 +43,7 @@ import foundation.e.apps.data.blockedApps.BlockedAppRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthenticatorRepository -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.data.parentalcontrol.ContentRatingDao import foundation.e.apps.data.parentalcontrol.ContentRatingEntity import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository @@ -288,7 +287,7 @@ class AgeRatingProvider : ContentProvider() { return try { authenticatorRepository.getGPlayAuthOrThrow() true - } catch (e: GPlayLoginException) { + } catch (e: CustomException) { Timber.e("No AuthData to check content rating") false } diff --git a/app/src/main/java/foundation/e/apps/ui/MainActivity.kt b/app/src/main/java/foundation/e/apps/ui/MainActivity.kt index b897133a0..b3d40fdaa 100644 --- a/app/src/main/java/foundation/e/apps/ui/MainActivity.kt +++ b/app/src/main/java/foundation/e/apps/ui/MainActivity.kt @@ -50,7 +50,7 @@ import foundation.e.apps.data.enums.User import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.PlayStoreAuthenticator -import foundation.e.apps.data.login.exceptions.GPlayValidationException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.ActivityMainBinding import foundation.e.apps.install.updates.UpdatesNotifier import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment @@ -356,7 +356,7 @@ class MainActivity : AppCompatActivity() { gPlayAuthObject?.result?.run { if (isSuccess()) { viewModel.gPlayAuthData = data as AuthData - } else if (exception is GPlayValidationException) { + } else if (exception?.type == CustomException.Type.GOOGLE_PLAY) { val email = otherPayload.toString() viewModel.uploadFaultyTokenToEcloud( email, 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 c4bde026c..622071c8b 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 @@ -61,7 +61,7 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.User import foundation.e.apps.data.enums.isInitialized import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentApplicationBinding import foundation.e.apps.di.CommonUtilsModule.LIST_OF_NULL import foundation.e.apps.domain.ValidateAppAgeLimitUseCase.Companion.KEY_ANTI_FEATURES_NSFW @@ -621,21 +621,21 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog diff --git a/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt b/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt index 363198426..19c2df2db 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt @@ -34,8 +34,7 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.install.AppManagerWrapper import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.install.download.data.DownloadProgress @@ -148,18 +147,20 @@ class ApplicationViewModel @Inject constructor( updateAppContentRatingState(packageName, appData.first.contentRating) val status = appData.second + val hasTimedOut = appData.second == ResultStatus.TIMEOUT + val error = if (hasTimedOut) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } if (appData.second != ResultStatus.OK) { val exception = - if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) - GPlayException( - appData.second == ResultStatus.TIMEOUT, - status.message.ifBlank { "Data load error" } - ) - else CleanApkException( - appData.second == ResultStatus.TIMEOUT, - status.message.ifBlank { "Data load error" } - ) + if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) { + CustomException(error, status.message.ifBlank { "Data load error" }, type = CustomException.Type.GOOGLE_PLAY) + } else { + CustomException(error, status.message.ifBlank { "Data load error" }) + } exceptionsList.add(exception) exceptionsLiveData.postValue(exceptionsList) 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 ef7aa73a6..a3050985d 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 @@ -36,7 +36,7 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.ApplicationInstaller import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentApplicationListBinding import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.pkg.PwaManager @@ -270,21 +270,21 @@ class ApplicationListFragment : } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListViewModel.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListViewModel.kt index bf4272a17..dad65ee63 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListViewModel.kt @@ -28,8 +28,7 @@ import foundation.e.apps.data.enums.Source import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -112,16 +111,21 @@ class ApplicationListViewModel @Inject constructor( private fun getException( authData: AuthData, result: ResultSupreme, String>> - ) = if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) { - GPlayException( - result.isTimeout(), - result.message.ifBlank { "Data load error" } - ) - } else { - CleanApkException( - result.isTimeout(), - result.message.ifBlank { "Data load error" } - ) + ) : CustomException { + val error = if (result.isTimeout()) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + + if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) { + return CustomException(error, + result.message.ifBlank { "Data load error" }, type = CustomException.Type.GOOGLE_PLAY + ) + } else { + return CustomException(error, result.message.ifBlank { "Data load error" } + ) + } } private fun updateNextPageUrl(nextPageUrl: String?) { diff --git a/app/src/main/java/foundation/e/apps/ui/categories/AppsFragment.kt b/app/src/main/java/foundation/e/apps/ui/categories/AppsFragment.kt index fadb8dd12..5842321bb 100644 --- a/app/src/main/java/foundation/e/apps/ui/categories/AppsFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/categories/AppsFragment.kt @@ -28,7 +28,7 @@ import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.R import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentAppsBinding import foundation.e.apps.ui.MainActivityViewModel import foundation.e.apps.ui.categories.model.CategoriesRVAdapter @@ -80,21 +80,21 @@ class AppsFragment : TimeoutFragment(R.layout.fragment_apps) { } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog diff --git a/app/src/main/java/foundation/e/apps/ui/categories/CategoriesViewModel.kt b/app/src/main/java/foundation/e/apps/ui/categories/CategoriesViewModel.kt index 163562d95..228252f01 100644 --- a/app/src/main/java/foundation/e/apps/ui/categories/CategoriesViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/categories/CategoriesViewModel.kt @@ -27,8 +27,7 @@ import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Category import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -67,17 +66,15 @@ class CategoriesViewModel @Inject constructor( val status = categoriesData.second + val error = if (categoriesData.second == ResultStatus.TIMEOUT) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + if (status != ResultStatus.OK) { val exception = - if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) - GPlayException( - categoriesData.second == ResultStatus.TIMEOUT, - status.message.ifBlank { "Data load error" } - ) - else CleanApkException( - categoriesData.second == ResultStatus.TIMEOUT, - status.message.ifBlank { "Data load error" } - ) + CustomException(error, status.message.ifBlank { "Data load error" }) exceptionsList.add(exception) exceptionsLiveData.postValue(exceptionsList) diff --git a/app/src/main/java/foundation/e/apps/ui/categories/GamesFragment.kt b/app/src/main/java/foundation/e/apps/ui/categories/GamesFragment.kt index dbbf2ad7a..f245eec8c 100644 --- a/app/src/main/java/foundation/e/apps/ui/categories/GamesFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/categories/GamesFragment.kt @@ -28,7 +28,7 @@ import dagger.hilt.android.AndroidEntryPoint import foundation.e.apps.R import foundation.e.apps.data.application.utils.CategoryType import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentGamesBinding import foundation.e.apps.ui.MainActivityViewModel import foundation.e.apps.ui.categories.model.CategoriesRVAdapter @@ -80,21 +80,21 @@ class GamesFragment : TimeoutFragment(R.layout.fragment_games) { } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog 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 7c5e7c9fc..8ada3f9cb 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 @@ -33,8 +33,7 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.ApplicationInstaller import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayException -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentHomeBinding import foundation.e.apps.di.CommonUtilsModule.safeNavigate import foundation.e.apps.install.download.data.DownloadProgress @@ -145,24 +144,20 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder - ): AlertDialog.Builder? { + ): AlertDialog.Builder { return predefinedDialog.apply { - if (exception is GPlayException) { - setMessage(R.string.timeout_desc_gplay) - setNegativeButton(R.string.open_settings) { _, _ -> - openSettings() - } - } else { - setMessage(R.string.timeout_desc_cleanapk) + setMessage(R.string.timeout_desc_gplay) + setNegativeButton(R.string.open_settings) { _, _ -> + openSettings() } setCancelable(false) } } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog.apply { @@ -173,14 +168,12 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder - ): AlertDialog.Builder? { + ): AlertDialog.Builder { return predefinedDialog.apply { - if (exception is GPlayException) { - setNegativeButton(R.string.open_settings) { _, _ -> - openSettings() - } + setNegativeButton(R.string.open_settings) { _, _ -> + openSettings() } } } diff --git a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt index afd4f8cd2..74b43a226 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/HomeViewModel.kt @@ -28,8 +28,7 @@ import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.launch @@ -83,16 +82,13 @@ class HomeViewModel @Inject constructor( return@observe } - val exception = - if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) - GPlayException( - it.isTimeout(), - it.message.ifBlank { "Data load error" } - ) - else CleanApkException( - it.isTimeout(), - it.message.ifBlank { "Data load error" } - ) + val error = if (it.isTimeout()) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + + val exception = CustomException(error, it.message.ifBlank { "Data load error" }) exceptionsList.add(exception) exceptionsLiveData.postValue(exceptionsList) diff --git a/app/src/main/java/foundation/e/apps/ui/parentFragment/LoadingViewModel.kt b/app/src/main/java/foundation/e/apps/ui/parentFragment/LoadingViewModel.kt index a59e502ca..ac62485ac 100644 --- a/app/src/main/java/foundation/e/apps/ui/parentFragment/LoadingViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/parentFragment/LoadingViewModel.kt @@ -20,8 +20,7 @@ package foundation.e.apps.ui.parentFragment import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayValidationException -import foundation.e.apps.data.login.exceptions.UnknownSourceException +import foundation.e.apps.data.login.exceptions.CustomException abstract class LoadingViewModel : ViewModel() { @@ -29,8 +28,8 @@ abstract class LoadingViewModel : ViewModel() { private var autoRetried = false } - val exceptionsLiveData: MutableLiveData> = MutableLiveData() - val exceptionsList = ArrayList() + val exceptionsLiveData: MutableLiveData> = MutableLiveData() + val exceptionsList = ArrayList() /** * Call this method from ViewModel. @@ -53,11 +52,11 @@ abstract class LoadingViewModel : ViewModel() { val failedAuthList = authObjectList.filter { !it.result.isSuccess() } failedAuthList.forEach { - exceptionsList.add(it.result.exception ?: UnknownSourceException()) + exceptionsList.add(it.result.exception ?: CustomException()) } exceptionsList.find { - it is GPlayValidationException + it.type == CustomException.Type.GOOGLE_PLAY }?.run { if (!autoRetried && retryBlock(failedAuthList)) { autoRetried = true diff --git a/app/src/main/java/foundation/e/apps/ui/parentFragment/TimeoutFragment.kt b/app/src/main/java/foundation/e/apps/ui/parentFragment/TimeoutFragment.kt index 6d3d162b8..30e160d6e 100644 --- a/app/src/main/java/foundation/e/apps/ui/parentFragment/TimeoutFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/parentFragment/TimeoutFragment.kt @@ -35,11 +35,7 @@ import foundation.e.apps.data.enums.User import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.PlayStoreAuthenticator import foundation.e.apps.ui.LoginViewModel -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException -import foundation.e.apps.data.login.exceptions.GPlayLoginException -import foundation.e.apps.data.login.exceptions.GPlayValidationException -import foundation.e.apps.data.login.exceptions.UnknownSourceException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.DialogErrorLogBinding import foundation.e.apps.ui.MainActivityViewModel import timber.log.Timber @@ -138,7 +134,7 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * or null to not show anything. */ abstract fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder, ): AlertDialog.Builder? @@ -162,7 +158,7 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * or null to not show anything. */ abstract fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder, ): AlertDialog.Builder? @@ -181,7 +177,7 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * 6. Dialog is cancellable. */ abstract fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder, ): AlertDialog.Builder? @@ -248,7 +244,7 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * instance if it deems fit. Else it may return null, in which case no timeout dialog * is shown to the user. */ - fun showTimeout(exception: Exception) { + private fun showTimeout(exception: CustomException) { val dialogView = DialogErrorLogBinding.inflate(requireActivity().layoutInflater) dialogView.apply { moreInfo.setOnClickListener { @@ -296,7 +292,7 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * instance if it deems fit. Else it may return null, at which case no error dialog * is shown to the user. */ - fun showSignInError(exception: GPlayLoginException) { + fun showSignInError(exception: CustomException) { val dialogView = DialogErrorLogBinding.inflate(requireActivity().layoutInflater) dialogView.apply { @@ -329,9 +325,10 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { setPositiveButton(R.string.retry) { _, _ -> showLoadingUI() - when (exception) { - is GPlayValidationException -> clearAndRestartGPlayLogin() - else -> loginViewModel.startLoginFlow() + if (exception.networkCode == 401) { + clearAndRestartGPlayLogin() + } else { + loginViewModel.startLoginFlow() } } setNegativeButton(R.string.logout) { _, _ -> @@ -356,7 +353,7 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * instance if it deems fit. Else it may return null, at which case no error dialog * is shown to the user. */ - fun showDataLoadError(exception: Exception) { + fun showDataLoadError(exception: CustomException) { val dialogView = DialogErrorLogBinding.inflate(requireActivity().layoutInflater) dialogView.apply { moreInfo.setOnClickListener { @@ -400,42 +397,27 @@ abstract class TimeoutFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) { * Common code to handle exceptions / errors during data loading. * Can be overridden in child fragments. */ - open fun handleExceptionsCommon(exceptions: List) { - val cleanApkException = exceptions.find { it is CleanApkException }?.run { - this as CleanApkException - } - val gPlayException = exceptions.find { it is GPlayException }?.run { - this as GPlayException - } - val unknownSourceException = exceptions.find { it is UnknownSourceException } + open fun handleExceptionsCommon(exceptions: List) { - if (gPlayException?.message?.contains(STATUS_TOO_MANY_REQUESTS) == true) { - return - } + exceptions.forEach { + when { + it.type == CustomException.Type.GOOGLE_PLAY -> { + if (it.message?.contains(STATUS_TOO_MANY_REQUESTS) == true) { + return + } - /* - * Take caution altering the cases. - * Cases to be defined from most restrictive to least restrictive. - */ - when { - // Handle timeouts - cleanApkException?.isTimeout == true -> showTimeout(cleanApkException) - gPlayException?.isTimeout == true -> showTimeout(gPlayException) - - // Handle sign-in error - gPlayException is GPlayLoginException -> showSignInError(gPlayException) - - // Other errors - data loading error - gPlayException != null -> showDataLoadError(gPlayException) - cleanApkException != null -> showDataLoadError(cleanApkException) - - // Unknown exception - unknownSourceException != null -> { - showAndSetDialog( + if (it.error == CustomException.Error.AUTHENTICATION_ERROR) { + showSignInError(it) + } + } + + it.error == CustomException.Error.TIMEOUT_ERROR -> showTimeout(it) + + else -> showAndSetDialog( AlertDialog.Builder(requireActivity()) .setTitle(R.string.unknown_error) - .setPositiveButton(R.string.close, null) - ) + .setPositiveButton(R.string.close, null)) + } } } 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 c84b019d8..0ae80fa78 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 @@ -49,7 +49,7 @@ import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.enums.Status import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentSearchBinding import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.pkg.PwaManager @@ -344,21 +344,21 @@ class SearchFragment : } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt index 9d89d8f31..61eb29a7c 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt @@ -34,9 +34,7 @@ import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.exodus.repositories.IAppPrivacyInfoRepository import foundation.e.apps.data.exodus.repositories.PrivacyScoreRepository import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException -import foundation.e.apps.data.login.exceptions.UnknownSourceException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.di.CommonUtilsModule.LIST_OF_NULL import foundation.e.apps.ui.parentFragment.LoadingViewModel import kotlinx.coroutines.Dispatchers @@ -151,20 +149,16 @@ class SearchViewModel @Inject constructor( hasGPlayBeenFetched = false emitFilteredResults(searchResultSupreme) + if (!searchResultSupreme.isSuccess()) { - val exception = - if (authData != null) { - GPlayException( - searchResultSupreme.isTimeout(), - searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } - ) - } else { - CleanApkException( - searchResultSupreme.isTimeout(), - searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } - ) - } + val error = if (searchResultSupreme.isTimeout()) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + + val exception = CustomException(error, searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR }) handleException(exception) } @@ -196,7 +190,7 @@ class SearchViewModel @Inject constructor( val gplaySearchResult = applicationRepository.getGplaySearchResults(query, nextSubBundle) if (!gplaySearchResult.isSuccess()) { - handleException(gplaySearchResult.exception ?: UnknownSourceException()) + handleException(gplaySearchResult.exception ?: CustomException()) } nextSubBundle = gplaySearchResult.data?.second @@ -219,7 +213,7 @@ class SearchViewModel @Inject constructor( return currentAppList.distinctBy { it.package_name } } - private fun handleException(exception: Exception) { + private fun handleException(exception: CustomException) { exceptionsList.add(exception) exceptionsLiveData.postValue(exceptionsList) } 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 941ec2f11..f1629f5c8 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 @@ -42,8 +42,7 @@ import foundation.e.apps.data.application.ApplicationInstaller import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.GPlayException -import foundation.e.apps.data.login.exceptions.GPlayLoginException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.databinding.FragmentUpdatesBinding import foundation.e.apps.di.CommonUtilsModule.safeNavigate import foundation.e.apps.install.download.data.DownloadProgress @@ -153,7 +152,14 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI Timber.d("===>> observeupdate list called") if (resultStatus != ResultStatus.OK) { - val exception = GPlayException(resultStatus == ResultStatus.TIMEOUT) + val error = if (resultStatus == ResultStatus.TIMEOUT) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + + val exception = CustomException(error, "exception") + val alertDialogBuilder = AlertDialog.Builder(requireContext()) onTimeout(exception, alertDialogBuilder) } @@ -238,11 +244,11 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI } override fun onTimeout( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog.apply { - if (exception is GPlayException) { + if (exception.type == CustomException.Type.GOOGLE_PLAY) { setMessage(R.string.timeout_desc_gplay) setNegativeButton(R.string.open_settings) { _, _ -> openSettings() @@ -254,7 +260,7 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI } override fun onSignInError( - exception: GPlayLoginException, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog.apply { @@ -265,11 +271,11 @@ class UpdatesFragment : TimeoutFragment(R.layout.fragment_updates), ApplicationI } override fun onDataLoadError( - exception: Exception, + exception: CustomException, predefinedDialog: AlertDialog.Builder ): AlertDialog.Builder? { return predefinedDialog.apply { - if (exception is GPlayException) { + if (exception.type == CustomException.Type.GOOGLE_PLAY) { setNegativeButton(R.string.open_settings) { _, _ -> openSettings() } diff --git a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesViewModel.kt b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesViewModel.kt index 77214dc20..41f8d6871 100644 --- a/app/src/main/java/foundation/e/apps/ui/updates/UpdatesViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/updates/UpdatesViewModel.kt @@ -28,8 +28,7 @@ import foundation.e.apps.data.enums.Status import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.login.AuthObject -import foundation.e.apps.data.login.exceptions.CleanApkException -import foundation.e.apps.data.login.exceptions.GPlayException +import foundation.e.apps.data.login.exceptions.CustomException import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.data.updates.UpdatesManagerRepository import foundation.e.apps.ui.parentFragment.LoadingViewModel @@ -73,18 +72,14 @@ class UpdatesViewModel @Inject constructor( val status = updatesResult.second if (status != ResultStatus.OK) { - val exception = - if (authData != null && - (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) - ) { - GPlayException( - updatesResult.second == ResultStatus.TIMEOUT, - status.message.ifBlank { "Data load error" } - ) - } else CleanApkException( - updatesResult.second == ResultStatus.TIMEOUT, - status.message.ifBlank { "Data load error" } - ) + + val error = if (updatesResult.second == ResultStatus.TIMEOUT) { + CustomException.Error.TIMEOUT_ERROR + } else { + CustomException.Error.UNKNOWN_ERROR + } + + val exception = CustomException(error, status.message.ifBlank { "Data load error" }) exceptionsList.add(exception) exceptionsLiveData.postValue(exceptionsList) -- GitLab From 737eb1585a0a7f4d421c5a9570a9fa0b77271060 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 30 Oct 2024 15:28:00 +0100 Subject: [PATCH 19/19] Disable Rabbit review on draft --- .coderabbit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 992d2a105..34d8a2cc6 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -10,6 +10,6 @@ reviews: collapse_walkthrough: true auto_review: enabled: true - drafts: true + drafts: false chat: auto_reply: false -- GitLab