added format details sheet on long press
This commit is contained in:
parent
a1655810f0
commit
4b433f66b9
9 changed files with 450 additions and 44 deletions
|
|
@ -107,6 +107,10 @@ class ConfigureMultipleDownloadsAdapter(onItemClickListener: OnItemClickListener
|
||||||
val btn = card.findViewById<MaterialButton>(R.id.action_button)
|
val btn = card.findViewById<MaterialButton>(R.id.action_button)
|
||||||
if (btn.hasOnClickListeners()) btn.setOnClickListener(null)
|
if (btn.hasOnClickListeners()) btn.setOnClickListener(null)
|
||||||
|
|
||||||
|
btn.setOnClickListener {
|
||||||
|
onItemClickListener.onButtonClick(item.url)
|
||||||
|
}
|
||||||
|
|
||||||
when(item.type) {
|
when(item.type) {
|
||||||
DownloadViewModel.Type.audio -> {
|
DownloadViewModel.Type.audio -> {
|
||||||
btn.setIconResource(R.drawable.ic_music)
|
btn.setIconResource(R.drawable.ic_music)
|
||||||
|
|
@ -125,7 +129,7 @@ class ConfigureMultipleDownloadsAdapter(onItemClickListener: OnItemClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnItemClickListener {
|
interface OnItemClickListener {
|
||||||
fun onButtonClick(videoURL: String, type: String?)
|
fun onButtonClick(itemURL: String)
|
||||||
fun onCardClick(itemURL: String)
|
fun onCardClick(itemURL: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,10 @@ data class Format(
|
||||||
@SerializedName(value = "filesize", alternate = ["clen", "filesize_approx"])
|
@SerializedName(value = "filesize", alternate = ["clen", "filesize_approx"])
|
||||||
var filesize: Long = 0,
|
var filesize: Long = 0,
|
||||||
@SerializedName(value = "format_note", alternate = ["resolution", "audioQuality"])
|
@SerializedName(value = "format_note", alternate = ["resolution", "audioQuality"])
|
||||||
var format_note: String = ""
|
var format_note: String = "",
|
||||||
|
@SerializedName(value = "fps")
|
||||||
|
var fps: String? = "",
|
||||||
|
@SerializedName(value = "asr", alternate = ["audioSampleRate"])
|
||||||
|
var asr: String? = "",
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
@ -27,23 +27,17 @@ import com.google.android.exoplayer2.DefaultRenderersFactory.EXTENSION_RENDERER_
|
||||||
import com.google.android.exoplayer2.ExoPlayer
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
import com.google.android.exoplayer2.MediaItem.fromUri
|
import com.google.android.exoplayer2.MediaItem.fromUri
|
||||||
import com.google.android.exoplayer2.Player
|
import com.google.android.exoplayer2.Player
|
||||||
import com.google.android.exoplayer2.database.DatabaseProvider
|
|
||||||
import com.google.android.exoplayer2.database.StandaloneDatabaseProvider
|
|
||||||
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo
|
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo
|
||||||
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector
|
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector
|
||||||
|
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
||||||
import com.google.android.exoplayer2.source.MediaSource
|
import com.google.android.exoplayer2.source.MediaSource
|
||||||
import com.google.android.exoplayer2.source.MergingMediaSource
|
import com.google.android.exoplayer2.source.MergingMediaSource
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
|
||||||
import com.google.android.exoplayer2.ui.PlayerView
|
import com.google.android.exoplayer2.ui.PlayerView
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.CacheDataSource
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
|
|
||||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache
|
|
||||||
import com.google.android.exoplayer2.util.MimeTypes
|
import com.google.android.exoplayer2.util.MimeTypes
|
||||||
import com.google.android.exoplayer2.util.Util
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.google.android.material.chip.ChipGroup
|
import com.google.android.material.chip.ChipGroup
|
||||||
|
|
@ -59,7 +53,6 @@ import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.File
|
|
||||||
import java.lang.reflect.Type
|
import java.lang.reflect.Type
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
@ -75,6 +68,8 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
private lateinit var cutSection : ConstraintLayout
|
private lateinit var cutSection : ConstraintLayout
|
||||||
private lateinit var durationText: TextView
|
private lateinit var durationText: TextView
|
||||||
private lateinit var progress : ProgressBar
|
private lateinit var progress : ProgressBar
|
||||||
|
private lateinit var pauseBtn : MaterialButton
|
||||||
|
private lateinit var muteBtn : MaterialButton
|
||||||
private lateinit var rangeSlider : RangeSlider
|
private lateinit var rangeSlider : RangeSlider
|
||||||
private lateinit var fromTextInput : TextInputLayout
|
private lateinit var fromTextInput : TextInputLayout
|
||||||
private lateinit var toTextInput : TextInputLayout
|
private lateinit var toTextInput : TextInputLayout
|
||||||
|
|
@ -92,8 +87,6 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
private lateinit var chapters: List<ChapterItem>
|
private lateinit var chapters: List<ChapterItem>
|
||||||
private lateinit var selectedCuts: MutableList<String>
|
private lateinit var selectedCuts: MutableList<String>
|
||||||
|
|
||||||
private lateinit var cache: SimpleCache
|
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
@ -138,26 +131,6 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
val trackSelector = DefaultTrackSelector()
|
val trackSelector = DefaultTrackSelector()
|
||||||
val loadControl = DefaultLoadControl()
|
val loadControl = DefaultLoadControl()
|
||||||
|
|
||||||
// Specify cache folder, my cache folder named media which is inside getCacheDir.
|
|
||||||
val cacheFolder = File(requireContext().cacheDir, "media")
|
|
||||||
|
|
||||||
// Specify cache size and removing policies
|
|
||||||
val cacheEvictor = LeastRecentlyUsedCacheEvictor(1 * 1024 * 1024) // My cache size will be 1MB and it will automatically remove least recently used files if the size is reached out.
|
|
||||||
|
|
||||||
// Build cache
|
|
||||||
val databaseProvider: DatabaseProvider = StandaloneDatabaseProvider(requireContext())
|
|
||||||
cache = SimpleCache(cacheFolder, cacheEvictor, databaseProvider)
|
|
||||||
|
|
||||||
// Build data source factory with cache enabled, if data is available in cache it will return immediately, otherwise it will open a new connection to get the data.
|
|
||||||
val defaultDataSourceFactory = DefaultDataSourceFactory(
|
|
||||||
requireContext(),
|
|
||||||
Util.getUserAgent(requireContext(), requireContext().getString(R.string.app_name))
|
|
||||||
)
|
|
||||||
|
|
||||||
val cacheDataSourceFactory = CacheDataSource.Factory()
|
|
||||||
.setCache(cache)
|
|
||||||
.setUpstreamDataSourceFactory(defaultDataSourceFactory)
|
|
||||||
|
|
||||||
player = ExoPlayer.Builder(requireContext(), renderersFactory)
|
player = ExoPlayer.Builder(requireContext(), renderersFactory)
|
||||||
.setTrackSelector(trackSelector)
|
.setTrackSelector(trackSelector)
|
||||||
.setLoadControl(loadControl)
|
.setLoadControl(loadControl)
|
||||||
|
|
@ -173,6 +146,8 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
durationText = view.findViewById(R.id.durationText)
|
durationText = view.findViewById(R.id.durationText)
|
||||||
durationText.text = ""
|
durationText.text = ""
|
||||||
progress = view.findViewById(R.id.progress)
|
progress = view.findViewById(R.id.progress)
|
||||||
|
pauseBtn = view.findViewById(R.id.pause)
|
||||||
|
muteBtn = view.findViewById(R.id.mute)
|
||||||
rangeSlider = view.findViewById(R.id.rangeSlider)
|
rangeSlider = view.findViewById(R.id.rangeSlider)
|
||||||
fromTextInput = view.findViewById(R.id.from_textinput)
|
fromTextInput = view.findViewById(R.id.from_textinput)
|
||||||
toTextInput = view.findViewById(R.id.to_textinput)
|
toTextInput = view.findViewById(R.id.to_textinput)
|
||||||
|
|
@ -218,10 +193,10 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
if (data.isEmpty()) throw Exception("No Streaming URL found!")
|
if (data.isEmpty()) throw Exception("No Streaming URL found!")
|
||||||
if (data.size == 2){
|
if (data.size == 2){
|
||||||
val audioSource : MediaSource =
|
val audioSource : MediaSource =
|
||||||
ProgressiveMediaSource.Factory(cacheDataSourceFactory)
|
DefaultMediaSourceFactory(requireContext())
|
||||||
.createMediaSource(fromUri(Uri.parse(data[0])))
|
.createMediaSource(fromUri(Uri.parse(data[0])))
|
||||||
val videoSource: MediaSource =
|
val videoSource: MediaSource =
|
||||||
ProgressiveMediaSource.Factory(cacheDataSourceFactory)
|
DefaultMediaSourceFactory(requireContext())
|
||||||
.createMediaSource(fromUri(Uri.parse(data[1])))
|
.createMediaSource(fromUri(Uri.parse(data[1])))
|
||||||
(player as ExoPlayer).setMediaSource(MergingMediaSource(videoSource, audioSource))
|
(player as ExoPlayer).setMediaSource(MergingMediaSource(videoSource, audioSource))
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -256,9 +231,23 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
}
|
}
|
||||||
|
|
||||||
videoView.setOnClickListener {
|
videoView.setOnClickListener {
|
||||||
if (player.isPlaying) player.pause()
|
if (player.isPlaying){
|
||||||
|
player.pause()
|
||||||
|
pauseBtn.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
player.play()
|
player.play()
|
||||||
|
pauseBtn.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
muteBtn.setOnClickListener {
|
||||||
|
if (player.volume > 0F) {
|
||||||
|
muteBtn.setIconResource(R.drawable.baseline_music_off_24)
|
||||||
|
player.volume = 0F
|
||||||
|
}else {
|
||||||
|
muteBtn.setIconResource(R.drawable.ic_music)
|
||||||
|
player.volume = 1F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -572,7 +561,6 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
||||||
private fun cleanUp(){
|
private fun cleanUp(){
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
player.stop()
|
player.stop()
|
||||||
cache.release()
|
|
||||||
parentFragmentManager.beginTransaction().remove(parentFragmentManager.findFragmentByTag("cutVideoSheet")!!).commit()
|
parentFragmentManager.beginTransaction().remove(parentFragmentManager.findFragmentByTag("cutVideoSheet")!!).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -308,8 +308,63 @@ class DownloadMultipleBottomSheetDialog(private var results: List<ResultItem?>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onButtonClick(videoURL: String, type: String?) {
|
override fun onButtonClick(itemURL: String) {
|
||||||
TODO("Not yet implemented")
|
lifecycleScope.launch {
|
||||||
|
val item = items.find { it.url == itemURL } ?: return@launch
|
||||||
|
val position = items.indexOf(item)
|
||||||
|
|
||||||
|
val bottomSheet = BottomSheetDialog(requireContext())
|
||||||
|
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
|
bottomSheet.setContentView(R.layout.download_type_sheet)
|
||||||
|
|
||||||
|
// BUTTON ----------------------------------
|
||||||
|
val audio = bottomSheet.findViewById<TextView>(R.id.audio)
|
||||||
|
val video = bottomSheet.findViewById<TextView>(R.id.video)
|
||||||
|
val command = bottomSheet.findViewById<TextView>(R.id.command)
|
||||||
|
|
||||||
|
withContext(Dispatchers.IO){
|
||||||
|
val nr = commandTemplateViewModel.getTotalNumber()
|
||||||
|
if(nr == 0){
|
||||||
|
command!!.visibility = View.GONE
|
||||||
|
}else{
|
||||||
|
command!!.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
audio!!.setOnClickListener {
|
||||||
|
items[position] = downloadViewModel.switchDownloadType(listOf(item), DownloadViewModel.Type.audio).first()
|
||||||
|
listAdapter.submitList(items.toList())
|
||||||
|
listAdapter.notifyItemChanged(position)
|
||||||
|
bottomSheet.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
video!!.setOnClickListener {
|
||||||
|
items[position] = downloadViewModel.switchDownloadType(listOf(item), DownloadViewModel.Type.video).first()
|
||||||
|
listAdapter.submitList(items.toList())
|
||||||
|
listAdapter.notifyItemChanged(position)
|
||||||
|
bottomSheet.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
command!!.setOnClickListener {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
items[position] = withContext(Dispatchers.IO){
|
||||||
|
downloadViewModel.switchDownloadType(listOf(item), DownloadViewModel.Type.command).first()
|
||||||
|
}
|
||||||
|
listAdapter.submitList(items.toList())
|
||||||
|
listAdapter.notifyItemChanged(position)
|
||||||
|
bottomSheet.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bottomSheet.show()
|
||||||
|
val displayMetrics = DisplayMetrics()
|
||||||
|
requireActivity().windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||||
|
bottomSheet.behavior.peekHeight = displayMetrics.heightPixels
|
||||||
|
bottomSheet.window!!.setLayout(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCardClick(itemURL: String) {
|
override fun onCardClick(itemURL: String) {
|
||||||
|
|
|
||||||
|
|
@ -6,27 +6,36 @@ import android.app.Dialog
|
||||||
import android.content.*
|
import android.content.*
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.text.format.DateFormat
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.Window
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.deniscerri.ytdlnis.R
|
import com.deniscerri.ytdlnis.R
|
||||||
import com.deniscerri.ytdlnis.database.models.DownloadItem
|
import com.deniscerri.ytdlnis.database.models.DownloadItem
|
||||||
import com.deniscerri.ytdlnis.database.models.Format
|
import com.deniscerri.ytdlnis.database.models.Format
|
||||||
|
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
|
||||||
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel.Type
|
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel.Type
|
||||||
import com.deniscerri.ytdlnis.util.FileUtil
|
import com.deniscerri.ytdlnis.util.FileUtil
|
||||||
import com.deniscerri.ytdlnis.util.InfoUtil
|
import com.deniscerri.ytdlnis.util.InfoUtil
|
||||||
import com.deniscerri.ytdlnis.util.UiUtil
|
import com.deniscerri.ytdlnis.util.UiUtil
|
||||||
import com.facebook.shimmer.ShimmerFrameLayout
|
import com.facebook.shimmer.ShimmerFrameLayout
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
|
@ -193,17 +202,108 @@ class FormatSelectionBottomSheetDialog(private val items: List<DownloadItem?>, p
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
formatItem.setOnLongClickListener {
|
formatItem.setOnLongClickListener {
|
||||||
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val bottomSheet = BottomSheetDialog(requireContext())
|
||||||
val clip = ClipData.newPlainText("format_id", format.format_id)
|
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
clipboard.setPrimaryClip(clip)
|
bottomSheet.setContentView(R.layout.format_details_sheet)
|
||||||
Toast.makeText(context, requireContext().getString(R.string.formatid_copied_to_clipboard), Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
val formatIdParent = bottomSheet.findViewById<LinearLayout>(R.id.format_id_parent)
|
||||||
|
val containerParent = bottomSheet.findViewById<LinearLayout>(R.id.container_parent)
|
||||||
|
val codecParent = bottomSheet.findViewById<LinearLayout>(R.id.codec_parent)
|
||||||
|
val filesizeParent = bottomSheet.findViewById<LinearLayout>(R.id.filesize_parent)
|
||||||
|
val formatnoteParent = bottomSheet.findViewById<LinearLayout>(R.id.format_note_parent)
|
||||||
|
val fpsParent = bottomSheet.findViewById<LinearLayout>(R.id.fps_parent)
|
||||||
|
val asrParent = bottomSheet.findViewById<LinearLayout>(R.id.asr_parent)
|
||||||
|
|
||||||
|
if (format.format_id.isBlank()) formatIdParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
formatIdParent?.findViewById<TextView>(R.id.format_id_value)?.text = format.format_id
|
||||||
|
formatIdParent?.setOnClickListener {
|
||||||
|
copyToClipboard(format.format_note)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (format.container.isBlank()) containerParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
containerParent?.findViewById<TextView>(R.id.container_value)?.text = format.container
|
||||||
|
containerParent?.setOnClickListener {
|
||||||
|
copyToClipboard(format.container)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val codecField =
|
||||||
|
if (format.encoding != "") {
|
||||||
|
format.encoding.uppercase()
|
||||||
|
}else if (format.vcodec != "none" && format.vcodec != ""){
|
||||||
|
format.vcodec.uppercase()
|
||||||
|
} else {
|
||||||
|
format.acodec.uppercase()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codecField.isBlank()) codecParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
codecParent?.findViewById<TextView>(R.id.codec_value)?.text = codecField
|
||||||
|
codecParent?.setOnClickListener {
|
||||||
|
copyToClipboard(codecField)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.filesize != 0L) filesizeParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
filesizeParent?.findViewById<TextView>(R.id.filesize_value)?.text = fileUtil.convertFileSize(format.filesize)
|
||||||
|
filesizeParent?.setOnClickListener {
|
||||||
|
copyToClipboard(fileUtil.convertFileSize(format.filesize))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.format_note.isBlank()) formatnoteParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
formatnoteParent?.findViewById<TextView>(R.id.format_note_value)?.text = format.format_note
|
||||||
|
formatnoteParent?.setOnClickListener {
|
||||||
|
copyToClipboard(format.format_note)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.fps.isNullOrBlank()) fpsParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
fpsParent?.findViewById<TextView>(R.id.fps_value)?.text = format.fps
|
||||||
|
fpsParent?.setOnClickListener {
|
||||||
|
copyToClipboard(format.fps!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.asr.isNullOrBlank()) asrParent?.visibility = View.GONE
|
||||||
|
else {
|
||||||
|
asrParent?.findViewById<TextView>(R.id.asr_value)?.text = format.asr
|
||||||
|
asrParent?.setOnClickListener {
|
||||||
|
copyToClipboard(format.asr!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bottomSheet.show()
|
||||||
|
val displayMetrics = DisplayMetrics()
|
||||||
|
requireActivity().windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||||
|
bottomSheet.behavior.peekHeight = displayMetrics.heightPixels
|
||||||
|
bottomSheet.window!!.setLayout(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
)
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
linearLayout.addView(formatItem)
|
linearLayout.addView(formatItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun copyToClipboard(text: String){
|
||||||
|
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clip = ClipData.newPlainText(text, text)
|
||||||
|
clipboard.setPrimaryClip(clip)
|
||||||
|
Toast.makeText(context, requireContext().getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCancel(dialog: DialogInterface) {
|
override fun onCancel(dialog: DialogInterface) {
|
||||||
|
|
|
||||||
5
app/src/main/res/drawable/baseline_music_off_24.xml
Normal file
5
app/src/main/res/drawable/baseline_music_off_24.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="?android:colorAccent" android:pathData="M4.27,3L3,4.27l9,9v0.28c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4v-1.73L19.73,21 21,19.73 4.27,3zM14,7h4V3h-6v5.18l2,2z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -37,6 +37,34 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/pause"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:clickable="false"
|
||||||
|
app:iconSize="50dp"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
app:iconTint="?android:colorAccent"
|
||||||
|
app:icon="@drawable/exomedia_ic_play_arrow_white"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:translationZ="10dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/frame_layout"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/mute"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:icon="@drawable/ic_music"
|
||||||
|
app:iconSize="30dp"
|
||||||
|
app:iconTint="?android:colorAccent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/frame_layout"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/frame_layout" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/durationText"
|
android:id="@+id/durationText"
|
||||||
|
|
|
||||||
217
app/src/main/res/layout/format_details_sheet.xml
Normal file
217
app/src/main/res/layout/format_details_sheet.xml
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/format"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/format_id_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:text="@string/format_id"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/format_id_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/container_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:text="@string/container"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/container_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/codec_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:text="@string/codec"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/codec_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/filesize_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:text="@string/file_size"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/filesize_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/format_note_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:text="@string/title"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/format_note_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/fps_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:text="FPS"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fps_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/asr_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:weightSum="100"
|
||||||
|
android:paddingHorizontal="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:text="@string/audio_samplerate"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/asr_value"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -219,4 +219,8 @@
|
||||||
<string name="format_filtering_hint">All items must be of the same type to use this option</string>
|
<string name="format_filtering_hint">All items must be of the same type to use this option</string>
|
||||||
<string name="preferred_home_screen">Preferred Home Screen</string>
|
<string name="preferred_home_screen">Preferred Home Screen</string>
|
||||||
<string name="undo">Undo</string>
|
<string name="undo">Undo</string>
|
||||||
|
<string name="format_id">Format ID</string>
|
||||||
|
<string name="codec">Codec</string>
|
||||||
|
<string name="audio_samplerate">Audio Sample Rate</string>
|
||||||
|
<string name="copied_to_clipboard">Copied To Clipboard</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in a new issue