From ced100e07356e73a8d8415c8a967af154cd543d4 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 16 Oct 2024 14:39:26 +0200 Subject: [PATCH 01/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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