|
@@ -4,10 +4,10 @@ import android.app.Activity
|
|
|
import android.app.ProgressDialog
|
|
|
import android.content.DialogInterface
|
|
|
import android.content.Intent
|
|
|
+import android.graphics.Bitmap
|
|
|
import android.support.v7.app.AppCompatActivity
|
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
|
import android.os.Bundle
|
|
|
-import android.graphics.drawable.Drawable
|
|
|
import android.support.v7.widget.RecyclerView
|
|
|
import android.view.*
|
|
|
import android.widget.PopupWindow
|
|
@@ -26,7 +26,6 @@ import com.example.tfat.myapplication.navigationbar.actor.LayerManagementDialog
|
|
|
import kotlinx.android.synthetic.main.control_actor_dialog.view.*
|
|
|
import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
|
import android.util.DisplayMetrics
|
|
|
-import android.widget.RelativeLayout
|
|
|
import com.bomostory.sceneeditmodule.EditTextDialog
|
|
|
import com.bomostory.sceneeditmodule.screen.movie.MovieEditActivity
|
|
|
import com.example.tfat.myapplication.navigationbar.EditSceneView
|
|
@@ -38,23 +37,25 @@ import kotlinx.android.synthetic.main.popupview_opacity_dialog.view.*
|
|
|
import kotlinx.android.synthetic.main.view_control_dialogue_dialog.view.*
|
|
|
import java.util.concurrent.CopyOnWriteArrayList
|
|
|
import android.widget.SeekBar
|
|
|
-import com.bomostory.sceneeditmodule.BrushDrawer
|
|
|
import com.bomostory.sceneeditmodule.DialogueColorData
|
|
|
+import com.bomostory.sceneeditmodule.SceneDrawer
|
|
|
import com.bomostory.sceneeditmodule.navigationbar.brush.BrushView
|
|
|
import com.bomostory.sceneeditmodule.screen.view.*
|
|
|
import kotlinx.android.synthetic.main.popupview_color_dialog.view.*
|
|
|
import kotlinx.android.synthetic.main.scene_brush_view.view.*
|
|
|
-import kotlin.math.ln1p
|
|
|
+import java.util.*
|
|
|
|
|
|
|
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
|
OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
|
|
|
- OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange, EditTextDialog.OnSetDialogFinish {
|
|
|
+ OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange, EditTextDialog.OnSetDialogFinish,
|
|
|
+ BrushView.OnSelectBrush {
|
|
|
|
|
|
private lateinit var project: Project
|
|
|
private var currentSceneIndex = 0
|
|
|
private var currentLayerIndex = 6
|
|
|
private var startRecordTime = 0L
|
|
|
+ private var recordingTime = 0L
|
|
|
private var swipeX = 0
|
|
|
private var record = Record()
|
|
|
private var resourceThemeBitmap = ArrayList<String>()
|
|
@@ -64,6 +65,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
private var layerManagementDialog = LayerManagementDialog()
|
|
|
private var editTextDialog = EditTextDialog()
|
|
|
private val monitorSize = DisplayMetrics()
|
|
|
+ private var timer = Timer()
|
|
|
companion object {
|
|
|
const val PHOTO_FROM_GALLERY = 1
|
|
|
const val LAYER_MANAGEMENT = "layer_management"
|
|
@@ -75,6 +77,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
const val ACTOR_INIT_POSITION_Y = 200
|
|
|
const val BACKGROUND_MOVE_RATE = 32
|
|
|
const val BRUSH_SIZE = 16
|
|
|
+ const val INIT_SCENE_NUMBER = 11
|
|
|
val listeners = CopyOnWriteArrayList<Runnable>()
|
|
|
}
|
|
|
|
|
@@ -96,6 +99,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
|
it[0].sceneWidth = monitorSize.widthPixels
|
|
|
+ for (i in 0 until INIT_SCENE_NUMBER){
|
|
|
+ addScene(0)
|
|
|
+ }
|
|
|
sceneEditView.scene = it[0]
|
|
|
}
|
|
|
}
|
|
@@ -270,20 +276,30 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
startRecord.visibility = View.VISIBLE
|
|
|
return
|
|
|
}
|
|
|
+ if (currentLayerIndex == 6){
|
|
|
+ switchLayer(0)
|
|
|
+ initBrushView()
|
|
|
+ }
|
|
|
startRecord.visibility = View.INVISIBLE
|
|
|
viewContainer.removeAllViews()
|
|
|
navigationBar.removeAllViews()
|
|
|
- paint_view.layoutParams.width = monitorSize.widthPixels
|
|
|
- paint_view.layoutParams.height = monitorSize.widthPixels.div(2)
|
|
|
- paint_view.bringToFront()
|
|
|
- paint_view.visibility = View.VISIBLE
|
|
|
var brushView = BrushView(this)
|
|
|
+ brushView.setColorListener(this)
|
|
|
navigationBar.addView(brushView)
|
|
|
brushView.gravity = Gravity.CENTER_HORIZONTAL
|
|
|
brushView.layoutParams.width = monitorSize.widthPixels
|
|
|
- brushView.setBrushSize(BRUSH_SIZE, object : SeekBar.OnSeekBarChangeListener{
|
|
|
+ var initBrush = Brush().apply {
|
|
|
+ brushSize = BRUSH_SIZE
|
|
|
+ brushColor = DialogueColorData.colorMap[1]
|
|
|
+ brushType = 0
|
|
|
+ }
|
|
|
+ brushView.setBrush(initBrush, object : SeekBar.OnSeekBarChangeListener{
|
|
|
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
|
|
brushView.tv_brush_view_size.text = "Size: " + p1.toString() + "px"
|
|
|
+ var brush = paint_view.brush
|
|
|
+ brush.brushSize = p1
|
|
|
+ paint_view.brush = brush
|
|
|
+ //paint_view.brushType = 0
|
|
|
}
|
|
|
override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
}
|
|
@@ -295,16 +311,21 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
paint_view.visibility = View.INVISIBLE
|
|
|
startRecord.visibility = View.VISIBLE
|
|
|
initNavigationBarView()
|
|
|
- var brush = Brush().apply {
|
|
|
- brushSize = brushView.getBrushSize()
|
|
|
+ FileUtils.saveBitmapForActor(this, paint_view.bitmap, System.currentTimeMillis().toString())
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let{
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
}
|
|
|
- //FileUtils.saveBitmapForActor(this, BrushDrawer.drawScene(brush), System.currentTimeMillis().toString())
|
|
|
-// project.story?.let {
|
|
|
-// it.scenes?.let{
|
|
|
-// sceneEditView.scene = it[currentSceneIndex]
|
|
|
-// }
|
|
|
-// }
|
|
|
})
|
|
|
+ paint_view.init()
|
|
|
+ paint_view.layoutParams.width = monitorSize.widthPixels
|
|
|
+ paint_view.layoutParams.height = monitorSize.widthPixels.div(2)
|
|
|
+ paint_view.bringToFront()
|
|
|
+ paint_view.visibility = View.VISIBLE
|
|
|
+ paint_view.setOnTouchListener(paint_view)
|
|
|
+ paint_view.brush = initBrush
|
|
|
+ //paint_view.brushType = 0
|
|
|
}
|
|
|
|
|
|
private fun initActorRecyclerView() {
|
|
@@ -341,7 +362,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
startRecord.visibility = View.INVISIBLE
|
|
|
if (currentLayerIndex == 6){
|
|
|
switchLayer(0)
|
|
|
- initActorRecyclerView()
|
|
|
+ initDialogueView()
|
|
|
+ return
|
|
|
}
|
|
|
var dialogueView = DialogueView(this)
|
|
|
sceneEditView.findViewById<LayerView>(currentLayerIndex).setOnDragListener(dragListener())
|
|
@@ -359,17 +381,19 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
|
|
|
private fun setControlSceneView(){
|
|
|
- var projectBitmaps = ArrayList<Drawable>()
|
|
|
+ var projectBitmaps = ArrayList<Bitmap?>()
|
|
|
var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
|
|
|
+ var recordTimeArrayList = ArrayList<Long?>()
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
|
for (i in 0 until it.size) {
|
|
|
onSceneSelectedArrayList.add(switchScene(i))
|
|
|
- projectBitmaps.add(Drawable.createFromPath(it[i].backgroundPath))
|
|
|
+ projectBitmaps.add(SceneDrawer.drawScene(this,it[i],0,1920,1080))
|
|
|
+ recordTimeArrayList.add(it[i].record?.period)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- sceneAdapter = SceneAdapter(this, projectBitmaps, onSceneSelectedArrayList, currentSceneIndex)
|
|
|
+ sceneAdapter = SceneAdapter(this, projectBitmaps, onSceneSelectedArrayList, currentSceneIndex, recordTimeArrayList)
|
|
|
var controlSceneView = ControlSceneView(this)
|
|
|
controlSceneView.setonClickAddBtn(View.OnClickListener {
|
|
|
viewContainer.removeAllViews()
|
|
@@ -379,7 +403,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
layoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
|
var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
|
|
|
for (i in 0 until resourceThemeBitmap.size) {
|
|
|
- onSceneSelectedArrayList.add(addScene(i))
|
|
|
+ onSceneSelectedArrayList.add(onClickAddSceneListener(i))
|
|
|
}
|
|
|
var addSceneAdapter = AddSceneAdapter(this, resourceThemeBitmap, onSceneSelectedArrayList)
|
|
|
var newSceneRecyclerView = addSceneView.findViewById<RecyclerView>(R.id.new_scene_recycler_view)
|
|
@@ -388,18 +412,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
})
|
|
|
controlSceneView.setonClickDuplicateBtn(View.OnClickListener {
|
|
|
project.story?.let {
|
|
|
- it.scenes?.let{
|
|
|
- it.add(currentSceneIndex + 1 ,it[currentSceneIndex])
|
|
|
+ it.scenes?.let {
|
|
|
+ it.add(currentSceneIndex + 1, it[currentSceneIndex])
|
|
|
}
|
|
|
}
|
|
|
var sceneAdapter = controlSceneView.findViewById<RecyclerView>(R.id.scene_recycler_view).adapter as SceneAdapter
|
|
|
- var projectBitmaps = ArrayList<Drawable>()
|
|
|
+ var projectBitmaps = ArrayList<Bitmap?>()
|
|
|
var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
|
for (i in 0 until it.size) {
|
|
|
onSceneSelectedArrayList.add(switchScene(i))
|
|
|
- projectBitmaps.add(Drawable.createFromPath(it[i].backgroundPath))
|
|
|
+ projectBitmaps.add(SceneDrawer.drawScene(this,it[i],0,200,100))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -412,6 +436,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
sceneRecyclerView.adapter = sceneAdapter
|
|
|
viewContainer.removeAllViews()
|
|
|
viewContainer.addView(controlSceneView)
|
|
|
+ startRecord.visibility = View.VISIBLE
|
|
|
}
|
|
|
private fun initRecord(){
|
|
|
startRecord.setOnClickListener(View.OnClickListener {
|
|
@@ -421,7 +446,22 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
isRecord = true
|
|
|
switchToPreViewLayer()
|
|
|
navigationBar.visibility = View.INVISIBLE
|
|
|
+ tv_scene_activity_record_time.visibility = View.VISIBLE
|
|
|
+ timer.schedule(object:TimerTask(){
|
|
|
+ override fun run() {
|
|
|
+ runOnUiThread {
|
|
|
+ recordingTime ++
|
|
|
+ tv_scene_activity_record_time.text = "Recording " + "0" + recordingTime.div(60).toString() + ":" +
|
|
|
+ recordingTime.rem(60).div(10).toString() + recordingTime.rem(60).rem(10).toString()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000, 1000)
|
|
|
} else {
|
|
|
+ tv_scene_activity_record_time.visibility = View.INVISIBLE
|
|
|
+ timer.cancel()
|
|
|
+ timer = Timer()
|
|
|
+ recordingTime = 0L
|
|
|
+ tv_scene_activity_record_time.text = "Recording 00:00"
|
|
|
isRecord = false
|
|
|
record.period = System.currentTimeMillis() - startRecordTime
|
|
|
project.story?.let {
|
|
@@ -438,7 +478,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private fun initRecordFinishView(){
|
|
|
navigationBar.removeAllViews()
|
|
|
var recordFinishView = RecordFinishView(this)
|
|
@@ -558,26 +597,46 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun addScene(position: Int): View.OnClickListener {
|
|
|
+ private fun onClickAddSceneListener(position: Int): View.OnClickListener {
|
|
|
return View.OnClickListener {
|
|
|
- var scene = Scene()
|
|
|
- for (i in 5 until 0){
|
|
|
- val layer = Layer()
|
|
|
- layer.id = i
|
|
|
- scene.layers.add(layer)
|
|
|
- }
|
|
|
- scene.backgroundPath = resourceThemeBitmap[position]
|
|
|
- project.story?.let {
|
|
|
- it.scenes?.let{
|
|
|
- scene.sceneWidth = monitorSize.widthPixels
|
|
|
- it.add(scene)
|
|
|
- }
|
|
|
- }
|
|
|
+ addScene(position)
|
|
|
initControlSceneView()
|
|
|
initNavigationBarView()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun addScene(position: Int){
|
|
|
+ var scene = Scene()
|
|
|
+ for (i in 5 until 0){
|
|
|
+ val layer = Layer()
|
|
|
+ layer.id = i
|
|
|
+ scene.layers.add(layer)
|
|
|
+ }
|
|
|
+ scene.backgroundPath = resourceThemeBitmap[position]
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let{
|
|
|
+ scene.sceneWidth = monitorSize.widthPixels
|
|
|
+ it.add(scene)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 {
|
|
|
return View.OnClickListener {
|
|
|
project.story?.let {
|
|
@@ -1170,4 +1229,10 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ override fun onSelectBrush(brush: Brush?) {
|
|
|
+ brush?.let {
|
|
|
+ paint_view.brush = it
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|