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

Verified Commit 908d31f1 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: fetch F-Droid app info before verifying installation

- Added new function getAppDetailsById in CleanApkRepository interface and its implementations in CleanApkAppsRepositoryImpl and CleanApkPWARepository
- Updated GetAppInstallationPermissionUseCaseImpl to fetch complete app information before validating NSFW anti-feature
- Updated Application data class to handle missing isFDroidApp property in search results
parent 8adea69e
Loading
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -101,7 +101,8 @@ data class Application(
    var filterLevel: FilterLevel = FilterLevel.UNKNOWN,
    var isGplayReplaced: Boolean = false,
    @SerializedName(value = "on_fdroid")
    val isFDroidApp: Boolean = false,
    private val isFDroidAppBackingField: Boolean? = null,
    val isFDroidApp: Boolean = isFDroidAppBackingField ?: isFDroid(type, origin),
    var contentRating: ContentRating = ContentRating(),
    @SerializedName(value = "antifeatures")
    val antiFeatures: List<Map<String, String>> = emptyList()
@@ -119,14 +120,8 @@ data class Application(
    }
}

val Application.shareUri: Uri
    get() = when (type) {
        PWA -> Uri.parse(url)
        NATIVE -> when {
            isFDroidApp -> buildFDroidUri(package_name)
            else -> Uri.parse(shareUrl)
        }
    }
private fun isFDroid(type: Type, origin: Origin) =
    (type == NATIVE && origin == Origin.CLEANAPK)

private fun buildFDroidUri(packageName: String): Uri {
    return Uri.Builder()
@@ -136,3 +131,12 @@ private fun buildFDroidUri(packageName: String): Uri {
        .appendPath(packageName)
        .build()
}

val Application.shareUri: Uri
    get() = when (type) {
        PWA -> Uri.parse(url)
        NATIVE -> when {
            isFDroidApp -> buildFDroidUri(package_name)
            else -> Uri.parse(shareUrl)
        }
    }
+18 −15
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 MURENA SAS
 *
 *  * 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 <https://www.gnu.org/licenses/>.
 * 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/>.
 *
 */

@@ -33,4 +31,9 @@ interface CleanApkAppDetailsRetrofit {
        @Query("architectures") architectures: List<String>? = null,
        @Query("type") type: String? = null
    ): Response<Application>

    @GET("apps?action=app_detail")
    suspend fun getAppDetails(
        @Query("id") id: String
    ): Application
}
+6 −2
Original line number Diff line number Diff line
/*
 * Copyright MURENA SAS 2023
 * Apps  Quickly and easily install Android apps onto your device!
 * 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
@@ -14,6 +13,7 @@
 *
 * 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.cleanapk.repositories
@@ -75,6 +75,10 @@ class CleanApkAppsRepositoryImpl(
        return cleanApkRetrofit.checkAvailablePackages(packageNames)
    }

    override suspend fun getAppDetailsById(appId: String): Result<Application> {
        return runCatching { cleanApkAppDetailsRetrofit.getAppDetails(appId) }
    }

    override suspend fun getAppDetails(packageNameOrId: String): Response<Application> {
        return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null)
    }
+6 −2
Original line number Diff line number Diff line
/*
 * Copyright MURENA SAS 2023
 * Apps  Quickly and easily install Android apps onto your device!
 * 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
@@ -14,6 +13,7 @@
 *
 * 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.cleanapk.repositories
@@ -69,6 +69,10 @@ class CleanApkPWARepository(
        return cleanAPKRetrofit.checkAvailablePackages(packageNames)
    }

    override suspend fun getAppDetailsById(appId: String): Result<Application> {
        return runCatching { cleanApkAppDetailsRetrofit.getAppDetails(appId) }
    }

    override suspend fun getAppDetails(packageNameOrId: String): Response<Application> {
        return cleanApkAppDetailsRetrofit.getAppOrPWADetailsByID(packageNameOrId, null, null)
    }
+4 −2
Original line number Diff line number Diff line
/*
 * Copyright MURENA SAS 2023
 * Apps  Quickly and easily install Android apps onto your device!
 * 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
@@ -14,11 +13,13 @@
 *
 * 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.cleanapk.repositories

import foundation.e.apps.data.StoreRepository
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
@@ -31,4 +32,5 @@ interface CleanApkRepository : StoreRepository {
    suspend fun getAppsByCategory(category: String, paginationParameter: Any? = null): Response<Search>
    suspend fun getCategories(): Response<Categories>
    suspend fun checkAvailablePackages(packageNames: List<String>): Response<Search>
    suspend fun getAppDetailsById(appId: String): Result<Application>
}
Loading