Source:
private void quickEdit(final String previousValue, final OnValueEdited callback, final int hint, boolean password) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.quickedit, null); final TextInputLayout editorInputLayout = view.findViewById(R.id.editor_input_layout); final TextInputEditText editor = view.findViewById(R.id.editor); builder.setPositiveButton(R.string.accept, null); if (hint != 0) { editorInputLayout.setHint(getResources().getString(hint)); } editor.requestFocus(); editor.setText(""); if (password) { editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); if (!previousValue.equals("")) { editor.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.length() == 0) { editorInputLayout.setPasswordVisibilityToggleEnabled(true); editor.removeTextChangedListener(this); } } }); } else { editorInputLayout.setPasswordVisibilityToggleEnabled(true); } } if (previousValue != null) { editor.getText().append(previousValue); } builder.setView(view); builder.setNegativeButton(R.string.cancel, null); final AlertDialog dialog = builder.create(); dialog.show(); View.OnClickListener clickListener = v -> { String value = editor.getText().toString(); if (!value.equals(previousValue) && value.trim().length() > 0) { String error = callback.onValueEdited(value); if (error != null) { editorInputLayout.setError(error); return; } } dialog.dismiss(); }; dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener); }

Target:
private void quickEdit(final String previousValue, final OnValueEdited callback, final int hint, boolean password) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.quickedit, null); final TextInputLayout editorInputLayout = view.findViewById(R.id.editor_input_layout); final TextInputEditText editor = view.findViewById(R.id.editor); builder.setPositiveButton(R.string.accept, null); if (hint != 0) { editorInputLayout.setHint(getResources().getString(hint)); } editor.requestFocus(); editor.setText(""); if (password) { editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); if (!previousValue.isEmpty()) { editor.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.length() == 0) { editorInputLayout.setPasswordVisibilityToggleEnabled(true); editor.removeTextChangedListener(this); } } }); } else { editorInputLayout.setPasswordVisibilityToggleEnabled(true); } } if (previousValue != null) { editor.getText().append(previousValue); } builder.setView(view); builder.setNegativeButton(R.string.cancel, null); final AlertDialog dialog = builder.create(); dialog.show(); View.OnClickListener clickListener = v -> { String value = editor.getText().toString(); if (!value.equals(previousValue) && value.trim().length() > 0) { String error = callback.onValueEdited(value); if (error != null) { editorInputLayout.setError(error); return; } } dialog.dismiss(); }; dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener); }