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

Commit 9f7845b1 authored by Hasib Prince's avatar Hasib Prince
Browse files

Enum is introduced for app sources

parent e2918ba8
Loading
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
    <ID>MagicNumber:ApkSignatureManager.kt$ApkSignatureManager$1024</ID>
    <ID>MagicNumber:AppDatabase.kt$AppDatabase.Companion.&lt;no name provided&gt;$3</ID>
    <ID>MagicNumber:AppDatabase.kt$AppDatabase.Companion.&lt;no name provided&gt;$4</ID>
    <ID>MagicNumber:ApplicationApiImpl.kt$ApplicationApiImpl$3</ID>
    <ID>MagicNumber:ApplicationFragment.kt$ApplicationFragment$100f</ID>
    <ID>MagicNumber:ApplicationFragment.kt$ApplicationFragment$15</ID>
    <ID>MagicNumber:ApplicationFragment.kt$ApplicationFragment$3</ID>
@@ -74,8 +73,6 @@
    <ID>MaxLineLength:AppPrivacyInfo.kt$AppPrivacyInfo</ID>
    <ID>MaxLineLength:ApplicationApi.kt$ApplicationApi$suspend fun getGplayAppsByCategory(authData: AuthData, category: String, pageUrl: String?): ResultSupreme&lt;Pair&lt;List&lt;Application&gt;, String&gt;&gt;</ID>
    <ID>MaxLineLength:ApplicationApiImpl.kt$ApplicationApiImpl$(cleanApkAppsRepository.getAppDetails(result.apps[0]._id) as Response&lt;CleanApkApplication&gt;).body()?.app</ID>
    <ID>MaxLineLength:ApplicationApiImpl.kt$ApplicationApiImpl$val hasGplayLimitedResult = gplayHomes.any { fusedHome -&gt; fusedHome.list.size &lt; THRESHOLD_LIMITED_RESULT_HOME_PAGE }</ID>
    <ID>MaxLineLength:ApplicationDiffUtil.kt$ApplicationDiffUtil$((oldItem.trackers == LIST_OF_NULL &amp;&amp; newItem.trackers.isEmpty()) || oldItem.trackers == newItem.trackers)</ID>
    <ID>MaxLineLength:ApplicationFragment.kt$ApplicationFragment.Companion$"https://gitlab.e.foundation/e/os/apps/-/blob/main/app/src/main/java/foundation/e/apps/data/exodus/repositories/PrivacyScoreRepositoryImpl.kt"</ID>
    <ID>MaxLineLength:CommonUtilsModule.kt$CommonUtilsModule$*</ID>
    <ID>MaxLineLength:DownloadManager.kt$DownloadManager$Timber.e("Download Issue: $downloadId : DownloadManager returns status: $status but the failed because: reason: $reason")</ID>
@@ -83,9 +80,6 @@
    <ID>MaxLineLength:DownloadManagerUtils.kt$DownloadManagerUtils$Timber.d("===&gt; updateDownloadStatus: ${fusedDownload.name}: $downloadId: $numberOfDownloadedItems/${fusedDownload.downloadIdMap.size}")</ID>
    <ID>MaxLineLength:DownloadManagerUtils.kt$DownloadManagerUtils$if</ID>
    <ID>MaxLineLength:DownloadManagerUtils.kt$DownloadManagerUtils$numberOfDownloadedItems == fusedDownload.downloadIdMap.size &amp;&amp; numberOfDownloadedItems == fusedDownload.downloadURLList.size</ID>
    <ID>MaxLineLength:DownloadProgressLD.kt$DownloadProgressLD$cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))</ID>
    <ID>MaxLineLength:DownloadProgressLD.kt$DownloadProgressLD$cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))</ID>
    <ID>MaxLineLength:DownloadProgressLD.kt$DownloadProgressLD$status == DownloadManager.STATUS_SUCCESSFUL || status == DownloadManager.STATUS_FAILED</ID>
    <ID>MaxLineLength:FdroidRepository.kt$FdroidRepository$override suspend</ID>
    <ID>MaxLineLength:FusedManagerImpl.kt$FusedManagerImpl$.</ID>
    <ID>MaxLineLength:FusedManagerImpl.kt$FusedManagerImpl$return</ID>
@@ -120,8 +114,6 @@
    <ID>ReturnCount:AppPrivacyInfoRepositoryImpl.kt$AppPrivacyInfoRepositoryImpl$override suspend fun getAppPrivacyInfo( application: Application, appHandle: String ): Result&lt;AppPrivacyInfo&gt;</ID>
    <ID>ReturnCount:AppPrivacyInfoRepositoryImpl.kt$AppPrivacyInfoRepositoryImpl$private fun getAppPrivacyInfo( application: Application, appTrackerData: List&lt;Report&gt;, ): AppPrivacyInfo</ID>
    <ID>ReturnCount:ApplicationApiImpl.kt$ApplicationApiImpl$override fun isAnyFusedAppUpdated( newApplications: List&lt;Application&gt;, oldApplications: List&lt;Application&gt; ): Boolean</ID>
    <ID>ReturnCount:ApplicationApiImpl.kt$ApplicationApiImpl$override fun isHomeDataUpdated( newHomeData: List&lt;Home&gt;, oldHomeData: List&lt;Home&gt; ): Boolean</ID>
    <ID>ReturnCount:ApplicationApiImpl.kt$ApplicationApiImpl$private fun areFusedAppsUpdated( oldHome: Home, newHome: Home, ): Boolean</ID>
    <ID>ReturnCount:DownloadManager.kt$DownloadManager$fun getSizeRequired(downloadId: Long): Long</ID>
    <ID>ReturnCount:DownloadManager.kt$DownloadManager$private fun sanitizeStatus(downloadId: Long, status: Int, reason: Int): Int</ID>
    <ID>ReturnCount:Extensions.kt$fun Context.isNetworkAvailable(): Boolean</ID>
+3 −3
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class ApplicationDataManager @Inject constructor(
        return application.restriction != Constants.Restriction.NOT_RESTRICTED
    }

    /**
    /*
     * Some apps are simply not visible.
     * Example: com.skype.m2
     */
@@ -83,7 +83,7 @@ class ApplicationDataManager @Inject constructor(
        return kotlin.runCatching { gplayRepository.getAppDetails(application.package_name) }.isSuccess
    }

    /**
    /*
     * Some apps are visible but not downloadable.
     * Example: com.riotgames.league.wildrift
     */
@@ -103,7 +103,7 @@ class ApplicationDataManager @Inject constructor(
        }
    }

    /**
    /*
     * Get fused app installation status.
     * Applicable for both native apps and PWAs.
     *
+23 −13
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.R
import foundation.e.apps.data.ResultSupreme
import foundation.e.apps.data.application.data.Home
import foundation.e.apps.data.application.utils.transformToApplication
import foundation.e.apps.data.application.utils.toApplication
import foundation.e.apps.data.cleanapk.data.home.HomeScreen
import foundation.e.apps.data.cleanapk.repositories.CleanApkRepository
import foundation.e.apps.data.enums.ResultStatus
@@ -59,10 +59,14 @@ class HomeApiImpl @Inject constructor(

    companion object {
        private const val THRESHOLD_LIMITED_RESULT_HOME_PAGE = 4
        private const val WEIGHT_PWA = 1
        private const val WEIGHT_OPEN_SOURCE = 2
        private const val WEIGHT_GPLAY = 3
    }

    private enum class AppSourceWeight {
        GPLAY,
        OPEN_SOURCE,
        PWA
    }

    override suspend fun fetchHomeScreenData(authData: AuthData): LiveData<ResultSupreme<List<Home>>> {
        val list = mutableListOf<Home>()
        var resultGplay: FusedHomeDeferred? = null
@@ -120,18 +124,21 @@ class HomeApiImpl @Inject constructor(
        }

        setHomeErrorMessage(result.getResultStatus(), source)
        priorList.sortByDescending {
        priorList.sortBy {
            when (it.source) {
                ApplicationApi.APP_TYPE_OPEN -> WEIGHT_OPEN_SOURCE
                ApplicationApi.APP_TYPE_PWA -> WEIGHT_PWA
                else -> WEIGHT_GPLAY
                ApplicationApi.APP_TYPE_OPEN -> AppSourceWeight.OPEN_SOURCE.ordinal
                ApplicationApi.APP_TYPE_PWA -> AppSourceWeight.PWA.ordinal
                else -> AppSourceWeight.GPLAY.ordinal
            }
        }

        return ResultSupreme.create(result.getResultStatus(), priorList)
    }

    private suspend fun handleCleanApkHomes(priorList: MutableList<Home>, appType: String): MutableList<Home> {
    private suspend fun handleCleanApkHomes(
        priorList: MutableList<Home>,
        appType: String
    ): MutableList<Home> {
        val response = if (appType == ApplicationApi.APP_TYPE_OPEN) {
            (cleanApkAppsRepository.getHomeScreenData() as Response<HomeScreen>).body()
        } else {
@@ -215,12 +222,15 @@ class HomeApiImpl @Inject constructor(
        }
    }

    private suspend fun fetchGPlayHome(authData: AuthData, priorList: MutableList<Home>): List<Home> {
    private suspend fun fetchGPlayHome(
        authData: AuthData,
        priorList: MutableList<Home>
    ): List<Home> {
        val list = mutableListOf<Home>()
        val gplayHomeData = gplayRepository.getHomeScreenData() as Map<String, List<App>>
        gplayHomeData.map {
            val fusedApps = it.value.map { app ->
                app.transformToApplication (context).apply {
                app.toApplication(context).apply {
                    applicationDataManager.updateStatus(this)
                    applicationDataManager.updateFilterLevel(authData, this)
                }
@@ -237,8 +247,8 @@ class HomeApiImpl @Inject constructor(

    private fun handleLimitedResult(homeList: List<Home>) {
        val gplayHomes = homeList.filter { fusedHome -> fusedHome.source.isEmpty() }
        val hasGplayLimitedResult = gplayHomes.any {
                fusedHome -> fusedHome.list.size < THRESHOLD_LIMITED_RESULT_HOME_PAGE
        val hasGplayLimitedResult = gplayHomes.any { fusedHome ->
            fusedHome.list.size < THRESHOLD_LIMITED_RESULT_HOME_PAGE
        }

        if (hasGplayLimitedResult) {
+3 −3
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.application.data.Ratings
import foundation.e.apps.data.enums.Origin

fun App.transformToApplication(context: Context): Application {
fun App.toApplication(context: Context): Application {
    val app = Application(
        _id = this.id.toString(),
        author = this.developerName,
@@ -38,7 +38,7 @@ fun App.transformToApplication(context: Context): Application {
        latest_version_code = this.versionCode,
        latest_version_number = this.versionName,
        name = this.displayName,
        other_images_path = this.screenshots.transformToList(),
        other_images_path = this.screenshots.toList(),
        package_name = this.packageName,
        ratings = Ratings(
            usageQualityScore =
@@ -60,7 +60,7 @@ fun App.transformToApplication(context: Context): Application {
    return app
}

private fun MutableList<Artwork>.transformToList(): List<String> {
private fun MutableList<Artwork>.toList(): List<String> {
    val list = mutableListOf<String>()
    this.forEach {
        list.add(it.url)
+18 −0
Original line number Diff line number Diff line
/*
 * Copyright MURENA SAS 2023
 * 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 dagger.Binds