Loading app/src/main/java/foundation/e/apps/MainActivity.kt +17 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ class MainActivity : AppCompatActivity() { } viewModel.updateAppWarningList() viewModel.updateContentRatings() observeEvents() } Loading Loading @@ -204,6 +205,22 @@ class MainActivity : AppCompatActivity() { launch { observeNoInternetEvent() } launch { EventBus.events.filter { it is AppEvent.AgeRateLimit }.collectLatest { ApplicationDialogFragment( getString(R.string.unknown_error), getString(R.string.age_rate_limit_message), positiveButtonText = getString(R.string.ok), positiveButtonAction = { findNavController(binding.fragment.id).popBackStack() } ).show(supportFragmentManager, TAG) } } } } } Loading app/src/main/java/foundation/e/apps/data/ParentalControlRepository.kt 0 → 100644 +77 −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 class ParentalControlRepository { fun isParentalControlEnabled(): Boolean { return true } fun getAllowedContentRatings(): List<String> { return listOf( "PEGI 3", "EVERYONE", "All ages", "General", "All ages", "For all", "PEGI 3", "Parental Guidance Recommended", // "EVERYONE", // "All ages", // "General", // "All ages", // "For all", // "Rated for 3+", // "PEGI 3", // "PEGI 7", // "Parental Guidance Recommended", // "EVERYONE", // "All ages", // "USK: Ages 6 and above", // "General", // "All ages", // "For all", // "Rated for 3+", // "Rated for 7+", // "PEGI 3", // "PEGI 7", // "PEGI 12", // "Parental Guidance Recommended", // "EVERYONE", // "EVERYONE 10+", // "TEEN", // "All ages", // "USK: Ages 6 and above", // "USK: Ages 12 and above", // "General", // "Parental Guidance", // "All ages", // "Rated 10+", // "Rated 12+", // "For all", // "Rated 12+", // "Rated for 3+", // "Rated for 7+", // "Rated for 12+" ) } } No newline at end of file app/src/main/java/foundation/e/apps/data/blockedApps/ContentRating.kt 0 → 100644 +29 −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.blockedApps import com.google.gson.annotations.SerializedName data class ContentRating( val id: String, @SerializedName("age_group") val ageGroup: String, val ratings: List<String> ) app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingsRepository.kt 0 → 100644 +77 −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.blockedApps import com.google.gson.Gson import com.google.gson.reflect.TypeToken import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.fusedDownload.FileManager import timber.log.Timber import java.io.File import javax.inject.Inject import javax.inject.Named import javax.inject.Singleton @Singleton class ContentRatingsRepository @Inject constructor( private val downloadManager: DownloadManager, private val gson: Gson, @Named("cacheDir") private val cacheDir: String ) { private var _contentRatings = listOf<ContentRating>() val contentRatingsList: List<ContentRating> get() = _contentRatings companion object { private const val CONTENT_RATINGS_FILE_URL = "https://gitlab.e.foundation/e/os/app-lounge-content-ratings/-/raw/main/content_ratings.json?ref_type=heads&inline=false" private const val CONTENT_RATINGS_FILE_NAME = "content_ratings.json" } fun fetchContentRatingData() { downloadManager.downloadFileInCache( CONTENT_RATINGS_FILE_URL, fileName = CONTENT_RATINGS_FILE_NAME ) { success, _ -> if (success) { parseContentRatingData() } } } private fun parseContentRatingData() { _contentRatings = try { val outputPath = "$cacheDir/warning_list/" FileManager.moveFile("$cacheDir/", CONTENT_RATINGS_FILE_NAME, outputPath) val downloadedFile = File(outputPath + CONTENT_RATINGS_FILE_NAME) Timber.d("Blocked list file exists: ${downloadedFile.exists()}") val blockedAppInfoJson = String(downloadedFile.inputStream().readBytes()) Timber.d("Blocked list file contents: $blockedAppInfoJson") val contentRatingsListType = object : TypeToken<List<ContentRating>>() {}.type gson.fromJson(blockedAppInfoJson, contentRatingsListType) } catch (exception: Exception) { Timber.e(exception.localizedMessage ?: "", exception) mutableListOf() } } } No newline at end of file app/src/main/java/foundation/e/apps/data/fusedDownload/models/FusedDownload.kt +4 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package foundation.e.apps.data.fusedDownload.models import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey import com.aurora.gplayapi.data.models.ContentRating import com.aurora.gplayapi.data.models.File import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.enums.Origin Loading Loading @@ -36,6 +37,9 @@ data class FusedDownload( Status.INSTALLING ) @Ignore var contentRating: ContentRating? = null fun isAppInstalling() = installingStatusList.contains(status) fun isAwaiting() = status == Status.AWAITING Loading Loading
app/src/main/java/foundation/e/apps/MainActivity.kt +17 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ class MainActivity : AppCompatActivity() { } viewModel.updateAppWarningList() viewModel.updateContentRatings() observeEvents() } Loading Loading @@ -204,6 +205,22 @@ class MainActivity : AppCompatActivity() { launch { observeNoInternetEvent() } launch { EventBus.events.filter { it is AppEvent.AgeRateLimit }.collectLatest { ApplicationDialogFragment( getString(R.string.unknown_error), getString(R.string.age_rate_limit_message), positiveButtonText = getString(R.string.ok), positiveButtonAction = { findNavController(binding.fragment.id).popBackStack() } ).show(supportFragmentManager, TAG) } } } } } Loading
app/src/main/java/foundation/e/apps/data/ParentalControlRepository.kt 0 → 100644 +77 −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 class ParentalControlRepository { fun isParentalControlEnabled(): Boolean { return true } fun getAllowedContentRatings(): List<String> { return listOf( "PEGI 3", "EVERYONE", "All ages", "General", "All ages", "For all", "PEGI 3", "Parental Guidance Recommended", // "EVERYONE", // "All ages", // "General", // "All ages", // "For all", // "Rated for 3+", // "PEGI 3", // "PEGI 7", // "Parental Guidance Recommended", // "EVERYONE", // "All ages", // "USK: Ages 6 and above", // "General", // "All ages", // "For all", // "Rated for 3+", // "Rated for 7+", // "PEGI 3", // "PEGI 7", // "PEGI 12", // "Parental Guidance Recommended", // "EVERYONE", // "EVERYONE 10+", // "TEEN", // "All ages", // "USK: Ages 6 and above", // "USK: Ages 12 and above", // "General", // "Parental Guidance", // "All ages", // "Rated 10+", // "Rated 12+", // "For all", // "Rated 12+", // "Rated for 3+", // "Rated for 7+", // "Rated for 12+" ) } } No newline at end of file
app/src/main/java/foundation/e/apps/data/blockedApps/ContentRating.kt 0 → 100644 +29 −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.blockedApps import com.google.gson.annotations.SerializedName data class ContentRating( val id: String, @SerializedName("age_group") val ageGroup: String, val ratings: List<String> )
app/src/main/java/foundation/e/apps/data/blockedApps/ContentRatingsRepository.kt 0 → 100644 +77 −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.blockedApps import com.google.gson.Gson import com.google.gson.reflect.TypeToken import foundation.e.apps.data.DownloadManager import foundation.e.apps.data.fusedDownload.FileManager import timber.log.Timber import java.io.File import javax.inject.Inject import javax.inject.Named import javax.inject.Singleton @Singleton class ContentRatingsRepository @Inject constructor( private val downloadManager: DownloadManager, private val gson: Gson, @Named("cacheDir") private val cacheDir: String ) { private var _contentRatings = listOf<ContentRating>() val contentRatingsList: List<ContentRating> get() = _contentRatings companion object { private const val CONTENT_RATINGS_FILE_URL = "https://gitlab.e.foundation/e/os/app-lounge-content-ratings/-/raw/main/content_ratings.json?ref_type=heads&inline=false" private const val CONTENT_RATINGS_FILE_NAME = "content_ratings.json" } fun fetchContentRatingData() { downloadManager.downloadFileInCache( CONTENT_RATINGS_FILE_URL, fileName = CONTENT_RATINGS_FILE_NAME ) { success, _ -> if (success) { parseContentRatingData() } } } private fun parseContentRatingData() { _contentRatings = try { val outputPath = "$cacheDir/warning_list/" FileManager.moveFile("$cacheDir/", CONTENT_RATINGS_FILE_NAME, outputPath) val downloadedFile = File(outputPath + CONTENT_RATINGS_FILE_NAME) Timber.d("Blocked list file exists: ${downloadedFile.exists()}") val blockedAppInfoJson = String(downloadedFile.inputStream().readBytes()) Timber.d("Blocked list file contents: $blockedAppInfoJson") val contentRatingsListType = object : TypeToken<List<ContentRating>>() {}.type gson.fromJson(blockedAppInfoJson, contentRatingsListType) } catch (exception: Exception) { Timber.e(exception.localizedMessage ?: "", exception) mutableListOf() } } } No newline at end of file
app/src/main/java/foundation/e/apps/data/fusedDownload/models/FusedDownload.kt +4 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package foundation.e.apps.data.fusedDownload.models import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey import com.aurora.gplayapi.data.models.ContentRating import com.aurora.gplayapi.data.models.File import foundation.e.apps.data.cleanapk.CleanApkRetrofit import foundation.e.apps.data.enums.Origin Loading Loading @@ -36,6 +37,9 @@ data class FusedDownload( Status.INSTALLING ) @Ignore var contentRating: ContentRating? = null fun isAppInstalling() = installingStatusList.contains(status) fun isAwaiting() = status == Status.AWAITING Loading