Quellcode durchsuchen

Change KMPDFAnnotEditMode.Mode to MODIFY when the annotation is attached

cooperku_kdanmobile vor 5 Jahren
Ursprung
Commit
9c9e9f5568
1 geänderte Dateien mit 23 neuen und 0 gelöschten Zeilen
  1. 23 0
      reader/src/main/java/com/kdanmobile/reader/ReaderViewModel.kt

+ 23 - 0
reader/src/main/java/com/kdanmobile/reader/ReaderViewModel.kt

@@ -7,11 +7,14 @@ import android.content.Context
 import android.graphics.Bitmap
 import android.graphics.RectF
 import android.net.Uri
+import com.kdanmobile.kmpdfkit.annotation.Annotation
 import com.kdanmobile.kmpdfkit.annotation.bean.*
 import com.kdanmobile.kmpdfkit.globaldata.AnnotConfig
 import com.kdanmobile.kmpdfkit.globaldata.Config
+import com.kdanmobile.kmpdfkit.globaldata.KMPDFAnnotEditMode
 import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
 import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
+import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAddAnnotCallback
 import com.kdanmobile.kmpdfkit.pdfcommon.*
 import com.kdanmobile.reader.screen.data.ShapeAttribute
 import com.kdanmobile.reader.screen.data.StampAttribute
@@ -158,6 +161,26 @@ class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMs
         kmpdfFactory?.readerView = readerView
         kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
         updateViewDirection()
+
+        kmpdfFactory?.kmpdfAddAnnotCallback = object : KMPDFAddAnnotCallback {
+
+            override fun onSaveAnnotFinished(type: Annotation.Type, result: Boolean, message: String) {
+                println("KMPDFAddAnnotCallback::onSaveAnnotFinished")
+            }
+
+            override fun onAttachAnnotWidgetFinished(type: Annotation.Type) {
+                println("KMPDFAddAnnotCallback::onAttachAnnotWidgetFinished")
+                val mode = when (type) {
+                    Annotation.Type.FREETEXT -> KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY
+                    Annotation.Type.STAMP -> KMPDFAnnotEditMode.Mode.STAMP_MODIFY
+                    Annotation.Type.CIRCLE, Annotation.Type.SQUARE, Annotation.Type.LINE -> KMPDFAnnotEditMode.Mode.SHAPE_MODIFY
+                    else -> KMPDFAnnotEditMode.Mode.NULL
+                }
+                if (mode != KMPDFAnnotEditMode.Mode.NULL) {
+                    kmpdfFactory?.kmpdfAnnotEditMode?.pdfAnnotEditMode = mode
+                }
+            }
+        }
     }
 
     fun setPageIndex(pageIndex: Int){