added progress indicators to download dialogs

This commit is contained in:
X1nto 2021-02-28 15:49:06 +04:00
parent ad299ed96d
commit ad17c6dfec
4 changed files with 66 additions and 21 deletions

View File

@ -1,5 +1,6 @@
package com.vanced.manager.ui.dialogs
import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@ -80,12 +81,14 @@ class AppDownloadDialog : BindingDialogFragment<DialogAppDownloadBinding>() {
}
}
@SuppressLint("SetTextI18n")
private fun DialogAppDownloadBinding.bindDownloadProgress() {
downloadProgress.observe(viewLifecycleOwner) {
appDownloadProgressbar.progress = it
appDownloadProgress.text = "$it%"
}
installing.observe(viewLifecycleOwner) { installing ->
appDownloadProgressbar.isVisible = !installing
appDownloadProgressbarContainer.isVisible = !installing
appInstallProgressbar.isVisible = installing
appDownloadFile.isVisible = !installing
appDownloadCancel.isEnabled = !installing

View File

@ -1,5 +1,6 @@
package com.vanced.manager.ui.dialogs
import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@ -77,10 +78,12 @@ class ManagerUpdateDialog : BindingDialogFragment<DialogManagerUpdateBinding>()
}
}
@SuppressLint("SetTextI18n")
private fun DialogManagerUpdateBinding.bindDownloadProgress() {
downloadProgress.observe(viewLifecycleOwner) {
managerUpdateProgressbar.progress = it
managerUpdateProgressbar.isVisible = it != 0
managerUpdateProgressbarContainer.isVisible = it != 0
managerUpdateProgress.text = "$it%"
}
}

View File

@ -17,18 +17,39 @@
<TextView
android:id="@+id/app_download_patient"
style="@style/DialogCardSubtitle"
android:layout_height="wrap_content"
android:layout_below="@id/app_download_header"
android:text="@string/please_be_patient"
style="@style/DialogCardSubtitle" />
android:layout_marginBottom="18dp"
android:text="@string/please_be_patient" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/app_download_progressbar"
<RelativeLayout
android:id="@+id/app_download_progressbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/app_download_patient"
android:layout_marginTop="24dp"
app:trackCornerRadius="15dp"
tools:progress="10" />
android:layout_below="@id/app_download_patient">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/app_download_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:trackCornerRadius="15dp"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/app_download_progress"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
tools:progress="10" />
<TextView
android:id="@+id/app_download_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:textSize="15sp"
tools:text="20%" />
</RelativeLayout>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/app_install_progressbar"
@ -36,8 +57,7 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@id/app_download_progressbar"
android:layout_marginTop="24dp"
android:layout_below="@id/app_download_progressbar_container"
android:indeterminate="true"
app:trackCornerRadius="15dp" />
@ -45,7 +65,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/app_install_progressbar"
android:layout_marginTop="8dp">
android:layout_marginTop="6dp">
<TextView
android:id="@+id/app_download_file"

View File

@ -21,23 +21,42 @@
android:text="@string/checking_updates"
style="@style/DialogCardSubtitle"/>
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/manager_update_progressbar"
<RelativeLayout
android:id="@+id/manager_update_progressbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/manager_update_patient"
android:layout_marginTop="32dp"
android:paddingBottom="8dp"
app:trackCornerRadius="15dp"
tools:progress="10"
tools:visibility="visible" />
android:layout_marginTop="18dp">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/manager_update_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:trackCornerRadius="15dp"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/manager_update_progress"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
tools:progress="10" />
<TextView
android:id="@+id/manager_update_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:textSize="15sp"
tools:text="20%" />
</RelativeLayout>
<com.vanced.manager.ui.core.ThemedOutlinedMaterialButton
android:id="@+id/manager_update_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@id/manager_update_progressbar"
android:layout_below="@id/manager_update_progressbar_container"
android:layout_marginTop="8dp"
android:text="@string/cancel"
style="@style/OutlinedButtonStyle" />