소스 검색

bomo Phase2-2

faterhenry 5 년 전
부모
커밋
fa25c613a7

+ 1 - 0
src/main/java/com/bomostory/sceneeditmodule/Config.kt

@@ -11,6 +11,7 @@ object Config {
     const val RECORD_FOLDER_NAME = "Record"
     const val IMAGE_FOLDER_NAME = "Image"
     const val MUSIC_FOLDER_NAME = "Music"
+    const val COVER_FOLDER_NAME = "Cover"
     val ASSETS_FOLDER = File(Environment.getExternalStorageDirectory(), ASSETS_FOLDER_PATH)
     val PROJECTS_FOLDER = File(Environment.getExternalStorageDirectory(), PROJECTS_FOLDER_PATH)
     const val PROJECT_FILE_NAME = "index"

+ 12 - 6
src/main/java/com/bomostory/sceneeditmodule/PdfMaker.kt

@@ -29,9 +29,12 @@ object PdfMaker {
             emitter.onNext(progress++ / total)
             val standardPdfWriter = StandardPdfWriter(file, front, back)
             project.story?.scenes?.forEach {
-                val bitmap = SceneDrawer.drawScene(context, it, 0, width, height) ?: return@forEach
-                standardPdfWriter.addImage(bitmap)
-                emitter.onNext(progress++ / total)
+                if (it != project.story?.scenes?.get(0)) {
+                    val bitmap = SceneDrawer.drawScene(context, it, 0, width, height)
+                            ?: return@forEach
+                    standardPdfWriter.addImage(bitmap)
+                    emitter.onNext(progress++ / total)
+                }
             }
             standardPdfWriter.finish()
             emitter.onComplete()
@@ -61,9 +64,12 @@ object PdfMaker {
             /** pages **/
             val pdfBookWriter = PdfBookWriter(file, front, back)
             project.story?.scenes?.forEach {
-                val bitmap = SceneDrawer.drawScene(context, it, 0, width, height) ?: return@forEach
-                pdfBookWriter.addImage(bitmap)
-                emitter.onNext(progress++ / total)
+                if (it != project.story?.scenes?.get(0)) {
+                    val bitmap = SceneDrawer.drawScene(context, it, 0, width, height)
+                            ?: return@forEach
+                    pdfBookWriter.addImage(bitmap)
+                    emitter.onNext(progress++ / total)
+                }
             }
             pdfBookWriter.finish()
             emitter.onComplete()

+ 288 - 110
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -7,6 +7,7 @@ import android.content.Context
 import android.content.DialogInterface
 import android.content.Intent
 import android.graphics.Bitmap
+import android.graphics.Canvas
 import android.os.Bundle
 import android.support.v7.app.AppCompatActivity
 import android.support.v7.widget.LinearLayoutManager
@@ -26,15 +27,10 @@ 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.EditSceneView
 import com.example.tfat.myapplication.navigationbar.NavigationBarView
 import com.example.tfat.myapplication.navigationbar.RecordFinishView
 import com.example.tfat.myapplication.navigationbar.actor.ActorAdapter
 import com.example.tfat.myapplication.navigationbar.actor.LayerManagementDialog
-import com.example.tfat.myapplication.navigationbar.scene.AddSceneAdapter
-import com.example.tfat.myapplication.navigationbar.scene.AddSceneView
-import com.example.tfat.myapplication.navigationbar.scene.ControlSceneView
-import com.example.tfat.myapplication.navigationbar.scene.SceneAdapter
 import com.google.gson.Gson
 import kotlinx.android.synthetic.main.activity_scene_edit.*
 import kotlinx.android.synthetic.main.control_actor_dialog.view.*
@@ -44,20 +40,23 @@ import kotlinx.android.synthetic.main.popupview_opacity_dialog.view.*
 import kotlinx.android.synthetic.main.view_control_dialogue_dialog.view.*
 import com.bomostory.sceneeditmodule.DialogueColorData
 import com.bomostory.sceneeditmodule.SceneDrawer
+import com.bomostory.sceneeditmodule.cover.CoverEditorDialog
 import com.bomostory.sceneeditmodule.navigationbar.actor.ObjectView
 import com.bomostory.sceneeditmodule.navigationbar.actor.NonInterceptTouchRecycleView
 import com.bomostory.sceneeditmodule.screen.draw.DrawActivity
+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.fragment_music_edit_dialog.view.*
 import kotlinx.android.synthetic.main.layer_management_fragment.*
 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.*
 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.File
 import java.util.*
 import java.util.concurrent.CopyOnWriteArrayList
@@ -67,7 +66,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 {
+        BrushView.OnSelectBrush, FileUtils.OnSaveCover {
 
     private lateinit var project: Project
     private var currentSceneIndex = 0
@@ -79,6 +78,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
     private var resourceThemeBitmap = ArrayList<String>()
     private var resourceActorBitmap = ArrayList<ArrayList<String>>()
     private var resourceObjectPath = ArrayList<String>()
+    private var themeName = ""
     private lateinit var sceneAdapter: SceneAdapter
     private var isRecord = false
     private var isAutoSwipe = false
@@ -122,7 +122,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                 for (i in 0 until it.size) {
                     it[i].sceneWidth = monitorSize.widthPixels
                 }
-                sceneEditView.scene = it[0]
+                if (project.coverFile == null) {
+                    val bitmap = CoverDrawer.drawFrontCover((monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.displayName
+                            ?: "", project.author ?: "", project.frontCoverColor.getColor(this))
+                    val bitmap2 = CoverDrawer.drawBackCover(this, (monitorSize.widthPixels) / 2, monitorSize.heightPixels, project.backCoverColor.getColor(this))
+                    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, project, bitmap3, project.name.toString())
+                } else {
+                    sceneEditView.scene = it[0]
+                }
             }
         }
         ic_scene_edit_activity_back.setOnClickListener {
@@ -135,6 +146,15 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     .doOnSubscribe { pd.show() }
                     .doFinally {
                         pd.dismiss()
+                        window.decorView.apply {
+                            systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+                                    or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                                    or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                                    or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                                    or View.SYSTEM_UI_FLAG_FULLSCREEN
+                                    or View.SYSTEM_UI_FLAG_LOW_PROFILE
+                                    or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
+                        }
                         this.onBackPressed()}
                     .subscribe {
                         listeners.forEach {it.run()}
@@ -215,13 +235,14 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             }
             else -> { intent.getStringArrayListExtra("resource_object")}
         }
+        themeName = project.themeAssetIndex.name
     }
     private fun initControlBarView() {
         controlBarView.setBtnSelected(6)
         switchToPreViewLayer()
         project.story?.let {
             it.scenes?.let {
-                if (it[currentSceneIndex].record != null) {
+                if (it[currentSceneIndex].record != null || currentSceneIndex == 0) {
                     controlBarView.visibility = View.INVISIBLE
                     sceneEditView.setOnTouchListener(null)
                 } else {
@@ -268,49 +289,80 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         var navigationBarView = NavigationBarView(this)
         project.story?.let {
             it.scenes?.let {
-                when (it[currentSceneIndex].record) {
-                    null -> {
-                        startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
-                        navigationBarView.setBtnEnable()
-                        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.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)
-
-                        })
+                if(currentSceneIndex == 0){
+                    when (it[currentSceneIndex].record) {
+                        null -> {
+                            startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
+                            navigationBarView . setBtnDisable ()
+                            navigationBar . addView (navigationBarView)
+                            navigationBarView . setonClickSceneBtn (View.OnClickListener {
+                                initControlSceneView()
+                            })
+                            navigationBarView . setonClickActorBtn (View.OnClickListener {})
+                            navigationBarView . setonClickBrushBtn (View.OnClickListener {})
+                            navigationBarView . setonClickDialogueBtn (View.OnClickListener {})
+                            navigationBarView . setonClickImageBtn (View.OnClickListener {})
+                            navigationBarView . setonClickSettingBtn (View.OnClickListener {})
+                        }
+                        else -> {
+                            startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_startover))
+                            navigationBarView . setBtnDisable ()
+                            navigationBar . addView (navigationBarView)
+                            navigationBarView . setonClickSceneBtn (View.OnClickListener {
+                                initControlSceneView()
+                            })
+                            navigationBarView . setonClickActorBtn (View.OnClickListener {})
+                            navigationBarView . setonClickBrushBtn (View.OnClickListener {})
+                            navigationBarView . setonClickDialogueBtn (View.OnClickListener {})
+                            navigationBarView . setonClickImageBtn (View.OnClickListener {})
+                            navigationBarView . setonClickSettingBtn (View.OnClickListener {})
+                        }
                     }
-                    else -> {
-                        startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_startover))
-                        navigationBarView.setBtnDisable()
-                        navigationBar.addView(navigationBarView)
-                        navigationBarView.setonClickSceneBtn(View.OnClickListener {
-                            initControlSceneView()
-                        })
-                        navigationBarView.setonClickActorBtn(View.OnClickListener {})
-                        navigationBarView.setonClickBrushBtn(View.OnClickListener {})
-                        navigationBarView.setonClickDialogueBtn(View.OnClickListener {})
-                        navigationBarView.setonClickImageBtn(View.OnClickListener {})
-                        navigationBarView.setonClickSettingBtn(View.OnClickListener {})
+                } else {
+                    when (it[currentSceneIndex].record) {
+                        null -> {
+                            startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
+                            navigationBarView.setBtnEnable()
+                            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.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)
+
+                            })
+                        }
+                        else -> {
+                            startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_startover))
+                            navigationBarView.setBtnDisable()
+                            navigationBar.addView(navigationBarView)
+                            navigationBarView.setonClickSceneBtn(View.OnClickListener {
+                                initControlSceneView()
+                            })
+                            navigationBarView.setonClickActorBtn(View.OnClickListener {})
+                            navigationBarView.setonClickBrushBtn(View.OnClickListener {})
+                            navigationBarView.setonClickDialogueBtn(View.OnClickListener {})
+                            navigationBarView.setonClickImageBtn(View.OnClickListener {})
+                            navigationBarView.setonClickSettingBtn(View.OnClickListener {})
+                        }
                     }
                 }
             }
@@ -412,6 +464,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         selectActorView.btn_scene.setOnClickListener {
             initReplaceSceneView()
         }
+        selectActorView.btn_choose_theme.text = themeName
         selectActorView.btn_choose_theme.setOnClickListener {
             chooseTheme()
         }
@@ -462,80 +515,90 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         var controlSceneView = ControlSceneView(this)
         controlSceneView.setonClickAddBtn(View.OnClickListener {
             viewContainer.removeAllViews()
-            var addSceneView = AddSceneView(this)
-            viewContainer.addView(addSceneView)
+            var replaceSceneView = ReplaceSceneView(this)
+            viewContainer.addView(replaceSceneView)
             val layoutManager = LinearLayoutManager(this)
             layoutManager.orientation = LinearLayoutManager.HORIZONTAL
             var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
             for (i in 0 until resourceThemeBitmap.size) {
                 onSceneSelectedArrayList.add(onClickAddSceneListener(i))
             }
-            var addSceneAdapter = AddSceneAdapter(this, resourceThemeBitmap, onSceneSelectedArrayList)
-            var newSceneRecyclerView = addSceneView.findViewById<RecyclerView>(R.id.new_scene_recycler_view)
+            var replaceSceneAdapter = ReplaceSceneAdapter(this, resourceThemeBitmap, onSceneSelectedArrayList)
+            var newSceneRecyclerView = replaceSceneView.findViewById<RecyclerView>(R.id.new_scene_recycler_view)
             newSceneRecyclerView.layoutManager = layoutManager
-            newSceneRecyclerView.adapter = addSceneAdapter
-            addSceneView.btn_add_scene_view_choose_theme.setOnClickListener {
+            newSceneRecyclerView.adapter = replaceSceneAdapter
+            replaceSceneView.btn_add_scene_view_choose_theme.text = themeName
+            replaceSceneView.btn_add_scene_view_choose_theme.setOnClickListener {
                 chooseTheme()
             }
-            addSceneView.btn_add_scene_view_character.setOnClickListener {
-                viewContainer.removeAllViews()
-                initActorRecyclerView()
-            }
         })
-        controlSceneView.setonClickDuplicateBtn(View.OnClickListener {
-            project.story?.let {
-                it.scenes?.let {
-                    var scene = Scene().apply {
-                        backgroundName = it[currentSceneIndex].backgroundName
-                        backgroundPath = it[currentSceneIndex].backgroundPath
-                        record = it[currentSceneIndex].record
-                        sceneWidth = it[currentSceneIndex].sceneWidth
-                        recordPath = it[currentSceneIndex].recordPath
-                        for (layer in it[currentSceneIndex].layers) {
-                            var newLayer = Layer()
-                            newLayer.id = layer.id
-                            newLayer.name = layer.name
-                            for(actor in layer.actors) {
-                                var newActor = Actor()
-                                newActor.resourcePath = actor.resourcePath
-                                newActor.positionX = actor.positionX
-                                newActor.positionY = actor.positionY
-                                newActor.positionZ = actor.positionZ
-                                newActor.sideLength = actor.sideLength
-                                newActor.sideHeight = actor.sideHeight
-                                newActor.isSelect = actor.isSelect
-                                newActor.parentLayerIndex = actor.parentLayerIndex
-                                newActor.isMovable = actor.isMovable
-                                newActor.text = actor.text
-                                newActor.textColor = actor.textColor
-                                newActor.textAlign = actor.textAlign
-                                newActor.isDialogue = actor.isDialogue
-                                newActor.isMirror = actor.isMirror
-                                newActor.opacity = actor.opacity
-                                newActor.dialogColor = actor.dialogColor
-                                newActor.dialogType = actor.dialogType
-                                newLayer.actors.add(newActor)
+        when (currentSceneIndex) {
+            0 -> {
+                controlSceneView.btn_controlSceneView_duplicate.text = resources.getString(R.string.uikit_home_edit_cover)
+                controlSceneView.setonClickDuplicateBtn(View.OnClickListener {
+                    onClickEditCover(project)
+                })
+            }
+
+            else -> {
+                controlSceneView.btn_controlSceneView_duplicate.text = resources.getString(R.string.uikit_edit_duplicate)
+                controlSceneView.setonClickDuplicateBtn(View.OnClickListener {
+                    project.story?.let {
+                        it.scenes?.let {
+                            var scene = Scene().apply {
+                                backgroundName = it[currentSceneIndex].backgroundName
+                                backgroundPath = it[currentSceneIndex].backgroundPath
+                                record = it[currentSceneIndex].record
+                                sceneWidth = it[currentSceneIndex].sceneWidth
+                                recordPath = it[currentSceneIndex].recordPath
+                                for (layer in it[currentSceneIndex].layers) {
+                                    var newLayer = Layer()
+                                    newLayer.id = layer.id
+                                    newLayer.name = layer.name
+                                    for(actor in layer.actors) {
+                                        var newActor = Actor()
+                                        newActor.resourcePath = actor.resourcePath
+                                        newActor.positionX = actor.positionX
+                                        newActor.positionY = actor.positionY
+                                        newActor.positionZ = actor.positionZ
+                                        newActor.sideLength = actor.sideLength
+                                        newActor.sideHeight = actor.sideHeight
+                                        newActor.isSelect = actor.isSelect
+                                        newActor.parentLayerIndex = actor.parentLayerIndex
+                                        newActor.isMovable = actor.isMovable
+                                        newActor.text = actor.text
+                                        newActor.textColor = actor.textColor
+                                        newActor.textAlign = actor.textAlign
+                                        newActor.isDialogue = actor.isDialogue
+                                        newActor.isMirror = actor.isMirror
+                                        newActor.opacity = actor.opacity
+                                        newActor.dialogColor = actor.dialogColor
+                                        newActor.dialogType = actor.dialogType
+                                        newLayer.actors.add(newActor)
+                                    }
+                                    layers.add(newLayer)
+                                }
                             }
-                            layers.add(newLayer)
+                            it.add(currentSceneIndex + 1, scene)
                         }
                     }
-                    it.add(currentSceneIndex + 1, scene)
-                }
-            }
-            var sceneAdapter = controlSceneView.findViewById<RecyclerView>(R.id.scene_recycler_view).adapter as SceneAdapter
-            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(SceneDrawer.drawScene(this,it[i],0,200,100))
-                        recordTimeArrayList.add(it[i].record?.period)
+                    var sceneAdapter = controlSceneView.findViewById<RecyclerView>(R.id.scene_recycler_view).adapter as SceneAdapter
+                    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(SceneDrawer.drawScene(this,it[i],0,200,100))
+                                recordTimeArrayList.add(it[i].record?.period)
+                            }
+                        }
                     }
-                }
+                    sceneAdapter.update(projectBitmaps, onSceneSelectedArrayList,recordTimeArrayList)
+                })
             }
-            sceneAdapter.update(projectBitmaps, onSceneSelectedArrayList,recordTimeArrayList)
-        })
+        }
+
         controlSceneView.setOnClickDeleteBtn(View.OnClickListener {
             var builder = AlertDialog.Builder(this@SceneEditActivity).apply {
                 setTitle(resources.getString(R.string.delete_check))
@@ -809,6 +872,10 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         addSceneView.btn_add_scene_view_object.setOnClickListener {
             initAddObjectView()
         }
+        addSceneView.btn_replace_scene_view_choose_theme.text = themeName
+        addSceneView.btn_replace_scene_view_choose_theme.setOnClickListener {
+            chooseTheme()
+        }
     }
 
     private fun initAddObjectView(){
@@ -825,6 +892,10 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         objectView.btn_scene.setOnClickListener {
             initReplaceSceneView()
         }
+        objectView.btn_choose_theme.text = themeName
+        objectView.btn_choose_theme.setOnClickListener {
+            chooseTheme()
+        }
     }
     private fun switchScene(position: Int): View.OnClickListener {
         return View.OnClickListener {
@@ -955,6 +1026,25 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         }
     }
 
+    private fun addCoverScene(coverPath: String){
+        if (!project.isAddCoverScene) {
+            var scene = Scene()
+            for (i in 5 until 0) {
+                val layer = Layer()
+                layer.id = i
+                scene.layers.add(layer)
+            }
+            scene.backgroundPath = coverPath
+            project.story?.let {
+                it.scenes?.let {
+                    scene.sceneWidth = monitorSize.widthPixels
+                    it.add(0, scene)
+                }
+            }
+            project.isAddCoverScene = true
+        }
+    }
+
     private fun replaceScene(position: Int): View.OnClickListener {
         return View.OnClickListener {
             project.story?.let {
@@ -1554,6 +1644,15 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         addActor(ACTOR_INIT_POSITION_X, ACTOR_INIT_POSITION_Y, filePath)
     }
 
+    override fun onSaveCoverImage(filePath: String) {
+        project.story?.let {
+            it.scenes?.let {
+                addCoverScene(filePath)
+                sceneEditView.scene = it[0]
+            }
+        }
+    }
+
     override fun onLayerChange(layerFrom: Int, layerTo: Int, position: Int){
         project.story?.let {
             it.scenes?.let {
@@ -1766,4 +1865,83 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             }
         }
     }
+
+    private fun onClickEditCover(project: Project) {
+        val dialog = CoverEditorDialog()
+        dialog.project = project
+        dialog.onViewCreated = Runnable {
+            dialog.apply {
+                val oldName = project.name ?: ""
+                onSave = View.OnClickListener { it ->
+                    if (project.name == "") {
+                        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.author = author
+                        project.frontCoverColor = frontCoverColor
+                        project.backCoverColor = backCoverColor
+                        project.category = category
+                        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]
+                                }
+                            }
+                        }
+                        initControlSceneView()
+                        this.dismiss()
+                        window.decorView.apply {
+                            systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+                                    or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                                    or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                                    or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                                    or View.SYSTEM_UI_FLAG_FULLSCREEN
+                                    or View.SYSTEM_UI_FLAG_LOW_PROFILE
+                                    or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
+                        }
+                    }
+                }
+                onCancel = View.OnClickListener {
+                    this.dismiss()
+                    window.decorView.apply {
+                        systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+                                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                                or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                                or View.SYSTEM_UI_FLAG_FULLSCREEN
+                                or View.SYSTEM_UI_FLAG_LOW_PROFILE
+                                or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
+                    }
+                }
+                coverFile = project.coverFile
+                storyName = project.displayName ?: ""
+                author = project.author ?: ""
+                category = project.category
+                if (project.coverFile == null) {
+                    frontCoverColor = project.frontCoverColor
+                }
+                backCoverColor = project.backCoverColor
+            }
+        }
+        dialog.show(supportFragmentManager)
+    }
 }

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

@@ -26,7 +26,8 @@ data class Project (
     // TODO : Remove this
         var actorResource: ArrayList<ArrayList<String>>? = null,
     // TODO : Remove this
-        var sceneResource: ArrayList<String>? = null
+        var sceneResource: ArrayList<String>? = null,
+        var isAddCoverScene: Boolean = false
 ) {
     var displayName: String? = null
 

+ 3 - 0
src/main/java/com/bomostory/sceneeditmodule/basicdata/Scene.kt

@@ -1,5 +1,7 @@
 package com.bomostory.sceneeditmodule.basicdata
 
+import android.graphics.Bitmap
+
 class Scene {
     var layers = ArrayList<Layer>().apply {
         for (i in 0 until 5) {
@@ -11,6 +13,7 @@ class Scene {
     var record: Record? = null
     var backgroundPath: String? = null
     var backgroundName: String? = null
+    var coverBitmap:Bitmap? = null
     var sceneWidth: Int = 0
     var recordPath: String? = null
 }

+ 2 - 2
src/main/java/com/bomostory/sceneeditmodule/cover/FrontCoverSceneChooserView.kt

@@ -102,7 +102,7 @@ class FrontCoverSceneChooserView @JvmOverloads constructor(
             val height = context.resources.getDimension(R.dimen.share_dialog_screenshot_height).toInt()
             val bitmap = SceneDrawer.drawScene(context, scene, 0, width, height) ?: return@forEach
             val isSelected = i == selected
-            val name = Utils.generateSceneName(i)
+            val name = Utils.generateSceneName(i - 1)
             val onSelectedListener = object : OnSelectedListener {
                 override fun onSelected(data: Data) {
                     lastSelectedData?.isSelected = false
@@ -115,7 +115,7 @@ class FrontCoverSceneChooserView @JvmOverloads constructor(
                 }
             }
             val data = Data(isSelected, bitmap, name, onSelectedListener)
-            dataList.add(data)
+            if (i != 0) dataList.add(data)
             i++
         }
         adapter.notifyDataSetChanged()

+ 1 - 1
src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/ControlSceneView.kt

@@ -30,7 +30,7 @@ class ControlSceneView : RelativeLayout {
     }
 
     fun setonClickDuplicateBtn(onClickListener: OnClickListener) {
-        duplicate.setOnClickListener(onClickListener)
+        btn_controlSceneView_duplicate.setOnClickListener(onClickListener)
     }
 
     fun setOnClickDeleteBtn(onClickListener: OnClickListener){

+ 36 - 0
src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/ReplaceSceneAdapter.kt

@@ -0,0 +1,36 @@
+package com.example.tfat.myapplication.navigationbar.scene
+
+import android.content.Context
+import android.graphics.Bitmap
+import android.graphics.drawable.Drawable
+import android.os.Environment
+import android.support.v7.widget.RecyclerView
+import android.view.*
+import android.widget.ImageView
+import com.example.tfat.myapplication.R
+import kotlin.collections.ArrayList
+
+class ReplaceSceneAdapter(var context : Context, var data: ArrayList<String>, onClickListenerList: ArrayList<View.OnClickListener>) : RecyclerView.Adapter<ReplaceSceneAdapter.ViewHolder>() {
+    private var bitmapData = data
+    private var onClickListenerList = onClickListenerList
+
+    override fun getItemCount(): Int {
+        return bitmapData.size
+    }
+
+    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+        holder.bind(bitmapData?.get(position), position, onClickListenerList)
+    }
+
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+        val v1 = LayoutInflater.from(parent.context).inflate(R.layout.item_replace_scene, parent, false)
+        return ViewHolder(v1)
+    }
+
+    class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
+        fun bind(filePath: String?, position : Int, onClickListenerList: ArrayList<View.OnClickListener>) {
+            itemView.findViewById<ImageView>(R.id.new_scene_image).setImageDrawable(Drawable.createFromPath(filePath))
+            itemView.findViewById<ImageView>(R.id.new_scene_image).setOnClickListener(onClickListenerList[position])
+        }
+    }
+}

+ 18 - 0
src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/ReplaceSceneView.kt

@@ -0,0 +1,18 @@
+package com.example.tfat.myapplication.navigationbar.scene
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.widget.RelativeLayout
+import com.example.tfat.myapplication.R
+
+class ReplaceSceneView : RelativeLayout {
+
+    constructor(context: Context) : super(context) {
+        initView()
+    }
+
+    private fun initView() {
+        val inflater = LayoutInflater.from(context)
+        var rootView = inflater.inflate(R.layout.replace_scene_view, this, true)
+    }
+}

+ 8 - 3
src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/SceneAdapter.kt

@@ -16,13 +16,14 @@ class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickL
     private var onClickListenerList = onClickListenerList
     private var sceneIndex = sceneIndex
     private var recordTimeArrayList = recordTime
+    private var cover = context.resources.getString(R.string.uikit_edit_cover)
 
     override fun getItemCount(): Int {
         return data.size
     }
 
     override fun onBindViewHolder(holder: ViewHolder, position: Int) {
-        holder.bind(data?.get(position), position, onClickListenerList, sceneIndex, recordTimeArrayList[position])
+        holder.bind(data?.get(position), position, onClickListenerList, sceneIndex, recordTimeArrayList[position], cover)
     }
 
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
@@ -31,10 +32,14 @@ class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickL
     }
 
     class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
-        fun bind(bitmap: Bitmap?, position : Int, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex: Int, recordTime: Long?) {
+        fun bind(bitmap: Bitmap?, position : Int, onClickListenerList: ArrayList<View.OnClickListener>, sceneIndex: Int, recordTime: Long?, cover: String) {
             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 = Utils.generateSceneName(position)
+            if (position == 0){
+                itemView.findViewById<TextView>(R.id.scene_number).text = cover
+            } else {
+                itemView.findViewById<TextView>(R.id.scene_number).text = Utils.generateSceneName(position - 1)
+            }
             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()}

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

@@ -224,6 +224,25 @@ object FileUtils {
         }
     }
 
+    fun saveCover(context: Context, project: Project, bitmap: Bitmap?, fileName: String){
+        val dir = File("${getProjectPath(project)}/${Config.COVER_FOLDER_NAME}/")
+        dir.mkdirs()
+        val file = File(dir, fileName.plus(".png"))
+        try {
+            val bos = BufferedOutputStream(FileOutputStream(file))
+            bitmap?.compress(Bitmap.CompressFormat.PNG, 80, bos)
+            bos.flush()
+            bos.close()
+            if (context is OnSaveCover) {
+                context.onSaveCoverImage(file.path)
+            } else {
+                throw RuntimeException(context.toString() + " must implement OnFragmentInteractionListener")
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
+
     private fun readFileToString(file: File): String {
         if (!file.exists()) return ""
         return FileReader(file).run {
@@ -321,7 +340,7 @@ object FileUtils {
                         var fileOutputStream = FileOutputStream(project.scene1File)
                         project.story?.let {
                             it.scenes?.let {
-                                SceneDrawer.drawScene(context, it[0], 0, scaleWidth, scaleHeight)?.compress(Bitmap.CompressFormat.PNG,
+                                SceneDrawer.drawScene(context, it[1], 0, scaleWidth, scaleHeight)?.compress(Bitmap.CompressFormat.PNG,
                                         100, fileOutputStream)
                                 fileOutputStream.flush()
                                 fileOutputStream.close()
@@ -330,7 +349,7 @@ object FileUtils {
                         fileOutputStream = FileOutputStream(project.scene2File)
                         project.story?.let {
                             it.scenes?.let {
-                                SceneDrawer.drawScene(context, it[1], 0, scaleWidth, scaleHeight)?.compress(Bitmap.CompressFormat.PNG,
+                                SceneDrawer.drawScene(context, it[2], 0, scaleWidth, scaleHeight)?.compress(Bitmap.CompressFormat.PNG,
                                         100, fileOutputStream)
                                 fileOutputStream.flush()
                                 fileOutputStream.close()
@@ -349,4 +368,8 @@ object FileUtils {
     interface OnSaveActorImage {
         fun onSaveActorImage(filePath: String)
     }
+
+    interface OnSaveCover {
+        fun onSaveCoverImage(filePath: String)
+    }
 }

+ 0 - 1
src/main/res/layout/actor_select_view.xml

@@ -18,7 +18,6 @@
             android:textColor="#ffecb3"
             android:background="#212121"
             android:text="@string/uikit_edit_choose_theme"
-            android:textAllCaps="true"
             android:drawableLeft="@drawable/ic_style"
             app:layout_constraintLeft_toLeftOf="parent"/>
         <Button

+ 2 - 41
src/main/res/layout/add_scene_view.xml

@@ -11,7 +11,7 @@ android:background="#212121">
         android:layout_height="40dp"
         android:paddingLeft="16dp">
         <Button
-            android:id="@+id/btn_add_scene_view_choose_theme"
+            android:id="@+id/btn_replace_scene_view_choose_theme"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textSize="14sp"
@@ -67,44 +67,5 @@ android:background="#212121">
 
 
 
-    <!--<?xml version="1.0" encoding="utf-8"?>-->
-    <!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
-    <!--android:layout_width="match_parent"-->
-    <!--android:layout_height="136dp"-->
-    <!--android:orientation="vertical"-->
-    <!--android:layout_above="@+id/navigation_bar"-->
-    <!--android:background="#212121">-->
-    <!--<RelativeLayout-->
-    <!--android:layout_width="match_parent"-->
-    <!--android:layout_height="40dp"-->
-    <!--android:paddingLeft="16dp">-->
-    <!--<Button-->
-    <!--android:id="@+id/btn_add_scene_view_choose_theme"-->
-    <!--android:layout_width="wrap_content"-->
-    <!--android:layout_height="wrap_content"-->
-    <!--android:layout_alignParentLeft="true"-->
-    <!--android:layout_centerVertical="true"-->
-    <!--android:background="#212121"-->
-    <!--android:drawableStart="@drawable/ic_style"-->
-    <!--android:textSize="14sp"-->
-    <!--android:textColor="#ffecb3"-->
-    <!--android:text="@string/uikit_edit_choose_theme"/>-->
-    <!--<TextView-->
-    <!--android:layout_width="wrap_content"-->
-    <!--android:layout_height="wrap_content"-->
-    <!--android:textSize="20sp"-->
-    <!--android:layout_centerHorizontal="true"-->
-    <!--android:layout_centerVertical="true"-->
-    <!--android:textColor="#ffffff"-->
-    <!--android:textAllCaps="true"-->
-    <!--android:text="@string/theme_name"/>-->
-    <!--</RelativeLayout>-->
-    <!--<android.support.v7.widget.RecyclerView-->
-    <!--android:id="@+id/new_scene_recycler_view"-->
-    <!--android:paddingLeft="8dp"-->
-    <!--android:layout_width="match_parent"-->
-    <!--android:layout_height="96dp"-->
-    <!--android:background="#f0ebe1">-->
-    <!--</android.support.v7.widget.RecyclerView>-->
-    <!--</LinearLayout>-->
+
 

+ 8 - 0
src/main/res/layout/item_replace_scene.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ImageView
+    android:id="@+id/new_scene_image"
+    android:layout_width="144dp"
+    android:layout_height="80dp"
+    android:layout_marginRight="8dp"
+    xmlns:android="http://schemas.android.com/apk/res/android" />
+

+ 40 - 0
src/main/res/layout/replace_scene_view.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+android:layout_width="match_parent"
+android:layout_height="136dp"
+android:orientation="vertical"
+android:layout_above="@+id/navigation_bar"
+android:background="#212121">
+    <RelativeLayout
+    android:layout_width="match_parent"
+    android:layout_height="40dp"
+    android:paddingLeft="16dp">
+        <Button
+        android:id="@+id/btn_add_scene_view_choose_theme"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_centerVertical="true"
+        android:background="#212121"
+        android:drawableStart="@drawable/ic_style"
+        android:textSize="14sp"
+        android:textColor="#ffecb3"
+        android:text="@string/uikit_edit_choose_theme"/>
+        <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="20sp"
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"
+        android:textColor="#ffffff"
+        android:textAllCaps="true"
+        android:text="@string/theme_name"/>
+    </RelativeLayout>
+    <android.support.v7.widget.RecyclerView
+    android:id="@+id/new_scene_recycler_view"
+    android:paddingLeft="8dp"
+    android:layout_width="match_parent"
+    android:layout_height="96dp"
+    android:background="#f0ebe1">
+    </android.support.v7.widget.RecyclerView>
+</LinearLayout>

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

@@ -7,7 +7,7 @@
 
     <android.support.v7.widget.RecyclerView
         android:id="@+id/scene_recycler_view"
-        android:layout_width="700dp"
+        android:layout_width="660dp"
         android:layout_height="120dp"
         android:layout_marginStart="40dp"
         android:layout_marginEnd="20dp"
@@ -16,7 +16,7 @@
         app:layout_constraintBottom_toBottomOf="parent" />
 
     <Button
-        android:id="@+id/duplicate"
+        android:id="@+id/btn_controlSceneView_duplicate"
         android:layout_width="96dp"
         android:layout_height="64dp"
         android:layout_marginTop="36dp"