|
@@ -17,10 +17,10 @@ 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_viewer_edit.view.*
|
|
|
-import kotlinx.android.synthetic.main.view_viewer_edit_tab.view.*
|
|
|
+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,
|
|
|
attrs: AttributeSet? = null,
|
|
|
defStyleAttr: Int = 0
|
|
@@ -44,19 +44,19 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
private var maskAnimator: ValueAnimator? = null
|
|
|
private var tabType = ViewerEditTabType.NONE
|
|
|
private var selected: ImageButton? = null
|
|
|
- var onViewerEditTabAddButtonClickListener: OnViewerEditTabAddButtonClickListener? = null
|
|
|
+ var onClickAddButtonListener: OnClickAddButtonListener? = null
|
|
|
|
|
|
init {
|
|
|
- LayoutInflater.from(context).inflate(R.layout.view_viewer_edit, this)
|
|
|
+ LayoutInflater.from(context).inflate(R.layout.view_media_box, this)
|
|
|
visibility = View.INVISIBLE
|
|
|
setupTabView()
|
|
|
|
|
|
/** 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) **/
|
|
|
val size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
|
|
|
- val v = view_viewEdit_content
|
|
|
+ val v = view_mediaBox_dialog
|
|
|
v.measure(size, size)
|
|
|
v.y = v.top + v.measuredHeight.toFloat()
|
|
|
}
|
|
@@ -108,7 +108,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
|
|
|
private fun showMediaBoxWithAnimation() {
|
|
|
mediaBoxAnimator?.cancel()
|
|
|
- val v = view_viewEdit_content
|
|
|
+ val v = view_mediaBox_dialog
|
|
|
v.visibility = View.VISIBLE
|
|
|
val from = v.y
|
|
|
val to = v.top.toFloat()
|
|
@@ -128,7 +128,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
|
|
|
private fun hideMediaBoxWithAnimation() {
|
|
|
mediaBoxAnimator?.cancel()
|
|
|
- val v = view_viewEdit_content
|
|
|
+ val v = view_mediaBox_dialog
|
|
|
val from = v.y
|
|
|
val to = v.top.toFloat() + v.height
|
|
|
val holder = PropertyValuesHolder.ofFloat("Y", from, to)
|
|
@@ -140,7 +140,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
super.onAnimationEnd(animation)
|
|
|
removeListener(this)
|
|
|
v.visibility = View.INVISIBLE
|
|
|
- this@ViewerEditView.visibility = View.GONE
|
|
|
+ this@MediaBoxView.visibility = View.GONE
|
|
|
}
|
|
|
})
|
|
|
start()
|
|
@@ -148,13 +148,13 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
}
|
|
|
|
|
|
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 {
|
|
@@ -180,7 +180,7 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
selected = button
|
|
|
button.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, true)))
|
|
|
|
|
|
- viewEdit_layout_tab_content.removeAllViews()
|
|
|
+ viewGroup_mediaBox_pageContainer.removeAllViews()
|
|
|
changed = true
|
|
|
}
|
|
|
return changed
|
|
@@ -191,10 +191,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
if (changed) {
|
|
|
val textBoxTabView = TextBoxTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
|
- viewEdit_layout_tab_content.addView(textBoxTabView, params)
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(textBoxTabView, params)
|
|
|
textBoxTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
|
override fun onTitleButtonClick() {
|
|
|
- onViewerEditTabAddButtonClickListener?.onTabTextBoxAddButtonClick(textBoxTabView)
|
|
|
+ onClickAddButtonListener?.onClickTextBoxAddButton(textBoxTabView)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -205,10 +205,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
if (changed) {
|
|
|
val signatureTabView = SignatureTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
|
- viewEdit_layout_tab_content.addView(signatureTabView, params)
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(signatureTabView, params)
|
|
|
signatureTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
|
override fun onTitleButtonClick() {
|
|
|
- onViewerEditTabAddButtonClickListener?.onTabSignatureAddButtonClick(signatureTabView)
|
|
|
+ onClickAddButtonListener?.onClickSignatureAddButton(signatureTabView)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -219,10 +219,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
if (changed) {
|
|
|
val stampTabView = StampTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
|
- viewEdit_layout_tab_content.addView(stampTabView, params)
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(stampTabView, params)
|
|
|
stampTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
|
override fun onTitleButtonClick() {
|
|
|
- onViewerEditTabAddButtonClickListener?.onTabStampAddButtonClick(stampTabView)
|
|
|
+ onClickAddButtonListener?.onClickStampAddButton(stampTabView)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -233,10 +233,10 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
if (changed) {
|
|
|
val shapeTabView = ShapeTabView(context)
|
|
|
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
|
|
|
- viewEdit_layout_tab_content.addView(shapeTabView, params)
|
|
|
+ viewGroup_mediaBox_pageContainer.addView(shapeTabView, params)
|
|
|
shapeTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
|
|
|
override fun onTitleButtonClick() {
|
|
|
- onViewerEditTabAddButtonClickListener?.onTabShapeAddButtonClick(shapeTabView)
|
|
|
+ onClickAddButtonListener?.onClickShapeAddButton(shapeTabView)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -246,14 +246,14 @@ class ViewerEditView @JvmOverloads constructor(
|
|
|
//TODO implements tab view and add to viewEdit_layout_tab_content
|
|
|
val changed = setupContent(view as ImageButton, ViewerEditTabType.FORM)
|
|
|
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)
|
|
|
}
|
|
|
}
|