diff --git a/app/src/main/java/com/github/libretube/api/obj/PipedStream.kt b/app/src/main/java/com/github/libretube/api/obj/PipedStream.kt index a6ecf5836..a07898791 100644 --- a/app/src/main/java/com/github/libretube/api/obj/PipedStream.kt +++ b/app/src/main/java/com/github/libretube/api/obj/PipedStream.kt @@ -20,6 +20,7 @@ data class PipedStream( val fps: Int? = null, val audioTrackName: String? = null, val audioTrackId: String? = null, + val contentLength: Long = -1 ) { fun getQualityString(fileName: String): String { return "${fileName}_${quality?.replace(" ", "_")}_$format." + diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt index ba1302c1c..7fa92e9c2 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt @@ -3,6 +3,7 @@ package com.github.libretube.ui.dialogs import android.app.Dialog import android.os.Bundle import android.text.InputFilter +import android.text.format.Formatter import android.util.Log import android.view.View import android.widget.ArrayAdapter @@ -108,7 +109,10 @@ class DownloadDialog( val videoArrayAdapter = ArrayAdapter( requireContext(), R.layout.dropdown_item, - videoStreams.map { "${it.quality} ${it.format}" }.toMutableList().also { + videoStreams.map { + val fileSize = Formatter.formatShortFileSize(context, it.contentLength) + "${it.quality} ${it.format} ($fileSize)" + }.toMutableList().also { it.add(0, getString(R.string.no_video)) }, ) @@ -116,7 +120,10 @@ class DownloadDialog( val audioArrayAdapter = ArrayAdapter( requireContext(), R.layout.dropdown_item, - audioStreams.map { "${it.quality} ${it.format}" }.toMutableList().also { + audioStreams.map { + val fileSize = Formatter.formatShortFileSize(context, it.contentLength) + "${it.quality} ${it.codec} ($fileSize)" + }.toMutableList().also { it.add(0, getString(R.string.no_audio)) }, ) @@ -217,7 +224,11 @@ class DownloadDialog( } } - private fun getStreamSelection(streams: List, quality: String, format: String): Int? { + private fun getStreamSelection( + streams: List, + quality: String, + format: String + ): Int? { if (quality.isBlank()) return null streams.forEachIndexed { index, pipedStream ->