Search in sources :

Example 6 with TextInputLayout

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());
}
Also used : MaterialAutoCompleteTextView(com.google.android.material.textfield.MaterialAutoCompleteTextView) Bundle(android.os.Bundle) Util(org.thoughtcrime.securesms.util.Util) NonNull(androidx.annotation.NonNull) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) TextUtils(android.text.TextUtils) Mnemonic(org.thoughtcrime.securesms.payments.Mnemonic) R(org.thoughtcrime.securesms.R) ArrayAdapter(android.widget.ArrayAdapter) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) MaterialAutoCompleteTextView(com.google.android.material.textfield.MaterialAutoCompleteTextView) SafeNavigation(org.thoughtcrime.securesms.util.navigation.SafeNavigation) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Navigation(androidx.navigation.Navigation) TextView(android.widget.TextView) MaterialAutoCompleteTextView(com.google.android.material.textfield.MaterialAutoCompleteTextView) TextInputLayout(com.google.android.material.textfield.TextInputLayout) TextView(android.widget.TextView) MaterialAutoCompleteTextView(com.google.android.material.textfield.MaterialAutoCompleteTextView) View(android.view.View) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(androidx.appcompat.widget.Toolbar)

Example 7 with TextInputLayout

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);
    }
}
Also used : FirebaseAuthError(com.firebase.ui.auth.util.FirebaseAuthError) TextInputLayout(com.google.android.material.textfield.TextInputLayout) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) FirebaseAuthException(com.google.firebase.auth.FirebaseAuthException) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) IdpResponse(com.firebase.ui.auth.IdpResponse)

Example 8 with TextInputLayout

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));
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AuthUI(com.firebase.ui.auth.AuthUI)

Example 9 with TextInputLayout

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);
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) TextInputLayout(com.google.android.material.textfield.TextInputLayout) Test(org.junit.Test)

Example 10 with TextInputLayout

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));
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Aggregations

TextInputLayout (com.google.android.material.textfield.TextInputLayout)21 TextView (android.widget.TextView)13 View (android.view.View)12 EditText (android.widget.EditText)10 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 NonNull (androidx.annotation.NonNull)5 DialogInterface (android.content.DialogInterface)4 Nullable (androidx.annotation.Nullable)4 AlertDialog (androidx.appcompat.app.AlertDialog)4 Toolbar (androidx.appcompat.widget.Toolbar)4 Fragment (androidx.fragment.app.Fragment)4 ViewModelProviders (androidx.lifecycle.ViewModelProviders)4 Navigation (androidx.navigation.Navigation)4 R (org.thoughtcrime.securesms.R)4 AfterTextChanged (org.thoughtcrime.securesms.util.text.AfterTextChanged)4 Activity (android.app.Activity)3 Drawable (android.graphics.drawable.Drawable)3 TextUtils (android.text.TextUtils)3 Button (android.widget.Button)3