|
@@ -1,4 +1,4 @@
|
|
-package com.kdanmobile.reader.screen.view
|
|
|
|
|
|
+package com.kdanmobile.reader.screen.reader.mediabox
|
|
|
|
|
|
import android.animation.*
|
|
import android.animation.*
|
|
import android.content.Context
|
|
import android.content.Context
|
|
@@ -12,11 +12,15 @@ import android.view.View.OnClickListener
|
|
import android.view.animation.AccelerateDecelerateInterpolator
|
|
import android.view.animation.AccelerateDecelerateInterpolator
|
|
import android.widget.ImageButton
|
|
import android.widget.ImageButton
|
|
import com.kdanmobile.reader.R
|
|
import com.kdanmobile.reader.R
|
|
-import com.kdanmobile.reader.screen.view.edit.*
|
|
|
|
-import kotlinx.android.synthetic.main.view_viewer_edit.view.*
|
|
|
|
-import kotlinx.android.synthetic.main.view_viewer_edit_tab.view.*
|
|
|
|
|
|
+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.TextBoxTabView
|
|
|
|
+import kotlinx.android.synthetic.main.view_media_box.view.*
|
|
|
|
+import kotlinx.android.synthetic.main.view_media_box_tab.view.*
|
|
|
|
|
|
-class ViewerEditView @JvmOverloads constructor(
|
|
|
|
|
|
+class MediaBoxView @JvmOverloads constructor(
|
|
context: Context,
|
|
context: Context,
|
|
attrs: AttributeSet? = null,
|
|
attrs: AttributeSet? = null,
|
|
defStyleAttr: Int = 0
|
|
defStyleAttr: Int = 0
|
|
@@ -40,19 +44,19 @@ class ViewerEditView @JvmOverloads constructor(
|
|
private var maskAnimator: ValueAnimator? = null
|
|
private var maskAnimator: ValueAnimator? = null
|
|
private var tabType = ViewerEditTabType.NONE
|
|
private var tabType = ViewerEditTabType.NONE
|
|
private var selected: ImageButton? = null
|
|
private var selected: ImageButton? = null
|
|
- var onViewerEditTabAddButtonClickListener: OnViewerEditTabAddButtonClickListener? = null
|
|
|
|
|
|
+ var onClickAddButtonListener: OnClickAddButtonListener? = null
|
|
|
|
|
|
init {
|
|
init {
|
|
- LayoutInflater.from(context).inflate(R.layout.view_viewer_edit, this)
|
|
|
|
|
|
+ LayoutInflater.from(context).inflate(R.layout.view_media_box, this)
|
|
visibility = View.INVISIBLE
|
|
visibility = View.INVISIBLE
|
|
setupTabView()
|
|
setupTabView()
|
|
|
|
|
|
/** Set empty listener to prevent dismissing by clicking box **/
|
|
/** Set empty listener to prevent dismissing by clicking box **/
|
|
- view_viewEdit_content.setOnClickListener {}
|
|
|
|
|
|
+ view_mediaBox_dialog.setOnClickListener {}
|
|
|
|
|
|
/** Move media box view to bottom of parent(hide it) **/
|
|
/** Move media box view to bottom of parent(hide it) **/
|
|
val size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
|
val size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
|
- val v = view_viewEdit_content
|
|
|
|
|
|
+ val v = view_mediaBox_dialog
|
|
v.measure(size, size)
|
|
v.measure(size, size)
|
|
v.y = v.top + v.measuredHeight.toFloat()
|
|
v.y = v.top + v.measuredHeight.toFloat()
|
|
}
|
|
}
|
|
@@ -106,7 +110,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
|
|
|
private fun showMediaBoxWithAnimation() {
|
|
private fun showMediaBoxWithAnimation() {
|
|
mediaBoxAnimator?.cancel()
|
|
mediaBoxAnimator?.cancel()
|
|
- val v = view_viewEdit_content
|
|
|
|
|
|
+ val v = view_mediaBox_dialog
|
|
v.visibility = View.VISIBLE
|
|
v.visibility = View.VISIBLE
|
|
val from = v.y
|
|
val from = v.y
|
|
val to = v.top.toFloat()
|
|
val to = v.top.toFloat()
|
|
@@ -126,7 +130,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
|
|
|
private fun hideMediaBoxWithAnimation() {
|
|
private fun hideMediaBoxWithAnimation() {
|
|
mediaBoxAnimator?.cancel()
|
|
mediaBoxAnimator?.cancel()
|
|
- val v = view_viewEdit_content
|
|
|
|
|
|
+ val v = view_mediaBox_dialog
|
|
val from = v.y
|
|
val from = v.y
|
|
val to = v.top.toFloat() + v.height
|
|
val to = v.top.toFloat() + v.height
|
|
val holder = PropertyValuesHolder.ofFloat("Y", from, to)
|
|
val holder = PropertyValuesHolder.ofFloat("Y", from, to)
|
|
@@ -138,7 +142,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
super.onAnimationEnd(animation)
|
|
super.onAnimationEnd(animation)
|
|
removeListener(this)
|
|
removeListener(this)
|
|
v.visibility = View.INVISIBLE
|
|
v.visibility = View.INVISIBLE
|
|
- this@ViewerEditView.visibility = View.GONE
|
|
|
|
|
|
+ this@MediaBoxView.visibility = View.GONE
|
|
}
|
|
}
|
|
})
|
|
})
|
|
start()
|
|
start()
|
|
@@ -146,13 +150,13 @@ class ViewerEditView @JvmOverloads constructor(
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupTabView() {
|
|
private fun setupTabView() {
|
|
- viewerEdit_tab.onClickListenerTabTextBox = OnClickListener(this::setupTextBoxView)
|
|
|
|
- viewerEdit_tab.onClickListenerTabSignature = OnClickListener(this::setupSignatureView)
|
|
|
|
- viewerEdit_tab.onClickListenerTabStamp = OnClickListener(this::setupStampView)
|
|
|
|
- viewerEdit_tab.onClickListenerTabShape = OnClickListener(this::setupShapeView)
|
|
|
|
- viewerEdit_tab.onClickListenerTabForm = OnClickListener(this::setupFormView)
|
|
|
|
|
|
+ mediaBoxTabView_mediaBox_tab.onClickListenerTabTextBox = OnClickListener(this::setupTextBoxView)
|
|
|
|
+ mediaBoxTabView_mediaBox_tab.onClickListenerTabSignature = OnClickListener(this::setupSignatureView)
|
|
|
|
+ mediaBoxTabView_mediaBox_tab.onClickListenerTabStamp = OnClickListener(this::setupStampView)
|
|
|
|
+ mediaBoxTabView_mediaBox_tab.onClickListenerTabShape = OnClickListener(this::setupShapeView)
|
|
|
|
+ mediaBoxTabView_mediaBox_tab.onClickListenerTabForm = OnClickListener(this::setupFormView)
|
|
|
|
|
|
- setupTextBoxView(viewerEdit_tab_textBox)
|
|
|
|
|
|
+ setupTextBoxView(ib_mediaBoxTab_textBox)
|
|
}
|
|
}
|
|
|
|
|
|
private fun getButtonDrawable(tabType: ViewerEditTabType, isSelected: Boolean): Int {
|
|
private fun getButtonDrawable(tabType: ViewerEditTabType, isSelected: Boolean): Int {
|
|
@@ -178,7 +182,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
selected = button
|
|
selected = button
|
|
button.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, true)))
|
|
button.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, true)))
|
|
|
|
|
|
- viewEdit_layout_tab_content.removeAllViews()
|
|
|
|
|
|
+ viewGroup_mediaBox_pageContainer.removeAllViews()
|
|
changed = true
|
|
changed = true
|
|
}
|
|
}
|
|
return changed
|
|
return changed
|
|
@@ -189,10 +193,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
if (changed) {
|
|
if (changed) {
|
|
val textBoxTabView = TextBoxTabView(context)
|
|
val textBoxTabView = TextBoxTabView(context)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
- viewEdit_layout_tab_content.addView(textBoxTabView, params)
|
|
|
|
- textBoxTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
|
|
|
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(textBoxTabView, params)
|
|
|
|
+ textBoxTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
override fun onTitleButtonClick() {
|
|
override fun onTitleButtonClick() {
|
|
- onViewerEditTabAddButtonClickListener?.onTabTextBoxAddButtonClick(textBoxTabView)
|
|
|
|
|
|
+ onClickAddButtonListener?.onClickTextBoxAddButton(textBoxTabView)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -203,10 +207,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
if (changed) {
|
|
if (changed) {
|
|
val signatureTabView = SignatureTabView(context)
|
|
val signatureTabView = SignatureTabView(context)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
- viewEdit_layout_tab_content.addView(signatureTabView, params)
|
|
|
|
- signatureTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
|
|
|
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(signatureTabView, params)
|
|
|
|
+ signatureTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
override fun onTitleButtonClick() {
|
|
override fun onTitleButtonClick() {
|
|
- onViewerEditTabAddButtonClickListener?.onTabSignatureAddButtonClick(signatureTabView)
|
|
|
|
|
|
+ onClickAddButtonListener?.onClickSignatureAddButton(signatureTabView)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -217,10 +221,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
if (changed) {
|
|
if (changed) {
|
|
val stampTabView = StampTabView(context)
|
|
val stampTabView = StampTabView(context)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
- viewEdit_layout_tab_content.addView(stampTabView, params)
|
|
|
|
- stampTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
|
|
|
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(stampTabView, params)
|
|
|
|
+ stampTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
override fun onTitleButtonClick() {
|
|
override fun onTitleButtonClick() {
|
|
- onViewerEditTabAddButtonClickListener?.onTabStampAddButtonClick(stampTabView)
|
|
|
|
|
|
+ onClickAddButtonListener?.onClickStampAddButton(stampTabView)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -231,10 +235,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
if (changed) {
|
|
if (changed) {
|
|
val shapeTabView = ShapeTabView(context)
|
|
val shapeTabView = ShapeTabView(context)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
- viewEdit_layout_tab_content.addView(shapeTabView, params)
|
|
|
|
- shapeTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
|
|
|
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(shapeTabView, params)
|
|
|
|
+ shapeTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
override fun onTitleButtonClick() {
|
|
override fun onTitleButtonClick() {
|
|
- onViewerEditTabAddButtonClickListener?.onTabShapeAddButtonClick(shapeTabView)
|
|
|
|
|
|
+ onClickAddButtonListener?.onClickShapeAddButton(shapeTabView)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -244,14 +248,14 @@ class ViewerEditView @JvmOverloads constructor(
|
|
//TODO implements tab view and add to viewEdit_layout_tab_content
|
|
//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, ViewerEditTabType.FORM)
|
|
if (changed) {
|
|
if (changed) {
|
|
- LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab, viewEdit_layout_tab_content)
|
|
|
|
|
|
+ LayoutInflater.from(context).inflate(R.layout.view_media_box_tab, viewGroup_mediaBox_pageContainer)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- interface OnViewerEditTabAddButtonClickListener {
|
|
|
|
- fun onTabTextBoxAddButtonClick(textBoxTabView: TextBoxTabView)
|
|
|
|
- fun onTabSignatureAddButtonClick(signatureTabView: SignatureTabView)
|
|
|
|
- fun onTabStampAddButtonClick(stampTabView: StampTabView)
|
|
|
|
- fun onTabShapeAddButtonClick(shapeTabView: ShapeTabView)
|
|
|
|
|
|
+ interface OnClickAddButtonListener {
|
|
|
|
+ fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView)
|
|
|
|
+ fun onClickSignatureAddButton(signatureTabView: SignatureTabView)
|
|
|
|
+ fun onClickStampAddButton(stampTabView: StampTabView)
|
|
|
|
+ fun onClickShapeAddButton(shapeTabView: ShapeTabView)
|
|
}
|
|
}
|
|
}
|
|
}
|