fix: disable cut for live videos

on tap show snackbar "cutting live videos is unsupported"
This commit is contained in:
Max Jakobitsch 2025-05-15 18:22:40 +02:00
parent 476220b3c6
commit 1454e75a9b
4 changed files with 15 additions and 12 deletions

View file

@ -337,6 +337,9 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
if(isUpdatingData){ if(isUpdatingData){
val snack = Snackbar.make(view, context.getString(R.string.please_wait), Snackbar.LENGTH_SHORT) val snack = Snackbar.make(view, context.getString(R.string.please_wait), Snackbar.LENGTH_SHORT)
snack.show() snack.show()
}else if (downloadItem.duration=="0:00"){
val snack = Snackbar.make(view, context.getString(R.string.cut_live_unsupported), Snackbar.LENGTH_SHORT)
snack.show()
}else if (!nonSpecific){ }else if (!nonSpecific){
val snack = Snackbar.make(view, context.getString(R.string.cut_unavailable), Snackbar.LENGTH_SHORT) val snack = Snackbar.make(view, context.getString(R.string.cut_unavailable), Snackbar.LENGTH_SHORT)
snack.setAction(R.string.update){ snack.setAction(R.string.update){

View file

@ -367,6 +367,9 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
if(isUpdatingData){ if(isUpdatingData){
val snack = Snackbar.make(view, context.getString(R.string.please_wait), Snackbar.LENGTH_SHORT) val snack = Snackbar.make(view, context.getString(R.string.please_wait), Snackbar.LENGTH_SHORT)
snack.show() snack.show()
}else if (downloadItem.duration=="0:00"){
val snack = Snackbar.make(view, context.getString(R.string.cut_live_unsupported), Snackbar.LENGTH_SHORT)
snack.show()
}else if (!nonSpecific){ }else if (!nonSpecific){
val snack = Snackbar.make(view, context.getString(R.string.cut_unavailable), Snackbar.LENGTH_SHORT) val snack = Snackbar.make(view, context.getString(R.string.cut_unavailable), Snackbar.LENGTH_SHORT)
snack.setAction(R.string.update){ snack.setAction(R.string.update){

View file

@ -1520,8 +1520,8 @@ object UiUtil {
if (items.size > 1 || items.first().url.isEmpty()) cut.isVisible = false if (items.size > 1 || items.first().url.isEmpty()) cut.isVisible = false
else{ else{
cut.setOnClickListener(null) cut.setOnClickListener(null)
val invalidDuration = items[0].duration == "-1" val duration = items[0].duration
if(items[0].duration.isNotEmpty() && !invalidDuration){ if(duration.isNotEmpty() && duration != "-1" && duration != "0:00"){
val downloadItem = items[0] val downloadItem = items[0]
cut.alpha = 1f cut.alpha = 1f
if (downloadItem.downloadSections.isNotBlank()) cut.text = downloadItem.downloadSections if (downloadItem.downloadSections.isNotBlank()) cut.text = downloadItem.downloadSections
@ -1560,10 +1560,8 @@ object UiUtil {
} }
}else{ }else{
cut.alpha = 0.3f cut.alpha = 0.3f
if (!invalidDuration) { cut.setOnClickListener {
cut.setOnClickListener { cutDisabledClicked()
cutDisabledClicked()
}
} }
} }
} }
@ -1686,8 +1684,8 @@ object UiUtil {
else{ else{
cut.setOnClickListener(null) cut.setOnClickListener(null)
val downloadItem = items[0] val downloadItem = items[0]
val invalidDuration = downloadItem.duration == "-1" val duration = downloadItem.duration
if (downloadItem.duration.isNotEmpty() && !invalidDuration){ if (duration.isNotEmpty() && duration != "-1" && duration != "0:00"){
cut.alpha = 1f cut.alpha = 1f
if (downloadItem.downloadSections.isNotBlank()) cut.text = downloadItem.downloadSections if (downloadItem.downloadSections.isNotBlank()) cut.text = downloadItem.downloadSections
val cutVideoListener = object : VideoCutListener { val cutVideoListener = object : VideoCutListener {
@ -1717,10 +1715,8 @@ object UiUtil {
}else{ }else{
cut.alpha = 0.3f cut.alpha = 0.3f
if (!invalidDuration) { cut.setOnClickListener {
cut.setOnClickListener { cutDisabledClicked()
cutDisabledClicked()
}
} }
} }
} }

View file

@ -476,4 +476,5 @@
<string name="regenerate">Re-generate</string> <string name="regenerate">Re-generate</string>
<string name="generate_potokens_warning">* By enabling this, you need to disable cookies</string> <string name="generate_potokens_warning">* By enabling this, you need to disable cookies</string>
<string name="custom">Custom</string> <string name="custom">Custom</string>
<string name="cut_live_unsupported">Cutting live videos is not supported</string>
</resources> </resources>