From 997f7e3ba819d2315672f121160cb4ae52f7175a Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Jul 2022 22:10:02 +0200 Subject: [PATCH] fix #2565, try fixing the video editor --- .../pro/activities/NewVideoEditActivity.kt | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt index c96ea00e1..b73a54ae9 100644 --- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt +++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt @@ -36,7 +36,6 @@ import ly.img.android.pesdk.ui.panels.item.PersonalStickerAddItem import ly.img.android.pesdk.ui.panels.item.ToggleAspectItem import java.io.File import java.io.InputStream -import java.io.OutputStream class NewVideoEditActivity : SimpleActivity() { private val VESDK_EDIT_VIDEO = 1 @@ -107,6 +106,7 @@ class NewVideoEditActivity : SimpleActivity() { val extras = resultData?.extras val resultPath = extras?.get(RESULT_URI)?.toString() ?: "" val sourcePath = Uri.decode(extras?.get(SOURCE_URI)?.toString() ?: "") + val settings = extras?.getParcelable(SETTINGS_LIST) if (settings != null) { val brush = settings.getSettingsModel(BrushSettings::class.java) @@ -137,15 +137,14 @@ class NewVideoEditActivity : SimpleActivity() { sourceFileLastModified = File(source).lastModified() handleFileOverwriting(destinationFilePath) { - var inputStream: InputStream? = null - var outputStream: OutputStream? = null try { - inputStream = contentResolver.openInputStream(Uri.parse(resultPath)) - outputStream = getFileOutputStreamSync(destinationFilePath, destinationFilePath.getMimeType()) - inputStream!!.copyTo(outputStream!!) - outputStream.flush() - inputStream.close() - outputStream.close() + val inputStream = contentResolver.openInputStream(Uri.parse(resultPath)) + val outputStream = getFileOutputStreamSync(destinationFilePath, destinationFilePath.getMimeType()) + inputStream?.use { + outputStream?.use { + inputStream.copyTo(outputStream) + } + } if (config.keepLastModified) { // add 1 s to the last modified time to properly update the thumbnail @@ -153,18 +152,15 @@ class NewVideoEditActivity : SimpleActivity() { } val paths = arrayListOf(destinationFilePath) - rescanPaths(arrayListOf(destinationFilePath)) { + rescanPaths(paths) { fixDateTaken(paths, false) - } - setResult(Activity.RESULT_OK, intent) - toast(R.string.file_edited_successfully) - finish() + setResult(Activity.RESULT_OK) + toast(R.string.file_edited_successfully) + finish() + } } catch (e: Exception) { showErrorToast(e) - } finally { - inputStream?.close() - outputStream?.close() } } } @@ -285,7 +281,6 @@ class NewVideoEditActivity : SimpleActivity() { getSettingsModel(UiConfigTheme::class.java).theme = theme configure { - it.allowFastTrim = true it.allowOrientationMatrixMetadata = true it.setOutputToTemp() it.outputMode = OutputMode.EXPORT_IF_NECESSARY