Do not display stop icon on uncancelable progress.

This commit is contained in:
Nicholas Tinsley
2023-11-28 11:32:30 -05:00
committed by Cody Henthorne
parent 64457b0235
commit 97c1ace020
2 changed files with 10 additions and 6 deletions

View File

@@ -385,7 +385,8 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
}
binding.secondaryProgressView.startClickListener = currentState.downloadClickedListener
applyFocusableAndClickable(currentState,
applyFocusableAndClickable(
currentState,
listOf(binding.secondaryProgressView, binding.secondaryDetailsText, binding.secondaryBackground),
listOf(binding.primaryProgressView, binding.playVideoButton)
)

View File

@@ -89,7 +89,8 @@ class TransferProgressView @JvmOverloads constructor(
super.onDraw(canvas)
when (currentState) {
State.IN_PROGRESS_CANCELABLE, State.IN_PROGRESS_NON_CANCELABLE -> drawProgress(canvas, progressPercent)
State.IN_PROGRESS_CANCELABLE -> drawProgress(canvas, progressPercent, true)
State.IN_PROGRESS_NON_CANCELABLE -> drawProgress(canvas, progressPercent, false)
State.READY_TO_UPLOAD -> sizeAndDrawDrawable(canvas, uploadDrawable)
State.READY_TO_DOWNLOAD -> sizeAndDrawDrawable(canvas, downloadDrawable)
State.UNINITIALIZED -> Unit
@@ -126,11 +127,13 @@ class TransferProgressView @JvmOverloads constructor(
invalidate()
}
private fun drawProgress(canvas: Canvas, progressPercent: Float) {
stopIconRect.set(0f, 0f, stopIconSize, stopIconSize)
private fun drawProgress(canvas: Canvas, progressPercent: Float, showStopIcon: Boolean) {
if (showStopIcon) {
stopIconRect.set(0f, 0f, stopIconSize, stopIconSize)
canvas.withTranslation(width / 2 - (stopIconSize / 2), height / 2 - (stopIconSize / 2)) {
drawRoundRect(stopIconRect, stopIconCornerRadius, stopIconCornerRadius, stopIconPaint)
canvas.withTranslation(width / 2 - (stopIconSize / 2), height / 2 - (stopIconSize / 2)) {
drawRoundRect(stopIconRect, stopIconCornerRadius, stopIconCornerRadius, stopIconPaint)
}
}
val trackWidthScaled = progressArcStrokeWidth