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

Commit a9ffdc5e authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Merge branch '2804-u-bring-back-request' into 'main'

Bring back EP report request

See merge request !523
parents a3f1c7a0 a098b9ea
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -117,6 +117,10 @@ data class Application(
            }
        }
    }

    fun hasExodusPrivacyRating(): Boolean {
        return this.reportId.toInt() != -1
    }
}

val Application.shareUri: Uri
+2 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ class AppPrivacyInfoRepositoryImpl @Inject constructor(
        }

        val reports = fetchReports(application.package_name)
        if (reports.isEmpty()) {
        if (reports.firstOrNull()?.handle != application.package_name) {
            return Result.error("Could not fetch reports for ${application.package_name}")
        }

@@ -63,7 +63,7 @@ class AppPrivacyInfoRepositoryImpl @Inject constructor(
        val requestBody = mapOf(
            "type" to "application",
            "query" to packageName,
            "limit" to 50
            "limit" to 5
        )

        val jsonBody = Gson().toJson(requestBody)
+4 −0
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ class PrivacyInfoViewModel @Inject constructor(
    }

    fun shouldRequestExodusReport(application: Application?): Boolean {
        if (application?.hasExodusPrivacyRating() == false)  {
            return true
        }

        if (application?.isFree != true) {
            return false
        }
+10 −2
Original line number Diff line number Diff line
@@ -303,9 +303,17 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
    }

    private fun openBrowser() {
        val url = generateExodusUrl()
        val application = applicationViewModel.getApplication()
        val packageName = application?.package_name ?: return

        val url = if (application.hasExodusPrivacyRating()) {
            ExodusUriGenerator.buildReportUri(packageName)
        } else {
            ExodusUriGenerator.buildRequestReportUri(packageName)
        }

        val intent = Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse(url)
            data = url
        }

        if (intent.resolveActivity(requireContext().packageManager) == null) {
+2 −17
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ class ApplicationListRVAdapter(
            appPrivacyScoreLayout.isVisible = false
            return
        }
        if (searchApp.ratings.privacyScore != -1.0) {
        if (searchApp.hasExodusPrivacyRating() && searchApp.ratings.privacyScore != -1.0) {
            appPrivacyScore.text = view.context.getString(
                R.string.privacy_rating_out_of,
                searchApp.ratings.privacyScore.toInt().toString()
@@ -395,23 +395,8 @@ class ApplicationListRVAdapter(
        searchApp: Application,
        view: View
    ) {
        if (searchApp.privacyScore > -1) {
            showPrivacyScoreOnAvailableData(searchApp, view)
        } else {
        showPrivacyScoreAfterFetching(searchApp, view)
    }
    }

    private fun ApplicationListItemBinding.showPrivacyScoreOnAvailableData(
        searchApp: Application,
        view: View
    ) {
        showPrivacyScore()
        appPrivacyScore.text = view.context.getString(
            R.string.privacy_rating_out_of,
            searchApp.privacyScore.toString()
        )
    }

    private fun ApplicationListItemBinding.showPrivacyScoreAfterFetching(
        searchApp: Application,