Procházet zdrojové kódy

PDFTool(Android) - 优化打开文档过慢问题,优化添加图片旋转bug,优化保存过慢卡死主线程问题

liuxiaolong před 7 měsíci
rodič
revize
d3dec52d7c

binární
ComPDFKit_Repo/compdfkit/ComPDFKit.aar


+ 2 - 2
ComPDFKit_Tools/build.gradle

@@ -54,8 +54,8 @@ dependencies {
     api project(path:':ComPDFKit_Repo:compdfkit')
     api project(path:':ComPDFKit_Repo:compdfkit-ui')
     // or use
-//    api ('com.compdf:compdfkit:2.1.1')
-//    api ('com.compdf:compdfkit-ui:2.1.1')
+//    api ('com.compdf:compdfkit:2.1.2')
+//    api ('com.compdf:compdfkit-ui:2.1.2')
     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'

+ 55 - 6
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFDocumentFragment.java

@@ -36,6 +36,8 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.constraintlayout.widget.ConstraintLayout;
 import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
 
 import com.compdfkit.core.annotation.CPDFAnnotation;
 import com.compdfkit.core.annotation.form.CPDFSignatureWidget;
@@ -59,6 +61,7 @@ import com.compdfkit.tools.common.utils.CToastUtil;
 import com.compdfkit.tools.common.utils.activitycontracts.CSelectPDFDocumentResultContract;
 import com.compdfkit.tools.common.utils.annotation.CPDFAnnotationManager;
 import com.compdfkit.tools.common.utils.dialog.CAlertDialog;
+import com.compdfkit.tools.common.utils.dialog.CLoadingDialog;
 import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils;
 import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
 import com.compdfkit.tools.common.utils.window.CPopupMenuWindow;
@@ -194,14 +197,28 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
                 if (pdfSearchToolBarView.getVisibility() == VISIBLE) {
                     pdfSearchToolBarView.exitSearch();
                     onBackPressedCallback.setEnabled(false);
-                } else {
+                    return;
+                }
+                if (pdfView.getCPdfReaderView().getTouchMode() == CPDFReaderView.TouchMode.SCREENSHOT) {
                     onBackPressedCallback.setEnabled(false);
-                    if (pdfView != null) {
-                        pdfView.savePDF((filePath, pdfUri) -> requireActivity().onBackPressed(), e -> {
-                            e.printStackTrace();
+                    exitScreenShot();
+                    return;
+                }
+                onBackPressedCallback.setEnabled(false);
+                if (pdfView != null) {
+                    pdfView.savePDF((filePath, pdfUri) -> {
+                        try {
                             requireActivity().onBackPressed();
-                        });
-                    }
+                        }catch (Exception e){
+                        }
+                    }, e -> {
+                        e.printStackTrace();
+                        try {
+                            requireActivity().onBackPressed();
+                        }catch (Exception e1){
+
+                        }
+                    });
                 }
             }
         };
@@ -644,9 +661,17 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
                         break;
                     case Save:
                         menuWindow.addItem(R.drawable.tools_ic_menu_save, R.string.tools_save, v1 -> {
+                            CLoadingDialog loadingDialog = CLoadingDialog.newInstance();
+                            loadingDialog.show(getChildFragmentManager(), "saveLoadingDialog");
                             pdfView.savePDF((filePath, pdfUri) -> {
+                                if (loadingDialog != null) {
+                                    loadingDialog.dismiss();
+                                }
                                 CToastUtil.showLongToast(getContext(), R.string.tools_save_success);
                             }, e -> {
+                                if (loadingDialog != null) {
+                                    loadingDialog.dismiss();
+                                }
                             });
                         });
                         break;
@@ -689,6 +714,7 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
                                 CPDFPageView view = (CPDFPageView) readerView.getChildAt(i);
                                 view.clearScreenShotRect();
                             }
+                            onBackPressedCallback.setEnabled(true);
                             // enter fill screen mode
                             screenManager.fillScreenChange();
                             // enter screenshot mode , Please select the screenshot area in the reader view
@@ -862,6 +888,29 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
         }
     }
 
+    public void exitScreenShot(){
+        CPDFReaderView readerView = pdfView.getCPdfReaderView();
+        if (readerView.getContextMenuShowListener() != null) {
+            readerView.getContextMenuShowListener().dismissContextMenu();
+        }
+        for (int i = 0; i < readerView.getChildCount(); i++) {
+            CPDFPageView view = (CPDFPageView) readerView.getChildAt(i);
+            view.clearScreenShotRect();
+        }
+        CPDFReaderView.ViewMode viewMode = readerView.getViewMode();
+        if(viewMode == CPDFReaderView.ViewMode.PDFEDIT){
+            readerView.setTouchMode(CPDFReaderView.TouchMode.EDIT);
+            CPDFEditManager editManager = readerView.getEditManager();
+            if (editManager != null && !editManager.isEditMode()) {
+                editManager.enable();
+                editManager.beginEdit(CPDFEditPage.LoadTextImage);
+            }
+        }else {
+            readerView.setTouchMode(CPDFReaderView.TouchMode.BROWSE);
+        }
+        screenManager.fillScreenChange();
+    }
+
     protected interface CRequestPermissionListener {
 
         void request();

+ 18 - 33
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/annotation/CPDFAnnotationManager.java

@@ -41,6 +41,8 @@ import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CPDFEditReplyDial
 import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CPDFReplyDetailsDialogFragment;
 import com.compdfkit.tools.annotation.pdfproperties.pdfnote.CNoteEditDialog;
 import com.compdfkit.tools.common.contextmenu.CPDFContextMenuHelper;
+import com.compdfkit.tools.common.utils.CUriUtil;
+import com.compdfkit.tools.common.utils.image.CBitmapUtil;
 import com.compdfkit.tools.common.views.pdfproperties.action.CActionEditDialogFragment;
 import com.compdfkit.tools.forms.pdfproperties.option.edit.CFormOptionEditFragment;
 import com.compdfkit.ui.attribute.CPDFFreetextAttr;
@@ -152,46 +154,30 @@ public class CPDFAnnotationManager {
     public void addImageStamp(String imagePath, CPDFReaderView readerView, CPDFPageView pageView, PointF pointF) {
         CPDFPage page = readerView.getPDFDocument().pageAtIndex(readerView.getPageNum());
         CPDFStampAnnotation stampAnnotation = (CPDFStampAnnotation) page.addAnnot(CPDFAnnotation.Type.STAMP);
-        stampAnnotation.setImageStamp(imagePath);
-
-        ExifInterface exif = null;
-        int rotate = 0;
-        try {
-            exif = new ExifInterface(imagePath);
-            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
-            switch (orientation) {
-                case ExifInterface.ORIENTATION_ROTATE_90:
-                    rotate = 90;
-                    break;
-                case ExifInterface.ORIENTATION_ROTATE_180:
-                    rotate = 180;
-                    break;
-                case ExifInterface.ORIENTATION_ROTATE_270:
-                    rotate = 270;
-                    break;
-                default:
-                    break;
-            }
-        } catch (Exception e) {
 
-        }
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inJustDecodeBounds = true;
+        BitmapFactory.decodeFile(imagePath, options);
 
+        int rotate = CUriUtil.getBitmapDegree(imagePath);
 
+        RectF area;
         float defaultWidth = 200F;
         PointF vertex = new PointF(pointF.x - (defaultWidth / 2), pointF.y);
-        BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inJustDecodeBounds = true;
-        BitmapFactory.decodeFile(imagePath, options);
-        RectF insertRect = new RectF(vertex.x, vertex.y, vertex.x + defaultWidth, vertex.y
-                + defaultWidth * ((rotate == 0 || rotate == 180) ? options.outHeight / options.outWidth : options.outWidth / options.outHeight));
-        RectF pageSize = readerView.getPageNoZoomSize(readerView.getPageNum());
-        insertRect.set(page.convertRectToPage(readerView.isCropMode(), pageSize.width(),
-                pageSize.height(), insertRect));
-        stampAnnotation.setRect(insertRect);
-        if (imagePath.endsWith("png")) {
+        if (rotate == 0 || rotate == 180) {
+            area = new RectF(vertex.x, vertex.y, vertex.x + defaultWidth, vertex.y + defaultWidth * options.outHeight / options.outWidth);
+        } else {
+            area = new RectF(vertex.x, vertex.y, vertex.x + defaultWidth, vertex.y + defaultWidth * options.outWidth / options.outHeight);
+        }
+        RectF size = readerView.getPageNoZoomSize(pageView.getPageNum());
+        area.set(page.convertRectToPage(readerView.isCropMode(), size.width(), size.height(), area));
+        stampAnnotation.setRect(area);
+
+        if (imagePath.endsWith(".png")) {
             BitmapFactory.Options tmpOptions = new BitmapFactory.Options();
             tmpOptions.inMutable = true;
             Bitmap bitmap = BitmapFactory.decodeFile(imagePath, tmpOptions);
+
             if (rotate == 0) {
                 stampAnnotation.updateApWithBitmap(bitmap);
             } else {
@@ -203,7 +189,6 @@ public class CPDFAnnotationManager {
                 stampAnnotation.updateApWithBitmap(newBM);
                 newBM.recycle();
             }
-            bitmap.recycle();
         } else {
             stampAnnotation.setImageStamp(imagePath);
             stampAnnotation.updateAp();

+ 1 - 2
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/glide/CPDFFether.java

@@ -67,7 +67,7 @@ class CPDFFether implements DataFetcher<Bitmap> {
         if (tpdfDocument == null) {
             throw new Exception("CPDFDocument is null!");
         }
-        RectF sizeRect = tpdfDocument.getPageSize(pageIndex);
+        RectF sizeRect = tpdfDocument.pageAtIndex(pageIndex).getSize();
         if (width == Target.SIZE_ORIGINAL ){
             width = (int) sizeRect.width();
         }
@@ -75,7 +75,6 @@ class CPDFFether implements DataFetcher<Bitmap> {
             height = (int) sizeRect.height();
         }
         Bitmap bitmap = Glide.get(context).getBitmapPool().get(width, height, Bitmap.Config.ARGB_4444);
-        CLog.e("ComPDFKit", "CPDFFether load PDF Image Size: " + width +" * " + height);
         boolean res = tpdfDocument.renderPageAtIndex(bitmap,
                 pageIndex,
                 width,

+ 1 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/glide/CPDFModelLoader.java

@@ -2,6 +2,7 @@ package com.compdfkit.tools.common.utils.glide;
 
 import android.content.Context;
 import android.graphics.Bitmap;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;

+ 53 - 40
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfview/CPDFViewCtrl.java

@@ -16,6 +16,7 @@ import android.net.Uri;
 import android.os.Handler;
 import android.os.Looper;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.LinearLayout;
@@ -261,11 +262,16 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
     }
 
     public void openPDF(String pdfFilePath, String password, COnOpenPdfFinishCallback openPdfFinishCallback) {
-        // Create a new instance of the CPDFDocument class, passing in the current context.
-        CPDFDocument cpdfDocument = new CPDFDocument(getContext());
-        // Attempt to open the PDF file at the given file path using the open method of the CPDFDocument class.
-        CPDFDocument.PDFDocumentError pdfDocumentError = cpdfDocument.open(pdfFilePath, password);
-        setPDFDocument(cpdfDocument, pdfFilePath, pdfDocumentError, openPdfFinishCallback);
+        CThreadPoolUtils.getInstance().executeIO(() -> {
+            // Create a new instance of the CPDFDocument class, passing in the current context.
+            CPDFDocument cpdfDocument = new CPDFDocument(getContext());
+            // Attempt to open the PDF file at the given file path using the open method of the CPDFDocument class.
+
+            CPDFDocument.PDFDocumentError pdfDocumentError = cpdfDocument.open(pdfFilePath, password);
+            CThreadPoolUtils.getInstance().executeMain(() -> {
+                setPDFDocument(cpdfDocument, pdfFilePath, pdfDocumentError, openPdfFinishCallback);
+            });
+        });
     }
 
     public void openPDF(Uri pdfUri) {
@@ -277,11 +283,15 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
     }
 
     public void openPDF(Uri pdfUri, String password, COnOpenPdfFinishCallback openPdfFinishCallback) {
-        // Create a new instance of the CPDFDocument class, passing in the current context.
-        CPDFDocument cpdfDocument = new CPDFDocument(getContext());
-        // Attempt to open the PDF file at the given file path using the open method of the CPDFDocument class.
-        CPDFDocument.PDFDocumentError pdfDocumentError = cpdfDocument.open(pdfUri, password);
-        setPDFDocument(cpdfDocument, pdfUri, pdfDocumentError, openPdfFinishCallback);
+        CThreadPoolUtils.getInstance().executeIO(() -> {
+            // Create a new instance of the CPDFDocument class, passing in the current context.
+            CPDFDocument cpdfDocument = new CPDFDocument(getContext());
+            // Attempt to open the PDF file at the given file path using the open method of the CPDFDocument class.
+            CPDFDocument.PDFDocumentError pdfDocumentError = cpdfDocument.open(pdfUri, password);
+            CThreadPoolUtils.getInstance().executeMain(() -> {
+                setPDFDocument(cpdfDocument, pdfUri, pdfDocumentError, openPdfFinishCallback);
+            });
+        });
     }
 
     private void setPDFDocument(CPDFDocument cpdfDocument, Object pdf, CPDFDocument.PDFDocumentError error, COnOpenPdfFinishCallback openPdfFinishCallback) {
@@ -375,7 +385,7 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
         }
     }
 
-    public void savePDF(COnSaveCallback callback, COnSaveError error){
+    public void savePDF(COnSaveCallback callback, COnSaveError error) {
         CThreadPoolUtils.getInstance().executeMain(() -> {
             cPdfReaderView.pauseAllRenderProcess();
             cPdfReaderView.removeAllAnnotFocus();
@@ -394,33 +404,36 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
             }
             exitEditMode();
             if (document.hasChanges()) {
-                try {
-
-                    boolean saveFileExtraFontSubset = false;
-                    if (cpdfConfiguration != null && cpdfConfiguration.globalConfig != null){
-                        saveFileExtraFontSubset = cpdfConfiguration.globalConfig.fileSaveExtraFontSubset;
-                    }
-                    CLog.e("ComPDFKit", "save pdf extra font subset:" + saveFileExtraFontSubset);
-                    boolean success = document.save(CPDFDocument.PDFDocumentSaveType.PDFDocumentSaveIncremental, saveFileExtraFontSubset);
-                    if (!success) {
-                        document.save(CPDFDocument.PDFDocumentSaveType.PDFDocumentSaveNoIncremental, saveFileExtraFontSubset);
-                    }
-                    if (callback != null) {
-                        callback.callback(document.getAbsolutePath(), document.getUri());
-                    }
-                    if (saveGlobalCallback != null) {
-                        saveGlobalCallback.callback(document.getAbsolutePath(), document.getUri());
-                    }
-                } catch (CPDFDocumentException e) {
-                    e.printStackTrace();
-                    CLog.e("ComPDFKit", "save fail:" + e.getMessage());
-                    if (error != null) {
-                        error.error(e);
-                    }
-                    if (saveGlobalErrorCallback != null) {
-                        saveGlobalErrorCallback.error(new Exception("document is null"));
+                CThreadPoolUtils.getInstance().executeIO(() -> {
+                    try {
+                        boolean saveFileExtraFontSubset = false;
+                        if (cpdfConfiguration != null && cpdfConfiguration.globalConfig != null) {
+                            saveFileExtraFontSubset = cpdfConfiguration.globalConfig.fileSaveExtraFontSubset;
+                        }
+                        CLog.e("ComPDFKit", "save pdf extra font subset:" + saveFileExtraFontSubset);
+                        boolean success = document.save(CPDFDocument.PDFDocumentSaveType.PDFDocumentSaveIncremental, saveFileExtraFontSubset);
+                        if (!success) {
+                            document.save(CPDFDocument.PDFDocumentSaveType.PDFDocumentSaveNoIncremental, saveFileExtraFontSubset);
+                        }
+                        CThreadPoolUtils.getInstance().executeMain(()->{
+                            if (callback != null) {
+                                callback.callback(document.getAbsolutePath(), document.getUri());
+                            }
+                            if (saveGlobalCallback != null) {
+                                saveGlobalCallback.callback(document.getAbsolutePath(), document.getUri());
+                            }
+                        });
+                    } catch (CPDFDocumentException e) {
+                        e.printStackTrace();
+                        CLog.e("ComPDFKit", "save fail:" + e.getMessage());
+                        if (error != null) {
+                            error.error(e);
+                        }
+                        if (saveGlobalErrorCallback != null) {
+                            saveGlobalErrorCallback.error(new Exception("document is null"));
+                        }
                     }
-                }
+                });
             } else {
                 if (callback != null) {
                     callback.callback(document.getAbsolutePath(), document.getUri());
@@ -636,7 +649,7 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
         pdfViewFocusedListenerList.add(listener);
     }
 
-    public void addReaderViewCallback(CPDFIReaderViewCallback callback){
+    public void addReaderViewCallback(CPDFIReaderViewCallback callback) {
         this.readerViewCallbacks.add(callback);
     }
 
@@ -651,9 +664,9 @@ public class CPDFViewCtrl extends ConstraintLayout implements IReaderViewCallbac
     }
 
     public boolean isSaveFileExtraFontSubset() {
-        if (cpdfConfiguration != null && cpdfConfiguration.globalConfig != null){
+        if (cpdfConfiguration != null && cpdfConfiguration.globalConfig != null) {
             return cpdfConfiguration.globalConfig.fileSaveExtraFontSubset;
-        }else {
+        } else {
             return false;
         }
     }

+ 6 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/security/watermark/CWatermarkEditDialog.java

@@ -30,6 +30,7 @@ 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.activitycontracts.CMultiplePermissionResultLauncher;
+import com.compdfkit.tools.common.utils.dialog.CLoadingDialog;
 import com.compdfkit.tools.common.utils.threadpools.SimpleBackgroundTask;
 import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
 import com.compdfkit.tools.common.views.CToolBar;
@@ -234,6 +235,8 @@ public class CWatermarkEditDialog extends CBasicBottomSheetDialogFragment implem
             File file = new File(dir, CFileUtils.getFileNameNoExtension(document.getFileName()) + getString(R.string.tools_watermark_suffix));
             File pdfFile = CFileUtils.renameNameSuffix(file);
             Fragment fragment = getChildFragmentManager().findFragmentByTag("f" + tabLayout.getSelectedTabPosition());
+            CLoadingDialog loadingDialog = CLoadingDialog.newInstance();
+            loadingDialog.show(getChildFragmentManager(), "saveDialog");
             if (fragment != null && fragment instanceof CWatermarkPageFragment) {
                 new SimpleBackgroundTask<String>(getContext()) {
 
@@ -254,6 +257,9 @@ public class CWatermarkEditDialog extends CBasicBottomSheetDialogFragment implem
 
                     @Override
                     protected void onSuccess(String result) {
+                        if (loadingDialog != null) {
+                            loadingDialog.dismiss();
+                        }
                         if (document.shouleReloadDocument()) {
                             document.reload();
                         }

+ 6 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/viewer/pdfsearch/CSearchReplaceToolbar.java

@@ -483,7 +483,9 @@ public class CSearchReplaceToolbar extends LinearLayout implements View.OnClickL
     }
 
     private void resetSearch() {
-        cpdfSearch.resetSearch();
+        if (cpdfSearch != null) {
+            cpdfSearch.resetSearch();
+        }
         groupSearchBefore.setVisibility(VISIBLE);
         groupSearchAfter.setVisibility(GONE);
     }
@@ -505,6 +507,9 @@ public class CSearchReplaceToolbar extends LinearLayout implements View.OnClickL
             loadingDialog.dismiss();
         }
         if (getContext() instanceof FragmentActivity){
+            if (pdfView == null || pdfView.getCPdfReaderView() == null){
+                return;
+            }
             if (pdfView.getCPdfReaderView().getPDFDocument().getPageCount() < 40) {
                 return;
             }

+ 305 - 298
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/viewer/pdfthumbnail/adpater/CPDFEditThumbnailListAdapter.java

@@ -8,9 +8,12 @@
  */
 package com.compdfkit.tools.viewer.pdfthumbnail.adpater;
 
+import android.content.Context;
+import android.content.res.Configuration;
 import android.graphics.RectF;
 import android.graphics.drawable.Drawable;
 import android.os.AsyncTask;
+import android.util.Log;
 import android.util.SparseIntArray;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -32,338 +35,342 @@ import com.compdfkit.core.document.CPDFDocument;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.interfaces.COnSetPDFDisplayPageIndexListener;
 import com.compdfkit.tools.common.utils.glide.CPDFWrapper;
+import com.compdfkit.tools.common.utils.viewutils.CDimensUtils;
 import com.compdfkit.tools.docseditor.drag.CDefaultItemTouchHelpCallback;
 
 import java.util.ArrayList;
 import java.util.List;
 
 public class CPDFEditThumbnailListAdapter
-    extends RecyclerView.Adapter<CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder>
-    implements CDefaultItemTouchHelpCallback.OnItemTouchCallbackListener {
-  private CPDFDocument cPdfDocument;
+        extends RecyclerView.Adapter<CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder>
+        implements CDefaultItemTouchHelpCallback.OnItemTouchCallbackListener {
+    private CPDFDocument cPdfDocument;
 
-  private int currentPageIndex;
+    private int currentPageIndex;
 
-  private COnSetPDFDisplayPageIndexListener displayPageIndexListener;
+    private COnSetPDFDisplayPageIndexListener displayPageIndexListener;
 
-  private boolean isEdit = false;
+    private boolean isEdit = false;
 
-  private SparseIntArray selectArr = new SparseIntArray();
+    private SparseIntArray selectArr = new SparseIntArray();
 
-  private OnPageEditListener onPageEditListener = null;
+    private OnPageEditListener onPageEditListener = null;
 
-  private int[] itemSize = new int[2];
+    private int[] itemSize = new int[2];
 
-  public CPDFEditThumbnailListAdapter(CPDFDocument cPdfDocument, int currentPageIndex) {
-    this.cPdfDocument = cPdfDocument;
-    this.currentPageIndex = currentPageIndex;
-  }
-
-  @NonNull
-  @Override
-  public CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder onCreateViewHolder(
-      @NonNull ViewGroup parent, int viewType) {
-    return new CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder(
-        LayoutInflater.from(parent.getContext())
-            .inflate(R.layout.tools_edit_thumbnail_list_item, parent, false));
-  }
+    public CPDFEditThumbnailListAdapter(CPDFDocument cPdfDocument, int currentPageIndex) {
+        this.cPdfDocument = cPdfDocument;
+        this.currentPageIndex = currentPageIndex;
+    }
 
-  @Override
-  public void onBindViewHolder(
-      @NonNull CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder holder, int position) {
 
-    RequestBuilder<Drawable> requestBuilder =
-        Glide.with(holder.itemView.getContext())
-            .load(CPDFWrapper.fromDocument(cPdfDocument, position));
-    if (itemSize[0] != 0 && itemSize[1] != 0) {
-        requestBuilder = requestBuilder.override(itemSize[0], itemSize[1]);
+    @NonNull
+    @Override
+    public CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder onCreateViewHolder(
+            @NonNull ViewGroup parent, int viewType) {
+        return new CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder(
+                LayoutInflater.from(parent.getContext())
+                        .inflate(R.layout.tools_edit_thumbnail_list_item, parent, false));
     }
-    requestBuilder
-        .diskCacheStrategy(DiskCacheStrategy.NONE)
-        .into(
-            new CustomTarget<Drawable>() {
-              @Override
-              public void onResourceReady(
-                  @NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
-                RectF rectF = cPdfDocument.pageAtIndex(position).getSize();
-                float itemWidth = holder.clItem.getMeasuredWidth();
-                float itemHeight = holder.clItem.getMeasuredHeight();
-                if (itemSize[0] == 0 || itemSize[1] == 0) {
-                  itemSize[0] = (int) (itemWidth * 0.6F);
-                  itemSize[1] = (int) (itemHeight * 0.6F);
-                }
-                float imageWidth = itemWidth;
-                float imageHeight = ((float) imageWidth / (float) rectF.width()) * rectF.height();
 
-                if (imageHeight > itemHeight) {
-                  imageHeight = itemHeight;
-                  imageWidth = (imageHeight / rectF.height()) * rectF.width();
-                }
-                ConstraintLayout.LayoutParams layoutParams =
-                    (ConstraintLayout.LayoutParams) holder.clThumbnail.getLayoutParams();
-                layoutParams.width = (int) imageWidth;
-                layoutParams.height = (int) imageHeight;
-                holder.clThumbnail.setLayoutParams(layoutParams);
-                holder.ivThumbnailImage.setImageDrawable(resource);
-              }
-
-              @Override
-              public void onLoadCleared(@Nullable Drawable placeholder) {}
-            });
-
-    holder.tvPageIndex.setText(String.valueOf(holder.getAdapterPosition() + 1));
-    updateSelectStatus(holder);
-  }
-
-  private void updateSelectStatus(CPDFThumbnailItemViewHolder holder) {
-    if (isEdit) {
-      if (selectArr.get(holder.getAdapterPosition()) == 1) {
-        holder.ivSelect.setSelected(true);
-        holder.tvPageIndex.setSelected(true);
-        holder.clThumbnail.setSelected(true);
-      } else {
-        holder.ivSelect.setSelected(false);
-        holder.tvPageIndex.setSelected(false);
-        holder.clThumbnail.setSelected(false);
-      }
-      holder.ivSelect.setVisibility(View.VISIBLE);
-    } else {
-      holder.ivSelect.setSelected(false);
-      holder.ivSelect.setVisibility(View.GONE);
-      holder.tvPageIndex.setSelected(holder.getAdapterPosition() == currentPageIndex);
-      holder.clThumbnail.setSelected(holder.getAdapterPosition() == currentPageIndex);
-    }
-  }
+    public static final int SPAN = 6;
+
+    private int[] calculateItemSize(CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder holder, int position) {
+        boolean isPortrait = holder.itemView.getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
+        int spanSize = isPortrait ? 2 : 1;
+        int screenWidth = CDimensUtils.getScreenWidth(holder.itemView.getContext());
+        if (spanSize == 1) {
+            screenWidth = CDimensUtils.dp2px(holder.itemView.getContext(), 600);
+        }
+        int itemWidth = screenWidth / (SPAN / spanSize);
+        int itemMarginHorizontal = CDimensUtils.dp2px(holder.itemView.getContext(), 4) * 2;
+        itemWidth -= itemMarginHorizontal;
 
-  @Override
-  public int getItemCount() {
-    return cPdfDocument == null ? 0 : cPdfDocument.getPageCount();
-  }
+        RectF rectF = cPdfDocument.pageAtIndex(position).getSize();
+        float itemHeight = itemWidth * (134F / 104F);
 
-  public void setPDFDisplayPageIndexListener(COnSetPDFDisplayPageIndexListener listener) {
-    this.displayPageIndexListener = listener;
-  }
+        float imageWidth = itemWidth;
+        float imageHeight = ((float) imageWidth / (float) rectF.width()) * rectF.height();
 
-  public void setEdit(boolean edit) {
-    isEdit = edit;
-    if (selectArr != null) {
-      selectArr.clear();
+        if (imageHeight > itemHeight) {
+            imageHeight = itemHeight;
+            imageWidth = (imageHeight / rectF.height()) * rectF.width();
+        }
+        ConstraintLayout.LayoutParams layoutParams =
+                (ConstraintLayout.LayoutParams) holder.clThumbnail.getLayoutParams();
+        layoutParams.width = (int) imageWidth;
+        layoutParams.height = (int) imageHeight;
+        holder.clThumbnail.setLayoutParams(layoutParams);
+        return new int[]{(int) imageWidth, (int) imageHeight};
     }
-  }
-
-  public boolean isEdit() {
-    return isEdit;
-  }
-
-  public void setItemClick(int position) {
-    if (isEdit) {
-      if (selectArr.get(position) == 0) {
-        selectArr.put(position, 1);
-      } else {
-        selectArr.removeAt(selectArr.indexOfKey(position));
-      }
+
+
+    @Override
+    public void onBindViewHolder(
+            @NonNull CPDFEditThumbnailListAdapter.CPDFThumbnailItemViewHolder holder, int position) {
+
+        int[] size = calculateItemSize(holder, position);
+
+        Glide.with(holder.itemView.getContext())
+                .load(CPDFWrapper.fromDocument(cPdfDocument, position))
+                .diskCacheStrategy(DiskCacheStrategy.NONE)
+                .override(size[0], size[1])
+                .into(holder.ivThumbnailImage);
+
+        holder.tvPageIndex.setText(String.valueOf(holder.getAdapterPosition() + 1));
+        updateSelectStatus(holder);
     }
-    notifyItemChanged(position);
-  }
-
-  public void setAllClick(RecyclerView recyclerView) {
-    if (isEdit && cPdfDocument != null) {
-      for (int i = 0; i < cPdfDocument.getPageCount(); i++) {
-        selectArr.put(i, 1);
-        RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i);
-        if (viewHolder != null) {
-          updateSelectStatus((CPDFThumbnailItemViewHolder) viewHolder);
+
+    private void updateSelectStatus(CPDFThumbnailItemViewHolder holder) {
+        if (isEdit) {
+            if (selectArr.get(holder.getAdapterPosition()) == 1) {
+                holder.ivSelect.setSelected(true);
+                holder.tvPageIndex.setSelected(true);
+                holder.clThumbnail.setSelected(true);
+            } else {
+                holder.ivSelect.setSelected(false);
+                holder.tvPageIndex.setSelected(false);
+                holder.clThumbnail.setSelected(false);
+            }
+            holder.ivSelect.setVisibility(View.VISIBLE);
         } else {
-          notifyItemChanged(i);
+            holder.ivSelect.setSelected(false);
+            holder.ivSelect.setVisibility(View.GONE);
+            holder.tvPageIndex.setSelected(holder.getAdapterPosition() == currentPageIndex);
+            holder.clThumbnail.setSelected(holder.getAdapterPosition() == currentPageIndex);
         }
-      }
     }
-  }
-
-  public void setAllUnClick(RecyclerView recyclerView) {
-    if (isEdit) {
-      for (int size = selectArr.size() - 1; size >= 0; size--) {
-        int key = selectArr.keyAt(size);
-        selectArr.removeAt(size);
-        RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(key);
-        if (viewHolder != null) {
-          updateSelectStatus((CPDFThumbnailItemViewHolder) viewHolder);
-        } else {
-          notifyItemChanged(key);
+
+    @Override
+    public int getItemCount() {
+        return cPdfDocument == null ? 0 : cPdfDocument.getPageCount();
+    }
+
+    public void setPDFDisplayPageIndexListener(COnSetPDFDisplayPageIndexListener listener) {
+        this.displayPageIndexListener = listener;
+    }
+
+    public void setEdit(boolean edit) {
+        isEdit = edit;
+        if (selectArr != null) {
+            selectArr.clear();
         }
-      }
     }
-  }
-
-  public SparseIntArray getSelectArr() {
-    return selectArr;
-  }
-
-  public void setSelectArr(int[] pageNum) {
-    if (pageNum != null) {
-      selectArr.clear();
-      for (int i = 0; i < pageNum.length; i++) {
-        selectArr.put(pageNum[i], 1);
-      }
+
+    public boolean isEdit() {
+        return isEdit;
     }
-    notifyDataSetChanged();
-  }
-
-  public void setOnPageEditListener(OnPageEditListener onPageEditListener) {
-    this.onPageEditListener = onPageEditListener;
-  }
-
-  @Override
-  public void onSwiped(int adapterPosition) {}
-
-  @Override
-  public boolean onDragging(
-      RecyclerView.ViewHolder sourceViewHolder, RecyclerView.ViewHolder targetViewHolder) {
-    int sourcePosition = sourceViewHolder.getAdapterPosition();
-    int targetPosition = targetViewHolder.getAdapterPosition();
-    notifyItemMoved(sourcePosition, targetPosition);
-    return true;
-  }
-
-  @Override
-  public void onMoved(
-      RecyclerView.ViewHolder sourceViewHolder, int sourcePosition, int targetPosition) {
-    AsyncTask<Void, Void, Boolean> asyncTask =
-        new AsyncTask<Void, Void, Boolean>() {
-          @Override
-          protected Boolean doInBackground(Void... voids) {
-            boolean isSuccess;
-            try {
-              isSuccess = cPdfDocument.movePage(sourcePosition, targetPosition);
-              if (sourcePosition < targetPosition) { // 往后移动
-                List<Integer> selected = new ArrayList<>();
-                for (int i = sourcePosition; i <= targetPosition; i++) {
-                  if (selectArr.get(i) == 1) {
-                    selected.add(i);
-                    selectArr.removeAt(selectArr.indexOfKey(i));
-                  }
-                }
-                for (int i = 0; i < selected.size(); i++) {
-                  if (selected.get(i) == sourcePosition) {
-                    continue;
-                  }
-                  selectArr.put(selected.get(i) - 1, 1);
-                }
-                if (selected.size() > 0) {
-                  if (selected.get(0) == sourcePosition) {
-                    selectArr.put(targetPosition, 1);
-                  }
-                }
-              } else { // 往前移动
-                List<Integer> selected = new ArrayList<>();
-                for (int i = sourcePosition; i >= targetPosition; i--) {
-                  if (selectArr.get(i) == 1) {
-                    selected.add(i);
-                    selectArr.removeAt(selectArr.indexOfKey(i));
-                  }
-                }
-                for (int i = 0; i < selected.size(); i++) {
-                  if (selected.get(i) == sourcePosition) {
-                    continue;
-                  }
-                  selectArr.put(selected.get(i) + 1, 1);
-                }
-                if (selected.size() > 0) {
-                  if (selected.get(0) == sourcePosition) {
-                    selectArr.put(targetPosition, 1);
-                  }
-                }
-              }
-              if (currentPageIndex == sourcePosition) {
-                currentPageIndex = targetPosition;
-              } else if (currentPageIndex == targetPosition) {
-                if (sourcePosition < targetPosition) {
-                  currentPageIndex = targetPosition - 1;
+
+    public void setItemClick(int position) {
+        if (isEdit) {
+            if (selectArr.get(position) == 0) {
+                selectArr.put(position, 1);
+            } else {
+                selectArr.removeAt(selectArr.indexOfKey(position));
+            }
+        }
+        notifyItemChanged(position);
+    }
+
+    public void setAllClick(RecyclerView recyclerView) {
+        if (isEdit && cPdfDocument != null) {
+            for (int i = 0; i < cPdfDocument.getPageCount(); i++) {
+                selectArr.put(i, 1);
+                RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i);
+                if (viewHolder != null) {
+                    updateSelectStatus((CPDFThumbnailItemViewHolder) viewHolder);
                 } else {
-                  currentPageIndex = targetPosition + 1;
-                }
-              } else {
-                if (sourcePosition < currentPageIndex && currentPageIndex < targetPosition) {
-                  currentPageIndex--;
-                } else if (targetPosition < currentPageIndex && currentPageIndex < sourcePosition) {
-                  currentPageIndex++;
+                    notifyItemChanged(i);
                 }
-              }
-            } catch (Exception e) {
-              return false;
             }
-            return isSuccess;
-          }
-
-          @Override
-          protected void onPostExecute(Boolean aBoolean) {
-            super.onPostExecute(aBoolean);
-            if (aBoolean) {
-              if (onPageEditListener != null) {
-                onPageEditListener.onEdit();
-              }
-              if (displayPageIndexListener != null) {
-                displayPageIndexListener.displayPage(currentPageIndex);
-              }
-              int start = sourcePosition < targetPosition ? sourcePosition : targetPosition;
-              int count = Math.abs(sourcePosition - targetPosition) + 1;
-              notifyItemRangeChanged(start, count);
-            }
-          }
-        };
-    asyncTask.execute();
-  }
-
-  @Override
-  public void onSwaped(
-      RecyclerView.ViewHolder sourceViewHolder, RecyclerView.ViewHolder targetViewHolder) {
-    int sourcePosition = sourceViewHolder.getAdapterPosition();
-    int targetPosition = targetViewHolder.getAdapterPosition();
-    AsyncTask<Void, Void, Boolean> asyncTask =
-        new AsyncTask<Void, Void, Boolean>() {
-          @Override
-          protected Boolean doInBackground(Void... voids) {
-            boolean isSuccess;
-            try {
-              isSuccess = cPdfDocument.exchangePage(sourcePosition, targetPosition);
-            } catch (Exception e) {
-              return false;
+        }
+    }
+
+    public void setAllUnClick(RecyclerView recyclerView) {
+        if (isEdit) {
+            for (int size = selectArr.size() - 1; size >= 0; size--) {
+                int key = selectArr.keyAt(size);
+                selectArr.removeAt(size);
+                RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(key);
+                if (viewHolder != null) {
+                    updateSelectStatus((CPDFThumbnailItemViewHolder) viewHolder);
+                } else {
+                    notifyItemChanged(key);
+                }
             }
-            return isSuccess;
-          }
-
-          @Override
-          protected void onPostExecute(Boolean aBoolean) {
-            super.onPostExecute(aBoolean);
-            if (aBoolean) {
-              notifyDataSetChanged();
-            } else {
+        }
+    }
+
+    public SparseIntArray getSelectArr() {
+        return selectArr;
+    }
 
+    public void setSelectArr(int[] pageNum) {
+        if (pageNum != null) {
+            selectArr.clear();
+            for (int i = 0; i < pageNum.length; i++) {
+                selectArr.put(pageNum[i], 1);
             }
-          }
-        };
-    asyncTask.execute();
-  }
-
-  static class CPDFThumbnailItemViewHolder extends RecyclerView.ViewHolder {
-    private AppCompatImageView ivThumbnailImage;
-    private AppCompatTextView tvPageIndex;
-    private ConstraintLayout clThumbnail;
-    private AppCompatImageView ivSelect;
-
-    private ConstraintLayout clItem;
-
-    public CPDFThumbnailItemViewHolder(@NonNull View itemView) {
-      super(itemView);
-      ivThumbnailImage = itemView.findViewById(R.id.iv_thumbnail);
-      tvPageIndex = itemView.findViewById(R.id.tv_thumbnail_page_index);
-      clThumbnail = itemView.findViewById(R.id.cl_thumbnail);
-      ivSelect = itemView.findViewById(R.id.iv_check_box);
-      clItem = itemView.findViewById(R.id.cl_item);
+        }
+        notifyDataSetChanged();
+    }
+
+    public void setOnPageEditListener(OnPageEditListener onPageEditListener) {
+        this.onPageEditListener = onPageEditListener;
+    }
+
+    @Override
+    public void onSwiped(int adapterPosition) {
+    }
+
+    @Override
+    public boolean onDragging(
+            RecyclerView.ViewHolder sourceViewHolder, RecyclerView.ViewHolder targetViewHolder) {
+        int sourcePosition = sourceViewHolder.getAdapterPosition();
+        int targetPosition = targetViewHolder.getAdapterPosition();
+        notifyItemMoved(sourcePosition, targetPosition);
+        return true;
     }
-  }
 
-  public interface OnPageEditListener {
-    void onEdit();
-  }
+    @Override
+    public void onMoved(
+            RecyclerView.ViewHolder sourceViewHolder, int sourcePosition, int targetPosition) {
+        AsyncTask<Void, Void, Boolean> asyncTask =
+                new AsyncTask<Void, Void, Boolean>() {
+                    @Override
+                    protected Boolean doInBackground(Void... voids) {
+                        boolean isSuccess;
+                        try {
+                            isSuccess = cPdfDocument.movePage(sourcePosition, targetPosition);
+                            if (sourcePosition < targetPosition) { // 往后移动
+                                List<Integer> selected = new ArrayList<>();
+                                for (int i = sourcePosition; i <= targetPosition; i++) {
+                                    if (selectArr.get(i) == 1) {
+                                        selected.add(i);
+                                        selectArr.removeAt(selectArr.indexOfKey(i));
+                                    }
+                                }
+                                for (int i = 0; i < selected.size(); i++) {
+                                    if (selected.get(i) == sourcePosition) {
+                                        continue;
+                                    }
+                                    selectArr.put(selected.get(i) - 1, 1);
+                                }
+                                if (selected.size() > 0) {
+                                    if (selected.get(0) == sourcePosition) {
+                                        selectArr.put(targetPosition, 1);
+                                    }
+                                }
+                            } else { // 往前移动
+                                List<Integer> selected = new ArrayList<>();
+                                for (int i = sourcePosition; i >= targetPosition; i--) {
+                                    if (selectArr.get(i) == 1) {
+                                        selected.add(i);
+                                        selectArr.removeAt(selectArr.indexOfKey(i));
+                                    }
+                                }
+                                for (int i = 0; i < selected.size(); i++) {
+                                    if (selected.get(i) == sourcePosition) {
+                                        continue;
+                                    }
+                                    selectArr.put(selected.get(i) + 1, 1);
+                                }
+                                if (selected.size() > 0) {
+                                    if (selected.get(0) == sourcePosition) {
+                                        selectArr.put(targetPosition, 1);
+                                    }
+                                }
+                            }
+                            if (currentPageIndex == sourcePosition) {
+                                currentPageIndex = targetPosition;
+                            } else if (currentPageIndex == targetPosition) {
+                                if (sourcePosition < targetPosition) {
+                                    currentPageIndex = targetPosition - 1;
+                                } else {
+                                    currentPageIndex = targetPosition + 1;
+                                }
+                            } else {
+                                if (sourcePosition < currentPageIndex && currentPageIndex < targetPosition) {
+                                    currentPageIndex--;
+                                } else if (targetPosition < currentPageIndex && currentPageIndex < sourcePosition) {
+                                    currentPageIndex++;
+                                }
+                            }
+                        } catch (Exception e) {
+                            return false;
+                        }
+                        return isSuccess;
+                    }
+
+                    @Override
+                    protected void onPostExecute(Boolean aBoolean) {
+                        super.onPostExecute(aBoolean);
+                        if (aBoolean) {
+                            if (onPageEditListener != null) {
+                                onPageEditListener.onEdit();
+                            }
+                            if (displayPageIndexListener != null) {
+                                displayPageIndexListener.displayPage(currentPageIndex);
+                            }
+                            int start = sourcePosition < targetPosition ? sourcePosition : targetPosition;
+                            int count = Math.abs(sourcePosition - targetPosition) + 1;
+                            notifyItemRangeChanged(start, count);
+                        }
+                    }
+                };
+        asyncTask.execute();
+    }
+
+    @Override
+    public void onSwaped(
+            RecyclerView.ViewHolder sourceViewHolder, RecyclerView.ViewHolder targetViewHolder) {
+        int sourcePosition = sourceViewHolder.getAdapterPosition();
+        int targetPosition = targetViewHolder.getAdapterPosition();
+        AsyncTask<Void, Void, Boolean> asyncTask =
+                new AsyncTask<Void, Void, Boolean>() {
+                    @Override
+                    protected Boolean doInBackground(Void... voids) {
+                        boolean isSuccess;
+                        try {
+                            isSuccess = cPdfDocument.exchangePage(sourcePosition, targetPosition);
+                        } catch (Exception e) {
+                            return false;
+                        }
+                        return isSuccess;
+                    }
+
+                    @Override
+                    protected void onPostExecute(Boolean aBoolean) {
+                        super.onPostExecute(aBoolean);
+                        if (aBoolean) {
+                            notifyDataSetChanged();
+                        } else {
+
+                        }
+                    }
+                };
+        asyncTask.execute();
+    }
+
+    static class CPDFThumbnailItemViewHolder extends RecyclerView.ViewHolder {
+        private AppCompatImageView ivThumbnailImage;
+        private AppCompatTextView tvPageIndex;
+        private ConstraintLayout clThumbnail;
+        private AppCompatImageView ivSelect;
+
+        private ConstraintLayout clItem;
+
+        public CPDFThumbnailItemViewHolder(@NonNull View itemView) {
+            super(itemView);
+            ivThumbnailImage = itemView.findViewById(R.id.iv_thumbnail);
+            tvPageIndex = itemView.findViewById(R.id.tv_thumbnail_page_index);
+            clThumbnail = itemView.findViewById(R.id.cl_thumbnail);
+            ivSelect = itemView.findViewById(R.id.iv_check_box);
+            clItem = itemView.findViewById(R.id.cl_item);
+        }
+    }
+
+    public interface OnPageEditListener {
+        void onEdit();
+    }
 }

+ 19 - 17
ComPDFKit_Tools/src/main/res/layout/tools_cpdf_tool_bar.xml

@@ -9,30 +9,34 @@
     android:elevation="4dp"
     tools:layout_height="?android:attr/actionBarSize">
 
-    <include
+    <LinearLayout
         android:id="@+id/ll_menu"
-        layout="@layout/tools_cpdf_tool_bar_pdf_view_menu_layout"
-        android:layout_width="wrap_content"
+        android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:animateLayoutChanges="true"
+        android:gravity="end|center_vertical"
+        android:orientation="horizontal"
+        app:layout_constrainedWidth="true"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toEndOf="@id/ll_title"
         app:layout_constraintTop_toTopOf="parent" />
 
     <androidx.appcompat.widget.AppCompatImageView
         android:id="@+id/iv_back_action"
         android:layout_width="40dp"
         android:layout_height="40dp"
-        android:padding="6dp"
         android:layout_marginStart="8dp"
-        android:visibility="gone"
-        tools:visibility="visible"
         android:background="@drawable/tools_common_oval_ripple_in_widget"
+        android:padding="6dp"
+        android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintDimensionRatio="1:1"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"
         app:srcCompat="@drawable/tools_ic_back"
-        app:tint="?attr/colorOnPrimary" />
+        app:tint="?attr/colorOnPrimary"
+        tools:visibility="visible" />
 
     <LinearLayout
         android:id="@+id/ll_title"
@@ -44,29 +48,27 @@
         android:gravity="center_vertical"
         android:paddingHorizontal="4dp"
         app:layout_constrainedWidth="true"
-        app:layout_goneMarginStart="16dp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toStartOf="@id/ll_menu"
         app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintHorizontal_chainStyle="packed"
         app:layout_constraintStart_toEndOf="@id/iv_back_action"
-        app:layout_constraintTop_toTopOf="parent">
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_goneMarginStart="16dp">
 
         <androidx.appcompat.widget.AppCompatTextView
             android:id="@+id/tv_tool_bar_title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:drawableEnd="@drawable/tools_ic_syas_arrow"
+            android:drawablePadding="8dp"
             android:fontFamily="sans-serif-medium"
-            android:textSize="20sp"
-            app:autoSizeMaxTextSize="20sp"
+            android:gravity="center_vertical"
+            android:maxLines="1"
             android:textAppearance="?attr/textAppearanceHeadline6"
-            android:drawablePadding="8dp"
+            android:textSize="16sp"
             app:drawableTint="?attr/colorOnPrimary"
-            android:maxLines="1"
-            android:gravity="center_vertical"
-            app:autoSizeMinTextSize="14sp"
-            app:autoSizeTextType="uniform"
-            tools:text="PDF View" />
+            tools:text="@string/tools_pdf_edit_mode" />
 
     </LinearLayout>
 

+ 0 - 76
ComPDFKit_Tools/src/main/res/layout/tools_cpdf_tool_bar_pdf_view_menu_layout.xml

@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:orientation="horizontal"
-    android:id="@+id/ll_menu"
-    android:gravity="center_vertical"
-    android:layout_height="?android:attr/actionBarSize"
-    android:layout_gravity="center_vertical">
-
-<!--    <androidx.appcompat.widget.AppCompatImageView-->
-<!--        android:id="@+id/iv_tool_bar_thumbnail"-->
-<!--        android:layout_width="40dp"-->
-<!--        android:layout_height="40dp"-->
-<!--        android:layout_margin="10dp"-->
-<!--        android:background="@drawable/tools_common_oval_ripple"-->
-<!--        android:clickable="true"-->
-<!--        android:focusable="true"-->
-<!--        android:padding="8dp"-->
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
-<!--        app:layout_constraintDimensionRatio="1:1"-->
-<!--        app:layout_constraintEnd_toStartOf="@id/iv_tool_bar_search"-->
-<!--        app:layout_constraintTop_toTopOf="parent"-->
-<!--        app:srcCompat="@drawable/tools_ic_thumbnail"-->
-<!--        app:tint="@color/tools_icon_status_color" />-->
-
-
-<!--    <androidx.appcompat.widget.AppCompatImageView-->
-<!--        android:id="@+id/iv_tool_bar_search"-->
-<!--        android:layout_width="40dp"-->
-<!--        android:layout_height="40dp"-->
-<!--        android:layout_margin="10dp"-->
-<!--        android:background="@drawable/tools_common_oval_ripple"-->
-<!--        android:clickable="true"-->
-<!--        android:focusable="true"-->
-<!--        android:padding="8dp"-->
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
-<!--        app:layout_constraintDimensionRatio="1:1"-->
-<!--        app:layout_constraintEnd_toStartOf="@id/iv_tool_bar_bota"-->
-<!--        app:layout_constraintTop_toTopOf="parent"-->
-<!--        app:srcCompat="@drawable/tools_ic_search"-->
-<!--        app:tint="@color/tools_icon_status_color" />-->
-
-<!--    <androidx.appcompat.widget.AppCompatImageView-->
-<!--        android:id="@+id/iv_tool_bar_bota"-->
-<!--        android:layout_width="40dp"-->
-<!--        android:layout_height="40dp"-->
-<!--        android:layout_margin="10dp"-->
-<!--        android:background="@drawable/tools_common_oval_ripple"-->
-<!--        android:clickable="true"-->
-<!--        android:focusable="true"-->
-<!--        android:padding="8dp"-->
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
-<!--        app:layout_constraintDimensionRatio="1:1"-->
-<!--        app:layout_constraintEnd_toStartOf="@id/iv_tool_bar_more"-->
-<!--        app:layout_constraintTop_toTopOf="parent"-->
-<!--        app:srcCompat="@drawable/tools_ic_bookmark"-->
-<!--        app:tint="@color/tools_icon_status_color" />-->
-
-<!--    <androidx.appcompat.widget.AppCompatImageView-->
-<!--        android:id="@+id/iv_tool_bar_more"-->
-<!--        android:layout_width="40dp"-->
-<!--        android:layout_height="40dp"-->
-<!--        android:layout_margin="10dp"-->
-<!--        android:background="@drawable/tools_common_oval_ripple"-->
-<!--        android:clickable="true"-->
-<!--        android:focusable="true"-->
-<!--        android:padding="8dp"-->
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
-<!--        app:layout_constraintDimensionRatio="1:1"-->
-<!--        app:layout_constraintEnd_toEndOf="parent"-->
-<!--        app:layout_constraintTop_toTopOf="parent"-->
-<!--        app:srcCompat="@drawable/tools_ic_more"-->
-<!--        app:tint="@color/tools_icon_status_color" />-->
-
-
-</LinearLayout>

+ 2 - 0
ComPDFKit_Tools/src/main/res/layout/tools_pdf_document_fragment.xml

@@ -104,11 +104,13 @@
         <com.compdfkit.tools.annotation.pdfannotationbar.CAnnotationToolbar
             android:id="@+id/annotation_tool_bar"
             android:layout_width="match_parent"
+            android:visibility="gone"
             android:layout_height="?android:attr/actionBarSize" />
 
         <com.compdfkit.tools.contenteditor.CEditToolbar
             android:id="@+id/edit_tool_bar"
             android:layout_width="match_parent"
+            android:visibility="gone"
             android:layout_height="?android:attr/actionBarSize" />
 
         <com.compdfkit.tools.forms.pdfformbar.CFormToolbar

+ 1 - 1
PDFViewer/build.gradle

@@ -56,5 +56,5 @@ dependencies {
     implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
     api project(path: ':ComPDFKit_Tools')
     // or
-//    implementation ('com.compdf:compdfkit-ui:2.1.1')
+//    implementation ('com.compdf:compdfkit-ui:2.1.2')
 }

+ 3 - 3
config.gradle

@@ -3,10 +3,10 @@ ext {
             COMPILESDK: 33,
             MINSDK: 21,
             TARGETSDK: 33,
-            VERSIONCODE: 1014
+            VERSIONCODE: 1015
     ]
     sdk = [
-            COMPDFKIT_SDK_VERSION : "2.1.1",
-            COMPDFKIT_SDK_BUILD_TAG : "build_dev_2.1.1_8485c6e5b_202408091626"
+            COMPDFKIT_SDK_VERSION : "2.1.2",
+            COMPDFKIT_SDK_BUILD_TAG : "build_dev_2.1.2_8485c6e5b_202408091626"
     ]
 }