|
@@ -28,6 +28,7 @@ import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
|
import com.compdfkit.core.annotation.form.CPDFSignatureWidget;
|
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
|
import com.compdfkit.core.edit.CPDFEditManager;
|
|
|
+import com.compdfkit.core.edit.CPDFEditPage;
|
|
|
import com.compdfkit.pdfviewer.databinding.PdfSampleActivityBinding;
|
|
|
import com.compdfkit.tools.common.basic.activity.CBasicPDFActivity;
|
|
|
import com.compdfkit.tools.common.contextmenu.CPDFContextMenuHelper;
|
|
@@ -50,7 +51,7 @@ 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.pdfview.CPDFViewCtrl;
|
|
|
import com.compdfkit.tools.common.views.pdfview.CPreviewMode;
|
|
|
-import com.compdfkit.tools.contenteditor.CPDFEditPage;
|
|
|
+import com.compdfkit.tools.forms.pdfproperties.pdfsign.CustomSignatureWidgetImpl;
|
|
|
import com.compdfkit.tools.forms.pdfproperties.pdfsign.SignatureWidgetImpl;
|
|
|
import com.compdfkit.tools.security.encryption.CDocumentEncryptionDialog;
|
|
|
import com.compdfkit.tools.security.encryption.CInputOwnerPwdDialog;
|
|
@@ -67,6 +68,7 @@ import com.compdfkit.ui.reader.CPDFPageView;
|
|
|
import com.compdfkit.ui.reader.CPDFReaderView;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
public class MainActivity extends CBasicPDFActivity {
|
|
@@ -86,6 +88,8 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
|
|
|
CSampleScreenManager screenManager = new CSampleScreenManager();
|
|
|
|
|
|
+ private CPDFConfiguration cpdfConfiguration;
|
|
|
+
|
|
|
private ActivityResultLauncher<Void> selectDocumentLauncher = registerForActivityResult(new CSelectPDFDocumentResultContract(), uri -> {
|
|
|
if (uri != null) {
|
|
|
CPDFReaderView readerView = binding.pdfView.getCPdfReaderView();
|
|
@@ -115,6 +119,7 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
binding = PdfSampleActivityBinding.inflate(getLayoutInflater());
|
|
|
setContentView(binding.getRoot());
|
|
|
screenManager.bind(binding);
|
|
|
+ parseConfiguration();
|
|
|
//Extract PDF files from the Android assets folder
|
|
|
initPDFView();
|
|
|
initToolBarView();
|
|
@@ -123,11 +128,10 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
initFormToolbar();
|
|
|
initEditBar();
|
|
|
initSignatureToolbar();
|
|
|
- parseConfiguration();
|
|
|
onDoNext();
|
|
|
}
|
|
|
|
|
|
- private void initDocument(){
|
|
|
+ private void initDocument() {
|
|
|
String password = getIntent().getStringExtra(EXTRA_FILE_PASSWORD);
|
|
|
if (!TextUtils.isEmpty(getIntent().getStringExtra(EXTRA_FILE_PATH))) {
|
|
|
String path = getIntent().getStringExtra(EXTRA_FILE_PATH);
|
|
@@ -137,7 +141,7 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
CFileUtils.takeUriPermission(this, getIntent().getData());
|
|
|
binding.pdfView.openPDF(getIntent().getData(), password);
|
|
|
binding.editToolBar.setEditMode(false);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
CExtractAssetFileTask.extract(this, QUICK_START_GUIDE, QUICK_START_GUIDE, (filePath) -> {
|
|
|
binding.pdfView.openPDF(filePath);
|
|
|
binding.editToolBar.setEditMode(false);
|
|
@@ -148,9 +152,7 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
|
|
|
private void initPDFView() {
|
|
|
initDocument();
|
|
|
-
|
|
|
binding.pdfView.getCPdfReaderView().setMinScaleEnable(false);
|
|
|
- resetContextMenu(binding.pdfView, CPreviewMode.Viewer);
|
|
|
initAnnotationAttr(binding.pdfView);
|
|
|
initFormAttr(binding.pdfView);
|
|
|
registerAnnotHelper(binding.pdfView);
|
|
@@ -210,6 +212,13 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
requestStoragePermissions();
|
|
|
}
|
|
|
} else {
|
|
|
+ if (mode == CPreviewMode.Signature){
|
|
|
+ binding.pdfView.getCPdfReaderView().getAnnotImplRegistry()
|
|
|
+ .registImpl(CPDFSignatureWidget.class, SignatureWidgetImpl.class);
|
|
|
+ }else {
|
|
|
+ binding.pdfView.getCPdfReaderView().getAnnotImplRegistry()
|
|
|
+ .registImpl(CPDFSignatureWidget.class, CustomSignatureWidgetImpl.class);
|
|
|
+ }
|
|
|
|
|
|
if (editManager != null && editManager.isEditMode()) {
|
|
|
editManager.endEdit();
|
|
@@ -237,120 +246,67 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
binding.pdfToolBar.addMode(CPreviewMode.Form);
|
|
|
binding.pdfToolBar.addMode(CPreviewMode.Signature);
|
|
|
binding.pdfToolBar.setPreviewModeChangeListener(this::setPreviewMode);
|
|
|
- binding.pdfToolBar.setSearchBtnClickListener(v -> {
|
|
|
- if (binding.pdfView.getCPdfReaderView().getEditManager().isEditMode()) {
|
|
|
- curEditMode = binding.pdfView.getCPdfReaderView().getLoadType();
|
|
|
- } else {
|
|
|
- curEditMode = CPDFEditPage.LoadUnknown;
|
|
|
- }
|
|
|
- binding.pdfView.exitEditMode();
|
|
|
- binding.pdfToolBar.setVisibility(View.GONE);
|
|
|
- binding.pdfSearchToolBar.setVisibility(View.VISIBLE);
|
|
|
- binding.pdfSearchToolBar.showKeyboard();
|
|
|
- });
|
|
|
- binding.pdfToolBar.setThumbnailBtnClickListener(v -> {
|
|
|
- showPageEdit(binding.pdfView, false, () -> {
|
|
|
- if (curEditMode > 0 && binding.pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
|
- CPDFEditManager editManager = binding.pdfView.getCPdfReaderView().getEditManager();
|
|
|
- if (!editManager.isEditMode()) {
|
|
|
- editManager.beginEdit(curEditMode);
|
|
|
- }
|
|
|
+ if (cpdfConfiguration != null) {
|
|
|
+ CPDFConfiguration.ToolbarConfig toolbarConfig = cpdfConfiguration.toolbarConfig;
|
|
|
+ for (CPDFConfiguration.ToolbarConfig.ToolbarAction androidAvailableAction : toolbarConfig.androidAvailableActions) {
|
|
|
+ switch (androidAvailableAction) {
|
|
|
+ case Thumbnail:
|
|
|
+ binding.pdfToolBar.addAction(R.drawable.tools_ic_thumbnail, v -> {
|
|
|
+ showPageEdit(binding.pdfView, false, () -> {
|
|
|
+ if (curEditMode > CPDFEditPage.LoadNone && binding.pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
|
+ CPDFEditManager editManager = binding.pdfView.getCPdfReaderView().getEditManager();
|
|
|
+ if (!editManager.isEditMode()) {
|
|
|
+ editManager.beginEdit(curEditMode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case Search:
|
|
|
+ binding.pdfToolBar.addAction(R.drawable.tools_ic_search, v -> {
|
|
|
+ if (binding.pdfView.getCPdfReaderView().getEditManager().isEditMode()) {
|
|
|
+ curEditMode = binding.pdfView.getCPdfReaderView().getLoadType();
|
|
|
+ } else {
|
|
|
+ curEditMode = CPDFEditPage.LoadNone;
|
|
|
+ }
|
|
|
+ binding.pdfView.exitEditMode();
|
|
|
+ binding.pdfToolBar.setVisibility(View.GONE);
|
|
|
+ binding.pdfSearchToolBar.setVisibility(View.VISIBLE);
|
|
|
+ binding.pdfSearchToolBar.showKeyboard();
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case Bota:
|
|
|
+ binding.pdfToolBar.addAction(R.drawable.tools_ic_bookmark, v -> {
|
|
|
+ binding.pdfView.getCPdfReaderView().removeAllAnnotFocus();
|
|
|
+ binding.pdfView.exitEditMode();
|
|
|
+ ArrayList<CPDFBotaFragmentTabs> tabs = new ArrayList<>();
|
|
|
+ CPDFBotaFragmentTabs annotationTab = new CPDFBotaFragmentTabs(CPDFBOTA.ANNOTATION, getString(R.string.tools_annotations));
|
|
|
+ CPDFBotaFragmentTabs outlineTab = new CPDFBotaFragmentTabs(CPDFBOTA.OUTLINE, getString(R.string.tools_outlines));
|
|
|
+ CPDFBotaFragmentTabs bookmarkTab = new CPDFBotaFragmentTabs(CPDFBOTA.BOOKMARKS, getString(R.string.tools_bookmarks));
|
|
|
+ if (binding.pdfToolBar.getMode() == CPreviewMode.Viewer) {
|
|
|
+ tabs.add(outlineTab);
|
|
|
+ tabs.add(bookmarkTab);
|
|
|
+ } else {
|
|
|
+ tabs.add(outlineTab);
|
|
|
+ tabs.add(bookmarkTab);
|
|
|
+ tabs.add(annotationTab);
|
|
|
+ }
|
|
|
+ CPDFBotaDialogFragment dialogFragment = CPDFBotaDialogFragment.newInstance();
|
|
|
+ dialogFragment.initWithPDFView(binding.pdfView);
|
|
|
+ dialogFragment.setBotaDialogTabs(tabs);
|
|
|
+ dialogFragment.show(getSupportFragmentManager(), "annotationList");
|
|
|
+ });
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Menu:
|
|
|
+ binding.pdfToolBar.addAction(R.drawable.tools_ic_more, v -> {
|
|
|
+ showToolbarMenuDialog(v);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:break;
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- binding.pdfToolBar.setBoTaBtnClickListener(v -> {
|
|
|
- binding.pdfView.getCPdfReaderView().removeAllAnnotFocus();
|
|
|
- binding.pdfView.exitEditMode();
|
|
|
- ArrayList<CPDFBotaFragmentTabs> tabs = new ArrayList<>();
|
|
|
- CPDFBotaFragmentTabs annotationTab = new CPDFBotaFragmentTabs(CPDFBOTA.ANNOTATION, getString(R.string.tools_annotations));
|
|
|
- CPDFBotaFragmentTabs outlineTab = new CPDFBotaFragmentTabs(CPDFBOTA.OUTLINE, getString(R.string.tools_outlines));
|
|
|
- CPDFBotaFragmentTabs bookmarkTab = new CPDFBotaFragmentTabs(CPDFBOTA.BOOKMARKS, getString(R.string.tools_bookmarks));
|
|
|
- if (binding.pdfToolBar.getMode() == CPreviewMode.Viewer) {
|
|
|
- tabs.add(outlineTab);
|
|
|
- tabs.add(bookmarkTab);
|
|
|
- } else {
|
|
|
- tabs.add(outlineTab);
|
|
|
- tabs.add(bookmarkTab);
|
|
|
- tabs.add(annotationTab);
|
|
|
}
|
|
|
- CPDFBotaDialogFragment dialogFragment = CPDFBotaDialogFragment.newInstance();
|
|
|
- dialogFragment.initWithPDFView(binding.pdfView);
|
|
|
- dialogFragment.setBotaDialogTabs(tabs);
|
|
|
- dialogFragment.show(getSupportFragmentManager(), "annotationList");
|
|
|
- });
|
|
|
- binding.pdfToolBar.setMoreBtnClickListener(v -> {
|
|
|
- v.setSelected(true);
|
|
|
- //Show the PDF settings dialog fragment
|
|
|
- CPopupMenuWindow menuWindow = new CPopupMenuWindow(this);
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_preview_settings, R.string.tools_view_setting, v1 -> {
|
|
|
- showDisplaySettings(binding.pdfView);
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_page_edit, R.string.tools_page_edit_toolbar_title, v1 -> {
|
|
|
- showPageEdit(binding.pdfView, true, () -> {
|
|
|
- if (curEditMode > 0 && binding.pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
|
- CPDFEditManager editManager = binding.pdfView.getCPdfReaderView().getEditManager();
|
|
|
- if (!editManager.isEditMode()) {
|
|
|
- editManager.beginEdit(curEditMode);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_add_security, R.string.tools_security, v1 -> {
|
|
|
- CPDFDocument document = binding.pdfView.getCPdfReaderView().getPDFDocument();
|
|
|
- if (document == null){
|
|
|
- return;
|
|
|
- }
|
|
|
- if (document.getPermissions() == CPDFDocument.PDFDocumentPermissions.PDFDocumentPermissionsUser) {
|
|
|
- CInputOwnerPwdDialog inputOwnerPwdDialog = CInputOwnerPwdDialog.newInstance();
|
|
|
- inputOwnerPwdDialog.setDocument(document);
|
|
|
- inputOwnerPwdDialog.setCancelClickListener(v2->{
|
|
|
- inputOwnerPwdDialog.dismiss();
|
|
|
- });
|
|
|
- inputOwnerPwdDialog.setConfirmClickListener(ownerPassword -> {
|
|
|
- document.reload(ownerPassword);
|
|
|
- showSettingEncryptionDialog();
|
|
|
- inputOwnerPwdDialog.dismiss();
|
|
|
- });
|
|
|
- inputOwnerPwdDialog.show(getSupportFragmentManager(), "inputPasswordDialog");
|
|
|
- return;
|
|
|
- }
|
|
|
- showSettingEncryptionDialog();
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_add_watermark, R.string.tools_watermark, v1 -> {
|
|
|
- CWatermarkEditDialog watermarkEditDialog = CWatermarkEditDialog.newInstance();
|
|
|
- watermarkEditDialog.setDocument(binding.pdfView.getCPdfReaderView().getPDFDocument());
|
|
|
- watermarkEditDialog.setPageIndex(binding.pdfView.currentPageIndex);
|
|
|
- watermarkEditDialog.setCompleteListener((pdfFile)->{
|
|
|
- binding.pdfView.openPDF(pdfFile);
|
|
|
- watermarkEditDialog.dismiss();
|
|
|
- CToastUtil.showLongToast(this, R.string.tools_watermark_add_success);
|
|
|
- });
|
|
|
- watermarkEditDialog.show(getSupportFragmentManager(), "watermarkEditDialog");
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_document_info, R.string.tools_document_info, v1 -> {
|
|
|
- showDocumentInfo(binding.pdfView);
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_menu_save,R.string.tools_save, v1 -> {
|
|
|
- binding.pdfView.savePDF((filePath, pdfUri) -> {
|
|
|
- CToastUtil.showLongToast(this, R.string.tools_save_success);
|
|
|
- },e -> {
|
|
|
-
|
|
|
- });
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_share, R.string.tools_share, v1 -> {
|
|
|
- binding.editToolBar.resetStatus();
|
|
|
- sharePDF(binding.pdfView);
|
|
|
- });
|
|
|
- menuWindow.addItem(R.drawable.tools_ic_new_file, R.string.tools_open_document, v1 -> {
|
|
|
- if (CPermissionUtil.hasStoragePermissions(this)) {
|
|
|
- selectDocument();
|
|
|
- } else {
|
|
|
- requestStoragePermissions();
|
|
|
- }
|
|
|
- });
|
|
|
- menuWindow.setOnDismissListener(() -> v.setSelected(false));
|
|
|
- menuWindow.showAsDropDown(v);
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void requestStoragePermissions() {
|
|
@@ -410,7 +366,7 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
});
|
|
|
});
|
|
|
binding.pdfSearchToolBar.setExitSearchListener(() -> {
|
|
|
- if (curEditMode > 0) {
|
|
|
+ if (curEditMode > CPDFEditPage.LoadNone) {
|
|
|
CPDFEditManager editManager = binding.pdfView.getCPdfReaderView().getEditManager();
|
|
|
if (!editManager.isEditMode()) {
|
|
|
editManager.beginEdit(curEditMode);
|
|
@@ -468,26 +424,29 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void parseConfiguration(){
|
|
|
- Configuration configuration;
|
|
|
- if (!getIntent().hasExtra(EXTRA_CONFIGURATION)) {
|
|
|
- setPreviewMode(CPreviewMode.Viewer);
|
|
|
- return;
|
|
|
+ private void parseConfiguration() {
|
|
|
+ if (getIntent().hasExtra(EXTRA_CONFIGURATION)) {
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
|
+ cpdfConfiguration = getIntent().getSerializableExtra(EXTRA_CONFIGURATION, CPDFConfiguration.class);
|
|
|
+ } else {
|
|
|
+ cpdfConfiguration = (CPDFConfiguration) getIntent().getSerializableExtra(EXTRA_CONFIGURATION);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ cpdfConfiguration = CPDFConfigurationUtils.normalConfig();
|
|
|
}
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
|
- configuration = getIntent().getSerializableExtra(EXTRA_CONFIGURATION, Configuration.class);
|
|
|
- }else {
|
|
|
- configuration = (Configuration) getIntent().getSerializableExtra(EXTRA_CONFIGURATION);
|
|
|
+ if (cpdfConfiguration.readerViewConfig != null) {
|
|
|
+ CPDFConfiguration.ReaderViewConfig readerViewConfig = cpdfConfiguration.readerViewConfig;
|
|
|
+ binding.pdfView.getCPdfReaderView().setLinkHighlight(readerViewConfig.linkHighlight);
|
|
|
+ binding.pdfView.getCPdfReaderView().setFormFieldHighlight(readerViewConfig.formFieldHighlight);
|
|
|
}
|
|
|
- if (configuration != null) {
|
|
|
- binding.pdfView.getCPdfReaderView().setLinkHighlight(configuration.isHighlightLink());
|
|
|
- binding.pdfView.getCPdfReaderView().setFormFieldHighlight(configuration.isHighlightForm());
|
|
|
- if (configuration.getMode() != CPreviewMode.PageEdit){
|
|
|
- setPreviewMode(configuration.getMode());
|
|
|
- }else {
|
|
|
+ if (cpdfConfiguration.modeConfig != null) {
|
|
|
+ CPDFConfiguration.ModeConfig modeConfig = cpdfConfiguration.modeConfig;
|
|
|
+ if (modeConfig.initialViewMode != CPreviewMode.PageEdit) {
|
|
|
+ setPreviewMode(modeConfig.initialViewMode);
|
|
|
+ } else {
|
|
|
setPreviewMode(CPreviewMode.Viewer);
|
|
|
showPageEdit(binding.pdfView, true, () -> {
|
|
|
- if (curEditMode > 0 && binding.pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
|
+ if (curEditMode > CPDFEditPage.LoadNone && binding.pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
|
CPDFEditManager editManager = binding.pdfView.getCPdfReaderView().getEditManager();
|
|
|
if (!editManager.isEditMode()) {
|
|
|
editManager.beginEdit(curEditMode);
|
|
@@ -498,6 +457,107 @@ public class MainActivity extends CBasicPDFActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void showToolbarMenuDialog(View anchorView) {
|
|
|
+ //Show the PDF settings dialog fragment
|
|
|
+ CPopupMenuWindow menuWindow = new CPopupMenuWindow(this);
|
|
|
+ if (cpdfConfiguration != null && cpdfConfiguration.toolbarConfig != null) {
|
|
|
+ List<CPDFConfiguration.ToolbarConfig.MenuAction> menuActions = cpdfConfiguration.toolbarConfig.availableMenus;
|
|
|
+ if (menuActions == null || menuActions.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ anchorView.setSelected(true);
|
|
|
+ for (CPDFConfiguration.ToolbarConfig.MenuAction menuAction : menuActions) {
|
|
|
+ switch (menuAction) {
|
|
|
+ case ViewSettings:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_preview_settings, R.string.tools_view_setting, v1 -> {
|
|
|
+ showDisplaySettings(binding.pdfView);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case DocumentEditor:
|
|
|
+ menuWindow.addItem(R.drawable.tools_page_edit, R.string.tools_page_edit_toolbar_title, v1 -> {
|
|
|
+ showPageEdit(binding.pdfView, true, () -> {
|
|
|
+ if (curEditMode > CPDFEditPage.LoadNone && binding.pdfToolBar.getMode() == CPreviewMode.Edit) {
|
|
|
+ CPDFEditManager editManager = binding.pdfView.getCPdfReaderView().getEditManager();
|
|
|
+ if (!editManager.isEditMode()) {
|
|
|
+ editManager.beginEdit(curEditMode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case Security:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_add_security, R.string.tools_security, v1 -> {
|
|
|
+ CPDFDocument document = binding.pdfView.getCPdfReaderView().getPDFDocument();
|
|
|
+ if (document == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (document.getPermissions() == CPDFDocument.PDFDocumentPermissions.PDFDocumentPermissionsUser) {
|
|
|
+ CInputOwnerPwdDialog inputOwnerPwdDialog = CInputOwnerPwdDialog.newInstance();
|
|
|
+ inputOwnerPwdDialog.setDocument(document);
|
|
|
+ inputOwnerPwdDialog.setCancelClickListener(v2 -> {
|
|
|
+ inputOwnerPwdDialog.dismiss();
|
|
|
+ });
|
|
|
+ inputOwnerPwdDialog.setConfirmClickListener(ownerPassword -> {
|
|
|
+ document.reload(ownerPassword);
|
|
|
+ showSettingEncryptionDialog();
|
|
|
+ inputOwnerPwdDialog.dismiss();
|
|
|
+ });
|
|
|
+ inputOwnerPwdDialog.show(getSupportFragmentManager(), "inputPasswordDialog");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ showSettingEncryptionDialog();
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case Watermark:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_add_watermark, R.string.tools_watermark, v1 -> {
|
|
|
+ CWatermarkEditDialog watermarkEditDialog = CWatermarkEditDialog.newInstance();
|
|
|
+ watermarkEditDialog.setDocument(binding.pdfView.getCPdfReaderView().getPDFDocument());
|
|
|
+ watermarkEditDialog.setPageIndex(binding.pdfView.currentPageIndex);
|
|
|
+ watermarkEditDialog.setCompleteListener((pdfFile) -> {
|
|
|
+ binding.pdfView.openPDF(pdfFile);
|
|
|
+ watermarkEditDialog.dismiss();
|
|
|
+ CToastUtil.showLongToast(this, R.string.tools_watermark_add_success);
|
|
|
+ });
|
|
|
+ watermarkEditDialog.show(getSupportFragmentManager(), "watermarkEditDialog");
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case DocumentInfo:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_document_info, R.string.tools_document_info, v1 -> {
|
|
|
+ showDocumentInfo(binding.pdfView);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case Save:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_menu_save, R.string.tools_save, v1 -> {
|
|
|
+ binding.pdfView.savePDF((filePath, pdfUri) -> {
|
|
|
+ CToastUtil.showLongToast(this, R.string.tools_save_success);
|
|
|
+ }, e -> {
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case Share:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_share, R.string.tools_share, v1 -> {
|
|
|
+ binding.editToolBar.resetStatus();
|
|
|
+ sharePDF(binding.pdfView);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case OpenDocument:
|
|
|
+ menuWindow.addItem(R.drawable.tools_ic_new_file, R.string.tools_open_document, v1 -> {
|
|
|
+ if (CPermissionUtil.hasStoragePermissions(this)) {
|
|
|
+ selectDocument();
|
|
|
+ } else {
|
|
|
+ requestStoragePermissions();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ menuWindow.setOnDismissListener(() -> anchorView.setSelected(false));
|
|
|
+ menuWindow.showAsDropDown(anchorView);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|