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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user