diff --git a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt index 0c8d390f4dd06e9bbcf134829944ea9d1eef80d4..e99278fcca8efa43dfcd23ff6c9a077664e6974b 100644 --- a/app/src/main/java/foundation/e/apps/data/application/data/Application.kt +++ b/app/src/main/java/foundation/e/apps/data/application/data/Application.kt @@ -117,6 +117,10 @@ data class Application( } } } + + fun hasExodusPrivacyRating(): Boolean { + return this.reportId.toInt() != -1 + } } val Application.shareUri: Uri diff --git a/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt b/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt index 37f4b7004a5f0c45ae37dfe5ffee1e7ccd273078..9900f6712266a2f3b47f4e7bf16fd0e3c75909b4 100644 --- a/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt +++ b/app/src/main/java/foundation/e/apps/data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt @@ -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) diff --git a/app/src/main/java/foundation/e/apps/ui/PrivacyInfoViewModel.kt b/app/src/main/java/foundation/e/apps/ui/PrivacyInfoViewModel.kt index f5985286e55ead70a328f5255c4196bd7be7a7f2..c01da14f4b44db93c92c36dc22b0f67149f2acdd 100644 --- a/app/src/main/java/foundation/e/apps/ui/PrivacyInfoViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/PrivacyInfoViewModel.kt @@ -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 } diff --git a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt index 8e7a6d4a49bf6eb91809cf41a7b3ddf232393613..9722b8c254e902ec954c506691f6ad11c5d3663c 100644 --- a/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt @@ -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) { diff --git a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt index d1a7cdac4b4b98a5d4d0d32dc7fd18fe27bc66fd..88c9f233d3e2cefc686ac9d695fe22f2cf24386a 100644 --- a/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/applicationlist/ApplicationListRVAdapter.kt @@ -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,22 +395,7 @@ 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() - ) + showPrivacyScoreAfterFetching(searchApp, view) } private fun ApplicationListItemBinding.showPrivacyScoreAfterFetching(