Improvements to download progress UI

Switch to LinearProgressIndicator where possible and show an indeterminate
progress bar while download progress is below 1%

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-12-31 14:56:22 +05:30
parent fe88345734
commit f851a5ad3e
7 changed files with 54 additions and 73 deletions

View File

@@ -20,14 +20,10 @@
package com.aurora.store.view.epoxy.views.app
import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.text.HtmlCompat
import androidx.core.view.isVisible
import coil.load
@@ -73,11 +69,6 @@ class AppUpdateView : RelativeLayout {
private fun init(context: Context?) {
val view = inflate(context, R.layout.view_app_update, this)
B = ViewAppUpdateBinding.bind(view)
B.progressDownload.progressDrawable?.apply {
val alphaColor = ColorUtils.setAlphaComponent(Color.GRAY, 100)
colorFilter = PorterDuffColorFilter(alphaColor, PorterDuff.Mode.SRC_IN)
}
}
@ModelProp
@@ -118,6 +109,7 @@ class AppUpdateView : RelativeLayout {
if (download != null) {
/*Inflate Download details*/
B.btnAction.updateState(download.status)
B.progressDownload.isIndeterminate = download.progress < 1
when (download.status) {
DownloadStatus.QUEUED -> {
B.progressDownload.progress = 0

View File

@@ -249,7 +249,9 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
if (it.isFinished) flip(0) else flip(1)
when (it.status) {
DownloadStatus.QUEUED,
DownloadStatus.QUEUED -> {
updateProgress(it.progress)
}
DownloadStatus.DOWNLOADING -> {
updateProgress(it.progress, it.speed, it.timeRemaining)
}
@@ -580,13 +582,10 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
binding.layoutDetailsInstall.apply {
txtProgressPercent.text = ("${progress}%")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
progressDownload.setProgress(progress, true)
} else {
progressDownload.progress = progress
progressDownload.apply {
this.progress = progress
isIndeterminate = progress < 1
}
txtEta.text = CommonUtil.getETAString(requireContext(), timeRemaining)
txtSpeed.text = CommonUtil.getDownloadSpeedString(requireContext(), speed)
}