From 5f9f229bcb432cc4a4e04a1d0c978565c20f2e8a Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Wed, 11 Oct 2023 17:00:09 +0600 Subject: [PATCH] changed fdroid with cleanapk to check app existance --- .../e/apps/data/cleanapk/RetrofitModule.kt | 13 -------- .../e/apps/data/fdroid/FdroidWebInterface.kt | 32 ------------------- .../e/apps/data/fused/FusedApiImpl.kt | 6 ++-- .../e/apps/fused/FusedApiImplTest.kt | 10 ++---- 4 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/data/fdroid/FdroidWebInterface.kt 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 c924f27c7..a9e28c0d6 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 0d3917ec7..000000000 --- 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 5aa83c320..4b25be110 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 22389662a..bc91a6ff9 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) -- GitLab