From a5464b1cabaab269a8b4b3b071018c043e407ebd Mon Sep 17 00:00:00 2001 From: Jean-BaptisteC Date: Sun, 26 Nov 2023 17:32:05 +0100 Subject: [PATCH] Improve visibility --- .../exodusprivacy/ExodusUpdateService.kt | 3 +++ .../exodusprivacy/fragments/apps/AppsFragment.kt | 12 ++++++++++-- .../exodusprivacy/utils/CommonExtensions.kt | 10 ++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/ExodusUpdateService.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/ExodusUpdateService.kt index 4dbbd56e..1d03e5d4 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/ExodusUpdateService.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/ExodusUpdateService.kt @@ -34,6 +34,7 @@ import org.eu.exodus_privacy.exodusprivacy.manager.packageinfo.ExodusPackageRepo import org.eu.exodus_privacy.exodusprivacy.manager.storage.ExodusConfig import org.eu.exodus_privacy.exodusprivacy.manager.storage.ExodusDataStoreRepository import org.eu.exodus_privacy.exodusprivacy.objects.Application +import org.eu.exodus_privacy.exodusprivacy.utils.updateStatutRefresh import javax.inject.Inject @AndroidEntryPoint @@ -243,6 +244,7 @@ class ExodusUpdateService : LifecycleService() { getString(R.string.fetching_apps), Toast.LENGTH_SHORT ).show() + updateStatutRefresh(true) serviceScope.launch { if (!firstTime) removeUninstalledApps() Log.d(TAG, "Refreshing trackers database.") @@ -397,6 +399,7 @@ class ExodusUpdateService : LifecycleService() { private fun stopService() { IS_SERVICE_RUNNING = false notificationManager.cancel(SERVICE_ID) + updateStatutRefresh(false) job.cancel() stopSelf() } diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/AppsFragment.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/AppsFragment.kt index 92bc3481..8a3b2e33 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/AppsFragment.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/apps/AppsFragment.kt @@ -20,6 +20,7 @@ import org.eu.exodus_privacy.exodusprivacy.ExodusUpdateService import org.eu.exodus_privacy.exodusprivacy.R import org.eu.exodus_privacy.exodusprivacy.databinding.FragmentAppsBinding import org.eu.exodus_privacy.exodusprivacy.fragments.apps.model.AppsRVAdapter +import org.eu.exodus_privacy.exodusprivacy.utils.getStatutRefresh @AndroidEntryPoint class AppsFragment : Fragment(R.layout.fragment_apps) { @@ -41,6 +42,7 @@ class AppsFragment : Fragment(R.layout.fragment_apps) { reenterTransition = MaterialFadeThrough() returnTransition = MaterialFadeThrough() + val progressBar = binding.progress val updateReportsFab = binding.updateReportsFAB // Setup menu actions @@ -62,6 +64,11 @@ class AppsFragment : Fragment(R.layout.fragment_apps) { } true } + if (!getStatutRefresh()) { + progressBar.visibility = View.GONE + } else { + progressBar.visibility = View.VISIBLE + } // Setup RecyclerView val appsRVAdapter = AppsRVAdapter(findNavController().currentDestination!!.id) @@ -94,7 +101,7 @@ class AppsFragment : Fragment(R.layout.fragment_apps) { if (!it.isNullOrEmpty()) { binding.swipeRefreshLayout.visibility = View.VISIBLE binding.shimmerLayout.visibility = View.GONE - binding.progress.visibility = View.GONE + progressBar.visibility = View.GONE appsRVAdapter.submitList(it) } else { binding.swipeRefreshLayout.visibility = View.VISIBLE @@ -105,10 +112,12 @@ class AppsFragment : Fragment(R.layout.fragment_apps) { binding.swipeRefreshLayout.setOnRefreshListener { binding.swipeRefreshLayout.isRefreshing = false updateReports(view.context) + progressBar.visibility = View.VISIBLE } updateReportsFab.setOnClickListener { updateReports(view.context) + progressBar.visibility = View.VISIBLE } } @@ -135,7 +144,6 @@ class AppsFragment : Fragment(R.layout.fragment_apps) { action = ExodusUpdateService.START_SERVICE activity?.startService(this) } - binding.progress.visibility = View.VISIBLE } } } diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt index 36b69061..e0bc679a 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/utils/CommonExtensions.kt @@ -12,6 +12,8 @@ import org.eu.exodus_privacy.exodusprivacy.manager.database.app.ExodusApplicatio import org.eu.exodus_privacy.exodusprivacy.objects.VersionReport import java.util.Locale +var isRefreshing: Boolean = false + fun Chip.setExodusColor(size: Int) { if (this.text != "?") { val colorRed = ContextCompat.getColor(context, R.color.colorRedLight) @@ -85,3 +87,11 @@ fun PackageManager.getSource(packageName: String): String? { this.getInstallerPackageName(packageName) } } + +fun updateStatutRefresh(value: Boolean) { + isRefreshing = value +} + +fun getStatutRefresh(): Boolean { + return isRefreshing +}