Pārlūkot izejas kodu

PDFTools(Android) - 1.新增Note编辑弹窗 2.新增属性监听 3.新增注释列表颜色修改

liuxiaolong 1 gadu atpakaļ
vecāks
revīzija
091a4dffb3
48 mainītis faili ar 1414 papildinājumiem un 372 dzēšanām
  1. 18 13
      annotation-ctrl-demo/src/main/java/com/compdfkit/demo/annotation/MainActivity.java
  2. 0 1
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfannotationlist/CPDFAnnotationListFragment.java
  3. 24 21
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/CAnnotStyleDialogFragment.java
  4. 141 38
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfattr/CAnnotStyle.java
  5. 23 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/CBasicOnStyleChangeListener.java
  6. 15 5
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/adapter/CAnnotPropertiesFragmentAdapter.java
  7. 1 6
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/data/CPropertiesFragmentDatas.java
  8. 229 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/manager/CAnnotStyleManager.java
  9. 21 22
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/viewmodel/CAnnotStyleViewModel.java
  10. 0 144
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfattr/CAnnotAttr.java
  11. 41 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdflnk/CInkStyleFragment.java
  12. 1 1
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfmarkup/CLinkStyleFragment.java
  13. 42 18
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfmarkup/CMarkupStyleFragment.java
  14. 109 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfnote/CNoteEditDialog.java
  15. 22 10
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfnote/CNoteStyleFragment.java
  16. 18 2
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfnote/CPDFtextAnnotAttachHelper.java
  17. 6 6
      compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/adapter/CWrapHeightPageChangeCallback.java
  18. 6 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/utils/adapter/CBaseQuickViewHolder.java
  19. 23 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/utils/viewutils/CDimensUtils.java
  20. 16 3
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/CAnnotationToolbar.java
  21. 50 6
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/adapter/CPDFAnnotationToolListAdapter.java
  22. 18 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/bean/CAnnotToolBean.java
  23. 24 7
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/data/CAnnotationToolDatas.java
  24. 12 6
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/basic/CBasicPropertiesFragment.java
  25. 52 13
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/CColorPickerFragment.java
  26. 7 7
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorAlphaSliderView.java
  27. 42 21
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorPickerView.java
  28. 1 3
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorRectShowView.java
  29. 0 5
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorRectView.java
  30. 78 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CAnnotMarkupPreviewView.java
  31. 51 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CAnnotNotePreviewView.java
  32. 38 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CBasicAnnotPreviewView.java
  33. 125 0
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CStylePreviewView.java
  34. 0 1
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/sliderbar/CSliderBar.java
  35. 1 3
      compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfview/CPDFViewCtrl.java
  36. 5 0
      compdfkit-tools/src/main/res/drawable/tools_ic_note.xml
  37. 5 0
      compdfkit-tools/src/main/res/drawable/tools_ic_save.xml
  38. 5 0
      compdfkit-tools/src/main/res/drawable/tools_properties_note_dialog_bg.xml
  39. 15 2
      compdfkit-tools/src/main/res/layout/tools_annot_list_item.xml
  40. 31 0
      compdfkit-tools/src/main/res/layout/tools_annot_preview_markup.xml
  41. 21 0
      compdfkit-tools/src/main/res/layout/tools_annot_preview_note.xml
  42. 1 1
      compdfkit-tools/src/main/res/layout/tools_common_slider_bar.xml
  43. 4 3
      compdfkit-tools/src/main/res/layout/tools_properties_markup_style_fragment.xml
  44. 49 0
      compdfkit-tools/src/main/res/layout/tools_properties_note_edit_dialog.xml
  45. 4 3
      compdfkit-tools/src/main/res/layout/tools_properties_note_style_fragment.xml
  46. 17 0
      compdfkit-tools/src/main/res/values/tools_attrs.xml
  47. 1 1
      compdfkit-tools/src/main/res/values/tools_strings.xml
  48. 1 0
      viewer-ctrl-demo/src/main/java/com/compdfkit/demo/viewer/PDFViewerSampleActivity.java

+ 18 - 13
annotation-ctrl-demo/src/main/java/com/compdfkit/demo/annotation/MainActivity.java

@@ -1,19 +1,20 @@
 package com.compdfkit.demo.annotation;
 
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 
 import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.PopupMenu;
 import androidx.core.content.ContextCompat;
 
+import com.compdfkit.core.annotation.CPDFTextAnnotation;
 import com.compdfkit.demo.annotation.databinding.ActivityMainBinding;
+import com.compdfkit.tools.annotation.pdfproperties.pdfnote.CPDFtextAnnotAttachHelper;
+import com.compdfkit.tools.annotation.pdfproperties.pdfnote.CPDFtextAnnotImpl;
 import com.compdfkit.tools.common.utils.animation.CFillScreenManager;
 import com.compdfkit.tools.common.utils.window.CPDFToolbarPopupMenu;
 import com.compdfkit.tools.common.views.CPDFToolBar;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotAttr;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.manager.CAnnotStyleManager;
 import com.compdfkit.tools.common.utils.task.CExtractAssetFileTask;
 import com.compdfkit.tools.common.views.pdfbota.CPDFBOTA;
 import com.compdfkit.tools.common.views.pdfbota.CPDFBotaDialogFragment;
@@ -41,6 +42,7 @@ public class MainActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         binding = ActivityMainBinding.inflate(getLayoutInflater());
         setContentView(binding.getRoot());
+        binding.pdfView.setAllowAddAndEditAnnot(true);
         //Extract PDF files from the Android assets folder
         CExtractAssetFileTask.extract(this, QUICK_START_GUIDE, QUICK_START_GUIDE, (filePath) -> binding.pdfView.openPDF(filePath));
         initAnnotationAttributes();
@@ -48,21 +50,21 @@ public class MainActivity extends AppCompatActivity {
         initSearchBar();
     }
 
-    private void initListener(){
+    private void initListener() {
         screenManager.bindTopToolView(binding.flTool);
         screenManager.bindBottomToolViewList(binding.annotationToolBar);
         screenManager.bindLeftToolViewList(binding.pdfView.indicatorView);
         screenManager.bindRightToolViewList(binding.pdfView.slideBar);
-        binding.pdfView.setOnTapMainDocAreaCallback(()->{
+        binding.pdfView.setOnTapMainDocAreaCallback(() -> {
             screenManager.fillScreenChange(binding.flTool.getVisibility() == View.VISIBLE);
         });
 
         binding.pdfToolBar.addMode(CPDFToolbarPopupMenu.PreviewMode.Annotation);
         binding.pdfToolBar.setPreviewModeChangeListener((mode, title) -> {
-            if (mode == CPDFToolbarPopupMenu.PreviewMode.PDFView){
+            if (mode == CPDFToolbarPopupMenu.PreviewMode.PDFView) {
                 screenManager.hideFromBottom(binding.annotationToolBar, 200);
                 screenManager.removeToolView(binding.annotationToolBar);
-            }else {
+            } else {
                 screenManager.bindBottomToolViewList(binding.annotationToolBar);
                 screenManager.showFromBottom(binding.annotationToolBar, 200);
             }
@@ -87,10 +89,10 @@ public class MainActivity extends AppCompatActivity {
             CPDFBotaFragmentTabs annotationTab = new CPDFBotaFragmentTabs(CPDFBOTA.ANNOTATION, getString(R.string.tools_annotations));
             CPDFBotaFragmentTabs outlineTab = new CPDFBotaFragmentTabs(CPDFBOTA.OUTLINE, getString(R.string.tools_outline));
             CPDFBotaFragmentTabs bookmarkTab = new CPDFBotaFragmentTabs(CPDFBOTA.BOOKMARKS, getString(R.string.tools_bookmarks));
-            if (binding.pdfToolBar.getMode() == CPDFToolbarPopupMenu.PreviewMode.PDFView){
+            if (binding.pdfToolBar.getMode() == CPDFToolbarPopupMenu.PreviewMode.PDFView) {
                 tabs.add(outlineTab);
                 tabs.add(bookmarkTab);
-            }else {
+            } else {
                 tabs.add(outlineTab);
                 tabs.add(bookmarkTab);
                 tabs.add(annotationTab);
@@ -103,12 +105,12 @@ public class MainActivity extends AppCompatActivity {
         });
 
         binding.pdfToolBar.setMoreMenuListener(menu -> {
-            if (menu == CPDFToolBar.MoreMenu.DocumentInfo){
+            if (menu == CPDFToolBar.MoreMenu.DocumentInfo) {
                 CPDFDocumentInfoDialogFragment infoDialogFragment = CPDFDocumentInfoDialogFragment.newInstance();
                 infoDialogFragment.initWithPDFView(binding.pdfView);
                 infoDialogFragment.show(getSupportFragmentManager(), "documentInfoDialogFragment");
-            }else {
-                CPDFDisplaySettingDialogFragment displaySettingDialogFragment =  CPDFDisplaySettingDialogFragment.newInstance();
+            } else {
+                CPDFDisplaySettingDialogFragment displaySettingDialogFragment = CPDFDisplaySettingDialogFragment.newInstance();
                 displaySettingDialogFragment.initWithPDFView(binding.pdfView);
                 displaySettingDialogFragment.show(getSupportFragmentManager(), "displaySettingsDialog");
             }
@@ -144,7 +146,8 @@ public class MainActivity extends AppCompatActivity {
 
     private void initAnnotationAttributes() {
         int defaultColor = ContextCompat.getColor(this, R.color.tools_annotation_markup_default_color);
-        new CAnnotAttr.Builder(binding.pdfView)
+        new CAnnotStyleManager.Builder(binding.pdfView)
+                .setColor(CAnnotationType.TEXT, defaultColor)
                 .setMarkup(CAnnotationType.HIGHLIGHT, defaultColor, 255)
                 .setMarkup(CAnnotationType.UNDERLINE, defaultColor, 255)
                 .setMarkup(CAnnotationType.SQUIGGLY, defaultColor, 255)
@@ -154,5 +157,7 @@ public class MainActivity extends AppCompatActivity {
                 .setShape(CAnnotationType.LINE, defaultColor, 255, defaultColor, 255, 5)
                 .setInkAttribute(defaultColor, 255)
                 .init();
+        binding.pdfView.getCPdfReaderView().getAnnotImplRegistry().registAttachHelper(CPDFTextAnnotation.class, CPDFtextAnnotAttachHelper.class);
+        binding.pdfView.getCPdfReaderView().getAnnotImplRegistry().registImpl(CPDFTextAnnotation.class, CPDFtextAnnotImpl.class);
     }
 }

+ 0 - 1
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfannotationlist/CPDFAnnotationListFragment.java

@@ -72,5 +72,4 @@ public class CPDFAnnotationListFragment  extends Fragment {
     public void setPDFDisplayPageIndexListener(COnSetPDFDisplayPageIndexListener displayPageIndexListener) {
         this.displayPageIndexListener = displayPageIndexListener;
     }
-
 }

+ 24 - 21
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/CAnnotStyleDialogFragment.java

@@ -1,39 +1,32 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ * <p>
+ * 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.annotation.pdfproperties;
 
-import android.animation.ObjectAnimator;
 import android.os.Bundle;
-import android.util.Log;
-import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
-import android.view.animation.LinearInterpolator;
-import android.widget.TextSwitcher;
-import android.widget.TextView;
-import android.widget.ViewSwitcher;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.appcompat.widget.AppCompatImageView;
 import androidx.appcompat.widget.AppCompatTextView;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.fragment.app.Fragment;
-import androidx.interpolator.view.animation.FastOutLinearInInterpolator;
 import androidx.lifecycle.ViewModelProvider;
 import androidx.viewpager2.widget.ViewPager2;
 
 import com.compdfkit.tools.R;
-import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.adapter.CAnnotPropertiesFragmentAdapter;
-import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.adapter.CWrapHeightPageChangeCallback;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.adapter.CAnnotStyleFragmentAdapter;
+import com.compdfkit.tools.common.utils.CWrapHeightPageChangeCallback;
 import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.viewmodel.CAnnotStyleViewModel;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
-import com.compdfkit.tools.common.utils.dialog.CDialogFragmentUtil;
-import com.compdfkit.tools.common.utils.transformer.CascadeTransformer;
-import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
-import com.compdfkit.tools.common.views.CToolBar;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
-import com.google.android.material.bottomsheet.BottomSheetBehavior;
 import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
 
 import java.util.ArrayList;
@@ -42,7 +35,6 @@ import java.util.List;
 
 public class CAnnotStyleDialogFragment extends BottomSheetDialogFragment implements CBasicPropertiesFragment.OnSwitchFragmentListener {
 
-
     private AppCompatImageView ivPreviousFragment;
 
     private AppCompatImageView ivClose;
@@ -55,6 +47,8 @@ public class CAnnotStyleDialogFragment extends BottomSheetDialogFragment impleme
 
     private CAnnotStyleViewModel viewModel;
 
+    private List<CAnnotStyle.OnAnnotStyleChangeListener> annotStyleChangeListenerList = new ArrayList<>();
+
     public static CAnnotStyleDialogFragment newInstance(CAnnotStyle style) {
         CAnnotStyleDialogFragment dialogFragment = new CAnnotStyleDialogFragment();
         dialogFragment.setStyle(style);
@@ -65,11 +59,16 @@ public class CAnnotStyleDialogFragment extends BottomSheetDialogFragment impleme
         this.style = style;
     }
 
+    public CAnnotStyle getStyle(){
+        return viewModel != null ? viewModel.getStyle() : null;
+    }
+
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setStyle(STYLE_NORMAL, R.style.Tools_Base_Theme_BottomSheetDialogStyle);
         viewModel = new ViewModelProvider(getActivity()).get(CAnnotStyleViewModel.class);
+        style.addStyleChangeListener(annotStyleChangeListenerList);
         viewModel.setStyle(style);
     }
 
@@ -98,7 +97,7 @@ public class CAnnotStyleDialogFragment extends BottomSheetDialogFragment impleme
 
     private void initViewPager() {
         if (style != null) {
-            CAnnotPropertiesFragmentAdapter adapter = new CAnnotPropertiesFragmentAdapter(style, getChildFragmentManager(), getLifecycle());
+            CAnnotStyleFragmentAdapter adapter = new CAnnotStyleFragmentAdapter(style, getChildFragmentManager(), getLifecycle());
             adapter.setSwitchFragmentListener(this);
             viewPager.setAdapter(adapter);
             viewPager.setUserInputEnabled(false);
@@ -131,4 +130,8 @@ public class CAnnotStyleDialogFragment extends BottomSheetDialogFragment impleme
     public void previousFragment() {
         viewPager.setCurrentItem(0);
     }
+
+    public void addAnnotStyleChangeListener(CAnnotStyle.OnAnnotStyleChangeListener annotStyleChangeListener) {
+        this.annotStyleChangeListenerList.add(annotStyleChangeListener);
+    }
 }

+ 141 - 38
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfattr/CAnnotStyle.java

@@ -7,18 +7,21 @@
  * This notice may not be removed from this file.
  */
 
-package com.compdfkit.tools.annotation.pdfproperties.pdfattr;
+package com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle;
 
 
 import android.content.Context;
 import android.graphics.Color;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.util.Log;
 
 import androidx.annotation.ColorInt;
 import androidx.annotation.ColorRes;
 import androidx.annotation.FloatRange;
 import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import androidx.core.content.ContextCompat;
 
 import com.compdfkit.core.annotation.CPDFLineAnnotation;
@@ -27,23 +30,26 @@ import com.compdfkit.core.annotation.CPDFTextAttribute;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
 
-public class CAnnotStyle implements Parcelable ,Cloneable{
+import java.util.ArrayList;
+import java.util.List;
+
+public class CAnnotStyle implements Parcelable, Cloneable {
 
     private CAnnotationType type;
 
     private int color = Color.BLACK;
 
-    private int colorAlpha = 255;
+    private int colorOpacity = 255;
 
     private float borderWidth;
 
     private int lineColor = Color.BLACK;
 
-    private int lineColorAlpha = 255;
+    private int lineColorOpacity = 255;
 
     private int fillColor = Color.BLACK;
 
-    private int fillAlpha = 255;
+    private int fillColorOpacity = 255;
 
     private CPDFLineAnnotation.LineType startLineType;
 
@@ -55,7 +61,7 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
 
     private int textColor = Color.BLACK;
 
-    private int textColorAlpha = 255;
+    private int textColorOpacity = 255;
 
     private int fontSize;
 
@@ -71,22 +77,24 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
 
     private CPDFStampAnnotation.TextStampColor textStampColor;
 
+    private List<OnAnnotStyleChangeListener> styleChangeListenerList = new ArrayList<>();
+
     public CAnnotStyle(CAnnotationType type) {
         this.type = type;
     }
 
     protected CAnnotStyle(Parcel in) {
         color = in.readInt();
-        colorAlpha = in.readInt();
+        colorOpacity = in.readInt();
         borderWidth = in.readFloat();
         lineColor = in.readInt();
-        lineColorAlpha = in.readInt();
+        lineColorOpacity = in.readInt();
         fillColor = in.readInt();
-        fillAlpha = in.readInt();
+        fillColorOpacity = in.readInt();
         fontBold = in.readByte() != 0;
         fontItalic = in.readByte() != 0;
         textColor = in.readInt();
-        textColorAlpha = in.readInt();
+        textColorOpacity = in.readInt();
         fontSize = in.readInt();
         imagePath = in.readString();
         textStampContent = in.readString();
@@ -96,16 +104,16 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeInt(color);
-        dest.writeInt(colorAlpha);
+        dest.writeInt(colorOpacity);
         dest.writeFloat(borderWidth);
         dest.writeInt(lineColor);
-        dest.writeInt(lineColorAlpha);
+        dest.writeInt(lineColorOpacity);
         dest.writeInt(fillColor);
-        dest.writeInt(fillAlpha);
+        dest.writeInt(fillColorOpacity);
         dest.writeByte((byte) (fontBold ? 1 : 0));
         dest.writeByte((byte) (fontItalic ? 1 : 0));
         dest.writeInt(textColor);
-        dest.writeInt(textColorAlpha);
+        dest.writeInt(textColorOpacity);
         dest.writeInt(fontSize);
         dest.writeString(imagePath);
         dest.writeString(textStampContent);
@@ -133,28 +141,26 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
         return type;
     }
 
-    public void setType(CAnnotationType type) {
-        this.type = type;
-    }
-
     public int getColor() {
         return color;
     }
 
     public void setColor(@ColorInt int color) {
+        boolean update = color != this.color;
         this.color = color;
+        Log.e("CAnnotStyle", "setColor(" + color + ", update:" + update + ")");
+        updateColorListener(this.color, update);
     }
 
-    public void setColor(Context context, @ColorRes int colorRes) {
-        this.color = ContextCompat.getColor(context, colorRes);
+    public int getColorOpacity() {
+        return colorOpacity;
     }
 
-    public int getColorAlpha() {
-        return colorAlpha;
-    }
-
-    public void setColorAlpha(@IntRange(from = 0, to = 255) int colorAlpha) {
-        this.colorAlpha = colorAlpha;
+    public void setColorOpacity(@IntRange(from = 0, to = 255) int colorOpacity) {
+        boolean update = colorOpacity != this.colorOpacity;
+        this.colorOpacity = colorOpacity;
+        Log.e("CAnnotStyle", "setColorOpacity(" + colorOpacity + ", update:" + update + ")");
+        updateColorOpacity(this.colorOpacity, update);
     }
 
     public float getBorderWidth() {
@@ -177,12 +183,12 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
         this.lineColor = ContextCompat.getColor(context, colorRes);
     }
 
-    public int getLineColorAlpha() {
-        return lineColorAlpha;
+    public int getLineColorOpacity() {
+        return lineColorOpacity;
     }
 
-    public void setLineColorAlpha(@IntRange(from = 0, to = 255) int lineColorAlpha) {
-        this.lineColorAlpha = lineColorAlpha;
+    public void setLineColorOpacity(@IntRange(from = 0, to = 255) int lineColorAlpha) {
+        this.lineColorOpacity = lineColorAlpha;
     }
 
     public int getFillColor() {
@@ -197,12 +203,12 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
         this.fillColor = ContextCompat.getColor(context, colorRes);
     }
 
-    public int getFillAlpha() {
-        return fillAlpha;
+    public int getFillColorOpacity() {
+        return fillColorOpacity;
     }
 
-    public void setFillAlpha(@IntRange(from = 0, to = 255) int fillAlpha) {
-        this.fillAlpha = fillAlpha;
+    public void setFillColorOpacity(@IntRange(from = 0, to = 255) int fillColorOpacity) {
+        this.fillColorOpacity = fillColorOpacity;
     }
 
     public CPDFLineAnnotation.LineType getStartLineType() {
@@ -249,12 +255,12 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
         this.textColor = ContextCompat.getColor(context, colorRes);
     }
 
-    public int getTextColorAlpha() {
-        return textColorAlpha;
+    public int getTextColorOpacity() {
+        return textColorOpacity;
     }
 
-    public void setTextColorAlpha(@IntRange(from = 0, to = 255) int textColorAlpha) {
-        this.textColorAlpha = textColorAlpha;
+    public void setTextColorOpacity(@IntRange(from = 0, to = 255) int textColorOpacity) {
+        this.textColorOpacity = textColorOpacity;
     }
 
     public int getFontSize() {
@@ -313,6 +319,66 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
         this.textStampColor = textStampColor;
     }
 
+    @NonNull
+    @Override
+    public String toString() {
+        return "CAnnotStyle{" +
+                "type:" + type + "," +
+                "color" + color + "," +
+                "colorOpacity" + colorOpacity + "," +
+                "borderWidth" + borderWidth + "," +
+                "lineColor" + lineColor + "," +
+                "lineColorOpacity" + lineColorOpacity + "," +
+                "fillColor" + fillColor + "," +
+                "fillColorOpacity" + fillColorOpacity + "," +
+                "startLineType" + (startLineType != null ? startLineType.name() : "empty") + "," +
+                "endLineType" + (endLineType != null ? endLineType.name() : "empty") + "," +
+                "fontBold" + fontBold + "," +
+                "fontItalic" + fontItalic + "," +
+                "textColor" + textColor + "," +
+                "textColorOpacity" + textColorOpacity + "," +
+                "fontSize" + fontSize + "," +
+                "fontType" + (fontType != null ? fontType.name() : "empty") + "," +
+                "imagePath" + imagePath + "," +
+                "textStampContent" + textStampContent + "," +
+                "textStampDate" + textStampDate + "," +
+                "textStampShape" + (textStampShape != null ? textStampShape.name() : "empty") + "," +
+                "textStampColor" + (textStampColor != null ? textStampColor.name() : "empty") + ",";
+    }
+
+    @Override
+    public int hashCode() {
+        int result = this.borderWidth != 0.0F ? Float.floatToIntBits(this.borderWidth) : 0;
+        result = 31 * result + this.color;
+        result = 31 * result + (this.colorOpacity != 0.0F ? Float.floatToIntBits(this.colorOpacity) : 0);
+        result = 31 * result + this.lineColor;
+        result = 31 * result + (this.lineColorOpacity != 0.0F ? Float.floatToIntBits(this.lineColorOpacity) : 0);
+        result = 31 * result + this.fillColor;
+        result = 31 * result + (this.fillColorOpacity != 0.0F ? Float.floatToIntBits(this.fillColorOpacity) : 0);
+        result = 31 * result + (this.startLineType != null ? this.startLineType.hashCode() : 0);
+        result = 31 * result + (this.endLineType != null ? this.endLineType.hashCode() : 0);
+        result = 31 * result + this.textColor;
+        result = 31 * result + (this.textColorOpacity != 0.0F ? Float.floatToIntBits(this.textColorOpacity) : 0);
+        result = 31 * result + (this.fontSize != 0.0F ? Float.floatToIntBits(this.fontSize) : 0);
+        result = 31 * result + (this.fontType != null ? this.fontType.hashCode() : 0);
+        result = 31 * result + (this.imagePath != null ? this.imagePath.hashCode() : 0);
+        result = 31 * result + (this.textStampContent != null ? this.textStampContent.hashCode() : 0);
+        result = 31 * result + (this.textStampDate != null ? this.textStampDate.hashCode() : 0);
+        result = 31 * result + (this.type != null ? type.hashCode() : 0);
+        result = 31 * result + (this.textStampShape != null ? this.textStampShape.hashCode() : 0);
+        result = 31 * result + (this.textStampColor != null ? this.textStampColor.hashCode() : 0);
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (obj instanceof CAnnotStyle) {
+            return obj.toString().equals(this.toString());
+        } else {
+            return false;
+        }
+    }
+
     public int getAnnotTypeTitleResId() {
         int titleResId = 0;
         switch (type) {
@@ -338,4 +404,41 @@ public class CAnnotStyle implements Parcelable ,Cloneable{
         }
         return titleResId;
     }
+
+
+    private void updateColorListener(@ColorInt int color, boolean update) {
+        if (styleChangeListenerList != null && update) {
+            for (OnAnnotStyleChangeListener onAnnotStyleChangeListener : styleChangeListenerList) {
+                onAnnotStyleChangeListener.onChangeAnnotColor(color);
+            }
+        }
+    }
+
+    private void updateColorOpacity(int colorOpacity, boolean update) {
+        if (styleChangeListenerList != null && update) {
+            for (OnAnnotStyleChangeListener onAnnotStyleChangeListener : styleChangeListenerList) {
+                onAnnotStyleChangeListener.onChangeAnnotColorOpacity(colorOpacity);
+            }
+        }
+    }
+
+    public void addStyleChangeListener(OnAnnotStyleChangeListener styleChangeListener) {
+        this.styleChangeListenerList.add(styleChangeListener);
+    }
+
+    public void addStyleChangeListener(List<OnAnnotStyleChangeListener> styleChangeListener) {
+        this.styleChangeListenerList.addAll(styleChangeListener);
+    }
+
+    public void removeStyleChangeListener(OnAnnotStyleChangeListener styleChangeListener) {
+        this.styleChangeListenerList.remove(styleChangeListener);
+    }
+
+    public interface OnAnnotStyleChangeListener {
+
+        void onChangeAnnotColor(@ColorInt int color);
+
+        void onChangeAnnotColorOpacity(@ColorInt int opacity);
+    }
+
 }

+ 23 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/CBasicOnStyleChangeListener.java

@@ -0,0 +1,23 @@
+/**
+ * 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.annotation.pdfproperties.pdfannotstyle;
+
+
+public class CBasicOnStyleChangeListener  implements CAnnotStyle.OnAnnotStyleChangeListener {
+    @Override
+    public void onChangeAnnotColor(int color) {
+
+    }
+
+    @Override
+    public void onChangeAnnotColorOpacity(int opacity) {
+
+    }
+}

+ 15 - 5
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/adapter/CAnnotPropertiesFragmentAdapter.java

@@ -1,3 +1,12 @@
+/**
+ * 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.annotation.pdfproperties.pdfannotstyle.adapter;
 
 import androidx.annotation.NonNull;
@@ -7,14 +16,13 @@ import androidx.lifecycle.Lifecycle;
 import androidx.viewpager2.adapter.FragmentStateAdapter;
 
 import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.data.CPropertiesFragmentDatas;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
 
 import java.util.ArrayList;
 import java.util.List;
 
-
-public class CAnnotPropertiesFragmentAdapter  extends FragmentStateAdapter {
+public class CAnnotStyleFragmentAdapter extends FragmentStateAdapter {
 
     private CAnnotStyle style;
 
@@ -22,7 +30,7 @@ public class CAnnotPropertiesFragmentAdapter  extends FragmentStateAdapter {
 
     private CBasicPropertiesFragment.OnSwitchFragmentListener listener;
 
-    public CAnnotPropertiesFragmentAdapter(CAnnotStyle style, @NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
+    public CAnnotStyleFragmentAdapter(CAnnotStyle style, @NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
         super(fragmentManager, lifecycle);
         this.style = style;
         propertiesClass = CPropertiesFragmentDatas.getPropertiesFragmentClass(style);
@@ -32,7 +40,9 @@ public class CAnnotPropertiesFragmentAdapter  extends FragmentStateAdapter {
     @Override
     public Fragment createFragment(int position) {
         CBasicPropertiesFragment fragment = CPropertiesFragmentDatas.createPropertiesFragment(propertiesClass.get(position).getFragmentClass(), style);
-        fragment.setSwitchFragmentListener(listener);
+        if (fragment != null) {
+            fragment.setSwitchFragmentListener(listener);
+        }
         return fragment;
     }
 

+ 1 - 6
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/data/CPropertiesFragmentDatas.java

@@ -12,7 +12,7 @@ package com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.data;
 import androidx.annotation.StringRes;
 
 import com.compdfkit.tools.R;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 import com.compdfkit.tools.annotation.pdfproperties.pdfmarkup.CMarkupStyleFragment;
 import com.compdfkit.tools.annotation.pdfproperties.pdfnote.CNoteStyleFragment;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
@@ -24,7 +24,6 @@ import java.util.List;
 
 public class CPropertiesFragmentDatas {
 
-
     public static List<CPropertiesFragmentBean> getPropertiesFragmentClass(CAnnotStyle style) {
         List<CPropertiesFragmentBean> list = new ArrayList<>();
         switch (style.getType()) {
@@ -51,7 +50,6 @@ public class CPropertiesFragmentDatas {
         }
     }
 
-
     private static List<CPropertiesFragmentBean> markupFragments(CAnnotStyle style) {
         List<CPropertiesFragmentBean> list = new ArrayList<>();
         list.add(new CPropertiesFragmentBean(style.getAnnotTypeTitleResId(), CMarkupStyleFragment.class));
@@ -66,7 +64,6 @@ public class CPropertiesFragmentDatas {
         return list;
     }
 
-
     public static class CPropertiesFragmentBean{
 
         private Class<? extends CBasicPropertiesFragment> fragmentClass;
@@ -78,7 +75,6 @@ public class CPropertiesFragmentDatas {
             this.fragmentClass = fragmentClass;
         }
 
-
         public Class<? extends CBasicPropertiesFragment> getFragmentClass() {
             return fragmentClass;
         }
@@ -95,5 +91,4 @@ public class CPropertiesFragmentDatas {
             this.titleResId = titleResId;
         }
     }
-
 }

+ 229 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/manager/CAnnotStyleManager.java

@@ -0,0 +1,229 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ * <p>
+ * 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.annotation.pdfproperties.pdfannotstyle.manager;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.IntRange;
+
+import com.compdfkit.tools.annotation.pdfproperties.CAnnotStyleDialogFragment;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
+import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
+import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
+import com.compdfkit.ui.attribute.CPDFAnnotAttribute;
+import com.compdfkit.ui.attribute.CPDFHighlightAttr;
+import com.compdfkit.ui.attribute.CPDFSquigglyAttr;
+import com.compdfkit.ui.attribute.CPDFStrikeoutAttr;
+import com.compdfkit.ui.attribute.CPDFUnderlineAttr;
+import com.compdfkit.ui.attribute.IAttributeCallback;
+import com.compdfkit.ui.attribute.form.CPDFTextfieldAttr;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+
+public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListener {
+
+    public void apply(CPDFViewCtrl pdfView, CAnnotStyle style, boolean onStore){
+        LinkedHashSet<CAnnotStyle> linkedHashSet = new LinkedHashSet<>();
+        linkedHashSet.add(style);
+        apply(pdfView, linkedHashSet, onStore);
+    }
+
+    public void apply(CPDFViewCtrl pdfView, LinkedHashSet<CAnnotStyle> styleSet, boolean onStore) {
+        CPDFAnnotAttribute attribute = pdfView.getCPdfReaderView().getReaderAttribute().getAnnotAttribute();
+        for (CAnnotStyle params : styleSet) {
+            if (params == null) {
+                continue;
+            }
+            IAttributeCallback callback = null;
+            switch (params.getType()) {
+                case TEXT:
+                    CPDFTextfieldAttr textfieldAttr = attribute.getTextfieldAttr();
+                    textfieldAttr.setBgColor(params.getColor());
+
+                    break;
+                case HIGHLIGHT:
+                    CPDFHighlightAttr highlightAttr = attribute.getHighlightAttr();
+                    highlightAttr.setColor(params.getColor());
+                    highlightAttr.setAlpha(params.getColorOpacity());
+                    callback = highlightAttr;
+                    break;
+
+                case UNDERLINE:
+                    CPDFUnderlineAttr underlineAttr = attribute.getUnderlineAttr();
+                    underlineAttr.setColor(params.getColor());
+                    underlineAttr.setAlpha(params.getColorOpacity());
+                    callback = underlineAttr;
+                    break;
+
+                case SQUIGGLY:
+                    CPDFSquigglyAttr squigglyAttr = attribute.getSquigglyAttr();
+                    squigglyAttr.setColor(params.getColor());
+                    squigglyAttr.setAlpha(params.getColorOpacity());
+                    callback = squigglyAttr;
+                    break;
+
+                case STRIKEOUT:
+                    CPDFStrikeoutAttr strikeoutAttr = attribute.getStrikeoutAttr();
+                    strikeoutAttr.setColor(params.getColor());
+                    strikeoutAttr.setAlpha(params.getColorOpacity());
+                    callback = strikeoutAttr;
+                    break;
+                default:
+                    break;
+            }
+            if (onStore) {
+                if (callback != null) {
+                    callback.onstore();
+                }
+            }
+        }
+    }
+
+    public void changeAnnotStyle(){
+
+
+    }
+
+    private CAnnotStyleDialogFragment annotStyleDialogFragment;
+
+    private CPDFViewCtrl pdfView;
+
+    public void bindAnnotStyleFragment(CPDFViewCtrl pdfView, CAnnotStyleDialogFragment styleDialogFragment){
+        this.pdfView = pdfView;
+        annotStyleDialogFragment = styleDialogFragment;
+        annotStyleDialogFragment.addAnnotStyleChangeListener(this);
+    }
+
+    @Override
+    public void onChangeAnnotColor(int color) {
+        if (pdfView != null && annotStyleDialogFragment != null) {
+            CAnnotStyle style = annotStyleDialogFragment.getStyle();
+            apply(pdfView, style, false);
+        }
+    }
+
+    @Override
+    public void onChangeAnnotColorOpacity(int opacity) {
+        if (pdfView != null && annotStyleDialogFragment != null) {
+            CAnnotStyle style = annotStyleDialogFragment.getStyle();
+            apply(pdfView, style, false);
+        }
+    }
+
+    public CAnnotStyle getAnnotStyle(CPDFViewCtrl pdfView, CAnnotationType type){
+        CAnnotStyle style = new CAnnotStyle(type);
+        CPDFAnnotAttribute attribute = pdfView.getCPdfReaderView().getReaderAttribute().getAnnotAttribute();
+        switch (type) {
+            case TEXT:
+                CPDFTextfieldAttr textfieldAttr = attribute.getTextfieldAttr();
+                style.setColor(textfieldAttr.getBgColor());
+                break;
+            case HIGHLIGHT:
+                CPDFHighlightAttr highlightAttr = attribute.getHighlightAttr();
+                style.setColor(highlightAttr.getColor());
+                style.setColorOpacity(highlightAttr.getAlpha());
+                break;
+
+            case UNDERLINE:
+                CPDFUnderlineAttr underlineAttr = attribute.getUnderlineAttr();
+                style.setColor(underlineAttr.getColor());
+                style.setColorOpacity(underlineAttr.getAlpha());
+                break;
+
+            case SQUIGGLY:
+                CPDFSquigglyAttr squigglyAttr = attribute.getSquigglyAttr();
+                style.setColor(squigglyAttr.getColor());
+                style.setColorOpacity(squigglyAttr.getAlpha());
+                break;
+
+            case STRIKEOUT:
+                CPDFStrikeoutAttr strikeoutAttr = attribute.getStrikeoutAttr();
+                style.setColor(strikeoutAttr.getColor());
+                style.setColorOpacity(strikeoutAttr.getAlpha());
+                break;
+            default:
+                break;
+        }
+        return style;
+    }
+
+
+    public static class Builder {
+        private LinkedHashSet<CAnnotStyle> attrSet = new LinkedHashSet();
+
+        private CPDFViewCtrl pdfView;
+
+        public Builder(CPDFViewCtrl pdfView) {
+            this.pdfView = pdfView;
+        }
+
+        public Builder setColor(CAnnotationType type, @ColorInt int color){
+            CAnnotStyle style = new CAnnotStyle(type);
+            style.setColor(color);
+            attrSet.add(style);
+            return this;
+        }
+
+        public Builder setMarkup(CAnnotationType type, @ColorInt int color, @IntRange(from = 0, to = 255) int colorAlpha) {
+            CAnnotStyle style = new CAnnotStyle(type);
+            style.setColor(color);
+            style.setColorOpacity(colorAlpha);
+            attrSet.add(style);
+            return this;
+        }
+
+
+        public Builder setInkAttribute(@ColorInt int color, @IntRange(from = 0, to = 255) int colorAlpha) {
+            CAnnotStyle style = new CAnnotStyle(CAnnotationType.INK);
+            style.setColor(color);
+            style.setColorOpacity(colorAlpha);
+            attrSet.add(style);
+            return this;
+        }
+
+        public Builder setShape(CAnnotationType type,
+                                @ColorInt int lineColor,
+                                @IntRange(from = 0, to = 255) int lineColorOpacity,
+                                @ColorInt int fillColor,
+                                @IntRange(from = 0, to = 255) int fillColorAlpha,
+                                float borderWidth) {
+            CAnnotStyle style = new CAnnotStyle(type);
+            style.setLineColor(lineColor);
+            style.setLineColorOpacity(lineColorOpacity);
+            style.setFillColor(fillColor);
+            style.setFillColor(fillColorAlpha);
+            style.setBorderWidth(borderWidth);
+            attrSet.add(style);
+            return this;
+        }
+
+        private CAnnotStyleManager create() {
+            return new CAnnotStyleManager();
+        }
+
+        public void clear(){
+            attrSet.clear();
+        }
+
+        public void apply() {
+            create().apply(pdfView, attrSet, false);
+        }
+
+        public void onStore() {
+            CAnnotStyleManager annotationAttr = create();
+            annotationAttr.apply(pdfView, attrSet, true);
+        }
+
+        public void init() {
+            onStore();
+        }
+    }
+}

+ 21 - 22
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/viewmodel/CAnnotStyleViewModel.java

@@ -1,42 +1,41 @@
-package com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.viewmodel;
+/**
+ * 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.
+ */
 
-import android.graphics.Color;
+package com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.viewmodel;
 
-import androidx.annotation.ColorInt;
-import androidx.lifecycle.LiveData;
-import androidx.lifecycle.MutableLiveData;
 import androidx.lifecycle.ViewModel;
 
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 
 
 public class CAnnotStyleViewModel extends ViewModel {
 
-    public MutableLiveData<CAnnotStyle> liveData = new MutableLiveData<>();
+
+    private CAnnotStyle annotStyle;
 
     public void setStyle(CAnnotStyle style) {
-        this.liveData.setValue(style);
+        this.annotStyle = style;
     }
 
     public CAnnotStyle getStyle() {
-        return liveData.getValue();
+        return annotStyle;
     }
 
-    public void setColor(@ColorInt int color) {
-        setColor(color, getStyle() != null ? getStyle().getColorAlpha() : 255);
-    }
-
-    public void setColorAlpha(int colorAlpha) {
-        setColor(getStyle() != null ? getStyle().getColor() : Color.WHITE, colorAlpha );
+    public void addStyleChangeListener(CAnnotStyle.OnAnnotStyleChangeListener listener){
+        if (annotStyle != null) {
+            annotStyle.addStyleChangeListener(listener);
+        }
     }
 
-    public void setColor(@ColorInt int color, int colorAlpha) {
-        CAnnotStyle style = liveData.getValue();
-        if (style != null) {
-            style.setColor(color);
-            style.setColorAlpha(colorAlpha);
-            liveData.setValue(style);
+    public void removeStyleChangeListener(CAnnotStyle.OnAnnotStyleChangeListener styleChangeListener){
+        if (annotStyle != null) {
+            annotStyle.removeStyleChangeListener(styleChangeListener);
         }
     }
-
 }

+ 0 - 144
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfattr/CAnnotAttr.java

@@ -1,144 +0,0 @@
-package com.compdfkit.tools.annotation.pdfproperties.pdfattr;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.IntRange;
-
-import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
-import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
-import com.compdfkit.ui.attribute.CPDFAnnotAttribute;
-import com.compdfkit.ui.attribute.CPDFHighlightAttr;
-import com.compdfkit.ui.attribute.CPDFSquigglyAttr;
-import com.compdfkit.ui.attribute.CPDFStrikeoutAttr;
-import com.compdfkit.ui.attribute.CPDFUnderlineAttr;
-import com.compdfkit.ui.attribute.IAttributeCallback;
-
-import java.util.HashMap;
-
-/**
- * @classname:
- * @author: LiuXiaoLong
- * @date: 2023/4/21
- * description:
- */
-public class CAnnotAttr {
-
-    private HashMap<CAnnotationType, CAnnotStyle> attrMaps = new HashMap<>();
-
-    private CPDFViewCtrl pdfView;
-
-    private boolean store;
-
-    public void apply(){
-        CPDFAnnotAttribute attribute = pdfView.getCPdfReaderView().getReaderAttribute().getAnnotAttribute();
-        for (CAnnotationType type : attrMaps.keySet()) {
-            CAnnotStyle params = attrMaps.get(type);
-            if (params == null){
-                continue;
-            }
-            IAttributeCallback callback = null;
-            switch (params.getType()) {
-                case HIGHLIGHT:
-                    CPDFHighlightAttr highlightAttr = attribute.getHighlightAttr();
-                    highlightAttr.setColor(params.getColor());
-                    highlightAttr.setAlpha(params.getColorAlpha());
-                    callback = highlightAttr;
-                    break;
-
-                case UNDERLINE:
-                    CPDFUnderlineAttr underlineAttr = attribute.getUnderlineAttr();
-                    underlineAttr.setColor(params.getColor());
-                    underlineAttr.setAlpha(params.getColorAlpha());
-                    callback = underlineAttr;
-                    break;
-
-                case SQUIGGLY:
-                    CPDFSquigglyAttr squigglyAttr = attribute.getSquigglyAttr();
-                    squigglyAttr.setColor(params.getColor());
-                    squigglyAttr.setAlpha(params.getColorAlpha());
-                    callback = squigglyAttr;
-                    break;
-
-                case STRIKEOUT:
-                    CPDFStrikeoutAttr strikeoutAttr= attribute.getStrikeoutAttr();
-                    strikeoutAttr.setColor(params.getColor());
-                    strikeoutAttr.setAlpha(params.getColorAlpha());
-                    callback = strikeoutAttr;
-                    break;
-                default:
-                    break;
-            }
-            if (store){
-                if (callback != null) {
-                    callback.onstore();
-                }
-            }
-        }
-    }
-
-
-
-    public static class Builder {
-        private HashMap<CAnnotationType, CAnnotStyle> attrMaps = new HashMap<>();
-
-        private CPDFViewCtrl pdfView;
-
-        public Builder(CPDFViewCtrl pdfView) {
-            this.pdfView = pdfView;
-        }
-
-        public Builder setMarkup(CAnnotationType type, @ColorInt int color, @IntRange(from = 0, to = 255) int colorAlpha) {
-            CAnnotStyle params = new CAnnotStyle(type);
-            params.setColor(color);
-            params.setColorAlpha(colorAlpha);
-            attrMaps.put(type, params);
-            return this;
-        }
-
-
-        public Builder setInkAttribute(@ColorInt int color, @IntRange(from = 0, to = 255) int colorAlpha) {
-            CAnnotStyle style = new CAnnotStyle(CAnnotationType.INK);
-            style.setColor(color);
-            style.setColorAlpha(colorAlpha);
-            attrMaps.put(CAnnotationType.INK, style);
-            return this;
-        }
-
-        public Builder setShape(CAnnotationType type,
-                                @ColorInt int lineColor,
-                                @IntRange(from = 0, to = 255) int lineColorAlpha,
-                                @ColorInt int fillColor,
-                                @IntRange(from = 0, to = 255) int fillColorAlpha,
-                                float borderWidth) {
-            CAnnotStyle params = new CAnnotStyle(type);
-            params.setLineColor(lineColor);
-            params.setLineColorAlpha(lineColorAlpha);
-            params.setFillColor( fillColor);
-            params.setFillColor(fillColorAlpha);
-            params.setBorderWidth(borderWidth);
-            attrMaps.put(type, params);
-            return this;
-        }
-
-        private CAnnotAttr create(){
-            CAnnotAttr annotationAttr = new CAnnotAttr();
-            annotationAttr.attrMaps = attrMaps;
-            annotationAttr.pdfView = pdfView;
-            return annotationAttr;
-        }
-
-        public void apply(){
-            create().apply();
-        }
-
-        public void onStore(){
-            CAnnotAttr annotationAttr = create();
-            annotationAttr.store = true;
-            annotationAttr.apply();
-        }
-
-        public void init(){
-            onStore();
-        }
-    }
-
-}

+ 41 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdflnk/CInkStyleFragment.java

@@ -0,0 +1,41 @@
+/**
+ * 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.annotation.pdfproperties.pdflnk;
+
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
+import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
+
+public class CInkStyleFragment extends CBasicPropertiesFragment {
+
+
+    public static CInkStyleFragment newInstance() {
+        return new CInkStyleFragment();
+    }
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+        return super.onCreateView(inflater, container, savedInstanceState);
+    }
+
+    @Override
+    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+    }
+}

+ 1 - 1
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfmarkup/CLinkStyleFragment.java

@@ -18,7 +18,7 @@ import android.view.ViewGroup;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
 
 public class CLinkStyleFragment extends CBasicPropertiesFragment {

+ 42 - 18
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfmarkup/CMarkupStyleFragment.java

@@ -11,21 +11,18 @@ package com.compdfkit.tools.annotation.pdfproperties.pdfmarkup;
 
 
 import android.os.Bundle;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.lifecycle.ViewModel;
-import androidx.lifecycle.ViewModelProvider;
 
 import com.compdfkit.tools.R;
-import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.viewmodel.CAnnotStyleViewModel;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CBasicOnStyleChangeListener;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
 import com.compdfkit.tools.common.views.pdfproperties.colorlist.CColorListView;
+import com.compdfkit.tools.common.views.pdfproperties.preview.CStylePreviewView;
 import com.compdfkit.tools.common.views.pdfproperties.sliderbar.CSliderBar;
 
 public class CMarkupStyleFragment extends CBasicPropertiesFragment {
@@ -34,6 +31,8 @@ public class CMarkupStyleFragment extends CBasicPropertiesFragment {
 
     private CSliderBar sliderBar;
 
+    private CStylePreviewView previewView;
+
     public static CMarkupStyleFragment newInstance() {
         return new CMarkupStyleFragment();
     }
@@ -44,29 +43,54 @@ public class CMarkupStyleFragment extends CBasicPropertiesFragment {
         View rootView = inflater.inflate(R.layout.tools_properties_markup_style_fragment, container, false);
         colorListView = rootView.findViewById(R.id.color_list_view);
         sliderBar = rootView.findViewById(R.id.slider_bar);
+        previewView = rootView.findViewById(R.id.style_preview);
         return rootView;
     }
 
     @Override
     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
+        previewView.setAnnotType(viewModel.getStyle().getType());
+        previewView.setColor(viewModel.getStyle().getColor());
+        previewView.setColorAlpha(viewModel.getStyle().getColorOpacity());
         colorListView.setColorChangeListener(color -> {
-            viewModel.setColor(color);
+            if (viewModel != null) {
+                viewModel.getStyle().setColor(color);
+            }
         });
-        sliderBar.setProgress(viewModel.getStyle().getColorAlpha());
+        sliderBar.setProgress(viewModel.getStyle().getColorOpacity());
         colorListView.setColorPickerClickListener(this::nextFragment);
-        sliderBar.setChangeListener((progress, percentageValue) ->{
-            viewModel.setColorAlpha(progress);
-        });
-        viewModel.liveData.observe(getViewLifecycleOwner(), style -> {
-            if (style != null && !isOnResume) {
-                if (colorListView != null) {
-                    colorListView.setSelectColor(style.getColor());
-                }
-                if (sliderBar != null) {
-                    sliderBar.setProgress(style.getColorAlpha());
-                }
+        sliderBar.setChangeListener((opacity, percentageValue) ->{
+            if (viewModel != null) {
+                viewModel.getStyle().setColorOpacity(opacity);
             }
         });
+        colorListView.showColorPicker(true);
+        viewModel.addStyleChangeListener(this);
+    }
+
+    @Override
+    public void onChangeAnnotColor(int color) {
+        if (!isOnResume){
+            if (colorListView != null) {
+                colorListView.setSelectColor(color);
+            }
+        }
+        if (previewView != null) {
+            previewView.setColor(color);
+        }
+    }
+
+    @Override
+    public void onChangeAnnotColorOpacity(int opacity) {
+        super.onChangeAnnotColorOpacity(opacity);
+        if (!isOnResume){
+            if (sliderBar != null) {
+                sliderBar.setProgress(opacity);
+            }
+        }
+        if (previewView != null) {
+            previewView.setColorAlpha(opacity);
+        }
     }
 }

+ 109 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfnote/CNoteEditDialog.java

@@ -0,0 +1,109 @@
+/**
+ * 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.annotation.pdfproperties.pdfnote;
+
+import android.content.DialogInterface;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatEditText;
+import androidx.appcompat.widget.AppCompatImageView;
+import androidx.fragment.app.DialogFragment;
+
+import com.compdfkit.tools.R;
+import com.compdfkit.tools.common.utils.viewutils.CDimensUtils;
+
+
+public class CNoteEditDialog extends DialogFragment {
+
+    public static final String EXTRA_NOTE_CONTENT = "extra_note_content";
+
+    private AppCompatImageView ivSave;
+
+    private AppCompatImageView ivDelete;
+
+    private AppCompatEditText etContent;
+
+    private View.OnClickListener deleteListener;
+
+    private View.OnClickListener saveListener;
+
+    public static CNoteEditDialog newInstance(String content) {
+        Bundle args = new Bundle();
+        args.putString(EXTRA_NOTE_CONTENT, content);
+        CNoteEditDialog fragment = new CNoteEditDialog();
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onStart() {
+        super.onStart();
+        if (getDialog() != null) {
+            Window window = getDialog().getWindow();
+            window.setDimAmount(0.4F);
+            WindowManager.LayoutParams attr = window.getAttributes();
+            attr.width = CDimensUtils.getMinWidthOrHeight(getContext()) * 4/ 5;
+            attr.height = CDimensUtils.getScreenHeight(getContext()) /2;
+            window.setAttributes(attr);
+            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+        }
+    }
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+        View rootView = inflater.inflate(R.layout.tools_properties_note_edit_dialog, container, false);
+        ivSave = rootView.findViewById(R.id.id_note_save);
+        ivDelete = rootView.findViewById(R.id.id_note_delete);
+        etContent  = rootView.findViewById(R.id.id_note_content);
+        return rootView;
+    }
+
+    @Override
+    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        ivSave.setOnClickListener(saveListener);
+        ivDelete.setOnClickListener(deleteListener);
+        if (getArguments() != null) {
+            String content = getArguments().getString(EXTRA_NOTE_CONTENT);
+            etContent.setText(content);
+            etContent.setSelection(content.length());
+        }
+    }
+
+    public void setDeleteListener(View.OnClickListener deleteListener) {
+        this.deleteListener = deleteListener;
+    }
+
+    public void setSaveListener(View.OnClickListener saveListener) {
+        this.saveListener = saveListener;
+    }
+
+    public String getContent(){
+        return etContent.getText() != null ? etContent.getText().toString() : "";
+    }
+
+    @Override
+    public void onCancel(@NonNull DialogInterface dialog) {
+        super.onCancel(dialog);
+        if (deleteListener != null) {
+            deleteListener.onClick(ivDelete);
+        }
+    }
+}

+ 22 - 10
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfnote/CNoteStyleFragment.java

@@ -19,14 +19,17 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.compdfkit.tools.R;
+import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
 import com.compdfkit.tools.common.views.pdfproperties.basic.CBasicPropertiesFragment;
 import com.compdfkit.tools.common.views.pdfproperties.colorlist.CColorListView;
-import com.compdfkit.tools.common.views.pdfproperties.sliderbar.CSliderBar;
+import com.compdfkit.tools.common.views.pdfproperties.preview.CStylePreviewView;
 
 public class CNoteStyleFragment extends CBasicPropertiesFragment {
 
     private CColorListView colorListView;
 
+    private CStylePreviewView stylePreviewView;
+
     public static CNoteStyleFragment newInstance() {
         return new CNoteStyleFragment();
     }
@@ -38,6 +41,9 @@ public class CNoteStyleFragment extends CBasicPropertiesFragment {
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         rootView = inflater.inflate(R.layout.tools_properties_note_style_fragment, container, false);
         colorListView = rootView.findViewById(R.id.color_list_view);
+        stylePreviewView = rootView.findViewById(R.id.style_preview);
+        stylePreviewView.setAnnotType(CAnnotationType.TEXT);
+        stylePreviewView.setColor(viewModel.getStyle().getColor());
         return rootView;
     }
 
@@ -45,17 +51,23 @@ public class CNoteStyleFragment extends CBasicPropertiesFragment {
     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
         colorListView.setColorChangeListener(color -> {
-            viewModel.setColor(color);
-        });
-        colorListView.setColorPickerClickListener(this::nextFragment);
-        viewModel.liveData.observe(getViewLifecycleOwner(), style -> {
-            if (style != null && !isOnResume) {
-                if (colorListView != null) {
-                    colorListView.setSelectColor(style.getColor());
-                }
+            if (viewModel != null) {
+                viewModel.getStyle().setColor(color);
             }
         });
+        colorListView.setColorPickerClickListener(this::nextFragment);
+        viewModel.addStyleChangeListener(this);
     }
 
-
+    @Override
+    public void onChangeAnnotColor(int color) {
+        if (!isOnResume) {
+            if (colorListView != null) {
+                colorListView.setSelectColor(color);
+            }
+        }
+        if (stylePreviewView != null) {
+            stylePreviewView.setColor(color);
+        }
+    }
 }

+ 18 - 2
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfnote/CPDFtextAnnotAttachHelper.java

@@ -1,5 +1,10 @@
 package com.compdfkit.tools.annotation.pdfproperties.pdfnote;
 
+import android.app.Activity;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+
 import com.compdfkit.tools.common.utils.dialog.CGotoPageDialog;
 import com.compdfkit.ui.proxy.CPDFTextAnnotImpl;
 import com.compdfkit.ui.proxy.attach.CPDFTextAnnotAttachHelper;
@@ -8,7 +13,18 @@ import com.compdfkit.ui.proxy.attach.CPDFTextAnnotAttachHelper;
 public class CPDFtextAnnotAttachHelper extends CPDFTextAnnotAttachHelper {
     @Override
     protected void onAddTextAnnot(CPDFTextAnnotImpl cpdfTextAnnot) {
-        CGotoPageDialog dialog = new CGotoPageDialog(readerView.getContext());
-        dialog.show();
+        CNoteEditDialog editDialog = CNoteEditDialog.newInstance("");
+        editDialog.setSaveListener(v -> {
+            String content = editDialog.getContent();
+            cpdfTextAnnot.onGetAnnotation().setContent(content);
+            editDialog.dismiss();
+        });
+        editDialog.setDeleteListener(v -> {
+            pageView.deleteAnnotation(cpdfTextAnnot);
+            editDialog.dismiss();
+        });
+        if (readerView.getContext() instanceof FragmentActivity){
+            editDialog.show(((FragmentActivity) readerView.getContext()).getSupportFragmentManager(), "noteEditDialog");
+        }
     }
 }

+ 6 - 6
compdfkit-tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfannotstyle/adapter/CWrapHeightPageChangeCallback.java

@@ -7,7 +7,7 @@
  * This notice may not be removed from this file.
  */
 
-package com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.adapter;
+package com.compdfkit.tools.common.utils;
 
 import android.animation.ObjectAnimator;
 import android.view.View;
@@ -48,11 +48,11 @@ public class CWrapHeightPageChangeCallback extends ViewPager2.OnPageChangeCallba
                     View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY);
             int hMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
             view.measure(wMeasureSpec, hMeasureSpec);
-            int hei = view.getMeasuredHeight();
-            int he = viewPager2.getLayoutParams().height;
-            if (he != hei) {
-                if (he > 0 && hei > 0) {
-                    requestHeightAnimation(viewPager2, he, hei);
+            int measuredHeight = view.getMeasuredHeight();
+            int layoutParamsHeight = viewPager2.getLayoutParams().height;
+            if (layoutParamsHeight != measuredHeight) {
+                if (layoutParamsHeight > 0 && measuredHeight > 0) {
+                    requestHeightAnimation(viewPager2, layoutParamsHeight, measuredHeight);
                 }else {
                     ViewGroup.LayoutParams layoutParams = viewPager2.getLayoutParams();
                     layoutParams.height = view.getMeasuredHeight();

+ 6 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/utils/adapter/CBaseQuickViewHolder.java

@@ -1,5 +1,6 @@
 package com.compdfkit.tools.common.utils.adapter;
 
+import android.content.res.ColorStateList;
 import android.graphics.drawable.Drawable;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
@@ -71,6 +72,11 @@ public class CBaseQuickViewHolder extends RecyclerView.ViewHolder {
         imageView.setImageDrawable(drawable);
     }
 
+    public void setImageTintList(@IdRes int viewId, ColorStateList colorStateList){
+        ImageView imageView = getView(viewId);
+        imageView.setImageTintList(colorStateList);
+    }
+
     public void setBackgroundResource(@IdRes int viewId, @DrawableRes int backgroundRes) {
         getView(viewId).setBackgroundResource(backgroundRes);
     }

+ 23 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/utils/viewutils/CDimensUtils.java

@@ -10,6 +10,7 @@
 package com.compdfkit.tools.common.utils.viewutils;
 
 import android.content.Context;
+import android.util.DisplayMetrics;
 
 
 public class CDimensUtils {
@@ -22,4 +23,26 @@ public class CDimensUtils {
         float scale = context.getResources().getDisplayMetrics().density;
         return (int) (dp * scale + 0.5f);
     }
+
+    public static DisplayMetrics getDisplayMetrics(Context context){
+        return context.getResources().getDisplayMetrics();
+    }
+
+    public static int getScreenWidth(Context context){
+        return getDisplayMetrics(context).widthPixels;
+    }
+
+    public static int getScreenHeight(Context context){
+        return getDisplayMetrics(context).heightPixels;
+    }
+
+    public static int getMinWidthOrHeight(Context context) {
+        if (context == null) {
+            return 0;
+        }
+        int height = getScreenHeight(context);
+
+        int width = getScreenWidth(context);
+        return Math.min(width, height);
+    }
 }

+ 16 - 3
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/CAnnotationToolbar.java

@@ -23,12 +23,14 @@ import androidx.recyclerview.widget.RecyclerView;
 
 import com.compdfkit.core.annotation.CPDFAnnotation;
 import com.compdfkit.tools.R;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CBasicOnStyleChangeListener;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.manager.CAnnotStyleManager;
 import com.compdfkit.tools.common.views.pdfannotationbar.adapter.CPDFAnnotationToolListAdapter;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotToolBean;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
 import com.compdfkit.tools.common.views.pdfannotationbar.data.CAnnotationToolDatas;
 import com.compdfkit.tools.annotation.pdfproperties.CAnnotStyleDialogFragment;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
 
 public class CAnnotationToolbar extends FrameLayout {
@@ -67,7 +69,6 @@ public class CAnnotationToolbar extends FrameLayout {
         ivUndo = findViewById(R.id.iv_annotation_attr_undo);
         ivRedo = findViewById(R.id.iv_annotation_attr_redo);
         toolListAdapter = new CPDFAnnotationToolListAdapter();
-        toolListAdapter.setList(CAnnotationToolDatas.getAnnotationList());
         rvAnnotationList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
         rvAnnotationList.setAdapter(toolListAdapter);
         initListener();
@@ -76,10 +77,21 @@ public class CAnnotationToolbar extends FrameLayout {
     private void initListener(){
         ivSetting.setEnabled(false);
         ivSetting.setOnClickListener(v -> {
-            CAnnotStyle style = new CAnnotStyle(toolListAdapter.getCurrentAnnotType());
+            CAnnotStyleManager manager = new CAnnotStyleManager();
+            CAnnotStyle style = manager.getAnnotStyle(pdfView, toolListAdapter.getCurrentAnnotType());
+
             CAnnotStyleDialogFragment dialogFragment = CAnnotStyleDialogFragment.newInstance(style);
+            manager.bindAnnotStyleFragment(pdfView, dialogFragment);
+            dialogFragment.addAnnotStyleChangeListener(new CBasicOnStyleChangeListener(){
+                @Override
+                public void onChangeAnnotColor(int color) {
+                    super.onChangeAnnotColor(color);
+                    toolListAdapter.updateItemColor(toolListAdapter.getCurrentAnnotType(), color);
+                }
+            });
             dialogFragment.show(fragmentManager, "annotStyleDialogFragment");
         });
+
         ivUndo.setOnClickListener(v -> {
 
         });
@@ -95,6 +107,7 @@ public class CAnnotationToolbar extends FrameLayout {
 
     public void initWithPDFView(CPDFViewCtrl pdfView){
         this.pdfView = pdfView;
+        toolListAdapter.setList(CAnnotationToolDatas.getAnnotationList(pdfView));
         this.pdfView.addOnPDFFocusedTypeChangeListener(type -> {
             toolListAdapter.selectByType(CAnnotationType.getType(type));
             ivSetting.setEnabled(toolListAdapter.hasSelectAnnotType());

+ 50 - 6
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/adapter/CPDFAnnotationToolListAdapter.java

@@ -10,8 +10,12 @@
 package com.compdfkit.tools.common.views.pdfannotationbar.adapter;
 
 import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.Color;
 import android.view.ViewGroup;
 
+import androidx.appcompat.widget.AppCompatImageView;
+
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotToolBean;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
@@ -23,7 +27,7 @@ import java.util.List;
 
 public class CPDFAnnotationToolListAdapter extends CBaseQuickAdapter<CAnnotToolBean, CBaseQuickViewHolder> {
 
-    public static final String REFRESH_SELECT = "refresh_select";
+    public static final String REFRESH_ITEM = "refresh_item";
 
     @Override
     protected CBaseQuickViewHolder onCreateViewHolder(Context context, ViewGroup parent, int viewType) {
@@ -33,7 +37,9 @@ public class CPDFAnnotationToolListAdapter extends CBaseQuickAdapter<CAnnotToolB
     @Override
     protected void onBindViewHolder(CBaseQuickViewHolder holder, int position, CAnnotToolBean item) {
         holder.setImageResource(R.id.iv_annot_type, item.getIconResId());
-        holder.setSelected(R.id.iv_annot_type, item.isSelect());
+        holder.setSelected(R.id.cl_annot_root, item.isSelect());
+        refreshAnnotColor(holder, item);
+
     }
 
     @Override
@@ -42,13 +48,40 @@ public class CPDFAnnotationToolListAdapter extends CBaseQuickAdapter<CAnnotToolB
            super.onBindViewHolder(holder, position, item, payloads);
         } else {
             for (Object payload : payloads) {
-                if (payload == REFRESH_SELECT) {
-                    holder.setSelected(R.id.iv_annot_type, item.isSelect());
+                if (payload == REFRESH_ITEM) {
+                    holder.setSelected(R.id.cl_annot_root, item.isSelect());
+                    refreshAnnotColor(holder, item);
                 }
             }
         }
     }
 
+    private void refreshAnnotColor(CBaseQuickViewHolder holder, CAnnotToolBean item){
+        switch (item.getType()){
+            case HIGHLIGHT:
+            case UNDERLINE:
+            case SQUIGGLY:
+            case INK:
+            case STRIKEOUT:
+                holder.setBackgroundColor(R.id.view_annot_bg, item.getBgColor());
+                holder.setImageTintList(R.id.iv_annot_type, null);
+                break;
+            case TEXT:
+                holder.setBackgroundColor(R.id.view_annot_bg, Color.TRANSPARENT);
+                if (item.getBgColor() == Color.TRANSPARENT){
+                    holder.setImageTintList(R.id.iv_annot_type, ColorStateList.valueOf(Color.BLACK));
+                }else {
+                    holder.setImageTintList(R.id.iv_annot_type, ColorStateList.valueOf(item.getBgColor()));
+                }
+                break;
+            default:
+                holder.setBackgroundColor(R.id.view_annot_bg, Color.TRANSPARENT);
+                holder.setImageTintList(R.id.iv_annot_type, null);
+                break;
+        }
+    }
+
+
     public void selectItem(int position) {
         for (int i = 0; i < list.size(); i++) {
             CAnnotToolBean item = list.get(i);
@@ -57,7 +90,7 @@ public class CPDFAnnotationToolListAdapter extends CBaseQuickAdapter<CAnnotToolB
             } else {
                 item.setSelect(false);
             }
-            notifyItemChanged(i, REFRESH_SELECT);
+            notifyItemChanged(i, REFRESH_ITEM);
         }
     }
 
@@ -69,7 +102,7 @@ public class CPDFAnnotationToolListAdapter extends CBaseQuickAdapter<CAnnotToolB
             } else {
                 item.setSelect(false);
             }
-            notifyItemChanged(i, REFRESH_SELECT);
+            notifyItemChanged(i, REFRESH_ITEM);
         }
     }
 
@@ -91,4 +124,15 @@ public class CPDFAnnotationToolListAdapter extends CBaseQuickAdapter<CAnnotToolB
         }
         return CAnnotationType.UNKNOWN;
     }
+
+    public void updateItemColor(CAnnotationType type, int color){
+        for (int i = 0; i < list.size(); i++) {
+            CAnnotToolBean item = list.get(i);
+            if (item.getType() == type) {
+                item.setBgColor(color);
+                notifyItemChanged(i, REFRESH_ITEM);
+                return;
+            }
+        }
+    }
 }

+ 18 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/bean/CAnnotToolBean.java

@@ -10,6 +10,8 @@
 package com.compdfkit.tools.common.views.pdfannotationbar.bean;
 
 
+import android.graphics.Color;
+
 import androidx.annotation.DrawableRes;
 
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
@@ -23,11 +25,19 @@ public class CAnnotToolBean {
 
     private boolean select;
 
+    private int bgColor = Color.TRANSPARENT;
+
     public CAnnotToolBean(CAnnotationType type, @DrawableRes int iconResId){
         this.type = type;
         this.iconResId = iconResId;
     }
 
+    public CAnnotToolBean(CAnnotationType type, @DrawableRes int iconResId, int bgColor){
+        this.type = type;
+        this.iconResId = iconResId;
+        this.bgColor = bgColor;
+    }
+
     public CAnnotationType getType() {
         return type;
     }
@@ -51,4 +61,12 @@ public class CAnnotToolBean {
     public void setSelect(boolean select) {
         this.select = select;
     }
+
+    public void setBgColor(int bgColor) {
+        this.bgColor = bgColor;
+    }
+
+    public int getBgColor() {
+        return bgColor;
+    }
 }

+ 24 - 7
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfannotationbar/data/CAnnotationToolDatas.java

@@ -2,22 +2,39 @@ package com.compdfkit.tools.common.views.pdfannotationbar.data;
 
 
 import com.compdfkit.tools.R;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.manager.CAnnotStyleManager;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotToolBean;
 import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
+import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
 
 import java.util.ArrayList;
 import java.util.List;
 
 public class CAnnotationToolDatas {
 
-    public static List<CAnnotToolBean> getAnnotationList() {
+    public static List<CAnnotToolBean> getAnnotationList(CPDFViewCtrl pdfView) {
         List<CAnnotToolBean> list = new ArrayList<>();
-        list.add(new CAnnotToolBean(CAnnotationType.TEXT, R.drawable.tools_ic_annotation_note));
-        list.add(new CAnnotToolBean(CAnnotationType.HIGHLIGHT, R.drawable.tools_ic_annotation_highlight));
-        list.add(new CAnnotToolBean(CAnnotationType.UNDERLINE, R.drawable.tools_ic_annotation_underline));
-        list.add(new CAnnotToolBean(CAnnotationType.STRIKEOUT, R.drawable.tools_ic_annotation_deleteline));
-        list.add(new CAnnotToolBean(CAnnotationType.SQUIGGLY, R.drawable.tools_ic_annotation_underline));
-        list.add(new CAnnotToolBean(CAnnotationType.INK, R.drawable.tools_ic_annotation_ink));
+        CAnnotStyleManager manager = new CAnnotStyleManager();
+
+        CAnnotStyle noteStyle = manager.getAnnotStyle(pdfView, CAnnotationType.TEXT);
+        list.add(new CAnnotToolBean(CAnnotationType.TEXT, R.drawable.tools_ic_annotation_note, noteStyle.getColor()));
+
+        CAnnotStyle highStyle = manager.getAnnotStyle(pdfView, CAnnotationType.HIGHLIGHT);
+        list.add(new CAnnotToolBean(CAnnotationType.HIGHLIGHT, R.drawable.tools_ic_annotation_highlight, highStyle.getColor()));
+
+        CAnnotStyle underLineStyle = manager.getAnnotStyle(pdfView, CAnnotationType.UNDERLINE);
+        list.add(new CAnnotToolBean(CAnnotationType.UNDERLINE, R.drawable.tools_ic_annotation_underline, underLineStyle.getColor()));
+
+        CAnnotStyle strikeoutStyle = manager.getAnnotStyle(pdfView, CAnnotationType.STRIKEOUT);
+        list.add(new CAnnotToolBean(CAnnotationType.STRIKEOUT, R.drawable.tools_ic_annotation_deleteline,strikeoutStyle.getColor()));
+
+        CAnnotStyle squigglyStyle = manager.getAnnotStyle(pdfView, CAnnotationType.SQUIGGLY);
+        list.add(new CAnnotToolBean(CAnnotationType.SQUIGGLY, R.drawable.tools_ic_annotation_underline,squigglyStyle.getColor()));
+
+        CAnnotStyle inkStyle = manager.getAnnotStyle(pdfView, CAnnotationType.INK);
+        list.add(new CAnnotToolBean(CAnnotationType.INK, R.drawable.tools_ic_annotation_ink, inkStyle.getColor()));
+
         list.add(new CAnnotToolBean(CAnnotationType.SQUARE, R.drawable.tools_ic_annotation_shape_rectangle));
         list.add(new CAnnotToolBean(CAnnotationType.CIRCLE, R.drawable.tools_ic_annotation_shape_circular));
         list.add(new CAnnotToolBean(CAnnotationType.ARROW, R.drawable.tools_ic_annotation_shape_arrow));

+ 12 - 6
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/basic/CBasicPropertiesFragment.java

@@ -10,20 +10,16 @@
 package com.compdfkit.tools.common.views.pdfproperties.basic;
 
 import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
 
-import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.fragment.app.Fragment;
 import androidx.lifecycle.ViewModelProvider;
 
+import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.CAnnotStyle;
 import com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.viewmodel.CAnnotStyleViewModel;
-import com.compdfkit.tools.annotation.pdfproperties.pdfattr.CAnnotStyle;
 
 
-public abstract class CBasicPropertiesFragment extends Fragment {
+public abstract class CBasicPropertiesFragment extends Fragment implements CAnnotStyle.OnAnnotStyleChangeListener {
 
     protected CAnnotStyleViewModel viewModel;
 
@@ -65,6 +61,16 @@ public abstract class CBasicPropertiesFragment extends Fragment {
         }
     }
 
+    @Override
+    public void onChangeAnnotColor(int color) {
+
+    }
+
+    @Override
+    public void onChangeAnnotColorOpacity(int opacity) {
+
+    }
+
     public interface OnSwitchFragmentListener {
 
         void nextFragment();

+ 52 - 13
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/CColorPickerFragment.java

@@ -9,9 +9,7 @@
 
 package com.compdfkit.tools.common.views.pdfproperties.colorpicker;
 
-import android.graphics.Color;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -32,27 +30,68 @@ public class CColorPickerFragment extends CBasicPropertiesFragment {
 
     private ColorPickerView colorPickerView;
 
-    private View rootView;
-
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-        rootView = inflater.inflate(R.layout.tools_color_pick_fragment, container, false);
+        View rootView = inflater.inflate(R.layout.tools_color_pick_fragment, container, false);
         colorPickerView = rootView.findViewById(R.id.color_picker_view);
         int color = viewModel.getStyle().getColor();
-        int alpha = viewModel.getStyle().getColorAlpha();
+        int alpha = viewModel.getStyle().getColorOpacity();
         colorPickerView.initColor(color, alpha);
-        colorPickerView.setColorPickerListener((color1, colorAlpha) -> {
-            viewModel.setColor(color1, colorAlpha);
-        });
-        viewModel.liveData.observe(getViewLifecycleOwner(), style -> {
-            if (!isOnResume) {
-                if (colorPickerView != null) {
-                    colorPickerView.initColor(style.getColor(), style.getColorAlpha());
+        colorPickerView.setColorPickerListener(new ColorPickerView.COnColorChangeListener() {
+            @Override
+            public void color(int color) {
+                if (viewModel != null) {
+                    viewModel.getStyle().setColor(color);
+                }
+            }
+
+            @Override
+            public void opacity(int opacity) {
+                if (viewModel != null) {
+                    viewModel.getStyle().setColorOpacity(opacity);
                 }
             }
         });
+        viewModel.addStyleChangeListener(this);
         return rootView;
     }
 
+    @Override
+    public void onChangeAnnotColor(int color) {
+        super.onChangeAnnotColor(color);
+        if (!isOnResume) {
+            if (colorPickerView != null) {
+                colorPickerView.initColor(color);
+            }
+        }
+    }
+
+    @Override
+    public void onChangeAnnotColorOpacity(int opacity) {
+        super.onChangeAnnotColorOpacity(opacity);
+        if (!isOnResume) {
+            if (colorPickerView != null) {
+                colorPickerView.initColor(opacity);
+            }
+        }
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        if (colorPickerView != null) {
+            int color = viewModel.getStyle().getColor();
+            int alpha = viewModel.getStyle().getColorOpacity();
+            colorPickerView.initColor(color, alpha);
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        if (viewModel != null) {
+            viewModel.removeStyleChangeListener(this);
+        }
+    }
 }

+ 7 - 7
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorAlphaSliderView.java

@@ -49,7 +49,7 @@ class ColorAlphaSliderView extends View implements CMotionEventUpdatable {
 
     private CThrottledTouchEventHandler handler;
 
-    private OnPercentChangeListener onPercentChangeListener;
+    private OnColorOpacityChangeListener onColorOpacityChangeListener;
 
     private float percent = 0F;
 
@@ -134,8 +134,8 @@ class ColorAlphaSliderView extends View implements CMotionEventUpdatable {
         updateValue(event.getX());
         boolean isTouchUpEvent = event.getActionMasked() == MotionEvent.ACTION_UP;
         if (!onlyUpdateOnTouchEventUp || isTouchUpEvent) {
-            if (onPercentChangeListener != null) {
-                onPercentChangeListener.value((int) (percent * 255));
+            if (onColorOpacityChangeListener != null) {
+                onColorOpacityChangeListener.opacity((int) (percent * 255));
             }
         }
     }
@@ -179,12 +179,12 @@ class ColorAlphaSliderView extends View implements CMotionEventUpdatable {
         this.onlyUpdateOnTouchEventUp = onlyUpdateOnTouchEventUp;
     }
 
-    public void setOnPercentChangeListener(OnPercentChangeListener onPercentChangeListener) {
-        this.onPercentChangeListener = onPercentChangeListener;
+    public void setColorOpacityChangeListener(OnColorOpacityChangeListener onColorOpacityChangeListener) {
+        this.onColorOpacityChangeListener = onColorOpacityChangeListener;
     }
 
-    public interface OnPercentChangeListener {
-        void value(int percent);
+    public interface OnColorOpacityChangeListener {
+        void opacity(int opacity);
     }
 }
 

+ 42 - 21
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorPickerView.java

@@ -12,7 +12,6 @@ package com.compdfkit.tools.common.views.pdfproperties.colorpicker.widget;
 import android.content.Context;
 import android.graphics.Color;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.FrameLayout;
@@ -34,7 +33,7 @@ public class ColorPickerView extends FrameLayout implements View.OnTouchListener
 
     private ColorSliderView colorSliderView;
 
-    private ColorAlphaSliderView colorAlphaSliderView;
+    private ColorAlphaSliderView colorOpacitySliderView;
 
     private int color = Color.BLACK;
 
@@ -44,7 +43,7 @@ public class ColorPickerView extends FrameLayout implements View.OnTouchListener
 
     private int lastColorAlpha = 255;
 
-    private ColorRectShowView.OnColorPickerListener colorPickerListener;
+    private COnColorChangeListener colorPickerListener;
 
     public ColorPickerView(@NonNull Context context) {
         this(context, null);
@@ -65,24 +64,27 @@ public class ColorPickerView extends FrameLayout implements View.OnTouchListener
         mLastColorShowView = findViewById(R.id.id_bottom_customize_cv_last);
         colorRectView = findViewById(R.id.id_bottom_customize_v_color_set);
         colorSliderView = findViewById(R.id.id_customize_color_slider);
-        colorAlphaSliderView = findViewById(R.id.id_customize_color_alpha_slider);
+        colorOpacitySliderView = findViewById(R.id.id_customize_color_alpha_slider);
 
         colorRectView.setColorSelectListener(color1 -> {
             mCurrentIndicatorColorView.changeColor(color1);
             colorSliderView.setBaseColor(color1);
-            colorAlphaSliderView.setBaseColor(color1);
+            colorOpacitySliderView.setBaseColor(color1);
         });
 
         colorSliderView.setOnColorLightChange(color1 -> {
             mCurrentIndicatorColorView.changeColor(color1);
         });
 
-        colorAlphaSliderView.setOnPercentChangeListener(percent -> {
-            mCurrentIndicatorColorView.changeAlpha(percent);
+        colorOpacitySliderView.setColorOpacityChangeListener(opacity -> {
+            mCurrentIndicatorColorView.changeAlpha(opacity);
+            if (colorPickerListener != null) {
+                colorPickerListener.opacity(opacity);
+            }
         });
         colorRectView.setOnTouchListener(this::onTouch);
         colorSliderView.setOnTouchListener(this::onTouch);
-        colorAlphaSliderView.setOnTouchListener(this::onTouch);
+//        colorOpacitySliderView.setOnTouchListener(this::onTouch);
     }
 
     public void initColor(@ColorInt int color, int colorAlpha){
@@ -93,35 +95,54 @@ public class ColorPickerView extends FrameLayout implements View.OnTouchListener
         updateColorView();
     }
 
+    public void initColor(@ColorInt int color){
+        this.color = color;
+        this.lastColor = color;
+        updateColorView();
+    }
+
+    public void initOpacity(int colorAlpha){
+        this.colorAlpha = colorAlpha;
+        this.lastColorAlpha = colorAlpha;
+        updateColorView();
+    }
+
+
+    public void refreshColor(){
+        initColor(this.color, this.colorAlpha);
+    }
 
 
     private void updateColorView(){
         colorRectView.setColor(color);
         colorSliderView.setBaseColor(color);
-        colorAlphaSliderView.setBaseColor(color);
-        colorAlphaSliderView.setPercent(colorAlpha / 255F);
+        colorOpacitySliderView.setBaseColor(color);
+        colorOpacitySliderView.setPercent(colorAlpha / 255F);
         mCurrentIndicatorColorView.changeColor(color);
         mCurrentIndicatorColorView.changeAlpha(colorAlpha);
-        colorAlphaSliderView.invalidate();
+        colorOpacitySliderView.invalidate();
         mLastColorShowView.changeAlpha(lastColorAlpha);
         mLastColorShowView.changeColor(lastColor);
     }
 
-    private void updateColor(){
-        if (colorPickerListener != null) {
-            colorPickerListener.color(mCurrentIndicatorColorView.getColor(), mCurrentIndicatorColorView.getColorAlpha());
+    @Override
+    public boolean onTouch(View v, MotionEvent event) {
+        if (event.getActionMasked() == MotionEvent.ACTION_UP){
+            if (colorPickerListener != null) {
+                colorPickerListener.color(mCurrentIndicatorColorView.getColor());
+            }
         }
+        return false;
     }
 
-    public void setColorPickerListener(ColorRectShowView.OnColorPickerListener colorPickerListener) {
+    public void setColorPickerListener(COnColorChangeListener colorPickerListener) {
         this.colorPickerListener = colorPickerListener;
     }
 
-    @Override
-    public boolean onTouch(View v, MotionEvent event) {
-        if (event.getActionMasked() == MotionEvent.ACTION_UP){
-            updateColor();
-        }
-        return false;
+    public interface COnColorChangeListener{
+        void color(int color);
+
+        void opacity(int opacity);
     }
+
 }

+ 1 - 3
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorRectShowView.java

@@ -94,7 +94,5 @@ class ColorRectShowView extends View {
         return colorPickerData.alpha;
     }
 
-    public interface OnColorPickerListener{
-        void color(int color, int colorAlpha);
-    }
+
 }

+ 0 - 5
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/colorpicker/widget/ColorRectView.java

@@ -166,11 +166,6 @@ public class ColorRectView extends FrameLayout implements CMotionEventUpdatable
         Color.HSVToColor(color, hsv);
         updateSelector((getWidth() - (getWidth() * hsv[0]) / 360), ((1 - hsv[1]) * getHeight()));
         currentColor = color;
-//        if (!onlyUpdateOnTouchEventUp){
-//            if (colorSelectListener != null) {
-//                colorSelectListener.color(currentColor);
-//            }
-//        }
     }
 
     private void updateSelector(float eventX,float eventY) {

+ 78 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CAnnotMarkupPreviewView.java

@@ -0,0 +1,78 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ * <p>
+ * 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.views.pdfproperties.preview;
+
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatImageView;
+import androidx.appcompat.widget.AppCompatTextView;
+
+import com.compdfkit.tools.R;
+import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
+
+class CAnnotMarkupPreviewView extends CBasicAnnotPreviewView {
+
+    private AppCompatImageView ivMarkup;
+
+    private View viewMarkupBg;
+
+    public CAnnotMarkupPreviewView(@NonNull Context context) {
+        super(context);
+    }
+
+    @Override
+    protected int layoutResId() {
+        return R.layout.tools_annot_preview_markup;
+    }
+
+    @Override
+    protected void initView() {
+        ivMarkup = findViewById(R.id.iv_preview_markup);
+        viewMarkupBg = findViewById(R.id.view_markup_bg);
+    }
+
+    @Override
+    public void setColor(int color) {
+        viewMarkupBg.setBackgroundColor(color);
+    }
+
+    @Override
+    public void setColorAlpha(int alpha) {
+        float percent = (float) alpha / 255F;
+        viewMarkupBg.setAlpha(percent);
+    }
+
+    public void setMarkupType(CAnnotationType type){
+        switch(type){
+            case HIGHLIGHT:
+                ivMarkup.setImageResource(R.drawable.tools_ic_annotation_highlight);
+                break;
+            case UNDERLINE:
+                ivMarkup.setImageResource(R.drawable.tools_ic_annotation_underline);
+                break;
+            case SQUIGGLY:
+                ivMarkup.setImageResource(R.drawable.tools_ic_annotation_squiggly);
+                break;
+            case STRIKEOUT:
+                ivMarkup.setImageResource(R.drawable.tools_ic_annotation_deleteline);
+                break;
+            default:break;
+        }
+    }
+
+}

+ 51 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CAnnotNotePreviewView.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ * <p>
+ * 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.views.pdfproperties.preview;
+
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.AppCompatImageView;
+
+import com.compdfkit.tools.R;
+
+ class CAnnotNotePreviewView extends CBasicAnnotPreviewView {
+
+    private AppCompatImageView ivPreview;
+
+    public CAnnotNotePreviewView(@NonNull Context context) {
+        super(context);
+    }
+
+    @Override
+    protected int layoutResId() {
+        return R.layout.tools_annot_preview_note;
+    }
+
+    @Override
+    protected void initView() {
+        ivPreview = findViewById(R.id.iv_preview_note);
+    }
+
+    @Override
+    public void setColor(int color) {
+        if (ivPreview != null) {
+            ivPreview.setImageTintList(ColorStateList.valueOf(color));
+        }
+    }
+
+    @Override
+    public void setColorAlpha(int alpha) {
+
+    }
+
+}

+ 38 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CBasicAnnotPreviewView.java

@@ -0,0 +1,38 @@
+package com.compdfkit.tools.common.views.pdfproperties.preview;
+
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+ abstract class CBasicAnnotPreviewView extends FrameLayout {
+
+    public CBasicAnnotPreviewView(@NonNull Context context) {
+        this(context, null);
+    }
+
+    public CBasicAnnotPreviewView(@NonNull Context context, @Nullable AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public CBasicAnnotPreviewView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        inflate(context, layoutResId(), this);
+        initView();
+    }
+
+    protected abstract int layoutResId();
+
+    protected abstract void initView();
+
+    public abstract void setColor(@ColorInt int color);
+
+    public abstract void setColorAlpha(@IntRange(from = 0, to = 255) int alpha);
+
+}

+ 125 - 0
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/preview/CStylePreviewView.java

@@ -0,0 +1,125 @@
+/**
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+ * <p>
+ * 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.views.pdfproperties.preview;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.compdfkit.tools.R;
+import com.compdfkit.tools.common.views.pdfannotationbar.bean.CAnnotationType;
+
+
+public class CStylePreviewView extends FrameLayout {
+
+    private CAnnotationType annotationType = CAnnotationType.TEXT;
+
+    private CBasicAnnotPreviewView previewView;
+
+    public CStylePreviewView(@NonNull Context context) {
+        this(context, null);
+    }
+
+    public CStylePreviewView(@NonNull Context context, @Nullable AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public CStylePreviewView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        initAttr(context, attrs);
+    }
+
+    private void initAttr(Context context, AttributeSet attrs) {
+        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CStylePreviewView);
+        if (typedArray != null) {
+            int annotEnumId = typedArray.getInt(R.styleable.CStylePreviewView_tools_annot_type, 0);
+            setAnnotType(getCAnnotTypeById(annotEnumId));
+            typedArray.recycle();
+        }
+    }
+
+    public void setAnnotType(CAnnotationType type) {
+        this.annotationType = type;
+        updatePreview();
+    }
+
+    public void setColor(@ColorInt int color) {
+        if (previewView != null) {
+            previewView.setColor(color);
+        }
+    }
+
+    public void setColorAlpha(int colorAlpha){
+        if (previewView != null){
+            previewView.setColorAlpha(colorAlpha);
+        }
+    }
+
+    private void updatePreview() {
+        removeAllViews();
+        previewView = null;
+        switch (annotationType) {
+            case TEXT:
+                previewView = new CAnnotNotePreviewView(getContext());
+                break;
+            case HIGHLIGHT:
+            case UNDERLINE:
+            case SQUIGGLY:
+            case STRIKEOUT:
+                CAnnotMarkupPreviewView view = new CAnnotMarkupPreviewView(getContext());
+                view.setMarkupType(annotationType);
+                previewView = view;
+                break;
+            default:
+                break;
+        }
+        if (previewView != null) {
+            addView(previewView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+        }
+    }
+
+    private CAnnotationType getCAnnotTypeById(int attrEnumId) {
+        switch (attrEnumId) {
+            case 0:
+                return CAnnotationType.TEXT;
+            case 1:
+                return CAnnotationType.HIGHLIGHT;
+            case 2:
+                return CAnnotationType.UNDERLINE;
+            case 3:
+                return CAnnotationType.SQUIGGLY;
+            case 4:
+                return CAnnotationType.STRIKEOUT;
+            case 5:
+                return CAnnotationType.INK;
+            case 6:
+                return CAnnotationType.CIRCLE;
+            case 7:
+                return CAnnotationType.SQUARE;
+            case 8:
+                return CAnnotationType.ARROW;
+            case 9:
+                return CAnnotationType.LINE;
+            case 10:
+                return CAnnotationType.FREE_TEXT;
+            case 11:
+                return CAnnotationType.SIGNATURE;
+            default:
+                return CAnnotationType.UNKNOWN;
+        }
+    }
+
+}

+ 0 - 1
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/sliderbar/CSliderBar.java

@@ -28,7 +28,6 @@ import com.compdfkit.tools.R;
 
 public class CSliderBar extends FrameLayout implements SeekBar.OnSeekBarChangeListener {
 
-
     enum ValueShowType {
         Source,
         Percentage

+ 1 - 3
compdfkit-tools/src/main/java/com/compdfkit/tools/common/views/pdfview/CPDFViewCtrl.java

@@ -192,9 +192,7 @@ public class CPDFViewCtrl extends RelativeLayout implements IReaderViewCallback
         cPdfReaderView.setReaderViewCallback(this);
         cPdfReaderView.setContextMenuShowListener(new CContextMenuHelper(cPdfReaderView));
         cPdfReaderView.setOnFocusedTypeChangedListener(this);
-        setAllowAddAndEditAnnot(false);
-//        cPdfReaderView.getAnnotImplRegistry().registAttachHelper(CPDFTextAnnotation.class, CPDFtextAnnotAttachHelper.class);
-//        cPdfReaderView.getAnnotImplRegistry().registImpl(CPDFTextAnnotation.class, CPDFtextAnnotImpl.class);
+
         addView(cPdfReaderView);
     }
 

+ 5 - 0
compdfkit-tools/src/main/res/drawable/tools_ic_note.xml

@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#000000"
+    android:viewportHeight="24" android:viewportWidth="24"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="@android:color/white" android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM8,14L6,14v-2h2v2zM8,11L6,11L6,9h2v2zM8,8L6,8L6,6h2v2zM15,14h-5v-2h5v2zM18,11h-8L10,9h8v2zM18,8h-8L10,6h8v2z"/>
+</vector>

+ 5 - 0
compdfkit-tools/src/main/res/drawable/tools_ic_save.xml

@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#000000"
+    android:viewportHeight="24" android:viewportWidth="24"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="@android:color/white" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
+</vector>

+ 5 - 0
compdfkit-tools/src/main/res/drawable/tools_properties_note_dialog_bg.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <corners android:radius="6dp"/>
+    <solid android:color="#FFF4D5"/>
+</shape>

+ 15 - 2
compdfkit-tools/src/main/res/layout/tools_annot_list_item.xml

@@ -3,13 +3,26 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
+    android:id="@+id/cl_annot_root"
+    android:background="@drawable/tools_annotation_tool_list_item_bg"
+    android:layout_margin="4dp"
     android:animateLayoutChanges="true">
 
+
+    <View
+        android:id="@+id/view_annot_bg"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_margin="8dp"
+        app:layout_constraintTop_toTopOf="@id/iv_annot_type"
+        app:layout_constraintBottom_toBottomOf="@id/iv_annot_type"
+        app:layout_constraintStart_toStartOf="@id/iv_annot_type"
+        app:layout_constraintEnd_toEndOf="@id/iv_annot_type"
+        />
+
     <androidx.appcompat.widget.AppCompatImageView
         android:id="@+id/iv_annot_type"
         style="@style/tools_annotation_tool_bar_item_iv_style"
-        android:layout_margin="4dp"
-        android:background="@drawable/tools_annotation_tool_list_item_bg"
         android:src="@drawable/tools_ic_annotation_highlight"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"

+ 31 - 0
compdfkit-tools/src/main/res/layout/tools_annot_preview_markup.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="80dp"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <View
+        android:id="@+id/view_markup_bg"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintTop_toTopOf="@id/iv_preview_markup"
+        app:layout_constraintBottom_toBottomOf="@id/iv_preview_markup"
+        app:layout_constraintStart_toStartOf="@id/iv_preview_markup"
+        app:layout_constraintEnd_toEndOf="@id/iv_preview_markup"
+        android:background="@color/tools_md_theme_light_primary"
+        />
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/iv_preview_markup"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintDimensionRatio="1:1"
+        app:layout_constraintHeight_percent="0.7"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:srcCompat="@drawable/tools_ic_annotation_highlight"
+        />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 21 - 0
compdfkit-tools/src/main/res/layout/tools_annot_preview_note.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="80dp"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/iv_preview_note"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintHeight_percent="0.7"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:srcCompat="@drawable/tools_ic_note"
+        />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 1
compdfkit-tools/src/main/res/layout/tools_common_slider_bar.xml

@@ -11,7 +11,7 @@
         android:layout_height="wrap_content"
         android:layout_marginStart="16dp"
         android:layout_marginTop="16dp"
-        android:text="@string/tools_transparency"
+        android:text="@string/tools_opacity"
         android:textColor="?android:attr/textColorPrimary"
         android:textSize="18sp" />
 

+ 4 - 3
compdfkit-tools/src/main/res/layout/tools_properties_markup_style_fragment.xml

@@ -5,10 +5,11 @@
     android:layout_height="match_parent">
 
 
-    <androidx.appcompat.widget.AppCompatImageView
-        android:id="@+id/iv_markup_sample"
+    <com.compdfkit.tools.common.views.pdfproperties.preview.CStylePreviewView
+        android:id="@+id/style_preview"
         android:layout_width="match_parent"
         android:layout_height="80dp"
+        app:tools_annot_type="highlight"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
@@ -20,7 +21,7 @@
         android:layout_height="wrap_content"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/iv_markup_sample" />
+        app:layout_constraintTop_toBottomOf="@id/style_preview" />
 
     <com.compdfkit.tools.common.views.pdfproperties.sliderbar.CSliderBar
         android:id="@+id/slider_bar"

+ 49 - 0
compdfkit-tools/src/main/res/layout/tools_properties_note_edit_dialog.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@drawable/tools_properties_note_dialog_bg">
+
+    <androidx.appcompat.widget.AppCompatEditText
+        android:id="@+id/id_note_content"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_margin="16dp"
+        android:background="@null"
+        android:gravity="start|top"
+        android:textColor="?android:attr/textColorPrimary"
+        android:textSize="14sp"
+        app:layout_constraintBottom_toTopOf="@id/id_note_delete"
+        app:layout_constraintTop_toTopOf="parent"
+        tools:text="" />
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/id_note_delete"
+        android:layout_width="36dp"
+        android:layout_height="36dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginBottom="10dp"
+        android:padding="6dp"
+        android:background="@drawable/tools_common_oval_ripple"
+        app:tint="?android:attr/colorAccent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:srcCompat="@drawable/tools_ic_delete" />
+
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/id_note_save"
+        android:layout_width="36dp"
+        android:layout_height="36dp"
+        android:layout_marginEnd="8dp"
+        android:layout_marginBottom="10dp"
+        android:background="@drawable/tools_common_oval_ripple"
+        android:padding="6dp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="@id/id_note_delete"
+        app:srcCompat="@drawable/tools_ic_save"
+        app:tint="?android:attr/colorAccent"
+        />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 4 - 3
compdfkit-tools/src/main/res/layout/tools_properties_note_style_fragment.xml

@@ -6,10 +6,11 @@
     android:paddingBottom="16dp">
 
 
-    <androidx.appcompat.widget.AppCompatImageView
-        android:id="@+id/iv_markup_sample"
+    <com.compdfkit.tools.common.views.pdfproperties.preview.CStylePreviewView
+        android:id="@+id/style_preview"
         android:layout_width="match_parent"
         android:layout_height="80dp"
+        app:tools_annot_type="text"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
@@ -21,6 +22,6 @@
         android:layout_height="wrap_content"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/iv_markup_sample" />
+        app:layout_constraintTop_toBottomOf="@id/style_preview" />
 
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 17 - 0
compdfkit-tools/src/main/res/values/tools_attrs.xml

@@ -48,4 +48,21 @@
         </attr>
         <attr name="tools_slider_bar_show_value" format="boolean"/>
     </declare-styleable>
+
+    <declare-styleable name="CStylePreviewView" tools:ignore="ResourceName">
+        <attr name="tools_annot_type" format="enum">
+            <enum name="text" value="0"/>
+            <enum name="highlight" value="1"/>
+            <enum name="underline" value="2"/>
+            <enum name="squiggly" value="3"/>
+            <enum name="strikeout" value="4"/>
+            <enum name="ink" value="5"/>
+            <enum name="circle" value="6"/>
+            <enum name="square" value="7"/>
+            <enum name="arrow" value="8"/>
+            <enum name="line" value="9"/>
+            <enum name="freetext" value="10"/>
+            <enum name="signature" value="11"/>
+        </attr>
+    </declare-styleable>
 </resources>

+ 1 - 1
compdfkit-tools/src/main/res/values/tools_strings.xml

@@ -65,7 +65,7 @@
     <string name="tools_custom_themes_color">Custom</string>
 
     <string name="tools_color">Color:</string>
-    <string name="tools_transparency">Transparency:</string>
+    <string name="tools_opacity">Opacity:</string>
     <string name="tools_annot_highlight">Highlight</string>
     <string name="tools_annot_underline">Underline</string>
     <string name="tools_annot_strikeout">StrikeOut</string>

+ 1 - 0
viewer-ctrl-demo/src/main/java/com/compdfkit/demo/viewer/PDFViewerSampleActivity.java

@@ -45,6 +45,7 @@ public class PDFViewerSampleActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         binding = ViewerPdfSampleActivityBinding.inflate(getLayoutInflater());
         setContentView(binding.getRoot());
+        binding.pdfView.setAllowAddAndEditAnnot(false);
         initToolbarListener();
         initSearchBar();
         //Extract PDF files from the Android assets folder