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

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

refactor: refactor parental control use case classes

This commit includes the following changes:
- Renamed GetParentalControlStateUseCaseImpl.kt to GetParentalControlStateUseCase.kt, and updated its usage in other classes.
- Updated import statements in GetAppInstallationPermissionUseCaseTest.kt and GetAppInstallationPermissionUseCase.kt to reflect the new class name.
- Removed an unused import from GetAppInstallationPermissionUseCase.kt.
parent 00cf6431
Loading
Loading
Loading
Loading
+0 −1
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.GetParentalControlStateUseCase
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState.AgeGroup
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState.Disabled
+3 −4
Original line number Diff line number Diff line
@@ -21,23 +21,22 @@ package foundation.e.apps.data.parentalcontrol
import android.content.Context
import android.net.Uri
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.domain.parentalcontrol.GetParentalControlStateUseCase
import foundation.e.apps.domain.parentalcontrol.model.AgeGroupValue
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class GetParentalControlStateUseCaseImpl
class GetParentalControlStateUseCase
@Inject
constructor(@ApplicationContext private val context: Context) : GetParentalControlStateUseCase {
constructor(@ApplicationContext private val context: Context) {
    companion object {
        private const val URI_PARENTAL_CONTROL_PROVIDER =
            "content://foundation.e.parentalcontrol.provider/age"
        private const val COLUMN_NAME = "age"
    }

    override suspend fun invoke(): ParentalControlState {
    fun invoke(): ParentalControlState {
        val uri = Uri.parse(URI_PARENTAL_CONTROL_PROVIDER)

        val cursor =
+0 −38
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.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.parentalcontrol.GetParentalControlStateUseCaseImpl
import foundation.e.apps.domain.parentalcontrol.GetParentalControlStateUseCase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
interface UseCaseModule {

    @Singleton
    @Binds
    fun bindGetParentalControlStateUseCase(
        useCase: GetParentalControlStateUseCaseImpl
    ): GetParentalControlStateUseCase
}
+0 −25
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.domain.parentalcontrol.model.ParentalControlState

interface GetParentalControlStateUseCase {
    suspend operator fun invoke(): ParentalControlState
}
+4 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.models.ContentRating
import foundation.e.apps.data.application.ApplicationRepository
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.cleanapk.data.app.Application as AppLoungeApplication
import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository
import foundation.e.apps.data.enums.ResultStatus
import foundation.e.apps.data.install.models.AppInstall
@@ -31,14 +32,16 @@ import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.All
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.parentalcontrol.GetParentalControlStateUseCase
import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingGroup
import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingsRepository
import foundation.e.apps.data.playstore.PlayStoreRepository
import foundation.e.apps.data.preference.DataStoreManager
import foundation.e.apps.domain.parentalcontrol.GetParentalControlStateUseCase
import foundation.e.apps.domain.parentalcontrol.model.AgeGroupValue
import foundation.e.apps.domain.parentalcontrol.model.ParentalControlState
import foundation.e.apps.util.MainCoroutineRule
import javax.inject.Named
import kotlin.test.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -47,9 +50,6 @@ import org.junit.Test
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
import javax.inject.Named
import kotlin.test.assertEquals
import foundation.e.apps.data.cleanapk.data.app.Application as AppLoungeApplication

class GetAppInstallationPermissionUseCaseTest {