Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1ce1c46 authored by Nishant Dande's avatar Nishant Dande
Browse files

Merge branch 'main' into 1346-connect-anonymous-api-with-ui

# Conflicts:
#	app/src/main/java/foundation/e/apps/data/cleanapk/RetrofitModule.kt
parents 93c8600a 9e4bf86f
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -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 {
+0 −32
Original line number Diff line number Diff line
/*
 * 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 <https://www.gnu.org/licenses/>.
 */

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<ResponseBody>
}
+2 −4
Original line number Diff line number Diff line
@@ -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,
@@ -1047,8 +1045,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
+4 −0
Original line number Diff line number Diff line
@@ -125,4 +125,8 @@
    <string name="privacy_description">Integritetspoängen är automatiskt beräknad utifrån behörigheter och spårare som detekterats i applikationer. Det ger en fingervisning micro-spårar sina användare.&lt;br /&gt;&lt;br /&gt;Algoritmens källkod för beräkningar kan hittas &lt;a href=<xliff:g id="source_code">%1$s</xliff:g>&gt;här&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Spårardetektering utförs med &lt;a href=<xliff:g id="exodus">%2$s</xliff:g>&gt;Exodus Privacy tools&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Poäng av 10.&lt;br /&gt;&lt;br /&gt;Läs mer om hur Integritetspoäng beräknas, dess begränsningar och hur du kan skydda dig själv från microspårning &lt;a href=<xliff:g id="e_doc">%3$s</xliff:g>&gt;på denna sidan&lt;/a&gt;.</string>
    <string name="updates">Uppdateringar</string>
    <string name="message_update_failed">På grund av ett tillfälligt fel kan inte alla dina appar uppdateras. Försök igen senare.</string>
    <string name="checking_updates">Söker efter uppdateringar ...</string>
    <string name="topselling_free_apps" weblate_ctx="home">Topplista: Gratisappar</string>
    <string name="topselling_free_games" weblate_ctx="home">Topplista: Gratisspel</string>
    <string name="topgrossing_apps" weblate_ctx="home">Topplista: Betalappar</string>
</resources>
 No newline at end of file
+3 −7
Original line number Diff line number Diff line
@@ -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<Formatter>
@@ -115,7 +112,6 @@ class FusedApiImplTest {
            pkgManagerModule,
            pwaManagerModule,
            preferenceManagerModule,
            fdroidWebInterface,
            gPlayAPIRepository,
            cleanApkAppsRepository,
            cleanApkPWARepository,
@@ -794,8 +790,8 @@ class FusedApiImplTest {
            )
        ).thenReturn(packageNameSearchResponse)

        Mockito.`when`(fdroidWebInterface.getFdroidApp(any()))
            .thenReturn(Response.error(404, "".toResponseBody(null)))
        Mockito.`when`(cleanApkAppsRepository.getAppDetails(any()))
            .thenReturn(Response.error<ResponseBody>(404, "".toResponseBody()))

        Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"), null))
            .thenReturn(gplayLivedata)