|
@@ -6,51 +6,40 @@ import static com.compdfkit.core.document.CPDFDocument.PDFDocumentError.PDFDocum
|
|
|
import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
-import android.os.Bundle;
|
|
|
import android.text.Editable;
|
|
|
import android.text.TextUtils;
|
|
|
import android.text.TextWatcher;
|
|
|
-import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
import android.widget.RadioButton;
|
|
|
import android.widget.RadioGroup;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
-import androidx.annotation.NonNull;
|
|
|
-import androidx.annotation.Nullable;
|
|
|
import androidx.appcompat.widget.AppCompatEditText;
|
|
|
import androidx.appcompat.widget.AppCompatImageView;
|
|
|
import androidx.appcompat.widget.AppCompatTextView;
|
|
|
|
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
|
import com.compdfkit.tools.R;
|
|
|
+import com.compdfkit.tools.common.basic.fragment.CBasicBottomSheetDialogFragment;
|
|
|
import com.compdfkit.tools.common.utils.CFileUtils;
|
|
|
import com.compdfkit.tools.common.utils.CToastUtil;
|
|
|
import com.compdfkit.tools.common.utils.CUriUtil;
|
|
|
-import com.compdfkit.tools.common.utils.dialog.CDialogFragmentUtil;
|
|
|
-import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils;
|
|
|
import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
|
|
|
import com.compdfkit.tools.common.views.CVerifyPasswordDialogFragment;
|
|
|
import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
|
|
|
import com.compdfkit.tools.docseditor.CPageEditBar;
|
|
|
-import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|
|
-import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
-public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment implements View.OnClickListener {
|
|
|
+public class CInsertPdfPageDialogFragment extends CBasicBottomSheetDialogFragment implements View.OnClickListener {
|
|
|
private CPageEditBar toolBar;
|
|
|
private CPDFViewCtrl pdfView;
|
|
|
private AppCompatTextView tvFilename;
|
|
|
- private AppCompatImageView ivFileNameRight;
|
|
|
-
|
|
|
- private RadioGroup rgPageRange;
|
|
|
|
|
|
private RadioButton rbFromPageLocationAll;
|
|
|
private RadioButton rbFromPageLocationOdd;
|
|
@@ -63,8 +52,6 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
private RadioButton rbToPageLocationBefore;
|
|
|
private RadioButton rbToPageLocationAfter;
|
|
|
|
|
|
- private RadioGroup rgInsertTo;
|
|
|
-
|
|
|
private AppCompatEditText etToInputPageIndex;
|
|
|
|
|
|
private CPageEditBar.OnEditDoneCallback onEditDoneCallback;
|
|
@@ -112,31 +99,36 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setStyle(STYLE_NORMAL, R.style.Tools_Base_Theme_BasicBottomSheetDialogStyle);
|
|
|
+ protected int getStyle() {
|
|
|
+ return R.style.Tools_Base_Theme_BasicBottomSheetDialogStyle;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onStart() {
|
|
|
- super.onStart();
|
|
|
- if (!CViewUtils.isLandScape(getContext())) {
|
|
|
- CDialogFragmentUtil.setDimAmount(getDialog(), 0F);
|
|
|
- }
|
|
|
- BottomSheetBehavior<View> behavior = BottomSheetBehavior.from((View) getView().getParent());
|
|
|
- behavior.setDraggable(false);
|
|
|
- CDialogFragmentUtil.setBottomSheetDialogFragmentFullScreen(getDialog(), behavior);
|
|
|
+ protected float dimAmount() {
|
|
|
+ return CViewUtils.isLandScape(getContext()) ? 0.2F : 0F;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected boolean draggable() {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- @Nullable
|
|
|
@Override
|
|
|
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
- View rootView = inflater.inflate(R.layout.tools_pageedit_insert_pdf_page_dialog_fragment, container, false);
|
|
|
+ protected boolean fullScreen() {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int layoutId() {
|
|
|
+ return R.layout.tools_pageedit_insert_pdf_page_dialog_fragment;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreateView(View rootView) {
|
|
|
toolBar = rootView.findViewById(R.id.page_edit_tool_bar);
|
|
|
tvFilename = rootView.findViewById(R.id.iv_tool_insert_page_filename);
|
|
|
-
|
|
|
- ivFileNameRight = rootView.findViewById(R.id.iv_tool_insert_page_right);
|
|
|
- rgPageRange = rootView.findViewById(R.id.rp_tools_edit_page_insertpage_from_location);
|
|
|
+ AppCompatImageView ivFileNameRight = rootView.findViewById(R.id.iv_tool_insert_page_right);
|
|
|
+ RadioGroup rgPageRange = rootView.findViewById(R.id.rp_tools_edit_page_insertpage_from_location);
|
|
|
rbFromPageLocationAll = rootView.findViewById(R.id.rb_tools_edit_page_insert_location_from_all);
|
|
|
rbFromPageLocationOdd = rootView.findViewById(R.id.rb_tools_edit_page_insert_location_from_odd);
|
|
|
rbFromPageLocationEven = rootView.findViewById(R.id.rb_tools_edit_page_insert_location_from_even);
|
|
@@ -147,7 +139,7 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
rbToPageLocationBefore = rootView.findViewById(R.id.rb_tools_edit_page_insert_location_before);
|
|
|
rbToPageLocationAfter = rootView.findViewById(R.id.rb_tools_edit_page_insert_location_after);
|
|
|
etToInputPageIndex = rootView.findViewById(R.id.et_tool_edit_page_enterpage);
|
|
|
- rgInsertTo = rootView.findViewById(R.id.rp_tools_edit_page_insertpage_location);
|
|
|
+ RadioGroup rgInsertTo = rootView.findViewById(R.id.rp_tools_edit_page_insertpage_location);
|
|
|
|
|
|
etFromInputPageIndex.setOnFocusChangeListener((view, b) -> {
|
|
|
if (b) {
|
|
@@ -280,9 +272,11 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onViewCreate() {
|
|
|
|
|
|
- return rootView;
|
|
|
}
|
|
|
|
|
|
private void updateDoneBtnStatus() {
|
|
@@ -420,11 +414,6 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
return insertPages;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
int id = view.getId();
|