diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4b789577b3f30108069c8b05478e75a20382c512..fe79aa0933f8fd69ee2db6a916b70b323660e5a6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ xmlns:tools="http://schemas.android.com/tools"> @@ -124,7 +124,7 @@ - @@ -175,8 +175,8 @@ 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/StoreRepository.kt b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt index 0f8e1e426c64c77e188da2034144dd184235a017..e1c04d98e371777d4f7278de0318ca78535a6841 100644 --- a/app/src/main/java/foundation/e/apps/data/StoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/StoreRepository.kt @@ -18,7 +18,9 @@ package foundation.e.apps.data +import foundation.e.apps.data.application.data.Application + interface StoreRepository { - suspend fun getHomeScreenData(): Any - suspend fun getAppDetails(packageNameOrId: String): Any? + suspend fun getHomeScreenData(): Map> + suspend fun getAppDetails(packageNameOrId: String): Application } diff --git a/app/src/main/java/foundation/e/apps/data/application/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/application/apps/AppsApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt index e4847beced933d98557325c576edf5aea4a854e1..beb4238d951e857f4963b51334a6afbc2441bdc0 100644 --- a/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/apps/AppsApiImpl.kt @@ -21,7 +21,6 @@ package foundation.e.apps.data.application.apps import android.content.Context import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData -import com.aurora.gplayapi.data.models.ContentRating import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.application.ApplicationDataManager @@ -38,7 +37,7 @@ import foundation.e.apps.data.preference.AppLoungePreference import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil import retrofit2.Response import javax.inject.Inject -import foundation.e.apps.data.cleanapk.data.app.Application as CleanApkApplication +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication class AppsApiImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -61,8 +60,7 @@ class AppsApiImpl @Inject constructor( if (result?.hasSingleResult() == true) { application = - (appSources.cleanApkAppsRepo.getAppDetails(result.apps[0]._id) - as Response).body()?.app ?: Application() + appSources.cleanApkAppsRepo.getAppDetails(result.apps[0]._id) } application.updateFilterLevel(null) @@ -190,18 +188,16 @@ class AppsApiImpl @Inject constructor( authData: AuthData, origin: Origin ): Pair { - var application: Application? + var application: Application val result = handleNetworkResult { application = if (origin == Origin.CLEANAPK) { - (appSources.cleanApkAppsRepo.getAppDetails(id) - as Response).body()?.app + appSources.cleanApkAppsRepo.getAppDetails(id) } else { - val app = appSources.gplayRepo.getAppDetails(packageName) as App? - app?.toApplication(context) + appSources.gplayRepo.getAppDetails(packageName) } - application?.let { + application.let { applicationDataManager.updateStatus(it) it.updateType() it.updateSource(context) diff --git a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt index 53a4024276f1a9cd564337967f7d6f1fecffd79b..6ed63a29c8319ef3ef640269c5cec955f80bead3 100644 --- a/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/application/home/HomeApiImpl.kt @@ -21,18 +21,14 @@ package foundation.e.apps.data.application.home import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.liveData -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import dagger.hilt.android.qualifiers.ApplicationContext -import foundation.e.apps.R import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.application.ApplicationDataManager import foundation.e.apps.data.application.data.Home import foundation.e.apps.data.application.search.FusedHomeDeferred import foundation.e.apps.data.application.search.SearchApi -import foundation.e.apps.data.application.utils.toApplication -import foundation.e.apps.data.cleanapk.data.home.HomeScreen import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Source import foundation.e.apps.data.handleNetworkResult @@ -44,10 +40,8 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch -import retrofit2.Response import timber.log.Timber import javax.inject.Inject -import foundation.e.apps.data.cleanapk.data.home.Home as CleanApkHome class HomeApiImpl @Inject constructor( @ApplicationContext private val context: Context, @@ -142,87 +136,19 @@ class HomeApiImpl @Inject constructor( priorList: MutableList, appType: String ): MutableList { - val response = if (appType == SearchApi.APP_TYPE_OPEN) { - (appSources.cleanApkAppsRepo.getHomeScreenData() as Response).body() + val homes = if (appType == SearchApi.APP_TYPE_OPEN) { + appSources.cleanApkAppsRepo.getHomeScreenData() } else { - (appSources.cleanApkPWARepo.getHomeScreenData() as Response).body() + appSources.cleanApkPWARepo.getHomeScreenData() } - response?.home?.let { - priorList.addAll(generateCleanAPKHome(it, appType)) + homes.forEach { (title, list) -> + priorList.add(Home(title, list, appType)) } return priorList } - private suspend fun generateCleanAPKHome(home: CleanApkHome, appType: String): List { - val list = mutableListOf() - val headings = if (appType == SearchApi.APP_TYPE_OPEN) { - getOpenSourceHomeCategories() - } else { - getPWAHomeCategories() - } - - headings.forEach { (key, value) -> - when (key) { - "top_updated_apps" -> { - applicationDataManager.prepareApps(home.top_updated_apps, list, value) - } - - "top_updated_games" -> { - applicationDataManager.prepareApps(home.top_updated_games, list, value) - } - - "popular_apps" -> { - applicationDataManager.prepareApps(home.popular_apps, list, value) - } - - "popular_games" -> { - applicationDataManager.prepareApps(home.popular_games, list, value) - } - - "popular_apps_in_last_24_hours" -> { - applicationDataManager.prepareApps( - home.popular_apps_in_last_24_hours, - list, - value - ) - } - - "popular_games_in_last_24_hours" -> { - applicationDataManager.prepareApps( - home.popular_games_in_last_24_hours, - list, - value - ) - } - - "discover" -> { - applicationDataManager.prepareApps(home.discover, list, value) - } - } - } - - return list.map { - it.source = appType - it - } - } - - private fun getPWAHomeCategories() = mapOf( - "popular_apps" to context.getString(R.string.popular_apps), - "popular_games" to context.getString(R.string.popular_games), - "discover" to context.getString(R.string.discover_pwa) - ) - - private fun getOpenSourceHomeCategories() = mapOf( - "top_updated_apps" to context.getString(R.string.top_updated_apps), - "top_updated_games" to context.getString(R.string.top_updated_games), - "popular_apps_in_last_24_hours" to context.getString(R.string.popular_apps_in_last_24_hours), - "popular_games_in_last_24_hours" to context.getString(R.string.popular_games_in_last_24_hours), - "discover" to context.getString(R.string.discover) - ) - private fun setHomeErrorMessage(apiStatus: ResultStatus, source: Source) { if (apiStatus != ResultStatus.OK) { apiStatus.message = when (source) { @@ -239,11 +165,11 @@ class HomeApiImpl @Inject constructor( priorList: MutableList ): List { val list = mutableListOf() - val gplayHomeData = - appSources.gplayRepo.getHomeScreenData() as Map> + val gplayHomeData = appSources.gplayRepo.getHomeScreenData() + gplayHomeData.map { val fusedApps = it.value.map { app -> - app.toApplication(context).apply { + app.apply { applicationDataManager.updateStatus(this) applicationDataManager.updateFilterLevel(authData, this) } @@ -277,5 +203,4 @@ class HomeApiImpl @Inject constructor( ) } } - } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt index 5d9b3910bef7caa82031b8ba1bead5754d493cb9..b5c69ee734d5f01da702f5ddda33e2d0ec0089ce 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/ApplicationDeserializer.kt @@ -22,22 +22,22 @@ import com.google.gson.Gson import com.google.gson.JsonDeserializationContext import com.google.gson.JsonDeserializer import com.google.gson.JsonElement -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication -class ApplicationDeserializer : JsonDeserializer { +class ApplicationDeserializer : JsonDeserializer { override fun deserialize( json: JsonElement?, typeOfT: java.lang.reflect.Type?, context: JsonDeserializationContext? - ): Application { + ): CleanApkApplication { val gson = Gson() - val application = gson.fromJson(json?.asJsonObject?.toString(), Application::class.java) - val lastUpdate = application.app.latest_downloaded_version + val cleanApkApplication = gson.fromJson(json?.asJsonObject?.toString(), CleanApkApplication::class.java) + val lastUpdate = cleanApkApplication.app.latest_downloaded_version val lastUpdateJson = json?.asJsonObject?.get("app")?.asJsonObject?.get(lastUpdate)?.asJsonObject val lastUpdatedOn = lastUpdateJson ?.asJsonObject?.get("update_on")?.asString ?: "" - application.app.updatedOn = lastUpdatedOn - application.app.latest_version_code = lastUpdateJson?.get("version_code")?.asInt ?: -1 - return application + cleanApkApplication.app.updatedOn = lastUpdatedOn + cleanApkApplication.app.latest_version_code = lastUpdateJson?.get("version_code")?.asInt ?: -1 + return cleanApkApplication } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/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/CleanApkRetrofit.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt index 3da3d4014c5d119b0b23b1d3bfb72832fe78f6e8..1e88833987942f8df0af439aecdabfd83bab0400 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/CleanApkRetrofit.kt @@ -18,10 +18,10 @@ package foundation.e.apps.data.cleanapk -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.download.Download -import foundation.e.apps.data.cleanapk.data.home.HomeScreen +import foundation.e.apps.data.cleanapk.data.home.HomeScreenResponse import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response import retrofit2.http.GET @@ -48,7 +48,7 @@ interface CleanApkRetrofit { suspend fun getHomeScreenData( @Query("type") type: String = APP_TYPE_ANY, @Query("source") source: String = APP_SOURCE_ANY, - ): Response + ): Response // TODO: Reminder that this function is for search App and PWA both @GET("apps?action=app_detail") @@ -56,7 +56,7 @@ interface CleanApkRetrofit { @Query("id") id: String, @Query("architectures") architectures: List? = null, @Query("type") type: String? = null - ): Response + ): Response @GET("apps?action=search") suspend fun searchApps( diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/Application.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/CleanApkApplication.kt similarity index 81% rename from app/src/main/java/foundation/e/apps/data/cleanapk/data/app/Application.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/data/app/CleanApkApplication.kt index 906d9b2d0a17384ff555de8830d6f01756472513..4ba0b0c7b5a79ad3296059d33a9b835bd1b2754e 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/app/CleanApkApplication.kt @@ -18,9 +18,9 @@ package foundation.e.apps.data.cleanapk.data.app -import foundation.e.apps.data.application.data.Application as AppLoungeApplication +import foundation.e.apps.data.application.data.Application -data class Application( - val app: AppLoungeApplication = AppLoungeApplication(), +data class CleanApkApplication( + val app: Application = Application(), val success: Boolean = false ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/Home.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt similarity index 86% rename from app/src/main/java/foundation/e/apps/data/cleanapk/data/home/Home.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt index 8e50e09c383b1ab92f15c25c3b7650a06a4e44dc..7118307bed1fb092e5a35f0e7c272d0949e5cd88 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/Home.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/CleanApkHome.kt @@ -21,13 +21,11 @@ package foundation.e.apps.data.cleanapk.data.home import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.application.data.Application -data class Home( +data class CleanApkHome( val top_updated_apps: List = emptyList(), val top_updated_games: List = emptyList(), val popular_apps: List = emptyList(), val popular_games: List = emptyList(), - val popular_apps_in_last_24_hours: List = emptyList(), - val popular_games_in_last_24_hours: List = emptyList(), val discover: List = emptyList(), var origin: Origin = Origin.CLEANAPK // Origin ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreen.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreenResponse.kt similarity index 89% rename from app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreen.kt rename to app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreenResponse.kt index 27d0f7db4f115c2b493d5596a812f9c526054f4e..9c64a8a752248048f4340bdc6d7405f314facaea 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreen.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/data/home/HomeScreenResponse.kt @@ -18,7 +18,7 @@ package foundation.e.apps.data.cleanapk.data.home -data class HomeScreen( - val home: Home = Home(), +data class HomeScreenResponse( + val home: CleanApkHome = CleanApkHome(), val success: Boolean = false ) diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkAppsRepository.kt similarity index 73% 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..b97b3ce301573483c072b9021990feda76ab1cdd 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,26 +18,38 @@ package foundation.e.apps.data.cleanapk.repositories -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.cleanapk.CleanApkDownloadInfoFetcher import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.download.Download -import foundation.e.apps.data.cleanapk.data.home.HomeScreen import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response +import javax.inject.Inject -class CleanApkAppsRepositoryImpl( +class CleanApkAppsRepository @Inject constructor( private val cleanApkRetrofit: CleanApkRetrofit, - private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit + private val homeConverter: HomeConverter ) : CleanApkRepository, CleanApkDownloadInfoFetcher { - override suspend fun getHomeScreenData(): Response { - return cleanApkRetrofit.getHomeScreenData( + override suspend fun getHomeScreenData(): Map> { + + val response = cleanApkRetrofit.getHomeScreenData( CleanApkRetrofit.APP_TYPE_ANY, CleanApkRetrofit.APP_SOURCE_FOSS ) + + val home = response.body()?.home ?: throw IllegalStateException("No home data found") + val listHome = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_ANY) + val map = mutableMapOf>() + listHome.forEach { + map[it.title] = it.list + } + + return map } override suspend fun getSearchResult(query: String, searchBy: String?): Response { @@ -75,8 +87,9 @@ class CleanApkAppsRepositoryImpl( return cleanApkRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + override suspend fun getAppDetails(packageNameOrId: String): Application { + val response = cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return response.body()?.app ?: throw IllegalStateException("No app data found") } override suspend fun getDownloadInfo(idOrPackageName: String, versionCode: Any?): Response { diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPWARepository.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt similarity index 62% 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..edf52f91e318cf10b35949471dc3d199e1600ec5 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPWARepository.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/CleanApkPwaRepository.kt @@ -18,27 +18,40 @@ package foundation.e.apps.data.cleanapk.repositories -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.cleanapk.CleanApkRetrofit -import foundation.e.apps.data.cleanapk.data.app.Application import foundation.e.apps.data.cleanapk.data.categories.Categories import foundation.e.apps.data.cleanapk.data.search.Search import retrofit2.Response +import javax.inject.Inject -class CleanApkPWARepository( - private val cleanAPKRetrofit: CleanApkRetrofit, - private val cleanApkAppDetailsRetrofit: CleanApkAppDetailsRetrofit +class CleanApkPwaRepository @Inject constructor( + private val cleanApkRetrofit: CleanApkRetrofit, + private val homeConverter: HomeConverter, + @ApplicationContext val context: Context ) : CleanApkRepository { - override suspend fun getHomeScreenData(): Any { - return cleanAPKRetrofit.getHomeScreenData( + override suspend fun getHomeScreenData(): Map> { + val response = cleanApkRetrofit.getHomeScreenData( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) + + val home = response.body()?.home ?: throw IllegalStateException("No home data found") + + val listHome = homeConverter.toGenericHome(home, CleanApkRetrofit.APP_TYPE_PWA) + val map = mutableMapOf>() + listHome.forEach { + map[it.title] = it.list + } + + return map } override suspend fun getSearchResult(query: String, searchBy: String?): Response { - return cleanAPKRetrofit.searchApps( + return cleanApkRetrofit.searchApps( query, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -49,7 +62,7 @@ class CleanApkPWARepository( } override suspend fun getAppsByCategory(category: String, paginationParameter: Any?): Response { - return cleanAPKRetrofit.listApps( + return cleanApkRetrofit.listApps( category, CleanApkRetrofit.APP_SOURCE_ANY, CleanApkRetrofit.APP_TYPE_PWA, @@ -59,17 +72,18 @@ class CleanApkPWARepository( } override suspend fun getCategories(): Response { - return cleanAPKRetrofit.getCategoriesList( + return cleanApkRetrofit.getCategoriesList( CleanApkRetrofit.APP_TYPE_PWA, CleanApkRetrofit.APP_SOURCE_ANY ) } override suspend fun checkAvailablePackages(packageNames: List): Response { - return cleanAPKRetrofit.checkAvailablePackages(packageNames) + return cleanApkRetrofit.checkAvailablePackages(packageNames) } - override suspend fun getAppDetails(packageNameOrId: String): Response { - return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + override suspend fun getAppDetails(packageNameOrId: String): Application { + val response = cleanApkRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null) + return response.body()?.app ?: throw IllegalStateException("No app data found") } } diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt new file mode 100644 index 0000000000000000000000000000000000000000..a5ecafbfcbb06d7218a633e577c48883202406e2 --- /dev/null +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/repositories/HomeConverter.kt @@ -0,0 +1,58 @@ +package foundation.e.apps.data.cleanapk.repositories + +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import foundation.e.apps.R +import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Home +import foundation.e.apps.data.cleanapk.data.home.CleanApkHome +import javax.inject.Inject + +class HomeConverter @Inject constructor( + @ApplicationContext val context: Context, + private val applicationDataManager: ApplicationDataManager +) { + + suspend fun toGenericHome(cleanApkHome: CleanApkHome, appType: String): List { + val list = mutableListOf() + + openSourceCategories.forEach { (key, value) -> + when (key) { + "top_updated_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_apps, list, value) + } + + "top_updated_games" -> { + applicationDataManager.prepareApps(cleanApkHome.top_updated_games, list, value) + } + + "popular_apps" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_apps, list, value) + } + + "popular_games" -> { + applicationDataManager.prepareApps(cleanApkHome.popular_games, list, value) + } + + "discover" -> { + applicationDataManager.prepareApps(cleanApkHome.discover, list, value) + } + } + } + + return list.map { + it.source = appType + it + } + } + + private val openSourceCategories: Map by lazy { + mapOf( + "top_updated_apps" to context.getString(R.string.top_updated_apps), + "top_updated_games" to context.getString(R.string.top_updated_games), + "popular_apps" to context.getString(R.string.popular_apps), + "popular_games" to context.getString(R.string.popular_games), + "discover" to context.getString(R.string.discover) + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/foundation/e/apps/data/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 94f2b2f6126893719b3aa9be968c51aeeb4a077c..183a65d08c344cc32f8f3c35d95b40782ec2ca3b 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 359681c6c01133a6f7a472b0f176759395e2e712..119b5653a84f76adbce3e4232f5f7ec2ffd5dc68 100644 --- a/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt +++ b/app/src/main/java/foundation/e/apps/data/install/AppManagerWrapper.kt @@ -6,7 +6,7 @@ import androidx.annotation.RequiresApi import androidx.lifecycle.LiveData import foundation.e.apps.OpenForTesting import foundation.e.apps.data.enums.Status -import foundation.e.apps.data.fdroid.FdroidRepository +import foundation.e.apps.data.fdroid.FDroidRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.install.download.data.DownloadProgress @@ -18,7 +18,7 @@ import javax.inject.Singleton @OpenForTesting class AppManagerWrapper @Inject constructor( private val appManager: AppManager, - private val fdroidRepository: FdroidRepository + private val fDroidRepository: FDroidRepository ) { fun createNotificationChannels() { @@ -182,9 +182,9 @@ class AppManagerWrapper @Inject constructor( return null } - suspend fun isFdroidApplicationSigned(context: Context, appInstall: AppInstall): Boolean { + suspend fun isFDroidApplicationSigned(context: Context, appInstall: AppInstall): Boolean { val apkFilePath = appManager.getBaseApkPath(appInstall) - return fdroidRepository.isFdroidApplicationSigned(context, appInstall.packageName, apkFilePath, appInstall.signature) + return fDroidRepository.isFDroidApplicationSigned(context, appInstall.packageName, apkFilePath, appInstall.signature) } fun isFusedDownloadInstalled(appInstall: AppInstall): Boolean { diff --git a/app/src/main/java/foundation/e/apps/data/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..22e0d88b7d49db73fbd94e3e992eb6db0b5c8b5e 100644 --- a/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/playstore/PlayStoreRepository.kt @@ -18,36 +18,233 @@ package foundation.e.apps.data.playstore +import android.content.Context import com.aurora.gplayapi.SearchSuggestEntry -import com.aurora.gplayapi.data.models.App +import com.aurora.gplayapi.data.models.App as GplayApp +import com.aurora.gplayapi.data.models.AuthData import com.aurora.gplayapi.data.models.Category import com.aurora.gplayapi.data.models.ContentRating 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.data.Application import foundation.e.apps.data.application.utils.CategoryType +import foundation.e.apps.data.application.utils.toApplication +import foundation.e.apps.data.login.AuthenticatorRepository +import foundation.e.apps.data.playstore.utils.GPlayHttpClient +import kotlinx.coroutines.Dispatchers +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(): Map> { + 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): Application { + var appDetails: GplayApp? + val authData = authenticatorRepository.getGPlayAuthOrThrow() + + withContext(Dispatchers.IO) { + val appDetailsHelper = AppDetailsHelper(authData).using(gPlayHttpClient) + appDetails = appDetailsHelper.getAppByPackageName(packageNameOrId) + } + + return appDetails?.toApplication(context) ?: Application() + } + + 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.map { + it.toApplication(context) + } + } -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/NetworkModule.kt b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt index 6fbf75e992aecfa62bbfd5070412e21312e9db57..cdeb0e363459775920d9e9ad6dffd030804356fc 100644 --- a/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/NetworkModule.kt @@ -29,7 +29,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import foundation.e.apps.data.cleanapk.ApplicationDeserializer -import foundation.e.apps.data.cleanapk.data.app.Application +import foundation.e.apps.data.cleanapk.data.app.CleanApkApplication import okhttp3.Cache import okhttp3.Interceptor import okhttp3.OkHttpClient @@ -58,7 +58,7 @@ object NetworkModule { @Named("gsonCustomAdapter") fun getGson(): Gson { return GsonBuilder() - .registerTypeAdapter(Application::class.java, ApplicationDeserializer()) + .registerTypeAdapter(CleanApkApplication::class.java, ApplicationDeserializer()) .enableComplexMapKeySerialization() .create() } diff --git a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt index 136add81108330203abad2575d74ecde0c3e9e46..2d6adc3e87631e63db6731cd0999c875d5b38471 100644 --- a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt @@ -24,7 +24,6 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import foundation.e.apps.data.cleanapk.CleanApkAppDetailsRetrofit import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.ecloud.EcloudApiInterface import foundation.e.apps.data.exodus.ExodusTrackerApi @@ -48,27 +47,17 @@ import javax.inject.Singleton class RetrofitApiModule { @Singleton @Provides - fun provideCleanApkApi(okHttpClient: OkHttpClient, moshi: Moshi): CleanApkRetrofit { - return Retrofit.Builder() - .baseUrl(CleanApkRetrofit.BASE_URL) - .client(okHttpClient) - .addConverterFactory(MoshiConverterFactory.create(moshi)) - .build() - .create(CleanApkRetrofit::class.java) - } - - @Singleton - @Provides - fun provideCleanApkAppDetailsApi( + fun provideCleanApkApi( okHttpClient: OkHttpClient, @Named("gsonCustomAdapter") gson: Gson - ): CleanApkAppDetailsRetrofit { + ): CleanApkRetrofit + { return Retrofit.Builder() .baseUrl(CleanApkRetrofit.BASE_URL) .client(okHttpClient) .addConverterFactory(GsonConverterFactory.create(gson)) .build() - .create(CleanApkAppDetailsRetrofit::class.java) + .create(CleanApkRetrofit::class.java) } @Singleton 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 8e5e5da16476f348421418b9f9ead522d1dfc6a2..a3e0c76842ee4749e548469b7bf66982cdb582b2 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 f3bf8552e22143907dc46b24c09c7a843879346c..0ed06df83d601b6acf738b76bc78e2b020aa88d8 100644 --- a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt +++ b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt @@ -138,7 +138,7 @@ class AgeRatingProvider : ContentProvider() { withContext(IO) { try { if (packageNames.isEmpty()) return@withContext cursor - canSetupAuthData() + initAuthData() ensureAgeGroupDataExists() compileAppBlockList(cursor, packageNames) @@ -198,10 +198,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) } } @@ -286,7 +286,8 @@ class AgeRatingProvider : ContentProvider() { private fun hasAuthData(): Boolean { return try { - authenticatorRepository.gplayAuth != null + authenticatorRepository.getGPlayAuthOrThrow() + true } catch (e: GPlayLoginException) { Timber.e("No AuthData to check content rating") false 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 e1b754c20f4591913f8d85151cdcd3f527898433..b06e667e25fefd2f66556c7582c3b0a238e2efaa 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 126bc7d0ee73d6daf03945d7f27e710ee3375f8c..c4bde026cb236c9f42b91deebeee464b6dffdb49 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt @@ -67,7 +67,7 @@ import foundation.e.apps.di.CommonUtilsModule.LIST_OF_NULL import foundation.e.apps.domain.ValidateAppAgeLimitUseCase.Companion.KEY_ANTI_FEATURES_NSFW import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.pkg.AppLoungePackageManager -import foundation.e.apps.install.pkg.PWAManager +import foundation.e.apps.install.pkg.PwaManager import foundation.e.apps.ui.AppInfoFetchViewModel import foundation.e.apps.ui.MainActivity import foundation.e.apps.ui.MainActivityViewModel @@ -130,7 +130,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { lateinit var appLoungePackageManager: AppLoungePackageManager @Inject - lateinit var pwaManager: PWAManager + lateinit var pwaManager: PwaManager private val applicationViewModel: ApplicationViewModel by viewModels() private val privacyInfoViewModel: PrivacyInfoViewModel by viewModels() diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListFragment.kt index 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/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 399766b085eb054f25369a92188179da417d9bce..6224e03ebbe7492bafba249daddf14d0a0aa3ad8 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -72,8 +72,6 @@ Entdecke Top quelloffene aktualisierte Apps Top quelloffene aktualisierte Spiele - Beliebteste quelloffene Apps in den letzten 24 Stunden - Beliebteste quelloffene Spiele in den letzten 24 Stunden PWA beliebteste Apps PWA beliebteste Spiele Top kostenlose Apps @@ -143,7 +141,6 @@ App Lounge-Version Über Bitte wähle mindestens eine Quelle von Apps aus. - Entdecke PWA\'s Anonymer Login ist fehlgeschlagen! Das kann verursacht sein, weil ein Server nicht funktioniert. \n diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6d29329f5f66403f546d14b0018ef46facd2d382..7ddd324cf290f701e04731b73563bc1476d1e06a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -76,8 +76,6 @@ Explorar Aplicaciones de código abierto más actualizadas Juegos de código abierto más actualizados - Juegos de código abierto más populares en las últimas 24 horas - Aplicaciones de código abierto más populares en las últimas 24 horas Aplicaciones PWA populares Juegos PWA populares Las mejores aplicaciones gratuitas @@ -144,7 +142,6 @@ ¡Límite de tiempo buscando aplicaciones! No hay información de rastreo disponible para esta aplicación. Actualización de %1$s aplicaciones completada en %2$s. - Explorar PWA La actualización de %1$s ha fallado debido a una regla de soporte (ubicación, versión del sistema operativo...). Debido a un fallo temporal, no se pueden actualizar todas tus aplicaciones. Vuelve a intentarlo más tarde. Actualizar todo ha fallado. Se harán reintentos automáticos. diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index c254423c87db3d8e86f49e1d4c740dfcd0cd4b4b..ad26a3cfbe04e0c71cdc87dcbe1a0761d72a4a17 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -110,8 +110,6 @@ Top ilmaiset sovellukset PWA Suositut pelit PWA Suositut sovellukset - Suosittuja avoimen lähdekoodin pelejä viimeisen 24 tunnin aikana - Suosittuja avoimen lähdekoodin sovelluksia viimeisen 24 tunnin aikana Avoimen lähdekoodin päivitettyjen pelien Top lista Avoimen lähdekoodin päivitettyjen sovellusten Top lista Tutustu @@ -146,7 +144,6 @@ \n \nAvaa asetukset ja etsi vain avoimen lähdekoodin sovelluksia tai PWA:ita. Aikakatkaisu sovellusten hakemisessa! - Tutustu PWA:n Päivitysvirhe! Päivitystä ei voida suorittaa koska allekirjoitus on ristiriidassa %1$s ja puhelimeesi asennetun version välillä. Voit korjata tämän poistamalla %1$s ja asentamalla se uudestaan App Loungesta.

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

Note : Ce message ne s\'affichera plus.
Il est impossible d\'afficher les applications Google Play quand seules les applications Open Source sont sélectionnées. diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 10f3aeb51bf046c1260c0c397e6439a50513b6ae..073464ad2cacfe2b428944304f8bfb8b688ddee3 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -120,7 +120,6 @@ Af hverju sé ég opnu hugbúnaðarútgáfuna\? Forrit með opinn grunnkóða Öll forrit eru af nýjustu útgáfu - Kynntu þér PWA-vefforrit Vinsæl PWA-vefforrit Vinsælir PWA-leikir Næ ekki að tengjast! Athugaðu internettenginguna þína og prófaðu svo aftur @@ -134,8 +133,6 @@ Vinsælustu uppfærðu forritin með opinn grunnkóða Vinsælustu uppfærðir leikir með opinn grunnkóða Vinsælustu ókeypis og frjálsu forritin - Vinsæl forrit síðasta sólahring með opinn grunnkóða - Vinsæla leiki síðasta sólahring með opinn grunnkóða Vinsælustu ókeypis og frjálsu leikirnir Forrit með mestu innkomuna Leikir með mestu innkomuna @@ -208,4 +205,4 @@ Villa kom upp við að hlaða inn forritum með opnum grunnkóða og PWA. Aðeins algeng forrit eru tiltæk í augnablikinu. Algeng forrit óaðgengileg Villa kom upp við að hlaða inn algengum forritum. Aðeins forrit með opnum grunnkóða og PWA eru tiltæk í augnablikinu. - \ No newline at end of file + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 34663ceda0918a1ccf432a9a8821d97bc7e76cef..b95a1a5cb783302698812e7ca2250797fc17718f 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -75,8 +75,6 @@ Errore sconosciuto! Aggiorna tutto Scopri - App Open Source più richieste nelle ultime 24 ore - Giochi Open Source più richiesti nelle ultime 24 ore App PWA più richieste Giochi PWA più richiesti Migliori App Open Source aggiornate @@ -153,7 +151,6 @@ \nPuoi riprovare adesso o più tardi.
Si è verificato un errore durante il caricamento delle App. Maggiori informazioni - Scopri le PWA Non posso avviare l\'App Google Play se sono permesse solo App open source. Chiudi Mensilmente diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index cb3ade70cc24cb026de6a77960adef04248ccf98..4ad70dd981e159fbad82b96942d569655c251f8b 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -52,7 +52,6 @@ Applikasjonsoppdateringer vil bli installert automatisk Oppdateringer Nedlastinger - Oppdag PWA Oppdag %1$s sin oppdatering har mislyktes på grunn av et misforhold (lokasjon, operativsystemversjon…). På gunn av en midlertidig feil kan ikke alle dine applikasjoner bli oppdatert. Prøv igjen senere. @@ -164,9 +163,7 @@ Topp gratis applikasjoner Mest populære spill Topp gratis spill - Populære åpen kildekode-applikasjoner de siste 24 timer Populære PWA spill - Populære åpen kildekode-spill de siste 24 timer Mest innbringende applikasjoner Mest innbringende spill Ingen sporingsinformasjon tilgjengelig for denne applikasjonen. @@ -202,4 +199,4 @@ Systemapplikasjon Innholdsvarsel Samler innholdsvurdering for alle applikasjonene du har installert. - \ No newline at end of file + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 35a1480f330d0e4f0fb67936f3fd648967e21583..b8887c22fd8f9b585961de8e78c50b8e6eb0b2e2 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -47,7 +47,6 @@ Top Gratis Apps PWA Populaire Spellen PWA Populaire Apps - Ontdek PWA Ontdek Update Fout! Alle apps zijn up-to-date @@ -152,8 +151,6 @@ Geen \"runtime android\" machtiging gevonden! Top Populaire Games Top Populaire Apps - Open Source Populaire Games van de laatste 24 uur - Open Source Populaire Apps van de laatste 24 uur Open Source Top Geüpdatete Games Open Source Top Geüpdatet Apps De update voor %1$s is niet door een ondersteuning regel (locatie, OS versie...). @@ -204,4 +201,4 @@ Deze app kan naaktheid, godslastering, laster, geweld, seksualiteit, politieke incorrectheid of andere mogelijk ongepaste onderwerpen bevatten. Dit is voornamelijk relevant in omgevingen als werkplekken, scholen, religieuze instellingen en gezinnen. Attentie, update! App Lounge zal door het systeem afgesloten worden tijdens zijn update. Voer a.u.b. geen andere taken uit totdat App Lounge geüpdatet en afgesloten is. - \ No newline at end of file + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 32c8bdcb9d47031fe0f3747b7bc6695f5a7481c9..827fb00d85242c0836e4373bc057436629e7d7bf 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -118,12 +118,9 @@ Топ бесплатных приложений Популярные PWA игры Популярные PWA приложения - Популярные Open Source игры за последние 24 часа - Популярные Open Source приложения за последние 24 часа Топ Open Source обновленных игр Топ обновленных Open Source приложений Откройте для себя - Откройте для себя PWA Обновление %1$s не произошло из-за поддержки (местоположения, версии ОС...). Из-за временного сбоя все ваши приложения не могут быть обновлены. Пожалуйста, повторите попытку позже. Обновить всё не удалось. Выполняются автоматические повторные попытки. @@ -204,4 +201,4 @@ Запросить исходный отчёт Анонимная учетная запись, которую вы используете в данный момент, недоступна. Пожалуйста, обновите сессию, чтобы получить другую. ОБНОВИТЬ СЕССИИ - \ No newline at end of file + diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ba3250eab292960ca315774c229cf6d73e6d5e96..aa11e72a775f610cfca6777ab8197f3d4c78473f 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -110,9 +110,6 @@ Välj åtminstone en källa av applikationer. Integritetsanalys Har du problem\? - Upptäck PWA - Populäraste apparna de senaste 24 timmarna med öppen källkod - Populäraste spelen de senaste 24 timmarna med öppen källkod Populära PWA-appar Populära PWA-spel Hämtningar @@ -204,4 +201,4 @@ Systemapp Varning för uppdatering! Systemet kommer stänga App Lounge medan uppdatering installeras för App Lounge. Undvik att något annat tills App Lounge är uppdaterat och har stängts. - \ No newline at end of file + diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index e11370dde7d72d87fcb736922f710a13138cc272..c8afa6a5e4c8e1554e9ae8b2507a66403246570a 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -85,11 +85,8 @@ Geçici bir arıza nedeniyle uygulamalarınızın tümü güncellenemiyor. Lütfen daha sonra tekrar deneyin. %1$s güncellemesi bir destek kuralı (konum, işletim sistemi sürümü...) nedeniyle başarısız oldu. Keşfet - PWA\'ları keşfedin Açık Kaynaklı Tutan Güncel Oyunlar Açık Kaynaklı Tutan Güncel Uygulamalar - Son 24 Saatte Açık Kaynaklı Popüler Uygulamalar - Son 24 Saatin Popüler Açık Kaynak Oyunları PWA popüler uygulamalar PWA Popüler Uygulamalar En Çok Kazanan Uygulamalar @@ -187,4 +184,4 @@ \n \nTekrar denemek için Yeniden Dene\'ye basın.
%s ekstra modüller yüklemek istiyor. Bunları yükleyebilmek için AppLounge\'da tekrar oturum açmalısınız. - \ No newline at end of file + diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index c40f460a8a0ce83df6f29105774f149f6a92ce9a..a02f1f8a6a7635f65400ef2ffc74dd455c525a8f 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -97,7 +97,6 @@ Оновлення не вдалося. Автоматичні повторні спроби уже в процесі. Трендові додатки в Топі Безкоштовні ігри в Топі - Дослідити PWA Дослідити %1$d оновлення застосунку доступне @@ -122,8 +121,6 @@ Топ безкоштовних ігор Популярні прогресивні веб-ігри Популярні прогресивні веб-застосунки - Популярні ігри з відкритим кодом за останню добу - Популярні додатки з відкритим кодом за останню добу Топ оновлених Ігор з відкритим кодом Топ оновлених додатків з відкритим кодом Оновлення %1$s не вдалося з причини підтримки (наприклад місцезнаходження, версія ОС…). @@ -174,4 +171,4 @@ Зареєструватися Обліковий запис недоступний Поділитися - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2ab9f4a3a597433eb8c6321890ccff2e0b4a73c1..e6cd006899e2056220b09d32fc5da5646894bcd0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,11 +147,8 @@ App Lounge will be closed by the system while installing its own update. Kindly refrain from doing any other task till App Lounge is updated and closed. Discover - Discover PWA Open Source Top Updated Apps Open Source Top Updated Games - Open Source Popular Apps In Last 24 Hours - Open Source Popular Games In Last 24 Hours PWA Popular Apps PWA Popular Games Top Free Apps diff --git a/app/src/test/java/foundation/e/apps/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..8cda6e3cff0d20e7da276b0d901644618b302273 100644 --- a/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt +++ b/app/src/test/java/foundation/e/apps/apps/AppsApiTest.kt @@ -22,11 +22,9 @@ import android.content.Context import android.text.format.Formatter import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.aurora.gplayapi.Constants -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer -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 +32,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 +67,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 +76,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 @@ -120,7 +120,7 @@ class AppsApiTest { @Test fun `is any app updated when new list is empty`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -154,7 +154,7 @@ class AppsApiTest { @Test fun `is any app updated when any app is uninstalled`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -175,7 +175,7 @@ class AppsApiTest { ) ) - val newAppList = mutableListOf( + val newAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -202,7 +202,7 @@ class AppsApiTest { @Test fun `has any app install status changed when changed`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -263,7 +263,7 @@ class AppsApiTest { @Test fun `has any app install status changed when not changed`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -324,7 +324,7 @@ class AppsApiTest { @Test fun `has any app install status changed when installation_issue`() { - val oldAppList = mutableListOf( + val oldAppList = mutableListOf( Application( _id = "111", status = Status.INSTALLATION_ISSUE, @@ -491,7 +491,7 @@ class AppsApiTest { } Mockito.`when`(gPlayAPIRepository.getAppDetails(fusedApp.package_name)) - .thenReturn(App(fusedApp.package_name)) + .thenReturn(Application(fusedApp.package_name)) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( @@ -533,7 +533,7 @@ class AppsApiTest { } Mockito.`when`(gPlayAPIRepository.getAppDetails(fusedApp.package_name)) - .thenReturn(App(fusedApp.package_name)) + .thenReturn(Application(fusedApp.package_name)) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( diff --git a/app/src/test/java/foundation/e/apps/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..3bb56cea6c3ac1584290c6e5dc02cdcac6167195 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 @@ -148,7 +148,7 @@ class SearchApiImplTest { @Ignore("Dependencies are not mockable") @Test fun `getSearchResult When all sources are selected`() = runTest { - val appList = mutableListOf( + val appList = mutableListOf( Application( _id = "111", status = Status.UNAVAILABLE, @@ -174,7 +174,7 @@ class SearchApiImplTest { val searchResult = Search(apps = appList, numberOfResults = 3, success = true) val packageNameSearchResponse = Response.success(searchResult) - val gplayPackageResult = App("com.search.package") + val gplayPackageResult = Application("com.search.package") preferenceManagerModule.isPWASelectedFake = true preferenceManagerModule.isOpenSourceelectedFake = true @@ -196,7 +196,7 @@ class SearchApiImplTest { private suspend fun setupMockingSearchApp( packageNameSearchResponse: Response?, - gplayPackageResult: App, + gplayPackageResult: Application, gplayLivedata: Pair, MutableSet>, willThrowException: Boolean = false ) { @@ -231,7 +231,7 @@ class SearchApiImplTest { ).thenReturn(packageNameSearchResponse) Mockito.`when`(cleanApkAppsRepository.getAppDetails(any())) - .thenReturn(Response.error(404, "".toResponseBody())) + .thenReturn(Application()) Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null)) .thenReturn(gplayLivedata) @@ -266,7 +266,7 @@ class SearchApiImplTest { val searchResult = Search(apps = appList, numberOfResults = 1, success = true) val packageNameSearchResponse = Response.success(searchResult) - val gplayPackageResult = App("com.search.package") + val gplayPackageResult = Application("com.search.package") val gplayFlow: Pair, MutableSet> = Pair( listOf(App("a.b.c"), App("c.d.e"), App("d.e.f"), App("d.e.g")), mutableSetOf() diff --git a/app/src/test/java/foundation/e/apps/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..ab9348c9713c72b360e316edad42050b292c02ce 100644 --- a/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt +++ b/app/src/test/java/foundation/e/apps/home/HomeApiTest.kt @@ -21,17 +21,18 @@ package foundation.e.apps.home import android.content.Context import android.text.format.Formatter import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import com.aurora.gplayapi.data.models.App import com.aurora.gplayapi.data.models.AuthData import foundation.e.apps.FakeAppLoungePreference import foundation.e.apps.data.AppSourcesContainer import foundation.e.apps.data.application.ApplicationDataManager +import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.home.HomeApi import foundation.e.apps.data.application.home.HomeApiImpl -import foundation.e.apps.data.cleanapk.repositories.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 @@ -111,19 +112,19 @@ class HomeApiTest { @Test fun testHomeScreenDataWhenDataIsLimited() = runTest { - val newAppList = mutableListOf( - App("foundation.e.demoone"), - App("foundation.e.demotwo"), - App("foundation.e.demothree"), + val newAppList = mutableListOf( + Application("foundation.e.demoone"), + Application("foundation.e.demotwo"), + Application("foundation.e.demothree"), ) - var newHomeData = mapOf>(Pair("Top Free Apps", newAppList)) + val newHomeData = mapOf>(Pair("Top Free Apps", newAppList)) preferenceManagerModule.isGplaySelectedFake = true formatterMocked.`when` { Formatter.formatFileSize(any(), any()) }.thenReturn("15MB") Mockito.`when`(gPlayAPIRepository.getHomeScreenData()).thenReturn(newHomeData) Mockito.`when`(gPlayAPIRepository.getAppDetails(ArgumentMatchers.anyString())).thenReturn( - App("foundation.e.demothree") + Application("foundation.e.demothree") ) Mockito.`when`( gPlayAPIRepository.getDownloadInfo( @@ -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 diff --git a/lint.xml b/lint.xml index bfd91922ca850f47cc99a7682bc304a0d11e3c19..9debeab74fa18efb7d0a54b4a130841c3c9d72aa 100644 --- a/lint.xml +++ b/lint.xml @@ -34,6 +34,9 @@ + + +