diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4b789577b3f30108069c8b05478e75a20382c512..a66085688848aa32773e28fb74c5f22757150533 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 f6735a11749f4014c82554c7e6d6d2d5995a6c12..c32a2fe17a5fb8a1388eaf63df0e5434b45a2924 100644 --- a/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt +++ b/app/src/main/java/foundation/e/apps/data/AppSourcesContainer.kt @@ -19,15 +19,15 @@ 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 import javax.inject.Singleton @Singleton class AppSourcesContainer @Inject constructor( - @Named("gplayRepository") val gplayRepo: PlayStoreRepository, - @Named("cleanApkAppsRepository") val cleanApkAppsRepo: CleanApkRepository, - @Named("cleanApkPWARepository") val cleanApkPWARepo: CleanApkRepository + val gplayRepo: PlayStoreRepository, + val cleanApkAppsRepo: CleanApkAppsRepository, + 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 7fafbccd5f5edfb25a7e02bca9df5654a97f8805..8885da06f438d18de161e02479927c04e6e09576 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( - @Named("gplayRepository") 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/CleanApkAppDetailsRetrofit.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkAppDetailsRetrofit.kt deleted file mode 100644 index 69574481db52aeda77f3c62983461a499f8a35f8..0000000000000000000000000000000000000000 --- 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/CleanApkAppsRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt similarity index 90% 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 e51a82823645d903fa0a85179db5745242cd9e48..8a5c09372f910939b95871f2dcf7cb156c8e75d9 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 @@ -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 @@ -27,10 +26,10 @@ 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 CleanApkAppsRepositoryImpl( - private val cleanApkRetrofit: CleanApkRetrofit, - private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit +class CleanApkAppsRepository @Inject constructor( + private val cleanApkRetrofit: CleanApkRetrofit ) : CleanApkRepository, CleanApkDownloadInfoFetcher { override suspend fun getHomeScreenData(): Response { @@ -76,7 +75,7 @@ class CleanApkAppsRepositoryImpl( } 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 similarity index 88% 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 8e8f84f6aac496bda4c4d5cfe5dc5f4588ee35d9..2f1f00dd2bc2eea51fb033b001b11c78497f2913 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,16 +18,15 @@ 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 import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response +import javax.inject.Inject -class CleanApkPWARepository( - private val cleanAPKRetrofit: CleanApkRetrofit, - private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit +class CleanApkPwaRepository @Inject constructor( + private val cleanAPKRetrofit: CleanApkRetrofit ) : CleanApkRepository { override suspend fun getHomeScreenData(): Any { @@ -70,6 +69,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/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 978b36e0543f1173c0099de96499ee6bfd75fdc2..34fd7c4dd4a821015482a4f7c1a1bee71d472e1c 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 51bdaefabdfd3a7655c92ead9d22014b9b9492de..84f411e4477296da22c3a4595ab7af893b48d078 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 27670c9be4774728eab4e0f43340ab3f47e0f229..4f36c82d4eef886efc3c9bb971b2749e8f17ba1d 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 83cc3f3f9c3c4e36f4180eb5809e87ecf03a7c29..a333ca5c872d68c9cb001202a14c305748ef9406 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/login/AuthenticatorRepository.kt b/app/src/main/java/foundation/e/apps/data/login/AuthenticatorRepository.kt index 2e4bc761d4b32ade786abb2498b934fb02cedcd4..fccc0b15aec13f192dbe1d174224294152080b07 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 03733b0d271499e289a93363e50c4ed76a31a9ae..3065874e2ab39b15c2492d9d1cd4ad69f9461f80 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,227 @@ 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.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) + 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), + ) + + fun getSearchResult( + query: String, + subBundle: MutableSet? + ): Pair, MutableSet> { + val authData = authenticatorRepository.getGPlayAuthOrThrow() + val searchHelper = SearchHelper(authData).using(gPlayHttpClient) + + Timber.d("Fetching search result for $query, subBundle: $subBundle") + + val searchResult = if (subBundle != null) { + Timber.d("fetching next page search data...") + searchHelper.next(subBundle) + } else { + 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.getGPlayAuthOrThrow() + + val searchData = mutableListOf() + withContext(Dispatchers.IO) { + val searchHelper = SearchHelper(authData).using(gPlayHttpClient) + searchData.addAll(searchHelper.searchSuggestions(query)) + } + return searchData.filter { it.suggestedQuery.isNotBlank() } + } + + fun getAppsByCategory(category: String, pageUrl: String?): StreamCluster { + val authData = authenticatorRepository.getGPlayAuthOrThrow() + + 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.getGPlayAuthOrThrow() + + 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.getGPlayAuthOrThrow() + + 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.getGPlayAuthOrThrow() + + 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.getGPlayAuthOrThrow() + + 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.getGPlayAuthOrThrow() + + 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.getGPlayAuthOrThrow() + val contentRatingHelper = ContentRatingHelper(authData) + + return withContext(Dispatchers.IO) { + contentRatingHelper.updateContentRatingWithId( + appPackage, + contentRating + ) + } + } + + suspend fun getEnglishContentRating(packageName: String): ContentRating { + val authData = authenticatorRepository.getGPlayAuthOrThrow() + 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 9ea9db7b9a003e58e63ced57f42345d2b4532e54..0000000000000000000000000000000000000000 --- 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 4cf3cd31a098106fdce6cdc2c220b644c96e0f47..89628886b514083d3ab2b3b4cd1b1c8c26f3c1a0 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,8 +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.playstore.PlayStoreRepositoryImpl +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 @@ -52,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, ) { @@ -417,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/NamedRepositoryModule.kt b/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt deleted file mode 100644 index e3d60030b145639369d39f8b2aa1c21a594a61ea..0000000000000000000000000000000000000000 --- a/app/src/main/java/foundation/e/apps/di/NamedRepositoryModule.kt +++ /dev/null @@ -1,72 +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 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.CleanApkAppDetailsRetrofit -import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.repositories.CleanApkAppsRepositoryImpl -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 - @Named("cleanApkAppsRepository") - fun getCleanApkAppsRepository( - cleanAPKRetrofit: CleanApkRetrofit, - cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit - ): CleanApkRepository { - return CleanApkAppsRepositoryImpl(cleanAPKRetrofit, cleanApkAppDetailsRetrofit) - } - - @Singleton - @Provides - @Named("cleanApkPWARepository") - fun getCleanApkPWARepository( - cleanAPKRetrofit: CleanApkRetrofit, - cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit - ): CleanApkRepository { - return CleanApkPWARepository(cleanAPKRetrofit, cleanApkAppDetailsRetrofit) - } -} 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 7d548e66a0032888edcb20b4b8680e276bc30946..0eb1d9a690712169f524965c798cd24615c64235 100644 --- a/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt +++ b/app/src/main/java/foundation/e/apps/di/RepositoryModule.kt @@ -26,10 +26,8 @@ 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.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 @@ -47,13 +45,9 @@ interface RepositoryModule { @Singleton @Binds - fun getFdroidRepository(fusedManagerImpl: FdroidRepository): IFdroidRepository + fun getFdroidRepository(fusedManagerImpl: FDroidRepository): IFdroidRepository @Singleton @Binds fun getPrivacyScoreRepository(privacyScoreRepositoryImpl: PrivacyScoreRepositoryImpl): PrivacyScoreRepository - - @Singleton - @Binds - fun getPlayStoreRepository(playStoreRepository: PlayStoreRepositoryImpl): PlayStoreRepository } 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 56914f6165379009bf6340177fd04025904b5d25..267ec7e60ca1045d7e10e99933e8df0905af3382 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 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 2a8a45056e737e0cf3bfb0b2dbc91634a4308ec4..689f70343f4e535527464c51090b1e34d94fcaef 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 ccb37248b2107783c78545b7dbb6866d8be0a8d3..b1ea00b57efa1d0e304d4eb5db118b0dad21ad95 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 9b3ed026761cde7a3e3bdcc20145ae6c2223b466..1339877cec6a6db214ff74ce468a39380ffcca38 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/install/splitinstall/SplitInstallBinder.kt b/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt index 0e303bf4a1543b1b497615195927521154377246..a2efbdf6933731f27e0472d5697bc2d8aa610d59 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 c82240b4047150b1629bb43c0c41418ee08d4eee..b909f2173752b246a609067f88dd1ebff8da99e1 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,10 +197,10 @@ 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.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 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 a4fd28790c90d004f8c660029710e99ce9b3c37a..1630c4d679da19165c79a2ff265debfe82aad9e1 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, - @Named("gplayRepository") 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 030755e7d6865ef6205dc53cda537fda47ec0a31..ceac9a937f112cda0fb9237db37a5ad2e8060ccf 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 3d25bf9ee91dd92be7dc14f8dd85827640bf94ae..7b0c1555fffc450b1e77566b017296c9e1c7fc78 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 909c6a89665ffd47323d059e665c4b13dc68e708..ef7aa73a697017cbc49b84990e62dbb39f3277f1 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 91ac8ad0ecbb3e775c0119ee75f75c6b2baf2423..7c5e7c9fc4cb233c1b841545508dfc4c6375c3f3 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 f813834094475c954945873169f8a15c5cf000af..c84b019d8050b474cba08c1ca4e836a7ecdca9ce 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 9ba5a6fee90445908456bbaa051122858cbb0e5d..941ec2f11fc29976b39037ddbb4776ff03225040 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 d483c05c5fb2a699a4edc3b7399e0891fa7a8ca4..eb5c7090f75e990c4e81b66afd6ae49a76037d6a 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 861cacf8e20b41e1ef452be57dc613013ad24aad..1dc1ce734813fa78f25a9775186b49a4d20b7b8e 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,8 +33,10 @@ 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.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -67,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 @@ -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 e6a96d7e2257c0e059a69b4d70b40ab335376c3b..ddf7a556a94b044727107c361de55c8b308179bc 100644 --- a/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt +++ b/app/src/test/java/foundation/e/apps/category/CategoryApiTest.kt @@ -29,10 +29,11 @@ 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 +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -64,16 +65,16 @@ class CategoryApiTest { private lateinit var context: Context @Mock - private lateinit var pwaManager: PWAManager + private lateinit var pwaManager: PwaManager @Mock 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 117b5cc9fd7c071bb26aa42c9d9170805cb081c6..3337aea51549988eb66ec6f5c348bcdee7765129 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,8 +33,10 @@ 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.PwaManager import foundation.e.apps.install.pkg.AppLoungePackageManager import foundation.e.apps.util.MainCoroutineRule import foundation.e.apps.utils.eventBus.EventBus @@ -43,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 @@ -76,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 @@ -85,10 +85,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 +231,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/fusedManager/AppManagerWrapperTest.kt b/app/src/test/java/foundation/e/apps/fusedManager/AppManagerWrapperTest.kt index 4fe3108f597214c3fd28921759c85640accd611e..fb77fcfce4cb48c54d54cfb54f06ae560566b8e8 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 34ad19888888cc14d79647d680cb97885a38588e..19642007134249d0916386548d7c784e4ccdf8c3 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -28,10 +28,11 @@ 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 +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 @@ -67,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 @@ -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 +} 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 5d893eb60d086c3632f67da56f35607f86cb6992..28d386f684653e3a890eca986011359a7e28515d 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 eb026c5bac6f4d212f7119367ee84c543b075a42..3099e0914e817b807aa5cabda6fe894dbba3bbd6 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