|
@@ -12,12 +12,14 @@ package com.compdfkit.tools.annotation.pdfproperties.pdfannotstyle.manager;
|
|
|
import androidx.annotation.ColorInt;
|
|
|
import androidx.annotation.IntRange;
|
|
|
|
|
|
+import com.compdfkit.core.annotation.CPDFInkAnnotation;
|
|
|
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.CPDFInkAttr;
|
|
|
import com.compdfkit.ui.attribute.CPDFSquigglyAttr;
|
|
|
import com.compdfkit.ui.attribute.CPDFStrikeoutAttr;
|
|
|
import com.compdfkit.ui.attribute.CPDFUnderlineAttr;
|
|
@@ -30,7 +32,7 @@ import java.util.LinkedHashSet;
|
|
|
|
|
|
public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListener {
|
|
|
|
|
|
- public void apply(CPDFViewCtrl pdfView, CAnnotStyle style, boolean onStore){
|
|
|
+ public void apply(CPDFViewCtrl pdfView, CAnnotStyle style, boolean onStore) {
|
|
|
LinkedHashSet<CAnnotStyle> linkedHashSet = new LinkedHashSet<>();
|
|
|
linkedHashSet.add(style);
|
|
|
apply(pdfView, linkedHashSet, onStore);
|
|
@@ -76,6 +78,13 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
strikeoutAttr.setAlpha(params.getColorOpacity());
|
|
|
callback = strikeoutAttr;
|
|
|
break;
|
|
|
+ case INK:
|
|
|
+ CPDFInkAttr inkAttr = attribute.getInkAttr();
|
|
|
+ inkAttr.setColor(params.getColor());
|
|
|
+ inkAttr.setAlpha(params.getColorOpacity());
|
|
|
+ inkAttr.setBorderWidth(params.getBorderWidth());
|
|
|
+ inkAttr.setEraseWidth(params.getEraserWidth());
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -87,7 +96,7 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void changeAnnotStyle(){
|
|
|
+ public void changeAnnotStyle() {
|
|
|
|
|
|
|
|
|
}
|
|
@@ -96,7 +105,7 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
|
|
|
private CPDFViewCtrl pdfView;
|
|
|
|
|
|
- public void bindAnnotStyleFragment(CPDFViewCtrl pdfView, CAnnotStyleDialogFragment styleDialogFragment){
|
|
|
+ public void bindAnnotStyleFragment(CPDFViewCtrl pdfView, CAnnotStyleDialogFragment styleDialogFragment) {
|
|
|
this.pdfView = pdfView;
|
|
|
annotStyleDialogFragment = styleDialogFragment;
|
|
|
annotStyleDialogFragment.addAnnotStyleChangeListener(this);
|
|
@@ -104,21 +113,27 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
|
|
|
@Override
|
|
|
public void onChangeAnnotColor(int color) {
|
|
|
- if (pdfView != null && annotStyleDialogFragment != null) {
|
|
|
- CAnnotStyle style = annotStyleDialogFragment.getStyle();
|
|
|
- apply(pdfView, style, false);
|
|
|
- }
|
|
|
+ updateAnnot();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onChangeAnnotColorOpacity(int opacity) {
|
|
|
+ updateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onChangeAnnotBorderWidth(float borderWidth) {
|
|
|
+ updateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateAnnot() {
|
|
|
if (pdfView != null && annotStyleDialogFragment != null) {
|
|
|
CAnnotStyle style = annotStyleDialogFragment.getStyle();
|
|
|
apply(pdfView, style, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public CAnnotStyle getAnnotStyle(CPDFViewCtrl pdfView, CAnnotationType type){
|
|
|
+ public CAnnotStyle getAnnotStyle(CPDFViewCtrl pdfView, CAnnotationType type) {
|
|
|
CAnnotStyle style = new CAnnotStyle(type);
|
|
|
CPDFAnnotAttribute attribute = pdfView.getCPdfReaderView().getReaderAttribute().getAnnotAttribute();
|
|
|
switch (type) {
|
|
@@ -149,6 +164,11 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
style.setColor(strikeoutAttr.getColor());
|
|
|
style.setColorOpacity(strikeoutAttr.getAlpha());
|
|
|
break;
|
|
|
+ case INK:
|
|
|
+ CPDFInkAttr inkAttr = attribute.getInkAttr();
|
|
|
+ style.setColor(inkAttr.getColor());
|
|
|
+ style.setColorOpacity(inkAttr.getAlpha());
|
|
|
+ style.setBorderWidth(inkAttr.getBorderWidth());
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -165,7 +185,7 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
this.pdfView = pdfView;
|
|
|
}
|
|
|
|
|
|
- public Builder setColor(CAnnotationType type, @ColorInt int color){
|
|
|
+ public Builder setColor(CAnnotationType type, @ColorInt int color) {
|
|
|
CAnnotStyle style = new CAnnotStyle(type);
|
|
|
style.setColor(color);
|
|
|
attrSet.add(style);
|
|
@@ -181,10 +201,18 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Builder setInkAttribute(@ColorInt int color, @IntRange(from = 0, to = 255) int colorAlpha) {
|
|
|
+ public Builder setInkAttribute(@ColorInt int color, @IntRange(from = 0, to = 255) int colorAlpha, int borderWidth) {
|
|
|
CAnnotStyle style = new CAnnotStyle(CAnnotationType.INK);
|
|
|
style.setColor(color);
|
|
|
style.setColorOpacity(colorAlpha);
|
|
|
+ style.setBorderWidth(borderWidth);
|
|
|
+ attrSet.add(style);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setEraserWidth(int borderWidth){
|
|
|
+ CAnnotStyle style = new CAnnotStyle(CAnnotationType.INK);
|
|
|
+ style.setEraserWidth(borderWidth);
|
|
|
attrSet.add(style);
|
|
|
return this;
|
|
|
}
|
|
@@ -209,7 +237,7 @@ public class CAnnotStyleManager implements CAnnotStyle.OnAnnotStyleChangeListene
|
|
|
return new CAnnotStyleManager();
|
|
|
}
|
|
|
|
|
|
- public void clear(){
|
|
|
+ public void clear() {
|
|
|
attrSet.clear();
|
|
|
}
|
|
|
|