From c1e0f0a4b8c0d7857b91f488e1ce22d5ed72c86b Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 27 Nov 2024 16:14:53 +0100 Subject: [PATCH 1/2] Display Exodus Privacy report request button again --- .../apps/data/application/data/Application.kt | 4 ++++ .../AppPrivacyInfoRepositoryImpl.kt | 2 +- .../e/apps/ui/PrivacyInfoViewModel.kt | 4 ++++ .../ui/application/ApplicationFragment.kt | 12 ++++++++++-- .../ApplicationListRVAdapter.kt | 19 ++----------------- 5 files changed, 21 insertions(+), 20 deletions(-) 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 0c8d390f4..e99278fcc 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 37f4b7004..91a6c044a 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}") } 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 f5985286e..c01da14f4 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 8e7a6d4a4..9722b8c25 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 d1a7cdac4..88c9f233d 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( -- GitLab From a098b9ea6837ad4ced53128baad16e4881971704 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 28 Nov 2024 08:11:11 +0100 Subject: [PATCH 2/2] Limit EP results to 5 --- .../data/exodus/repositories/AppPrivacyInfoRepositoryImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 91a6c044a..9900f6712 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 @@ -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) -- GitLab