|
@@ -4,8 +4,8 @@ import android.arch.lifecycle.LiveData
|
|
import android.arch.lifecycle.MutableLiveData
|
|
import android.arch.lifecycle.MutableLiveData
|
|
import android.arch.lifecycle.ViewModel
|
|
import android.arch.lifecycle.ViewModel
|
|
import android.content.Context
|
|
import android.content.Context
|
|
-import android.graphics.Color
|
|
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
|
|
+import android.graphics.Color
|
|
import android.graphics.RectF
|
|
import android.graphics.RectF
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
import com.kdanmobile.kmpdfkit.annotation.Annotation
|
|
import com.kdanmobile.kmpdfkit.annotation.Annotation
|
|
@@ -17,14 +17,18 @@ import com.kdanmobile.kmpdfkit.globaldata.Config
|
|
import com.kdanmobile.kmpdfkit.globaldata.KMPDFAnnotEditMode
|
|
import com.kdanmobile.kmpdfkit.globaldata.KMPDFAnnotEditMode
|
|
import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
|
|
import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
|
|
import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
|
|
import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
|
|
|
|
+import com.kdanmobile.kmpdfkit.manager.controller.KMPDFFreeTextController
|
|
|
|
+import com.kdanmobile.kmpdfkit.manager.controller.KMPDFLongPressCreateAnnotController
|
|
|
|
+import com.kdanmobile.kmpdfkit.manager.controller.KMPDFSignatureController
|
|
|
|
+import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAddAnnotCallback
|
|
|
|
+import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAnnotEditModeChangeListener
|
|
|
|
+import com.kdanmobile.kmpdfkit.pdfcommon.Bookmark
|
|
import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
|
|
import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
|
|
|
|
+import com.kdanmobile.kmpdfkit.pdfcommon.OutlineItem
|
|
|
|
+import com.kdanmobile.kmpdfkit.pdfcommon.TextWord
|
|
import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
|
|
import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
|
|
-import com.kdanmobile.reader.annotationattribute.InkAttribute
|
|
|
|
-import com.kdanmobile.kmpdfkit.pdfcommon.*
|
|
|
|
import com.kdanmobile.reader.annotationattribute.Brush
|
|
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.annotationattribute.InkAttribute
|
|
import com.kdanmobile.reader.screen.contextmenu.TextBoxContextMenuActionListener
|
|
import com.kdanmobile.reader.screen.contextmenu.TextBoxContextMenuActionListener
|
|
import com.kdanmobile.reader.screen.data.ShapeAttribute
|
|
import com.kdanmobile.reader.screen.data.ShapeAttribute
|
|
import com.kdanmobile.reader.screen.data.SignatureAttribute
|
|
import com.kdanmobile.reader.screen.data.SignatureAttribute
|
|
@@ -222,6 +226,10 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
|
|
|
|
fun setHighLightAttributes(annotationAttribute: AnnotationAttribute) {
|
|
fun setHighLightAttributes(annotationAttribute: AnnotationAttribute) {
|
|
highLightAttributeLiveData.postValue(annotationAttribute)
|
|
highLightAttributeLiveData.postValue(annotationAttribute)
|
|
|
|
+ setHighLightAttributesImp(annotationAttribute)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setHighLightAttributesImp(annotationAttribute: AnnotationAttribute) {
|
|
kmpdfFactory?.setAnnotationAttribute(KMPDFHighlightAnnotationBean("", annotationAttribute.color, annotationAttribute.alpha))
|
|
kmpdfFactory?.setAnnotationAttribute(KMPDFHighlightAnnotationBean("", annotationAttribute.color, annotationAttribute.alpha))
|
|
kmpdfFactory?.annotConfig?.apply {
|
|
kmpdfFactory?.annotConfig?.apply {
|
|
markerPenColor_hightlight = annotationAttribute.color
|
|
markerPenColor_hightlight = annotationAttribute.color
|
|
@@ -236,6 +244,10 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
|
|
|
|
fun setStrikeOutAttributes(annotationAttribute: AnnotationAttribute) {
|
|
fun setStrikeOutAttributes(annotationAttribute: AnnotationAttribute) {
|
|
strikeAttributeLiveData.postValue(annotationAttribute)
|
|
strikeAttributeLiveData.postValue(annotationAttribute)
|
|
|
|
+ setStrikeOutAttributesImp(annotationAttribute)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setStrikeOutAttributesImp(annotationAttribute: AnnotationAttribute) {
|
|
kmpdfFactory?.setAnnotationAttribute(KMPDFStrikeoutAnnotationBean("",annotationAttribute.color, annotationAttribute.alpha))
|
|
kmpdfFactory?.setAnnotationAttribute(KMPDFStrikeoutAnnotationBean("",annotationAttribute.color, annotationAttribute.alpha))
|
|
kmpdfFactory?.annotConfig?.apply {
|
|
kmpdfFactory?.annotConfig?.apply {
|
|
markerPenColor_strikeout = annotationAttribute.color
|
|
markerPenColor_strikeout = annotationAttribute.color
|
|
@@ -250,6 +262,10 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
|
|
|
|
fun setUnderLineAttributes(annotationAttribute: AnnotationAttribute) {
|
|
fun setUnderLineAttributes(annotationAttribute: AnnotationAttribute) {
|
|
underLineAttributeLiveData.postValue(annotationAttribute)
|
|
underLineAttributeLiveData.postValue(annotationAttribute)
|
|
|
|
+ setUnderLineAttributesImp(annotationAttribute)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setUnderLineAttributesImp(annotationAttribute: AnnotationAttribute) {
|
|
kmpdfFactory?.setAnnotationAttribute(KMPDFUnderlineAnnotationBean("", annotationAttribute.color, annotationAttribute.alpha))
|
|
kmpdfFactory?.setAnnotationAttribute(KMPDFUnderlineAnnotationBean("", annotationAttribute.color, annotationAttribute.alpha))
|
|
kmpdfFactory?.annotConfig?.apply {
|
|
kmpdfFactory?.annotConfig?.apply {
|
|
markerPenColor_underline = annotationAttribute.color
|
|
markerPenColor_underline = annotationAttribute.color
|
|
@@ -264,6 +280,10 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
|
|
|
|
fun setInkAttributes(inkAttribute: InkAttribute) {
|
|
fun setInkAttributes(inkAttribute: InkAttribute) {
|
|
inkAttributeLiveData.postValue(inkAttribute)
|
|
inkAttributeLiveData.postValue(inkAttribute)
|
|
|
|
+ setInkAttributesImp(inkAttribute)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fun setInkAttributesImp(inkAttribute: InkAttribute) {
|
|
kmpdfFactory?.apply {
|
|
kmpdfFactory?.apply {
|
|
setAnnotationAttribute(KMPDFInkAnnotationBean("", inkAttribute.color, inkAttribute.width, inkAttribute.alpha))
|
|
setAnnotationAttribute(KMPDFInkAnnotationBean("", inkAttribute.color, inkAttribute.width, inkAttribute.alpha))
|
|
annotConfig?.apply {
|
|
annotConfig?.apply {
|
|
@@ -288,6 +308,13 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
|
|
val isFirst = kmpdfFactory?.readerView == null
|
|
val isFirst = kmpdfFactory?.readerView == null
|
|
kmpdfFactory?.readerView = readerView
|
|
kmpdfFactory?.readerView = readerView
|
|
kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
|
|
kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
|
|
|
|
+
|
|
|
|
+ /** init annotation color **/
|
|
|
|
+ highLightAttributeLiveData.value?.also { setHighLightAttributesImp(it) }
|
|
|
|
+ strikeAttributeLiveData.value?.also { setStrikeOutAttributesImp(it) }
|
|
|
|
+ underLineAttributeLiveData.value?.also { setUnderLineAttributesImp(it) }
|
|
|
|
+ inkAttributeLiveData.value?.also { setInkAttributesImp(it) }
|
|
|
|
+
|
|
updateViewDirection()
|
|
updateViewDirection()
|
|
|
|
|
|
kmpdfFactory?.kmpdfAddAnnotCallback = object : KMPDFAddAnnotCallback {
|
|
kmpdfFactory?.kmpdfAddAnnotCallback = object : KMPDFAddAnnotCallback {
|