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)
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Aurora Store
|
||||
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
~
|
||||
~ Aurora Store is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 2 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ Aurora Store is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="@color/colorScrim" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="@color/colorScrimAlt" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -60,15 +60,22 @@
|
||||
android:gravity="center_vertical"
|
||||
android:weightSum="4">
|
||||
|
||||
<ProgressBar
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_download"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/icon_size_small"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@id/img_cancel"
|
||||
android:indeterminateTint="@color/colorScrim"
|
||||
android:progressDrawable="@drawable/progressbar_bg"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/colorScrimAlt"
|
||||
app:indicatorColor="@color/colorScrimAlt"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:trackColor="@color/colorScrim"
|
||||
app:trackCornerRadius="10dp"
|
||||
app:trackThickness="@dimen/icon_size_small"
|
||||
tools:progress="40" />
|
||||
|
||||
<LinearLayout
|
||||
@@ -159,4 +166,4 @@
|
||||
android:textColor="@color/colorWhite"
|
||||
tools:text="@string/purchase_invalid" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -52,14 +52,15 @@
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/progress_download"
|
||||
style="@style/Widget.Material3.CircularProgressIndicator"
|
||||
android:layout_width="@dimen/icon_size_medium"
|
||||
android:layout_height="@dimen/icon_size_medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/progressbar_bg"
|
||||
android:indeterminate="false"
|
||||
android:visibility="invisible"
|
||||
app:trackThickness="24dp"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/colorScrimAlt"
|
||||
android:visibility="gone"
|
||||
app:indicatorColor="@color/colorScrimAlt"
|
||||
app:trackColor="@color/colorScrim"
|
||||
app:trackThickness="@dimen/icon_size_default"
|
||||
tools:progress="40" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:paddingStart="@dimen/padding_small"
|
||||
android:paddingEnd="@dimen/padding_small">
|
||||
@@ -61,12 +62,19 @@
|
||||
android:textAlignment="viewStart"
|
||||
tools:text="Status" />
|
||||
|
||||
<ProgressBar
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_download"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:indeterminate="false"
|
||||
android:max="100"
|
||||
app:indicatorColor="@color/colorAccent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:trackColor="@android:color/darker_gray"
|
||||
app:trackCornerRadius="10dp"
|
||||
tools:progress="75" />
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_normal"
|
||||
@@ -34,12 +36,21 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ProgressBar
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/avg_rating"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/avg_num"
|
||||
android:progressDrawable="@drawable/bg_progressbar" />
|
||||
android:indeterminate="false"
|
||||
app:indicatorColor="@color/colorAccent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:trackColor="@android:color/darker_gray"
|
||||
app:trackCornerRadius="10dp"
|
||||
app:trackThickness="8dp"
|
||||
tools:progress="40" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
Reference in New Issue
Block a user