fix #2565, try fixing the video editor

This commit is contained in:
tibbi 2022-07-29 22:10:02 +02:00
parent 41697d6a46
commit 997f7e3ba8

View file

@ -36,7 +36,6 @@ import ly.img.android.pesdk.ui.panels.item.PersonalStickerAddItem
import ly.img.android.pesdk.ui.panels.item.ToggleAspectItem import ly.img.android.pesdk.ui.panels.item.ToggleAspectItem
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
import java.io.OutputStream
class NewVideoEditActivity : SimpleActivity() { class NewVideoEditActivity : SimpleActivity() {
private val VESDK_EDIT_VIDEO = 1 private val VESDK_EDIT_VIDEO = 1
@ -107,6 +106,7 @@ class NewVideoEditActivity : SimpleActivity() {
val extras = resultData?.extras val extras = resultData?.extras
val resultPath = extras?.get(RESULT_URI)?.toString() ?: "" val resultPath = extras?.get(RESULT_URI)?.toString() ?: ""
val sourcePath = Uri.decode(extras?.get(SOURCE_URI)?.toString() ?: "") val sourcePath = Uri.decode(extras?.get(SOURCE_URI)?.toString() ?: "")
val settings = extras?.getParcelable<SettingsList>(SETTINGS_LIST) val settings = extras?.getParcelable<SettingsList>(SETTINGS_LIST)
if (settings != null) { if (settings != null) {
val brush = settings.getSettingsModel(BrushSettings::class.java) val brush = settings.getSettingsModel(BrushSettings::class.java)
@ -137,15 +137,14 @@ class NewVideoEditActivity : SimpleActivity() {
sourceFileLastModified = File(source).lastModified() sourceFileLastModified = File(source).lastModified()
handleFileOverwriting(destinationFilePath) { handleFileOverwriting(destinationFilePath) {
var inputStream: InputStream? = null
var outputStream: OutputStream? = null
try { try {
inputStream = contentResolver.openInputStream(Uri.parse(resultPath)) val inputStream = contentResolver.openInputStream(Uri.parse(resultPath))
outputStream = getFileOutputStreamSync(destinationFilePath, destinationFilePath.getMimeType()) val outputStream = getFileOutputStreamSync(destinationFilePath, destinationFilePath.getMimeType())
inputStream!!.copyTo(outputStream!!) inputStream?.use {
outputStream.flush() outputStream?.use {
inputStream.close() inputStream.copyTo(outputStream)
outputStream.close() }
}
if (config.keepLastModified) { if (config.keepLastModified) {
// add 1 s to the last modified time to properly update the thumbnail // add 1 s to the last modified time to properly update the thumbnail
@ -153,18 +152,15 @@ class NewVideoEditActivity : SimpleActivity() {
} }
val paths = arrayListOf(destinationFilePath) val paths = arrayListOf(destinationFilePath)
rescanPaths(arrayListOf(destinationFilePath)) { rescanPaths(paths) {
fixDateTaken(paths, false) fixDateTaken(paths, false)
}
setResult(Activity.RESULT_OK, intent) setResult(Activity.RESULT_OK)
toast(R.string.file_edited_successfully) toast(R.string.file_edited_successfully)
finish() finish()
}
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} finally {
inputStream?.close()
outputStream?.close()
} }
} }
} }
@ -285,7 +281,6 @@ class NewVideoEditActivity : SimpleActivity() {
getSettingsModel(UiConfigTheme::class.java).theme = theme getSettingsModel(UiConfigTheme::class.java).theme = theme
configure<VideoEditorSaveSettings> { configure<VideoEditorSaveSettings> {
it.allowFastTrim = true
it.allowOrientationMatrixMetadata = true it.allowOrientationMatrixMetadata = true
it.setOutputToTemp() it.setOutputToTemp()
it.outputMode = OutputMode.EXPORT_IF_NECESSARY it.outputMode = OutputMode.EXPORT_IF_NECESSARY