diff --git a/app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt b/app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt index c924f27c7ad5412351e3f3f40ce9b58b530ddb12..a9e28c0d62e5d6181e74925cd875f12143e8e34c 100644 --- a/app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt +++ b/app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt @@ -33,7 +33,6 @@ import foundation.e.apps.data.cleanapk.data.app.Application import foundation.e.apps.data.ecloud.EcloudApiInterface import foundation.e.apps.data.exodus.ExodusTrackerApi import foundation.e.apps.data.fdroid.FdroidApiInterface -import foundation.e.apps.data.fdroid.FdroidWebInterface import okhttp3.Cache import okhttp3.Interceptor import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -121,18 +120,6 @@ object RetrofitModule { .create(FdroidApiInterface::class.java) } - @Singleton - @Provides - fun provideFdroidWebApi( - okHttpClient: OkHttpClient, - ): FdroidWebInterface { - return Retrofit.Builder() - .baseUrl(FdroidWebInterface.BASE_URL) - .client(okHttpClient) - .build() - .create(FdroidWebInterface::class.java) - } - @Singleton @Provides fun provideEcloudApi(okHttpClient: OkHttpClient, moshi: Moshi): EcloudApiInterface { diff --git a/app/src/main/java/foundation/e/apps/data/fdroid/FdroidWebInterface.kt b/app/src/main/java/foundation/e/apps/data/fdroid/FdroidWebInterface.kt deleted file mode 100644 index 0d3917ec7f689c23fedfe688acfe5b7ffa30032a..0000000000000000000000000000000000000000 --- a/app/src/main/java/foundation/e/apps/data/fdroid/FdroidWebInterface.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019-2022 MURENA SAS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package foundation.e.apps.data.fdroid - -import okhttp3.ResponseBody -import retrofit2.Response -import retrofit2.http.GET -import retrofit2.http.Path - -interface FdroidWebInterface { - companion object { - const val BASE_URL = "https://f-droid.org/fr/packages/" - } - - @GET("{packageName}") - suspend fun getFdroidApp(@Path("packageName") packageName: String): Response -} diff --git a/app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt b/app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt index 5aa83c320f7bfc44dc45372b65b422d65c6751f4..4b25be110fb2e75e074dee59e6fcf7ac6734f0b3 100644 --- a/app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/fused/FusedApiImpl.kt @@ -49,7 +49,6 @@ import foundation.e.apps.data.enums.Source import foundation.e.apps.data.enums.Status import foundation.e.apps.data.enums.Type import foundation.e.apps.data.enums.isUnFiltered -import foundation.e.apps.data.fdroid.FdroidWebInterface import foundation.e.apps.data.fused.FusedApi.Companion.APP_TYPE_ANY import foundation.e.apps.data.fused.FusedApi.Companion.APP_TYPE_OPEN import foundation.e.apps.data.fused.FusedApi.Companion.APP_TYPE_PWA @@ -82,7 +81,6 @@ class FusedApiImpl @Inject constructor( private val pkgManagerModule: PkgManagerModule, private val pwaManagerModule: PWAManagerModule, private val preferenceManagerModule: PreferenceManagerModule, - private val fdroidWebInterface: FdroidWebInterface, @Named("gplayRepository") private val gplayRepository: GplayStoreRepository, @Named("cleanApkAppsRepository") private val cleanApkAppsRepository: CleanApkRepository, @Named("cleanApkPWARepository") private val cleanApkPWARepository: CleanApkRepository, @@ -1046,8 +1044,8 @@ class FusedApiImpl @Inject constructor( */ private suspend fun replaceWithFDroid(gPlayApp: App): FusedApp { val gPlayFusedApp = gPlayApp.transformToFusedApp() - val response = fdroidWebInterface.getFdroidApp(gPlayFusedApp.package_name) - if (response.isSuccessful) { + val response = cleanApkAppsRepository.getAppDetails(gPlayApp.packageName) + if (response != null) { val fdroidApp = getCleanApkPackageResult(gPlayFusedApp.package_name)?.apply { updateSource() isGplayReplaced = true diff --git a/app/src/test/java/foundation/e/apps/fused/FusedApiImplTest.kt b/app/src/test/java/foundation/e/apps/fused/FusedApiImplTest.kt index 22389662aebfc57f310e7a20be6efd5a5f95ddf4..bc91a6ff9f3b743b58d9fd15e64fbc879a2d90fd 100644 --- a/app/src/test/java/foundation/e/apps/fused/FusedApiImplTest.kt +++ b/app/src/test/java/foundation/e/apps/fused/FusedApiImplTest.kt @@ -34,7 +34,6 @@ import foundation.e.apps.data.enums.FilterLevel 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.fdroid.FdroidWebInterface import foundation.e.apps.data.fused.FusedApiImpl import foundation.e.apps.data.fused.data.FusedApp import foundation.e.apps.data.fused.data.FusedHome @@ -45,6 +44,7 @@ import foundation.e.apps.install.pkg.PkgManagerModule import foundation.e.apps.util.MainCoroutineRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest +import okhttp3.ResponseBody import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.After import org.junit.Assert.assertEquals @@ -95,9 +95,6 @@ class FusedApiImplTest { @Mock private lateinit var gPlayAPIRepository: GplayStoreRepository - @Mock - private lateinit var fdroidWebInterface: FdroidWebInterface - private lateinit var preferenceManagerModule: FakePreferenceModule private lateinit var formatterMocked: MockedStatic @@ -115,7 +112,6 @@ class FusedApiImplTest { pkgManagerModule, pwaManagerModule, preferenceManagerModule, - fdroidWebInterface, gPlayAPIRepository, cleanApkAppsRepository, cleanApkPWARepository, @@ -783,8 +779,8 @@ class FusedApiImplTest { ) ).thenReturn(packageNameSearchResponse) - Mockito.`when`(fdroidWebInterface.getFdroidApp(any())) - .thenReturn(Response.error(404, "".toResponseBody(null))) + Mockito.`when`(cleanApkAppsRepository.getAppDetails(any())) + .thenReturn(Response.error(404, "".toResponseBody())) Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null)) .thenReturn(gplayLivedata)