Parcourir la source

bomoPhase2-fix

faterhenry il y a 5 ans
Parent
commit
f688461735
27 fichiers modifiés avec 580 ajouts et 87 suppressions
  1. 1 1
      src/main/java/com/bomostory/sceneeditmodule/ImageOperation.kt
  2. 12 2
      src/main/java/com/bomostory/sceneeditmodule/SceneDrawer.kt
  3. 325 62
      src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt
  4. 5 3
      src/main/java/com/bomostory/sceneeditmodule/basicdata/Scene.kt
  5. 3 3
      src/main/java/com/bomostory/sceneeditmodule/cover/CoverEditorDialog.kt
  6. 1 1
      src/main/java/com/bomostory/sceneeditmodule/cover/FrontCoverSceneChooserView.kt
  7. 4 1
      src/main/java/com/bomostory/sceneeditmodule/layermanagement/ItemMoveSwipeListener.kt
  8. 6 1
      src/main/java/com/bomostory/sceneeditmodule/layermanagement/ItemTouchHelpCallback.kt
  9. 5 1
      src/main/java/com/bomostory/sceneeditmodule/layermanagement/LayerAdapter.kt
  10. 10 1
      src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/AddSceneAdapter.kt
  11. 12 1
      src/main/java/com/bomostory/sceneeditmodule/navigationbar/scene/SceneAdapter.kt
  12. 7 0
      src/main/java/com/bomostory/sceneeditmodule/sceneview/OnTouchSceneListener.kt
  13. 14 1
      src/main/java/com/bomostory/sceneeditmodule/sceneview/SceneView1.kt
  14. 6 6
      src/main/java/com/bomostory/sceneeditmodule/screen/draw/DrawActivity.kt
  15. 1 1
      src/main/java/com/bomostory/sceneeditmodule/screen/view/ActorView.kt
  16. 12 0
      src/main/java/com/bomostory/sceneeditmodule/screen/view/EditActorView.kt
  17. 17 1
      src/main/java/com/bomostory/sceneeditmodule/screen/view/MovieView.kt
  18. 3 0
      src/main/java/com/bomostory/sceneeditmodule/share/ShareDialog.kt
  19. 24 0
      src/main/java/com/bomostory/sceneeditmodule/utils/FileUtils.kt
  20. 5 0
      src/main/res/drawable/bg_rounded_8dp_cooa_stroke.xml
  21. 6 0
      src/main/res/drawable/bg_rounded_8dp_white_stroke.xml
  22. 5 0
      src/main/res/drawable/ic_chevron_left_black_24dp.xml
  23. 5 0
      src/main/res/drawable/ic_chevron_right_black_24dp.xml
  24. 6 0
      src/main/res/drawable/ic_photolibrary.xml
  25. 34 0
      src/main/res/layout/activity_scene_edit.xml
  26. 50 0
      src/main/res/layout/control_background_dialog.xml
  27. 1 1
      src/main/res/layout/view_front_cover_scene_chooser.xml

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

@@ -4,7 +4,7 @@ import android.graphics.*
 import android.graphics.Paint.ANTI_ALIAS_FLAG
 
 object ImageOperation {
-    fun imageoperation(mbitmap: Bitmap, hue: Float, saturation: Float, lum: Float): Bitmap {
+    fun imageOperation(mbitmap: Bitmap, hue: Float, saturation: Float, lum: Float): Bitmap {
         val mbitmap_fu = Bitmap.createBitmap(mbitmap.getWidth(), mbitmap.getHeight(), Bitmap.Config.ARGB_8888)
         val canvas = Canvas(mbitmap_fu)
         val mpaint = Paint(ANTI_ALIAS_FLAG)

+ 12 - 2
src/main/java/com/bomostory/sceneeditmodule/SceneDrawer.kt

@@ -2,6 +2,7 @@ package com.bomostory.sceneeditmodule
 
 import android.content.Context
 import android.graphics.*
+import android.graphics.drawable.BitmapDrawable
 import com.bomostory.sceneeditmodule.basicdata.Actor
 import com.bomostory.sceneeditmodule.basicdata.Scene
 import pl.droidsonroids.gif.GifDrawable
@@ -128,7 +129,8 @@ object SceneDrawer {
             paint.alpha = (actor.opacity * 255).toInt()
             if (actor.isMirror)
                 canvas.scale(-1f, 1f, actorX + bitmapWidth / 2, actorY + bitmapHeight / 2)
-            canvas.drawBitmap(bitmap, actorX, actorY, paint)
+            val adjustBitmap = (ImageOperation.imageOperation(bitmap,actor.hue,actor.saturation.div(50),actor.brightness.div(50)))
+            canvas.drawBitmap(adjustBitmap, actorX, actorY, paint)
         } else {
             var actorX = (actor.positionX).toFloat()
             var actorY = (actor.positionY).toFloat()
@@ -180,7 +182,15 @@ object SceneDrawer {
 
     private fun loadBitmaps(context: Context, scaleWidth: Int, scaleHeight: Int, createGifData: Boolean) {
         nowScene?.apply {
-            sceneBitmap = BitmapFactory.decodeFile(backgroundPath)
+            var backgroundBitmap = (ImageOperation.imageOperation(BitmapFactory.decodeFile(backgroundPath),hue,saturation.div(50),brightness.div(50)))
+            when(isBackGroundMirror){
+                true -> {
+                    val matrix = Matrix()
+                    matrix.postScale(-1f, 1f)
+                    backgroundBitmap = Bitmap.createBitmap(backgroundBitmap, 0, 0, backgroundBitmap.width, backgroundBitmap.height, matrix, true)
+                }
+            }
+            sceneBitmap = backgroundBitmap
             sceneBitmap = Bitmap.createScaledBitmap(sceneBitmap, (scaleWidth * 33 / 32f).toInt(), scaleHeight, true)
             sceneBitmap = sceneBitmap?.copy(Bitmap.Config.ARGB_8888, true)
             for (layer in layers) {

+ 325 - 62
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

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

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

@@ -1,7 +1,5 @@
 package com.bomostory.sceneeditmodule.basicdata
 
-import android.graphics.Bitmap
-
 class Scene {
     var layers = ArrayList<Layer>().apply {
         for (i in 0 until 5) {
@@ -13,7 +11,11 @@ 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
+    var isBackGroundMirror = false
+    var hue = 0f
+    var brightness = 50f
+    var saturation =  50f
+
 }

+ 3 - 3
src/main/java/com/bomostory/sceneeditmodule/cover/CoverEditorDialog.kt

@@ -141,12 +141,12 @@ class CoverEditorDialog : DialogFragment() {
             frontCoverSceneChooser_frontCoverEditor.apply {
                 this.onApply = View.OnClickListener {
                     this@CoverEditorDialog.frontCoverSceneChooser_frontCoverEditor.visibility = View.GONE
-                    val selectedSceneIndex = this@CoverEditorDialog.frontCoverSceneChooser_frontCoverEditor.selected
+                    val selectedSceneIndex = this@CoverEditorDialog.frontCoverSceneChooser_frontCoverEditor.selected + 1
                     val scenes = this@CoverEditorDialog.project?.story?.scenes ?: return@OnClickListener
                     val scene = scenes[selectedSceneIndex]
                     val alignStyle = this@CoverEditorDialog.frontCoverSceneChooser_frontCoverEditor.alignStyle
-                    val width = context.resources.getDimension(R.dimen.share_dialog_screenshot_width).toInt()
-                    val height = context.resources.getDimension(R.dimen.share_dialog_screenshot_height).toInt()
+                    val width = 1920
+                    val height = 1080
                     val bitmap = SceneDrawer.drawScene(context, scene, 0, width, height)?.crop(alignStyle)
                             ?: return@OnClickListener
                     val file = FileUtils.getCoverFile(project!!)

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

@@ -124,7 +124,7 @@ class FrontCoverSceneChooserView @JvmOverloads constructor(
 
     private fun updateCover() {
         val scenes = project?.story?.scenes ?: return
-        val scene = scenes[selected]
+        val scene = scenes[selected + 1]
         val width = context.resources.getDimension(R.dimen.share_dialog_screenshot_width).toInt()
         val height = context.resources.getDimension(R.dimen.share_dialog_screenshot_height).toInt()
         val bitmap = SceneDrawer.drawScene(context, scene, 0, width, height)?.crop(alignStyle)

+ 4 - 1
src/main/java/com/bomostory/sceneeditmodule/layermanagement/ItemMoveSwipeListener.kt

@@ -1,7 +1,10 @@
 package com.bomostory.sceneeditmodule.layermanagement
 
+import android.support.v7.widget.RecyclerView
+
 interface ItemMoveSwipeListener {
     fun onItemMove(fromPosition: Int, toPosition: Int): Boolean
     fun onItemSwipe(position: Int)
-    fun clearView()
+    fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int)
+    fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder)
 }

+ 6 - 1
src/main/java/com/bomostory/sceneeditmodule/layermanagement/ItemTouchHelpCallback.kt

@@ -19,8 +19,13 @@ class ItemTouchHelpCallback (private val itemMoveSwipeListener: ItemMoveSwipeLis
         itemMoveSwipeListener.onItemSwipe(viewHolder.adapterPosition)
     }
 
+    override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
+        itemMoveSwipeListener.onSelectedChanged(viewHolder, actionState)
+        super.onSelectedChanged(viewHolder, actionState)
+    }
+
     override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
-        itemMoveSwipeListener.clearView()
+        itemMoveSwipeListener.clearView(recyclerView,viewHolder)
         super.clearView(recyclerView, viewHolder)
     }
 }

+ 5 - 1
src/main/java/com/bomostory/sceneeditmodule/layermanagement/LayerAdapter.kt

@@ -2,6 +2,7 @@ package com.bomostory.sceneeditmodule.layermanagement
 
 import android.graphics.drawable.Drawable
 import android.support.v7.widget.RecyclerView
+import android.support.v7.widget.helper.ItemTouchHelper
 import android.view.*
 import com.bomostory.sceneeditmodule.basicdata.Actor
 import com.example.tfat.myapplication.R
@@ -51,10 +52,13 @@ class LayerAdapter (actorData: ArrayList<Actor>, actorListeners: ArrayList<View.
     override fun onItemSwipe(position: Int) {
     }
 
-    override fun clearView() {
+    override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
         listener.clearView()
     }
 
+    override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
+    }
+
     interface ItemMoveListener{
         fun onItemMove(layerNum: Int, fromPosition: Int, toPosition: Int)
         fun clearView()

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

@@ -29,7 +29,16 @@ class AddSceneAdapter(var context : Context, var data: ArrayList<String>, onClic
 
     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))
+            when(position){
+                0 -> {
+                    itemView.findViewById<ImageView>(R.id.new_scene_image).setImageResource(R.drawable.ic_photolibrary)
+                    itemView.findViewById<ImageView>(R.id.new_scene_image).scaleType = ImageView.ScaleType.CENTER
+                    itemView.findViewById<ImageView>(R.id.new_scene_image).setBackgroundResource(R.drawable.bg_rounded_8dp_cooa_stroke)
+                }
+                else -> {
+                    itemView.findViewById<ImageView>(R.id.new_scene_image).setImageDrawable(Drawable.createFromPath(filePath))
+                }
+            }
             itemView.findViewById<ImageView>(R.id.new_scene_image).setOnClickListener(onClickListenerList[position])
         }
     }

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

@@ -4,6 +4,7 @@ import android.content.Context
 import android.graphics.Bitmap
 import android.graphics.drawable.Drawable
 import android.support.v7.widget.RecyclerView
+import android.support.v7.widget.helper.ItemTouchHelper
 import android.view.*
 import android.widget.ImageView
 import android.widget.TextView
@@ -64,7 +65,9 @@ class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickL
         this.notifyDataSetChanged()
     }
 
-    override fun clearView() {
+    override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
+        viewHolder.itemView.scaleX = 1.0f
+        viewHolder.itemView.scaleY = 1.0f
         listener.clearView()
     }
 
@@ -74,9 +77,17 @@ class SceneAdapter(var context : Context, var data: ArrayList<Bitmap?>, onClickL
             notifyItemMoved(fromPosition, toPosition)
             listener.onItemMove(fromPosition, toPosition)
         }
+
         return true
     }
 
+    override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
+        if (actionState != ItemTouchHelper.ACTION_STATE_IDLE && null != viewHolder) {
+            viewHolder.itemView.scaleX = 0.9f
+            viewHolder.itemView.scaleY = 0.9f
+        }
+    }
+
     override fun onItemSwipe(position: Int) {
 
     }

+ 7 - 0
src/main/java/com/bomostory/sceneeditmodule/sceneview/OnTouchSceneListener.kt

@@ -6,10 +6,12 @@ import android.view.View
 class OnTouchSceneListener : View.OnTouchListener{
     var positionX = 0f
     var onSceneTouchCallBack: OnSceneTouchListener? = null
+    var clickTime = 0L
 
     override fun onTouch(v: View?, event: MotionEvent?): Boolean {
             when (event?.action) {
                 MotionEvent.ACTION_DOWN -> {
+                    clickTime = System.currentTimeMillis()
                     positionX = event.x
                     onSceneTouchCallBack?.onSceneTouch()
                 }
@@ -17,6 +19,10 @@ class OnTouchSceneListener : View.OnTouchListener{
 
                 }
                 MotionEvent.ACTION_UP -> {
+                    if ((System.currentTimeMillis() - clickTime) > 1000) {
+                        clickTime = 0
+                        onSceneTouchCallBack?.onSceneLongClick()
+                    }
                 }
             }
         return true
@@ -27,6 +33,7 @@ class OnTouchSceneListener : View.OnTouchListener{
     }
     interface OnSceneTouchListener{
         fun onSceneTouch()
+        fun onSceneLongClick()
     }
 
 }

+ 14 - 1
src/main/java/com/bomostory/sceneeditmodule/sceneview/SceneView1.kt

@@ -1,11 +1,16 @@
 package com.bomostory.sceneeditmodule.screen.view
 
 import android.content.Context
+import android.graphics.Bitmap
+import android.graphics.BitmapFactory
+import android.graphics.Matrix
+import android.graphics.drawable.BitmapDrawable
 import android.graphics.drawable.Drawable
 import android.support.constraint.ConstraintLayout
 import android.util.AttributeSet
 import android.view.View
 import android.widget.RelativeLayout
+import com.bomostory.sceneeditmodule.ImageOperation
 import com.bomostory.sceneeditmodule.basicdata.Scene
 import kotlin.math.pow
 
@@ -22,7 +27,15 @@ class SceneView1 : ConstraintLayout {
                 backgroundView = LayerView(context)
                 var lParams = RelativeLayout.LayoutParams(it.sceneWidth + it.sceneWidth.div(32),it.sceneWidth.div(2))
                 backgroundView?.layoutParams = lParams
-                backgroundView?.background = Drawable.createFromPath(it.backgroundPath)
+                var backgroundBitmap = (ImageOperation.imageOperation(BitmapFactory.decodeFile(it.backgroundPath),it.hue,it.saturation.div(50),it.brightness.div(50)))
+                when(it.isBackGroundMirror){
+                    true -> {
+                        val matrix = Matrix()
+                        matrix.postScale(-1f, 1f)
+                        backgroundBitmap = Bitmap.createBitmap(backgroundBitmap, 0, 0, backgroundBitmap.width, backgroundBitmap.height, matrix, true)
+                    }
+                }
+                backgroundView?.background = BitmapDrawable(backgroundBitmap)
                 backgroundView?.x = -(it.sceneWidth.div(64)).toFloat()
                 addView(backgroundView)
                 for (layer in it.layers) {

+ 6 - 6
src/main/java/com/bomostory/sceneeditmodule/screen/draw/DrawActivity.kt

@@ -49,15 +49,16 @@ class DrawActivity : AppCompatActivity() , FileUtils.OnSaveActorImage{
         drawViewLayout.addView(drawView)
 
         project = Gson().fromJson<Project>(intent.getStringExtra("project"), Project::class.java)
+        val currentScene = intent.getIntExtra("currentScene",1)
         project.story?.let {
             it.scenes?.let {
                 var layoutPrams = view_drawActivity_sceneEditView.layoutParams
-                layoutPrams.width = it[1].sceneWidth
-                layoutPrams.height = it[1].sceneWidth.div(2)
-                view_drawActivity_sceneEditView.scene = it[1]
+                layoutPrams.width = it[currentScene].sceneWidth
+                layoutPrams.height = it[currentScene].sceneWidth.div(2)
+                view_drawActivity_sceneEditView.scene = it[currentScene]
                 var drawViewLayoutPrams = drawViewLayout.layoutParams
-                drawViewLayoutPrams.width = it[1].sceneWidth
-                drawViewLayoutPrams.height = it[1].sceneWidth.div(2)
+                drawViewLayoutPrams.width = it[currentScene].sceneWidth
+                drawViewLayoutPrams.height = it[currentScene].sceneWidth.div(2)
             }
         }
         //TODO change button to your widget
@@ -237,7 +238,6 @@ class DrawActivity : AppCompatActivity() , FileUtils.OnSaveActorImage{
             for (j in 0 until drawView.drawerBitmap.width) {
                 if(drawView.drawerBitmap.getPixel(j, i) != 0) {
                     bottom = i
-                    Log.d("TEST12345", "TT" + i.toString())
                     break
                 }
                 if (bottom > 0) break

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

@@ -25,7 +25,7 @@ class ActorView : ImageView {
                         setImageDrawable(gifDrawable)
                         gifDrawable?.start()
                     } else {
-                        setImageBitmap(ImageOperation.imageoperation(BitmapFactory.decodeFile(it.resourcePath),it.hue,it.saturation.div(50),it.brightness.div(50)))
+                        setImageBitmap(ImageOperation.imageOperation(BitmapFactory.decodeFile(it.resourcePath),it.hue,it.saturation.div(50),it.brightness.div(50)))
                     }
                 }
                 if (it.isMirror && !it.isDialogue) {

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

@@ -155,6 +155,9 @@ open class EditActorView @JvmOverloads constructor(
                         isDialogue = actor.isDialogue
                         isMirror = actor.isMirror
                         opacity = actor.opacity
+                        hue = actor.hue
+                        brightness = actor.brightness
+                        saturation = actor.saturation
                     }
                     actor = actorData
                 }
@@ -212,6 +215,9 @@ open class EditActorView @JvmOverloads constructor(
                         isDialogue = actor.isDialogue
                         isMirror = actor.isMirror
                         opacity = actor.opacity
+                        hue = actor.hue
+                        brightness = actor.brightness
+                        saturation = actor.saturation
                     }
                     actor = actorData
                 }
@@ -267,6 +273,9 @@ open class EditActorView @JvmOverloads constructor(
                         isDialogue = actor.isDialogue
                         isMirror = actor.isMirror
                         opacity = actor.opacity
+                        hue = actor.hue
+                        brightness = actor.brightness
+                        saturation = actor.saturation
                     }
                     actor = actorData
                 }
@@ -322,6 +331,9 @@ open class EditActorView @JvmOverloads constructor(
                         isDialogue = actor.isDialogue
                         isMirror = actor.isMirror
                         opacity = actor.opacity
+                        hue = actor.hue
+                        brightness = actor.brightness
+                        saturation = actor.saturation
                     }
                     actor = actorData
                 }

+ 17 - 1
src/main/java/com/bomostory/sceneeditmodule/screen/view/MovieView.kt

@@ -1,7 +1,11 @@
 package com.bomostory.sceneeditmodule.screen.view
 
 import android.content.Context
+import android.graphics.Bitmap
+import android.graphics.BitmapFactory
+import android.graphics.Matrix
 import android.graphics.Paint
+import android.graphics.drawable.BitmapDrawable
 import android.graphics.drawable.Drawable
 import android.support.constraint.ConstraintLayout
 import android.util.AttributeSet
@@ -9,6 +13,7 @@ import android.util.DisplayMetrics
 import android.view.ViewGroup
 import android.view.WindowManager
 import android.widget.RelativeLayout
+import com.bomostory.sceneeditmodule.ImageOperation
 import com.bomostory.sceneeditmodule.basicdata.Actor
 import com.bomostory.sceneeditmodule.basicdata.Scene
 import kotlin.math.pow
@@ -36,7 +41,15 @@ class MovieView : ConstraintLayout {
                     val height = (it.sceneWidth / 2 * heightScaleFactor).toInt()
                     var lParams = RelativeLayout.LayoutParams(width, height)
                     layoutParams = lParams
-                    background = Drawable.createFromPath(it.backgroundPath)
+                    var backgroundBitmap = (ImageOperation.imageOperation(BitmapFactory.decodeFile(it.backgroundPath),it.hue,it.saturation.div(50),it.brightness.div(50)))
+                    when(it.isBackGroundMirror){
+                        true -> {
+                            val matrix = Matrix()
+                            matrix.postScale(-1f, 1f)
+                            backgroundBitmap = Bitmap.createBitmap(backgroundBitmap, 0, 0, backgroundBitmap.width, backgroundBitmap.height, matrix, true)
+                        }
+                    }
+                    background = BitmapDrawable(backgroundBitmap)
                     x = -width / 64f
                 }
                 addView(backgroundView)
@@ -73,6 +86,9 @@ class MovieView : ConstraintLayout {
                             opacity = actor.opacity
                             dialogColor = actor.dialogColor
                             dialogType = actor.dialogType
+                            hue = actor.hue
+                            saturation = actor.saturation
+                            brightness = actor.brightness
                         }
                         actorsFix.add(actorFix)
                     }

+ 3 - 0
src/main/java/com/bomostory/sceneeditmodule/share/ShareDialog.kt

@@ -1,5 +1,6 @@
 package com.bomostory.sceneeditmodule.share
 
+import android.app.Dialog
 import android.graphics.PorterDuff
 import android.media.MediaMetadataRetriever
 import android.os.Bundle
@@ -82,6 +83,7 @@ class ShareDialog : DialogFragment() {
                 }
 
                 iv_shareDialog_play.setOnClickListener {
+                    isCancelable = false
                     it.visibility = View.INVISIBLE
                     iv_shareDialog_pause.visibility = View.VISIBLE
 
@@ -108,6 +110,7 @@ class ShareDialog : DialogFragment() {
                     iv_shareDialog_play.visibility = View.VISIBLE
                     videoShareDialogPreview.pause()
                     isPause = true
+                    isCancelable = true
                 }
 
                 tv_shareDialog_time?.text = getString(R.string.preview_progress_time,TimeUtils.getPlayMovieTimeFormat(seekBarMoviePlay.progress.toLong()),TimeUtils.getPlayMovieTimeFormat(seekBarMoviePlay.max.toLong()))

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

@@ -205,6 +205,26 @@ object FileUtils {
         }
     }
 
+    fun saveImageForTheme(context: Context, project: Project, uri: Uri, fileName: String){
+        val dir = File("${getProjectPath(project)}/${Config.IMAGE_FOLDER_NAME}/")
+        dir.mkdirs()
+        val file = File(dir, fileName.plus(".jpg"))
+        try {
+            val bitmap = MediaStore.Images.Media.getBitmap(context.contentResolver, uri)
+            val bos = BufferedOutputStream(FileOutputStream(file))
+            bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bos)
+            bos.flush()
+            bos.close()
+            if (context is OnSaveThemeImage) {
+                context.onSaveThemeImage(file.path)
+            } else {
+                throw RuntimeException(context.toString() + " must implement OnFragmentInteractionListener")
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
+
     fun saveBitmapForActor(context: Context, project: Project, bitmap: Bitmap?, fileName: String){
         val dir = File("${getProjectPath(project)}/${Config.IMAGE_FOLDER_NAME}/")
         dir.mkdirs()
@@ -372,4 +392,8 @@ object FileUtils {
     interface OnSaveCover {
         fun onSaveCoverImage(filePath: String)
     }
+
+    interface OnSaveThemeImage {
+        fun onSaveThemeImage(filePath: String)
+    }
 }

+ 5 - 0
src/main/res/drawable/bg_rounded_8dp_cooa_stroke.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@android:color/transparent" />
+    <stroke android:width="2px" android:color="@color/cocoa" />
+</shape>

+ 6 - 0
src/main/res/drawable/bg_rounded_8dp_white_stroke.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@android:color/transparent" />
+    <corners android:radius="8dp" />
+    <stroke android:width="2px" android:color="#FFFFFF" />
+</shape>

+ 5 - 0
src/main/res/drawable/ic_chevron_left_black_24dp.xml

@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
+</vector>

+ 5 - 0
src/main/res/drawable/ic_chevron_right_black_24dp.xml

@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
+</vector>

+ 6 - 0
src/main/res/drawable/ic_photolibrary.xml

@@ -0,0 +1,6 @@
+<vector android:height="24dp" android:viewportHeight="30"
+    android:viewportWidth="30" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#4E342E" android:fillType="nonZero"
+        android:pathData="M30,21L30,3C30,1.35 28.65,0 27,0L9,0C7.35,0 6,1.35 6,3L6,21C6,22.65 7.35,24 9,24L27,24C28.65,24 30,22.65 30,21ZM13.5,15L16.545,19.065L21,13.5L27,21L9,21L13.5,15ZM0,6L0,27C0,28.65 1.35,30 3,30L24,30L24,27L3,27L3,6L0,6Z"
+        android:strokeColor="#00000000" android:strokeWidth="1"/>
+</vector>

+ 34 - 0
src/main/res/layout/activity_scene_edit.xml

@@ -21,6 +21,18 @@
             android:layout_marginTop="36dp"
             android:layout_alignParentStart="true"
             android:src="@drawable/ic_button_back_01"/>
+        <Button
+            android:id="@+id/btn_scene_edit_activity_export"
+            android:layout_width="wrap_content"
+            android:background="@drawable/bg_rounded_8dp_white_stroke"
+            android:layout_height="48dp"
+            android:layout_marginRight="24dp"
+            android:layout_marginTop="36dp"
+            android:padding="16dp"
+            android:layout_alignParentEnd="true"
+            android:text="@string/uikit_edit_export_video"
+            android:textColor="@color/white"
+            android:drawableLeft="@drawable/ic_cameraroll"/>
     </RelativeLayout>
 
     <android.support.constraint.ConstraintLayout
@@ -62,6 +74,28 @@
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
 
+    <ImageView
+        android:id="@+id/previous_page"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginBottom="16dp"
+        android:src="@drawable/ic_chevron_left_black_24dp"
+        app:layout_constraintTop_toBottomOf="@+id/scene_view_container"
+        app:layout_constraintBottom_toTopOf="@+id/tv_scene_activity_record_time"
+        app:layout_constraintLeft_toLeftOf="parent"/>
+
+    <ImageView
+        android:id="@+id/next_page"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginBottom="16dp"
+        android:src="@drawable/ic_chevron_right_black_24dp"
+        app:layout_constraintTop_toBottomOf="@+id/scene_view_container"
+        app:layout_constraintBottom_toTopOf="@+id/tv_scene_activity_record_time"
+        app:layout_constraintRight_toRightOf="parent"/>
+
     <ImageView
         android:id="@+id/startRecord"
         android:layout_width="56dp"

+ 50 - 0
src/main/res/layout/control_background_dialog.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:background="#ffffff">
+    <LinearLayout
+        android:id="@+id/Mirror"
+        android:layout_width="160dp"
+        android:layout_height="wrap_content"
+        app:layout_constraintTop_toTopOf="parent"
+        android:orientation="horizontal">
+        <ImageView
+            android:layout_width="24dp"
+            android:layout_height="24dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginLeft="16dp"
+            android:background="#ffffff"
+            android:src="@drawable/ic_flip_b"/>
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="24dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginLeft="16dp"
+            android:background="#ffffff"
+            android:text="@string/uikit_edit_mirror"/>
+    </LinearLayout>
+    <LinearLayout
+        android:id="@+id/adjustment"
+        android:layout_width="160dp"
+        android:layout_height="wrap_content"
+        app:layout_constraintTop_toBottomOf="@+id/Mirror"
+        android:orientation="horizontal">
+        <ImageView
+            android:layout_width="24dp"
+            android:layout_height="24dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginLeft="16dp"
+            android:layout_marginBottom="20dp"
+            android:background="#ffffff"
+            android:src="@drawable/ic_adjustment"/>
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="24dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginLeft="16dp"
+            android:background="#ffffff"
+            android:text="@string/uikit_edit_adjustment"/>
+    </LinearLayout>
+</android.support.constraint.ConstraintLayout>

+ 1 - 1
src/main/res/layout/view_front_cover_scene_chooser.xml

@@ -113,7 +113,7 @@
         android:layout_height="wrap_content"
         android:layout_marginTop="28dp"
         android:layout_marginBottom="24dp"
-        android:text="@string/uikit_edit_discard"
+        android:text="@string/uikit_edit_save"
         android:textColor="@color/cocoa"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintRight_toRightOf="@id/recyclerView_frontCoverSceneChooserDialog_sceneList"