Skip to content

Commit

Permalink
Improve visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-BaptisteC committed Nov 26, 2023
1 parent 5042615 commit a5464b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -397,6 +399,7 @@ class ExodusUpdateService : LifecycleService() {
private fun stopService() {
IS_SERVICE_RUNNING = false
notificationManager.cancel(SERVICE_ID)
updateStatutRefresh(false)
job.cancel()
stopSelf()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}

Expand All @@ -135,7 +144,6 @@ class AppsFragment : Fragment(R.layout.fragment_apps) {
action = ExodusUpdateService.START_SERVICE
activity?.startService(this)
}
binding.progress.visibility = View.VISIBLE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -85,3 +87,11 @@ fun PackageManager.getSource(packageName: String): String? {
this.getInstallerPackageName(packageName)
}
}

fun updateStatutRefresh(value: Boolean) {
isRefreshing = value
}

fun getStatutRefresh(): Boolean {
return isRefreshing
}

0 comments on commit a5464b1

Please sign in to comment.