use of com.google.android.material.textfield.TextInputLayout in project Signal-Android by WhisperSystems.
the class PaymentsRecoveryEntryFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.payments_recovery_entry_fragment_toolbar);
TextView message = view.findViewById(R.id.payments_recovery_entry_fragment_message);
TextInputLayout wrapper = view.findViewById(R.id.payments_recovery_entry_fragment_word_wrapper);
MaterialAutoCompleteTextView word = view.findViewById(R.id.payments_recovery_entry_fragment_word);
View next = view.findViewById(R.id.payments_recovery_entry_fragment_next);
PaymentsRecoveryEntryViewModel viewModel = ViewModelProviders.of(this).get(PaymentsRecoveryEntryViewModel.class);
toolbar.setNavigationOnClickListener(t -> Navigation.findNavController(view).popBackStack(R.id.paymentsHome, false));
viewModel.getState().observe(getViewLifecycleOwner(), state -> {
message.setText(getString(R.string.PaymentsRecoveryEntryFragment__enter_word_d, state.getWordIndex() + 1));
word.setHint(getString(R.string.PaymentsRecoveryEntryFragment__word_d, state.getWordIndex() + 1));
wrapper.setError(state.canMoveToNext() || TextUtils.isEmpty(state.getCurrentEntry()) ? null : getString(R.string.PaymentsRecoveryEntryFragment__invalid_word));
next.setEnabled(state.canMoveToNext());
String inTextView = word.getText().toString();
String inState = Util.firstNonNull(state.getCurrentEntry(), "");
if (!inTextView.equals(inState)) {
word.setText(inState);
}
});
viewModel.getEvents().observe(getViewLifecycleOwner(), event -> {
if (event == PaymentsRecoveryEntryViewModel.Events.GO_TO_CONFIRM) {
SafeNavigation.safeNavigate(Navigation.findNavController(view), PaymentsRecoveryEntryFragmentDirections.actionPaymentsRecoveryEntryToPaymentsRecoveryPhrase(false).setWords(viewModel.getWords()));
}
});
ArrayAdapter<String> wordAdapter = new ArrayAdapter<>(requireContext(), R.layout.support_simple_spinner_dropdown_item, Mnemonic.BIP39_WORDS_ENGLISH);
word.setAdapter(wordAdapter);
word.addTextChangedListener(new AfterTextChanged(e -> viewModel.onWordChanged(e.toString())));
next.setOnClickListener(v -> viewModel.onNextClicked());
}
use of com.google.android.material.textfield.TextInputLayout in project FirebaseUI-Android by firebase.
the class PhoneActivity method handleError.
private void handleError(@Nullable Exception e) {
TextInputLayout errorView = getErrorView();
if (errorView == null) {
return;
}
if (e instanceof FirebaseAuthAnonymousUpgradeException) {
IdpResponse response = ((FirebaseAuthAnonymousUpgradeException) e).getResponse();
finish(ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT, response.toIntent());
} else if (e instanceof FirebaseAuthException) {
FirebaseAuthError error = FirebaseAuthError.fromException((FirebaseAuthException) e);
if (error == FirebaseAuthError.ERROR_USER_DISABLED) {
IdpResponse response = IdpResponse.from(new FirebaseUiException(ErrorCodes.ERROR_USER_DISABLED));
finish(RESULT_CANCELED, response.toIntent());
return;
}
errorView.setError(getErrorMessage(error));
} else if (e != null) {
errorView.setError(getErrorMessage(FirebaseAuthError.ERROR_UNKNOWN));
} else {
errorView.setError(null);
}
}
use of com.google.android.material.textfield.TextInputLayout in project FirebaseUI-Android by firebase.
the class EmailActivity method onNewUser.
@Override
public void onNewUser(User user) {
// New user, direct them to create an account with email/password
// if account creation is enabled in SignInIntentBuilder
TextInputLayout emailLayout = findViewById(R.id.email_layout);
AuthUI.IdpConfig emailConfig = ProviderUtils.getConfigFromIdps(getFlowParams().providers, EmailAuthProvider.PROVIDER_ID);
if (emailConfig == null) {
emailConfig = ProviderUtils.getConfigFromIdps(getFlowParams().providers, EMAIL_LINK_PROVIDER);
}
if (emailConfig.getParams().getBoolean(ExtraConstants.ALLOW_NEW_EMAILS, true)) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (emailConfig.getProviderId().equals(EMAIL_LINK_PROVIDER)) {
showRegisterEmailLinkFragment(emailConfig, user.getEmail());
} else {
RegisterEmailFragment fragment = RegisterEmailFragment.newInstance(user);
ft.replace(R.id.fragment_register_email, fragment, RegisterEmailFragment.TAG);
if (emailLayout != null) {
String emailFieldName = getString(R.string.fui_email_field_name);
ViewCompat.setTransitionName(emailLayout, emailFieldName);
ft.addSharedElement(emailLayout, emailFieldName);
}
ft.disallowAddToBackStack().commit();
}
} else {
emailLayout.setError(getString(R.string.fui_error_email_does_not_exist));
}
}
use of com.google.android.material.textfield.TextInputLayout in project FirebaseUI-Android by firebase.
the class WelcomeBackPasswordPromptTest method testSignInButton_validatesFields.
@Test
public void testSignInButton_validatesFields() {
WelcomeBackPasswordPrompt welcomeBack = createActivity();
Button signIn = welcomeBack.findViewById(R.id.button_done);
signIn.performClick();
TextInputLayout passwordLayout = welcomeBack.findViewById(R.id.password_layout);
assertEquals(welcomeBack.getString(R.string.fui_error_invalid_password), passwordLayout.getError().toString());
// should block and not start a new activity
ShadowActivity.IntentForResult nextIntent = Shadows.shadowOf(welcomeBack).getNextStartedActivityForResult();
assertNull(nextIntent);
}
use of com.google.android.material.textfield.TextInputLayout in project fdroidclient by f-droid.
the class CrashReportActivity method init.
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
final AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.crash_dialog_title).setView(R.layout.crash_report_dialog).setPositiveButton(R.string.ok, this).setNegativeButton(R.string.cancel, this).create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnDismissListener(this);
dialog.show();
TextInputLayout commentLayout = dialog.findViewById(android.R.id.input);
comment = commentLayout.getEditText();
if (savedInstanceState != null) {
comment.setText(savedInstanceState.getString(STATE_COMMENT));
}
}
Aggregations