浏览代码

PDFTool(Android) - v1.13.0 release

liuxiaolong 9 月之前
父节点
当前提交
0c05f06ed0

+ 2 - 0
ComPDFKit_Tools/build.gradle

@@ -62,3 +62,5 @@ dependencies {
     api 'com.google.android.material:material:1.8.0'
     api 'androidx.constraintlayout:constraintlayout:2.1.4'
 }
+
+configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' }

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

@@ -250,6 +250,7 @@
     "enableSliderBar": true,
     "enablePageIndicator": true,
     "pageSpacing": 10,
-    "pageScale": 1.0
+    "pageScale": 1.0,
+    "pageSameWidth": true
   }
 }

+ 1 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFApplyConfigUtil.java

@@ -91,6 +91,7 @@ public class CPDFApplyConfigUtil {
             readerView.setContinueMode(readerViewConfig.continueMode);
             readerView.setVerticalMode(readerViewConfig.verticalMode);
             readerView.setCropMode(readerViewConfig.cropMode);
+            readerView.setPageSameWidth(readerViewConfig.pageSameWidth);
             switch (readerViewConfig.themes) {
                 case Dark:
                     readerView.setReadBackgroundColor(ContextCompat.getColor(fragment.getContext(), R.color.tools_themes_dark));

+ 1 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFConfigurationUtils.java

@@ -167,6 +167,7 @@ public class CPDFConfigurationUtils {
         readerViewConfig.enablePageIndicator = jsonObject.optBoolean("enablePageIndicator", true);
         readerViewConfig.pageSpacing = jsonObject.optInt("pageSpacing", 10);
         readerViewConfig.pageScale = Math.max((float) jsonObject.optDouble("pageScale", 1.0), 1.0F);
+        readerViewConfig.pageSameWidth = jsonObject.optBoolean("pageSameWidth", true);
         return readerViewConfig;
     }
 

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

@@ -17,8 +17,6 @@ import static com.compdfkit.tools.contenteditor.CEditToolbar.SELECT_AREA_TEXT;
 import android.Manifest;
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
 import android.content.res.Configuration;
 import android.graphics.Paint;
 import android.net.Uri;
@@ -27,7 +25,6 @@ import android.os.Bundle;
 import android.os.Environment;
 import android.provider.Settings;
 import android.text.TextUtils;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -55,7 +52,6 @@ import com.compdfkit.tools.common.contextmenu.CPDFContextMenuHelper;
 import com.compdfkit.tools.common.pdf.config.CPDFConfiguration;
 import com.compdfkit.tools.common.pdf.config.ToolbarConfig;
 import com.compdfkit.tools.common.utils.CFileUtils;
-import com.compdfkit.tools.common.utils.CLog;
 import com.compdfkit.tools.common.utils.CPermissionUtil;
 import com.compdfkit.tools.common.utils.CToastUtil;
 import com.compdfkit.tools.common.utils.activitycontracts.CSelectPDFDocumentResultContract;
@@ -95,7 +91,6 @@ import com.compdfkit.ui.reader.CPDFReaderView;
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 
@@ -361,6 +356,11 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
             ToolbarConfig toolbarConfig = cpdfConfiguration.toolbarConfig;
             for (ToolbarConfig.ToolbarAction androidAvailableAction : toolbarConfig.androidAvailableActions) {
                 switch (androidAvailableAction) {
+                    case Back:
+                        pdfToolBar.addBackPressedAction(v -> {
+                            onBackPressedCallback.handleOnBackPressed();
+                        });
+                        break;
                     case Thumbnail:
                         pdfToolBar.addAction(R.drawable.tools_ic_thumbnail, v -> showPageEdit(pdfView, false, () -> {
                             if (curEditMode > CPDFEditPage.LoadNone && pdfToolBar.getMode() == CPreviewMode.Edit) {
@@ -414,7 +414,6 @@ public class CPDFDocumentFragment extends CBasicPDFFragment {
                             dialogFragment.show(getChildFragmentManager(), "annotationList");
                         });
                         break;
-
                     case Menu:
                         pdfToolBar.addAction(R.drawable.tools_ic_more, this::showToolbarMenuDialog);
                         break;

+ 4 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/config/ReaderViewConfig.java

@@ -38,6 +38,8 @@ public class ReaderViewConfig implements Serializable {
 
     public float pageScale = 1.0F;
 
+    public boolean pageSameWidth = true;
+
     @NonNull
     @Override
     public String toString() {
@@ -52,7 +54,8 @@ public class ReaderViewConfig implements Serializable {
                 "enableSliderBar:" + enableSliderBar + ", " +
                 "enablePageIndicator:" + enablePageIndicator + ", " +
                 "pageSpacing:" + pageSpacing + ", " +
-                "pageScale:" + pageScale + ", ";
+                "pageScale:" + pageScale + ", " +
+                "pageSameWidth:" + pageSameWidth + ", ";
         return stringBuilder;
     }
 

+ 9 - 6
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/config/ToolbarConfig.java

@@ -1,15 +1,18 @@
+/**
+ * Copyright © 2014-2023 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.common.pdf.config;
 
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.List;
 
-/**
- * @classname:
- * @author: LiuXiaoLong
- * @date: 2023/12/7
- * description:
- */
+
 public class ToolbarConfig implements Serializable {
 
     public ToolbarConfig() {

+ 8 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/CPDFToolBar.java

@@ -70,6 +70,8 @@ public class CPDFToolBar extends FrameLayout {
 
     private LinearLayout llMenu;
 
+    private AppCompatImageView ivBack;
+
     private LinkedHashSet<CPreviewMode> previewModes = new LinkedHashSet<>();
 
     private CPreviewMode currentPreviewMode = CPreviewMode.Viewer;
@@ -95,6 +97,7 @@ public class CPDFToolBar extends FrameLayout {
         clMainToolbar.setOnClickListener(v -> {});
         llMenu = findViewById(R.id.ll_menu);
         tvToolBarTitle = findViewById(R.id.tv_tool_bar_title);
+        ivBack = findViewById(R.id.iv_back_action);
         LinearLayout llTitle = findViewById(R.id.ll_title);
         llTitle.setOnClickListener(v -> {
             if (previewModes != null && previewModes.size() > 1) {
@@ -159,6 +162,11 @@ public class CPDFToolBar extends FrameLayout {
         }
     }
 
+    public void addBackPressedAction(View.OnClickListener listener){
+        ivBack.setVisibility(View.VISIBLE);
+        ivBack.setOnClickListener(listener);
+    }
+
     public void setPreviewModeChangeListener(CModeSwitchDialogFragment.OnPreviewModeChangeListener changeListener) {
         this.changeListener = changeListener;
     }

+ 20 - 3
ComPDFKit_Tools/src/main/res/layout/tools_cpdf_tool_bar.xml

@@ -18,20 +18,37 @@
         app:layout_constraintEnd_toEndOf="parent"
         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"
+        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="@color/tools_on_primary" />
+
     <LinearLayout
         android:id="@+id/ll_title"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_marginVertical="4dp"
-        android:layout_marginStart="16dp"
+        android:layout_marginStart="4dp"
         android:background="@drawable/tools_common_btn_corner_ripple"
         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/cl_menu"
+        app:layout_constraintEnd_toStartOf="@id/ll_menu"
         app:layout_constraintHorizontal_bias="0"
-        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintStart_toEndOf="@id/iv_back_action"
         app:layout_constraintTop_toTopOf="parent">
 
         <androidx.appcompat.widget.AppCompatTextView

+ 3 - 1
ComPDFKit_Tools/src/main/res/layout/tools_cpdf_tool_bar_pdf_view_menu_action.xml

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    xmlns:android="http://schemas.android.com/apk/res/android" >
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools">
 
     <androidx.appcompat.widget.AppCompatImageView xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -18,6 +19,7 @@
         app:layout_constraintDimensionRatio="1:1"
         app:layout_constraintTop_toTopOf="parent"
         app:srcCompat="@drawable/tools_ic_thumbnail"
+        tools:src="@drawable/tools_ic_back"
         app:tint="@color/tools_icon_status_color" />
 </FrameLayout>
 

+ 1 - 1
compdfkit-tools-mavencentral.gradle

@@ -1,7 +1,7 @@
 apply plugin: 'maven-publish'
 apply plugin: 'signing'
 
-def PUBLISH_VERSION = '1.13.0-SNAPSHOT'
+def PUBLISH_VERSION = '1.13.0'
 def PUBLISH_GROUP_ID = 'com.compdf'
 def PUBLISH_ARTIFACT_ID = 'compdfkit-tools'