|
@@ -1,3 +1,12 @@
|
|
|
|
+/**
|
|
|
|
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
|
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
|
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
|
+ * This notice may not be removed from this file.
|
|
|
|
+ */
|
|
|
|
+
|
|
package com.compdfkit.tools.pdfview.dialog;
|
|
package com.compdfkit.tools.pdfview.dialog;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
@@ -13,33 +22,24 @@ import androidx.appcompat.app.AppCompatDialog;
|
|
|
|
|
|
import com.compdfkit.tools.R;
|
|
import com.compdfkit.tools.R;
|
|
|
|
|
|
-/**
|
|
|
|
- * @author luozhipeng
|
|
|
|
- * @classname CommonInputDialog
|
|
|
|
- * @date 2020-02-21 11:42
|
|
|
|
- * @description
|
|
|
|
- */
|
|
|
|
-public class CCommonInputDialog extends AppCompatDialog {
|
|
|
|
|
|
|
|
- private Context context;
|
|
|
|
|
|
+public class CCommonInputDialog extends AppCompatDialog {
|
|
|
|
|
|
private String title;
|
|
private String title;
|
|
- private String message;
|
|
|
|
- private String cancelStr;
|
|
|
|
- private String okStr;
|
|
|
|
- private Runnable cancelCallback;
|
|
|
|
- private OnInputConpleteListener onInputConpleteListener;
|
|
|
|
-
|
|
|
|
- private View mView;
|
|
|
|
|
|
+ private String hintMessageText;
|
|
|
|
+ private String cancelText;
|
|
|
|
+ private String confirmText;
|
|
|
|
+ private OnCancelClickListener cancelClickListener;
|
|
|
|
+ private OnInputCompleteListener onInputCompleteListener;
|
|
|
|
|
|
- private TextView titleTv;
|
|
|
|
|
|
+ private TextView tvTitle;
|
|
|
|
|
|
- private TextView messageTv;
|
|
|
|
|
|
+ private TextView tvMessage;
|
|
private String messageStrTv;
|
|
private String messageStrTv;
|
|
|
|
|
|
- private EditText messageEt;
|
|
|
|
- private Button cancelBt;
|
|
|
|
- private Button okBt;
|
|
|
|
|
|
+ private EditText etMessage;
|
|
|
|
+ private Button btnCancel;
|
|
|
|
+ private Button btnConfirm;
|
|
|
|
|
|
public CCommonInputDialog(Context context) {
|
|
public CCommonInputDialog(Context context) {
|
|
super(context);
|
|
super(context);
|
|
@@ -57,30 +57,29 @@ public class CCommonInputDialog extends AppCompatDialog {
|
|
}
|
|
}
|
|
|
|
|
|
private void initView(Context context) {
|
|
private void initView(Context context) {
|
|
- this.context = context;
|
|
|
|
|
|
|
|
- mView = View.inflate(context, R.layout.tools_common_input_dialog_layout, null);
|
|
|
|
|
|
+ View rootView = View.inflate(context, R.layout.tools_common_input_dialog_layout, null);
|
|
|
|
|
|
- titleTv = mView.findViewById(R.id.common_input_dialog_title);
|
|
|
|
|
|
+ tvTitle = rootView.findViewById(R.id.common_input_dialog_title);
|
|
|
|
|
|
- messageTv = mView.findViewById(R.id.common_input_dialog_message);
|
|
|
|
|
|
+ tvMessage = rootView.findViewById(R.id.common_input_dialog_message);
|
|
|
|
|
|
- messageEt = mView.findViewById(R.id.common_input_dialog_et);
|
|
|
|
- cancelBt = mView.findViewById(R.id.common_input_dialog_cancel);
|
|
|
|
- okBt = mView.findViewById(R.id.common_input_dialog_ok);
|
|
|
|
- cancelBt.setOnClickListener(v -> {
|
|
|
|
- if (cancelCallback != null) {
|
|
|
|
- cancelCallback.run();
|
|
|
|
|
|
+ etMessage = rootView.findViewById(R.id.common_input_dialog_et);
|
|
|
|
+ btnCancel = rootView.findViewById(R.id.common_input_dialog_cancel);
|
|
|
|
+ btnConfirm = rootView.findViewById(R.id.common_input_dialog_ok);
|
|
|
|
+ btnCancel.setOnClickListener(v -> {
|
|
|
|
+ if (cancelClickListener != null) {
|
|
|
|
+ cancelClickListener.click();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- okBt.setOnClickListener(v -> {
|
|
|
|
- if (onInputConpleteListener != null) {
|
|
|
|
- onInputConpleteListener.getInputText(messageEt.getText().toString());
|
|
|
|
|
|
+ btnConfirm.setOnClickListener(v -> {
|
|
|
|
+ if (onInputCompleteListener != null) {
|
|
|
|
+ onInputCompleteListener.getInputText(etMessage.getText().toString());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- setContentView(mView);
|
|
|
|
|
|
+ setContentView(rootView);
|
|
|
|
|
|
Window window = getWindow();
|
|
Window window = getWindow();
|
|
WindowManager m = window.getWindowManager();
|
|
WindowManager m = window.getWindowManager();
|
|
@@ -92,55 +91,55 @@ public class CCommonInputDialog extends AppCompatDialog {
|
|
|
|
|
|
private void initVisibility() {
|
|
private void initVisibility() {
|
|
if (TextUtils.isEmpty(title)) {
|
|
if (TextUtils.isEmpty(title)) {
|
|
- titleTv.setVisibility(View.GONE);
|
|
|
|
|
|
+ tvTitle.setVisibility(View.GONE);
|
|
} else {
|
|
} else {
|
|
- titleTv.setVisibility(View.VISIBLE);
|
|
|
|
|
|
+ tvTitle.setVisibility(View.VISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
if (TextUtils.isEmpty(messageStrTv)) {
|
|
if (TextUtils.isEmpty(messageStrTv)) {
|
|
- messageTv.setVisibility(View.GONE);
|
|
|
|
|
|
+ tvMessage.setVisibility(View.GONE);
|
|
} else {
|
|
} else {
|
|
- messageTv.setVisibility(View.VISIBLE);
|
|
|
|
|
|
+ tvMessage.setVisibility(View.VISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
- if (cancelCallback != null) {
|
|
|
|
- cancelBt.setVisibility(View.VISIBLE);
|
|
|
|
|
|
+ if (cancelClickListener != null) {
|
|
|
|
+ btnCancel.setVisibility(View.VISIBLE);
|
|
} else {
|
|
} else {
|
|
- cancelBt.setVisibility(View.GONE);
|
|
|
|
|
|
+ btnCancel.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void setInputType(int type) {
|
|
public void setInputType(int type) {
|
|
- messageEt.setInputType(type);
|
|
|
|
|
|
+ etMessage.setInputType(type);
|
|
}
|
|
}
|
|
|
|
|
|
- public CCommonInputDialog setTitle(String title) {
|
|
|
|
- this.title = title;
|
|
|
|
- titleTv.setText(title);
|
|
|
|
|
|
+ public CCommonInputDialog setTitle(String titleText) {
|
|
|
|
+ this.title = titleText;
|
|
|
|
+ tvTitle.setText(titleText);
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
public CCommonInputDialog setMessage(String message) {
|
|
public CCommonInputDialog setMessage(String message) {
|
|
this.messageStrTv = message;
|
|
this.messageStrTv = message;
|
|
- messageTv.setText(message);
|
|
|
|
|
|
+ tvMessage.setText(message);
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- public CCommonInputDialog setHintInputText(String message) {
|
|
|
|
- this.message = message;
|
|
|
|
- messageEt.setHint(message);
|
|
|
|
|
|
+ public CCommonInputDialog setHintInputText(String hintMessageText) {
|
|
|
|
+ this.hintMessageText = hintMessageText;
|
|
|
|
+ etMessage.setHint(hintMessageText);
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- public CCommonInputDialog setCancelCallback(String cancelStr, Runnable cancelCallback) {
|
|
|
|
- this.cancelStr = cancelStr;
|
|
|
|
- this.cancelCallback = cancelCallback;
|
|
|
|
|
|
+ public CCommonInputDialog setCancelCallback(String cancelText, OnCancelClickListener cancelClickListener) {
|
|
|
|
+ this.cancelText = cancelText;
|
|
|
|
+ this.cancelClickListener = cancelClickListener;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- public CCommonInputDialog setOkCallback(String okStr, OnInputConpleteListener onInputConpleteListener) {
|
|
|
|
- this.okStr = okStr;
|
|
|
|
- this.onInputConpleteListener = onInputConpleteListener;
|
|
|
|
|
|
+ public CCommonInputDialog setConfirmCallback(String confirmText, OnInputCompleteListener onInputCompleteListener) {
|
|
|
|
+ this.confirmText = confirmText;
|
|
|
|
+ this.onInputCompleteListener = onInputCompleteListener;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -150,7 +149,11 @@ public class CCommonInputDialog extends AppCompatDialog {
|
|
super.show();
|
|
super.show();
|
|
}
|
|
}
|
|
|
|
|
|
- public interface OnInputConpleteListener {
|
|
|
|
|
|
+ public interface OnInputCompleteListener {
|
|
void getInputText(String text);
|
|
void getInputText(String text);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public interface OnCancelClickListener {
|
|
|
|
+ void click();
|
|
|
|
+ }
|
|
}
|
|
}
|