浏览代码

PDFTool(Android) - 优化存储权限使用,移除MANAGE权限使用

liuxiaolong 9 月之前
父节点
当前提交
b52ed0893d

+ 2 - 0
ComPDFKit_Tools/src/main/assets/tools_default_configuration.json

@@ -30,6 +30,8 @@
       "documentEditor",
       "documentInfo",
       "save",
+      "watermark",
+      "security",
       "flattened",
       "share",
       "openDocument"

+ 13 - 27
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/basic/fragment/CBasicPDFFragment.java

@@ -10,11 +10,8 @@
 package com.compdfkit.tools.common.basic.fragment;
 
 
-import android.Manifest;
 import android.graphics.Color;
-import android.os.Build;
-import android.os.Environment;
-import android.text.TextUtils;
+import android.net.Uri;
 
 import androidx.core.content.ContextCompat;
 import androidx.fragment.app.FragmentActivity;
@@ -27,8 +24,6 @@ import com.compdfkit.core.annotation.form.CPDFComboboxWidget;
 import com.compdfkit.core.annotation.form.CPDFListboxWidget;
 import com.compdfkit.core.annotation.form.CPDFSignatureWidget;
 import com.compdfkit.core.annotation.form.CPDFWidget;
-import com.compdfkit.core.common.CPDFDocumentException;
-import com.compdfkit.core.document.CPDFDocument;
 import com.compdfkit.core.edit.CPDFEditPage;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.annotation.pdfproperties.pdflink.CLinkAnnotAttachHelper;
@@ -40,7 +35,6 @@ import com.compdfkit.tools.common.contextmenu.impl.CEditTextContextMenuView;
 import com.compdfkit.tools.common.contextmenu.impl.CSearchReplaceContextMenuView;
 import com.compdfkit.tools.common.contextmenu.impl.CSignatureContextMenuView;
 import com.compdfkit.tools.common.utils.CFileUtils;
-import com.compdfkit.tools.common.utils.CPermissionUtil;
 import com.compdfkit.tools.common.utils.dialog.CLoadingDialog;
 import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleType;
 import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.manager.CStyleManager;
@@ -60,6 +54,11 @@ public class CBasicPDFFragment extends CPermissionFragment {
 
     public int curEditMode = CPDFEditPage.LoadNone;
 
+    protected Uri documentUri;
+
+    protected String documentPath;
+
+
     protected void resetContextMenu(CPDFViewCtrl pdfView, CPreviewMode mode) {
         switch (mode) {
             case Viewer:
@@ -161,30 +160,17 @@ public class CBasicPDFFragment extends CPermissionFragment {
     }
 
     protected void sharePDF(CPDFViewCtrl pdfView) {
-        pdfView.exitEditMode();
-        CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
-        if (document == null) {
-            return;
-        }
-        boolean isExternalFile = !TextUtils.isEmpty(document.getAbsolutePath()) &&
-                document.getAbsolutePath().startsWith("/storage/emulated/0");
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && isExternalFile) {
-            if (CPermissionUtil.checkManifestPermission(getContext(), Manifest.permission.MANAGE_EXTERNAL_STORAGE) && !Environment.isExternalStorageManager()) {
-                CPermissionUtil.openManageAllFileAppSettings(getContext());
-                return;
-            }
-        }
         pdfView.savePDF((filePath, pdfUri) -> {
-            if (!TextUtils.isEmpty(filePath)) {
-                CFileUtils.shareFile(getContext(), getString(R.string.tools_share_to), "application/pdf", new File(filePath));
+            if (null != documentUri) {
+                CFileUtils.shareFile(getContext(), getString(R.string.tools_share_to), "application/pdf", documentUri);
             } else {
-                CFileUtils.shareFile(getContext(), getString(R.string.tools_share_to), "application/pdf", pdfUri);
+                CFileUtils.shareFile(getContext(), getString(R.string.tools_share_to), "application/pdf", new File(documentPath));
             }
         }, e -> {
-            if (e instanceof CPDFDocumentException) {
-                if (!document.isCanWrite() && document.hasRepaired()) {
-                    pdfView.showWritePermissionsDialog(document);
-                }
+            if (null != documentUri) {
+                CFileUtils.shareFile(getContext(), getString(R.string.tools_share_to), "application/pdf", documentUri);
+            } else {
+                CFileUtils.shareFile(getContext(), getString(R.string.tools_share_to), "application/pdf", new File(documentPath));
             }
         });
     }

+ 16 - 11
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFDocumentFragment.java

@@ -29,6 +29,7 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
+import android.widget.Toast;
 
 import androidx.activity.OnBackPressedCallback;
 import androidx.activity.result.ActivityResultLauncher;
@@ -44,6 +45,7 @@ import com.compdfkit.core.document.CPDFDocument;
 import com.compdfkit.core.edit.CPDFEditManager;
 import com.compdfkit.core.edit.CPDFEditPage;
 import com.compdfkit.core.page.CPDFPage;
+import com.compdfkit.tools.BuildConfig;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.annotation.pdfannotationbar.CAnnotationToolbar;
 import com.compdfkit.tools.annotation.pdfproperties.pdflnk.CInkCtrlView;
@@ -253,10 +255,12 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
             String password = getArguments().getString(EXTRA_FILE_PASSWORD);
             if (!TextUtils.isEmpty(getArguments().getString(EXTRA_FILE_PATH))) {
                 String path = getArguments().getString(EXTRA_FILE_PATH);
+                documentPath = path;
                 pdfView.openPDF(path, password, callback);
             } else if (getArguments().getParcelable(EXTRA_FILE_URI) != null) {
                 Uri uri = getArguments().getParcelable(EXTRA_FILE_URI);
                 CFileUtils.takeUriPermission(getContext(), uri);
+                documentUri = uri;
                 pdfView.openPDF(uri, password, callback);
             }
         }
@@ -326,9 +330,6 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
                 editManager.enable();
                 editManager.beginEdit(CPDFEditPage.LoadTextImage);
             }
-            if (!CPermissionUtil.hasStoragePermissions(getContext())) {
-                requestStoragePermissions(this::selectDocument);
-            }
         } else {
             if (editManager != null && editManager.isEditMode()) {
                 editManager.endEdit();
@@ -614,19 +615,23 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
                         break;
                     case OpenDocument:
                         menuWindow.addItem(R.drawable.tools_ic_new_file, R.string.tools_open_document, v1 -> {
-                            if (CPermissionUtil.hasStoragePermissions(getContext())) {
                                 selectDocument();
-                            } else {
-                                requestStoragePermissions(this::selectDocument);
-                            }
                         });
                         break;
                     case Flattened:
                         menuWindow.addItem(R.drawable.tools_ic_flattened, R.string.tools_flattened, v1 -> {
-                            if (CPermissionUtil.hasStoragePermissions(getContext())) {
+                            if (Build.VERSION.SDK_INT < CPermissionUtil.VERSION_R) {
+                                multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
+                                    if (CPermissionUtil.hasStoragePermissions(getContext())) {
+                                        pdfView.savePDF((filePath, pdfUri) -> flattenedPdf(), e -> flattenedPdf());
+                                    } else {
+                                        if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+                                            CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
+                                        }
+                                    }
+                                });
+                            }else {
                                 pdfView.savePDF((filePath, pdfUri) -> flattenedPdf(), e -> flattenedPdf());
-                            } else {
-                                requestStoragePermissions(() -> pdfView.savePDF((filePath, pdfUri) -> flattenedPdf(), e -> flattenedPdf()));
                             }
                         });
                         break;
@@ -726,7 +731,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
         }
         CAlertDialog alertDialog = CAlertDialog.newInstance(getString(R.string.tools_save_title), getString(R.string.tools_save_message));
         alertDialog.setConfirmClickListener(v -> {
-            //save pdf document
+            // save pdf document
             pdfView.savePDF((filePath, pdfUri) -> {
                 alertDialog.dismiss();
                 selectDocumentLauncher.launch(null);

+ 6 - 2
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfview/CPDFViewCtrl.java

@@ -35,6 +35,7 @@ import com.compdfkit.core.annotation.form.CPDFWidget;
 import com.compdfkit.core.common.CPDFDocumentException;
 import com.compdfkit.core.document.CPDFDocument;
 import com.compdfkit.core.edit.CPDFEditManager;
+import com.compdfkit.tools.BuildConfig;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.utils.CFileUtils;
 import com.compdfkit.tools.common.utils.CLog;
@@ -342,7 +343,7 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
     public void showWritePermissionsDialog(CPDFDocument document) {
         if (getContext() instanceof FragmentActivity) {
             Fragment rwPermissionDialog = ((FragmentActivity) getContext()).getSupportFragmentManager().findFragmentByTag("rwPermissionDialog");
-            if (rwPermissionDialog != null && rwPermissionDialog instanceof DialogFragment){
+            if (rwPermissionDialog != null && rwPermissionDialog instanceof DialogFragment) {
                 ((DialogFragment) rwPermissionDialog).dismiss();
             }
         }
@@ -397,6 +398,9 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
                     }
                 } catch (CPDFDocumentException e) {
                     e.printStackTrace();
+                    if (BuildConfig.DEBUG) {
+                        CToastUtil.showLongToast(getContext(), "保存异常");
+                    }
                     CLog.e("ComPDFKit", "save fail:" + e.getMessage());
                     if (error != null) {
                         error.error(e);
@@ -555,7 +559,7 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
         indicatorView.setAlpha(0F);
         addView(indicatorView);
         CPDFDocument document = cPdfReaderView.getPDFDocument();
-        if (document == null){
+        if (document == null) {
             return;
         }
         int totalPageCount = cPdfReaderView.getPDFDocument().getPageCount();

+ 12 - 17
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/security/encryption/CDocumentEncryptionDialog.java

@@ -232,6 +232,7 @@ public class CDocumentEncryptionDialog extends CBasicBottomSheetDialogFragment i
         if (v.getId() == toolBar.getIvToolBarBackBtn().getId()) {
             dismiss();
         } else if (v.getId() == R.id.btn_done) {
+            CViewUtils.hideKeyboard(getDialog());
             Editable userPassword = etUserPassword.getText();
             Editable ownerPassword = etOwnerPassword.getText();
             if (swUserPassword.isChecked() && TextUtils.isEmpty(userPassword)){
@@ -247,24 +248,18 @@ public class CDocumentEncryptionDialog extends CBasicBottomSheetDialogFragment i
                 CToastUtil.showLongToast(getContext(), R.string.tools_password_must_be_different);
                 return;
             }
-            // Check the storage permissions to ensure that
-            // you can select the directory and save to the corresponding directory normally.
-            if (CPermissionUtil.hasStoragePermissions(getContext())) {
-                showSelectDirDialog();
-            }else {
-                if (CPermissionUtil.checkManifestPermission(getContext(), Manifest.permission.MANAGE_EXTERNAL_STORAGE) && Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_R) {
-                    CPermissionUtil.openManageAllFileAppSettings(getContext());
-                } else {
-                    multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
-                        if (CPermissionUtil.hasStoragePermissions(getContext())) {
-                            showSelectDirDialog();
-                        } else {
-                            if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
-                                CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
-                            }
+            if (Build.VERSION.SDK_INT < CPermissionUtil.VERSION_R) {
+                multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
+                    if (CPermissionUtil.hasStoragePermissions(getContext())) {
+                        showSelectDirDialog();
+                    } else {
+                        if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+                            CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
                         }
-                    });
-                }
+                    }
+                });
+            }else {
+                showSelectDirDialog();
             }
         } else if (v.getId() == R.id.iv_user_pwd_show) {
             ivUserPwdVisible.setSelected(!ivUserPwdVisible.isSelected());

+ 12 - 19
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/security/watermark/CWatermarkEditDialog.java

@@ -162,25 +162,18 @@ public class CWatermarkEditDialog extends CBasicBottomSheetDialogFragment implem
                     return;
                 }
             }
-
-            // Check the storage permissions to ensure that
-            // you can select the directory and save to the corresponding directory normally.
-            if (CPermissionUtil.hasStoragePermissions(getContext())) {
-                save();
-            } else {
-                if (CPermissionUtil.checkManifestPermission(getContext(), Manifest.permission.MANAGE_EXTERNAL_STORAGE) && Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_R) {
-                    CPermissionUtil.openManageAllFileAppSettings(getContext());
-                } else {
-                    multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
-                        if (CPermissionUtil.hasStoragePermissions(getContext())) {
-                            save();
-                        } else {
-                            if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
-                                CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
-                            }
+            if (Build.VERSION.SDK_INT < CPermissionUtil.VERSION_R) {
+                multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
+                    if (CPermissionUtil.hasStoragePermissions(getContext())) {
+                        save();
+                    } else {
+                        if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+                            CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
                         }
-                    });
-                }
+                    }
+                });
+            }else {
+                save();
             }
         } else if (v.getId() == R.id.iv_watermark_setting) {
             Fragment fragment = getChildFragmentManager().findFragmentByTag("f" + tabLayout.getSelectedTabPosition());
@@ -238,7 +231,7 @@ public class CWatermarkEditDialog extends CBasicBottomSheetDialogFragment implem
                     protected String onRun() {
                         try {
                             boolean success = ((CWatermarkPageFragment) fragment).applyWatermark();
-                            if (!success){
+                            if (!success) {
                                 return null;
                             }
                             boolean result = document.saveAs(pdfFile.getAbsolutePath(), false);

+ 0 - 9
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/importcert/create/CPDFSelectDigitalSignatureDialog.java

@@ -129,15 +129,6 @@ public class CPDFSelectDigitalSignatureDialog extends DialogFragment implements
         if (v.getId() == R.id.btn_cancel) {
             dismiss();
         } else if (v.getId() == R.id.btn_confirm) {
-            if (!CPermissionUtil.hasStoragePermissions(getContext())){
-                if (Build.VERSION.SDK_INT >= CPermissionUtil.VERSION_R &&
-                CPermissionUtil.checkManifestPermission(getContext(), Manifest.permission.MANAGE_EXTERNAL_STORAGE)) {
-                    CPermissionUtil.openManageAllFileAppSettings(getContext());
-                }else {
-                    requestStorageLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE);
-                }
-                return;
-            }
             if (rgType.getCheckedRadioButtonId() == R.id.rb_import_digital_sign){
                 selectCertificateLauncher.launch(CFileUtils.getIntent(CERTIFICATE_DIGITAL_TYPE));
             }else {

+ 33 - 10
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/importcert/create/CreateCertificateDigitalDialog.java

@@ -9,7 +9,9 @@
 
 package com.compdfkit.tools.signature.importcert.create;
 
+import android.Manifest;
 import android.app.Dialog;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
 import android.text.TextUtils;
@@ -33,7 +35,9 @@ import com.compdfkit.core.signature.CPDFSignature;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.basic.fragment.CBasicBottomSheetDialogFragment;
 import com.compdfkit.tools.common.utils.CFileUtils;
+import com.compdfkit.tools.common.utils.CPermissionUtil;
 import com.compdfkit.tools.common.utils.CToastUtil;
+import com.compdfkit.tools.common.utils.activitycontracts.CMultiplePermissionResultLauncher;
 import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils;
 import com.compdfkit.tools.common.utils.view.CEditText;
 import com.compdfkit.tools.common.views.directory.CFileDirectoryDialog;
@@ -95,6 +99,8 @@ public class CreateCertificateDigitalDialog extends CBasicBottomSheetDialogFragm
 
     private String fileName = "";
 
+    protected CMultiplePermissionResultLauncher multiplePermissionResultLauncher = new CMultiplePermissionResultLauncher(this);
+
     public static CreateCertificateDigitalDialog newInstance() {
         Bundle args = new Bundle();
         CreateCertificateDigitalDialog fragment = new CreateCertificateDigitalDialog();
@@ -206,16 +212,20 @@ public class CreateCertificateDigitalDialog extends CBasicBottomSheetDialogFragm
         } else if (v.getId() == R.id.iv_tool_bar_close) {
             dismiss();
         } else if (v.getId() == R.id.tv_save_address) {
-            CFileDirectoryDialog directoryDialog = CFileDirectoryDialog.newInstance(
-                    Environment.getExternalStorageDirectory().getAbsolutePath(),
-                    getContext().getString(R.string.tools_select_folder),
-                    getContext().getString(R.string.tools_save_to_this_directory)
-            );
-            directoryDialog.setSelectFolderListener(dir -> {
-                customSavePath = dir;
-                tvSaveAddress.setText(getSaveAddress() + File.separator + fileName);
-            });
-            directoryDialog.show(getChildFragmentManager(), "directoryDialog");
+            if (Build.VERSION.SDK_INT < CPermissionUtil.VERSION_R) {
+                multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
+                    if (CPermissionUtil.hasStoragePermissions(getContext())) {
+                        showDirectoryDialog();
+                    } else {
+                        if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+                            CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
+                        }
+                    }
+                });
+            }else {
+                showDirectoryDialog();
+            }
+
         } else if (v.getId() == R.id.btn_save) {
             String name = etName.getText();
             String grantor = etOrganizationUnit.getText();
@@ -318,6 +328,19 @@ public class CreateCertificateDigitalDialog extends CBasicBottomSheetDialogFragm
         });
     }
 
+    private void showDirectoryDialog(){
+        CFileDirectoryDialog directoryDialog = CFileDirectoryDialog.newInstance(
+                Environment.getExternalStorageDirectory().getAbsolutePath(),
+                getContext().getString(R.string.tools_select_folder),
+                getContext().getString(R.string.tools_save_to_this_directory)
+        );
+        directoryDialog.setSelectFolderListener(dir -> {
+            customSavePath = dir;
+            tvSaveAddress.setText(getSaveAddress() + File.separator + fileName);
+        });
+        directoryDialog.show(getChildFragmentManager(), "directoryDialog");
+    }
+
     private void enableConfirmButton() {
         String name = etName.getText();
         String email = etEmailAddress.getText();

+ 8 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/interfaces/COnSelectCertFileListener.java

@@ -1,3 +1,11 @@
+/**
+ * Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+ *
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ */
 package com.compdfkit.tools.signature.interfaces;
 
 

+ 38 - 15
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/preview/CDigitalSignStylePreviewDialog.java

@@ -9,8 +9,10 @@
 
 package com.compdfkit.tools.signature.preview;
 
+import android.Manifest;
 import android.app.Dialog;
 import android.graphics.Bitmap;
+import android.os.Build;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.view.View;
@@ -31,6 +33,8 @@ import com.compdfkit.core.signature.CPDFDigitalSigConfig;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.annotation.pdfproperties.pdfsignature.data.CSignatureDatas;
 import com.compdfkit.tools.common.basic.fragment.CBasicBottomSheetDialogFragment;
+import com.compdfkit.tools.common.utils.CPermissionUtil;
+import com.compdfkit.tools.common.utils.activitycontracts.CMultiplePermissionResultLauncher;
 import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
 import com.compdfkit.tools.common.views.CToolBar;
 import com.compdfkit.tools.signature.pdfproperties.pdfsign.CDigitalSignStylePreviewView;
@@ -88,6 +92,8 @@ public class CDigitalSignStylePreviewDialog extends CBasicBottomSheetDialogFragm
 
     private COnResultDigitalSignListener resultDigitalSignListener;
 
+    protected CMultiplePermissionResultLauncher multiplePermissionResultLauncher = new CMultiplePermissionResultLauncher(this);
+
     public static CDigitalSignStylePreviewDialog newInstance(String signImagePath, String commonName, String dn) {
         Bundle args = new Bundle();
         args.putString(EXTRA_SIGN_IMAGE_PATH, signImagePath);
@@ -274,23 +280,40 @@ public class CDigitalSignStylePreviewDialog extends CBasicBottomSheetDialogFragm
             previewView.setContentAlignLeft(true);
         } else if (v.getId() == R.id.btn_save){
             CViewUtils.hideKeyboard(getDialog());
-            if (positionView.getVisibility() == View.VISIBLE){
-                positionView.setVisibility(View.GONE);
-                slMain.setVisibility(View.VISIBLE);
-                return;
-            }
-            if (reasonView.getVisibility() == View.VISIBLE){
-                reasonView.setVisibility(View.GONE);
-                slMain.setVisibility(View.VISIBLE);
-                return;
-            }
-            Bitmap bitmap = previewView.getBitmap();
-            String imagePath = CSignatureDatas.saveDigitalSignatureBitmap(getContext(), bitmap);
-            if (resultDigitalSignListener != null) {
-                resultDigitalSignListener.sign(imagePath, previewView.getConfig(), previewView.getLocation(), previewView.getReason());
+            if (Build.VERSION.SDK_INT < CPermissionUtil.VERSION_R) {
+                multiplePermissionResultLauncher.launch(CPermissionUtil.STORAGE_PERMISSIONS, result -> {
+                    if (CPermissionUtil.hasStoragePermissions(getContext())) {
+                        save();
+                    } else {
+                        if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+                            CPermissionUtil.showPermissionsRequiredDialog(getChildFragmentManager(), getContext());
+                        }
+                    }
+                });
+            }else {
+                save();
             }
-            dismiss();
+
+        }
+    }
+
+    private void save(){
+        if (positionView.getVisibility() == View.VISIBLE){
+            positionView.setVisibility(View.GONE);
+            slMain.setVisibility(View.VISIBLE);
+            return;
+        }
+        if (reasonView.getVisibility() == View.VISIBLE){
+            reasonView.setVisibility(View.GONE);
+            slMain.setVisibility(View.VISIBLE);
+            return;
+        }
+        Bitmap bitmap = previewView.getBitmap();
+        String imagePath = CSignatureDatas.saveDigitalSignatureBitmap(getContext(), bitmap);
+        if (resultDigitalSignListener != null) {
+            resultDigitalSignListener.sign(imagePath, previewView.getConfig(), previewView.getLocation(), previewView.getReason());
         }
+        dismiss();
     }
 
     public void setResultDigitalSignListener(COnResultDigitalSignListener resultDigitalSignListener) {

+ 0 - 8
PDFViewer/build.gradle

@@ -14,14 +14,6 @@ android {
         versionCode rootProject.ext.android.VERSIONCODE as int
         versionName rootProject.ext.sdk.CONVERSION_SDK_VERSION
 
-        javaCompileOptions {
-            annotationProcessorOptions {
-                arguments = [
-                        rxhttp_rxjava: '3.1.6',
-                        rxhttp_package: 'rxhttp.xxx'
-                ]
-            }
-        }
     }
 
     buildTypes {

+ 0 - 1
PDFViewer/src/main/AndroidManifest.xml

@@ -4,7 +4,6 @@
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
 
     <application
         android:allowBackup="true"

+ 2 - 2
config.gradle

@@ -6,7 +6,7 @@ ext {
             VERSIONCODE: 1008
     ]
     sdk = [
-            COMPDFKIT_SDK_VERSION : "1.13.0",
-            COMPDFKIT_SDK_BUILD_TAG : "build_beta_1.13.0_7a627ab8b_202402021045"
+            COMPDFKIT_SDK_VERSION : "2.0.0",
+            COMPDFKIT_SDK_BUILD_TAG : "build_beta_2.0.0_7a627ab8b_202402021045"
     ]
 }