mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Clamp videos to max duration after media quality change.
Fixes #13930 Resolves #13932
This commit is contained in:
@@ -335,6 +335,14 @@ class MediaSelectionViewModel(
|
|||||||
|
|
||||||
store.update { it.copy(quality = sentMediaQuality, isPreUploadEnabled = false) }
|
store.update { it.copy(quality = sentMediaQuality, isPreUploadEnabled = false) }
|
||||||
repository.uploadRepository.cancelAllUploads()
|
repository.uploadRepository.cancelAllUploads()
|
||||||
|
|
||||||
|
store.state.selectedMedia.forEach { mediaItem ->
|
||||||
|
if (MediaUtil.isVideoType(mediaItem.contentType) && MediaConstraints.isVideoTranscodeAvailable()) {
|
||||||
|
val uri = mediaItem.uri
|
||||||
|
val data = store.state.getOrCreateVideoTrimData(uri)
|
||||||
|
onEditVideoDuration(totalDurationUs = data.totalInputDurationUs, startTimeUs = data.startTimeUs, endTimeUs = data.endTimeUs, touchEnabled = true, uri = uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setMessage(text: CharSequence?) {
|
fun setMessage(text: CharSequence?) {
|
||||||
@@ -345,9 +353,9 @@ class MediaSelectionViewModel(
|
|||||||
store.update { it.copy(viewOnceToggleState = it.viewOnceToggleState.next()) }
|
store.update { it.copy(viewOnceToggleState = it.viewOnceToggleState.next()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEditVideoDuration(totalDurationUs: Long, startTimeUs: Long, endTimeUs: Long, touchEnabled: Boolean) {
|
fun onEditVideoDuration(totalDurationUs: Long, startTimeUs: Long, endTimeUs: Long, touchEnabled: Boolean, uri: Uri? = store.state.focusedMedia?.uri) {
|
||||||
|
if (uri == null) return
|
||||||
store.update {
|
store.update {
|
||||||
val uri = it.focusedMedia?.uri ?: return@update it
|
|
||||||
val data = it.getOrCreateVideoTrimData(uri)
|
val data = it.getOrCreateVideoTrimData(uri)
|
||||||
val clampedStartTime = max(startTimeUs, 0)
|
val clampedStartTime = max(startTimeUs, 0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user