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

Commit 98e3ab9f authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury Committed by Hasib Prince
Browse files

Issue 2203: Blocklist for NSFW apps

parent 59a44b81
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -372,9 +372,11 @@ class MainActivity : AppCompatActivity() {
    }

    private fun broadcastGPlayLogin() {
        val user = viewModel.getUser().name
        Timber.d("Sending broadcast with login type - $user")
        val intent = Intent(Constants.ACTION_PARENTAL_CONTROL_APP_LOUNGE_LOGIN).apply {
            setPackage(BuildConfig.PACKAGE_NAME_PARENTAL_CONTROL)
            putExtra(COLUMN_LOGIN_TYPE, viewModel.getUser().name)
            putExtra(COLUMN_LOGIN_TYPE, user)
        }
        sendBroadcast(intent)
    }
+34 −0
Original line number 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.data.ageRating

import retrofit2.Response
import retrofit2.http.GET

interface FDroidMonitorApi {

    companion object {
        const val BASE_URL = "https://f-droid.org/repo/"
    }

    @GET("status/update.json")
    suspend fun getMonitorData(): Response<FDroidMonitorData>

}
+36 −0
Original line number 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.data.ageRating

import com.squareup.moshi.Json

data class FDroidMonitorData(
    val antiFeatures: AntiFeatures
) {
    fun getNSFWApps() = antiFeatures.nsfw.apps
}

data class AntiFeatures(
    @Json(name = "NSFW") val nsfw: NSFW
)

data class NSFW(
    val apps: List<String>
)
+3 −1
Original line number Diff line number Diff line
@@ -102,7 +102,9 @@ data class Application(
    var isGplayReplaced: Boolean = false,
    @SerializedName(value = "on_fdroid")
    val isFDroidApp: Boolean = false,
    var contentRating: ContentRating = ContentRating()
    var contentRating: ContentRating = ContentRating(),
    @SerializedName(value = "antifeatures")
    val antiFeatures: List<Map<String, String>> = emptyList(),
) {
    fun updateType() {
        this.type = if (this.is_pwa) PWA else NATIVE
+9 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ package foundation.e.apps.data.blockedApps
import com.aurora.gplayapi.data.models.ContentRating
import com.aurora.gplayapi.helpers.ContentRatingHelper
import foundation.e.apps.data.ageRating.AgeGroupApi
import foundation.e.apps.data.ageRating.FDroidMonitorApi
import foundation.e.apps.data.handleNetworkResult
import foundation.e.apps.data.login.AuthenticatorRepository
import javax.inject.Inject
@@ -30,6 +31,7 @@ import javax.inject.Singleton
@Singleton
class ContentRatingsRepository @Inject constructor(
    private val ageGroupApi: AgeGroupApi,
    private val fDroidMonitorApi: FDroidMonitorApi,
    private val authenticatorRepository: AuthenticatorRepository,
) {

@@ -37,6 +39,9 @@ class ContentRatingsRepository @Inject constructor(
    val contentRatingGroups: List<ContentRatingGroup>
        get() = _contentRatingGroups

    var fDroidNSFWApps = listOf<String>()
        private set

    suspend fun fetchContentRatingData() {
        val response = ageGroupApi.getDefinedAgeGroups()
        if (response.isSuccessful) {
@@ -44,6 +49,10 @@ class ContentRatingsRepository @Inject constructor(
        }
    }

    suspend fun fetchNSFWApps() {
        fDroidNSFWApps = fDroidMonitorApi.getMonitorData().body()?.getNSFWApps() ?: emptyList()
    }

    suspend fun getEnglishContentRating(packageName: String): ContentRating? {
        val authData = authenticatorRepository.gplayAuth ?: return null
        val contentRatingHelper = ContentRatingHelper(authData)
Loading