|
@@ -19,7 +19,6 @@ import android.view.Gravity;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
-import android.widget.PopupWindow;
|
|
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
|
|
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
@@ -27,22 +26,16 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
-import androidx.core.view.GravityCompat;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
-import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
|
|
import com.compdfkit.core.annotation.CPDFReplyAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFReplyAnnotation;
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
-import com.compdfkit.core.document.CPDFSdk;
|
|
|
|
-import com.compdfkit.core.page.CPDFPage;
|
|
|
|
import com.compdfkit.tools.R;
|
|
import com.compdfkit.tools.R;
|
|
-import com.compdfkit.tools.annotation.pdfannotationbar.data.CAnnotationToolDatas;
|
|
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.adapter.CPDFAnnotListAdapter;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.adapter.CPDFAnnotListAdapter;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.bean.CPDFAnnotListItem;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.bean.CPDFAnnotListItem;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.data.CPDFAnnotDatas;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.data.CPDFAnnotDatas;
|
|
-import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CMarkedTipsWindow;
|
|
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CPDFEditReplyDialogFragment;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CPDFEditReplyDialogFragment;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CPDFReplyDetailsDialogFragment;
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.dialog.CPDFReplyDetailsDialogFragment;
|
|
import com.compdfkit.tools.common.interfaces.COnSetPDFDisplayPageIndexListener;
|
|
import com.compdfkit.tools.common.interfaces.COnSetPDFDisplayPageIndexListener;
|
|
@@ -74,6 +67,7 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
|
|
|
private ProgressBar progressBar;
|
|
private ProgressBar progressBar;
|
|
|
|
|
|
|
|
+
|
|
public static CPDFAnnotationListFragment newInstance() {
|
|
public static CPDFAnnotationListFragment newInstance() {
|
|
return new CPDFAnnotationListFragment();
|
|
return new CPDFAnnotationListFragment();
|
|
}
|
|
}
|
|
@@ -90,19 +84,19 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
// get xfdf format file name
|
|
// get xfdf format file name
|
|
String fileName = CUriUtil.getUriFileName(getContext(), uri);
|
|
String fileName = CUriUtil.getUriFileName(getContext(), uri);
|
|
//Determine whether the file is in xfdf format
|
|
//Determine whether the file is in xfdf format
|
|
- if (fileName.toLowerCase().endsWith(".xfdf")){
|
|
|
|
|
|
+ if (fileName.toLowerCase().endsWith(".xfdf")) {
|
|
// Save the file to the app's internal storage cache directory
|
|
// Save the file to the app's internal storage cache directory
|
|
String dir = new File(getContext().getCacheDir(), CFileUtils.CACHE_FOLDER + File.separator + "xfdfFile").getAbsolutePath();
|
|
String dir = new File(getContext().getCacheDir(), CFileUtils.CACHE_FOLDER + File.separator + "xfdfFile").getAbsolutePath();
|
|
// Get the saved file path
|
|
// Get the saved file path
|
|
String importFilePath = CFileUtils.copyFileToInternalDirectory(getContext(), uri, dir, fileName);
|
|
String importFilePath = CFileUtils.copyFileToInternalDirectory(getContext(), uri, dir, fileName);
|
|
CLog.e("ComPDFKit-Tools", "importFilePath:" + importFilePath);
|
|
CLog.e("ComPDFKit-Tools", "importFilePath:" + importFilePath);
|
|
|
|
|
|
- if (!TextUtils.isEmpty(importFilePath)){
|
|
|
|
|
|
+ if (!TextUtils.isEmpty(importFilePath)) {
|
|
boolean importResult = CPDFAnnotDatas.importAnnotations(pdfView.getCPdfReaderView().getPDFDocument(), importFilePath);
|
|
boolean importResult = CPDFAnnotDatas.importAnnotations(pdfView.getCPdfReaderView().getPDFDocument(), importFilePath);
|
|
- if (importResult){
|
|
|
|
|
|
+ if (importResult) {
|
|
CToastUtil.showLongToast(getContext(), R.string.tools_import_success);
|
|
CToastUtil.showLongToast(getContext(), R.string.tools_import_success);
|
|
pdfView.getCPdfReaderView().reloadPages();
|
|
pdfView.getCPdfReaderView().reloadPages();
|
|
- pdfView.postDelayed(()-> updateAnnotationList(), 400);
|
|
|
|
|
|
+ pdfView.postDelayed(this::updateAnnotationList, 400);
|
|
}
|
|
}
|
|
CLog.e("ComPDFKit-Tools", "import Annotation xfdf format file " + (importResult ? "success" : "fail"));
|
|
CLog.e("ComPDFKit-Tools", "import Annotation xfdf format file " + (importResult ? "success" : "fail"));
|
|
}
|
|
}
|
|
@@ -132,7 +126,7 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
super.onViewCreated(view, savedInstanceState);
|
|
super.onViewCreated(view, savedInstanceState);
|
|
listAdapter = new CPDFAnnotListAdapter();
|
|
listAdapter = new CPDFAnnotListAdapter();
|
|
updateAnnotationList();
|
|
updateAnnotationList();
|
|
- listAdapter.addOnItemChildClickListener((adapter,view1,position) -> {
|
|
|
|
|
|
+ listAdapter.addOnItemChildClickListener((adapter, view1, position) -> {
|
|
CPDFAnnotListItem item = adapter.list.get(position);
|
|
CPDFAnnotListItem item = adapter.list.get(position);
|
|
if (view1.getId() == R.id.cl_root) {
|
|
if (view1.getId() == R.id.cl_root) {
|
|
if (!item.isHeader()) {
|
|
if (!item.isHeader()) {
|
|
@@ -141,14 +135,14 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
displayPageIndexListener.displayPage(item.getPage());
|
|
displayPageIndexListener.displayPage(item.getPage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if(view1.getId() == R.id.iv_review_status){
|
|
|
|
|
|
+ } else if (view1.getId() == R.id.iv_review_status) {
|
|
listAdapter.showReviewStatusMenu(getContext(), position, view1);
|
|
listAdapter.showReviewStatusMenu(getContext(), position, view1);
|
|
- } else if(view1.getId() == R.id.cb_marked_status){
|
|
|
|
|
|
+ } else if (view1.getId() == R.id.cb_marked_status) {
|
|
listAdapter.showMarkedStatusMenu(getContext(), position, view1);
|
|
listAdapter.showMarkedStatusMenu(getContext(), position, view1);
|
|
- } else if(view1.getId() == R.id.iv_more){
|
|
|
|
|
|
+ } else if (view1.getId() == R.id.iv_more) {
|
|
showAnnotationMoreMenu(item, position, view1);
|
|
showAnnotationMoreMenu(item, position, view1);
|
|
}
|
|
}
|
|
- },R.id.iv_review_status, R.id.cb_marked_status, R.id.iv_more, R.id.cl_root);
|
|
|
|
|
|
+ }, R.id.iv_review_status, R.id.cb_marked_status, R.id.iv_more, R.id.cl_root);
|
|
rvAnnotation.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
rvAnnotation.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
rvAnnotation.setAdapter(listAdapter);
|
|
rvAnnotation.setAdapter(listAdapter);
|
|
}
|
|
}
|
|
@@ -160,19 +154,20 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Reload the annotation list data
|
|
* Reload the annotation list data
|
|
|
|
+ *
|
|
* @param showProgressBar Whether to display the loading status when loading
|
|
* @param showProgressBar Whether to display the loading status when loading
|
|
*/
|
|
*/
|
|
public void updateAnnotationList(boolean showProgressBar) {
|
|
public void updateAnnotationList(boolean showProgressBar) {
|
|
- if (showProgressBar){
|
|
|
|
|
|
+ if (showProgressBar) {
|
|
progressBar.setVisibility(View.VISIBLE);
|
|
progressBar.setVisibility(View.VISIBLE);
|
|
}
|
|
}
|
|
CThreadPoolUtils.getInstance().executeIO(() -> {
|
|
CThreadPoolUtils.getInstance().executeIO(() -> {
|
|
List<CPDFAnnotListItem> list = CPDFAnnotDatas.getAnnotationList(pdfView);
|
|
List<CPDFAnnotListItem> list = CPDFAnnotDatas.getAnnotationList(pdfView);
|
|
if (getActivity() != null) {
|
|
if (getActivity() != null) {
|
|
- getActivity().runOnUiThread(()->{
|
|
|
|
- if (list == null || list.size() <= 0) {
|
|
|
|
|
|
+ getActivity().runOnUiThread(() -> {
|
|
|
|
+ if (list.isEmpty()) {
|
|
clEmptyView.setVisibility(View.VISIBLE);
|
|
clEmptyView.setVisibility(View.VISIBLE);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
clEmptyView.setVisibility(View.GONE);
|
|
clEmptyView.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
listAdapter.setList(list);
|
|
listAdapter.setList(list);
|
|
@@ -184,13 +179,11 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
|
|
|
/**
|
|
/**
|
|
* show toolbar annotation menu, in CPDFBOTAFragment
|
|
* show toolbar annotation menu, in CPDFBOTAFragment
|
|
- * @param anchorView
|
|
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
- public void showAnnotationMenu(View anchorView){
|
|
|
|
|
|
+ public void showAnnotationMenu(View anchorView) {
|
|
CPopupMenuWindow menuWindow = new CPopupMenuWindow(getContext());
|
|
CPopupMenuWindow menuWindow = new CPopupMenuWindow(getContext());
|
|
- menuWindow.addItem(R.string.tools_import_annotations, v -> {
|
|
|
|
- importAnnotFileLauncher.launch(CFileUtils.getIntent("application/octet-stream"));
|
|
|
|
- });
|
|
|
|
|
|
+ menuWindow.addItem(R.string.tools_import_annotations, v -> importAnnotFileLauncher.launch(CFileUtils.getIntent("application/octet-stream")));
|
|
menuWindow.addItem(R.string.tools_export_annotations, v -> {
|
|
menuWindow.addItem(R.string.tools_export_annotations, v -> {
|
|
// Select the directory to export the annotation files
|
|
// Select the directory to export the annotation files
|
|
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
|
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
|
@@ -198,15 +191,13 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
directoryDialog.setSelectFolderListener(dir -> {
|
|
directoryDialog.setSelectFolderListener(dir -> {
|
|
CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
|
|
CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
|
|
boolean result = CPDFAnnotDatas.exportAnnotations(document, dir, CFileUtils.getFileNameNoExtension(document.getFileName()));
|
|
boolean result = CPDFAnnotDatas.exportAnnotations(document, dir, CFileUtils.getFileNameNoExtension(document.getFileName()));
|
|
- if (result){
|
|
|
|
|
|
+ if (result) {
|
|
CToastUtil.showLongToast(getContext(), R.string.tools_export_success);
|
|
CToastUtil.showLongToast(getContext(), R.string.tools_export_success);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
directoryDialog.show(getChildFragmentManager(), "dirDialog");
|
|
directoryDialog.show(getChildFragmentManager(), "dirDialog");
|
|
});
|
|
});
|
|
- menuWindow.addItem(R.string.tools_delete_all_annotations, v -> {
|
|
|
|
- deleteAllAnnotations();
|
|
|
|
- });
|
|
|
|
|
|
+ menuWindow.addItem(R.string.tools_delete_all_annotations, v -> deleteAllAnnotations());
|
|
menuWindow.addItem(R.string.tools_delete_all_replies, v -> {
|
|
menuWindow.addItem(R.string.tools_delete_all_replies, v -> {
|
|
CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
|
|
CPDFDocument document = pdfView.getCPdfReaderView().getPDFDocument();
|
|
CPDFAnnotDatas.removeAllAnnotationReply(document);
|
|
CPDFAnnotDatas.removeAllAnnotationReply(document);
|
|
@@ -218,9 +209,9 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
/**
|
|
/**
|
|
* delete pdf document all annotations
|
|
* delete pdf document all annotations
|
|
*/
|
|
*/
|
|
- public void deleteAllAnnotations(){
|
|
|
|
|
|
+ public void deleteAllAnnotations() {
|
|
boolean result = CPDFAnnotDatas.removeAllAnnotations(listAdapter.list);
|
|
boolean result = CPDFAnnotDatas.removeAllAnnotations(listAdapter.list);
|
|
- if (result){
|
|
|
|
|
|
+ if (result) {
|
|
pdfView.getCPdfReaderView().reloadPages();
|
|
pdfView.getCPdfReaderView().reloadPages();
|
|
updateAnnotationList();
|
|
updateAnnotationList();
|
|
}
|
|
}
|
|
@@ -229,13 +220,14 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
/**
|
|
/**
|
|
* Displays the more options menu for the selected annotation, including:
|
|
* Displays the more options menu for the selected annotation, including:
|
|
* adding an annotation reply, showing the annotation reply list, and deleting the annotation.
|
|
* adding an annotation reply, showing the annotation reply list, and deleting the annotation.
|
|
- * @param item The annotation data currently selected from the list
|
|
|
|
- * @param position The position of the selected item in the list
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param item The annotation data currently selected from the list
|
|
|
|
+ * @param position The position of the selected item in the list
|
|
* @param anchorView The view to anchor the menu to
|
|
* @param anchorView The view to anchor the menu to
|
|
*/
|
|
*/
|
|
- private void showAnnotationMoreMenu(CPDFAnnotListItem item, int position, View anchorView){
|
|
|
|
|
|
+ private void showAnnotationMoreMenu(CPDFAnnotListItem item, int position, View anchorView) {
|
|
CPopupMenuWindow moreMenu = new CPopupMenuWindow(getContext());
|
|
CPopupMenuWindow moreMenu = new CPopupMenuWindow(getContext());
|
|
- moreMenu.addItem(R.string.tools_add_a_new_reply,v -> {
|
|
|
|
|
|
+ moreMenu.addItem(R.string.tools_add_a_new_reply, v -> {
|
|
CPDFEditReplyDialogFragment editReplyDialogFragment = CPDFEditReplyDialogFragment.addReply();
|
|
CPDFEditReplyDialogFragment editReplyDialogFragment = CPDFEditReplyDialogFragment.addReply();
|
|
editReplyDialogFragment.setReplyContentListener(content -> {
|
|
editReplyDialogFragment.setReplyContentListener(content -> {
|
|
CPDFReplyAnnotation replyAnnotation = item.getAttr().createReplyAnnotation();
|
|
CPDFReplyAnnotation replyAnnotation = item.getAttr().createReplyAnnotation();
|
|
@@ -245,40 +237,36 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
});
|
|
});
|
|
editReplyDialogFragment.show(getChildFragmentManager(), "addReplyDialogFragment");
|
|
editReplyDialogFragment.show(getChildFragmentManager(), "addReplyDialogFragment");
|
|
});
|
|
});
|
|
- moreMenu.addItem(R.string.tools_view_replies, v -> {
|
|
|
|
- showReplyDetailsFragment(item, position);
|
|
|
|
- });
|
|
|
|
|
|
+ moreMenu.addItem(R.string.tools_view_replies, v -> showReplyDetailsFragment(item, position));
|
|
moreMenu.addItem(R.string.tools_delete_annotation, v -> {
|
|
moreMenu.addItem(R.string.tools_delete_annotation, v -> {
|
|
boolean result = item.getAttr().removeFromPage();
|
|
boolean result = item.getAttr().removeFromPage();
|
|
- if (result){
|
|
|
|
|
|
+ if (result) {
|
|
listAdapter.remove(position);
|
|
listAdapter.remove(position);
|
|
ArrayList<Integer> pages = new ArrayList<>();
|
|
ArrayList<Integer> pages = new ArrayList<>();
|
|
pages.add(item.getPage());
|
|
pages.add(item.getPage());
|
|
pdfView.getCPdfReaderView().reloadPages(pages);
|
|
pdfView.getCPdfReaderView().reloadPages(pages);
|
|
- pdfView.getCPdfReaderView().postDelayed(()-> updateAnnotationList(false), 450);
|
|
|
|
|
|
+ pdfView.getCPdfReaderView().postDelayed(() -> updateAnnotationList(false), 450);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
int[] windowPos = CDimensUtils.calculatePopWindowPos(anchorView, moreMenu.getContentView());
|
|
int[] windowPos = CDimensUtils.calculatePopWindowPos(anchorView, moreMenu.getContentView());
|
|
- windowPos[0] -= anchorView.getMeasuredWidth() /2 ;
|
|
|
|
|
|
+ windowPos[0] -= anchorView.getMeasuredWidth() / 2;
|
|
windowPos[1] -= anchorView.getMeasuredHeight();
|
|
windowPos[1] -= anchorView.getMeasuredHeight();
|
|
moreMenu.setAnimationStyle(R.style.PopupAnimation);
|
|
moreMenu.setAnimationStyle(R.style.PopupAnimation);
|
|
moreMenu.showAtLocation(anchorView, Gravity.START | Gravity.TOP, windowPos[0], windowPos[1]);
|
|
moreMenu.showAtLocation(anchorView, Gravity.START | Gravity.TOP, windowPos[0], windowPos[1]);
|
|
}
|
|
}
|
|
|
|
|
|
- private void showReplyDetailsFragment(CPDFAnnotListItem item, int position){
|
|
|
|
|
|
+ private void showReplyDetailsFragment(CPDFAnnotListItem item, int position) {
|
|
CPDFReplyDetailsDialogFragment replyDetailsDialogFragment = CPDFReplyDetailsDialogFragment.newInstance();
|
|
CPDFReplyDetailsDialogFragment replyDetailsDialogFragment = CPDFReplyDetailsDialogFragment.newInstance();
|
|
replyDetailsDialogFragment.setCPDFAnnotation(item.getAttr());
|
|
replyDetailsDialogFragment.setCPDFAnnotation(item.getAttr());
|
|
replyDetailsDialogFragment.setAnnotAuthor(pdfView.getCPDFConfiguration().annotationsConfig.annotationAuthor);
|
|
replyDetailsDialogFragment.setAnnotAuthor(pdfView.getCPDFConfiguration().annotationsConfig.annotationAuthor);
|
|
- replyDetailsDialogFragment.setUpdateAnnotationListListener(()->{
|
|
|
|
|
|
+ replyDetailsDialogFragment.setUpdateAnnotationListListener(() -> {
|
|
listAdapter.remove(position);
|
|
listAdapter.remove(position);
|
|
ArrayList<Integer> pages = new ArrayList<>();
|
|
ArrayList<Integer> pages = new ArrayList<>();
|
|
pages.add(item.getPage());
|
|
pages.add(item.getPage());
|
|
pdfView.getCPdfReaderView().reloadPages(pages);
|
|
pdfView.getCPdfReaderView().reloadPages(pages);
|
|
- pdfView.getCPdfReaderView().postDelayed(()-> updateAnnotationList(false), 450);
|
|
|
|
- });
|
|
|
|
- replyDetailsDialogFragment.setDismissListener(()->{
|
|
|
|
- listAdapter.notifyItemChanged(position);
|
|
|
|
|
|
+ pdfView.getCPdfReaderView().postDelayed(() -> updateAnnotationList(false), 450);
|
|
});
|
|
});
|
|
|
|
+ replyDetailsDialogFragment.setDismissListener(() -> listAdapter.notifyItemChanged(position));
|
|
replyDetailsDialogFragment.show(getChildFragmentManager(), "replyDetailsDialogFragment");
|
|
replyDetailsDialogFragment.show(getChildFragmentManager(), "replyDetailsDialogFragment");
|
|
}
|
|
}
|
|
|
|
|