فهرست منبع

PDFTool(Android) - 压缩功能新增翻译、云朵边框时不可调节线条间隔

liuxiaolong 1 روز پیش
والد
کامیت
166ada144e
18فایلهای تغییر یافته به همراه111 افزوده شده و 16 حذف شده
  1. 3 7
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdffreetext/CFreeTextStyleFragment.java
  2. 8 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfshape/CShapeStyleFragment.java
  3. 7 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/view/sliderbar/CSliderBar.java
  4. 6 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/view/sliderbar/CSliderBarValueView.java
  5. 33 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/viewutils/EditTextUtils.java
  6. 5 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/CAnnotStyle.java
  7. 3 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/compress/CPDFCompressDialog.java
  8. 6 0
      ComPDFKit_Tools/src/main/res/color/tools_seek_bar_progress_main_progress.xml
  9. 6 0
      ComPDFKit_Tools/src/main/res/color/tools_seek_bar_progress_secondary_progress.xml
  10. 7 0
      ComPDFKit_Tools/src/main/res/color/tools_slider_bar_value_text_color.xml
  11. 3 3
      ComPDFKit_Tools/src/main/res/drawable/tools_seek_bar_progress_drawable.xml
  12. 1 1
      ComPDFKit_Tools/src/main/res/drawable/tools_seek_bar_thumb_drawable.xml
  13. 2 2
      ComPDFKit_Tools/src/main/res/layout/tools_compress_dialog.xml
  14. 1 1
      ComPDFKit_Tools/src/main/res/layout/tools_slider_bar_value_layout.xml
  15. 1 0
      ComPDFKit_Tools/src/main/res/layout/tools_verify_password_dialog_fragment.xml
  16. 14 0
      ComPDFKit_Tools/src/main/res/values-zh-rCN/tools_strings.xml
  17. 4 2
      ComPDFKit_Tools/src/main/res/values/tools_strings.xml
  18. 1 0
      PDFViewer/build.gradle

+ 3 - 7
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdffreetext/CFreeTextStyleFragment.java

@@ -122,13 +122,9 @@ public class CFreeTextStyleFragment extends CBasicPropertiesFragment implements
         });
         viewModel.addStyleChangeListener(this);
 
-        fontView.setFontChangeListener(new CPDFFontView.CFontChangeListener() {
-
-            @Override
-            public void font(String psName) {
-                if (viewModel != null) {
-                    viewModel.getStyle().setExternFontName(psName);
-                }
+        fontView.setFontChangeListener(psName -> {
+            if (viewModel != null) {
+                viewModel.getStyle().setExternFontName(psName);
             }
         });
     }

+ 8 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfshape/CShapeStyleFragment.java

@@ -193,6 +193,7 @@ public class CShapeStyleFragment extends CBasicPropertiesFragment {
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                 CPDFAnnotation.CPDFBorderEffectType bordEffectType = bordEffectTypeAdapter.list.get(position);
                 viewModel.getStyle().setBordEffectType(bordEffectType);
+                enableDashSeekBar(bordEffectType == CPDFAnnotation.CPDFBorderEffectType.CPDFBorderEffectTypeSolid);
             }
 
             @Override
@@ -202,6 +203,13 @@ public class CShapeStyleFragment extends CBasicPropertiesFragment {
         });
     }
 
+    private void enableDashSeekBar(boolean enable){
+        dashedSliderBar.setEnabled(enable);
+        if (!enable){
+            dashedSliderBar.setProgress(0);
+        }
+    }
+
     private void updateBorderColor(int color) {
         if (viewModel != null) {
             CAnnotStyle style = viewModel.getStyle();

+ 7 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/view/sliderbar/CSliderBar.java

@@ -154,6 +154,13 @@ public class CSliderBar extends FrameLayout implements SeekBar.OnSeekBarChangeLi
         tvTitle.setText(title);
     }
 
+    @Override
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        seekBar.setEnabled(enabled);
+        sliderBarValueView.setEnabled(enabled);
+    }
+
     private void updateSeekBarValue(int value, boolean stop) {
         int v = value + sliderBarMinValue;
         if (v > sliderBarMaxValue){

+ 6 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/view/sliderbar/CSliderBarValueView.java

@@ -90,4 +90,10 @@ public class CSliderBarValueView extends FrameLayout {
         this.valueUnit = valueUnit;
         setValue(value);
     }
+
+    @Override
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        textView.setEnabled(enabled);
+    }
 }

+ 33 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/viewutils/EditTextUtils.java

@@ -0,0 +1,33 @@
+/**
+ * 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.common.utils.viewutils;
+
+import android.text.InputFilter;
+import android.text.Spanned;
+
+
+public class EditTextUtils {
+
+
+    public static InputFilter inputRangeFilter(int minValue , int maxValue){
+        return (source, start, end, dest, dstart, dend) -> {
+            try {
+                String newInput = dest.toString().substring(0, dstart) + source + dest.toString().substring(dend);
+                int input = Integer.parseInt(newInput);
+
+                if (input >= minValue && input <= maxValue) {
+                    return null;
+                }
+            } catch (NumberFormatException e) {
+            }
+            return "";
+        };
+    }
+}

+ 5 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/CAnnotStyle.java

@@ -454,7 +454,10 @@ public class CAnnotStyle implements Serializable {
     public void setEditTextUnderLine(boolean editTextUnderLine) {
         boolean update = this.editTextUnderLine != editTextUnderLine;
         this.editTextUnderLine = editTextUnderLine;
+        setUpdatePropertyType(EditUpdatePropertyType.UnderLine);
         updateEditTextUnderLine(editTextUnderLine, update);
+        setUpdatePropertyType(EditUpdatePropertyType.All);
+
     }
 
     public boolean isEditTextUnderLine() {
@@ -464,7 +467,9 @@ public class CAnnotStyle implements Serializable {
     public void setEditTextStrikeThrough(boolean editTextStrikeThrough) {
         boolean update = this.editTextStrikeThrough != editTextStrikeThrough;
         this.editTextStrikeThrough = editTextStrikeThrough;
+        setUpdatePropertyType(EditUpdatePropertyType.StrikeThrough);
         updateEditTextStrikeThrough(editTextStrikeThrough, update);
+        setUpdatePropertyType(EditUpdatePropertyType.All);
     }
 
     public boolean isEditTextStrikeThrough() {

+ 3 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/compress/CPDFCompressDialog.java

@@ -11,6 +11,7 @@ package com.compdfkit.tools.compress;
 
 import android.net.Uri;
 import android.os.Environment;
+import android.text.InputFilter;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.CompoundButton;
@@ -31,6 +32,7 @@ import com.compdfkit.tools.common.utils.CUriUtil;
 import com.compdfkit.tools.common.utils.activitycontracts.CSelectPDFDocumentResultContract;
 import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils;
 import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
+import com.compdfkit.tools.common.utils.viewutils.EditTextUtils;
 import com.compdfkit.tools.common.views.CToolBar;
 import com.compdfkit.tools.common.views.CVerifyPasswordDialogFragment;
 import com.compdfkit.tools.common.views.directory.CFileDirectoryDialog;
@@ -149,6 +151,7 @@ public class CPDFCompressDialog extends CBasicBottomSheetDialogFragment implemen
         rbQualityHigh.setOnCheckedChangeListener(this);
         rbQualityCustom.setOnCheckedChangeListener(this);
         radioButtons.addAll(Arrays.asList(rbQualityLow, rbQualityStandard, rbQualityHigh, rbQualityCustom));
+        etCustomQuality.setFilters(new InputFilter[]{EditTextUtils.inputRangeFilter(1, 120)});
     }
 
     @Override

+ 6 - 0
ComPDFKit_Tools/src/main/res/color/tools_seek_bar_progress_main_progress.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="?attr/colorAccent" android:state_enabled="true" />
+    <item android:color="#B31460F3" android:state_enabled="false"/>
+
+</selector>

+ 6 - 0
ComPDFKit_Tools/src/main/res/color/tools_seek_bar_progress_secondary_progress.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="#5C1460F3" android:state_enabled="true"/>
+    <item android:color="#1A1460F3" android:state_enabled="false"/>
+
+</selector>

+ 7 - 0
ComPDFKit_Tools/src/main/res/color/tools_slider_bar_value_text_color.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:color="?android:attr/textColorPrimary" android:state_enabled="true"/>
+    <item android:color="?android:attr/textColorHint" android:state_enabled="false"/>
+
+</selector>

+ 3 - 3
ComPDFKit_Tools/src/main/res/drawable/tools_seek_bar_progress_drawable.xml

@@ -8,9 +8,9 @@
     </item>
 
     <item android:id="@android:id/secondaryProgress">
-        <clip>
+        <clip android:layout_width="match_parent">
             <shape>
-                <solid android:color="#5C1460F3" />
+                <solid android:color="@color/tools_seek_bar_progress_secondary_progress" />
             </shape>
         </clip>
     </item>
@@ -18,7 +18,7 @@
     <item android:id="@android:id/progress">
         <clip>
             <shape>
-                <solid android:color="?attr/colorAccent" />
+                <solid android:color="@color/tools_seek_bar_progress_main_progress" />
             </shape>
         </clip>
 

+ 1 - 1
ComPDFKit_Tools/src/main/res/drawable/tools_seek_bar_thumb_drawable.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="oval">
-    <solid android:color="?attr/colorAccent" />
+    <solid android:color="@color/tools_seek_bar_progress_main_progress" />
     <size
         android:width="12dp"
         android:height="12dp" />

+ 2 - 2
ComPDFKit_Tools/src/main/res/layout/tools_compress_dialog.xml

@@ -11,7 +11,7 @@
         android:layout_width="match_parent"
         android:layout_height="56dp"
         android:textSize="18sp"
-        android:title="@string/tools_compressed"
+        android:title="@string/tools_compress"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
@@ -72,7 +72,7 @@
                 android:layout_height="30dp"
                 android:layout_marginStart="16dp"
                 android:layout_marginTop="18dp"
-                android:src="@drawable/tools_ic_pdf"
+                app:srcCompat="@drawable/tools_ic_pdf"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toBottomOf="@id/tv_selected_file" />
 

+ 1 - 1
ComPDFKit_Tools/src/main/res/layout/tools_slider_bar_value_layout.xml

@@ -11,7 +11,7 @@
         android:id="@+id/tv_title"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textColor="?android:attr/textColorPrimary"
+        android:textColor="@color/tools_slider_bar_value_text_color"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"

+ 1 - 0
ComPDFKit_Tools/src/main/res/layout/tools_verify_password_dialog_fragment.xml

@@ -115,6 +115,7 @@
     <androidx.appcompat.widget.AppCompatButton
         android:id="@+id/btn_confirm"
         android:layout_width="match_parent"
+        android:enabled="false"
         android:layout_height="48dp"
         android:layout_marginHorizontal="16dp"
         android:layout_marginTop="48dp"

+ 14 - 0
ComPDFKit_Tools/src/main/res/values-zh-rCN/tools_strings.xml

@@ -516,4 +516,18 @@
     <string name="tools_total">共计%d条</string>
     <string name="tools_reply">回复</string>
     <string name="tools_view_reply">查看回复</string>
+
+    <string name="tools_style_title">效果</string>
+    <string name="tools_line_type">线型</string>
+    <string name="tools_compress">压缩</string>
+    <string name="tools_selected_file">选中文档</string>
+    <string name="tools_compress_quality">压缩质量</string>
+    <string name="tools_change">更换</string>
+    <string name="tools_low_quality">低</string>
+    <string name="tools_standard_quality">标准</string>
+    <string name="tools_high_quality">高</string>
+    <string name="tools_custom_quality">自定义</string>
+    <string name="tools_please_enter_percentage">请输入百分比</string>
+    <string name="tools_save_path">文件存储路径</string>
+    <string name="tools_compressed_successfully">压缩成功</string>
 </resources>

+ 4 - 2
ComPDFKit_Tools/src/main/res/values/tools_strings.xml

@@ -529,8 +529,7 @@
 
 <!--    v2.2.0 -->
     <string name="tools_style_title">Style</string>
-    <string name="tools_line_type">Line Type</string>
-    <string name="tools_compressed">Compressed</string>
+    <string name="tools_line_type">Line and Border Style</string>
     <string name="tools_compress">Compress</string>
     <string name="tools_selected_file">Selected File</string>
     <string name="tools_compress_quality">Compress Quality</string>
@@ -543,4 +542,7 @@
     <string name="tools_save_path">Saving Path</string>
     <string name="tools_compressed_successfully">Compressed successfully!</string>
 
+
+
+
 </resources>

+ 1 - 0
PDFViewer/build.gradle

@@ -55,6 +55,7 @@ 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.1.3')
 }