|
@@ -26,6 +26,8 @@ import com.example.tfat.myapplication.navigationbar.actor.LayerManagementDialog
|
|
import kotlinx.android.synthetic.main.control_actor_dialog.view.*
|
|
import kotlinx.android.synthetic.main.control_actor_dialog.view.*
|
|
import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
import android.util.DisplayMetrics
|
|
import android.util.DisplayMetrics
|
|
|
|
+import android.util.Log
|
|
|
|
+import android.widget.RadioGroup
|
|
import com.bomostory.sceneeditmodule.EditTextDialog
|
|
import com.bomostory.sceneeditmodule.EditTextDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.MovieEditActivity
|
|
import com.bomostory.sceneeditmodule.screen.movie.MovieEditActivity
|
|
import com.example.tfat.myapplication.navigationbar.EditSceneView
|
|
import com.example.tfat.myapplication.navigationbar.EditSceneView
|
|
@@ -41,7 +43,10 @@ import com.bomostory.sceneeditmodule.DialogueColorData
|
|
import com.bomostory.sceneeditmodule.SceneDrawer
|
|
import com.bomostory.sceneeditmodule.SceneDrawer
|
|
import com.bomostory.sceneeditmodule.navigationbar.brush.BrushView
|
|
import com.bomostory.sceneeditmodule.navigationbar.brush.BrushView
|
|
import com.bomostory.sceneeditmodule.screen.view.*
|
|
import com.bomostory.sceneeditmodule.screen.view.*
|
|
|
|
+import kotlinx.android.synthetic.main.movie_item_view.*
|
|
|
|
+import kotlinx.android.synthetic.main.navigation_bar_view.view.*
|
|
import kotlinx.android.synthetic.main.popupview_color_dialog.view.*
|
|
import kotlinx.android.synthetic.main.popupview_color_dialog.view.*
|
|
|
|
+import kotlinx.android.synthetic.main.popupview_setting.view.*
|
|
import kotlinx.android.synthetic.main.scene_brush_view.view.*
|
|
import kotlinx.android.synthetic.main.scene_brush_view.view.*
|
|
import java.util.*
|
|
import java.util.*
|
|
|
|
|
|
@@ -62,6 +67,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
private var resourceActorBitmap = ArrayList<ArrayList<String>>()
|
|
private var resourceActorBitmap = ArrayList<ArrayList<String>>()
|
|
private lateinit var sceneAdapter: SceneAdapter
|
|
private lateinit var sceneAdapter: SceneAdapter
|
|
private var isRecord = false
|
|
private var isRecord = false
|
|
|
|
+ private var isAutoSwipe = false
|
|
private var layerManagementDialog = LayerManagementDialog()
|
|
private var layerManagementDialog = LayerManagementDialog()
|
|
private var editTextDialog = EditTextDialog()
|
|
private var editTextDialog = EditTextDialog()
|
|
private val monitorSize = DisplayMetrics()
|
|
private val monitorSize = DisplayMetrics()
|
|
@@ -78,6 +84,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
const val BACKGROUND_MOVE_RATE = 32
|
|
const val BACKGROUND_MOVE_RATE = 32
|
|
const val BRUSH_SIZE = 16
|
|
const val BRUSH_SIZE = 16
|
|
const val INIT_SCENE_NUMBER = 11
|
|
const val INIT_SCENE_NUMBER = 11
|
|
|
|
+ const val TIME_STEP_FOR_FPS = 33L
|
|
val listeners = CopyOnWriteArrayList<Runnable>()
|
|
val listeners = CopyOnWriteArrayList<Runnable>()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -121,7 +128,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
initControlBarView()
|
|
initControlBarView()
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationFunction()
|
|
initRecord()
|
|
initRecord()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -182,54 +189,25 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- private fun initNavigationBarView() {
|
|
|
|
|
|
+ private fun initNavigationBarView(position: Int) {
|
|
project.story?.let {
|
|
project.story?.let {
|
|
it.scenes?.let {
|
|
it.scenes?.let {
|
|
- if (it[currentSceneIndex].record == null) {
|
|
|
|
- var navigationBarView = NavigationBarView(this)
|
|
|
|
- navigationBar.addView(navigationBarView)
|
|
|
|
- navigationBarView.setonClickSceneBtn(View.OnClickListener {
|
|
|
|
- initControlSceneView()
|
|
|
|
- })
|
|
|
|
- navigationBarView.setonClickActorBtn(View.OnClickListener {
|
|
|
|
- initActorRecyclerView()
|
|
|
|
- })
|
|
|
|
- navigationBarView.setonClickBrushBtn(View.OnClickListener {
|
|
|
|
- initBrushView()
|
|
|
|
- })
|
|
|
|
- navigationBarView.setonClickDialogueBtn(View.OnClickListener {
|
|
|
|
- initDialogueView()
|
|
|
|
- })
|
|
|
|
- navigationBarView.setonClickImageBtn(View.OnClickListener {
|
|
|
|
- pickFromGallery()
|
|
|
|
- })
|
|
|
|
|
|
+ if (position != currentSceneIndex) {
|
|
|
|
+ initNavigationFunction()
|
|
} else {
|
|
} else {
|
|
navigationBar.removeAllViews()
|
|
navigationBar.removeAllViews()
|
|
var editSceneView = EditSceneView(this)
|
|
var editSceneView = EditSceneView(this)
|
|
navigationBar.addView(editSceneView)
|
|
navigationBar.addView(editSceneView)
|
|
setControlSceneView()
|
|
setControlSceneView()
|
|
editSceneView.setOnClickDoneListener(View.OnClickListener {
|
|
editSceneView.setOnClickDoneListener(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)
|
|
|
|
|
|
+ initNavigationFunction()
|
|
})
|
|
})
|
|
editSceneView.setOnClickStartOverListener(View.OnClickListener {
|
|
editSceneView.setOnClickStartOverListener(View.OnClickListener {
|
|
project.story?.let {
|
|
project.story?.let {
|
|
it.scenes?.let{
|
|
it.scenes?.let{
|
|
it[currentSceneIndex].record = null
|
|
it[currentSceneIndex].record = null
|
|
sceneEditView.scene = it[currentSceneIndex]
|
|
sceneEditView.scene = it[currentSceneIndex]
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -260,8 +238,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
false -> sceneEditView.scene = it[currentSceneIndex]
|
|
false -> sceneEditView.scene = it[currentSceneIndex]
|
|
}
|
|
}
|
|
- initNavigationBarView()
|
|
|
|
- initControlSceneView()
|
|
|
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
|
|
+ setControlSceneView()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -270,6 +248,63 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun initNavigationFunction(){
|
|
|
|
+ var navigationBarView = NavigationBarView(this)
|
|
|
|
+ navigationBar.addView(navigationBarView)
|
|
|
|
+ navigationBarView.setonClickSceneBtn(View.OnClickListener {
|
|
|
|
+ initControlSceneView()
|
|
|
|
+ })
|
|
|
|
+ navigationBarView.setonClickActorBtn(View.OnClickListener {
|
|
|
|
+ initActorRecyclerView()
|
|
|
|
+ })
|
|
|
|
+ navigationBarView.setonClickBrushBtn(View.OnClickListener {
|
|
|
|
+ initBrushView()
|
|
|
|
+ })
|
|
|
|
+ navigationBarView.setonClickDialogueBtn(View.OnClickListener {
|
|
|
|
+ initDialogueView()
|
|
|
|
+ })
|
|
|
|
+ navigationBarView.setonClickImageBtn(View.OnClickListener {
|
|
|
|
+ pickFromGallery()
|
|
|
|
+ })
|
|
|
|
+ navigationBarView.setonClickSettingBtn(View.OnClickListener {
|
|
|
|
+ var popupWindow = PopupWindow(this)
|
|
|
|
+ popupWindow.contentView = createSettingPopupView(popupWindow)
|
|
|
|
+ popupWindow.width = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
|
+ popupWindow.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
|
+ popupWindow.isOutsideTouchable = true
|
|
|
|
+ var valueXInPixels = resources.getDimension(R.dimen.popup_view_setting_height) + resources.getDimension(R.dimen.navigation_bar_height)
|
|
|
|
+ popupWindow.showAsDropDown(navigationBarView.settings, 0, -(valueXInPixels).toInt(), Gravity.CENTER_HORIZONTAL)
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun createSettingPopupView(popupWindow: PopupWindow): View{
|
|
|
|
+ val popupView = LayoutInflater.from(this).inflate(R.layout.popupview_setting, null)
|
|
|
|
+ when (isAutoSwipe) {
|
|
|
|
+ true -> {
|
|
|
|
+ popupView.rb_manual.isChecked = false
|
|
|
|
+ popupView.rb_auto_swipe.isChecked = true
|
|
|
|
+ }
|
|
|
|
+ false -> {
|
|
|
|
+ popupView.rb_manual.isChecked = true
|
|
|
|
+ popupView.rb_auto_swipe.isChecked = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ popupView.rg_settings.setOnCheckedChangeListener(object : RadioGroup.OnCheckedChangeListener{
|
|
|
|
+ override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
|
|
|
|
+ when (checkedId) {
|
|
|
|
+ popupView.rb_manual.id -> {
|
|
|
|
+ isAutoSwipe = false
|
|
|
|
+ }
|
|
|
|
+ popupView.rb_auto_swipe.id ->{
|
|
|
|
+ isAutoSwipe = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return popupView
|
|
|
|
+ }
|
|
private fun initBrushView(){
|
|
private fun initBrushView(){
|
|
if (navigationBar.getChildAt(0) is BrushView) {
|
|
if (navigationBar.getChildAt(0) is BrushView) {
|
|
navigationBar.removeAllViews()
|
|
navigationBar.removeAllViews()
|
|
@@ -299,7 +334,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
var brush = paint_view.brush
|
|
var brush = paint_view.brush
|
|
brush.brushSize = p1
|
|
brush.brushSize = p1
|
|
paint_view.brush = brush
|
|
paint_view.brush = brush
|
|
- //paint_view.brushType = 0
|
|
|
|
}
|
|
}
|
|
override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
}
|
|
}
|
|
@@ -310,7 +344,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
navigationBar.removeAllViews()
|
|
navigationBar.removeAllViews()
|
|
paint_view.visibility = View.INVISIBLE
|
|
paint_view.visibility = View.INVISIBLE
|
|
startRecord.visibility = View.VISIBLE
|
|
startRecord.visibility = View.VISIBLE
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
FileUtils.saveBitmapForActor(this, paint_view.bitmap, System.currentTimeMillis().toString())
|
|
FileUtils.saveBitmapForActor(this, paint_view.bitmap, System.currentTimeMillis().toString())
|
|
project.story?.let {
|
|
project.story?.let {
|
|
it.scenes?.let{
|
|
it.scenes?.let{
|
|
@@ -325,7 +359,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
paint_view.visibility = View.VISIBLE
|
|
paint_view.visibility = View.VISIBLE
|
|
paint_view.setOnTouchListener(paint_view)
|
|
paint_view.setOnTouchListener(paint_view)
|
|
paint_view.brush = initBrush
|
|
paint_view.brush = initBrush
|
|
- //paint_view.brushType = 0
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private fun initActorRecyclerView() {
|
|
private fun initActorRecyclerView() {
|
|
@@ -388,7 +421,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
it.scenes?.let{
|
|
it.scenes?.let{
|
|
for (i in 0 until it.size) {
|
|
for (i in 0 until it.size) {
|
|
onSceneSelectedArrayList.add(switchScene(i))
|
|
onSceneSelectedArrayList.add(switchScene(i))
|
|
- projectBitmaps.add(SceneDrawer.drawScene(this,it[i],0,1920,1080))
|
|
|
|
|
|
+ projectBitmaps.add(SceneDrawer.drawScene(this,it[i],0,200,100))
|
|
recordTimeArrayList.add(it[i].record?.period)
|
|
recordTimeArrayList.add(it[i].record?.period)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -464,11 +497,39 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
tv_scene_activity_record_time.text = "Recording 00:00"
|
|
tv_scene_activity_record_time.text = "Recording 00:00"
|
|
isRecord = false
|
|
isRecord = false
|
|
record.period = System.currentTimeMillis() - startRecordTime
|
|
record.period = System.currentTimeMillis() - startRecordTime
|
|
- project.story?.let {
|
|
|
|
- it.scenes?.let{
|
|
|
|
- it[currentSceneIndex].record = record
|
|
|
|
|
|
+ if (!isAutoSwipe){
|
|
|
|
+ project.story?.let {
|
|
|
|
+ it.scenes?.let{
|
|
|
|
+ it[currentSceneIndex].record = record
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ var autoSwipeRecord = Record()
|
|
|
|
+ autoSwipeRecord.period = record.period
|
|
|
|
+ for (i in 0 until record.period step TIME_STEP_FOR_FPS)
|
|
|
|
+ autoSwipeRecord.tracks.apply {
|
|
|
|
+ var track = Track().apply {
|
|
|
|
+ when (i <= record.period.div(2)){
|
|
|
|
+ true -> {
|
|
|
|
+ positionX = (-monitorSize.widthPixels.div(2)) + i.div(TIME_STEP_FOR_FPS).toInt() * monitorSize.widthPixels.div(record.period.div(2 * TIME_STEP_FOR_FPS).toInt())
|
|
|
|
+ time = i
|
|
|
|
+ }
|
|
|
|
+ false -> {
|
|
|
|
+ var j = i - record.period.div(2)
|
|
|
|
+ positionX = (monitorSize.widthPixels.div(2)) - j.div(TIME_STEP_FOR_FPS).toInt() * monitorSize.widthPixels.div(record.period.div(2 * TIME_STEP_FOR_FPS).toInt())
|
|
|
|
+ time = i
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ add(track)
|
|
|
|
+ }
|
|
|
|
+ project.story?.let {
|
|
|
|
+ it.scenes?.let{
|
|
|
|
+ it[currentSceneIndex].record = autoSwipeRecord
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
|
|
startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
|
|
navigationBar.visibility = View.VISIBLE
|
|
navigationBar.visibility = View.VISIBLE
|
|
initControlBarView()
|
|
initControlBarView()
|
|
@@ -498,15 +559,29 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
initControlBarView()
|
|
initControlBarView()
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
})
|
|
})
|
|
recordFinishView.setOnFinishClickListener(View.OnClickListener {
|
|
recordFinishView.setOnFinishClickListener(View.OnClickListener {
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ 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)
|
|
navigationBar.addView(recordFinishView)
|
|
}
|
|
}
|
|
private fun switchScene(position: Int): View.OnClickListener {
|
|
private fun switchScene(position: Int): View.OnClickListener {
|
|
return View.OnClickListener {
|
|
return View.OnClickListener {
|
|
|
|
+ var oldSceneIndex = currentSceneIndex
|
|
currentSceneIndex = position
|
|
currentSceneIndex = position
|
|
switchToPreViewLayer()
|
|
switchToPreViewLayer()
|
|
project.story?.let {
|
|
project.story?.let {
|
|
@@ -516,7 +591,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
record = Record()
|
|
record = Record()
|
|
initControlBarView()
|
|
initControlBarView()
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationBarView(oldSceneIndex)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -601,7 +676,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
return View.OnClickListener {
|
|
return View.OnClickListener {
|
|
addScene(position)
|
|
addScene(position)
|
|
initControlSceneView()
|
|
initControlSceneView()
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -621,22 +696,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private fun addScene(index: Int, backgroundPath: String?){
|
|
|
|
- var scene = Scene()
|
|
|
|
- for (i in 5 until 0){
|
|
|
|
- val layer = Layer()
|
|
|
|
- layer.id = i
|
|
|
|
- scene.layers.add(layer)
|
|
|
|
- }
|
|
|
|
- scene.backgroundPath = backgroundPath
|
|
|
|
- project.story?.let {
|
|
|
|
- it.scenes?.let{
|
|
|
|
- scene.sceneWidth = monitorSize.widthPixels
|
|
|
|
- it.add(scene)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private fun replaceScene(position: Int): View.OnClickListener {
|
|
private fun replaceScene(position: Int): View.OnClickListener {
|
|
return View.OnClickListener {
|
|
return View.OnClickListener {
|
|
project.story?.let {
|
|
project.story?.let {
|
|
@@ -646,7 +705,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
initControlSceneView()
|
|
initControlSceneView()
|
|
- initNavigationBarView()
|
|
|
|
|
|
+ initNavigationBarView(currentSceneIndex)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private fun setActorPositionZ(actors: ArrayList<Actor>){
|
|
private fun setActorPositionZ(actors: ArrayList<Actor>){
|