|
@@ -29,6 +29,7 @@ import com.bomostory.sceneeditmodule.screen.view.AudioTrackGroupView
|
|
|
import com.bomostory.sceneeditmodule.screen.view.MovieSelectView
|
|
|
import com.bomostory.sceneeditmodule.share.ExportPdfDialog
|
|
|
import com.bomostory.sceneeditmodule.share.ShareDialog
|
|
|
+import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
|
import com.bomostory.sceneeditmodule.utils.MoviePlayerV2
|
|
|
import com.bomostory.sceneeditmodule.utils.MusicPlayerV2
|
|
|
import com.bomostory.sceneeditmodule.utils.Utils
|
|
@@ -356,8 +357,17 @@ class MovieEditActivity : AppCompatActivity(),
|
|
|
}
|
|
|
|
|
|
private fun onClickSaveAndShareBtn(view: View) {
|
|
|
+ saveMovie(object : OnMovieSavedListener {
|
|
|
+ override fun onSaved(file: File) {
|
|
|
+ showShareDialog(file)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun showShareDialog(videoFile: File) {
|
|
|
shareDialog.apply {
|
|
|
- project = viewModel.project ?: return@apply
|
|
|
+ val p = viewModel.project ?: return
|
|
|
+ project = p
|
|
|
storyPeriod = viewModel.storyPeriodLiveData.value ?: 0
|
|
|
dismissListener = DialogInterface.OnDismissListener {
|
|
|
moviePlayer.moviePlayListener = editMoviePlayListener
|
|
@@ -379,44 +389,36 @@ class MovieEditActivity : AppCompatActivity(),
|
|
|
}
|
|
|
}
|
|
|
onClickBomo = Runnable {
|
|
|
- saveMovie(object : OnMovieSavedListener {
|
|
|
- override fun onSaved(file: File) {
|
|
|
- val pd = ProgressDialog(this@MovieEditActivity).apply {
|
|
|
- isCancelable = false
|
|
|
- }
|
|
|
- viewModel.uploadVideo(this@MovieEditActivity, file, project)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .doOnSubscribe { pd.show() }
|
|
|
- .doFinally { pd.dismiss() }
|
|
|
- .subscribe({
|
|
|
- val context = this@MovieEditActivity
|
|
|
- when (it.errorCode) {
|
|
|
- 4013 -> Toast.makeText(context, R.string.share_dialog_upload_failed, Toast.LENGTH_SHORT).show()
|
|
|
- else -> {
|
|
|
- Toast.makeText(context, R.string.share_dialog_upload_suc, Toast.LENGTH_SHORT).show()
|
|
|
- }
|
|
|
- }
|
|
|
- }, {
|
|
|
- Toast.makeText(this@MovieEditActivity, R.string.share_dialog_upload_failed, Toast.LENGTH_SHORT).show()
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ val pd = ProgressDialog(this@MovieEditActivity).apply {
|
|
|
+ setCancelable(false)
|
|
|
+ }
|
|
|
+ viewModel.uploadVideo(this@MovieEditActivity, videoFile, project)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .doOnSubscribe { pd.show() }
|
|
|
+ .doFinally { pd.dismiss() }
|
|
|
+ .subscribe({
|
|
|
+ val context = this@MovieEditActivity
|
|
|
+ when (it.errorCode) {
|
|
|
+ 4013 -> Toast.makeText(context, R.string.share_dialog_upload_failed, Toast.LENGTH_SHORT).show()
|
|
|
+ else -> {
|
|
|
+ Toast.makeText(context, R.string.share_dialog_upload_suc, Toast.LENGTH_SHORT).show()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ Toast.makeText(this@MovieEditActivity, R.string.share_dialog_upload_failed, Toast.LENGTH_SHORT).show()
|
|
|
+ })
|
|
|
}
|
|
|
onClickMore = Runnable {
|
|
|
- saveMovie(object : OnMovieSavedListener {
|
|
|
- override fun onSaved(file: File) {
|
|
|
- val authority = "$packageName"
|
|
|
- val context = this@MovieEditActivity
|
|
|
- val uri = FileProvider.getUriForFile(context, authority, file)
|
|
|
-
|
|
|
- val intent = Intent(Intent.ACTION_SEND)
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
|
|
|
- intent.type = "video/mp4"
|
|
|
- intent.putExtra(Intent.EXTRA_STREAM, uri)
|
|
|
- startActivity(Intent.createChooser(intent, ""))
|
|
|
- }
|
|
|
- })
|
|
|
+ val authority = "$packageName"
|
|
|
+ val context = this@MovieEditActivity
|
|
|
+ val uri = FileProvider.getUriForFile(context, authority, videoFile)
|
|
|
+
|
|
|
+ val intent = Intent(Intent.ACTION_SEND)
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
|
|
|
+ intent.type = "video/mp4"
|
|
|
+ intent.putExtra(Intent.EXTRA_STREAM, uri)
|
|
|
+ startActivity(Intent.createChooser(intent, ""))
|
|
|
}
|
|
|
onClickExportPdf = Runnable { onClickExportPdf() }
|
|
|
onClickPlay = Runnable {
|
|
@@ -483,9 +485,13 @@ class MovieEditActivity : AppCompatActivity(),
|
|
|
setCancelable(false)
|
|
|
}
|
|
|
|
|
|
- val fileName = "test${System.currentTimeMillis()}.mp4"
|
|
|
- val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
|
|
|
val project = viewModel.project ?: return
|
|
|
+ val outputFile = FileUtils.getVideoFile(project)
|
|
|
+
|
|
|
+ if (outputFile.exists()) {
|
|
|
+ outputFile.delete()
|
|
|
+ }
|
|
|
+ outputFile.createNewFile()
|
|
|
|
|
|
SuperMovieMaker().make(
|
|
|
this,
|