From 570bfa641052e28b54560f3751526a4e817cdc0f Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Tue, 25 Jun 2024 19:42:50 +0600 Subject: [PATCH 1/3] refactor: separate Google Play and F-Droid functionality in parental control This commit refactors the parental control components in the application by separating the Google Play and F-Droid related functionalities. It also renames and reorganizes the relevant classes and methods to improve readability and maintainability. --- .../data/blockedApps/ContentRatingGroup.kt | 29 ------------ .../ParentalControlRepository.kt | 25 +++++----- .../fdroid/FDroidAntiFeatureRepository.kt | 36 +++++++++++++++ .../{ => fdroid}/FDroidMonitorApi.kt | 2 +- .../{ => fdroid}/FDroidMonitorData.kt | 2 +- .../{ => gplayrating}/AgeGroupApi.kt | 5 +- .../GooglePlayContentRatingGroup.kt | 28 +++++++++++ .../GooglePlayContentRatingParser.kt} | 37 ++++++++------- .../GooglePlayContentRatingRepository.kt} | 18 ++------ .../e/apps/di/network/RetrofitApiModule.kt | 4 +- .../apps/domain/ValidateAppAgeLimitUseCase.kt | 20 ++++---- .../e/apps/provider/AgeRatingProvider.kt | 46 ++++++++++--------- .../e/apps/ui/MainActivityViewModel.kt | 10 ++-- .../ui/application/ApplicationViewModel.kt | 6 +-- 14 files changed, 148 insertions(+), 120 deletions(-) delete mode 100644 app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingGroup.kt rename app/src/main/java/foundation/e/apps/data/{blockedApps => parentalcontrol}/ParentalControlRepository.kt (56%) create mode 100644 app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt rename app/src/main/java/foundation/e/apps/data/parentalcontrol/{ => fdroid}/FDroidMonitorApi.kt (94%) rename app/src/main/java/foundation/e/apps/data/parentalcontrol/{ => fdroid}/FDroidMonitorData.kt (94%) rename app/src/main/java/foundation/e/apps/data/parentalcontrol/{ => gplayrating}/AgeGroupApi.kt (84%) create mode 100644 app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt rename app/src/main/java/foundation/e/apps/data/{blockedApps/ContentRatingParser.kt => parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt} (63%) rename app/src/main/java/foundation/e/apps/data/{blockedApps/ContentRatingsRepository.kt => parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt} (71%) diff --git a/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingGroup.kt b/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingGroup.kt deleted file mode 100644 index ec2be627e..000000000 --- a/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingGroup.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright MURENA SAS 2024 - * 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 . - * - */ - -package foundation.e.apps.data.blockedApps - -import com.squareup.moshi.Json - -data class ContentRatingGroup( - val id: String, - @Json(name = "age_group") - val ageGroup: String, - var ratings: List -) diff --git a/app/src/main/java/foundation/e/apps/data/blockedApps/ParentalControlRepository.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt similarity index 56% rename from app/src/main/java/foundation/e/apps/data/blockedApps/ParentalControlRepository.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt index 6cab641e3..d5279252a 100644 --- a/app/src/main/java/foundation/e/apps/data/blockedApps/ParentalControlRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/ParentalControlRepository.kt @@ -1,23 +1,22 @@ /* - * Copyright MURENA SAS 2024 - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * 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. + * 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 . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * */ -package foundation.e.apps.data.blockedApps +package foundation.e.apps.data.parentalcontrol import android.content.Context import android.net.Uri diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt new file mode 100644 index 000000000..426cdb961 --- /dev/null +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt @@ -0,0 +1,36 @@ +/* + * 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 . + * + */ + +package foundation.e.apps.data.parentalcontrol.fdroid + +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class FDroidAntiFeatureRepository +@Inject +constructor( + private val fDroidMonitorApi: FDroidMonitorApi, +) { + var fDroidNsfwApps = listOf() + private set + + suspend fun fetchNsfwApps() { + fDroidNsfwApps = fDroidMonitorApi.getMonitorData().body()?.getNSFWApps() ?: emptyList() + } +} diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/FDroidMonitorApi.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorApi.kt similarity index 94% rename from app/src/main/java/foundation/e/apps/data/parentalcontrol/FDroidMonitorApi.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorApi.kt index 2d36c5d05..0967b9e99 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/FDroidMonitorApi.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorApi.kt @@ -16,7 +16,7 @@ * */ -package foundation.e.apps.data.parentalcontrol +package foundation.e.apps.data.parentalcontrol.fdroid import retrofit2.Response import retrofit2.http.GET diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/FDroidMonitorData.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt similarity index 94% rename from app/src/main/java/foundation/e/apps/data/parentalcontrol/FDroidMonitorData.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt index b30c61794..c17c2ce58 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/FDroidMonitorData.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt @@ -16,7 +16,7 @@ * */ -package foundation.e.apps.data.parentalcontrol +package foundation.e.apps.data.parentalcontrol.fdroid import com.squareup.moshi.Json diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/AgeGroupApi.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/AgeGroupApi.kt similarity index 84% rename from app/src/main/java/foundation/e/apps/data/parentalcontrol/AgeGroupApi.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/AgeGroupApi.kt index 7ccc00550..86a976967 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/AgeGroupApi.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/AgeGroupApi.kt @@ -16,9 +16,8 @@ * */ -package foundation.e.apps.data.parentalcontrol +package foundation.e.apps.data.parentalcontrol.gplayrating -import foundation.e.apps.data.blockedApps.ContentRatingGroup import retrofit2.Response import retrofit2.http.GET @@ -29,6 +28,6 @@ interface AgeGroupApi { } @GET("content_ratings.json?ref_type=heads") - suspend fun getDefinedAgeGroups(): Response> + suspend fun getDefinedAgeGroups(): Response> } diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt new file mode 100644 index 000000000..8a0362cfb --- /dev/null +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt @@ -0,0 +1,28 @@ +/* + * 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 . + * + */ + +package foundation.e.apps.data.parentalcontrol.gplayrating + +import com.squareup.moshi.Json + +data class GooglePlayContentRatingGroup( + val id: String, + @Json(name = "age_group") + val ageGroup: String, + var ratings: List +) diff --git a/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingParser.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt similarity index 63% rename from app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingParser.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt index cde87e638..936675b79 100644 --- a/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingParser.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt @@ -1,23 +1,22 @@ /* - * Copyright MURENA SAS 2024 - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * 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. + * 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 . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * */ -package foundation.e.apps.data.blockedApps +package foundation.e.apps.data.parentalcontrol.gplayrating import com.google.gson.Gson import com.google.gson.JsonSyntaxException @@ -29,7 +28,7 @@ import java.io.IOException import javax.inject.Inject import javax.inject.Named -class ContentRatingParser @Inject constructor( +class GooglePlayContentRatingParser @Inject constructor( private val gson: Gson, @Named("cacheDir") private val cacheDir: String ) { @@ -38,7 +37,7 @@ class ContentRatingParser @Inject constructor( private const val CONTENT_RATINGS_FILE_NAME = "content_ratings.json" } - fun parseContentRatingData(): List { + fun parseContentRatingData(): List { return try { val outputPath = moveFile() val contentRatingJson = readJsonFromFile(outputPath) @@ -69,9 +68,9 @@ class ContentRatingParser @Inject constructor( return outputPath } - private fun parseJsonOfContentRatingGroup(contentRatingJson: String): List { - val contentRatingsListTypeGroup = object : TypeToken>() {}.type - val contentRatingGroups: List = + private fun parseJsonOfContentRatingGroup(contentRatingJson: String): List { + val contentRatingsListTypeGroup = object : TypeToken>() {}.type + val contentRatingGroups: List = gson.fromJson(contentRatingJson, contentRatingsListTypeGroup) return contentRatingGroups.map { @@ -82,7 +81,7 @@ class ContentRatingParser @Inject constructor( } } - private fun handleException(exception: Exception): List { + private fun handleException(exception: Exception): List { Timber.e(exception.localizedMessage ?: "", exception) return listOf() } diff --git a/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingsRepository.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt similarity index 71% rename from app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingsRepository.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt index b09fbb43c..2303104ee 100644 --- a/app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingsRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt @@ -16,30 +16,24 @@ * */ -package foundation.e.apps.data.blockedApps +package foundation.e.apps.data.parentalcontrol.gplayrating import com.aurora.gplayapi.data.models.ContentRating -import foundation.e.apps.data.parentalcontrol.AgeGroupApi -import foundation.e.apps.data.parentalcontrol.FDroidMonitorApi import foundation.e.apps.data.handleNetworkResult import foundation.e.apps.data.playstore.PlayStoreRepository import javax.inject.Inject import javax.inject.Singleton @Singleton -class ContentRatingsRepository @Inject constructor( +class GooglePlayContentRatingRepository @Inject constructor( private val ageGroupApi: AgeGroupApi, - private val fDroidMonitorApi: FDroidMonitorApi, private val playStoreRepository: PlayStoreRepository, ) { - private var _contentRatingGroups = listOf() - val contentRatingGroups: List + private var _contentRatingGroups = listOf() + val contentRatingGroups: List get() = _contentRatingGroups - var fDroidNSFWApps = listOf() - private set - suspend fun fetchContentRatingData() { val response = ageGroupApi.getDefinedAgeGroups() if (response.isSuccessful) { @@ -47,10 +41,6 @@ class ContentRatingsRepository @Inject constructor( } } - suspend fun fetchNSFWApps() { - fDroidNSFWApps = fDroidMonitorApi.getMonitorData().body()?.getNSFWApps() ?: emptyList() - } - suspend fun getEnglishContentRating(packageName: String): ContentRating? { return handleNetworkResult { playStoreRepository.getEnglishContentRating(packageName) diff --git a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt index f76699090..5f59d7047 100644 --- a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt @@ -29,9 +29,9 @@ import foundation.e.apps.data.cleanapk.CleanApkRetrofit 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.parentalcontrol.fdroid.FDroidMonitorApi +import foundation.e.apps.data.parentalcontrol.gplayrating.AgeGroupApi import foundation.e.apps.di.network.NetworkModule.getYamlFactory -import foundation.e.apps.data.parentalcontrol.AgeGroupApi -import foundation.e.apps.data.parentalcontrol.FDroidMonitorApi import okhttp3.OkHttpClient import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory diff --git a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt index f94648b50..33daff42e 100644 --- a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt +++ b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt @@ -20,18 +20,20 @@ package foundation.e.apps.domain import foundation.e.apps.data.ResultSupreme import foundation.e.apps.data.application.apps.AppsApi -import foundation.e.apps.data.blockedApps.Age -import foundation.e.apps.data.blockedApps.ContentRatingGroup -import foundation.e.apps.data.blockedApps.ContentRatingsRepository -import foundation.e.apps.data.blockedApps.ParentalControlRepository +import foundation.e.apps.data.parentalcontrol.Age +import foundation.e.apps.data.parentalcontrol.ParentalControlRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.Type import foundation.e.apps.data.install.models.AppInstall +import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository +import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingGroup +import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingRepository import timber.log.Timber import javax.inject.Inject class ValidateAppAgeLimitUseCase @Inject constructor( - private val contentRatingRepository: ContentRatingsRepository, + private val googlePlayContentRatingRepository: GooglePlayContentRatingRepository, + private val fDroidAntiFeatureRepository: FDroidAntiFeatureRepository, private val parentalControlRepository: ParentalControlRepository, private val appsApi: AppsApi, ) { @@ -73,7 +75,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( } private fun isKnownNsfwApp(app: AppInstall): Boolean { - return app.packageName in contentRatingRepository.fDroidNSFWApps + return app.packageName in fDroidAntiFeatureRepository.fDroidNsfwApps } private fun validateAgeLimit( @@ -81,7 +83,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( app: AppInstall ): ResultSupreme.Success { val allowedContentRating = - contentRatingRepository.contentRatingGroups.find { it.id == ageGroup.toString() } + googlePlayContentRatingRepository.contentRatingGroups.find { it.id == ageGroup.toString() } Timber.d( "Selected age group: $ageGroup \n" + @@ -97,7 +99,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( private fun isValidAppAgeRating( app: AppInstall, - allowedContentRating: ContentRatingGroup? + allowedContentRating: GooglePlayContentRatingGroup? ): Boolean { val allowedAgeRatings = allowedContentRating?.ratings?.map { it.lowercase() } ?: emptyList() return app.contentRating.id.isNotEmpty() && allowedAgeRatings.contains(app.contentRating.id) @@ -108,7 +110,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( private suspend fun verifyContentRatingExists(app: AppInstall): Boolean { if (app.contentRating.id.isEmpty()) { - contentRatingRepository.getEnglishContentRating(app.packageName)?.run { + googlePlayContentRatingRepository.getEnglishContentRating(app.packageName)?.run { Timber.d("Updating content rating for package: ${app.packageName}") app.contentRating = this } diff --git a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt index 2c3531016..a6317c6bb 100644 --- a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt +++ b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt @@ -1,19 +1,18 @@ /* - * Copyright MURENA SAS 2024 - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * 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. + * 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 . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * */ @@ -23,7 +22,6 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.ContentProvider import android.content.ContentValues -import android.content.Context import android.content.UriMatcher import android.database.Cursor import android.database.MatrixCursor @@ -41,10 +39,11 @@ import foundation.e.apps.contract.ParentalControlContract.COLUMN_PACKAGE_NAME import foundation.e.apps.contract.ParentalControlContract.PATH_BLOCKLIST import foundation.e.apps.contract.ParentalControlContract.PATH_LOGIN_TYPE import foundation.e.apps.contract.ParentalControlContract.getAppLoungeProviderAuthority -import foundation.e.apps.data.blockedApps.ContentRatingsRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthenticatorRepository +import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository +import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingRepository import foundation.e.apps.data.preference.DataStoreManager import foundation.e.apps.domain.ValidateAppAgeLimitUseCase import foundation.e.apps.install.pkg.AppLoungePackageManager @@ -54,7 +53,6 @@ import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import timber.log.Timber -import javax.inject.Inject class AgeRatingProvider : ContentProvider() { @@ -63,7 +61,8 @@ class AgeRatingProvider : ContentProvider() { interface ContentProviderEntryPoint { fun provideAuthenticationRepository(): AuthenticatorRepository fun providePackageManager(): AppLoungePackageManager - fun provideContentRatingsRepository(): ContentRatingsRepository + fun provideGooglePlayContentRatingsRepository(): GooglePlayContentRatingRepository + fun provideFDroidAntiFeatureRepository(): FDroidAntiFeatureRepository fun provideValidateAppAgeLimitUseCase(): ValidateAppAgeLimitUseCase fun provideDataStoreManager(): DataStoreManager @@ -77,7 +76,8 @@ class AgeRatingProvider : ContentProvider() { private lateinit var authenticatorRepository: AuthenticatorRepository private lateinit var appLoungePackageManager: AppLoungePackageManager - private lateinit var contentRatingsRepository: ContentRatingsRepository + private lateinit var googlePlayContentRatingRepository: GooglePlayContentRatingRepository + private lateinit var fDroidAntiFeatureRepository: FDroidAntiFeatureRepository private lateinit var validateAppAgeLimitUseCase: ValidateAppAgeLimitUseCase private lateinit var dataStoreManager: DataStoreManager private lateinit var notificationManager: NotificationManager @@ -173,13 +173,13 @@ class AgeRatingProvider : ContentProvider() { private suspend fun ensureAgeGroupDataExists() { withContext(IO) { val deferredFetchRatings = async { - if (contentRatingsRepository.contentRatingGroups.isEmpty()) { - contentRatingsRepository.fetchContentRatingData() + if (googlePlayContentRatingRepository.contentRatingGroups.isEmpty()) { + googlePlayContentRatingRepository.fetchContentRatingData() } } val deferredFetchNSFW = async { - if (contentRatingsRepository.fDroidNSFWApps.isEmpty()) { - contentRatingsRepository.fetchNSFWApps() + if (fDroidAntiFeatureRepository.fDroidNsfwApps.isEmpty()) { + fDroidAntiFeatureRepository.fetchNsfwApps() } } listOf(deferredFetchRatings, deferredFetchNSFW).awaitAll() @@ -252,7 +252,9 @@ class AgeRatingProvider : ContentProvider() { authenticatorRepository = hiltEntryPoint.provideAuthenticationRepository() appLoungePackageManager = hiltEntryPoint.providePackageManager() - contentRatingsRepository = hiltEntryPoint.provideContentRatingsRepository() + googlePlayContentRatingRepository = + hiltEntryPoint.provideGooglePlayContentRatingsRepository() + fDroidAntiFeatureRepository = hiltEntryPoint.provideFDroidAntiFeatureRepository() validateAppAgeLimitUseCase = hiltEntryPoint.provideValidateAppAgeLimitUseCase() dataStoreManager = hiltEntryPoint.provideDataStoreManager() notificationManager = hiltEntryPoint.provideNotificationManager() diff --git a/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt index 18a1671a9..0130be13f 100644 --- a/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt @@ -35,13 +35,14 @@ import foundation.e.apps.R import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.blockedApps.BlockedAppRepository -import foundation.e.apps.data.blockedApps.ContentRatingsRepository import foundation.e.apps.data.ecloud.EcloudRepository import foundation.e.apps.data.enums.User import foundation.e.apps.data.enums.isInitialized import foundation.e.apps.data.enums.isUnFiltered import foundation.e.apps.data.install.AppManagerWrapper import foundation.e.apps.data.install.models.AppInstall +import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository +import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingRepository import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.data.preference.getSync import foundation.e.apps.install.pkg.AppLoungePackageManager @@ -60,7 +61,8 @@ class MainActivityViewModel @Inject constructor( private val pwaManager: PWAManager, private val ecloudRepository: EcloudRepository, private val blockedAppRepository: BlockedAppRepository, - private val contentRatingsRepository: ContentRatingsRepository, + private val googlePlayContentRatingRepository: GooglePlayContentRatingRepository, + private val fDroidAntiFeatureRepository: FDroidAntiFeatureRepository, private val appInstallProcessor: AppInstallProcessor, ) : ViewModel() { @@ -240,8 +242,8 @@ class MainActivityViewModel @Inject constructor( fun updateContentRatings() { viewModelScope.launch { - contentRatingsRepository.fetchNSFWApps() - contentRatingsRepository.fetchContentRatingData() + fDroidAntiFeatureRepository.fetchNsfwApps() + googlePlayContentRatingRepository.fetchContentRatingData() } } diff --git a/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt b/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt index 35aecadfd..e9a0980ae 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/ApplicationViewModel.kt @@ -28,7 +28,6 @@ import foundation.e.apps.R import foundation.e.apps.data.application.ApplicationRepository import foundation.e.apps.data.application.data.Application import foundation.e.apps.data.application.data.shareUri -import foundation.e.apps.data.blockedApps.ContentRatingsRepository import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.ResultStatus import foundation.e.apps.data.enums.Status @@ -37,6 +36,7 @@ import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthObject import foundation.e.apps.data.login.exceptions.CleanApkException import foundation.e.apps.data.login.exceptions.GPlayException +import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository import foundation.e.apps.data.playstore.PlayStoreRepository import foundation.e.apps.install.download.data.DownloadProgress import foundation.e.apps.install.download.data.DownloadProgressLD @@ -56,7 +56,7 @@ class ApplicationViewModel @Inject constructor( private val applicationRepository: ApplicationRepository, private val playStoreRepository: PlayStoreRepository, private val appManagerWrapper: AppManagerWrapper, - private val contentRatingsRepository: ContentRatingsRepository, + private val fDroidAntiFeatureRepository: FDroidAntiFeatureRepository, ) : LoadingViewModel() { val applicationLiveData: MutableLiveData> = MutableLiveData() @@ -239,7 +239,7 @@ class ApplicationViewModel @Inject constructor( fun isOpenSourceSelected() = applicationRepository.isOpenSourceSelected() fun isKnownNsfwApp(app: Application): Boolean { - return app.package_name in contentRatingsRepository.fDroidNSFWApps + return app.package_name in fDroidAntiFeatureRepository.fDroidNsfwApps } } -- GitLab From 0c10d0186912fb73d1fbfc65d0a7ad06e1975173 Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Wed, 26 Jun 2024 18:15:14 +0600 Subject: [PATCH 2/3] refactor: rename getNSFWApps to getNsfwApps for consistency --- .../data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt | 2 +- .../e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt index 426cdb961..5043d8acc 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidAntiFeatureRepository.kt @@ -31,6 +31,6 @@ constructor( private set suspend fun fetchNsfwApps() { - fDroidNsfwApps = fDroidMonitorApi.getMonitorData().body()?.getNSFWApps() ?: emptyList() + fDroidNsfwApps = fDroidMonitorApi.getMonitorData().body()?.getNsfwApps() ?: emptyList() } } diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt index c17c2ce58..3225a6417 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/fdroid/FDroidMonitorData.kt @@ -23,7 +23,7 @@ import com.squareup.moshi.Json data class FDroidMonitorData( val antiFeatures: AntiFeatures ) { - fun getNSFWApps() = antiFeatures.nsfw.apps + fun getNsfwApps() = antiFeatures.nsfw.apps } data class AntiFeatures( -- GitLab From b804db373cd05ddd93ece124f823f3d350f1897a Mon Sep 17 00:00:00 2001 From: Fahim Masud Choudhury Date: Thu, 27 Jun 2024 10:40:16 +0600 Subject: [PATCH 3/3] refactor: rename GooglePlayContentRating to GPlayContentRating Renamed all instances of GooglePlayContentRating to GPlayContentRating for better readability and consistency. Removed GooglePlayContentRatingParser.kt as it's not needed anymore. --- .../AgeGroupApi.kt | 4 +- .../GPlayContentRatingGroup.kt} | 4 +- .../GPlayContentRatingRepository.kt} | 8 +- .../GooglePlayContentRatingParser.kt | 88 ------------------- .../e/apps/di/network/RetrofitApiModule.kt | 2 +- .../apps/domain/ValidateAppAgeLimitUseCase.kt | 12 +-- .../e/apps/provider/AgeRatingProvider.kt | 14 ++- .../e/apps/ui/MainActivityViewModel.kt | 6 +- 8 files changed, 24 insertions(+), 114 deletions(-) rename app/src/main/java/foundation/e/apps/data/parentalcontrol/{gplayrating => googleplay}/AgeGroupApi.kt (87%) rename app/src/main/java/foundation/e/apps/data/parentalcontrol/{gplayrating/GooglePlayContentRatingGroup.kt => googleplay/GPlayContentRatingGroup.kt} (89%) rename app/src/main/java/foundation/e/apps/data/parentalcontrol/{gplayrating/GooglePlayContentRatingRepository.kt => googleplay/GPlayContentRatingRepository.kt} (85%) delete mode 100644 app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/AgeGroupApi.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/AgeGroupApi.kt similarity index 87% rename from app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/AgeGroupApi.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/AgeGroupApi.kt index 86a976967..80a40e317 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/AgeGroupApi.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/AgeGroupApi.kt @@ -16,7 +16,7 @@ * */ -package foundation.e.apps.data.parentalcontrol.gplayrating +package foundation.e.apps.data.parentalcontrol.googleplay import retrofit2.Response import retrofit2.http.GET @@ -28,6 +28,6 @@ interface AgeGroupApi { } @GET("content_ratings.json?ref_type=heads") - suspend fun getDefinedAgeGroups(): Response> + suspend fun getDefinedAgeGroups(): Response> } diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/GPlayContentRatingGroup.kt similarity index 89% rename from app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/GPlayContentRatingGroup.kt index 8a0362cfb..708e1f278 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingGroup.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/GPlayContentRatingGroup.kt @@ -16,11 +16,11 @@ * */ -package foundation.e.apps.data.parentalcontrol.gplayrating +package foundation.e.apps.data.parentalcontrol.googleplay import com.squareup.moshi.Json -data class GooglePlayContentRatingGroup( +data class GPlayContentRatingGroup( val id: String, @Json(name = "age_group") val ageGroup: String, diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/GPlayContentRatingRepository.kt similarity index 85% rename from app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt rename to app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/GPlayContentRatingRepository.kt index 2303104ee..28d03c09d 100644 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/parentalcontrol/googleplay/GPlayContentRatingRepository.kt @@ -16,7 +16,7 @@ * */ -package foundation.e.apps.data.parentalcontrol.gplayrating +package foundation.e.apps.data.parentalcontrol.googleplay import com.aurora.gplayapi.data.models.ContentRating import foundation.e.apps.data.handleNetworkResult @@ -25,13 +25,13 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class GooglePlayContentRatingRepository @Inject constructor( +class GPlayContentRatingRepository @Inject constructor( private val ageGroupApi: AgeGroupApi, private val playStoreRepository: PlayStoreRepository, ) { - private var _contentRatingGroups = listOf() - val contentRatingGroups: List + private var _contentRatingGroups = listOf() + val contentRatingGroups: List get() = _contentRatingGroups suspend fun fetchContentRatingData() { diff --git a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt b/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt deleted file mode 100644 index 936675b79..000000000 --- a/app/src/main/java/foundation/e/apps/data/parentalcontrol/gplayrating/GooglePlayContentRatingParser.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 . - * - */ - -package foundation.e.apps.data.parentalcontrol.gplayrating - -import com.google.gson.Gson -import com.google.gson.JsonSyntaxException -import com.google.gson.reflect.TypeToken -import foundation.e.apps.data.install.FileManager -import timber.log.Timber -import java.io.File -import java.io.IOException -import javax.inject.Inject -import javax.inject.Named - -class GooglePlayContentRatingParser @Inject constructor( - private val gson: Gson, - @Named("cacheDir") private val cacheDir: String -) { - - companion object { - private const val CONTENT_RATINGS_FILE_NAME = "content_ratings.json" - } - - fun parseContentRatingData(): List { - return try { - val outputPath = moveFile() - val contentRatingJson = readJsonFromFile(outputPath) - Timber.d("ContentRatings file contents: $contentRatingJson") - parseJsonOfContentRatingGroup(contentRatingJson) - } catch (exception: IOException) { - handleException(exception) - } catch (exception: JsonSyntaxException) { - handleException(exception) - } - } - - private fun readJsonFromFile(outputPath: String): String { - val downloadedFile = - File(outputPath + CONTENT_RATINGS_FILE_NAME) - val contentRatingJson = String(downloadedFile.inputStream().readBytes()) - - return contentRatingJson - } - - private fun moveFile(): String { - val outputPath = "$cacheDir/content_ratings/" - FileManager.moveFile( - "$cacheDir/", - CONTENT_RATINGS_FILE_NAME, outputPath - ) - - return outputPath - } - - private fun parseJsonOfContentRatingGroup(contentRatingJson: String): List { - val contentRatingsListTypeGroup = object : TypeToken>() {}.type - val contentRatingGroups: List = - gson.fromJson(contentRatingJson, contentRatingsListTypeGroup) - - return contentRatingGroups.map { - it.ratings = it.ratings.map { rating -> - rating.lowercase() - } - it - } - } - - private fun handleException(exception: Exception): List { - Timber.e(exception.localizedMessage ?: "", exception) - return listOf() - } -} diff --git a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt index 5f59d7047..576302cc9 100644 --- a/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt +++ b/app/src/main/java/foundation/e/apps/di/network/RetrofitApiModule.kt @@ -30,7 +30,7 @@ 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.parentalcontrol.fdroid.FDroidMonitorApi -import foundation.e.apps.data.parentalcontrol.gplayrating.AgeGroupApi +import foundation.e.apps.data.parentalcontrol.googleplay.AgeGroupApi import foundation.e.apps.di.network.NetworkModule.getYamlFactory import okhttp3.OkHttpClient import retrofit2.Retrofit diff --git a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt index 33daff42e..05cbe5c93 100644 --- a/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt +++ b/app/src/main/java/foundation/e/apps/domain/ValidateAppAgeLimitUseCase.kt @@ -26,13 +26,13 @@ import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.enums.Type import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository -import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingGroup -import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingRepository +import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingGroup +import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingRepository import timber.log.Timber import javax.inject.Inject class ValidateAppAgeLimitUseCase @Inject constructor( - private val googlePlayContentRatingRepository: GooglePlayContentRatingRepository, + private val gPlayContentRatingRepository: GPlayContentRatingRepository, private val fDroidAntiFeatureRepository: FDroidAntiFeatureRepository, private val parentalControlRepository: ParentalControlRepository, private val appsApi: AppsApi, @@ -83,7 +83,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( app: AppInstall ): ResultSupreme.Success { val allowedContentRating = - googlePlayContentRatingRepository.contentRatingGroups.find { it.id == ageGroup.toString() } + gPlayContentRatingRepository.contentRatingGroups.find { it.id == ageGroup.toString() } Timber.d( "Selected age group: $ageGroup \n" + @@ -99,7 +99,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( private fun isValidAppAgeRating( app: AppInstall, - allowedContentRating: GooglePlayContentRatingGroup? + allowedContentRating: GPlayContentRatingGroup? ): Boolean { val allowedAgeRatings = allowedContentRating?.ratings?.map { it.lowercase() } ?: emptyList() return app.contentRating.id.isNotEmpty() && allowedAgeRatings.contains(app.contentRating.id) @@ -110,7 +110,7 @@ class ValidateAppAgeLimitUseCase @Inject constructor( private suspend fun verifyContentRatingExists(app: AppInstall): Boolean { if (app.contentRating.id.isEmpty()) { - googlePlayContentRatingRepository.getEnglishContentRating(app.packageName)?.run { + gPlayContentRatingRepository.getEnglishContentRating(app.packageName)?.run { Timber.d("Updating content rating for package: ${app.packageName}") app.contentRating = this } diff --git a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt index a6317c6bb..86fdf8c15 100644 --- a/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt +++ b/app/src/main/java/foundation/e/apps/provider/AgeRatingProvider.kt @@ -43,7 +43,7 @@ import foundation.e.apps.data.enums.Origin import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.login.AuthenticatorRepository import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository -import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingRepository +import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingRepository import foundation.e.apps.data.preference.DataStoreManager import foundation.e.apps.domain.ValidateAppAgeLimitUseCase import foundation.e.apps.install.pkg.AppLoungePackageManager @@ -61,11 +61,10 @@ class AgeRatingProvider : ContentProvider() { interface ContentProviderEntryPoint { fun provideAuthenticationRepository(): AuthenticatorRepository fun providePackageManager(): AppLoungePackageManager - fun provideGooglePlayContentRatingsRepository(): GooglePlayContentRatingRepository + fun provideGPlayContentRatingsRepository(): GPlayContentRatingRepository fun provideFDroidAntiFeatureRepository(): FDroidAntiFeatureRepository fun provideValidateAppAgeLimitUseCase(): ValidateAppAgeLimitUseCase fun provideDataStoreManager(): DataStoreManager - fun provideNotificationManager(): NotificationManager } @@ -76,7 +75,7 @@ class AgeRatingProvider : ContentProvider() { private lateinit var authenticatorRepository: AuthenticatorRepository private lateinit var appLoungePackageManager: AppLoungePackageManager - private lateinit var googlePlayContentRatingRepository: GooglePlayContentRatingRepository + private lateinit var gPlayContentRatingRepository: GPlayContentRatingRepository private lateinit var fDroidAntiFeatureRepository: FDroidAntiFeatureRepository private lateinit var validateAppAgeLimitUseCase: ValidateAppAgeLimitUseCase private lateinit var dataStoreManager: DataStoreManager @@ -173,8 +172,8 @@ class AgeRatingProvider : ContentProvider() { private suspend fun ensureAgeGroupDataExists() { withContext(IO) { val deferredFetchRatings = async { - if (googlePlayContentRatingRepository.contentRatingGroups.isEmpty()) { - googlePlayContentRatingRepository.fetchContentRatingData() + if (gPlayContentRatingRepository.contentRatingGroups.isEmpty()) { + gPlayContentRatingRepository.fetchContentRatingData() } } val deferredFetchNSFW = async { @@ -252,8 +251,7 @@ class AgeRatingProvider : ContentProvider() { authenticatorRepository = hiltEntryPoint.provideAuthenticationRepository() appLoungePackageManager = hiltEntryPoint.providePackageManager() - googlePlayContentRatingRepository = - hiltEntryPoint.provideGooglePlayContentRatingsRepository() + gPlayContentRatingRepository = hiltEntryPoint.provideGPlayContentRatingsRepository() fDroidAntiFeatureRepository = hiltEntryPoint.provideFDroidAntiFeatureRepository() validateAppAgeLimitUseCase = hiltEntryPoint.provideValidateAppAgeLimitUseCase() dataStoreManager = hiltEntryPoint.provideDataStoreManager() diff --git a/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt b/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt index 0130be13f..474308fee 100644 --- a/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/MainActivityViewModel.kt @@ -42,7 +42,7 @@ import foundation.e.apps.data.enums.isUnFiltered import foundation.e.apps.data.install.AppManagerWrapper import foundation.e.apps.data.install.models.AppInstall import foundation.e.apps.data.parentalcontrol.fdroid.FDroidAntiFeatureRepository -import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingRepository +import foundation.e.apps.data.parentalcontrol.googleplay.GPlayContentRatingRepository import foundation.e.apps.data.preference.AppLoungeDataStore import foundation.e.apps.data.preference.getSync import foundation.e.apps.install.pkg.AppLoungePackageManager @@ -61,7 +61,7 @@ class MainActivityViewModel @Inject constructor( private val pwaManager: PWAManager, private val ecloudRepository: EcloudRepository, private val blockedAppRepository: BlockedAppRepository, - private val googlePlayContentRatingRepository: GooglePlayContentRatingRepository, + private val gPlayContentRatingRepository: GPlayContentRatingRepository, private val fDroidAntiFeatureRepository: FDroidAntiFeatureRepository, private val appInstallProcessor: AppInstallProcessor, ) : ViewModel() { @@ -243,7 +243,7 @@ class MainActivityViewModel @Inject constructor( fun updateContentRatings() { viewModelScope.launch { fDroidAntiFeatureRepository.fetchNsfwApps() - googlePlayContentRatingRepository.fetchContentRatingData() + gPlayContentRatingRepository.fetchContentRatingData() } } -- GitLab