|
@@ -564,6 +564,26 @@ class ReaderViewModel(private val readerModelManager: ReaderModelManager, val ur
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun createTextBoxSelector(context: Context, topLeft: Boolean, topRight: Boolean, bottomRight: Boolean, bottomLeft: Boolean): Drawable {
|
|
|
+ val radius = context.resources.getDimension(R.dimen.reader_context_menu_text_box_radius)
|
|
|
+ val topLeftRadius = if (topLeft) PointF(radius, radius) else PointF()
|
|
|
+ val topRightRadius = if (topRight) PointF(radius, radius) else PointF()
|
|
|
+ val bottomRightRadius = if (bottomRight) PointF(radius, radius) else PointF()
|
|
|
+ val bottomLeftRadius = if (bottomLeft) PointF(radius, radius) else PointF()
|
|
|
+ val cornerRadii = floatArrayOf(topLeftRadius.x, topLeftRadius.y, topRightRadius.x, topRightRadius.y, bottomRightRadius.x, bottomRightRadius.y, bottomLeftRadius.x, bottomLeftRadius.y)
|
|
|
+
|
|
|
+ val normalDrawable = GradientDrawable()
|
|
|
+ normalDrawable.cornerRadii = cornerRadii
|
|
|
+ normalDrawable.setColor(ContextCompat.getColor(context, R.color.reader_contextMenu_bgNormal))
|
|
|
+ val pressedDrawable = GradientDrawable()
|
|
|
+ pressedDrawable.cornerRadii = cornerRadii
|
|
|
+ pressedDrawable.setColor(ContextCompat.getColor(context, R.color.reader_contextMenu_bgPressed))
|
|
|
+ val drawable = StateListDrawable()
|
|
|
+ drawable.addState(intArrayOf(android.R.attr.state_pressed), pressedDrawable)
|
|
|
+ drawable.addState(intArrayOf(android.R.attr.state_enabled), normalDrawable)
|
|
|
+ return drawable
|
|
|
+ }
|
|
|
+
|
|
|
private fun createMarkupContextMenuView(context: Context): View {
|
|
|
/** Just set HIGH_LIGHT then highlight, strike, underline will be triggered. **/
|
|
|
/** WTF !!!!!!!!!!! **/
|
|
@@ -589,19 +609,30 @@ class ReaderViewModel(private val readerModelManager: ReaderModelManager, val ur
|
|
|
private fun createSelectTextContextMenuView(context: Context): View {
|
|
|
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
|
|
val contentView = layoutInflater.inflate(R.layout.view_context_menu_select_text, null)
|
|
|
- contentView.findViewById<TextView>(R.id.btnCopy_contextMenu).setOnClickListener {
|
|
|
+
|
|
|
+ val btnCopy = contentView.findViewById<TextView>(R.id.btnCopy_contextMenu)
|
|
|
+ val btnHighlight = contentView.findViewById<TextView>(R.id.btnHighlight_contextMenu)
|
|
|
+ val btnUnderline = contentView.findViewById<TextView>(R.id.btnUnderline_contextMenu)
|
|
|
+ val btnStrikeout = contentView.findViewById<TextView>(R.id.btnStrikeout_contextMenu)
|
|
|
+
|
|
|
+ setViewBackground(btnCopy, createTextBoxSelector(context, true, false, false, true))
|
|
|
+ setViewBackground(btnHighlight, createTextBoxSelector(context, false, false, false, false))
|
|
|
+ setViewBackground(btnUnderline, createTextBoxSelector(context, false, false, false, false))
|
|
|
+ setViewBackground(btnStrikeout, createTextBoxSelector(context, false, true, true, false))
|
|
|
+
|
|
|
+ btnCopy.setOnClickListener {
|
|
|
(kmpdfFactory?.getController(KMPDFFactory.ControllerType.SELECT_TEXT) as KMPDFSelectTextController).copySelectedText()
|
|
|
dismissPopupWindow()
|
|
|
}
|
|
|
- contentView.findViewById<TextView>(R.id.btnHighlight_contextMenu).setOnClickListener {
|
|
|
+ btnHighlight.setOnClickListener {
|
|
|
(kmpdfFactory?.getController(KMPDFFactory.ControllerType.SELECT_TEXT) as KMPDFSelectTextController).highlightSelectedText()
|
|
|
dismissPopupWindow()
|
|
|
}
|
|
|
- contentView.findViewById<TextView>(R.id.btnUnderline_contextMenu).setOnClickListener {
|
|
|
+ btnUnderline.setOnClickListener {
|
|
|
(kmpdfFactory?.getController(KMPDFFactory.ControllerType.SELECT_TEXT) as KMPDFSelectTextController).underlineSelectedText()
|
|
|
dismissPopupWindow()
|
|
|
}
|
|
|
- contentView.findViewById<TextView>(R.id.btnStrikeout_contextMenu).setOnClickListener {
|
|
|
+ btnStrikeout.setOnClickListener {
|
|
|
(kmpdfFactory?.getController(KMPDFFactory.ControllerType.SELECT_TEXT) as KMPDFSelectTextController).strikeoutSelectedText()
|
|
|
dismissPopupWindow()
|
|
|
}
|
|
@@ -622,35 +653,15 @@ class ReaderViewModel(private val readerModelManager: ReaderModelManager, val ur
|
|
|
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
|
|
val contentView = layoutInflater.inflate(R.layout.view_context_menu_textbox, null)
|
|
|
|
|
|
- fun createTextBoxSelector(topLeft: Boolean, topRight: Boolean, bottomRight: Boolean, bottomLeft: Boolean): Drawable {
|
|
|
- val radius = context.resources.getDimension(R.dimen.reader_context_menu_text_box_radius)
|
|
|
- val topLeftRadius = if (topLeft) PointF(radius, radius) else PointF()
|
|
|
- val topRightRadius = if (topRight) PointF(radius, radius) else PointF()
|
|
|
- val bottomRightRadius = if (bottomRight) PointF(radius, radius) else PointF()
|
|
|
- val bottomLeftRadius = if (bottomLeft) PointF(radius, radius) else PointF()
|
|
|
- val cornerRadii = floatArrayOf(topLeftRadius.x, topLeftRadius.y, topRightRadius.x, topRightRadius.y, bottomRightRadius.x, bottomRightRadius.y, bottomLeftRadius.x, bottomLeftRadius.y)
|
|
|
-
|
|
|
- val normalDrawable = GradientDrawable()
|
|
|
- normalDrawable.cornerRadii = cornerRadii
|
|
|
- normalDrawable.setColor(ContextCompat.getColor(context, R.color.reader_contextMenu_bgNormal))
|
|
|
- val pressedDrawable = GradientDrawable()
|
|
|
- pressedDrawable.cornerRadii = cornerRadii
|
|
|
- pressedDrawable.setColor(ContextCompat.getColor(context, R.color.reader_contextMenu_bgPressed))
|
|
|
- val drawable = StateListDrawable()
|
|
|
- drawable.addState(intArrayOf(android.R.attr.state_pressed), pressedDrawable)
|
|
|
- drawable.addState(intArrayOf(android.R.attr.state_enabled), normalDrawable)
|
|
|
- return drawable
|
|
|
- }
|
|
|
-
|
|
|
val btnDelete = contentView.findViewById<TextView>(R.id.btnDelete_contextMenu)
|
|
|
val btnStyle = contentView.findViewById<TextView>(R.id.btnStyle_contextMenu)
|
|
|
val btnEdit = contentView.findViewById<TextView>(R.id.btnEdit_contextMenu)
|
|
|
val btnCopy = contentView.findViewById<TextView>(R.id.btnCopy_contextMenu)
|
|
|
|
|
|
- setViewBackground(btnDelete, createTextBoxSelector(true, false, false, true))
|
|
|
- setViewBackground(btnStyle, createTextBoxSelector(false, false, false, false))
|
|
|
- setViewBackground(btnEdit, createTextBoxSelector(false, false, false, false))
|
|
|
- setViewBackground(btnCopy, createTextBoxSelector(false, true, true, false))
|
|
|
+ setViewBackground(btnDelete, createTextBoxSelector(context, true, false, false, true))
|
|
|
+ setViewBackground(btnStyle, createTextBoxSelector(context, false, false, false, false))
|
|
|
+ setViewBackground(btnEdit, createTextBoxSelector(context, false, false, false, false))
|
|
|
+ setViewBackground(btnCopy, createTextBoxSelector(context, false, true, true, false))
|
|
|
|
|
|
btnDelete.setOnClickListener {
|
|
|
textBoxContextMenuActionListener?.onDelete()
|
|
@@ -674,11 +685,18 @@ class ReaderViewModel(private val readerModelManager: ReaderModelManager, val ur
|
|
|
private fun createSignatureContextMenuView(context: Context): View {
|
|
|
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
|
|
val contentView = layoutInflater.inflate(R.layout.view_context_menu_signature, null)
|
|
|
- contentView.findViewById<TextView>(R.id.btnDelete_contextMenu).setOnClickListener {
|
|
|
+
|
|
|
+ val btnDelete = contentView.findViewById<TextView>(R.id.btnDelete_contextMenu)
|
|
|
+ val btnAdd = contentView.findViewById<TextView>(R.id.btnAdd_contextMenu)
|
|
|
+
|
|
|
+ setViewBackground(btnDelete, createTextBoxSelector(context, true, false, false, true))
|
|
|
+ setViewBackground(btnAdd, createTextBoxSelector(context, false, true, true, false))
|
|
|
+
|
|
|
+ btnDelete.setOnClickListener {
|
|
|
(kmpdfFactory?.getController(KMPDFFactory.ControllerType.SIGNATURE) as KMPDFSignatureController).deleteSignatureAnnotView()
|
|
|
dismissPopupWindow()
|
|
|
}
|
|
|
- contentView.findViewById<TextView>(R.id.btnAdd_contextMenu).setOnClickListener {
|
|
|
+ btnAdd.setOnClickListener {
|
|
|
(kmpdfFactory?.getController(KMPDFFactory.ControllerType.SIGNATURE) as KMPDFSignatureController).saveSignatureAnnot()
|
|
|
dismissPopupWindow()
|
|
|
}
|