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

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

refactor: fix the bug where the ratings from GitLab were not being set

parent 45f75c6b
Loading
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class GooglePlayContentRatingsRepository @Inject constructor(
class GooglePlayContentRatingsRepository
@Inject
constructor(
    private val downloadManager: DownloadManager,
    private val googlePlayContentRatingParser: GooglePlayContentRatingParser
) {
@@ -41,11 +43,12 @@ class GooglePlayContentRatingsRepository @Inject constructor(

    fun fetchContentRatingData() {
        downloadManager.downloadFileInCache(
            CONTENT_RATINGS_FILE_URL,
            fileName = CONTENT_RATINGS_FILE_NAME
        ) { success, _ ->
            CONTENT_RATINGS_FILE_URL, fileName = CONTENT_RATINGS_FILE_NAME) { success, _ ->
                _contentRatingGroups =
                    if (success) {
                        googlePlayContentRatingParser.parseContentRatingData()
                    } else {
                        emptyList()
                    }
            }
    }
+6 −9
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.GetAppInstallationPermissionUseCaseImpl
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
@@ -56,7 +56,7 @@ class AppInstallProcessor @Inject constructor(
    @ApplicationContext private val context: Context,
    private val appInstallComponents: AppInstallComponents,
    private val applicationRepository: ApplicationRepository,
    private val getAppInstallationPermissionUseCaseImpl: GetAppInstallationPermissionUseCaseImpl,
    private val getAppInstallationPermissionUseCase: GetAppInstallationPermissionUseCase,
    private val dataStoreManager: DataStoreManager,
    private val storageNotificationManager: StorageNotificationManager,
) {
@@ -138,25 +138,22 @@ class AppInstallProcessor @Inject constructor(


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

                Denied -> {
                    Timber.tag("Parental control")
                        .i("${appInstall.name} can't be installed because of parental control setting.")
                    Timber.i("${appInstall.name} can't be installed because of parental control setting.")
                    EventBus.invokeEvent(AppEvent.AgeLimitRestrictionEvent(appInstall.name))
                    appInstallComponents.appManagerWrapper.cancelDownload(appInstall)
                    return
                }

                DeniedOnDataLoadError -> {
                    Timber.tag("Parental control")
                        .i("${appInstall.name} can't be installed because of unavailable data.")
                    Timber.i("${appInstall.name} can't be installed because of unavailable data.")
                    EventBus.invokeEvent(AppEvent.ErrorMessageDialogEvent(R.string.data_load_error_desc))
                    appInstallComponents.appManagerWrapper.cancelDownload(appInstall)
                    return
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import foundation.e.apps.data.install.AppManager
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState
import foundation.e.apps.data.preference.DataStoreManager
import foundation.e.apps.data.parentalcontrol.GetAppInstallationPermissionUseCaseImpl
import foundation.e.apps.domain.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.install.AppInstallComponents
import foundation.e.apps.install.notification.StorageNotificationManager
import foundation.e.apps.install.workmanager.AppInstallProcessor
@@ -79,7 +79,7 @@ class AppInstallProcessorTest {
    private lateinit var appInstallProcessor: AppInstallProcessor

    @Mock
    private lateinit var getAppInstallationPermissionUseCase: GetAppInstallationPermissionUseCaseImpl
    private lateinit var getAppInstallationPermissionUseCase: GetAppInstallationPermissionUseCase

    @Mock
    private lateinit var storageNotificationManager: StorageNotificationManager