|
@@ -40,6 +40,7 @@ import androidx.core.content.ContextCompat;
|
|
import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFFreetextAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFFreetextAnnotation;
|
|
import com.compdfkit.core.annotation.form.CPDFSignatureWidget;
|
|
import com.compdfkit.core.annotation.form.CPDFSignatureWidget;
|
|
|
|
+import com.compdfkit.core.document.CPDFBackground;
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
import com.compdfkit.core.edit.CPDFEditConfig;
|
|
import com.compdfkit.core.edit.CPDFEditConfig;
|
|
import com.compdfkit.core.edit.CPDFEditManager;
|
|
import com.compdfkit.core.edit.CPDFEditManager;
|
|
@@ -72,6 +73,7 @@ import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CAnnotStyle;
|
|
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleDialogFragment;
|
|
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleDialogFragment;
|
|
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleType;
|
|
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleType;
|
|
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.manager.CStyleManager;
|
|
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.manager.CStyleManager;
|
|
|
|
+import com.compdfkit.tools.common.views.pdfview.CPDFIReaderViewCallback;
|
|
import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
|
|
import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
|
|
import com.compdfkit.tools.common.views.pdfview.CPreviewMode;
|
|
import com.compdfkit.tools.common.views.pdfview.CPreviewMode;
|
|
import com.compdfkit.tools.contenteditor.CEditToolbar;
|
|
import com.compdfkit.tools.contenteditor.CEditToolbar;
|
|
@@ -141,6 +143,8 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
|
|
|
|
private CPopupMenuWindow menuWindow;
|
|
private CPopupMenuWindow menuWindow;
|
|
|
|
|
|
|
|
+ private CPDFDocumentFragmentInitListener initListener;
|
|
|
|
+
|
|
public static CPDFDocumentFragment newInstance(String filePath, String password, CPDFConfiguration configuration) {
|
|
public static CPDFDocumentFragment newInstance(String filePath, String password, CPDFConfiguration configuration) {
|
|
Bundle args = new Bundle();
|
|
Bundle args = new Bundle();
|
|
args.putString(EXTRA_FILE_PATH, filePath);
|
|
args.putString(EXTRA_FILE_PATH, filePath);
|
|
@@ -243,10 +247,13 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
initSignatureToolbar();
|
|
initSignatureToolbar();
|
|
applyConfiguration();
|
|
applyConfiguration();
|
|
onDoNext();
|
|
onDoNext();
|
|
|
|
+ if (initListener != null) {
|
|
|
|
+ initListener.compile(pdfView);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void initDocument(CPDFViewCtrl.COnOpenPdfFinishCallback callback) {
|
|
|
|
|
|
+ protected void initDocument(CPDFViewCtrl.COnOpenPdfFinishCallback callback) {
|
|
if (getArguments() != null) {
|
|
if (getArguments() != null) {
|
|
String password = getArguments().getString(EXTRA_FILE_PASSWORD);
|
|
String password = getArguments().getString(EXTRA_FILE_PASSWORD);
|
|
if (!TextUtils.isEmpty(getArguments().getString(EXTRA_FILE_PATH))) {
|
|
if (!TextUtils.isEmpty(getArguments().getString(EXTRA_FILE_PATH))) {
|
|
@@ -262,7 +269,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void initPDFView() {
|
|
|
|
|
|
+ protected void initPDFView() {
|
|
pdfView.setCPDFConfiguration(cpdfConfiguration);
|
|
pdfView.setCPDFConfiguration(cpdfConfiguration);
|
|
pdfView.getCPdfReaderView().setMinScaleEnable(false);
|
|
pdfView.getCPdfReaderView().setMinScaleEnable(false);
|
|
registerAnnotHelper(pdfView);
|
|
registerAnnotHelper(pdfView);
|
|
@@ -278,17 +285,27 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- pdfView.setOnTapMainDocAreaCallback(() -> {
|
|
|
|
- if (pdfSearchToolBarView.getVisibility() == VISIBLE) {
|
|
|
|
- pdfSearchToolBarView.showSearchReplaceContextMenu();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (pdfView.getCPdfReaderView().getTouchMode() == CPDFReaderView.TouchMode.SCREENSHOT){
|
|
|
|
- return;
|
|
|
|
|
|
+ pdfView.addReaderViewCallback(new CPDFIReaderViewCallback(){
|
|
|
|
+ @Override
|
|
|
|
+ public void onTapMainDocArea() {
|
|
|
|
+ if (pdfSearchToolBarView.getVisibility() == VISIBLE) {
|
|
|
|
+ pdfSearchToolBarView.showSearchReplaceContextMenu();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (pdfView.getCPdfReaderView().getTouchMode() == CPDFReaderView.TouchMode.SCREENSHOT){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!cpdfConfiguration.modeConfig.readerOnly){
|
|
|
|
+ //Use the CFillScreenManager.class to manage fullscreen switching.
|
|
|
|
+ screenManager.fillScreenChange();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (!cpdfConfiguration.modeConfig.readerOnly){
|
|
|
|
- //Use the CFillScreenManager.class to manage fullscreen switching.
|
|
|
|
- screenManager.fillScreenChange();
|
|
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onEndScroll() {
|
|
|
|
+ super.onEndScroll();
|
|
|
|
+ pdfSearchToolBarView.showSearchReplaceContextMenu();
|
|
|
|
+ editToolBar.updateUndoRedo();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
pdfView.getCPdfReaderView().setPdfAddAnnotCallback((cpdfPageView, cpdfBaseAnnot) -> {
|
|
pdfView.getCPdfReaderView().setPdfAddAnnotCallback((cpdfPageView, cpdfBaseAnnot) -> {
|
|
@@ -363,7 +380,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void initToolBarView() {
|
|
|
|
|
|
+ protected void initToolBarView() {
|
|
pdfToolBar.setPreviewModeChangeListener(this::setPreviewMode);
|
|
pdfToolBar.setPreviewModeChangeListener(this::setPreviewMode);
|
|
if (cpdfConfiguration != null) {
|
|
if (cpdfConfiguration != null) {
|
|
ToolbarConfig toolbarConfig = cpdfConfiguration.toolbarConfig;
|
|
ToolbarConfig toolbarConfig = cpdfConfiguration.toolbarConfig;
|
|
@@ -440,7 +457,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void requestStoragePermissions(CRequestPermissionListener permissionListener) {
|
|
|
|
|
|
+ protected void requestStoragePermissions(CRequestPermissionListener permissionListener) {
|
|
if (Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_TIRAMISU) {
|
|
if (Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_TIRAMISU) {
|
|
CPermissionUtil.openManageAllFileAppSettings(getContext());
|
|
CPermissionUtil.openManageAllFileAppSettings(getContext());
|
|
} else {
|
|
} else {
|
|
@@ -458,7 +475,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void initAnnotToolbar() {
|
|
|
|
|
|
+ protected void initAnnotToolbar() {
|
|
annotationToolbar.initWithPDFView(pdfView);
|
|
annotationToolbar.initWithPDFView(pdfView);
|
|
annotationToolbar.setFragmentManager(getChildFragmentManager());
|
|
annotationToolbar.setFragmentManager(getChildFragmentManager());
|
|
annotationToolbar.setAnnotationChangeListener(type -> {
|
|
annotationToolbar.setAnnotationChangeListener(type -> {
|
|
@@ -481,12 +498,12 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
inkCtrlView.setFragmentManager(getChildFragmentManager());
|
|
inkCtrlView.setFragmentManager(getChildFragmentManager());
|
|
}
|
|
}
|
|
|
|
|
|
- private void initFormToolbar() {
|
|
|
|
|
|
+ protected void initFormToolbar() {
|
|
formToolBar.initWithPDFView(pdfView);
|
|
formToolBar.initWithPDFView(pdfView);
|
|
formToolBar.setFragmentManager(getChildFragmentManager());
|
|
formToolBar.setFragmentManager(getChildFragmentManager());
|
|
}
|
|
}
|
|
|
|
|
|
- private void initSearchBar() {
|
|
|
|
|
|
+ protected void initSearchBar() {
|
|
pdfSearchToolBarView.initWithPDFView(pdfView);
|
|
pdfSearchToolBarView.initWithPDFView(pdfView);
|
|
pdfSearchToolBarView.setExitSearchListener(() -> {
|
|
pdfSearchToolBarView.setExitSearchListener(() -> {
|
|
if (curEditMode > CPDFEditPage.LoadNone) {
|
|
if (curEditMode > CPDFEditPage.LoadNone) {
|
|
@@ -506,7 +523,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void initEditBar() {
|
|
|
|
|
|
+ protected void initEditBar() {
|
|
if (pdfView == null || pdfView.getCPdfReaderView() == null) {
|
|
if (pdfView == null || pdfView.getCPdfReaderView() == null) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -545,13 +562,9 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
menuHelper.dismissContextMenu();
|
|
menuHelper.dismissContextMenu();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- pdfView.setEndScrollCallback(() -> {
|
|
|
|
- pdfSearchToolBarView.showSearchReplaceContextMenu();
|
|
|
|
- editToolBar.updateUndoRedo();
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void initSignatureToolbar() {
|
|
|
|
|
|
+ protected void initSignatureToolbar() {
|
|
signStatusView.initWithPDFView(pdfView);
|
|
signStatusView.initWithPDFView(pdfView);
|
|
signStatusView.getBtnDetails().setOnClickListener(v -> {
|
|
signStatusView.getBtnDetails().setOnClickListener(v -> {
|
|
CPDFCertDigitalSignListDialog signListDialog = CPDFCertDigitalSignListDialog.newInstance();
|
|
CPDFCertDigitalSignListDialog signListDialog = CPDFCertDigitalSignListDialog.newInstance();
|
|
@@ -563,7 +576,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
signatureToolBar.getVerifySignButton().setOnClickListener(v -> verifyDocumentSignStatus());
|
|
signatureToolBar.getVerifySignButton().setOnClickListener(v -> verifyDocumentSignStatus());
|
|
}
|
|
}
|
|
|
|
|
|
- private void showToolbarMenuDialog(View anchorView) {
|
|
|
|
|
|
+ protected void showToolbarMenuDialog(View anchorView) {
|
|
//Show the PDF settings dialog fragment
|
|
//Show the PDF settings dialog fragment
|
|
menuWindow = new CPopupMenuWindow(getContext());
|
|
menuWindow = new CPopupMenuWindow(getContext());
|
|
if (cpdfConfiguration != null && cpdfConfiguration.toolbarConfig != null) {
|
|
if (cpdfConfiguration != null && cpdfConfiguration.toolbarConfig != null) {
|
|
@@ -692,7 +705,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
menuWindow.showAsDropDown(anchorView);
|
|
menuWindow.showAsDropDown(anchorView);
|
|
}
|
|
}
|
|
|
|
|
|
- private void flattenedPdf() {
|
|
|
|
|
|
+ protected void flattenedPdf() {
|
|
CFileDirectoryDialog directoryDialog = CFileDirectoryDialog.newInstance(
|
|
CFileDirectoryDialog directoryDialog = CFileDirectoryDialog.newInstance(
|
|
Environment.getExternalStorageDirectory().getAbsolutePath(),
|
|
Environment.getExternalStorageDirectory().getAbsolutePath(),
|
|
getContext().getString(R.string.tools_select_folder),
|
|
getContext().getString(R.string.tools_select_folder),
|
|
@@ -738,7 +751,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- private void verifyDocumentSignStatus() {
|
|
|
|
|
|
+ protected void verifyDocumentSignStatus() {
|
|
CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
|
|
CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
|
|
if (CertificateDigitalDatas.hasDigitalSignature(document)) {
|
|
if (CertificateDigitalDatas.hasDigitalSignature(document)) {
|
|
CThreadPoolUtils.getInstance().executeIO(() -> {
|
|
CThreadPoolUtils.getInstance().executeIO(() -> {
|
|
@@ -759,7 +772,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void selectDocument() {
|
|
|
|
|
|
+ protected void selectDocument() {
|
|
if (pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
if (pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
pdfView.exitEditMode();
|
|
pdfView.exitEditMode();
|
|
}
|
|
}
|
|
@@ -790,13 +803,13 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
alertDialog.show(getChildFragmentManager(), "alertDialog");
|
|
alertDialog.show(getChildFragmentManager(), "alertDialog");
|
|
}
|
|
}
|
|
|
|
|
|
- private void onDoNext() {
|
|
|
|
|
|
+ protected void onDoNext() {
|
|
multiplePermissionResultLauncher.launch(STORAGE_PERMISSIONS, result -> {
|
|
multiplePermissionResultLauncher.launch(STORAGE_PERMISSIONS, result -> {
|
|
|
|
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void showSettingEncryptionDialog() {
|
|
|
|
|
|
+ protected void showSettingEncryptionDialog() {
|
|
CDocumentEncryptionDialog documentEncryptionDialog = CDocumentEncryptionDialog.newInstance();
|
|
CDocumentEncryptionDialog documentEncryptionDialog = CDocumentEncryptionDialog.newInstance();
|
|
documentEncryptionDialog.setDocument(pdfView.getCPdfReaderView().getPDFDocument());
|
|
documentEncryptionDialog.setDocument(pdfView.getCPdfReaderView().getPDFDocument());
|
|
documentEncryptionDialog.setSaveFileExtraFontSubset(pdfView.isSaveFileExtraFontSubset());
|
|
documentEncryptionDialog.setSaveFileExtraFontSubset(pdfView.isSaveFileExtraFontSubset());
|
|
@@ -823,7 +836,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
.registImpl(CPDFSignatureWidget.class, SignatureWidgetImpl.class);
|
|
.registImpl(CPDFSignatureWidget.class, SignatureWidgetImpl.class);
|
|
}
|
|
}
|
|
|
|
|
|
- private void parseConfiguration() {
|
|
|
|
|
|
+ protected void parseConfiguration() {
|
|
if (getArguments() != null && getArguments().containsKey(EXTRA_CONFIGURATION)) {
|
|
if (getArguments() != null && getArguments().containsKey(EXTRA_CONFIGURATION)) {
|
|
if (Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_TIRAMISU) {
|
|
if (Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_TIRAMISU) {
|
|
cpdfConfiguration = getArguments().getSerializable(EXTRA_CONFIGURATION, CPDFConfiguration.class);
|
|
cpdfConfiguration = getArguments().getSerializable(EXTRA_CONFIGURATION, CPDFConfiguration.class);
|
|
@@ -836,7 +849,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void applyConfiguration() {
|
|
|
|
|
|
+ protected void applyConfiguration() {
|
|
CPDFApplyConfigUtil.getInstance().applyConfiguration(this, cpdfConfiguration);
|
|
CPDFApplyConfigUtil.getInstance().applyConfiguration(this, cpdfConfiguration);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -872,4 +885,12 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
|
|
}
|
|
}
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void setInitListener(CPDFDocumentFragmentInitListener initListener) {
|
|
|
|
+ this.initListener = initListener;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public interface CPDFDocumentFragmentInitListener{
|
|
|
|
+ void compile(CPDFViewCtrl pdfView);
|
|
|
|
+ }
|
|
}
|
|
}
|