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

Verified Commit 9e227fc8 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

feat: refactor GetAppInstallationPermissionUseCase

Refactored GetAppInstallationPermissionUseCase. Removed its interface and renamed GetAppInstallationPermissionUseCaseImpl to GetAppInstallationPermissionUseCase. Also updated all the references accordingly. Removed commented out code in CleanApkRetrofit class and removed unused binding in UseCaseModule.
parent 21ca6d77
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -34,10 +34,6 @@ interface CleanApkRetrofit {
        const val BASE_URL = "https://api.cleanapk.org/v2/"
        const val ASSET_URL = "https://api.cleanapk.org/v2/media/"

        // TODO: Configure dev and prod flavors to auto switch URLs
//         const val BASE_URL = "https://api.dev.cleanapk.org/v2/"
//         const val ASSET_URL = "https://api.dev.cleanapk.org/v2/media/"

        // Application sources
        const val APP_SOURCE_FOSS = "open"
        const val APP_SOURCE_ANY = "any"
+3 −4
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Den
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.DeniedOnDataLoadError
import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingsRepository
import foundation.e.apps.data.playstore.PlayStoreRepository
import foundation.e.apps.domain.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.domain.parentalcontrol.GetParentalControlStateUseCase
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState.AgeGroup
@@ -36,20 +35,20 @@ import foundation.e.apps.domain.parentalcontrol.model.isEnabled
import javax.inject.Inject
import javax.inject.Named

class GetAppInstallationPermissionUseCaseImpl
class GetAppInstallationPermissionUseCase
@Inject
constructor(
    private val googlePlayContentRatingsRepository: GooglePlayContentRatingsRepository,
    private val getParentalControlStateUseCase: GetParentalControlStateUseCase,
    private val playStoreRepository: PlayStoreRepository,
    @Named("cleanApkAppsRepository") private val cleanApkRepository: CleanApkRepository
) : GetAppInstallationPermissionUseCase {
) {

    companion object {
        private const val KEY_ANTI_FEATURES_NSFW = "NSFW"
    }

    override suspend operator fun invoke(app: AppInstall): AppInstallationPermissionState {
    suspend operator fun invoke(app: AppInstall): AppInstallationPermissionState {
        return when (val parentalControl = getParentalControlStateUseCase.invoke()) {
            is Disabled -> Allowed
            is AgeGroup ->
+0 −7
Original line number Diff line number Diff line
@@ -22,20 +22,13 @@ import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.parentalcontrol.GetAppInstallationPermissionUseCaseImpl
import foundation.e.apps.data.parentalcontrol.GetParentalControlStateUseCaseImpl
import foundation.e.apps.domain.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.domain.parentalcontrol.GetParentalControlStateUseCase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
interface UseCaseModule {
    @Singleton
    @Binds
    fun bindGetAppInstallationPermissionUseCase(
        useCase: GetAppInstallationPermissionUseCaseImpl
    ): GetAppInstallationPermissionUseCase

    @Singleton
    @Binds
+0 −26
Original line number Diff line number Diff line
/*
 * 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 <https://www.gnu.org/licenses/>.
 *
 */

package foundation.e.apps.domain.parentalcontrol

import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState

interface GetAppInstallationPermissionUseCase {
    suspend operator fun invoke(app: AppInstall): AppInstallationPermissionState
}
+2 −5
Original line number Diff line number Diff line
@@ -33,9 +33,9 @@ import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Allowed
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Denied
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.DeniedOnDataLoadError
import foundation.e.apps.data.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.data.playstore.utils.GplayHttpRequestException
import foundation.e.apps.data.preference.DataStoreManager
import foundation.e.apps.domain.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.install.AppInstallComponents
import foundation.e.apps.install.download.DownloadManagerUtils
import foundation.e.apps.install.notification.StorageNotificationManager
@@ -136,10 +136,7 @@ class AppInstallProcessor @Inject constructor(
                return
            }


            val installationPermission =
                getAppInstallationPermissionUseCase.invoke(appInstall)
            when (installationPermission) {
            when (getAppInstallationPermissionUseCase.invoke(appInstall)) {
                Allowed -> {
                    Timber.i("${appInstall.name} is allowed to be installed.")
                    // no operation, allow installation
Loading