Skip to content

Commit c210107

Browse files
committed
PDFTool(Android) - v2.4.0
1 parent c1eaba4 commit c210107

35 files changed

+756
-239
lines changed
781 Bytes
Binary file not shown.
16 KB
Binary file not shown.

ComPDFKit_Tools/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ dependencies {
5454
// api project(path:':ComPDFKit_Repo:compdfkit')
5555
// api project(path:':ComPDFKit_Repo:compdfkit-ui')
5656
// or use
57-
api ('com.compdf:compdfkit:2.3.0')
58-
api ('com.compdf:compdfkit-ui:2.3.0')
57+
api ('com.compdf:compdfkit:2.4.0')
58+
api ('com.compdf:compdfkit-ui:2.4.0')
5959
api 'com.github.bumptech.glide:glide:4.15.1'
6060
annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
6161
api 'androidx.documentfile:documentfile:1.0.1'

ComPDFKit_Tools/src/main/assets/tools_default_configuration.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"squiggly",
5050
"strikeout",
5151
"ink",
52+
"ink_eraser",
5253
"circle",
5354
"square",
5455
"arrow",
@@ -266,7 +267,10 @@
266267
"themeMode" : "system",
267268
"fileSaveExtraFontSubset" : true,
268269
"watermark": {
269-
"saveAsNewFile" : true
270-
}
270+
"saveAsNewFile" : true,
271+
"outsideBackgroundColor" : ""
272+
},
273+
"signatureType": "manual",
274+
"enableExitSaveTips" : true
271275
}
272276
}

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfannotationbar/CAnnotationToolbar.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.manager.CStyleManager;
4949
import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
5050
import com.compdfkit.ui.proxy.attach.IInkDrawCallback;
51+
import com.compdfkit.ui.reader.CPDFReaderView;
5152

5253
import java.util.Arrays;
5354
import java.util.Collections;
@@ -108,14 +109,15 @@ public void initWithPDFView(CPDFViewCtrl pdfView) {
108109
this.pdfView.addOnPDFFocusedTypeChangeListener(type -> {
109110
if (type == CPDFAnnotation.Type.UNKNOWN) {
110111
if (toolListAdapter.hasSelectAnnotType()) {
111-
toolListAdapter.selectByType(CAnnotationType.UNKNOWN);
112+
if (toolListAdapter.getCurrentAnnotType() != CAnnotationType.INK_ERASER){
113+
toolListAdapter.selectByType(CAnnotationType.UNKNOWN);
114+
}
112115
if (ivSetting != null) {
113116
ivSetting.setEnabled(toolListAdapter.annotEnableSetting());
114117
}
115118
}
116119
}
117120
});
118-
// redoUndoManager();
119121
}
120122

121123
private void showAnnotStyleDialog() {
@@ -138,7 +140,6 @@ public void onChangeColor(int color) {
138140
public void onChangeOpacity(int opacity) {
139141
super.onChangeOpacity(opacity);
140142
toolListAdapter.updateItemColorOpacity(toolListAdapter.getCurrentAnnotType(), opacity);
141-
142143
}
143144
});
144145
dialogFragment.setStyleDialogDismissListener(() -> {
@@ -163,16 +164,13 @@ private void switchAnnotationType(CAnnotToolBean bean) {
163164
}
164165
if (!bean.isSelect()) {
165166
pdfView.resetAnnotationType();
166-
pdfView.getCPdfReaderView().getInkDrawHelper().onClean();
167+
pdfView.getCPdfReaderView().getInkDrawHelper().onSave();
167168
if (annotationChangeListener != null) {
168169
annotationChangeListener.change(CAnnotationType.UNKNOWN);
169170
}
170171
return;
171172
}
172-
if (bean.getType() != CAnnotationType.INK) {
173-
pdfView.getCPdfReaderView().getInkDrawHelper().onClean();
174-
pdfView.getCPdfReaderView().getInkDrawHelper().setMode(IInkDrawCallback.Mode.DRAW);
175-
}
173+
pdfView.getCPdfReaderView().getInkDrawHelper().onSave();
176174
pdfView.getCPdfReaderView().removeAllAnnotFocus();
177175
switch (bean.getType()) {
178176
case TEXT:
@@ -182,6 +180,10 @@ private void switchAnnotationType(CAnnotToolBean bean) {
182180
pdfView.changeAnnotationType(CPDFAnnotation.Type.INK);
183181
pdfView.getCPdfReaderView().getInkDrawHelper().setEffect(IInkDrawCallback.Effect.NORMAL);
184182
break;
183+
case INK_ERASER:
184+
pdfView.resetAnnotationType();
185+
pdfView.getCPdfReaderView().setTouchMode(CPDFReaderView.TouchMode.ERASE_INK);
186+
break;
185187
case ARROW: {
186188
pdfView.changeAnnotationType(CPDFAnnotation.Type.LINE);
187189
CStyleManager styleManager = new CStyleManager(pdfView);
@@ -258,6 +260,9 @@ public void updateItemColor() {
258260
if (pdfView == null) {
259261
return;
260262
}
263+
if (toolListAdapter == null || toolListAdapter.list.isEmpty()){
264+
return;
265+
}
261266
CStyleManager styleManager = new CStyleManager(pdfView);
262267
CAnnotStyle noteStyle = styleManager.getStyle(CStyleType.ANNOT_TEXT);
263268
toolListAdapter.updateItem(CAnnotationType.TEXT, noteStyle.getColor(), noteStyle.getOpacity());
@@ -401,4 +406,5 @@ public void setAnnotationList(CAnnotationType... types) {
401406
toolListAdapter.setList(list);
402407
}
403408

409+
404410
}

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfannotationbar/adapter/CPDFAnnotationToolListAdapter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,27 @@ public CAnnotationType getCurrentAnnotType() {
148148
return CAnnotationType.UNKNOWN;
149149
}
150150

151+
public CAnnotToolBean getSelectItem() {
152+
for (CAnnotToolBean cAnnotToolBean : list) {
153+
if (cAnnotToolBean.isSelect()) {
154+
return cAnnotToolBean;
155+
}
156+
}
157+
return null;
158+
}
159+
160+
161+
151162
public boolean annotEnableSetting() {
152163
CAnnotationType type = getCurrentAnnotType();
164+
CAnnotToolBean item = getSelectItem();
153165
return type != CAnnotationType.SIGNATURE &&
154166
type != CAnnotationType.STAMP &&
155167
type != CAnnotationType.PIC &&
156168
type != CAnnotationType.LINK &&
157169
type != CAnnotationType.SOUND &&
158-
type != CAnnotationType.UNKNOWN;
170+
type != CAnnotationType.UNKNOWN &&
171+
type != CAnnotationType.INK_ERASER;
159172
}
160173

161174
public void updateItemColor(CAnnotationType type,@ColorInt int color) {

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfannotationbar/data/CAnnotationToolDatas.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static List<CAnnotToolBean> getAnnotationList(CPDFViewCtrl pdfView) {
4141
list.add(new CAnnotToolBean(CAnnotationType.INK, R.drawable.tools_ic_annotation_ink,
4242
R.drawable.tools_ic_annotation_ink_dark, inkStyle.getColor(), inkStyle.getOpacity()));
4343

44+
list.add(new CAnnotToolBean(CAnnotationType.INK_ERASER, R.drawable.tools_ic_eraser));
4445
list.add(new CAnnotToolBean(CAnnotationType.CIRCLE, R.drawable.tools_ic_annotation_shape_circular));
4546
list.add(new CAnnotToolBean(CAnnotationType.SQUARE, R.drawable.tools_ic_annotation_shape_rectangle));
4647
list.add(new CAnnotToolBean(CAnnotationType.ARROW, R.drawable.tools_ic_annotation_shape_arrow));

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdflnk/CInkCtrlView.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import androidx.annotation.Nullable;
1919
import androidx.appcompat.widget.AppCompatImageView;
2020
import androidx.appcompat.widget.AppCompatTextView;
21+
import androidx.fragment.app.Fragment;
2122
import androidx.fragment.app.FragmentActivity;
2223

2324
import com.compdfkit.tools.R;
25+
import com.compdfkit.tools.common.pdf.CPDFDocumentFragment;
2426
import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
2527
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CAnnotStyle;
2628
import com.compdfkit.tools.common.views.pdfproperties.pdfstyle.CStyleDialogFragment;
@@ -127,6 +129,7 @@ public void onClick(View v) {
127129
CStyleDialogFragment styleDialogFragment = CStyleDialogFragment.newInstance(style);
128130
styleDialogFragment.setStyleDialogDismissListener(()->{
129131
ivSetting.setSelected(false);
132+
changeAnnotToolbarInkColor();
130133
});
131134
styleManager.setAnnotStyleFragmentListener(styleDialogFragment);
132135
FragmentActivity fragmentActivity = CViewUtils.getFragmentActivity(getContext());
@@ -135,4 +138,17 @@ public void onClick(View v) {
135138
}
136139
}
137140
}
141+
142+
private void changeAnnotToolbarInkColor(){
143+
CPDFReaderView readerView = pdfView.getCPdfReaderView();
144+
FragmentActivity fragmentActivity = CViewUtils.getFragmentActivity(readerView.getContext());
145+
if (fragmentActivity != null){
146+
Fragment fragment = fragmentActivity.getSupportFragmentManager()
147+
.findFragmentByTag("documentFragment");
148+
if (fragment != null && fragment instanceof CPDFDocumentFragment){
149+
CPDFDocumentFragment documentFragment = (CPDFDocumentFragment) fragment;
150+
documentFragment.annotationToolbar.updateItemColor();
151+
}
152+
}
153+
}
138154
}

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfsignature/CAddSignatureActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private void initView() {
206206
ivNone.setVisibility(showNoneType ? View.VISIBLE : View.GONE);
207207
}
208208
hideTypeface = getIntent().getBooleanExtra(EXTRA_HIDE_TYPEFACE, false);
209-
fontView.initFont("Nimbus Sans");
209+
fontView.initFont("Helvetica");
210210
}
211211

212212
private void switchTab(int selectPosition) {
@@ -303,7 +303,7 @@ private void saveBitmap() {
303303
savePath = CSignatureDatas.saveSignatureBitmap(this, resultBitmap);
304304
} else if (ivAddTextSignature.isSelected()) {
305305
if (editText.getText() != null && editText.getText().length() > 0) {
306-
Bitmap resultBitmap = CImageUtil.getViewBitmap(editText);
306+
Bitmap resultBitmap = CImageUtil.convertLongTextToBitmap(editText);
307307
savePath = CSignatureDatas.saveSignatureBitmap(this, resultBitmap);
308308
} else {
309309
savePath = null;

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/basic/fragment/CBasicPDFFragment.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.compdfkit.tools.forms.pdfproperties.pdfcombobox.CustomComboBoxWidgetImpl;
4747
import com.compdfkit.tools.forms.pdfproperties.pdflistbox.CustomListBoxWidgetImpl;
4848
import com.compdfkit.tools.forms.pdfproperties.pdfsign.CustomSignatureWidgetImpl;
49+
import com.compdfkit.tools.forms.pdfproperties.pdfsign.SignatureWidgetImpl;
4950
import com.compdfkit.tools.viewer.contextmenu.CopyContextMenuView;
5051
import com.compdfkit.tools.viewer.pdfdisplaysettings.CPDFDisplaySettingDialogFragment;
5152
import com.compdfkit.tools.viewer.pdfinfo.CPDFDocumentInfoDialogFragment;
@@ -61,6 +62,8 @@ public class CBasicPDFFragment extends CPermissionFragment {
6162

6263
public int curEditMode = CPDFEditPage.LoadNone;
6364

65+
private CPDFPageEditDialogFragment.COnEnterBackPressedListener pageEditDialogOnBackListener;
66+
6467

6568
protected void resetContextMenu(CPDFViewCtrl pdfView, CPreviewMode mode) {
6669
switch (mode) {
@@ -117,7 +120,7 @@ protected void registerFormHelper(CPDFViewCtrl pdfView) {
117120
// Register the CustomListBoxWidgetImpl.class to implement a custom dropdown options popup.
118121
.registImpl(CPDFListboxWidget.class, CustomListBoxWidgetImpl.class)
119122
// Register the CustomSignatureWidgetImpl.class to implement a custom dropdown options popup.
120-
.registImpl(CPDFSignatureWidget.class, CustomSignatureWidgetImpl.class);
123+
.registImpl(CPDFSignatureWidget.class, SignatureWidgetImpl.class);
121124
}
122125

123126
public void showDisplaySettings(CPDFViewCtrl pdfView) {
@@ -177,6 +180,12 @@ protected void sharePDF(CPDFViewCtrl pdfView) {
177180
});
178181
}
179182

183+
184+
public void setPageEditDialogOnBackListener(
185+
CPDFPageEditDialogFragment.COnEnterBackPressedListener pageEditDialogOnBackListener) {
186+
this.pageEditDialogOnBackListener = pageEditDialogOnBackListener;
187+
}
188+
180189
protected void showPageEdit(CPDFViewCtrl pdfView, boolean enterEdit, CPDFPageEditDialogFragment.OnBackLisener backListener) {
181190
curEditMode = pdfView.getCPdfReaderView().getLoadType();
182191
pdfView.exitEditMode();
@@ -185,6 +194,11 @@ protected void showPageEdit(CPDFViewCtrl pdfView, boolean enterEdit, CPDFPageEdi
185194
pageEditDialogFragment.initWithPDFView(pdfView);
186195
pageEditDialogFragment.setEnterEdit(enterEdit);
187196
pageEditDialogFragment.setOnBackListener(backListener);
197+
pageEditDialogFragment.setOnEnterBackPressedListener(()->{
198+
if (pageEditDialogOnBackListener != null) {
199+
pageEditDialogOnBackListener.onEnterBackPressed();
200+
}
201+
});
188202
pageEditDialogFragment.show(getChildFragmentManager(), "pageEditDialogFragment");
189203
}
190204

0 commit comments

Comments
 (0)