gpt4 book ai didi

android - 使用 PSPDFKit 创建 PDF 注释时如何显示自定义 Dialogfragment

转载 作者:行者123 更新时间:2023-11-30 00:16:35 26 4
gpt4 key购买 nike

我正在研究适用于 Android 的 PDF 库 PSPDFKit

// Inside my app's dependencies {}
implementation 'com.pspdfkit:pspdfkit-demo:4.0.2'

该库令人印象深刻,具有许多“开箱即用”的宝贵功能。但是,我遇到了创建注释注释时显示的对话框 fragment 的问题。

我需要一个自定义的对话框 UI,因为我的应用程序显示的 PDF 允许多个用户添加/编辑注释。这需要在编辑注释时显示的对话框包含创建注释的用户个人资料图像和全名。

我在我的应用程序中使用 com.pspdfkit.ui.PdfFragment 作为子 fragment ,并且看不到任何允许我在创建和/或编辑注释注释时提供自定义 dialogFragment 的方式。

是否可以自定义在 PSPDFKit 中创建/编辑注释 fragment 时显示的对话框 fragment ?

从我所看到的源代码来看,我需要在 PSPDFKit 中覆盖这个方法。

public void enterAnnotationCreationMode(@NonNull final AnnotationTool annotationTool) {
this.viewCoordinator.a(new b() {
public void run(@NonNull FrameLayout container, @NonNull PdfPasswordView passwordView, @NonNull View errorView, @NonNull final DocumentView documentView) {
el var10000 = com.pspdfkit.framework.a.d();
PdfFragment.this.getContext();
if(var10000.a(PdfFragment.this.configuration)) {
if(!PdfFragment.this.getAnnotationPreferences().isAnnotationCreatorSet()) {
AnnotationCreatorInputDialogFragment.show(PdfFragment.this.getActivity().getSupportFragmentManager(), (String)null, new OnAnnotationCreatorSetListener() {
public void onAnnotationCreatorSet(String annotationCreator) {
documentView.enterAnnotationCreationMode(annotationTool);
}

public void onAbort() {
}
});
com.pspdfkit.framework.a.f().a("show_annotation_creator_dialog").a();
} else {
documentView.enterAnnotationCreationMode(annotationTool);
}
} else {
throw new PSPDFKitException("Entering annotation creation mode for " + annotationTool + " is not permitted, either by the license or configuration.");
}
}
}, true);
}

最佳答案

从 PSPDFKit 4.0.2 开始,无法替换注释注释编辑器 UI。一般来说,直接联系 PSPDFKit 支持以寻找缺失的功能是个好主意 https://pspdfkit.com/support/request/

但是,PSPDFKit 团队已经对此进行了跟踪,很可能会在未来的版本中提供。

解决方法:您可以实现自定义注释操作并将其添加到 AnnotationCreationToolbar。有一个 guide article关于如何使用工具栏分组 API 修改工具栏上的操作。这也可用于删除现有操作并添加新操作。

使用 OnContextualToolbarLifecycleListener,您可以注册您的自定义过滤器逻辑,删除默认的注释操作并将其替换为您的自定义逻辑(然后将显示您的自定义对话框)。

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
toolbarCoordinatorLayout.setOnContextualToolbarLifecycleListener(this);
}

@Override
public void onPrepareContextualToolbar(@NonNull ContextualToolbar toolbar) {
if (toolbar instanceof AnnotationCreationToolbar) {
toolbar.setMenuItemGroupingRule(new CustomNoteAnnotationActionRule(this));
}
}

然后,您可以在按下自定义笔记图标以切换到“笔记创建模式”时进行注册。每当调用 DocumentListener#onPageClick() 时,您都可以显示自定义注释创建 UI。

关于android - 使用 PSPDFKit 创建 PDF 注释时如何显示自定义 Dialogfragment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47142087/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com