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

Commit def7bb10 authored by Hasib Prince's avatar Hasib Prince
Browse files

refactor: fix detekt issuees

parent b6579f81
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
    <ID>LongParameterList:ApplicationViewModel.kt$ApplicationViewModel$( id: String, packageName: String, origin: Origin, isFdroidLink: Boolean, authObjectList: List&lt;AuthObject&gt;, retryBlock: (failedObjects: List&lt;AuthObject&gt;) -&gt; Boolean, )</ID>
    <ID>LongParameterList:CleanApkRetrofit.kt$CleanApkRetrofit$( @Query("keyword") keyword: String, @Query("source") source: String = APP_SOURCE_FOSS, @Query("type") type: String = APP_TYPE_ANY, @Query("nres") nres: Int = 20, @Query("page") page: Int = 1, @Query("by") by: String? = null, )</ID>
    <ID>LongParameterList:EglExtensionProvider.kt$EglExtensionProvider$( egl10: EGL10, eglDisplay: EGLDisplay, eglConfig: EGLConfig?, ai: IntArray, ai1: IntArray?, set: MutableSet&lt;String&gt; )</ID>
    <ID>LongParameterList:MainActivityViewModel.kt$MainActivityViewModel$( private val appLoungeDataStore: AppLoungeDataStore, private val applicationRepository: ApplicationRepository, private val appManagerWrapper: AppManagerWrapper, private val appLoungePackageManager: AppLoungePackageManager, private val pwaManager: PWAManager, private val ecloudRepository: EcloudRepository, private val blockedAppRepository: BlockedAppRepository, private val appInstallProcessor: AppInstallProcessor, )</ID>
    <ID>LongParameterList:MainActivityViewModel.kt$MainActivityViewModel$( private val appLoungeDataStore: AppLoungeDataStore, private val applicationRepository: ApplicationRepository, private val appManagerWrapper: AppManagerWrapper, private val appLoungePackageManager: AppLoungePackageManager, private val pwaManager: PWAManager, private val ecloudRepository: EcloudRepository, private val blockedAppRepository: BlockedAppRepository, private val contentRatingsRepository: ContentRatingsRepository, private val appInstallProcessor: AppInstallProcessor, )</ID>
    <ID>LongParameterList:UpdatesManagerImpl.kt$UpdatesManagerImpl$( @ApplicationContext private val context: Context, private val appLoungePackageManager: AppLoungePackageManager, private val applicationRepository: ApplicationRepository, private val faultyAppRepository: FaultyAppRepository, private val appLoungePreference: AppLoungePreference, private val fdroidRepository: FdroidRepository, private val blockedAppRepository: BlockedAppRepository, )</ID>
    <ID>LongParameterList:UpdatesWorker.kt$UpdatesWorker$( @Assisted private val context: Context, @Assisted private val params: WorkerParameters, private val updatesManagerRepository: UpdatesManagerRepository, private val dataStoreManager: DataStoreManager, private val authenticatorRepository: AuthenticatorRepository, private val appInstallProcessor: AppInstallProcessor, private val blockedAppRepository: BlockedAppRepository, )</ID>
    <ID>MagicNumber:AnonymousLoginManager.kt$AnonymousLoginManager$200</ID>
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ package foundation.e.apps.data.blockedApps

import com.google.gson.annotations.SerializedName

data class ContentRating(
data class ContentRatingGroup(
    val id: String,
    @SerializedName("age_group")
    val ageGroup: String,
+17 −11
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
package foundation.e.apps.data.blockedApps

import com.google.gson.Gson
import com.google.gson.JsonSyntaxException
import com.google.gson.reflect.TypeToken
import foundation.e.apps.data.DownloadManager
import foundation.e.apps.data.install.FileManager
@@ -36,13 +37,14 @@ class ContentRatingsRepository @Inject constructor(
    @Named("cacheDir") private val cacheDir: String
) {

    private var _contentRatings = listOf<ContentRating>()
    val contentRatings: List<ContentRating>
        get() = _contentRatings
    private var _contentRatingGroups = listOf<ContentRatingGroup>()
    val contentRatingGroups: List<ContentRatingGroup>
        get() = _contentRatingGroups

    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"
            "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"
    }

@@ -58,7 +60,7 @@ class ContentRatingsRepository @Inject constructor(
    }

    private fun parseContentRatingData() {
        _contentRatings = try {
        _contentRatingGroups = try {
            val outputPath = "$cacheDir/warning_list/"
            FileManager.moveFile("$cacheDir/",
                CONTENT_RATINGS_FILE_NAME, outputPath)
@@ -66,11 +68,15 @@ class ContentRatingsRepository @Inject constructor(
            val contentRatingJson = String(downloadedFile.inputStream().readBytes())
            Timber.d("ContentRatings file contents: $contentRatingJson")

            val contentRatingsListType = object : TypeToken<List<ContentRating>>() {}.type
            gson.fromJson(contentRatingJson, contentRatingsListType)
        } catch (exception: Exception) {
            Timber.e(exception.localizedMessage ?: "", exception)
            mutableListOf()
            val contentRatingsListTypeGroup = object : TypeToken<List<ContentRatingGroup>>() {}.type
            gson.fromJson(contentRatingJson, contentRatingsListTypeGroup)
        } catch (exception: JsonSyntaxException) {
            handleException(exception)
        }
    }

    private fun handleException(exception: Exception): MutableList<ContentRatingGroup> {
        Timber.e(exception.localizedMessage ?: "", exception)
        return mutableListOf()
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class CheckAppAgeLimitUseCase @Inject constructor(
        }

        val selectedAgeGroup = parentalControlRepository.getSelectedAgeGroup()
        val allowedContentRating = contentRatingRepository.contentRatings.find {
        val allowedContentRating = contentRatingRepository.contentRatingGroups.find {
            it.id == selectedAgeGroup.toString()
        }

+31 −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.install

import foundation.e.apps.data.install.AppInstallRepository
import foundation.e.apps.data.install.AppManagerWrapper
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class AppInstallComponents @Inject constructor(
    val appInstallRepository: AppInstallRepository,
    val appManagerWrapper: AppManagerWrapper
)
Loading