Skip to content

Commit 3535f67

Browse files
committed
v2.6.8
1 parent 2911a03 commit 3535f67

39 files changed

Lines changed: 1005 additions & 925 deletions
737 Bytes
Binary file not shown.
4.98 KB
Binary file not shown.

ComPDFKit_Tools/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ dependencies {
5555
// api project(path:':ComPDFKit_Repo:compdfkit')
5656
// api project(path:':ComPDFKit_Repo:compdfkit-ui')
5757
// or use
58-
api ('com.compdf:compdfkit:2.6.7')
59-
api ('com.compdf:compdfkit-ui:2.6.7')
58+
api ('com.compdf:compdfkit:2.6.8')
59+
api ('com.compdf:compdfkit-ui:2.6.8')
6060
api 'com.github.bumptech.glide:glide:4.15.1'
6161
annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
6262
api "androidx.print:print:1.0.0"

ComPDFKit_Tools/src/main/assets/tools_default_configuration.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@
270270
"cropMode": false,
271271
"themes": "light",
272272
"enableSliderBar": true,
273+
"slideBarPosition": "right",
273274
"enablePageIndicator": true,
274275
"pageSpacing": 10,
275276
"margins": [0, 0, 0, 0],

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfproperties/pdfpic/CImageStyleFragment.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
package com.compdfkit.tools.annotation.pdfproperties.pdfpic;
1111

1212
import android.Manifest;
13+
import android.net.Uri;
1314
import android.os.Bundle;
15+
import android.text.TextUtils;
1416
import android.view.View;
1517

1618
import androidx.activity.result.ActivityResultLauncher;
@@ -20,7 +22,9 @@
2022

2123
import com.compdfkit.tools.R;
2224
import com.compdfkit.tools.common.utils.CFileUtils;
25+
import com.compdfkit.tools.common.utils.CLog;
2326
import com.compdfkit.tools.common.utils.CPermissionUtil;
27+
import com.compdfkit.tools.common.utils.CUriUtil;
2428
import com.compdfkit.tools.common.utils.activitycontracts.CImageResultContracts;
2529
import com.compdfkit.tools.common.utils.activitycontracts.CPermissionResultLauncher;
2630
import com.compdfkit.tools.common.utils.date.CDateUtil;
@@ -31,12 +35,24 @@
3135

3236
public class CImageStyleFragment extends CBasicPropertiesFragment {
3337

34-
private ActivityResultLauncher<CImageResultContracts.RequestType> imageLauncher = registerForActivityResult(new CImageResultContracts(), result -> {
38+
private ActivityResultLauncher<CImageResultContracts.Request> imageLauncher = registerForActivityResult(new CImageResultContracts(), result -> {
3539
if (result != null && viewModel != null) {
40+
CUriUtil.logImageUriInfo(getContext(), "pic result uri", result);
3641
File file = new File(getContext().getFilesDir(), CFileUtils.CACHE_FOLDER);
37-
String path = CFileUtils.copyFileToInternalDirectory(getContext(), result, file.getAbsolutePath(), "pic_" + CDateUtil.getDataTime(CDateUtil.NORMAL_DATE_FORMAT) + ".png");
38-
viewModel.getStyle().setImagePath(path);
39-
dismissStyleDialog();
42+
String ext = CUriUtil.getImageExtension(getContext(), result);
43+
String path = CFileUtils.copyFileToInternalDirectory(getContext(), result, file.getAbsolutePath(), "pic_" + CDateUtil.getDataTime(CDateUtil.NORMAL_DATE_FORMAT) + ext);
44+
CLog.e("ImageAnnot", "pic copied, uri=" + result + ", ext=" + ext + ", path=" + path);
45+
CUriUtil.logImageFileInfo("pic copied file", path);
46+
if (!TextUtils.isEmpty(path)) {
47+
CLog.e("ImageAnnot", "pic setImagePath before, path=" + path);
48+
viewModel.getStyle().setImagePath(path);
49+
CLog.e("ImageAnnot", "pic setImagePath after, path=" + path);
50+
dismissStyleDialog();
51+
} else {
52+
CLog.e("ImageAnnot", "pic copy failed, uri=" + result);
53+
}
54+
} else {
55+
CLog.e("ImageAnnot", "pic result ignored, result=" + result + ", viewModel=" + viewModel);
4056
}
4157
});
4258

@@ -56,15 +72,15 @@ protected void onCreateView(View rootView) {
5672
ConstraintLayout clFromAlbum = rootView.findViewById(R.id.cl_from_album);
5773
ConstraintLayout clFromCamera = rootView.findViewById(R.id.cl_from_camera);
5874
clFromAlbum.setOnClickListener(v -> {
59-
imageLauncher.launch(CImageResultContracts.RequestType.PHOTO_ALBUM);
75+
imageLauncher.launch(new CImageResultContracts.Request(CImageResultContracts.RequestType.PHOTO_ALBUM));
6076
});
6177
clFromCamera.setOnClickListener(v -> {
6278
if (!CPermissionUtil.checkManifestPermission(getContext(), Manifest.permission.CAMERA)){
63-
imageLauncher.launch(CImageResultContracts.RequestType.CAMERA);
79+
launchCamera();
6480
}else {
6581
permissionResultLauncher.launch(Manifest.permission.CAMERA, granted -> {
6682
if (granted){
67-
imageLauncher.launch(CImageResultContracts.RequestType.CAMERA);
83+
launchCamera();
6884
} else {
6985
if (getActivity() != null) {
7086
if (!CPermissionUtil.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.CAMERA)) {
@@ -77,6 +93,15 @@ protected void onCreateView(View rootView) {
7793
});
7894
}
7995

96+
private void launchCamera() {
97+
Uri outputUri = CImageResultContracts.createCameraOutputUri(getContext());
98+
if (outputUri == null) {
99+
CLog.e("ImageAnnot", "pic camera output uri is null");
100+
return;
101+
}
102+
imageLauncher.launch(new CImageResultContracts.Request(CImageResultContracts.RequestType.CAMERA, outputUri));
103+
}
104+
80105
@Override
81106
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
82107
super.onViewCreated(view, savedInstanceState);

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFApplyConfigUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private void applyReaderViewConfig(CPDFDocumentFragment fragment,
136136
break;
137137
}
138138
readerView.setContinueMode(readerViewConfig.continueMode);
139-
readerView.setVerticalMode(readerViewConfig.verticalMode);
139+
fragment.pdfView.setVerticalMode(readerViewConfig.verticalMode);
140140
readerView.setCropMode(readerViewConfig.cropMode);
141141
readerView.setPageSameWidth(readerViewConfig.pageSameWidth);
142142
readerView.setMinScaleEnable(readerViewConfig.enableMinScale);

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFConfigurationUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@ private static ReaderViewConfig parseReaderViewConfig(@Nullable JSONObject jsonO
223223
default:break;
224224
}
225225
readerViewConfig.enableSliderBar = jsonObject.optBoolean("enableSliderBar", true);
226+
switch (jsonObject.optString("slideBarPosition", "right").toLowerCase()) {
227+
case "left":
228+
readerViewConfig.slideBarPosition = ReaderViewConfig.SlideBarPosition.Left;
229+
break;
230+
case "top":
231+
readerViewConfig.slideBarPosition = ReaderViewConfig.SlideBarPosition.Top;
232+
break;
233+
case "bottom":
234+
readerViewConfig.slideBarPosition = ReaderViewConfig.SlideBarPosition.Bottom;
235+
break;
236+
default:
237+
readerViewConfig.slideBarPosition = ReaderViewConfig.SlideBarPosition.Right;
238+
break;
239+
}
226240
readerViewConfig.enablePageIndicator = jsonObject.optBoolean("enablePageIndicator", true);
227241
readerViewConfig.pageSpacing = jsonObject.optInt("pageSpacing", 10);
228242
readerViewConfig.pageScale = (float) jsonObject.optDouble("pageScale", 1.0);

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFDocumentFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static CPDFDocumentFragment newInstance(Bundle bundle) {
217217
editToolBar.setEditMode(false);
218218
boolean enableSliderBar = pdfView.isEnableSliderBar();
219219
if (enableSliderBar && !screenManager.isFillScreen) {
220-
screenManager.fillScreenManager.showFromRight(pdfView.slideBar, CFillScreenManager.CONFIG_SHORT_ANIM_TIME);
220+
screenManager.fillScreenManager.showFromRight(pdfView.getSlideBarView(), CFillScreenManager.CONFIG_SHORT_ANIM_TIME);
221221
}
222222
});
223223
}
@@ -865,7 +865,7 @@ public void showPageEdit(boolean enterEditMode, boolean enableEditMode) {
865865
boolean show = pageCount > 1;
866866
pdfView.enableSliderBar(show);
867867
if (show && !screenManager.isFillScreen) {
868-
screenManager.fillScreenManager.showFromRight(pdfView.slideBar, CFillScreenManager.CONFIG_SHORT_ANIM_TIME);
868+
screenManager.fillScreenManager.showFromRight(pdfView.getSlideBarView(), CFillScreenManager.CONFIG_SHORT_ANIM_TIME);
869869
}
870870
}
871871
}

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CSampleScreenManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class CSampleScreenManager {
3737
public void bind(CPDFDocumentFragment documentFragment){
3838
this.documentFragment = documentFragment;
3939
constraintSet.clone(documentFragment.clRoot);
40-
fillScreenManager.bindRightToolViewList(documentFragment.pdfView.slideBar);
40+
fillScreenManager.bindRightToolViewList(documentFragment.pdfView.getSlideBarView());
4141
fillScreenManager.bindBottomToolViewList(documentFragment.pdfView.indicatorView);
4242
fillScreenManager.bindBottomToolViewList(documentFragment.flBottomToolBar);
4343
}

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/config/ReaderViewConfig.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class ReaderViewConfig implements Serializable {
3333

3434
public boolean enableSliderBar = true;
3535

36+
public SlideBarPosition slideBarPosition = SlideBarPosition.Right;
37+
3638
public boolean enablePageIndicator = true;
3739

3840
public int pageSpacing = 10;
@@ -66,6 +68,7 @@ public String toString() {
6668
"cropMode:" + cropMode + ", " +
6769
"themes:" + themes.name() + ", " +
6870
"enableSliderBar:" + enableSliderBar + ", " +
71+
"slideBarPosition:" + slideBarPosition.name() + ", " +
6972
"enablePageIndicator:" + enablePageIndicator + ", " +
7073
"pageSpacing:" + pageSpacing + ", " +
7174
"pageScale:" + pageScale + ", " +
@@ -98,4 +101,15 @@ public enum Themes{
98101
Reseda
99102

100103
}
104+
105+
public enum SlideBarPosition {
106+
107+
Left,
108+
109+
Top,
110+
111+
Right,
112+
113+
Bottom
114+
}
101115
}

0 commit comments

Comments
 (0)