use of com.google.android.material.textfield.TextInputEditText in project android by owncloud.
the class ReceiveExternalFilesActivity method showUploadTextDialog.
/**
* Show a dialog where the user can enter a filename for the file he wants to place the text in.
*/
private void showUploadTextDialog() {
final AlertDialog.Builder builder = new Builder(this);
final View dialogView = getLayoutInflater().inflate(R.layout.dialog_upload_text, null);
builder.setView(dialogView);
builder.setTitle(R.string.uploader_upload_text_dialog_title);
builder.setCancelable(false);
builder.setPositiveButton(R.string.uploader_btn_upload_text, null);
builder.setNegativeButton(android.R.string.cancel, null);
final TextInputEditText input = dialogView.findViewById(R.id.inputFileName);
final TextInputLayout inputLayout = dialogView.findViewById(R.id.inputTextLayout);
input.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) {
inputLayout.setError(null);
inputLayout.setErrorEnabled(false);
}
});
final AlertDialog alertDialog = builder.create();
setFileNameFromIntent(alertDialog, input);
alertDialog.setOnShowListener(dialog -> {
Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(view -> {
String fileName = input.getText().toString();
String error = null;
if (fileName.length() > MAX_FILENAME_LENGTH) {
error = String.format(getString(R.string.uploader_upload_text_dialog_filename_error_length_max), MAX_FILENAME_LENGTH);
} else if (fileName.length() == 0) {
error = getString(R.string.uploader_upload_text_dialog_filename_error_empty);
} else {
fileName += ".txt";
Uri fileUri = savePlainTextToFile(fileName);
mStreamsToUpload.clear();
mStreamsToUpload.add(fileUri);
uploadFiles();
}
inputLayout.setErrorEnabled(error != null);
inputLayout.setError(error);
});
});
alertDialog.show();
}
use of com.google.android.material.textfield.TextInputEditText in project FirebaseUI-Android by firebase.
the class EmailActivityTest method testSetDefaultEmail_validField.
@Test
public void testSetDefaultEmail_validField() {
EmailActivity emailActivity = createActivity(EmailAuthProvider.PROVIDER_ID, false, true);
CheckEmailFragment fragment = (CheckEmailFragment) emailActivity.getSupportFragmentManager().findFragmentByTag(CheckEmailFragment.TAG);
assertThat(fragment).isNotNull();
TextInputEditText email = emailActivity.findViewById(R.id.email);
assertEquals(TestConstants.EMAIL, email.getText().toString());
}
Aggregations