Search in sources :

Example 6 with AppCompatEditText

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;
}
Also used : Context(android.content.Context) FragmentManager(androidx.fragment.app.FragmentManager) LinearLayout(android.widget.LinearLayout) ImageView(android.widget.ImageView) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Drawable(android.graphics.drawable.Drawable) ViewGroup(android.view.ViewGroup) TypedArray(android.content.res.TypedArray) Gravity(android.view.Gravity) R(com.moro.mtweaks.R) Glide(com.bumptech.glide.Glide) Dialog(com.moro.mtweaks.views.dialog.Dialog) TypedValue(android.util.TypedValue) Bitmap(android.graphics.Bitmap) Fragment(androidx.fragment.app.Fragment) DialogInterface(android.content.DialogInterface) DialogFragment(androidx.fragment.app.DialogFragment) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) Dialog(com.moro.mtweaks.views.dialog.Dialog) LinearLayout(android.widget.LinearLayout)

Example 7 with AppCompatEditText

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) DialogInterface(android.content.DialogInterface) SpannableString(android.text.SpannableString) TextView(android.widget.TextView) View(android.view.View)

Example 8 with AppCompatEditText

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;
}
Also used : Context(android.content.Context) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SharedPreferences(android.content.SharedPreferences) BasicActivity(com.amaze.filemanager.ui.activities.superclasses.BasicActivity) View(android.view.View) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Editable(android.text.Editable) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Example 9 with AppCompatEditText

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;
}
Also used : Context(android.content.Context) FragmentManager(androidx.fragment.app.FragmentManager) LinearLayout(android.widget.LinearLayout) ImageView(android.widget.ImageView) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Drawable(android.graphics.drawable.Drawable) ViewGroup(android.view.ViewGroup) TypedArray(android.content.res.TypedArray) Gravity(android.view.Gravity) R(com.moro.mtweaks.R) Glide(com.bumptech.glide.Glide) Dialog(com.moro.mtweaks.views.dialog.Dialog) TypedValue(android.util.TypedValue) Bitmap(android.graphics.Bitmap) Fragment(androidx.fragment.app.Fragment) DialogInterface(android.content.DialogInterface) DialogFragment(androidx.fragment.app.DialogFragment) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) Dialog(com.moro.mtweaks.views.dialog.Dialog) LinearLayout(android.widget.LinearLayout)

Example 10 with AppCompatEditText

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();
        }
    }
}
Also used : AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Aggregations

AppCompatEditText (androidx.appcompat.widget.AppCompatEditText)10 Context (android.content.Context)6 View (android.view.View)5 LinearLayout (android.widget.LinearLayout)5 Editable (android.text.Editable)4 Gravity (android.view.Gravity)4 ViewGroup (android.view.ViewGroup)4 Fragment (androidx.fragment.app.Fragment)4 R (com.moro.mtweaks.R)4 Dialog (com.moro.mtweaks.views.dialog.Dialog)4 AlertDialog (androidx.appcompat.app.AlertDialog)3 SuppressLint (android.annotation.SuppressLint)2 ProgressDialog (android.app.ProgressDialog)2 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 Resources (android.content.res.Resources)2 AsyncTask (android.os.AsyncTask)2 Build (android.os.Build)2 Bundle (android.os.Bundle)2 Handler (android.os.Handler)2