Explorar el Código

Merge branch 'contextMenu'

cooperku_kdanmobile hace 5 años
padre
commit
201c962162
Se han modificado 22 ficheros con 397 adiciones y 95 borrados
  1. 39 4
      reader/src/main/java/com/kdanmobile/reader/ReaderActivity.kt
  2. 63 2
      reader/src/main/java/com/kdanmobile/reader/ReaderViewModel.kt
  3. 8 0
      reader/src/main/java/com/kdanmobile/reader/screen/contextmenu/TextBoxContextMenuActionListener.kt
  4. 60 17
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/MediaBoxView.kt
  5. 1 1
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/shape/ShapeTabView.kt
  6. 1 1
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StampTabView.kt
  7. 59 0
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxStyleView.kt
  8. 2 15
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxTabView.kt
  9. 1 1
      reader/src/main/res/layout/activity_reader.xml
  10. 4 4
      reader/src/main/res/layout/activity_view_signature_create.xml
  11. 0 27
      reader/src/main/res/layout/view_viewer_edit_item_edittext.xml
  12. 4 4
      reader/src/main/res/layout/view_viewer_edit_item_shape_border.xml
  13. 2 2
      reader/src/main/res/layout/view_viewer_edit_item_shape_fill.xml
  14. 1 3
      reader/src/main/res/layout/view_viewer_edit_item_stamp_custom.xml
  15. 2 2
      reader/src/main/res/layout/view_viewer_edit_tab_shape.xml
  16. 2 2
      reader/src/main/res/layout/view_viewer_edit_tab_signature.xml
  17. 2 2
      reader/src/main/res/layout/view_viewer_edit_tab_stamp.xml
  18. 8 8
      reader/src/main/res/layout/view_viewer_edit_tab_text_box.xml
  19. 85 0
      reader/src/main/res/layout/view_viewer_edit_tab_text_box_style.xml
  20. 7 0
      reader/src/main/res/menu/context_menu_longpress.xml
  21. 16 0
      reader/src/main/res/menu/context_menu_textbox.xml
  22. 30 0
      reader/src/main/res/values/strings.xml

+ 39 - 4
reader/src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -28,6 +28,7 @@ import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
 import com.kdanmobile.reader.annotationattribute.AnnotationColor
 import com.kdanmobile.reader.annotationattribute.InkAttribute
 import com.kdanmobile.reader.screen.ViewerSettingActivity
+import com.kdanmobile.reader.screen.contextmenu.TextBoxContextMenuActionListener
 import com.kdanmobile.reader.screen.reader.mediabox.MediaBoxView
 import com.kdanmobile.reader.screen.reader.mediabox.shape.ShapeTabView
 import com.kdanmobile.reader.screen.reader.mediabox.signature.SignatureTabView
@@ -119,7 +120,7 @@ abstract class ReaderActivity : AppCompatActivity() {
 
     override fun onBackPressed() {
         when {
-            viewerEditView.isShown -> viewerEditView.dismiss()
+            mediaBoxView.isShown -> mediaBoxView.dismiss()
             else -> super.onBackPressed()
         }
     }
@@ -291,9 +292,37 @@ abstract class ReaderActivity : AppCompatActivity() {
         }
         viewModel.setReaderView(readerView)
         viewModel.pdfInfoHandler.setCurrentPage(viewModel.pageIndexLiveData.value ?: 0)
+        initTextBoxContextMenuActions()
         container.addView(readerView)
     }
 
+    private fun initTextBoxContextMenuActions() {
+        viewModel.setTextBoxContextMenuActions(object : TextBoxContextMenuActionListener {
+            override fun onDelete(): Boolean {
+                viewModel.deleteSelectedTextBox()
+                return true
+            }
+
+            override fun onEditStyle(): Boolean {
+                mediaBoxView.showTextBoxStyleView()
+                viewModel.editSelectedTextBoxStyle()
+                return true
+            }
+
+            override fun onEditText(): Boolean {
+                hideAllToolbars()
+                isHideToolbar = true
+                viewModel.editSelectedTextBoxText()
+                return true
+            }
+
+            override fun onCopy(): Boolean {
+                viewModel.copySelectedTextBox()
+                return true
+            }
+        })
+    }
+
     override fun onDestroy() {
         viewModel.saveModifyingAnnotationBeforeDestroy()
         super.onDestroy()
@@ -466,19 +495,24 @@ abstract class ReaderActivity : AppCompatActivity() {
     }
 
     private fun setupBottomToolbar() {
-        ib_readerActivity_bottomToolbarMediaBox.setOnClickListener { viewerEditView.show() }
+        ib_readerActivity_bottomToolbarMediaBox.setOnClickListener { mediaBoxView.show() }
     }
 
     private fun setupViewerEditView() {
-        viewerEditView.apply {
+        mediaBoxView.apply {
             onShowListener = Runnable { onMediaBoxShown() }
             onDismissListener = Runnable { onMediaBoxDismissed() }
-            onClickAddButtonListener = object : MediaBoxView.OnClickAddButtonListener {
+            onClickAddButtonListener = object : MediaBoxView.OnClickHeaderButtonListener {
                 override fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView) {
                     dismiss(false)
                     viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute())
                 }
 
+                override fun onClickTextBoxStyleApplyButton(textBoxTabView: TextBoxTabView) {
+                    dismiss(false)
+                    viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute(), true)
+                }
+
                 override fun onClickSignatureAddButton(signatureTabView: SignatureTabView) {
                     dismiss(false)
                     viewModel.setSignatureAttribute(signatureTabView.getSignatureAttribute())
@@ -646,6 +680,7 @@ abstract class ReaderActivity : AppCompatActivity() {
 
     private fun onMediaBoxDismissed() {
         showAllToolbars()
+        viewModel.clearSelection()
     }
 
     private fun onThumbnailClick() {

+ 63 - 2
reader/src/main/java/com/kdanmobile/reader/ReaderViewModel.kt

@@ -10,6 +10,8 @@ import android.graphics.RectF
 import android.net.Uri
 import com.kdanmobile.kmpdfkit.annotation.Annotation
 import com.kdanmobile.kmpdfkit.annotation.bean.*
+import com.kdanmobile.kmpdfkit.contextmenu.KMPDFMenuItem
+import com.kdanmobile.kmpdfkit.contextmenu.MenuItemCallback
 import com.kdanmobile.kmpdfkit.globaldata.AnnotConfig
 import com.kdanmobile.kmpdfkit.globaldata.Config
 import com.kdanmobile.kmpdfkit.globaldata.KMPDFAnnotEditMode
@@ -23,6 +25,7 @@ import com.kdanmobile.reader.annotationattribute.Brush
 import com.kdanmobile.kmpdfkit.manager.controller.*
 import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAddAnnotCallback
 import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAnnotEditModeChangeListener
+import com.kdanmobile.reader.screen.contextmenu.TextBoxContextMenuActionListener
 import com.kdanmobile.reader.screen.data.ShapeAttribute
 import com.kdanmobile.reader.screen.data.SignatureAttribute
 import com.kdanmobile.reader.screen.data.StampAttribute
@@ -290,11 +293,45 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
             annotationEitModeLiveData.postValue(it)
         }
 
+        setLongPressContextMenuActions()
+
         if (!isFirst) {
             restoreStateBeforeDestroy()
         }
     }
 
+    private fun setLongPressContextMenuActions() {
+        val item = KMPDFMenuItem()
+        item.annotType = KMPDFMenuItem.AnnotType.LONG_PRESS
+        item.menu_resId = R.menu.context_menu_longpress
+        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
+            (kmpdfFactory?.getController(KMPDFFactory.ControllerType.LONGCLICK) as KMPDFLongPressCreateAnnotController).longPress_Paste()
+            annotationEitModeLiveData.postValue(KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY)
+
+            return@MenuItemCallback true
+        })
+        kmpdfFactory?.setAnnotationContextMenu(item)
+    }
+
+    fun setTextBoxContextMenuActions(listener: TextBoxContextMenuActionListener) {
+        val item = KMPDFMenuItem()
+        item.annotType = KMPDFMenuItem.AnnotType.FREETEXT
+        item.menu_resId = R.menu.context_menu_textbox
+        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
+            return@MenuItemCallback listener.onDelete()
+        })
+        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
+            return@MenuItemCallback listener.onEditStyle()
+        })
+        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
+            return@MenuItemCallback listener.onEditText()
+        })
+        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
+            return@MenuItemCallback listener.onCopy()
+        })
+        kmpdfFactory?.setAnnotationContextMenu(item)
+    }
+
     private fun restoreStateBeforeDestroy() {
         if (isCopyModeLiveData.value == true) {
             startCopyTextMode()
@@ -316,6 +353,28 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
         kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
     }
 
+    fun clearSelection() {
+        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
+        kmpdfFactory?.kmpdfAnnotEditMode?.pdfAnnotEditMode = KMPDFAnnotEditMode.Mode.NULL
+        annotationEitModeLiveData.postValue(KMPDFAnnotEditMode.Mode.NULL)
+    }
+
+    fun deleteSelectedTextBox() {
+        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).deleteFreeTextAnnotView()
+    }
+
+    fun editSelectedTextBoxStyle() {
+        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).setCurrentFreeTextViewEditMode(0)
+    }
+
+    fun editSelectedTextBoxText() {
+        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).setCurrentFreeTextViewEditMode(1)
+    }
+
+    fun copySelectedTextBox() {
+        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).copyFreeTextContent()
+    }
+
     fun setPageIndex(pageIndex: Int){
         mPageIndexLiveData.value = pageIndex
     }
@@ -366,11 +425,13 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
         }
     }
 
-    fun setTextBoxAttribute(attr: TextBoxAttribute) {
+    fun setTextBoxAttribute(attr: TextBoxAttribute, modify: Boolean = false) {
 
         val kmpdfFreetextAnnotationBean = KMPDFFreetextAnnotationBean("", attr.textColor, attr.textSize, 255, "Courier", attr.isBold, attr.isItalic)
         kmpdfFactory?.setAnnotationAttribute(kmpdfFreetextAnnotationBean)
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.FREETEXT)
+        if (!modify) {
+            kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.FREETEXT)
+        }
     }
 
     fun setSignatureAttribute(attr: SignatureAttribute) {

+ 8 - 0
reader/src/main/java/com/kdanmobile/reader/screen/contextmenu/TextBoxContextMenuActionListener.kt

@@ -0,0 +1,8 @@
+package com.kdanmobile.reader.screen.contextmenu
+
+interface TextBoxContextMenuActionListener {
+    fun onDelete(): Boolean
+    fun onEditStyle(): Boolean
+    fun onEditText(): Boolean
+    fun onCopy(): Boolean
+}

+ 60 - 17
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/MediaBoxView.kt

@@ -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)

+ 1 - 1
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/shape/ShapeTabView.kt

@@ -82,7 +82,7 @@ class ShapeTabView : ConstraintLayout {
         }
         shapeType = AnnotConfig.ShapeAnnotationType.CIRCLE
 
-        viewPager.adapter = ViewPagerAdapter(context, arrayListOf("Border", "Fill"))
+        viewPager.adapter = ViewPagerAdapter(context, arrayListOf(resources.getString(R.string.mediaBox_shape_tabBorder), resources.getString(R.string.mediaBox_shape_tabFill)))
         tabLayout.setupWithViewPager(viewPager)
     }
 

+ 1 - 1
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StampTabView.kt

@@ -48,7 +48,7 @@ class StampTabView : ConstraintLayout {
     private fun initView() {
         LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab_stamp, this)
 
-        viewPager.adapter = StampViewPagerAdapter(arrayListOf("Custom", "Standard"))
+        viewPager.adapter = StampViewPagerAdapter(arrayListOf(resources.getString(R.string.mediaBox_stamp_tabCustom), resources.getString(R.string.mediaBox_stamp_tabStandard)))
         tabLayout.setupWithViewPager(viewPager)
     }
 

+ 59 - 0
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxStyleView.kt

@@ -0,0 +1,59 @@
+package com.kdanmobile.reader.screen.reader.mediabox.textbox
+
+import android.content.Context
+import android.graphics.Typeface
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.widget.SeekBar
+import com.kdanmobile.reader.R
+import com.kdanmobile.reader.screen.view.ColorSelectView
+import kotlinx.android.synthetic.main.view_viewer_edit_tab_text_box_style.view.*
+
+class TextBoxStyleView : TextBoxTabView {
+
+    constructor(context: Context) : super(context)
+
+    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
+
+    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
+
+    override fun initView() {
+        LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab_text_box_style, this)
+
+        textAttrView_textBox.onTextAttrClickListener = object : TextAttrView.OnTextAttrClickListener {
+
+            private fun getTypeface(): Int {
+                return when (textAttrView_textBox.isTextBold) {
+                    true -> when (textAttrView_textBox.isTextItalic) {
+                        true -> Typeface.BOLD_ITALIC
+                        false -> Typeface.BOLD
+                    }
+                    false -> when (textAttrView_textBox.isTextItalic) {
+                        true -> Typeface.ITALIC
+                        false -> Typeface.NORMAL
+                    }
+                }
+            }
+
+            override fun onBoldClick(isSelected: Boolean) {
+                tv_preview.setTypeface(null, getTypeface())
+            }
+
+            override fun onItalicClick(isSelected: Boolean) {
+                tv_preview.setTypeface(null, getTypeface())
+            }
+
+            override fun onAlignmentClick(gravity: Int) {
+                tv_preview.gravity = gravity
+            }
+        }
+
+        colorChooser_textBox.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
+            override fun onColorSelected(color: Int) {
+                tv_preview.setTextColor(color)
+            }
+        }
+
+        tv_preview.setTextColor(colorChooser_textBox.getSelectedColor())
+    }
+}

+ 2 - 15
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxTabView.kt

@@ -12,7 +12,7 @@ import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
 import com.kdanmobile.reader.screen.view.ColorSelectView
 import kotlinx.android.synthetic.main.view_viewer_edit_tab_text_box.view.*
 
-class TextBoxTabView : ConstraintLayout {
+open class TextBoxTabView : ConstraintLayout {
 
     var onMediaBoxHeaderClickListener: MediaBoxHeader.OnTitleButtonClickListener? = null
         set(value) {
@@ -32,7 +32,7 @@ class TextBoxTabView : ConstraintLayout {
         initView()
     }
 
-    private fun initView() {
+    protected open fun initView() {
         LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab_text_box, this)
 
         textAttrView_textBox.onTextAttrClickListener = object : TextAttrView.OnTextAttrClickListener {
@@ -69,19 +69,6 @@ class TextBoxTabView : ConstraintLayout {
             }
         }
 
-        seekBar_textBox_textSize.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
-            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
-//                tv_preview.textSize = seekBar_textBox_textSize.currentValue.toFloat()
-            }
-
-            override fun onStartTrackingTouch(seekBar: SeekBar) {
-            }
-
-            override fun onStopTrackingTouch(seekBar: SeekBar) {
-//                tv_preview.textSize = seekBar_textBox_textSize.currentValue.toFloat()
-            }
-        }
-
         tv_preview.setTextColor(colorChooser_textBox.getSelectedColor())
     }
 

+ 1 - 1
reader/src/main/res/layout/activity_reader.xml

@@ -247,7 +247,7 @@
     </android.support.constraint.ConstraintLayout>
 
     <com.kdanmobile.reader.screen.reader.mediabox.MediaBoxView
-        android:id="@+id/viewerEditView"
+        android:id="@+id/mediaBoxView"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
 </android.support.constraint.ConstraintLayout>

+ 4 - 4
reader/src/main/res/layout/activity_view_signature_create.xml

@@ -10,7 +10,7 @@
         android:layout_width="match_parent"
         android:layout_height="?attr/actionBarSize"
         android:background="#0077fd"
-        app:title="Create signature"
+        app:title="@string/mediaBox_signature_createSignature"
         app:titleTextColor="@android:color/white"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
@@ -26,7 +26,7 @@
         android:paddingEnd="16dp"
         android:textColor="@android:color/white"
         android:textSize="14sp"
-        android:text="SAVE"
+        android:text="@string/mediaBox_signature_btnSave"
         android:gravity="center"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintRight_toRightOf="parent" />
@@ -43,7 +43,7 @@
         android:gravity="center"
         android:textColor="#61000000"
         android:textSize="16sp"
-        android:text="Write here"
+        android:text="@string/mediaBox_signature_writeHere"
         app:layout_constraintTop_toBottomOf="@id/toolbar_signature"
         app:layout_constraintBottom_toTopOf="@id/btn_clear_signature"
         app:layout_constraintLeft_toLeftOf="parent"
@@ -121,7 +121,7 @@
         android:textColor="#0077fd"
         android:textSize="14sp"
         android:textStyle="bold"
-        android:text="CLEAR"
+        android:text="@string/mediaBox_signature_btnClear"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="parent" />
 

+ 0 - 27
reader/src/main/res/layout/view_viewer_edit_item_edittext.xml

@@ -1,27 +0,0 @@
-<?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:id="@+id/layout_title_add"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="#14000000">
-
-    <EditText
-        android:id="@+id/et_input"
-        style="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="16dp"
-        android:layout_marginStart="16dp"
-        android:layout_marginRight="16dp"
-        android:layout_marginEnd="16dp"
-        android:gravity="start"
-        android:textColor="#f5a623"
-        android:textSize="24sp"
-        android:text="Sample Text"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent" />
-
-</android.support.constraint.ConstraintLayout>

+ 4 - 4
reader/src/main/res/layout/view_viewer_edit_item_shape_border.xml

@@ -20,8 +20,8 @@
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_shapeBorder_opacity"
         android:layout_marginTop="8dp"
-        app:title="Opacity"
-        app:unit="%"
+        app:title="@string/mediaBox_shape_titleSeekBarOpacity"
+        app:unit="@string/mediaBox_shape_unitSeekBarOpacity"
         app:maxValue="255"
         app:minValue="0"
         app:initValue="255"
@@ -34,8 +34,8 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_shapeBorder_thickness"
-        app:title="Thickness"
-        app:unit="px"
+        app:title="@string/mediaBox_shape_titleSeekBarThickness"
+        app:unit="@string/mediaBox_shape_unitSeekBarThickness"
         app:maxValue="24"
         app:minValue="0"
         app:initValue="3"

+ 2 - 2
reader/src/main/res/layout/view_viewer_edit_item_shape_fill.xml

@@ -20,8 +20,8 @@
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_shapeFill_opacity"
         android:layout_marginTop="8dp"
-        app:title="Opacity"
-        app:unit="%"
+        app:title="@string/mediaBox_shape_titleSeekBarOpacity"
+        app:unit="@string/mediaBox_shape_unitSeekBarOpacity"
         app:maxValue="255"
         app:minValue="0"
         app:initValue="0"

+ 1 - 3
reader/src/main/res/layout/view_viewer_edit_item_stamp_custom.xml

@@ -29,7 +29,7 @@
             android:gravity="start"
             android:textColor="#f5a623"
             android:textSize="16sp"
-            android:hint="Enter Text"
+            android:hint="@string/mediaBox_stamp_hintEditText"
             app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintBottom_toBottomOf="parent" />
     </android.support.constraint.ConstraintLayout>
@@ -42,7 +42,6 @@
         android:layout_marginBottom="20dp"
         android:gravity="center_vertical"
         android:textSize="14sp"
-        android:text="2018/12/31"
         app:layout_constraintBottom_toTopOf="@+id/recyclerView_shapeCustom"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toLeftOf="@+id/cb_time"
@@ -55,7 +54,6 @@
         android:layout_marginBottom="12dp"
         android:gravity="center_vertical"
         android:textSize="14sp"
-        android:text="10:59:00 am"
         app:layout_constraintBottom_toTopOf="@+id/recyclerView_shapeCustom"
         app:layout_constraintLeft_toRightOf="@+id/cb_date"
         app:layout_constraintRight_toRightOf="parent"

+ 2 - 2
reader/src/main/res/layout/view_viewer_edit_tab_shape.xml

@@ -11,8 +11,8 @@
         android:layout_width="match_parent"
         android:layout_height="56dp"
         android:id="@+id/titleButton_shape"
-        app:title="Shape"
-        app:buttonText="ADD"
+        app:title="@string/mediaBox_shape_title"
+        app:buttonText="@string/mediaBox_shape_btnAdd"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent"

+ 2 - 2
reader/src/main/res/layout/view_viewer_edit_tab_signature.xml

@@ -18,7 +18,7 @@
         android:gravity="center_vertical"
         android:textColor="#de000000"
         android:textSize="14sp"
-        android:text="Signature Library" />
+        android:text="@string/mediaBox_signature_title" />
 
     <TextView
         android:id="@+id/tv_noSignature"
@@ -32,7 +32,7 @@
         android:gravity="center_vertical"
         android:textColor="#61000000"
         android:textSize="16sp"
-        android:text="No signature created"
+        android:text="@string/mediaBox_signature_noSignatureCreated"
         app:layout_constraintTop_toBottomOf="@id/tv_title_signature"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent" />

+ 2 - 2
reader/src/main/res/layout/view_viewer_edit_tab_stamp.xml

@@ -11,8 +11,8 @@
         android:layout_width="match_parent"
         android:layout_height="56dp"
         android:id="@+id/titleButton_stamp"
-        app:title="Stamp"
-        app:buttonText="ADD"
+        app:title="@string/mediaBox_stamp_title"
+        app:buttonText="@string/mediaBox_stamp_btnAdd"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent"

+ 8 - 8
reader/src/main/res/layout/view_viewer_edit_tab_text_box.xml

@@ -11,15 +11,15 @@
         android:layout_width="match_parent"
         android:layout_height="56dp"
         android:id="@+id/titleButton_textBox"
-        app:title="Text"
-        app:buttonText="ADD"
+        app:title="@string/mediaBox_textBox_title"
+        app:buttonText="@string/mediaBox_textBox_btnAdd"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintBottom_toTopOf="@+id/editTextView_textBox" />
+        app:layout_constraintBottom_toTopOf="@+id/layout_textBox" />
 
     <android.support.constraint.ConstraintLayout
-        android:id="@+id/editTextView_textBox"
+        android:id="@+id/layout_textBox"
         android:layout_width="match_parent"
         android:layout_height="64dp"
         android:orientation="vertical"
@@ -42,7 +42,7 @@
             android:gravity="start"
             android:textColor="#f5a623"
             android:textSize="24sp"
-            android:text="Sample Text"
+            android:text="@string/mediaBox_textBox_simpleText"
             app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintBottom_toBottomOf="parent" />
     </android.support.constraint.ConstraintLayout>
@@ -53,7 +53,7 @@
         android:id="@+id/textAttrView_textBox"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/editTextView_textBox"
+        app:layout_constraintTop_toBottomOf="@+id/layout_textBox"
         app:layout_constraintBottom_toTopOf="@+id/colorChooser_textBox" />
 
     <com.kdanmobile.reader.screen.view.ColorSelectView
@@ -73,8 +73,8 @@
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_textBox_textSize"
         android:layout_marginTop="16dp"
-        app:title="Size"
-        app:unit="pt"
+        app:title="@string/mediaBox_textBox_titleSeekBarSize"
+        app:unit="@string/mediaBox_textBox_unitSeekBarSize"
         app:maxValue="96"
         app:minValue="8"
         app:initValue="24"

+ 85 - 0
reader/src/main/res/layout/view_viewer_edit_tab_text_box_style.xml

@@ -0,0 +1,85 @@
+<?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="match_parent"
+    android:layout_height="match_parent"
+    android:clickable="true"
+    android:focusable="true"
+    android:background="#FFFFFFFF">
+
+    <com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
+        android:layout_width="match_parent"
+        android:layout_height="56dp"
+        android:id="@+id/titleButton_textBox"
+        app:title="@string/mediaBox_textBoxModify_title"
+        app:buttonText="@string/mediaBox_textBoxModify_btnApply"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/layout_textBox" />
+
+    <android.support.constraint.ConstraintLayout
+        android:id="@+id/layout_textBox"
+        android:layout_width="match_parent"
+        android:layout_height="64dp"
+        android:orientation="vertical"
+        android:background="#14000000"
+        android:layout_marginBottom="8dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/titleButton_textBox"
+        app:layout_constraintBottom_toTopOf="@+id/textAttrView_textBox" >
+
+        <TextView
+            android:id="@+id/tv_preview"
+            style="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="16dp"
+            android:layout_marginStart="16dp"
+            android:layout_marginRight="16dp"
+            android:layout_marginEnd="16dp"
+            android:gravity="start"
+            android:textColor="#f5a623"
+            android:textSize="24sp"
+            android:text="@string/mediaBox_textBox_simpleText"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent" />
+    </android.support.constraint.ConstraintLayout>
+
+    <com.kdanmobile.reader.screen.reader.mediabox.textbox.TextAttrView
+        android:layout_width="match_parent"
+        android:layout_height="48dp"
+        android:id="@+id/textAttrView_textBox"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/layout_textBox"
+        app:layout_constraintBottom_toTopOf="@+id/colorChooser_textBox" />
+
+    <com.kdanmobile.reader.screen.view.ColorSelectView
+        android:id="@+id/colorChooser_textBox"
+        android:layout_width="0dp"
+        android:layout_height="48dp"
+        android:gravity="center"
+        android:paddingTop="12dp"
+        android:layout_marginTop="16dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/textAttrView_textBox"
+        app:layout_constraintBottom_toTopOf="@+id/seekBar_textBox_textSize" />
+
+    <com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxSeekBar
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/seekBar_textBox_textSize"
+        android:layout_marginTop="16dp"
+        app:title="@string/mediaBox_textBox_titleSeekBarSize"
+        app:unit="@string/mediaBox_textBox_unitSeekBarSize"
+        app:maxValue="96"
+        app:minValue="8"
+        app:initValue="24"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/colorChooser_textBox" />
+
+</android.support.constraint.ConstraintLayout>

+ 7 - 0
reader/src/main/res/menu/context_menu_longpress.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:title="@string/context_menu_paste" />
+
+</menu>

+ 16 - 0
reader/src/main/res/menu/context_menu_textbox.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:title="@string/context_menu_delete" />
+
+    <item
+        android:title="@string/contextMenu_textbox_style" />
+
+    <item
+        android:title="@string/context_menu_edit" />
+
+    <item
+        android:title="@string/context_menu_copy" />
+
+</menu>

+ 30 - 0
reader/src/main/res/values/strings.xml

@@ -47,4 +47,34 @@
     <string name="viewer_setting_toolbar_display_setting">Toolbar Display Setting</string>
     <string name="viewer_setting_toolbar_display_setting_comment">Display Comment Tool</string>
     <string name="viewer_setting_toolbar_display_setting_bota">Display BOTA tool</string>
+
+    <string name="contextMenu_textbox_style">Style</string>
+
+    <!--MediaBox-->
+    <string name="mediaBox_textBox_title">Text</string>
+    <string name="mediaBox_textBox_btnAdd">ADD</string>
+    <string name="mediaBox_textBox_simpleText">Sample Text</string>
+    <string name="mediaBox_textBox_titleSeekBarSize">Size</string>
+    <string name="mediaBox_textBox_unitSeekBarSize">pt</string>
+    <string name="mediaBox_textBoxModify_title">Style</string>
+    <string name="mediaBox_textBoxModify_btnApply">APPLY</string>
+    <string name="mediaBox_signature_title">Signature Library</string>
+    <string name="mediaBox_signature_noSignatureCreated">No signature created</string>
+    <string name="mediaBox_signature_createSignature">Create signature</string>
+    <string name="mediaBox_signature_btnSave">SAVE</string>
+    <string name="mediaBox_signature_writeHere">Write here</string>
+    <string name="mediaBox_signature_btnClear">CLEAR</string>
+    <string name="mediaBox_stamp_title">Stamp</string>
+    <string name="mediaBox_stamp_btnAdd">ADD</string>
+    <string name="mediaBox_stamp_hintEditText">Enter Text</string>
+    <string name="mediaBox_stamp_tabCustom">Custom</string>
+    <string name="mediaBox_stamp_tabStandard">Standard</string>
+    <string name="mediaBox_shape_title">Shape</string>
+    <string name="mediaBox_shape_btnAdd">ADD</string>
+    <string name="mediaBox_shape_tabBorder">Border</string>
+    <string name="mediaBox_shape_tabFill">Fill</string>
+    <string name="mediaBox_shape_titleSeekBarOpacity">Opacity</string>
+    <string name="mediaBox_shape_unitSeekBarOpacity">%</string>
+    <string name="mediaBox_shape_titleSeekBarThickness">Thickness</string>
+    <string name="mediaBox_shape_unitSeekBarThickness">px</string>
 </resources>