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

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

refactor: merge more changes from 2203-paco

parent f826d103
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -120,7 +120,7 @@ data class Application(
    }
    }
}
}


private fun isFDroid(type: Type, origin: Origin) =
internal fun isFDroid(type: Type, origin: Origin) =
    (type == NATIVE && origin == Origin.CLEANAPK)
    (type == NATIVE && origin == Origin.CLEANAPK)


private fun buildFDroidUri(packageName: String): Uri {
private fun buildFDroidUri(packageName: String): Uri {
+4 −0
Original line number Original line Diff line number Diff line
@@ -49,4 +49,8 @@ interface PlayStoreRepository : StoreRepository {
        appPackage: String,
        appPackage: String,
        contentRating: ContentRating
        contentRating: ContentRating
    ): ContentRating
    ): ContentRating

    suspend fun getEnglishContentRating(
        appPackage: String,
    ): ContentRating
}
}
+0 −47
Original line number Original line Diff line number Diff line
/*
 *  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 <https://www.gnu.org/licenses/>.
 *
 */

package foundation.e.apps.di

import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import foundation.e.apps.data.ageRating.AgeGroupApi
import javax.inject.Singleton
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory

@Module
@InstallIn(SingletonComponent::class)
object AgeRatingModule {

    @Singleton
    @Provides
    fun provideAgeGroupApi(okHttpClient: OkHttpClient, moshi: Moshi): AgeGroupApi {
        return Retrofit.Builder()
            .baseUrl(AgeGroupApi.BASE_URL)
            .client(okHttpClient)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build()
            .create(AgeGroupApi::class.java)
    }
}
+11 −13
Original line number Original line Diff line number Diff line
@@ -34,16 +34,14 @@ import foundation.e.apps.contract.ParentalControlContract.COLUMN_PACKAGE_NAME
import foundation.e.apps.contract.ParentalControlContract.PATH_BLOCKLIST
import foundation.e.apps.contract.ParentalControlContract.PATH_BLOCKLIST
import foundation.e.apps.contract.ParentalControlContract.PATH_LOGIN_TYPE
import foundation.e.apps.contract.ParentalControlContract.PATH_LOGIN_TYPE
import foundation.e.apps.contract.ParentalControlContract.getAppLoungeProviderAuthority
import foundation.e.apps.contract.ParentalControlContract.getAppLoungeProviderAuthority
import foundation.e.apps.data.blockedApps.ContentRatingsRepository
import foundation.e.apps.data.application.ApplicationRepository
import foundation.e.apps.data.enums.Origin
import foundation.e.apps.data.enums.Origin
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.login.AuthenticatorRepository
import foundation.e.apps.data.login.AuthenticatorRepository
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Allowed
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Allowed
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Denied
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.Denied
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.DeniedOnDataLoadError
import foundation.e.apps.data.parentalcontrol.AppInstallationPermissionState.DeniedOnDataLoadError
import foundation.e.apps.data.parentalcontrol.gplayrating.GooglePlayContentRatingsRepository
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.data.preference.DataStoreManager
import foundation.e.apps.domain.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.domain.parentalcontrol.GetAppInstallationPermissionUseCase
import foundation.e.apps.install.pkg.AppLoungePackageManager
import foundation.e.apps.install.pkg.AppLoungePackageManager
@@ -62,7 +60,7 @@ class AgeRatingProvider : ContentProvider() {
        fun provideAuthenticationRepository(): AuthenticatorRepository
        fun provideAuthenticationRepository(): AuthenticatorRepository
        fun providePackageManager(): AppLoungePackageManager
        fun providePackageManager(): AppLoungePackageManager
        fun provideContentRatingsRepository(): GooglePlayContentRatingsRepository
        fun provideContentRatingsRepository(): GooglePlayContentRatingsRepository
        fun provideValidateAppAgeLimitUseCase(): GetAppInstallationPermissionUseCase
        fun provideGetAppInstallationPermissionUseCase(): GetAppInstallationPermissionUseCase
        fun provideDataStoreManager(): DataStoreManager
        fun provideDataStoreManager(): DataStoreManager
    }
    }


@@ -147,13 +145,13 @@ class AgeRatingProvider : ContentProvider() {
        return false
        return false
    }
    }


    private suspend fun getAppAgeValidity(packageName: String): Boolean {
    private suspend fun getAppAgeValidity(packageName: String): AppInstallationPermissionState {
        val fakeAppInstall = AppInstall(
        val fakeAppInstall = AppInstall(
            packageName = packageName,
            packageName = packageName,
            origin = Origin.GPLAY
            origin = Origin.GPLAY
        )
        )
        val validateResult = validateAppAgeLimitUseCase(fakeAppInstall)
        val appInstallationPermissionState = getAppInstallationPermissionUseCase(fakeAppInstall)
        return validateResult.data ?: false
        return appInstallationPermissionState
    }
    }


    private suspend fun compileAppBlockList(
    private suspend fun compileAppBlockList(
@@ -162,15 +160,14 @@ class AgeRatingProvider : ContentProvider() {
    ) {
    ) {
        withContext(IO) {
        withContext(IO) {
            val validityList = packageNames.map { packageName ->
            val validityList = packageNames.map { packageName ->
                async {
                async { getAppAgeValidity(packageName) }
                    getAppAgeValidity(packageName)
                }
            }.awaitAll()
            }.awaitAll()
            validityList.forEachIndexed { index: Int, permission ->

            validityList.forEachIndexed { index: Int, permission: AppInstallationPermissionState ->
                when (permission) {
                when (permission) {
                    is Denied, DeniedOnDataLoadError -> {
                    is Denied, DeniedOnDataLoadError -> {
                        // Collect package names for blocklist
                        // Collect package names for blocklist
                        cursor.addRow(arrayOf(packagesNames[index]))
                        cursor.addRow(arrayOf(packageNames[index]))
                    }
                    }


                    Allowed -> {
                    Allowed -> {
@@ -191,7 +188,8 @@ class AgeRatingProvider : ContentProvider() {
        authenticatorRepository = hiltEntryPoint.provideAuthenticationRepository()
        authenticatorRepository = hiltEntryPoint.provideAuthenticationRepository()
        appLoungePackageManager = hiltEntryPoint.providePackageManager()
        appLoungePackageManager = hiltEntryPoint.providePackageManager()
        contentRatingsRepository = hiltEntryPoint.provideContentRatingsRepository()
        contentRatingsRepository = hiltEntryPoint.provideContentRatingsRepository()
        getAppInstallationPermissionUseCase = hiltEntryPoint.getValidateAppAgeLimitUseCase()
        getAppInstallationPermissionUseCase =
            hiltEntryPoint.provideGetAppInstallationPermissionUseCase()
        dataStoreManager = hiltEntryPoint.provideDataStoreManager()
        dataStoreManager = hiltEntryPoint.provideDataStoreManager()


        return true
        return true
+1 −1
Original line number Original line Diff line number Diff line
@@ -125,7 +125,7 @@
    <string name="troubleshootURL" translatable="false">https://doc.e.foundation/support-topics/app_lounge_troubleshooting</string>
    <string name="troubleshootURL" translatable="false">https://doc.e.foundation/support-topics/app_lounge_troubleshooting</string>
    <string name="share">Share</string>
    <string name="share">Share</string>
    <string name="restricted_app">[%1$s] Restricted App</string>
    <string name="restricted_app">[%1$s] Restricted App</string>
    <string name="age_rate_limit_message">You are too young to be able to install %1$s. Please check with your parent your age group is correct or disable Parental Control to be able to install it.</string>
    <string name="age_rate_limit_message">You are too young to be able to install %1$s. Please check with your parent your age group is correct or disable parental control to be able to install it.</string>


    <string name="message_inappropriate_content">This app may contain inappropriate content.</string>
    <string name="message_inappropriate_content">This app may contain inappropriate content.</string>


Loading