use of androidx.appcompat.widget.AppCompatEditText in project MTweaks-KernelAdiutorMOD by morogoku.
the class ViewUtils method dialogEditText.
public static Dialog dialogEditText(String text, final DialogInterface.OnClickListener negativeListener, final OnDialogEditTextListener onDialogEditTextListener, int inputType, Context context) {
LinearLayout layout = new LinearLayout(context);
int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
layout.setPadding(padding, padding, padding, padding);
final AppCompatEditText editText = new AppCompatEditText(context);
editText.setGravity(Gravity.CENTER);
editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (text != null) {
editText.append(text);
}
editText.setSingleLine(true);
if (inputType >= 0) {
editText.setInputType(inputType);
}
layout.addView(editText);
Dialog dialog = new Dialog(context).setView(layout);
if (negativeListener != null) {
dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
}
if (onDialogEditTextListener != null) {
dialog.setPositiveButton(context.getString(R.string.ok), (dialog1, which) -> onDialogEditTextListener.onClick(editText.getText().toString())).setOnDismissListener(dialog1 -> {
if (negativeListener != null) {
negativeListener.onClick(dialog1, 0);
}
});
}
return dialog;
}
use of androidx.appcompat.widget.AppCompatEditText in project CloudReader by youlookwhat.
the class DialogBuild method show.
/**
* 编辑收藏网址
*/
public static void show(View v, String name, String link, OnEditClickListener listener) {
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle("编辑");
View inflate = View.inflate(v.getContext(), R.layout.dialog_eidt_url, null);
builder.setView(inflate);
AppCompatEditText etName = inflate.findViewById(R.id.et_name);
AppCompatEditText etLink = inflate.findViewById(R.id.et_link);
if (!TextUtils.isEmpty(name)) {
etName.setText(name);
etName.setSelection(name.length());
}
etLink.setText(link);
builder.setNegativeButton("取消", null);
builder.setPositiveButton("编辑完成", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = etName.getText().toString().trim();
String link = etLink.getText().toString().trim();
if (TextUtils.isEmpty(name)) {
ToastUtil.showToastLong("请输入名称");
return;
}
if (TextUtils.isEmpty(link)) {
ToastUtil.showToastLong("请输入链接");
return;
}
listener.onClick(name, link);
}
});
builder.show();
}
use of androidx.appcompat.widget.AppCompatEditText in project AmazeFileManager by TeamAmaze.
the class RenameBookmark method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Context c = getActivity();
if (getActivity() instanceof BookmarkCallback)
bookmarkCallback = (BookmarkCallback) getActivity();
title = getArguments().getString("title");
path = getArguments().getString("path");
int accentColor = getArguments().getInt("accentColor");
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c);
if (dataUtils.containsBooks(new String[] { title, path }) != -1) {
final MaterialDialog materialDialog;
String pa = path;
MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
builder.title(R.string.rename_bookmark);
builder.positiveColor(accentColor);
builder.negativeColor(accentColor);
builder.neutralColor(accentColor);
builder.positiveText(R.string.save);
builder.neutralText(R.string.cancel);
builder.negativeText(R.string.delete);
builder.theme(((BasicActivity) getActivity()).getAppTheme().getMaterialDialogTheme());
builder.autoDismiss(false);
View v2 = getActivity().getLayoutInflater().inflate(R.layout.rename, null);
builder.customView(v2, true);
final TextInputLayout t1 = v2.findViewById(R.id.t1);
final TextInputLayout t2 = v2.findViewById(R.id.t2);
final AppCompatEditText conName = v2.findViewById(R.id.editText4);
conName.setText(title);
final String s1 = getString(R.string.cant_be_empty, c.getString(R.string.name));
final String s2 = getString(R.string.cant_be_empty, c.getString(R.string.path));
conName.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (conName.getText().toString().length() == 0)
t1.setError(s2);
else
t1.setError("");
}
});
final AppCompatEditText ip = v2.findViewById(R.id.editText);
t2.setVisibility(View.GONE);
ip.setText(pa);
builder.onNeutral((dialog, which) -> dialog.dismiss());
materialDialog = builder.build();
materialDialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(v -> {
String t = ip.getText().toString();
String name = conName.getText().toString();
int i = -1;
if ((i = dataUtils.containsBooks(new String[] { title, path })) != -1) {
if (!t.equals(title) && t.length() >= 1) {
dataUtils.removeBook(i);
dataUtils.addBook(new String[] { name, t });
dataUtils.sortBook();
if (bookmarkCallback != null) {
bookmarkCallback.modify(path, title, t, name);
}
}
}
materialDialog.dismiss();
});
materialDialog.getActionButton(DialogAction.NEGATIVE).setOnClickListener(v -> {
int i;
if ((i = dataUtils.containsBooks(new String[] { title, path })) != -1) {
dataUtils.removeBook(i);
if (bookmarkCallback != null) {
bookmarkCallback.delete(title, path);
}
}
materialDialog.dismiss();
});
return materialDialog;
}
return null;
}
use of androidx.appcompat.widget.AppCompatEditText in project MTweaks-KernelAdiutorMOD by morogoku.
the class ViewUtils method dialogEditTexts.
public static Dialog dialogEditTexts(String text, String text2, String hint, String hint2, final DialogInterface.OnClickListener negativeListener, final onDialogEditTextsListener onDialogEditTextListener, Context context) {
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
layout.setPadding(padding, padding, padding, padding);
final AppCompatEditText editText = new AppCompatEditText(context);
editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (text != null) {
editText.append(text);
}
if (hint != null) {
editText.setHint(hint);
}
editText.setSingleLine(true);
final AppCompatEditText editText2 = new AppCompatEditText(context);
editText2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
if (text2 != null) {
editText2.setText(text2);
}
if (hint2 != null) {
editText2.setHint(hint2);
}
editText2.setSingleLine(true);
layout.addView(editText);
layout.addView(editText2);
Dialog dialog = new Dialog(context).setView(layout);
if (negativeListener != null) {
dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
}
if (onDialogEditTextListener != null) {
dialog.setPositiveButton(context.getString(R.string.ok), (dialog1, which) -> onDialogEditTextListener.onClick(editText.getText().toString(), editText2.getText().toString())).setOnDismissListener(dialog1 -> {
if (negativeListener != null) {
negativeListener.onClick(dialog1, 0);
}
});
}
return dialog;
}
use of androidx.appcompat.widget.AppCompatEditText in project MTweaks-KernelAdiutorMOD by morogoku.
the class SecurityActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_security);
final String password = Utils.decodeString(getIntent().getStringExtra(PASSWORD_INTENT));
AppCompatEditText editText = findViewById(R.id.edittext);
mPasswordWrong = findViewById(R.id.password_wrong);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().equals(password)) {
mPasswordWrong.setVisibility(View.GONE);
setResult(1);
finish();
} else {
mPasswordWrong.setVisibility(editable.toString().isEmpty() ? View.GONE : View.VISIBLE);
}
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && AppSettings.isFingerprint(this)) {
mFingerprintManagerCompat = FingerprintManagerCompat.from(this);
if (mFingerprintManagerCompat.isHardwareDetected() && mFingerprintManagerCompat.hasEnrolledFingerprints() && getSystemService(KeyguardManager.class).isDeviceSecure()) {
loadFingerprint();
}
}
}
Aggregations