|
@@ -9,6 +9,7 @@ import android.os.Build
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.support.constraint.ConstraintLayout
|
|
import android.support.constraint.ConstraintLayout
|
|
import android.support.constraint.ConstraintSet
|
|
import android.support.constraint.ConstraintSet
|
|
|
|
+import android.support.design.widget.Snackbar
|
|
import android.support.v4.content.ContextCompat
|
|
import android.support.v4.content.ContextCompat
|
|
import android.support.v7.app.AlertDialog
|
|
import android.support.v7.app.AlertDialog
|
|
import android.support.v7.app.AppCompatActivity
|
|
import android.support.v7.app.AppCompatActivity
|
|
@@ -72,6 +73,8 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
|
|
|
|
private var oldLeftToolbarType = ReaderViewModel.LeftToolbarType.NONE
|
|
private var oldLeftToolbarType = ReaderViewModel.LeftToolbarType.NONE
|
|
|
|
|
|
|
|
+ private var snackbarMediaBox: Snackbar? = null
|
|
|
|
+
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_reader)
|
|
setContentView(R.layout.activity_reader)
|
|
@@ -233,10 +236,23 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
}
|
|
}
|
|
|
|
|
|
private fun onAnnotationEditModeUpdate(mode: KMPDFAnnotEditMode.Mode?) {
|
|
private fun onAnnotationEditModeUpdate(mode: KMPDFAnnotEditMode.Mode?) {
|
|
- println("onAnnotationEditModeUpdate KMPDFAnnotEditMode.Mode.$mode")
|
|
|
|
when (mode) {
|
|
when (mode) {
|
|
- KMPDFAnnotEditMode.Mode.NULL -> showAllToolbars()
|
|
|
|
- KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY, KMPDFAnnotEditMode.Mode.STAMP_MODIFY, KMPDFAnnotEditMode.Mode.SIGN_MODIFY, KMPDFAnnotEditMode.Mode.SHAPE_MODIFY -> hideAllToolbars()
|
|
|
|
|
|
+ KMPDFAnnotEditMode.Mode.NULL -> {
|
|
|
|
+ showAllToolbars()
|
|
|
|
+ isHideToolbar = false
|
|
|
|
+ snackbarMediaBox?.dismiss()
|
|
|
|
+ snackbarMediaBox = null
|
|
|
|
+ }
|
|
|
|
+ KMPDFAnnotEditMode.Mode.SIGN_MODIFY -> {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ isHideToolbar = true
|
|
|
|
+ }
|
|
|
|
+ KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY, KMPDFAnnotEditMode.Mode.STAMP_MODIFY, KMPDFAnnotEditMode.Mode.SHAPE_MODIFY -> {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ isHideToolbar = true
|
|
|
|
+ snackbarMediaBox?.dismiss()
|
|
|
|
+ snackbarMediaBox = null
|
|
|
|
+ }
|
|
else -> {}
|
|
else -> {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -505,13 +521,37 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupMediaBoxView() {
|
|
private fun setupMediaBoxView() {
|
|
|
|
+
|
|
|
|
+ fun showSnackbar(title: String, btnText: String) {
|
|
|
|
+ snackbarMediaBox = Snackbar.make(mediaBoxView, title, Snackbar.LENGTH_INDEFINITE)
|
|
|
|
+ .setAction(btnText) {
|
|
|
|
+ viewModel.clearSelection()
|
|
|
|
+ mediaBoxView.post {
|
|
|
|
+ mediaBoxView.show()
|
|
|
|
+ snackbarMediaBox?.dismiss()
|
|
|
|
+ snackbarMediaBox = null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ snackbarMediaBox?.setActionTextColor(ContextCompat.getColor(this, R.color.bright_blue))
|
|
|
|
+ snackbarMediaBox?.show()
|
|
|
|
+ }
|
|
|
|
+
|
|
mediaBoxView.apply {
|
|
mediaBoxView.apply {
|
|
- onShowListener = Runnable { onMediaBoxShown() }
|
|
|
|
- onDismissListener = Runnable { onMediaBoxDismissed() }
|
|
|
|
|
|
+ onShowListener = Runnable {
|
|
|
|
+ onMediaBoxShown()
|
|
|
|
+ snackbarMediaBox?.dismiss()
|
|
|
|
+ snackbarMediaBox = null
|
|
|
|
+ }
|
|
|
|
+ onDismissListener = Runnable {
|
|
|
|
+ onMediaBoxDismissed()
|
|
|
|
+ snackbarMediaBox?.dismiss()
|
|
|
|
+ snackbarMediaBox = null
|
|
|
|
+ }
|
|
onClickAddButtonListener = object : MediaBoxView.OnClickHeaderButtonListener {
|
|
onClickAddButtonListener = object : MediaBoxView.OnClickHeaderButtonListener {
|
|
override fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView) {
|
|
override fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView) {
|
|
dismiss(false)
|
|
dismiss(false)
|
|
viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute())
|
|
viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute())
|
|
|
|
+ showSnackbar(resources.getString(R.string.mediaBox_snakebar_textBox), resources.getString(R.string.mediaBox_snakebar_undo))
|
|
}
|
|
}
|
|
|
|
|
|
override fun onClickTextBoxStyleApplyButton(textBoxTabView: TextBoxTabView) {
|
|
override fun onClickTextBoxStyleApplyButton(textBoxTabView: TextBoxTabView) {
|
|
@@ -522,16 +562,19 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
override fun onClickSignatureAddButton(signatureTabView: SignatureTabView) {
|
|
override fun onClickSignatureAddButton(signatureTabView: SignatureTabView) {
|
|
dismiss(false)
|
|
dismiss(false)
|
|
viewModel.setSignatureAttribute(signatureTabView.getSignatureAttribute())
|
|
viewModel.setSignatureAttribute(signatureTabView.getSignatureAttribute())
|
|
|
|
+ showSnackbar(resources.getString(R.string.mediaBox_snakebar_signature), resources.getString(R.string.mediaBox_snakebar_undo))
|
|
}
|
|
}
|
|
|
|
|
|
override fun onClickStampAddButton(stampTabView: StampTabView) {
|
|
override fun onClickStampAddButton(stampTabView: StampTabView) {
|
|
dismiss(false)
|
|
dismiss(false)
|
|
viewModel.setStampAttribute(stampTabView.getStampAttribute())
|
|
viewModel.setStampAttribute(stampTabView.getStampAttribute())
|
|
|
|
+ showSnackbar(resources.getString(R.string.mediaBox_snakebar_stamp), resources.getString(R.string.mediaBox_snakebar_undo))
|
|
}
|
|
}
|
|
|
|
|
|
override fun onClickShapeAddButton(shapeTabView: ShapeTabView) {
|
|
override fun onClickShapeAddButton(shapeTabView: ShapeTabView) {
|
|
dismiss(false)
|
|
dismiss(false)
|
|
viewModel.setShapeAttribute(shapeTabView.getShapeAttribute())
|
|
viewModel.setShapeAttribute(shapeTabView.getShapeAttribute())
|
|
|
|
+ showSnackbar(resources.getString(R.string.mediaBox_snakebar_shape), resources.getString(R.string.mediaBox_snakebar_undo))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -667,10 +710,12 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
|
|
|
|
private fun onMediaBoxShown() {
|
|
private fun onMediaBoxShown() {
|
|
hideAllToolbars()
|
|
hideAllToolbars()
|
|
|
|
+ isHideToolbar = true
|
|
}
|
|
}
|
|
|
|
|
|
private fun onMediaBoxDismissed() {
|
|
private fun onMediaBoxDismissed() {
|
|
showAllToolbars()
|
|
showAllToolbars()
|
|
|
|
+ isHideToolbar = false
|
|
viewModel.clearSelection()
|
|
viewModel.clearSelection()
|
|
}
|
|
}
|
|
|
|
|