Quellcode durchsuchen

Merge branch 'brushview-and-issue-fix'

faterhenry vor 6 Jahren
Ursprung
Commit
2403168a99
23 geänderte Dateien mit 483 neuen und 124 gelöschten Zeilen
  1. 0 23
      src/main/java/com/bomostory/sceneeditmodule/BrushDrawer.kt
  2. 13 0
      src/main/java/com/bomostory/sceneeditmodule/DialogueColorData.kt
  3. 107 42
      src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt
  4. 1 1
      src/main/java/com/bomostory/sceneeditmodule/basicdata/Brush.kt
  5. 38 5
      src/main/java/com/bomostory/sceneeditmodule/navigationbar/brush/BrushView.kt
  6. 12 10
      src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/SceneAdapter.kt
  7. 1 0
      src/main/java/com/bomostory/sceneeditmodule/screen/view/EditActorView.kt
  8. 62 21
      src/main/java/com/bomostory/sceneeditmodule/screen/view/PaintView.kt
  9. 2 2
      src/main/java/com/bomostory/sceneeditmodule/utils/FileUtils.kt
  10. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color1.xml
  11. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color10.xml
  12. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color2.xml
  13. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color3.xml
  14. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color4.xml
  15. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color5.xml
  16. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color6.xml
  17. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color7.xml
  18. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color8.xml
  19. 20 0
      src/main/res/drawable/btn_edit_brush_color_circle_color9.xml
  20. 11 1
      src/main/res/layout/activity_scene_edit.xml
  21. 21 7
      src/main/res/layout/item_scene.xml
  22. 2 2
      src/main/res/layout/navigation_bar_view.xml
  23. 13 10
      src/main/res/layout/scene_brush_view.xml

+ 0 - 23
src/main/java/com/bomostory/sceneeditmodule/BrushDrawer.kt

@@ -1,23 +0,0 @@
-package com.bomostory.sceneeditmodule
-
-import android.graphics.*
-import com.bomostory.sceneeditmodule.basicdata.Brush
-
-object BrushDrawer {
-    fun drawScene(brush: Brush): Bitmap? {
-        var sceneBitmap: Bitmap? = null
-
-            val conf = Bitmap.Config.ARGB_8888
-            sceneBitmap = Bitmap.createBitmap(300, 300, conf)
-            sceneBitmap = Bitmap.createScaledBitmap(sceneBitmap, 300, 300, true)
-
-            val canvas = Canvas(sceneBitmap)
-            val textPaint = Paint()
-            textPaint.strokeWidth = 1f
-            textPaint.isAntiAlias = true
-            textPaint.color = Color.parseColor(brush.color)
-            textPaint.textSize = brush.brushSize.toFloat()
-            canvas.drawText("FUCK",0f,150f,textPaint)
-        return sceneBitmap
-    }
-}

+ 13 - 0
src/main/java/com/bomostory/sceneeditmodule/DialogueColorData.kt

@@ -50,4 +50,17 @@ object DialogueColorData {
         }
         return  Pair(0,0)
     }
+
+    val colorMap = HashMap<Int,String>().apply {
+        put(1,"#d0021b")
+        put(2,"#f5a623")
+        put(3,"#f8e71c")
+        put(4,"#ffecb3")
+        put(5,"#417505")
+        put(6,"#bd10e0")
+        put(7,"#9013fe")
+        put(8,"#4a90e2")
+        put(9,"#000000")
+        put(10,"#ffffff")
+    }
 }

+ 107 - 42
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -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
+        }
+    }
 }

+ 1 - 1
src/main/java/com/bomostory/sceneeditmodule/basicdata/Brush.kt

@@ -3,7 +3,7 @@ package com.bomostory.sceneeditmodule.basicdata
 import android.graphics.Color
 
 class Brush {
-    var color: String? = "#ffffff"
+    var brushColor: String? = "#ffffff"
     var brushType: Int = 0
     var brushSize: Int = 0
 }

+ 38 - 5
src/main/java/com/bomostory/sceneeditmodule/navigationbar/brush/BrushView.kt

@@ -6,10 +6,14 @@ import android.util.AttributeSet
 import android.view.LayoutInflater
 import android.widget.LinearLayout
 import android.widget.SeekBar
+import com.bomostory.sceneeditmodule.DialogueColorData
+import com.bomostory.sceneeditmodule.basicdata.Brush
 import com.example.tfat.myapplication.R
 import kotlinx.android.synthetic.main.scene_brush_view.view.*
 
 class BrushView : LinearLayout {
+    var listener: OnSelectBrush? = null
+    var brush: Brush? = null
     constructor(context: Context) : super(context) {
         initView()
     }
@@ -26,47 +30,69 @@ class BrushView : LinearLayout {
         LayoutInflater.from(context).inflate(R.layout.scene_brush_view, this, true)
         iv_brush_view_color1.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[1]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color1.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color2.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[2]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color2.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color3.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[3]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color3.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color4.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[4]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color4.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color5.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[5]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color5.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color6.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[6]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color6.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color7.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[7]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color7.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color8.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[8]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color8.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color9.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[9]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color9.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_color10.setOnClickListener {
             initColorState()
+            brush?.brushColor = DialogueColorData.colorMap[10]
+            listener?.onSelectBrush(brush)
             iv_brush_view_color10.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
         }
         iv_brush_view_brush1.setOnClickListener {
             initBrushState()
             iv_brush_view_brush1.alpha = 1f
+            brush?.brushType = 0
+            listener?.onSelectBrush(brush)
         }
         iv_brush_view_brush2.setOnClickListener {
             initBrushState()
@@ -83,12 +109,15 @@ class BrushView : LinearLayout {
         iv_brush_view_brush5.setOnClickListener {
             initBrushState()
             iv_brush_view_brush5.alpha = 1f
+            brush?.brushType = 4
+            listener?.onSelectBrush(brush)
         }
     }
 
-    fun setBrushSize(size: Int, onSeekBarChangeListener: SeekBar.OnSeekBarChangeListener){
-        tv_brush_view_size.text = "Size: " + size.toString() + "px"
-        seek_bar_brush_view_size.progress = size
+    fun setBrush(brush: Brush, onSeekBarChangeListener: SeekBar.OnSeekBarChangeListener){
+        this.brush = brush
+        tv_brush_view_size.text = "Size: " + brush.brushSize.toString() + "px"
+        seek_bar_brush_view_size.progress = brush.brushSize
         seek_bar_brush_view_size.setOnSeekBarChangeListener(onSeekBarChangeListener)
     }
 
@@ -96,8 +125,8 @@ class BrushView : LinearLayout {
         btn_brush_view_done.setOnClickListener(onClickListener)
     }
 
-    fun getBrushSize() : Int{
-        return seek_bar_brush_view_size.progress
+    fun setColorListener(onSelectColor: OnSelectBrush){
+        listener = onSelectColor
     }
 
     private fun initColorState(){
@@ -120,4 +149,8 @@ class BrushView : LinearLayout {
         iv_brush_view_brush4.alpha = 0.7f
         iv_brush_view_brush5.alpha = 0.7f
     }
+
+    interface OnSelectBrush{
+        fun onSelectBrush(brush: Brush?)
+    }
 }

+ 12 - 10
src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/SceneAdapter.kt

@@ -8,18 +8,20 @@ import android.view.*
 import android.widget.ImageView
 import android.widget.TextView
 import com.example.tfat.myapplication.R
+import kotlinx.android.synthetic.main.item_scene.view.*
 import kotlin.collections.ArrayList
 
-class SceneAdapter(var context : Context, var data: ArrayList<Drawable>, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex : Int) : RecyclerView.Adapter<SceneAdapter.ViewHolder>() {
+class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex : Int, recordTime: ArrayList<Long?>) : RecyclerView.Adapter<SceneAdapter.ViewHolder>() {
     private var onClickListenerList = onClickListenerList
     private var sceneIndex = sceneIndex
+    private var recordTimeArrayList = recordTime
 
     override fun getItemCount(): Int {
         return data.size
     }
 
     override fun onBindViewHolder(holder: ViewHolder, position: Int) {
-        holder.bind(data?.get(position), position, onClickListenerList, sceneIndex)
+        holder.bind(data?.get(position), position, onClickListenerList, sceneIndex, recordTimeArrayList[position])
     }
 
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
@@ -28,10 +30,15 @@ class SceneAdapter(var context : Context, var data: ArrayList<Drawable>, onClick
     }
 
     class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
-        fun bind(drawable: Drawable, position : Int, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex: Int) {
-            itemView.findViewById<ImageView>(R.id.scene_image).setImageDrawable(drawable)
+        fun bind(bitmap: Bitmap?, position : Int, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex: Int, recordTime: Long?) {
+            itemView.findViewById<ImageView>(R.id.scene_image).setImageBitmap(bitmap)
             itemView.findViewById<ImageView>(R.id.scene_image).setOnClickListener(onClickListenerList[position])
             itemView.findViewById<TextView>(R.id.scene_number).text = position.toString()
+            when (recordTime != null) {
+                true -> {itemView.scene_record_time.text = recordTime?.div(1000)?.div(60).toString() + ":" +
+                        recordTime?.div(1000)?.rem(60)?.div(10) + recordTime?.div(1000)?.rem(60)?.rem(10).toString()}
+                false -> {itemView.scene_record_time.text = null}
+            }
             if (sceneIndex == position) {
                 itemView.findViewById<ImageView>(R.id.edit_view).visibility = View.VISIBLE
             } else {
@@ -40,12 +47,7 @@ class SceneAdapter(var context : Context, var data: ArrayList<Drawable>, onClick
         }
     }
 
-    fun updateCurrentScene(index : Int) {
-        sceneIndex = index
-        this.notifyDataSetChanged()
-    }
-
-    fun update(data : ArrayList<Drawable>, onClickListenerList: ArrayList<View.OnClickListener>) {
+    fun update(data : ArrayList<Bitmap?>, onClickListenerList: ArrayList<View.OnClickListener>) {
         this.data = data
         this.onClickListenerList = onClickListenerList
         this.notifyDataSetChanged()

+ 1 - 0
src/main/java/com/bomostory/sceneeditmodule/screen/view/EditActorView.kt

@@ -244,6 +244,7 @@ open class EditActorView @JvmOverloads constructor(
                     actorData.sideHeight = sizeY + my
                     actorData.positionX = x + mx
                     actorData.positionY = y
+                    actor = actorData
                 }
                 MotionEvent.ACTION_UP -> {
                     actor.isSelect = true

+ 62 - 21
src/main/java/com/bomostory/sceneeditmodule/screen/view/PaintView.kt

@@ -6,37 +6,78 @@ import android.support.constraint.ConstraintLayout
 import android.util.AttributeSet
 import android.view.MotionEvent
 import android.view.View
+import com.bomostory.sceneeditmodule.basicdata.Brush
+import android.graphics.PorterDuff
+import android.graphics.PorterDuffXfermode
+
 
 class PaintView: ConstraintLayout , View.OnTouchListener{
 
-    var paint = Paint()
-    private var points = ArrayList<Point>()
     constructor(context: Context) : super(context)
-
-
     constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
-
-
     constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
-
-
+    lateinit var bitmap: Bitmap
+    private lateinit var bufferCanvas: Canvas
+    private var paint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG)
+    var brush = Brush()
+        set(value) {
+            field = value
+            paint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG)
+            value?.let {
+                when(it.brushType){
+                    0 -> {
+                        paint.style = Paint.Style.STROKE
+                        paint.strokeCap = Paint.Cap.ROUND
+                        paint.strokeWidth = it.brushSize.toFloat()
+                        paint.color = Color.parseColor(brush.brushColor)
+                        paint.xfermode = null
+                    }
+                    4 -> {
+                        paint.style = Paint.Style.STROKE
+                        paint.strokeCap = Paint.Cap.ROUND
+                        paint.strokeWidth = it.brushSize.toFloat()
+                        paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
+                    }
+                }
+            }
+        }
+    var path = Path()
+    private var mX: Float = 0f
+    private var mY: Float = 0f
+    fun init(){
+        bitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888)
+        bitmap.eraseColor(Color.TRANSPARENT)
+        bufferCanvas = Canvas(bitmap)
+    }
     override fun onTouch(v: View?, event: MotionEvent): Boolean {
-        val point = Point()
-        point.x = event.getX().toInt()
-        point.y = event.getY().toInt()
-        points.add(point)
-        invalidate()
+        var x = event.x
+        var y = event.y
+        when(event.action){
+            MotionEvent.ACTION_DOWN ->{
+                path.reset()
+                path.moveTo(x,y)
+                mX = x
+                mY = y
+                invalidate()
+            }
+            MotionEvent.ACTION_MOVE ->{
+                path.lineTo(mX,mY)
+                bufferCanvas.drawPath(path, paint)
+                mX = x
+                mY = y
+                invalidate()
+            }
+            MotionEvent.ACTION_UP -> {
+                path.lineTo(mX, mY)
+                bufferCanvas.drawPath(path, paint)
+                invalidate()
+                path.reset()
+            }
+        }
         return true
     }
     override fun onDraw(canvas: Canvas?) {
         super.onDraw(canvas)
-        val mPaint = Paint()
-        mPaint.style = Paint.Style.FILL
-        mPaint.strokeWidth = 5f
-        mPaint.isAntiAlias = true
-        mPaint.color = Color.parseColor("#4e342e")
-        for (point in points) {
-            canvas?.drawCircle(point.x.toFloat(), point.y.toFloat(), 5f, mPaint)
-        }
+        canvas?.drawBitmap(bitmap,0f,0f, null)
     }
 }

+ 2 - 2
src/main/java/com/bomostory/sceneeditmodule/utils/FileUtils.kt

@@ -38,10 +38,10 @@ object FileUtils {
     fun saveBitmapForActor(context: Context, bitmap: Bitmap?, fileName: String){
         val dir = File(Config.IMAGE_FOLDER,"")
         dir.mkdir()
-        val file = File(Config.IMAGE_FOLDER, fileName)
+        val file = File(Config.IMAGE_FOLDER, fileName.plus(".png"))
         try {
             val bos = BufferedOutputStream(FileOutputStream(file))
-            bitmap?.compress(Bitmap.CompressFormat.JPEG, 80, bos)
+            bitmap?.compress(Bitmap.CompressFormat.PNG, 80, bos)
             bos.flush()
             bos.close()
             if (context is OnSaveActorImage) {

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color1.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#d0021b"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color10.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#ffffff"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color2.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#f5a623"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color3.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#f8e71c"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color4.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#ffecb3"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color5.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#417505"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color6.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#bd10e0"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color7.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#913feb"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color8.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#4a90e2"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 20 - 0
src/main/res/drawable/btn_edit_brush_color_circle_color9.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:shape="oval">
+
+            <solid
+                android:color="#000000"/>
+
+            <stroke
+                android:width="1dp"
+                android:color="#ffffff" />
+
+            <size
+                android:width="24dp"
+                android:height="24dp"/>
+        </shape>
+    </item>
+</layer-list>

+ 11 - 1
src/main/res/layout/activity_scene_edit.xml

@@ -66,8 +66,18 @@
         android:id="@+id/startRecord"
         android:layout_width="56dp"
         android:layout_height="56dp"
-        android:layout_marginBottom="36dp"
+        android:layout_marginBottom="16dp"
         android:src="@drawable/ic_btn_record"
+        app:layout_constraintBottom_toTopOf="@+id/tv_scene_activity_record_time"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent" />
+    <TextView
+        android:id="@+id/tv_scene_activity_record_time"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="8dp"
+        android:textColor="#ffffff"
+        android:visibility="invisible"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent" />

+ 21 - 7
src/main/res/layout/item_scene.xml

@@ -4,15 +4,29 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:orientation="vertical">
-    <TextView
-        android:id="@+id/scene_number"
+    <RelativeLayout
+        android:layout_width="144dp"
+        android:layout_height="16dp"
         android:paddingLeft="8dp"
+        android:paddingRight="8dp"
         android:layout_marginBottom="8dp"
-        android:layout_marginTop="8dp"
-        android:textSize="14sp"
-        android:textColor="#ffffff"
-        android:layout_width="144dp"
-        android:layout_height="16dp"/>
+        android:layout_marginTop="8dp">
+        <TextView
+            android:id="@+id/scene_number"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentLeft="true"
+            android:textSize="14sp"
+            android:textColor="#ffffff" />
+        <TextView
+            android:id="@+id/scene_record_time"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:text="QQ"
+            android:textSize="14sp"
+            android:textColor="#ffffff" />
+    </RelativeLayout>
     <RelativeLayout
         android:layout_width="144dp"
         android:layout_height="72dp">

+ 2 - 2
src/main/res/layout/navigation_bar_view.xml

@@ -28,7 +28,7 @@
                 android:layout_height="wrap_content"
                 android:layout_below="@+id/scene_btn"
                 android:layout_centerInParent="true"
-                android:text="Scene"
+                android:text="Pages"
                 android:textColor="#ffecb3"/>
         </RelativeLayout>
         <RelativeLayout
@@ -51,7 +51,7 @@
                 android:layout_height="wrap_content"
                 android:layout_below="@+id/actor_btn"
                 android:layout_centerInParent="true"
-                android:text="Actor"
+                android:text="Materials"
                 android:textColor="#ffecb3"/>
         </RelativeLayout>
         <RelativeLayout

+ 13 - 10
src/main/res/layout/scene_brush_view.xml

@@ -25,6 +25,7 @@
         android:scaleType="fitXY"
         android:src="@drawable/ic_brush_2"
         android:alpha="0.7"
+        android:visibility="invisible"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toRightOf="@+id/iv_brush_view_brush1"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_brush3" />
@@ -37,6 +38,7 @@
         android:scaleType="fitXY"
         android:src="@drawable/ic_brush_3"
         android:alpha="0.7"
+        android:visibility="invisible"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toRightOf="@+id/iv_brush_view_brush2"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_brush4" />
@@ -49,6 +51,7 @@
         android:scaleType="fitXY"
         android:src="@drawable/ic_brush_4"
         android:alpha="0.7"
+        android:visibility="invisible"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toRightOf="@+id/iv_brush_view_brush3"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_brush5" />
@@ -91,7 +94,7 @@
         android:layout_height="30dp"
         android:layout_marginLeft="30dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color1"
         app:layout_constraintLeft_toRightOf="@+id/seek_bar_brush_view_size"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_color2"
         app:layout_constraintTop_toTopOf="parent" />
@@ -102,7 +105,7 @@
         android:layout_height="30dp"
         android:layout_marginLeft="30dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color2"
         app:layout_constraintLeft_toRightOf="@+id/iv_brush_view_color1"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_color3"
         app:layout_constraintTop_toTopOf="parent" />
@@ -113,7 +116,7 @@
         android:layout_height="30dp"
         android:layout_marginLeft="30dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color3"
         app:layout_constraintLeft_toRightOf="@id/iv_brush_view_color2"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_color4"
         app:layout_constraintTop_toTopOf="parent" />
@@ -124,7 +127,7 @@
         android:layout_height="30dp"
         android:layout_marginLeft="30dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color4"
         app:layout_constraintLeft_toRightOf="@+id/iv_brush_view_color3"
         app:layout_constraintRight_toLeftOf="@+id/iv_brush_view_color5"
         app:layout_constraintTop_toTopOf="parent" />
@@ -135,7 +138,7 @@
         android:layout_height="30dp"
         android:layout_marginLeft="30dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color5"
         app:layout_constraintLeft_toRightOf="@+id/iv_brush_view_color4"
         app:layout_constraintRight_toLeftOf="@+id/btn_brush_view_tune"
         app:layout_constraintTop_toTopOf="parent" />
@@ -146,7 +149,7 @@
         android:layout_height="30dp"
         android:layout_marginBottom="4dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color6"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="@+id/iv_brush_view_color1" />
 
@@ -156,7 +159,7 @@
         android:layout_height="30dp"
         android:layout_marginBottom="4dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color7"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="@+id/iv_brush_view_color2"/>
 
@@ -166,7 +169,7 @@
         android:layout_height="30dp"
         android:layout_marginBottom="4dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color8"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="@+id/iv_brush_view_color3" />
 
@@ -176,7 +179,7 @@
         android:layout_height="30dp"
         android:layout_marginBottom="4dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color9"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="@+id/iv_brush_view_color4" />
 
@@ -186,7 +189,7 @@
         android:layout_height="30dp"
         android:layout_marginBottom="4dp"
         android:scaleType="center"
-        android:src="@drawable/btn_edit_text_dialog_circle_red"
+        android:src="@drawable/btn_edit_brush_color_circle_color10"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="@+id/iv_brush_view_color5" />