|
@@ -9,7 +9,9 @@ import android.content.Intent
|
|
|
import android.graphics.Bitmap
|
|
|
import android.graphics.BitmapFactory
|
|
|
import android.graphics.Canvas
|
|
|
+import android.net.Uri
|
|
|
import android.os.Bundle
|
|
|
+import android.provider.MediaStore
|
|
|
import android.support.v7.app.AppCompatActivity
|
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
|
import android.support.v7.widget.RecyclerView
|
|
@@ -24,10 +26,6 @@ import com.bomostory.sceneeditmodule.navigationbar.actor.SelectActorView
|
|
|
import com.bomostory.sceneeditmodule.navigationbar.brush.BrushView
|
|
|
import com.bomostory.sceneeditmodule.navigationbar.dialogue.DialogueView
|
|
|
import com.bomostory.sceneeditmodule.screen.movie.MovieEditActivity
|
|
|
-import com.bomostory.sceneeditmodule.screen.view.EditActorView
|
|
|
-import com.bomostory.sceneeditmodule.screen.view.LayerView
|
|
|
-import com.bomostory.sceneeditmodule.screen.view.OnTouchBoMoSceneListener
|
|
|
-import com.bomostory.sceneeditmodule.screen.view.OnTouchSceneListener
|
|
|
import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
|
import com.example.tfat.myapplication.navigationbar.NavigationBarView
|
|
|
import com.example.tfat.myapplication.navigationbar.RecordFinishView
|
|
@@ -47,13 +45,13 @@ import com.bomostory.sceneeditmodule.layermanagement.ItemTouchHelpCallback
|
|
|
import com.bomostory.sceneeditmodule.navigationbar.actor.ObjectView
|
|
|
import com.bomostory.sceneeditmodule.navigationbar.actor.NonInterceptTouchRecycleView
|
|
|
import com.bomostory.sceneeditmodule.screen.draw.DrawActivity
|
|
|
+import com.bomostory.sceneeditmodule.screen.view.*
|
|
|
import com.example.tfat.myapplication.navigationbar.scene.*
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
|
import io.reactivex.schedulers.Schedulers
|
|
|
import kotlinx.android.synthetic.main.actor_select_view.view.*
|
|
|
import kotlinx.android.synthetic.main.add_scene_view.view.*
|
|
|
import kotlinx.android.synthetic.main.layer_management_fragment.*
|
|
|
-import kotlinx.android.synthetic.main.layer_management_fragment.view.*
|
|
|
import kotlinx.android.synthetic.main.navigation_bar_view.view.*
|
|
|
import kotlinx.android.synthetic.main.popupview_adjustment_dialog.view.*
|
|
|
import kotlinx.android.synthetic.main.popupview_color_dialog.view.*
|
|
@@ -61,6 +59,7 @@ import kotlinx.android.synthetic.main.popupview_setting.view.*
|
|
|
import kotlinx.android.synthetic.main.popupview_start_over.view.*
|
|
|
import kotlinx.android.synthetic.main.replace_scene_view.view.*
|
|
|
import kotlinx.android.synthetic.main.scene_control_view.view.*
|
|
|
+import java.io.ByteArrayOutputStream
|
|
|
import java.io.File
|
|
|
import java.util.*
|
|
|
import java.util.concurrent.CopyOnWriteArrayList
|
|
@@ -70,7 +69,7 @@ import kotlin.collections.ArrayList
|
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
|
OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
|
|
|
OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange, EditTextDialog.OnSetDialogFinish,
|
|
|
- BrushView.OnSelectBrush, FileUtils.OnSaveCover, SceneAdapter.ItemMoveListener {
|
|
|
+ BrushView.OnSelectBrush, FileUtils.OnSaveCover, FileUtils.OnSaveThemeImage, SceneAdapter.ItemMoveListener {
|
|
|
|
|
|
private lateinit var project: Project
|
|
|
private var currentSceneIndex = 0
|
|
@@ -95,6 +94,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
companion object {
|
|
|
const val PHOTO_FROM_GALLERY = 1
|
|
|
const val ACTOR_FROM_BRUSH = 2
|
|
|
+ const val FROM_GALLERY_AND_CROP = 3
|
|
|
+ const val CROP_TO_BACKGROUND = 4
|
|
|
const val LAYER_MANAGEMENT = "layer_management"
|
|
|
const val ACTOR_HEIGHT = 400
|
|
|
const val ACTOR_WIDTH = 400
|
|
@@ -164,6 +165,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
listeners.forEach {it.run()}
|
|
|
}
|
|
|
}
|
|
|
+ initExportVideoButton()
|
|
|
+ initPreviousNextButton()
|
|
|
initControlBarView()
|
|
|
project.story?.let {
|
|
|
it.scenes?.let {
|
|
@@ -297,9 +300,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
when (it[currentSceneIndex].record) {
|
|
|
null -> {
|
|
|
startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
|
|
|
- navigationBarView . setBtnDisable ()
|
|
|
- navigationBar . addView (navigationBarView)
|
|
|
- navigationBarView . setonClickSceneBtn (View.OnClickListener {
|
|
|
+ navigationBarView.setBtnDisable()
|
|
|
+ navigationBar.addView (navigationBarView)
|
|
|
+ navigationBarView.setonClickSceneBtn (View.OnClickListener {
|
|
|
initControlSceneView()
|
|
|
})
|
|
|
navigationBarView . setonClickActorBtn (View.OnClickListener {})
|
|
@@ -310,9 +313,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
else -> {
|
|
|
startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_startover))
|
|
|
- navigationBarView . setBtnDisable ()
|
|
|
- navigationBar . addView (navigationBarView)
|
|
|
- navigationBarView . setonClickSceneBtn (View.OnClickListener {
|
|
|
+ navigationBarView.setBtnDisable()
|
|
|
+ navigationBar.addView(navigationBarView)
|
|
|
+ navigationBarView.setonClickSceneBtn (View.OnClickListener {
|
|
|
initControlSceneView()
|
|
|
})
|
|
|
navigationBarView . setonClickActorBtn (View.OnClickListener {})
|
|
@@ -371,6 +374,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ initExportVideoButton()
|
|
|
}
|
|
|
|
|
|
private fun createSettingPopupView(): View{
|
|
@@ -436,6 +440,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
unSelectActor()
|
|
|
var intent = Intent(this, DrawActivity::class.java).apply {
|
|
|
putExtra("project", Gson().toJson(project))
|
|
|
+ putExtra("currentScene", currentSceneIndex)
|
|
|
}
|
|
|
startActivityForResult(intent, ACTOR_FROM_BRUSH)
|
|
|
}
|
|
@@ -445,6 +450,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
if (viewContainer.getChildAt(0) is SelectActorView || viewContainer.getChildAt(0) is ObjectView || viewContainer.getChildAt(0) is AddSceneView) {
|
|
|
viewContainer.removeAllViews()
|
|
|
startRecord.visibility = View.VISIBLE
|
|
|
+ initPreviousNextButton()
|
|
|
return
|
|
|
} else {
|
|
|
viewContainer.removeAllViews()
|
|
@@ -473,11 +479,13 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
selectActorView.btn_choose_theme.setOnClickListener {
|
|
|
chooseTheme()
|
|
|
}
|
|
|
+ initPreviousNextButton()
|
|
|
}
|
|
|
private fun initDialogueView(){
|
|
|
if (viewContainer.getChildAt(0) is DialogueView) {
|
|
|
viewContainer.removeAllViews()
|
|
|
startRecord.visibility = View.VISIBLE
|
|
|
+ initPreviousNextButton()
|
|
|
return
|
|
|
} else {
|
|
|
viewContainer.removeAllViews()
|
|
@@ -492,15 +500,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
sceneEditView.findViewById<LayerView>(currentLayerIndex).setOnDragListener(dragListener())
|
|
|
viewContainer.addView(dialogueView)
|
|
|
dialogueView.layoutParams.width = monitorSize.widthPixels
|
|
|
+ initPreviousNextButton()
|
|
|
}
|
|
|
|
|
|
|
|
|
private fun initControlSceneView() {
|
|
|
if (viewContainer.getChildAt(0) is ControlSceneView) {
|
|
|
viewContainer.removeAllViews()
|
|
|
+ initPreviousNextButton()
|
|
|
return
|
|
|
}
|
|
|
setControlSceneView()
|
|
|
+ initPreviousNextButton()
|
|
|
}
|
|
|
|
|
|
private fun setControlSceneView(){
|
|
@@ -580,9 +591,12 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
newActor.opacity = actor.opacity
|
|
|
newActor.dialogColor = actor.dialogColor
|
|
|
newActor.dialogType = actor.dialogType
|
|
|
+ newActor.hue = actor.hue
|
|
|
+ newActor.saturation = actor.saturation
|
|
|
+ newActor.brightness = actor.brightness
|
|
|
newLayer.actors.add(newActor)
|
|
|
}
|
|
|
- layers.add(newLayer)
|
|
|
+ layers[it[currentSceneIndex].layers.indexOf(layer)] = newLayer
|
|
|
}
|
|
|
}
|
|
|
it.add(currentSceneIndex + 1, scene)
|
|
@@ -681,7 +695,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
navigationBar.visibility = View.VISIBLE
|
|
|
initControlBarView()
|
|
|
initControlSceneView()
|
|
|
- initRecordFinishView()
|
|
|
+ //initRecordFinishView()
|
|
|
+ initExportVideoButton()
|
|
|
}
|
|
|
|
|
|
private fun getRecordFilePath(): String {
|
|
@@ -811,7 +826,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
navigationBar.visibility = View.VISIBLE
|
|
|
initControlBarView()
|
|
|
initControlSceneView()
|
|
|
- initRecordFinishView()
|
|
|
+ //initRecordFinishView()
|
|
|
+ initExportVideoButton()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -819,10 +835,82 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun initRecordFinishView(){
|
|
|
- navigationBar.removeAllViews()
|
|
|
- var recordFinishView = RecordFinishView(this)
|
|
|
- recordFinishView.setOnNextSceneClickListener(View.OnClickListener {
|
|
|
+ private fun initExportVideoButton(){
|
|
|
+ var hasRecord = false
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ it.forEach {
|
|
|
+ if (it.record != null) {
|
|
|
+ hasRecord = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hasRecord) {
|
|
|
+ btn_scene_edit_activity_export.alpha = 1.0f
|
|
|
+ btn_scene_edit_activity_export.setOnClickListener {
|
|
|
+ val pd = ProgressDialog(this).apply {
|
|
|
+ setCancelable(false)
|
|
|
+ }
|
|
|
+ FileUtils.saveProject(this, project, 1920,1080)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .doOnSubscribe { pd.show() }
|
|
|
+ .doFinally { pd.dismiss() }
|
|
|
+ .subscribe {
|
|
|
+ listeners.forEach {it.run()}
|
|
|
+ }
|
|
|
+ val intent = Intent(this, MovieEditActivity::class.java)
|
|
|
+ intent.putExtra(MovieEditActivity.PROJECT_KEY, Gson().toJson(project))
|
|
|
+ startActivity(intent)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ btn_scene_edit_activity_export.alpha = 0.4f
|
|
|
+ btn_scene_edit_activity_export.setOnClickListener {}
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initPreviousNextButton(){
|
|
|
+ when (viewContainer.childCount){
|
|
|
+ 0 -> {
|
|
|
+ previous_page.visibility = View.VISIBLE
|
|
|
+ next_page.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ previous_page.visibility = View.INVISIBLE
|
|
|
+ next_page.visibility = View.INVISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ when (currentSceneIndex){
|
|
|
+ 0 -> {
|
|
|
+ previous_page.visibility = View.INVISIBLE
|
|
|
+ }
|
|
|
+ project.story?.scenes?.size?.minus(1) -> {
|
|
|
+ next_page.visibility = View.INVISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ previous_page.setOnClickListener {
|
|
|
+ currentSceneIndex--
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let{
|
|
|
+ when(currentSceneIndex < 0){
|
|
|
+ true -> {
|
|
|
+ currentSceneIndex = 0
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
+ false -> {
|
|
|
+ switchToPreViewLayer()
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ initControlBarView()
|
|
|
+ initPreviousNextButton()
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
|
+ }
|
|
|
+ next_page.setOnClickListener {
|
|
|
currentSceneIndex++
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
@@ -839,38 +927,35 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
initControlBarView()
|
|
|
+ initPreviousNextButton()
|
|
|
initNavigationBarView(currentSceneIndex)
|
|
|
- })
|
|
|
- recordFinishView.setOnFinishClickListener(View.OnClickListener {
|
|
|
- val pd = ProgressDialog(this).apply {
|
|
|
- setCancelable(false)
|
|
|
- }
|
|
|
- FileUtils.saveProject(this, project, 1920,1080)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .doOnSubscribe { pd.show() }
|
|
|
- .doFinally { pd.dismiss() }
|
|
|
- .subscribe {
|
|
|
- listeners.forEach {it.run()}
|
|
|
- }
|
|
|
- val intent = Intent(this, MovieEditActivity::class.java)
|
|
|
- intent.putExtra(MovieEditActivity.PROJECT_KEY, Gson().toJson(project))
|
|
|
- startActivity(intent)
|
|
|
- })
|
|
|
- navigationBar.addView(recordFinishView)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun initReplaceSceneView(){
|
|
|
viewContainer.removeAllViews()
|
|
|
+ switchLayer(4)
|
|
|
var addSceneView = AddSceneView(this)
|
|
|
viewContainer.addView(addSceneView)
|
|
|
val layoutManager = LinearLayoutManager(this)
|
|
|
layoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
|
var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
|
|
|
- for (i in 0 until resourceThemeBitmap.size) {
|
|
|
- onSceneSelectedArrayList.add(replaceScene(i))
|
|
|
+ for (i in 0 until resourceThemeBitmap.size + 1) {
|
|
|
+ if(i == 0){
|
|
|
+ onSceneSelectedArrayList.add(View.OnClickListener {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.type = "image/*"
|
|
|
+ intent.action = Intent.ACTION_GET_CONTENT
|
|
|
+ startActivityForResult(intent, FROM_GALLERY_AND_CROP)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {onSceneSelectedArrayList.add(replaceScene(i - 1))}
|
|
|
+ }
|
|
|
+ var replaceData = ArrayList<String>().apply {
|
|
|
+ add(File(Config.ASSETS_FOLDER, Config.PROJECT_WHITE_FILE_NAME).path)
|
|
|
+ addAll(resourceThemeBitmap)
|
|
|
}
|
|
|
- var addSceneAdapter = AddSceneAdapter(this, resourceThemeBitmap, onSceneSelectedArrayList)
|
|
|
+ var addSceneAdapter = AddSceneAdapter(this, replaceData, onSceneSelectedArrayList)
|
|
|
var newSceneRecyclerView = addSceneView.findViewById<RecyclerView>(R.id.new_scene_recycler_view)
|
|
|
newSceneRecyclerView.layoutManager = layoutManager
|
|
|
newSceneRecyclerView.adapter = addSceneAdapter
|
|
@@ -889,6 +974,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
|
|
|
private fun initAddObjectView(){
|
|
|
viewContainer.removeAllViews()
|
|
|
+ switchLayer(0)
|
|
|
var objectView = ObjectView(this)
|
|
|
objectView.setData(resourceObjectPath)
|
|
|
sceneEditView.findViewById<LayerView>(currentLayerIndex).setOnDragListener(objectDragListener())
|
|
@@ -919,6 +1005,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
record = Record()
|
|
|
initControlBarView()
|
|
|
initNavigationBarView(oldSceneIndex)
|
|
|
+ initPreviousNextButton()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1261,6 +1348,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
isMirror = actor.isMirror
|
|
|
dialogType = actor.dialogType
|
|
|
dialogColor = actor.dialogColor
|
|
|
+ hue = actor.hue
|
|
|
+ brightness = actor.brightness
|
|
|
+ saturation = actor.saturation
|
|
|
}
|
|
|
it[currentSceneIndex].layers[currentLayerIndex].actors.add(actorData)
|
|
|
setActorPositionZ(it[currentSceneIndex].layers[currentLayerIndex].actors)
|
|
@@ -1608,6 +1698,109 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
return popupView
|
|
|
}
|
|
|
+
|
|
|
+ private fun createBackGroundPopupView(popupWindow: PopupWindow): View{
|
|
|
+ val popupView = LayoutInflater.from(this).inflate(R.layout.control_background_dialog, null)
|
|
|
+
|
|
|
+ popupView.adjustment.setOnClickListener {
|
|
|
+ popupWindow.dismiss()
|
|
|
+ var popupWindow = PopupWindow(this)
|
|
|
+ var popupView = LayoutInflater.from(this).inflate(R.layout.popupview_adjustment_dialog, null)
|
|
|
+ popupWindow.contentView = popupView
|
|
|
+ popupWindow.width = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popupWindow.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popupWindow.isOutsideTouchable = false
|
|
|
+ popupWindow.showAtLocation(sceneEditView, Gravity.CENTER,0,0)
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ popupView.sb_adjustment_dialog_hue.progress = it[currentSceneIndex].hue.toInt() + 180
|
|
|
+ popupView.tv_adjustment_dialog_hue.text = "Hue" + " : " + (it[currentSceneIndex].hue.toInt() + 180).toString()
|
|
|
+ popupView.sb_adjustment_dialog_hue.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
|
|
|
+ override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
|
|
+ popupView.tv_adjustment_dialog_hue.text = "Hue : " + p1.toString()
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ it[currentSceneIndex].hue = p1.toFloat() - 180
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ popupView.tv_adjustment_dialog_done.setOnClickListener {
|
|
|
+ popupWindow.dismiss()
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ popupView.sb_adjustment_dialog_brightness.progress = it[currentSceneIndex].brightness.toInt()
|
|
|
+ popupView.tv_adjustment_dialog_brightness.text = "Brightness" + " : " + it[currentSceneIndex].brightness.toInt().toString()
|
|
|
+ popupView.sb_adjustment_dialog_brightness.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
|
|
+ override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
|
|
+ popupView.tv_adjustment_dialog_brightness.text = "Brightness : " + p1.toString()
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ it[currentSceneIndex].brightness = p1.toFloat()
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ popupView.sb_adjustment_dialog_saturation.progress = it[currentSceneIndex].saturation.toInt()
|
|
|
+ popupView.tv_adjustment_dialog_saturation.text = "Saturation" + " : " + it[currentSceneIndex].saturation.toInt().toString()
|
|
|
+ popupView.sb_adjustment_dialog_saturation.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
|
|
+ override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
|
|
+ popupView.tv_adjustment_dialog_saturation.text = "Saturation : " + p1.toString()
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ it[currentSceneIndex].saturation = p1.toFloat()
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+ popupView.Mirror.setOnClickListener {
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ it[currentSceneIndex].isBackGroundMirror = !it[currentSceneIndex].isBackGroundMirror
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ popupWindow.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+
|
|
|
+ return popupView
|
|
|
+ }
|
|
|
+
|
|
|
override fun onSceneMove(dX: Int) {
|
|
|
if ( (BACKGROUND_MOVE_RATE * monitorSize.widthPixels.div(BACKGROUND_MOVE_RATE * 2)) >= (swipeX + dX) && (swipeX + dX) > (-(BACKGROUND_MOVE_RATE * monitorSize.widthPixels.div(BACKGROUND_MOVE_RATE * 2)))) {
|
|
|
sceneEditView.x = swipeX + dX
|
|
@@ -1673,6 +1866,30 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ FROM_GALLERY_AND_CROP ->
|
|
|
+ when (resultCode) {
|
|
|
+ Activity.RESULT_OK -> if (data != null) {
|
|
|
+ FileUtils.saveImageForTheme(this, project, data.data, System.currentTimeMillis().toString())
|
|
|
+ }
|
|
|
+ Activity.RESULT_CANCELED -> {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CROP_TO_BACKGROUND ->
|
|
|
+ when (resultCode) {
|
|
|
+ Activity.RESULT_OK -> if (data != null) {
|
|
|
+ var uri = data.data
|
|
|
+ val path = FileUtils.getRealPathFromURI(this, uri)
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let{
|
|
|
+ it[currentSceneIndex].backgroundPath = path
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Activity.RESULT_CANCELED -> {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1680,6 +1897,24 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
addActor(ACTOR_INIT_POSITION_X, ACTOR_INIT_POSITION_Y, filePath)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ override fun onSaveThemeImage(filePath: String){
|
|
|
+ val bytes = ByteArrayOutputStream()
|
|
|
+ val bitmap = BitmapFactory.decodeFile(filePath)
|
|
|
+ bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes)
|
|
|
+ val path = MediaStore.Images.Media.insertImage(contentResolver, bitmap, "Title", null)
|
|
|
+ var uri = Uri.parse(path)
|
|
|
+ val cropIntent = Intent("com.android.camera.action.CROP")
|
|
|
+ cropIntent.setDataAndType(uri, "image/*")
|
|
|
+ cropIntent.putExtra("crop", "true")
|
|
|
+ cropIntent.putExtra("aspectX", 2)
|
|
|
+ cropIntent.putExtra("aspectY", 1)
|
|
|
+ cropIntent.putExtra("outputX", 128)
|
|
|
+ cropIntent.putExtra("outputY", 128)
|
|
|
+ cropIntent.putExtra("return-data", true)
|
|
|
+ startActivityForResult(cropIntent, CROP_TO_BACKGROUND)
|
|
|
+ }
|
|
|
+
|
|
|
override fun onSaveCoverImage(filePath: String) {
|
|
|
project.story?.let {
|
|
|
it.scenes?.let {
|
|
@@ -1738,6 +1973,17 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
}
|
|
|
|
|
|
+ override fun onSceneLongClick() {
|
|
|
+ if(currentLayerIndex == 4){
|
|
|
+ var popupWindow = PopupWindow(this)
|
|
|
+ popupWindow.contentView = createBackGroundPopupView(popupWindow)
|
|
|
+ popupWindow.width = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popupWindow.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popupWindow.isOutsideTouchable = true
|
|
|
+ popupWindow.showAtLocation(sceneEditView, Gravity.CENTER,0,0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun unSelectActor(){
|
|
|
project.story?.let {
|
|
|
it.scenes?.let {
|
|
@@ -1907,42 +2153,59 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
dialog.project = project
|
|
|
dialog.onViewCreated = Runnable {
|
|
|
dialog.apply {
|
|
|
- val oldName = project.name ?: ""
|
|
|
+ val oldName = project.displayName ?: ""
|
|
|
onSave = View.OnClickListener { it ->
|
|
|
- if (project.name == "") {
|
|
|
+ if (storyName == "") {
|
|
|
showEmptyProjectNameMsg()
|
|
|
- } else if (project.name != oldName) {
|
|
|
- showDuplicatedProjectNameMsg()
|
|
|
} else {
|
|
|
if (coverFile == null) {
|
|
|
project.coverFile = null
|
|
|
} else {
|
|
|
project.coverFile = coverFile
|
|
|
}
|
|
|
- //project.name = storyName
|
|
|
- //project.displayName = storyName
|
|
|
+ project.displayName = storyName
|
|
|
project.author = author
|
|
|
project.frontCoverColor = frontCoverColor
|
|
|
project.backCoverColor = backCoverColor
|
|
|
project.category = category
|
|
|
+ val pd = ProgressDialog(this@SceneEditActivity).apply {
|
|
|
+ setCancelable(false)
|
|
|
+ }
|
|
|
FileUtils.saveProject(this@SceneEditActivity, project, 1920,1080)
|
|
|
- project.story?.let {
|
|
|
- it.scenes?.let {
|
|
|
- if (project.coverFile == null) {
|
|
|
- val bitmap = CoverDrawer.drawFrontCover((monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.displayName
|
|
|
- ?: "", project.author
|
|
|
- ?: "", project.frontCoverColor.getColor(this@SceneEditActivity))
|
|
|
- val bitmap2 = CoverDrawer.drawBackCover(this@SceneEditActivity, (monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.backCoverColor.getColor(this@SceneEditActivity))
|
|
|
- val bitmap3 = Bitmap.createBitmap(monitorSize.widthPixels, monitorSize.heightPixels, bitmap.config)
|
|
|
- val canvas = Canvas(bitmap3)
|
|
|
- canvas.drawBitmap(bitmap, 0f, 0f, null)
|
|
|
- canvas.drawBitmap(bitmap2, ((monitorSize.widthPixels) / 2).toFloat(), 0f, null)
|
|
|
- FileUtils.saveCover(this@SceneEditActivity, project, bitmap3, project.name.toString())
|
|
|
- } else {
|
|
|
- sceneEditView.scene = it[0]
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .doOnSubscribe { pd.show() }
|
|
|
+ .doFinally {
|
|
|
+ pd.dismiss()
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ .subscribe {
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ if (coverFile == null) {
|
|
|
+ val bitmap = CoverDrawer.drawFrontCover((monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.displayName
|
|
|
+ ?: "", project.author
|
|
|
+ ?: "", project.frontCoverColor.getColor(this@SceneEditActivity))
|
|
|
+ val bitmap2 = CoverDrawer.drawBackCover(this@SceneEditActivity, (monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.backCoverColor.getColor(this@SceneEditActivity))
|
|
|
+ val bitmap3 = Bitmap.createBitmap(monitorSize.widthPixels, monitorSize.heightPixels, bitmap.config)
|
|
|
+ val canvas = Canvas(bitmap3)
|
|
|
+ canvas.drawBitmap(bitmap, 0f, 0f, null)
|
|
|
+ canvas.drawBitmap(bitmap2, ((monitorSize.widthPixels) / 2).toFloat(), 0f, null)
|
|
|
+ FileUtils.saveCover(this@SceneEditActivity, project, bitmap3, project.name.toString())
|
|
|
+ } else {
|
|
|
+ val bitmap = CoverDrawer.drawFrontCover((monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.displayName
|
|
|
+ ?: "", project.author
|
|
|
+ ?: "", coverFile!!)
|
|
|
+ val bitmap2 = CoverDrawer.drawBackCover(this@SceneEditActivity, (monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.backCoverColor.getColor(this@SceneEditActivity))
|
|
|
+ val bitmap3 = Bitmap.createBitmap(monitorSize.widthPixels, monitorSize.heightPixels, bitmap.config)
|
|
|
+ val canvas = Canvas(bitmap3)
|
|
|
+ canvas.drawBitmap(bitmap, 0f, 0f, null)
|
|
|
+ canvas.drawBitmap(bitmap2, ((monitorSize.widthPixels) / 2).toFloat(), 0f, null)
|
|
|
+ FileUtils.saveCover(this@SceneEditActivity, project, bitmap3, project.name.toString())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
initControlSceneView()
|
|
|
this.dismiss()
|
|
|
window.decorView.apply {
|