|
@@ -16,6 +16,7 @@ import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
|
|
|
import com.kdanmobile.reader.screen.reader.mediabox.shape.ShapeTabView
|
|
|
import com.kdanmobile.reader.screen.reader.mediabox.signature.SignatureTabView
|
|
|
import com.kdanmobile.reader.screen.reader.mediabox.stamp.StampTabView
|
|
|
+import com.kdanmobile.reader.screen.reader.mediabox.textbox.TextBoxStyleView
|
|
|
import com.kdanmobile.reader.screen.reader.mediabox.textbox.TextBoxTabView
|
|
|
import kotlinx.android.synthetic.main.view_media_box.view.*
|
|
|
import kotlinx.android.synthetic.main.view_media_box_tab.view.*
|
|
@@ -32,8 +33,8 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
const val DEFAULT_DURATION_ANIMATION = 300L
|
|
|
}
|
|
|
|
|
|
- private enum class ViewerEditTabType {
|
|
|
- NONE, TEXT_BOX, SIGNATURE, STAMP, SHAPE, FORM
|
|
|
+ enum class MediaBoxTabType {
|
|
|
+ NONE, TEXT_BOX, SIGNATURE, STAMP, SHAPE, FORM, TEXT_BOX_STYLE
|
|
|
}
|
|
|
|
|
|
var onShowListener: Runnable? = null
|
|
@@ -42,9 +43,10 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
|
|
|
private var mediaBoxAnimator: ObjectAnimator? = null
|
|
|
private var maskAnimator: ValueAnimator? = null
|
|
|
- private var tabType = ViewerEditTabType.NONE
|
|
|
+ private var cacheView: View? = null
|
|
|
+ private var tabType = MediaBoxTabType.NONE
|
|
|
private var selected: ImageButton? = null
|
|
|
- var onClickAddButtonListener: OnClickAddButtonListener? = null
|
|
|
+ var onClickAddButtonListener: OnClickHeaderButtonListener? = null
|
|
|
|
|
|
init {
|
|
|
LayoutInflater.from(context).inflate(R.layout.view_media_box, this)
|
|
@@ -61,6 +63,30 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
v.y = v.top + v.measuredHeight.toFloat()
|
|
|
}
|
|
|
|
|
|
+ fun showTextBoxStyleView() {
|
|
|
+ if (viewGroup_mediaBox_pageContainer.childCount > 0) {
|
|
|
+ cacheView = viewGroup_mediaBox_pageContainer.getChildAt(0)
|
|
|
+ viewGroup_mediaBox_pageContainer.removeAllViews()
|
|
|
+ }
|
|
|
+ val textBoxStyleView = TextBoxStyleView(context)
|
|
|
+ val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(textBoxStyleView, params)
|
|
|
+ textBoxStyleView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
|
+ override fun onTitleButtonClick() {
|
|
|
+ onClickAddButtonListener?.onClickTextBoxStyleApplyButton(textBoxStyleView)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ show()
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun showLeftSideTabView() {
|
|
|
+ mediaBoxTabView_mediaBox_tab.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun hideLeftSideTabView() {
|
|
|
+ mediaBoxTabView_mediaBox_tab.visibility = View.GONE
|
|
|
+ }
|
|
|
+
|
|
|
fun show() {
|
|
|
visibility = View.VISIBLE
|
|
|
setOnClickListener { dismiss(true) }
|
|
@@ -119,6 +145,13 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
interpolator = AccelerateDecelerateInterpolator()
|
|
|
duration = animationDuration
|
|
|
addListener(object : AnimatorListenerAdapter() {
|
|
|
+ override fun onAnimationStart(animation: Animator?) {
|
|
|
+ super.onAnimationStart(animation)
|
|
|
+ if (null != cacheView) {
|
|
|
+ hideLeftSideTabView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override fun onAnimationEnd(animation: Animator?) {
|
|
|
super.onAnimationEnd(animation)
|
|
|
removeListener(this)
|
|
@@ -143,6 +176,13 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
removeListener(this)
|
|
|
v.visibility = View.INVISIBLE
|
|
|
this@MediaBoxView.visibility = View.GONE
|
|
|
+
|
|
|
+ if (null != cacheView) {
|
|
|
+ viewGroup_mediaBox_pageContainer.removeAllViews()
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(cacheView)
|
|
|
+ cacheView = null
|
|
|
+ showLeftSideTabView()
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
start()
|
|
@@ -159,22 +199,22 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
setupTextBoxView(ib_mediaBoxTab_textBox)
|
|
|
}
|
|
|
|
|
|
- private fun getButtonDrawable(tabType: ViewerEditTabType, isSelected: Boolean): Int {
|
|
|
+ private fun getButtonDrawable(tabType: MediaBoxTabType, isSelected: Boolean): Int {
|
|
|
return when (tabType) {
|
|
|
- ViewerEditTabType.NONE, ViewerEditTabType.TEXT_BOX ->
|
|
|
+ MediaBoxTabType.NONE, MediaBoxTabType.TEXT_BOX, MediaBoxTabType.TEXT_BOX_STYLE ->
|
|
|
if (isSelected) R.drawable.ic_textbox_selected else R.drawable.ic_textbox
|
|
|
- ViewerEditTabType.SIGNATURE ->
|
|
|
+ MediaBoxTabType.SIGNATURE ->
|
|
|
if (isSelected) R.drawable.ic_signature_selected else R.drawable.ic_signature
|
|
|
- ViewerEditTabType.STAMP ->
|
|
|
+ MediaBoxTabType.STAMP ->
|
|
|
if (isSelected) R.drawable.ic_stamp_selected else R.drawable.ic_stamp
|
|
|
- ViewerEditTabType.SHAPE ->
|
|
|
+ MediaBoxTabType.SHAPE ->
|
|
|
if (isSelected) R.drawable.ic_shape_selected else R.drawable.ic_shape
|
|
|
- ViewerEditTabType.FORM ->
|
|
|
+ MediaBoxTabType.FORM ->
|
|
|
if (isSelected) R.drawable.ic_form_selected else R.drawable.ic_form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun setupContent(button: ImageButton, tabType: ViewerEditTabType): Boolean {
|
|
|
+ private fun setupContent(button: ImageButton, tabType: MediaBoxTabType): Boolean {
|
|
|
var changed = false
|
|
|
if (this.tabType != tabType) {
|
|
|
selected?.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, false)))
|
|
@@ -189,7 +229,7 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
}
|
|
|
|
|
|
private fun setupTextBoxView(view: View) {
|
|
|
- val changed = setupContent(view as ImageButton, ViewerEditTabType.TEXT_BOX)
|
|
|
+ val changed = setupContent(view as ImageButton, MediaBoxTabType.TEXT_BOX)
|
|
|
if (changed) {
|
|
|
val textBoxTabView = TextBoxTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
@@ -203,7 +243,7 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
}
|
|
|
|
|
|
private fun setupSignatureView(view: View) {
|
|
|
- val changed = setupContent(view as ImageButton, ViewerEditTabType.SIGNATURE)
|
|
|
+ val changed = setupContent(view as ImageButton, MediaBoxTabType.SIGNATURE)
|
|
|
if (changed) {
|
|
|
val signatureTabView = SignatureTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
@@ -217,7 +257,7 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
}
|
|
|
|
|
|
private fun setupStampView(view: View) {
|
|
|
- val changed = setupContent(view as ImageButton, ViewerEditTabType.STAMP)
|
|
|
+ val changed = setupContent(view as ImageButton, MediaBoxTabType.STAMP)
|
|
|
if (changed) {
|
|
|
val stampTabView = StampTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
@@ -231,7 +271,7 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
}
|
|
|
|
|
|
private fun setupShapeView(view: View) {
|
|
|
- val changed = setupContent(view as ImageButton, ViewerEditTabType.SHAPE)
|
|
|
+ val changed = setupContent(view as ImageButton, MediaBoxTabType.SHAPE)
|
|
|
if (changed) {
|
|
|
val shapeTabView = ShapeTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
@@ -246,14 +286,17 @@ class MediaBoxView @JvmOverloads constructor(
|
|
|
|
|
|
private fun setupFormView(view: View) {
|
|
|
//TODO implements tab view and add to viewEdit_layout_tab_content
|
|
|
- val changed = setupContent(view as ImageButton, ViewerEditTabType.FORM)
|
|
|
+ val changed = setupContent(view as ImageButton, MediaBoxTabType.FORM)
|
|
|
if (changed) {
|
|
|
LayoutInflater.from(context).inflate(R.layout.view_media_box_tab, viewGroup_mediaBox_pageContainer)
|
|
|
+ mediaBoxTabView_mediaBox_tab.visibility = View.VISIBLE
|
|
|
+ invalidate()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- interface OnClickAddButtonListener {
|
|
|
+ interface OnClickHeaderButtonListener {
|
|
|
fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView)
|
|
|
+ fun onClickTextBoxStyleApplyButton(textBoxTabView: TextBoxTabView)
|
|
|
fun onClickSignatureAddButton(signatureTabView: SignatureTabView)
|
|
|
fun onClickStampAddButton(stampTabView: StampTabView)
|
|
|
fun onClickShapeAddButton(shapeTabView: ShapeTabView)
|