|
@@ -33,6 +33,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
|
+import com.compdfkit.core.annotation.CPDFReplyAnnotation;
|
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
|
import com.compdfkit.core.page.CPDFPage;
|
|
|
import com.compdfkit.tools.R;
|
|
@@ -41,6 +42,8 @@ import com.compdfkit.tools.annotation.pdfannotationlist.adapter.CPDFAnnotListAda
|
|
|
import com.compdfkit.tools.annotation.pdfannotationlist.bean.CPDFAnnotListItem;
|
|
|
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.CPDFReplyDetailsDialogFragment;
|
|
|
import com.compdfkit.tools.common.interfaces.COnSetPDFDisplayPageIndexListener;
|
|
|
import com.compdfkit.tools.common.utils.CFileUtils;
|
|
|
import com.compdfkit.tools.common.utils.CLog;
|
|
@@ -51,11 +54,9 @@ import com.compdfkit.tools.common.utils.viewutils.CDimensUtils;
|
|
|
import com.compdfkit.tools.common.utils.window.CPopupMenuWindow;
|
|
|
import com.compdfkit.tools.common.views.directory.CFileDirectoryDialog;
|
|
|
import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
|
|
|
-import com.compdfkit.ui.reader.CPDFPageView;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -77,7 +78,12 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
return new CPDFAnnotationListFragment();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Used to select `xfdf` format annotation files from the system file manager
|
|
|
+ * and import them into PDF documents
|
|
|
+ * sample:<br/><br/>
|
|
|
+ * importAnnotFileLauncher.launch(CFileUtils.getIntent("application/octet-stream")
|
|
|
+ */
|
|
|
private ActivityResultLauncher<Intent> importAnnotFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
|
|
if (result.getResultCode() == Activity.RESULT_OK) {
|
|
|
Uri uri = result.getData().getData();
|
|
@@ -130,19 +136,19 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
CPDFAnnotListItem item = adapter.list.get(position);
|
|
|
if (view1.getId() == R.id.cl_root) {
|
|
|
if (!item.isHeader()) {
|
|
|
+ // Close the dialog and jump to the corresponding page number
|
|
|
if (displayPageIndexListener != null) {
|
|
|
displayPageIndexListener.displayPage(item.getPage());
|
|
|
}
|
|
|
}
|
|
|
} else if(view1.getId() == R.id.iv_review_status){
|
|
|
- showReviewStatusMenu(item,position, view1);
|
|
|
+ listAdapter.showReviewStatusMenu(getContext(), position, view1);
|
|
|
} else if(view1.getId() == R.id.cb_marked_status){
|
|
|
- showMarkedStatusMenu(position, view1);
|
|
|
+ listAdapter.showMarkedStatusMenu(getContext(), position, view1);
|
|
|
} else if(view1.getId() == R.id.iv_more){
|
|
|
showAnnotationMoreMenu(item, position, view1);
|
|
|
}
|
|
|
},R.id.iv_review_status, R.id.cb_marked_status, R.id.iv_more, R.id.cl_root);
|
|
|
-
|
|
|
rvAnnotation.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
|
rvAnnotation.setAdapter(listAdapter);
|
|
|
}
|
|
@@ -152,6 +158,10 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
updateAnnotationList(true);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Reload the annotation list data
|
|
|
+ * @param showProgressBar Whether to display the loading status when loading
|
|
|
+ */
|
|
|
public void updateAnnotationList(boolean showProgressBar) {
|
|
|
if (showProgressBar){
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
|
@@ -172,7 +182,6 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* show toolbar annotation menu, in CPDFBOTAFragment
|
|
|
* @param anchorView
|
|
@@ -183,6 +192,7 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
importAnnotFileLauncher.launch(CFileUtils.getIntent("application/octet-stream"));
|
|
|
});
|
|
|
menuWindow.addItem(R.string.tools_export_annotations, v -> {
|
|
|
+ // Select the directory to export the annotation files
|
|
|
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
|
|
CFileDirectoryDialog directoryDialog = CFileDirectoryDialog.newInstance(dirPath, getString(R.string.tools_saving_path), getString(R.string.tools_okay));
|
|
|
directoryDialog.setSelectFolderListener(dir -> {
|
|
@@ -217,58 +227,39 @@ public class CPDFAnnotationListFragment extends Fragment {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void showReviewStatusMenu(CPDFAnnotListItem item,int position, View anchorView){
|
|
|
- anchorView.setSelected(true);
|
|
|
- reviewStatusMenuWindow = new CPopupMenuWindow(getContext());
|
|
|
- reviewStatusMenuWindow.setOutsideTouchable(false);
|
|
|
- reviewStatusMenuWindow.addItem(R.drawable.tools_annot_review_status_accepted, R.string.tools_accepted, v -> {
|
|
|
- listAdapter.setReviewStatus(position, CPDFAnnotation.ReviewState.REVIEW_ACCEPTED);
|
|
|
- });
|
|
|
- reviewStatusMenuWindow.addItem(R.drawable.tools_annot_review_status_rejected, R.string.tools_rejected, v -> {
|
|
|
- listAdapter.setReviewStatus(position, CPDFAnnotation.ReviewState.REVIEW_REJECTED);
|
|
|
- });
|
|
|
- reviewStatusMenuWindow.addItem(R.drawable.tools_annot_review_status_cancelled, R.string.tools_cancelled, v -> {
|
|
|
- listAdapter.setReviewStatus(position, CPDFAnnotation.ReviewState.REVIEW_CANCELLED);
|
|
|
-
|
|
|
- });
|
|
|
- reviewStatusMenuWindow.addItem(R.drawable.tools_annot_review_status_completed, R.string.tools_completed, v -> {
|
|
|
- listAdapter.setReviewStatus(position, CPDFAnnotation.ReviewState.REVIEW_COMPLETED);
|
|
|
- });
|
|
|
- reviewStatusMenuWindow.addItem(R.drawable.tools_annot_review_status_none, R.string.tools_none, v -> {
|
|
|
- listAdapter.setReviewStatus(position, CPDFAnnotation.ReviewState.REVIEW_NONE);
|
|
|
- });
|
|
|
- reviewStatusMenuWindow.setOnDismissListener(() -> anchorView.setSelected(false));
|
|
|
- int[] windowPos = CDimensUtils.calculatePopWindowPos(anchorView, reviewStatusMenuWindow.getContentView());
|
|
|
- windowPos[0] -= reviewStatusMenuWindow.getContentView().getMeasuredWidth() /2;
|
|
|
-
|
|
|
- windowPos[1] -= anchorView.getMeasuredHeight() / 2;
|
|
|
- windowPos[1] -= anchorView.getMeasuredHeight();
|
|
|
- reviewStatusMenuWindow.setAnimationStyle(R.style.PopupAnimation);
|
|
|
- reviewStatusMenuWindow.showAtLocation(anchorView, Gravity.START | Gravity.TOP, windowPos[0], windowPos[1]);
|
|
|
- }
|
|
|
-
|
|
|
- private void showMarkedStatusMenu( int position,View anchorView){
|
|
|
- listAdapter.checkedMarkedStatus(position);
|
|
|
- CMarkedTipsWindow tipsWindow = new CMarkedTipsWindow(getContext());
|
|
|
- tipsWindow.setMarkState(listAdapter.list.get(position).getMarkState());
|
|
|
-
|
|
|
- tipsWindow.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
|
|
|
- int winWidth = tipsWindow.getContentView().getMeasuredWidth();
|
|
|
- int winHeight = tipsWindow.getContentView().getMeasuredHeight();
|
|
|
- int anchorViewWidth = anchorView.getWidth();
|
|
|
- int anchorViewHeight = anchorView.getHeight();
|
|
|
- int offsetX = (anchorViewWidth - winWidth) / 2;
|
|
|
- int offsetY = anchorViewHeight + winHeight;
|
|
|
- tipsWindow.showAsDropDown(anchorView, offsetX, -offsetY);
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Displays the more options menu for the selected annotation, including:
|
|
|
+ * 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 anchorView The view to anchor the menu to
|
|
|
+ */
|
|
|
private void showAnnotationMoreMenu(CPDFAnnotListItem item, int position, View anchorView){
|
|
|
CPopupMenuWindow moreMenu = new CPopupMenuWindow(getContext());
|
|
|
moreMenu.addItem(R.string.tools_add_a_new_reply,v -> {
|
|
|
-
|
|
|
+ CPDFEditReplyDialogFragment editReplyDialogFragment = CPDFEditReplyDialogFragment.addReply();
|
|
|
+ editReplyDialogFragment.setReplyContentListener(content -> {
|
|
|
+ CPDFReplyAnnotation replyAnnotation = item.getAttr().createReplyAnnotation();
|
|
|
+ replyAnnotation.setTitle(pdfView.getCPDFConfiguration().globalConfig.annotationAuthor);
|
|
|
+ replyAnnotation.setContent(content);
|
|
|
+ });
|
|
|
+ editReplyDialogFragment.show(getChildFragmentManager(), "addReplyDialogFragment");
|
|
|
});
|
|
|
moreMenu.addItem(R.string.tools_view_replies, v -> {
|
|
|
-
|
|
|
+ CPDFReplyDetailsDialogFragment replyDetailsDialogFragment = CPDFReplyDetailsDialogFragment.newInstance();
|
|
|
+ replyDetailsDialogFragment.setItem(item);
|
|
|
+ replyDetailsDialogFragment.setAnnotAuthor(pdfView.getCPDFConfiguration().globalConfig.annotationAuthor);
|
|
|
+ replyDetailsDialogFragment.setUpdateAnnotationListListener(()->{
|
|
|
+ listAdapter.remove(position);
|
|
|
+ ArrayList<Integer> pages = new ArrayList<>();
|
|
|
+ pages.add(item.getPage());
|
|
|
+ pdfView.getCPdfReaderView().reloadPages(pages);
|
|
|
+ pdfView.getCPdfReaderView().postDelayed(()-> updateAnnotationList(false), 450);
|
|
|
+ });
|
|
|
+ replyDetailsDialogFragment.setDismissListener(()->{
|
|
|
+ listAdapter.notifyItemChanged(position);
|
|
|
+ });
|
|
|
+ replyDetailsDialogFragment.show(getChildFragmentManager(), "replyDetailsDialogFragment");
|
|
|
});
|
|
|
moreMenu.addItem(R.string.tools_delete_annotation, v -> {
|
|
|
boolean result = item.getAttr().removeFromPage();
|