mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge pull request #3842 from Bnyro/master
Show file size in download dialog
This commit is contained in:
commit
570800685f
@ -20,6 +20,7 @@ data class PipedStream(
|
|||||||
val fps: Int? = null,
|
val fps: Int? = null,
|
||||||
val audioTrackName: String? = null,
|
val audioTrackName: String? = null,
|
||||||
val audioTrackId: String? = null,
|
val audioTrackId: String? = null,
|
||||||
|
val contentLength: Long = -1
|
||||||
) {
|
) {
|
||||||
fun getQualityString(fileName: String): String {
|
fun getQualityString(fileName: String): String {
|
||||||
return "${fileName}_${quality?.replace(" ", "_")}_$format." +
|
return "${fileName}_${quality?.replace(" ", "_")}_$format." +
|
||||||
|
@ -3,6 +3,7 @@ package com.github.libretube.ui.dialogs
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.InputFilter
|
import android.text.InputFilter
|
||||||
|
import android.text.format.Formatter
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
@ -108,7 +109,10 @@ class DownloadDialog(
|
|||||||
val videoArrayAdapter = ArrayAdapter(
|
val videoArrayAdapter = ArrayAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
R.layout.dropdown_item,
|
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))
|
it.add(0, getString(R.string.no_video))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -116,7 +120,10 @@ class DownloadDialog(
|
|||||||
val audioArrayAdapter = ArrayAdapter(
|
val audioArrayAdapter = ArrayAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
R.layout.dropdown_item,
|
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))
|
it.add(0, getString(R.string.no_audio))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -217,7 +224,11 @@ class DownloadDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStreamSelection(streams: List<PipedStream>, quality: String, format: String): Int? {
|
private fun getStreamSelection(
|
||||||
|
streams: List<PipedStream>,
|
||||||
|
quality: String,
|
||||||
|
format: String
|
||||||
|
): Int? {
|
||||||
if (quality.isBlank()) return null
|
if (quality.isBlank()) return null
|
||||||
|
|
||||||
streams.forEachIndexed { index, pipedStream ->
|
streams.forEachIndexed { index, pipedStream ->
|
||||||
|
Loading…
Reference in New Issue
Block a user