Переглянути джерело

PDFTool(Android) - 优化截图不清晰问题,修复截图崩溃bug

liuxiaolong 2 місяців тому
батько
коміт
9445bb2dee

BIN
ComPDFKit_Repo/compdfkit-ui/ComPDFKit-UI.aar


BIN
ComPDFKit_Repo/compdfkit/ComPDFKit.aar


+ 4 - 4
ComPDFKit_Tools/build.gradle

@@ -52,11 +52,11 @@ dependencies {
 
     api fileTree(include: ['*.jar'], dir: 'libs')
     // use this
-//    api project(path:':ComPDFKit_Repo:compdfkit')
-//    api project(path:':ComPDFKit_Repo:compdfkit-ui')
+    api project(path:':ComPDFKit_Repo:compdfkit')
+    api project(path:':ComPDFKit_Repo:compdfkit-ui')
     // or use
-    api ('com.compdf:compdfkit:2.2.1-SNAPSHOT')
-    api ('com.compdf:compdfkit-ui:2.2.1-SNAPSHOT')
+//    api ('com.compdf:compdfkit:2.2.0')
+//    api ('com.compdf:compdfkit-ui:2.2.0')
     api 'com.github.bumptech.glide:glide:4.15.1'
     annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
     api 'androidx.documentfile:documentfile:1.0.1'

+ 12 - 9
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/contextmenu/impl/CScreenShotContextMenuView.java

@@ -18,8 +18,6 @@ import android.view.View;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentActivity;
 
-import com.compdfkit.core.edit.CPDFEditManager;
-import com.compdfkit.core.edit.CPDFEditPage;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.contextmenu.CPDFContextMenuHelper;
 import com.compdfkit.tools.common.contextmenu.interfaces.ContextMenuScreenShotProvider;
@@ -44,15 +42,20 @@ public class CScreenShotContextMenuView implements ContextMenuScreenShotProvider
             exitScreenShot(helper, pageView);
         });
         menuView.addItem(R.string.tools_share, v -> {
-            Bitmap bitmap = pageView.getScreenshotBitmap();
-            if (bitmap == null){
+            try{
+                Bitmap bitmap = pageView.getScreenshotBitmap();
+                if (bitmap == null){
+                    exitScreenShot(helper, pageView);
+                    return;
+                }
+                String fileName = "screenshot_"+ CDateUtil.getDataTime(CDateUtil.NORMAL_DATE_FORMAT)+".png";
+                String screenShotFilePath = CImageUtil.saveBitmap(pageView.getContext(), fileName, bitmap);
+                CFileUtils.shareFile(menuView.getContext(), pageView.getContext().getString(R.string.tools_share), "image/*", new File(screenShotFilePath));
+                exitScreenShot(helper, pageView);
+            }catch (Exception e){
+                e.printStackTrace();
                 exitScreenShot(helper, pageView);
-                return;
             }
-            String fileName = "screenshot_"+ CDateUtil.getDataTime(CDateUtil.NORMAL_DATE_FORMAT)+".png";
-            String screenShotFilePath = CImageUtil.saveBitmap(pageView.getContext(), fileName, pageView.getScreenshotBitmap());
-            CFileUtils.shareFile(menuView.getContext(), pageView.getContext().getString(R.string.tools_share), "image/*", new File(screenShotFilePath));
-            exitScreenShot(helper, pageView);
         });
         return menuView;
     }

+ 2 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFDocumentFragment.java

@@ -511,11 +511,12 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
         paint.setStyle(Paint.Style.FILL);
         paint.setColor(ContextCompat.getColor(getContext(), R.color.tools_color_accent_50));
 
+        int colorAccent = CViewUtils.getThemeAttrData(getContext().getTheme(), R.attr.colorAccent);
         CPDFEditConfig editConfig = pdfView.getCPdfReaderView()
                 .getEditManager()
                 .getEditConfigBuilder()
                 .setScreenshotRectColor(Color.TRANSPARENT)
-                .setScreenshotBorderColor(ContextCompat.getColor(getContext(), R.color.tools_color_accent))
+                .setScreenshotBorderColor(colorAccent)
                 .setScreenshotBorderDash(new float[]{8.0F, 4F})
                 .setFormPreviewPaint(paint)
                 .setRotateAnnotationDrawableRes(R.drawable.tools_rotate)

+ 1 - 2
PDFViewer/build.gradle

@@ -55,7 +55,6 @@ dependencies {
     implementation 'com.google.android.material:material:1.8.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
     api project(path: ':ComPDFKit_Tools')
-//    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
     // or
-//    implementation ('com.compdf:compdfkit-tools:2.2.1-SNAPSHOT')
+//    implementation ('com.compdf:compdfkit-tools:2.2.0')
 }

+ 1 - 1
PDFViewer/src/main/java/com/compdfkit/pdfviewer/home/datas/FunDatas.java

@@ -43,7 +43,7 @@ public class FunDatas {
                 new HomeFunBean(context, HomeFunBean.FunType.Conversion, R.drawable.ic_fun_conversion, R.string.tools_fun_conversion, R.string.tools_fun_conversion_desc),
                 new HomeFunBean(context, HomeFunBean.FunType.Compress, R.drawable.ic_fun_compress, R.string.tools_fun_compress, R.string.tools_fun_compress_desc, true),
                 new HomeFunBean(context, HomeFunBean.FunType.Measurement, R.drawable.ic_fun_mesurement, R.string.tools_fun_measurement, R.string.tools_fun_measurement_desc),
-                new HomeFunBean(context, HomeFunBean.FunType.FunSample, R.drawable.ic_fun_document_editor, R.string.tools_fun_document_editor, R.string.tools_fun_document_editor_desc),
+//                new HomeFunBean(context, HomeFunBean.FunType.FunSample, R.drawable.ic_fun_document_editor, R.string.tools_fun_document_editor, R.string.tools_fun_document_editor_desc),
                 HomeFunBean.head(context, R.string.tools_click_to_open_process),
                 HomeFunBean.assetsFile(context, "ComPDFKit_Sample_File_Android.pdf", "ComPDFKit_Sample_File_Android.pdf"));
     }