|
@@ -1,21 +1,25 @@
|
|
|
package com.bomostory.sceneeditmodule
|
|
|
|
|
|
import android.content.DialogInterface
|
|
|
+import android.graphics.Color
|
|
|
import android.graphics.Paint
|
|
|
import android.os.Bundle
|
|
|
import android.support.v4.app.DialogFragment
|
|
|
import android.support.v4.content.ContextCompat
|
|
|
-import android.view.LayoutInflater
|
|
|
-import android.view.View
|
|
|
-import android.view.ViewGroup
|
|
|
-import android.view.Window
|
|
|
+import android.view.*
|
|
|
+import android.widget.PopupWindow
|
|
|
+import android.widget.SeekBar
|
|
|
import com.bomostory.sceneeditmodule.basicdata.Actor
|
|
|
import com.example.tfat.myapplication.R
|
|
|
+import kotlinx.android.synthetic.main.dialogfragment_edit_text.*
|
|
|
import kotlinx.android.synthetic.main.dialogfragment_edit_text.view.*
|
|
|
+import kotlinx.android.synthetic.main.popupview_set_color.view.*
|
|
|
+
|
|
|
|
|
|
class EditTextDialog : DialogFragment() {
|
|
|
- var onSetDialogFinish: OnSetDialogFinish? = null
|
|
|
- lateinit var dialogueActor: Actor
|
|
|
+ private var onSetDialogFinish: OnSetDialogFinish? = null
|
|
|
+ private lateinit var dialogueActor: Actor
|
|
|
+ private var popupWindow = PopupWindow()
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
|
return inflater.inflate(R.layout.dialogfragment_edit_text, container).apply {
|
|
@@ -29,7 +33,9 @@ class EditTextDialog : DialogFragment() {
|
|
|
iv_edit_text_blue.background = null
|
|
|
iv_edit_text_green.background = null
|
|
|
iv_edit_text_black.background = null
|
|
|
- dialogueActor?.textColor = "#d0021b"
|
|
|
+ dialogueActor?.textColor = Color.parseColor("#d0021b")
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ popupWindow.dismiss()
|
|
|
}
|
|
|
iv_edit_text_yellow.setOnClickListener {
|
|
|
iv_edit_text_red.background = null
|
|
@@ -37,7 +43,9 @@ class EditTextDialog : DialogFragment() {
|
|
|
iv_edit_text_blue.background = null
|
|
|
iv_edit_text_green.background = null
|
|
|
iv_edit_text_black.background = null
|
|
|
- dialogueActor?.textColor = "#f8e71c"
|
|
|
+ dialogueActor?.textColor = Color.parseColor("#f8e71c")
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ popupWindow.dismiss()
|
|
|
}
|
|
|
iv_edit_text_blue.setOnClickListener {
|
|
|
iv_edit_text_red.background = null
|
|
@@ -45,7 +53,9 @@ class EditTextDialog : DialogFragment() {
|
|
|
iv_edit_text_blue.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
|
|
|
iv_edit_text_green.background = null
|
|
|
iv_edit_text_black.background = null
|
|
|
- dialogueActor?.textColor = "#4a90e2"
|
|
|
+ dialogueActor?.textColor = Color.parseColor("#4a90e2")
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ popupWindow.dismiss()
|
|
|
}
|
|
|
iv_edit_text_green.setOnClickListener {
|
|
|
iv_edit_text_red.background = null
|
|
@@ -53,7 +63,9 @@ class EditTextDialog : DialogFragment() {
|
|
|
iv_edit_text_blue.background = null
|
|
|
iv_edit_text_green.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
|
|
|
iv_edit_text_black.background = null
|
|
|
- dialogueActor?.textColor = "#417505"
|
|
|
+ dialogueActor?.textColor = Color.parseColor("#417505")
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ popupWindow.dismiss()
|
|
|
}
|
|
|
iv_edit_text_black.setOnClickListener {
|
|
|
iv_edit_text_red.background = null
|
|
@@ -61,7 +73,23 @@ class EditTextDialog : DialogFragment() {
|
|
|
iv_edit_text_blue.background = null
|
|
|
iv_edit_text_green.background = null
|
|
|
iv_edit_text_black.background = ContextCompat.getDrawable(context, R.drawable.btn_edit_text_dialog_circle_selected)
|
|
|
- dialogueActor?.textColor = "#000000"
|
|
|
+ dialogueActor?.textColor = Color.parseColor("#000000")
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ popupWindow.dismiss()
|
|
|
+
|
|
|
+ }
|
|
|
+ iv_edit_text_tune.setOnClickListener {
|
|
|
+ iv_edit_text_red.background = null
|
|
|
+ iv_edit_text_yellow.background = null
|
|
|
+ iv_edit_text_blue.background = null
|
|
|
+ iv_edit_text_green.background = null
|
|
|
+ iv_edit_text_black.background = null
|
|
|
+ popupWindow.contentView = createPopupView()
|
|
|
+ popupWindow.width = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popupWindow.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popupWindow.isOutsideTouchable = false
|
|
|
+ var valueXInPixels = resources.getDimension(R.dimen.popup_view_set_color_height)
|
|
|
+ popupWindow.showAsDropDown(iv_edit_text_tune, 0, -valueXInPixels.toInt(), Gravity.CENTER_HORIZONTAL)
|
|
|
}
|
|
|
btn_edit_dialog_align_left.setOnClickListener {
|
|
|
btn_edit_dialog_align_left.setImageResource(R.drawable.ic_alignleft_w)
|
|
@@ -84,6 +112,68 @@ class EditTextDialog : DialogFragment() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun createPopupView(): View{
|
|
|
+ val popupView = LayoutInflater.from(context).inflate(R.layout.popupview_set_color, null)
|
|
|
+ popupView.sb_set_color_r.max = 255
|
|
|
+ popupView.sb_set_color_r.progress = 255
|
|
|
+ popupView.sb_set_color_r.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
|
|
|
+ override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
|
+ popupView.tv_set_color_r.text = progress.toString()
|
|
|
+ dialogueActor?.textColor = Color.argb(popupView.tv_set_color_a.text.toString().toInt(),popupView.tv_set_color_r.text.toString().toInt(),
|
|
|
+ popupView.tv_set_color_g.text.toString().toInt(),popupView.tv_set_color_b.text.toString().toInt())
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ }
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ popupView.sb_set_color_g.max = 255
|
|
|
+ popupView.sb_set_color_g.progress = 255
|
|
|
+ popupView.sb_set_color_g.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
|
|
|
+ override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
|
+ popupView.tv_set_color_g.text = progress.toString()
|
|
|
+ dialogueActor?.textColor = Color.argb(popupView.tv_set_color_a.text.toString().toInt(),popupView.tv_set_color_r.text.toString().toInt(),
|
|
|
+ popupView.tv_set_color_g.text.toString().toInt(),popupView.tv_set_color_b.text.toString().toInt())
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ }
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ popupView.sb_set_color_b.max = 255
|
|
|
+ popupView.sb_set_color_b.progress = 255
|
|
|
+ popupView.sb_set_color_b.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
|
|
|
+ override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
|
+ popupView.tv_set_color_b.text = progress.toString()
|
|
|
+ dialogueActor?.textColor = Color.argb(popupView.tv_set_color_a.text.toString().toInt(),popupView.tv_set_color_r.text.toString().toInt(),
|
|
|
+ popupView.tv_set_color_g.text.toString().toInt(),popupView.tv_set_color_b.text.toString().toInt())
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+ }
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ popupView.sb_set_color_a.max = 255
|
|
|
+ popupView.sb_set_color_a.progress = 255
|
|
|
+ popupView.sb_set_color_a.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
|
|
|
+ override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
|
+ popupView.tv_set_color_r.text = progress.toString()
|
|
|
+ dialogueActor?.textColor = Color.argb(popupView.tv_set_color_a.text.toString().toInt(),popupView.tv_set_color_r.text.toString().toInt(),
|
|
|
+ popupView.tv_set_color_g.text.toString().toInt(),popupView.tv_set_color_b.text.toString().toInt())
|
|
|
+ etv_text.setTextColor(dialogueActor?.textColor)
|
|
|
+
|
|
|
+ }
|
|
|
+ override fun onStartTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return popupView
|
|
|
+ }
|
|
|
+
|
|
|
override fun onDismiss(dialog: DialogInterface?) {
|
|
|
super.onDismiss(dialog)
|
|
|
onSetDialogFinish?.onEditTextDialogDismiss()
|