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

Commit ebe33eb0 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

FusedAPIImpl: Add comments regarding internal functions

parent 1d2ae125
Loading
Loading
Loading
Loading
+28 −8
Original line number Diff line number Diff line
@@ -281,6 +281,10 @@ class FusedAPIImpl @Inject constructor(
        return response ?: FusedApp()
    }

    /*
     * Categories-related internal functions
     */

    private suspend fun handleCleanApkCategories(
        preferredApplicationType: String,
        categoriesList: MutableList<FusedCategory>,
@@ -448,6 +452,18 @@ class FusedAPIImpl @Inject constructor(
        ).body()
    }

    private fun Category.transformToFusedCategory(): FusedCategory {
        return FusedCategory(
            title = this.title,
            browseUrl = this.browseUrl,
            imageUrl = this.imageUrl,
        )
    }

    /*
     * Search-related internal functions
     */

    private suspend fun getCleanAPKSearchResults(
        keyword: String,
        source: String = CleanAPKInterface.APP_SOURCE_FOSS,
@@ -473,6 +489,10 @@ class FusedAPIImpl @Inject constructor(
        }
    }

    /*
     * Download-related internal functions
     */

    private fun downloadApp(name: String, packageName: String, url: String): Long {
        val packagePath = File(cacheDir, "$packageName.apk")
        if (packagePath.exists()) packagePath.delete() // Delete old download if-exists
@@ -482,6 +502,10 @@ class FusedAPIImpl @Inject constructor(
        return downloadManager.enqueue(request)
    }

    /*
     * Home screen-related internal functions
     */

    private fun generateCleanAPKHome(home: Home, prefType: String): List<FusedHome> {
        val list = mutableListOf<FusedHome>()
        val headings = if (prefType == APP_TYPE_OPEN) {
@@ -562,6 +586,10 @@ class FusedAPIImpl @Inject constructor(
        return list
    }

    /*
     * FusedApp-related internal extensions and functions
     */

    private fun App.transformToFusedApp(): FusedApp {
        return FusedApp(
            _id = this.id.toString(),
@@ -594,12 +622,4 @@ class FusedAPIImpl @Inject constructor(
        }
        return list
    }

    private fun Category.transformToFusedCategory(): FusedCategory {
        return FusedCategory(
            title = this.title,
            browseUrl = this.browseUrl,
            imageUrl = this.imageUrl,
        )
    }
}