|
@@ -1,11 +1,6 @@
|
|
|
package com.compdfkit.pdfviewer.flutter.helpers
|
|
|
|
|
|
-import android.graphics.Color
|
|
|
-import android.util.Log
|
|
|
-import com.compdfkit.core.annotation.CPDFAnnotation
|
|
|
-import com.compdfkit.core.annotation.CPDFLineAnnotation
|
|
|
import com.compdfkit.pdfviewer.flutter.view.PDFReaderView
|
|
|
-import com.compdfkit.ui.reader.CPDFReaderView
|
|
|
import io.flutter.plugin.common.MethodCall
|
|
|
import io.flutter.plugin.common.MethodChannel
|
|
|
|
|
@@ -21,13 +16,13 @@ import io.flutter.plugin.common.MethodChannel
|
|
|
object PluginUtils {
|
|
|
|
|
|
|
|
|
-
|
|
|
- const val EVENT_CHANNEL_READER_VIEW_CALL_BACK = "event_reader_view_call_back"
|
|
|
- const val EVENT_CHANNEL_READER_VIEW_CONTEXT_MENU_HELPER = "event_reader_view_context_menu_helper"
|
|
|
- const val METHOD_CHANNEL_MODIFY_ANNOTATION_ATTRIBUTE = "method_modify_annotation_attribute"
|
|
|
- const val EVENT_CHANNEL_READER_VIEW_FOCUSED_CHANGE_CALL_BACK = "event_reader_view_focused_change_call_back"
|
|
|
- //get ComPDFKit Version info
|
|
|
- const val KEY_COMPDFKIT_VERSION = "ComPDFKitVersion"
|
|
|
+ const val METHOD_COM_PDF_KIT_GLOBAL_INFO = "com.compdfkit.pdf.flutter.global"
|
|
|
+ const val METHOD_COM_PDF_KIT_VIEW_SETTINGS = "com.compdfkit.pdf.flutter.pdfview.settings"
|
|
|
+ const val METHOD_CHANNEL_MODIFY_ANNOTATION_ATTRIBUTE = "com.compdfkit.pdf.flutter.pdfview.modify.annotation.attribute"
|
|
|
+ const val VIEW_TYPE_COM_PDF_KIT_PDF_VIEW = "com.compdfkit.pdf.flutter.pdfview"
|
|
|
+ const val EVENT_CHANNEL_READER_VIEW_CALL_BACK = "com.compdfkit.pdf.flutter.pdfview.view.call.back"
|
|
|
+ const val EVENT_CHANNEL_READER_VIEW_CONTEXT_MENU_HELPER = "com.compdfkit.pdf.flutter.pdfview.context.menu.helper"
|
|
|
+ const val EVENT_CHANNEL_READER_VIEW_FOCUSED_CHANGE_CALL_BACK = "com.compdfkit.pdf.flutter.pdfview.focused.change.callback"
|
|
|
|
|
|
|
|
|
const val EVENT_ON_TAP_MAIN_DOC_AREA = "onTapMainDocArea"
|
|
@@ -63,21 +58,23 @@ object PluginUtils {
|
|
|
const val EVENT_DOCUMENT_CURRENT_PAGE_INDEX = "documentCurrentPageIndex"
|
|
|
const val EVENT_DOCUMENT_PAGE_COUNT = "documentPageCount"
|
|
|
|
|
|
- const val KEY_SCROLL_DIRECTION = "scrollDirection"
|
|
|
- const val KEY_IS_DOUBLE_PAGE = "isDoublePage"
|
|
|
- const val KEY_IS_CONTINUE_MODE = "isContinueMode"
|
|
|
- const val KEY_IS_COVER_PAGE_MODE = "isCoverPageMode"
|
|
|
- const val KEY_IS_CROP_PAGE_MODE = "isCropPageMode"
|
|
|
- const val KEY_ANNOT_TYPE = "annotType"
|
|
|
- const val KEY_ANNOT_ATTRIBUTE = "annotAttribute"
|
|
|
- const val KEY_TOUCH_MODE = "touchMode"
|
|
|
- const val KEY_FOCUSED_TYPE = "focusedType"
|
|
|
- const val KEY_READ_BACKGROUND_COLOR = "readBackgroundColor"
|
|
|
- const val KEY_MODIFY_ANNOTATION_ATTRIBUTE = "modifyAnnotationAttribute"
|
|
|
- const val KEY_DISMISS_MODIFY_ANNOTATION_ATTRIBUTE = "dismissModifyAnnotationAttr"
|
|
|
+ const val EVENT_SCROLL_DIRECTION = "scrollDirection"
|
|
|
+ const val EVENT_IS_DOUBLE_PAGE = "isDoublePage"
|
|
|
+ const val EVENT_IS_CONTINUE_MODE = "isContinueMode"
|
|
|
+ const val EVENT_IS_COVER_PAGE_MODE = "isCoverPageMode"
|
|
|
+ const val EVENT_IS_CROP_PAGE_MODE = "isCropPageMode"
|
|
|
+ const val EVENT_ANNOT_TYPE = "annotType"
|
|
|
+ const val EVENT_ANNOT_ATTRIBUTE = "annotAttribute"
|
|
|
+ const val EVENT_TOUCH_MODE = "touchMode"
|
|
|
+ const val EVENT_FOCUSED_TYPE = "focusedType"
|
|
|
+ const val EVENT_READ_BACKGROUND_COLOR = "readBackgroundColor"
|
|
|
+ const val EVENT_MODIFY_ANNOTATION_ATTRIBUTE = "modifyAnnotationAttribute"
|
|
|
+ const val EVENT_DISMISS_MODIFY_ANNOTATION_ATTRIBUTE = "dismissModifyAnnotationAttr"
|
|
|
const val SCROLL_DIRECTION_VERTICAL = "vertical"
|
|
|
const val SCROLL_DIRECTION_HORIZONTAL = "horizontal"
|
|
|
|
|
|
+ //get ComPDFKit Version info
|
|
|
+ const val FUNCTION_GET_COMPDFKIT_VERSION = "ComPDFKitVersion"
|
|
|
///MethodChannel invokeMethod method name
|
|
|
const val FUNCTION_SET_SCROLL_DIRECTION = "setScrollDirection"
|
|
|
const val FUNCTION_GET_SCROLL_DIRECTION = "getScrollDirection"
|
|
@@ -98,25 +95,25 @@ object PluginUtils {
|
|
|
|
|
|
fun initPDFReaderViewConfig(pdfReaderView: PDFReaderView, configurationMap: Map<String, Any>?) {
|
|
|
|
|
|
- configurationMap.getString(KEY_SCROLL_DIRECTION)?.let {
|
|
|
+ configurationMap.getString(EVENT_SCROLL_DIRECTION)?.let {
|
|
|
pdfReaderView.pdfReaderView.isVerticalMode = it == SCROLL_DIRECTION_VERTICAL
|
|
|
}
|
|
|
- configurationMap.getBoolean(KEY_IS_DOUBLE_PAGE)?.let {
|
|
|
+ configurationMap.getBoolean(EVENT_IS_DOUBLE_PAGE)?.let {
|
|
|
pdfReaderView.pdfReaderView.isDoublePageMode = it
|
|
|
}
|
|
|
- configurationMap.getBoolean(KEY_IS_CONTINUE_MODE)?.let {
|
|
|
+ configurationMap.getBoolean(EVENT_IS_CONTINUE_MODE)?.let {
|
|
|
pdfReaderView.pdfReaderView.isContinueMode = it
|
|
|
}
|
|
|
- configurationMap.getBoolean(KEY_IS_COVER_PAGE_MODE)?.let {
|
|
|
+ configurationMap.getBoolean(EVENT_IS_COVER_PAGE_MODE)?.let {
|
|
|
pdfReaderView.pdfReaderView.isCoverPageMode = it
|
|
|
}
|
|
|
- configurationMap.getBoolean(KEY_IS_CROP_PAGE_MODE)?.let {
|
|
|
+ configurationMap.getBoolean(EVENT_IS_CROP_PAGE_MODE)?.let {
|
|
|
pdfReaderView.pdfReaderView.isCropMode = it
|
|
|
}
|
|
|
- configurationMap.getMap(KEY_ANNOT_ATTRIBUTE)?.let {
|
|
|
+ configurationMap.getMap(EVENT_ANNOT_ATTRIBUTE)?.let {
|
|
|
AnnotAttributeUtil.setAnnotAttribute(pdfReaderView.pdfReaderView, it)
|
|
|
}
|
|
|
- configurationMap.getString(KEY_READ_BACKGROUND_COLOR)?.let {
|
|
|
+ configurationMap.getString(EVENT_READ_BACKGROUND_COLOR)?.let {
|
|
|
pdfReaderView.pdfReaderView.readBackgroundColor = it.fromHex()
|
|
|
}
|
|
|
|
|
@@ -130,7 +127,7 @@ object PluginUtils {
|
|
|
result.success(if (pdfReaderView.pdfReaderView.isVerticalMode) SCROLL_DIRECTION_VERTICAL else SCROLL_DIRECTION_HORIZONTAL)
|
|
|
}
|
|
|
FUNCTION_SET_SCROLL_DIRECTION -> {
|
|
|
- (configuration?.get(KEY_SCROLL_DIRECTION) as? String)?.let {
|
|
|
+ (configuration?.get(EVENT_SCROLL_DIRECTION) as? String)?.let {
|
|
|
pdfReaderView.pdfReaderView.isVerticalMode = it == SCROLL_DIRECTION_VERTICAL
|
|
|
result.success(if (pdfReaderView.pdfReaderView.isVerticalMode) SCROLL_DIRECTION_VERTICAL else SCROLL_DIRECTION_HORIZONTAL)
|
|
|
}
|
|
@@ -139,13 +136,13 @@ object PluginUtils {
|
|
|
result.success(pdfReaderView.pdfReaderView.isDoublePageMode)
|
|
|
}
|
|
|
FUNCTION_SET_PAGE_MODE -> {
|
|
|
- (configuration?.get(KEY_IS_DOUBLE_PAGE) as? Boolean)?.let {
|
|
|
+ (configuration?.get(EVENT_IS_DOUBLE_PAGE) as? Boolean)?.let {
|
|
|
pdfReaderView.pdfReaderView.isDoublePageMode = it
|
|
|
result.success(pdfReaderView.pdfReaderView.isDoublePageMode)
|
|
|
}
|
|
|
}
|
|
|
FUNCTION_SET_IS_CONTINUE_MODE -> {
|
|
|
- (configuration?.get(KEY_IS_CONTINUE_MODE) as? Boolean)?.let {
|
|
|
+ (configuration?.get(EVENT_IS_CONTINUE_MODE) as? Boolean)?.let {
|
|
|
pdfReaderView.pdfReaderView.isContinueMode = it
|
|
|
result.success(pdfReaderView.pdfReaderView.isContinueMode)
|
|
|
}
|
|
@@ -157,7 +154,7 @@ object PluginUtils {
|
|
|
result.success(pdfReaderView.pdfReaderView.isCoverPageMode)
|
|
|
}
|
|
|
FUNCTION_SET_IS_COVER_PAGE_MODE -> {
|
|
|
- (configuration?.get(KEY_IS_COVER_PAGE_MODE) as? Boolean)?.let {
|
|
|
+ (configuration?.get(EVENT_IS_COVER_PAGE_MODE) as? Boolean)?.let {
|
|
|
pdfReaderView.pdfReaderView.isCoverPageMode = it
|
|
|
result.success(pdfReaderView.pdfReaderView.isCoverPageMode)
|
|
|
}
|
|
@@ -166,26 +163,26 @@ object PluginUtils {
|
|
|
result.success(pdfReaderView.pdfReaderView.isCropMode)
|
|
|
}
|
|
|
FUNCTION_SET_IS_CROP_PAGE_MODE -> {
|
|
|
- (configuration?.get(KEY_IS_CROP_PAGE_MODE) as? Boolean)?.let {
|
|
|
+ (configuration?.get(EVENT_IS_CROP_PAGE_MODE) as? Boolean)?.let {
|
|
|
pdfReaderView.pdfReaderView.isCropMode = it
|
|
|
result.success(pdfReaderView.pdfReaderView.isCropMode)
|
|
|
}
|
|
|
}
|
|
|
FUNCTION_GET_ANNOT_ATTRIBUTE -> {
|
|
|
- (configuration?.get(KEY_ANNOT_TYPE) as? String)?.let {
|
|
|
+ (configuration?.get(EVENT_ANNOT_TYPE) as? String)?.let {
|
|
|
val annotAttribute = AnnotAttributeUtil.getReaderAnnotAttribute(pdfReaderView.pdfReaderView, AnnotType.valueOf(it.uppercase()))
|
|
|
result.success(annotAttribute)
|
|
|
}
|
|
|
}
|
|
|
FUNCTION_SET_ANNOT_ATTRIBUTE -> {
|
|
|
- configuration.getString(KEY_ANNOT_TYPE)?.let {
|
|
|
- val annotAttr = configuration?.get(KEY_ANNOT_ATTRIBUTE) as? Map<String, Any> ?: hashMapOf()
|
|
|
+ configuration.getString(EVENT_ANNOT_TYPE)?.let {
|
|
|
+ val annotAttr = configuration?.get(EVENT_ANNOT_ATTRIBUTE) as? Map<String, Any> ?: hashMapOf()
|
|
|
AnnotAttributeUtil.setAnnotAttribute(pdfReaderView.pdfReaderView, mapOf(it to annotAttr))
|
|
|
}
|
|
|
}
|
|
|
FUNCTION_SET_CURRENT_FOCUSED_TYPE -> {
|
|
|
- val touchMode = configuration.getString(KEY_TOUCH_MODE)
|
|
|
- val focusedType = configuration.getString(KEY_FOCUSED_TYPE)
|
|
|
+ val touchMode = configuration.getString(EVENT_TOUCH_MODE)
|
|
|
+ val focusedType = configuration.getString(EVENT_FOCUSED_TYPE)
|
|
|
pdfReaderView.setAnnotationType(touchMode, focusedType)
|
|
|
result.success(true)
|
|
|
}
|
|
@@ -193,7 +190,7 @@ object PluginUtils {
|
|
|
result.success(pdfReaderView.pdfReaderView.readBackgroundColor)
|
|
|
}
|
|
|
FUNCTION_SET_READER_VIEW_BACKGROUND_COLOR -> {
|
|
|
- configuration.getLong(KEY_READ_BACKGROUND_COLOR)?.let {
|
|
|
+ configuration.getLong(EVENT_READ_BACKGROUND_COLOR)?.let {
|
|
|
pdfReaderView.pdfReaderView.readBackgroundColor = it.toInt()
|
|
|
result.success(pdfReaderView.pdfReaderView.readBackgroundColor)
|
|
|
}
|