|
@@ -5,6 +5,7 @@ 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;
|
|
@@ -13,6 +14,7 @@ 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;
|
|
@@ -47,6 +49,9 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
private CPDFViewCtrl pdfView;
|
|
|
private AppCompatTextView tvFilename;
|
|
|
private AppCompatImageView ivFileNameRight;
|
|
|
+
|
|
|
+ private RadioGroup rgPageRange;
|
|
|
+
|
|
|
private RadioButton rbFromPageLocationAll;
|
|
|
private RadioButton rbFromPageLocationOdd;
|
|
|
private RadioButton rbFromPageLocationEven;
|
|
@@ -57,6 +62,9 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
private RadioButton rbToPageLocationLast;
|
|
|
private RadioButton rbToPageLocationBefore;
|
|
|
private RadioButton rbToPageLocationAfter;
|
|
|
+
|
|
|
+ private RadioGroup rgInsertTo;
|
|
|
+
|
|
|
private AppCompatEditText etToInputPageIndex;
|
|
|
|
|
|
private CPageEditBar.OnEditDoneCallback onEditDoneCallback;
|
|
@@ -128,6 +136,7 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
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);
|
|
|
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);
|
|
@@ -138,27 +147,43 @@ 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);
|
|
|
-
|
|
|
- rbFromPageLocationAll.setOnClickListener(this);
|
|
|
- rbFromPageLocationOdd.setOnClickListener(this);
|
|
|
- rbFromPageLocationEven.setOnClickListener(this);
|
|
|
- rbFromPageLocationSpecify.setOnClickListener(this);
|
|
|
-
|
|
|
- rbToPageLocationHome.setOnClickListener(this);
|
|
|
- rbToPageLocationLast.setOnClickListener(this);
|
|
|
- rbToPageLocationBefore.setOnClickListener(this);
|
|
|
- rbToPageLocationAfter.setOnClickListener(this);
|
|
|
+ rgInsertTo = rootView.findViewById(R.id.rp_tools_edit_page_insertpage_location);
|
|
|
|
|
|
etFromInputPageIndex.setOnFocusChangeListener((view, b) -> {
|
|
|
if (b) {
|
|
|
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
+ if (!rbFromPageLocationSpecify.isChecked()) {
|
|
|
+ rbFromPageLocationSpecify.setChecked(true);
|
|
|
+ CViewUtils.showKeyboard(etFromInputPageIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CViewUtils.hideKeyboard(etFromInputPageIndex);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ etFromInputPageIndex.setOnClickListener(v -> {
|
|
|
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
if (!rbFromPageLocationSpecify.isChecked()) {
|
|
|
rbFromPageLocationSpecify.setChecked(true);
|
|
|
CViewUtils.showKeyboard(etFromInputPageIndex);
|
|
|
}
|
|
|
- } else {
|
|
|
- CViewUtils.hideKeyboard(etFromInputPageIndex);
|
|
|
}
|
|
|
});
|
|
|
+ rgPageRange.setOnCheckedChangeListener((group, checkedId) -> {
|
|
|
+ if (checkedId == R.id.rb_tools_edit_page_insert_location_from_all) {
|
|
|
+ etFromInputPageIndex.clearFocus();
|
|
|
+ } else if (checkedId == R.id.rb_tools_edit_page_insert_location_from_odd) {
|
|
|
+ etFromInputPageIndex.clearFocus();
|
|
|
+ } else if (checkedId == R.id.rb_tools_edit_page_insert_location_from_even) {
|
|
|
+ etFromInputPageIndex.clearFocus();
|
|
|
+ } else if (checkedId == R.id.rb_tools_edit_page_insert_location_from_specify) {
|
|
|
+ if (!etFromInputPageIndex.isFocused()) {
|
|
|
+ etFromInputPageIndex.requestFocus();
|
|
|
+ CViewUtils.showKeyboard(etFromInputPageIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateDoneBtnStatus();
|
|
|
+ });
|
|
|
etFromInputPageIndex.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
@@ -186,6 +211,24 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
CViewUtils.hideKeyboard(etToInputPageIndex);
|
|
|
}
|
|
|
});
|
|
|
+ rgInsertTo.setOnCheckedChangeListener((group, checkedId) -> {
|
|
|
+ if (checkedId == R.id.rb_tools_edit_page_insert_location_homepage) {
|
|
|
+ etToInputPageIndex.clearFocus();
|
|
|
+ } else if (checkedId == R.id.rb_tools_edit_page_insert_location_lastpage) {
|
|
|
+ etToInputPageIndex.clearFocus();
|
|
|
+ } else if (checkedId == R.id.rb_tools_edit_page_insert_location_before) {
|
|
|
+ if (!etToInputPageIndex.isFocused()) {
|
|
|
+ etToInputPageIndex.requestFocus();
|
|
|
+ CViewUtils.showKeyboard(etToInputPageIndex);
|
|
|
+ }
|
|
|
+ } else if (checkedId == R.id.rb_tools_edit_page_insert_location_after) {
|
|
|
+ if (!etToInputPageIndex.isFocused()) {
|
|
|
+ etToInputPageIndex.requestFocus();
|
|
|
+ CViewUtils.showKeyboard(etToInputPageIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateDoneBtnStatus();
|
|
|
+ });
|
|
|
etToInputPageIndex.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
@@ -390,33 +433,7 @@ public class CInsertPdfPageDialogFragment extends BottomSheetDialogFragment impl
|
|
|
int id = view.getId();
|
|
|
if (id == R.id.iv_tool_insert_page_right) {
|
|
|
selectDocumentLauncher.launch(CFileUtils.getContentIntent());
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_from_all) {
|
|
|
- etFromInputPageIndex.clearFocus();
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_from_odd) {
|
|
|
- etFromInputPageIndex.clearFocus();
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_from_even) {
|
|
|
- etFromInputPageIndex.clearFocus();
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_from_specify) {
|
|
|
- if (!etFromInputPageIndex.isFocused()) {
|
|
|
- etFromInputPageIndex.requestFocus();
|
|
|
- CViewUtils.showKeyboard(etFromInputPageIndex);
|
|
|
- }
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_homepage) {
|
|
|
- etToInputPageIndex.clearFocus();
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_lastpage) {
|
|
|
- etToInputPageIndex.clearFocus();
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_before) {
|
|
|
- if (!etToInputPageIndex.isFocused()) {
|
|
|
- etToInputPageIndex.requestFocus();
|
|
|
- CViewUtils.showKeyboard(etToInputPageIndex);
|
|
|
- }
|
|
|
- } else if (id == R.id.rb_tools_edit_page_insert_location_after) {
|
|
|
- if (!etToInputPageIndex.isFocused()) {
|
|
|
- etToInputPageIndex.requestFocus();
|
|
|
- CViewUtils.showKeyboard(etToInputPageIndex);
|
|
|
- }
|
|
|
}
|
|
|
- updateDoneBtnStatus();
|
|
|
}
|
|
|
|
|
|
public void setOnEditDoneCallback(CPageEditBar.OnEditDoneCallback callback) {
|