Search in sources :

Example 16 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project FirebaseUI-Android by firebase.

the class EmailActivityTest method testSignUpButton_validatesFields.

@Test
public void testSignUpButton_validatesFields() {
    EmailActivity emailActivity = createActivity(EmailAuthProvider.PROVIDER_ID);
    // Trigger RegisterEmailFragment (bypass check email)
    emailActivity.onNewUser(new User.Builder(EmailAuthProvider.PROVIDER_ID, TestConstants.EMAIL).build());
    Button button = emailActivity.findViewById(R.id.button_create);
    button.performClick();
    TextInputLayout nameLayout = emailActivity.findViewById(R.id.name_layout);
    TextInputLayout passwordLayout = emailActivity.findViewById(R.id.password_layout);
    assertEquals(emailActivity.getString(R.string.fui_missing_first_and_last_name), nameLayout.getError().toString());
    assertEquals(String.format(emailActivity.getResources().getQuantityString(R.plurals.fui_error_weak_password, R.integer.fui_min_password_length), emailActivity.getResources().getInteger(R.integer.fui_min_password_length)), passwordLayout.getError().toString());
}
Also used : Button(android.widget.Button) TextInputLayout(com.google.android.material.textfield.TextInputLayout) Test(org.junit.Test)

Example 17 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project materialistic by hidroh.

the class FeedbackActivity method onCreate.

@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_feedback);
    AppUtils.setTextWithLinks((TextView) findViewById(R.id.feedback_note), AppUtils.fromHtml(getString(R.string.feedback_note)));
    final TextInputLayout titleLayout = (TextInputLayout) findViewById(R.id.textinput_title);
    final TextInputLayout bodyLayout = (TextInputLayout) findViewById(R.id.textinput_body);
    final EditText title = (EditText) findViewById(R.id.edittext_title);
    final EditText body = (EditText) findViewById(R.id.edittext_body);
    final View sendButton = findViewById(R.id.feedback_button);
    findViewById(R.id.button_rate).setOnClickListener(v -> {
        AppUtils.openPlayStore(FeedbackActivity.this);
        finish();
    });
    sendButton.setOnClickListener(v -> {
        titleLayout.setErrorEnabled(false);
        bodyLayout.setErrorEnabled(false);
        if (title.length() == 0) {
            titleLayout.setError(getString(R.string.title_required));
        }
        if (body.length() == 0) {
            bodyLayout.setError(getString(R.string.comment_required));
        }
        if (title.length() == 0 || body.length() == 0) {
            return;
        }
        sendButton.setEnabled(false);
        mFeedbackClient.send(title.getText().toString(), body.getText().toString(), new FeedbackCallback(this));
    });
}
Also used : EditText(android.widget.EditText) TextInputLayout(com.google.android.material.textfield.TextInputLayout) TextView(android.widget.TextView) View(android.view.View)

Example 18 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project k-9 by k9mail.

the class AccountSetupIncoming method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setLayout(R.layout.account_setup_incoming);
    setTitle(R.string.account_setup_incoming_title);
    mUsernameView = findViewById(R.id.account_username);
    mPasswordView = findViewById(R.id.account_password);
    mClientCertificateSpinner = findViewById(R.id.account_client_certificate_spinner);
    mPasswordLayoutView = findViewById(R.id.account_password_layout);
    mServerView = findViewById(R.id.account_server);
    mPortView = findViewById(R.id.account_port);
    mSecurityTypeView = findViewById(R.id.account_security_type);
    mAuthTypeView = findViewById(R.id.account_auth_type);
    mImapAutoDetectNamespaceView = findViewById(R.id.imap_autodetect_namespace);
    mImapPathPrefixView = findViewById(R.id.imap_path_prefix);
    mWebdavPathPrefixView = findViewById(R.id.webdav_path_prefix);
    mWebdavAuthPathView = findViewById(R.id.webdav_auth_path);
    mWebdavMailboxPathView = findViewById(R.id.webdav_mailbox_path);
    mNextButton = findViewById(R.id.next);
    mCompressionMobile = findViewById(R.id.compression_mobile);
    mCompressionWifi = findViewById(R.id.compression_wifi);
    mCompressionOther = findViewById(R.id.compression_other);
    mSubscribedFoldersOnly = findViewById(R.id.subscribed_folders_only);
    mAllowClientCertificateView = findViewById(R.id.account_allow_client_certificate);
    TextInputLayout serverLayoutView = findViewById(R.id.account_server_layout);
    mNextButton.setOnClickListener(this);
    mImapAutoDetectNamespaceView.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mImapPathPrefixView.setEnabled(!isChecked);
            if (isChecked && mImapPathPrefixView.hasFocus()) {
                mImapPathPrefixView.focusSearch(View.FOCUS_UP).requestFocus();
            } else if (!isChecked) {
                mImapPathPrefixView.requestFocus();
            }
        }
    });
    mAuthTypeAdapter = AuthTypeAdapter.get(this);
    mAuthTypeView.setAdapter(mAuthTypeAdapter);
    /*
         * Only allow digits in the port field.
         */
    mPortView.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
    String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
    mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
    /*
         * If we're being reloaded we override the original account with the one
         * we saved
         */
    if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_ACCOUNT)) {
        accountUuid = savedInstanceState.getString(EXTRA_ACCOUNT);
        mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    }
    boolean editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
    if (editSettings) {
        TextInputLayoutHelper.configureAuthenticatedPasswordToggle(mPasswordLayoutView, this, getString(R.string.account_setup_basics_show_password_biometrics_title), getString(R.string.account_setup_basics_show_password_biometrics_subtitle), getString(R.string.account_setup_basics_show_password_need_lock));
    }
    try {
        ServerSettings settings = mAccount.getIncomingServerSettings();
        if (savedInstanceState == null) {
            // The first item is selected if settings.authenticationType is null or is not in mAuthTypeAdapter
            mCurrentAuthTypeViewPosition = mAuthTypeAdapter.getAuthPosition(settings.authenticationType);
        } else {
            mCurrentAuthTypeViewPosition = savedInstanceState.getInt(STATE_AUTH_TYPE_POSITION);
        }
        mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
        updateViewFromAuthType();
        mUsernameView.setText(settings.username);
        if (settings.password != null) {
            mPasswordView.setText(settings.password);
        }
        if (settings.clientCertificateAlias != null) {
            mClientCertificateSpinner.setAlias(settings.clientCertificateAlias);
        }
        mStoreType = settings.type;
        if (settings.type.equals(Protocols.POP3)) {
            serverLayoutView.setHint(getString(R.string.account_setup_incoming_pop_server_label));
            findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
            findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
            findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
            findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
            findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
            findViewById(R.id.compression_section).setVisibility(View.GONE);
            findViewById(R.id.compression_label).setVisibility(View.GONE);
            mSubscribedFoldersOnly.setVisibility(View.GONE);
        } else if (settings.type.equals(Protocols.IMAP)) {
            serverLayoutView.setHint(getString(R.string.account_setup_incoming_imap_server_label));
            boolean autoDetectNamespace = ImapStoreSettings.getAutoDetectNamespace(settings);
            String pathPrefix = ImapStoreSettings.getPathPrefix(settings);
            mImapAutoDetectNamespaceView.setChecked(autoDetectNamespace);
            if (pathPrefix != null) {
                mImapPathPrefixView.setText(pathPrefix);
            }
            findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
            findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
            findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
            findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
            if (!editSettings) {
                findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
            }
        } else if (settings.type.equals(Protocols.WEBDAV)) {
            serverLayoutView.setHint(getString(R.string.account_setup_incoming_webdav_server_label));
            mConnectionSecurityChoices = new ConnectionSecurity[] { ConnectionSecurity.NONE, ConnectionSecurity.SSL_TLS_REQUIRED };
            // Hide the unnecessary fields
            findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
            findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
            findViewById(R.id.account_auth_type).setVisibility(View.GONE);
            findViewById(R.id.compression_section).setVisibility(View.GONE);
            findViewById(R.id.compression_label).setVisibility(View.GONE);
            mSubscribedFoldersOnly.setVisibility(View.GONE);
            String path = WebDavStoreSettings.getPath(settings);
            if (path != null) {
                mWebdavPathPrefixView.setText(path);
            }
            String authPath = WebDavStoreSettings.getAuthPath(settings);
            if (authPath != null) {
                mWebdavAuthPathView.setText(authPath);
            }
            String mailboxPath = WebDavStoreSettings.getMailboxPath(settings);
            if (mailboxPath != null) {
                mWebdavMailboxPathView.setText(mailboxPath);
            }
        } else {
            throw new Exception("Unknown account type: " + settings.type);
        }
        if (!editSettings) {
            mAccount.setDeletePolicy(accountCreator.getDefaultDeletePolicy(settings.type));
        }
        // Note that mConnectionSecurityChoices is configured above based on server type
        ConnectionSecurityAdapter securityTypesAdapter = ConnectionSecurityAdapter.get(this, mConnectionSecurityChoices);
        mSecurityTypeView.setAdapter(securityTypesAdapter);
        // Select currently configured security type
        if (savedInstanceState == null) {
            mCurrentSecurityTypeViewPosition = securityTypesAdapter.getConnectionSecurityPosition(settings.connectionSecurity);
        } else {
            /*
                 * Restore the spinner state now, before calling
                 * setOnItemSelectedListener(), thus avoiding a call to
                 * onItemSelected(). Then, when the system restores the state
                 * (again) in onRestoreInstanceState(), The system will see that
                 * the new state is the same as the current state (set here), so
                 * once again onItemSelected() will not be called.
                 */
            mCurrentSecurityTypeViewPosition = savedInstanceState.getInt(STATE_SECURITY_TYPE_POSITION);
        }
        mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
        updateAuthPlainTextFromSecurityType(settings.connectionSecurity);
        updateViewFromSecurity();
        mCompressionMobile.setChecked(mAccount.useCompression(NetworkType.MOBILE));
        mCompressionWifi.setChecked(mAccount.useCompression(NetworkType.WIFI));
        mCompressionOther.setChecked(mAccount.useCompression(NetworkType.OTHER));
        if (settings.host != null) {
            mServerView.setText(settings.host);
        }
        if (settings.port != -1) {
            mPortView.setText(String.format(Locale.ROOT, "%d", settings.port));
        } else {
            updatePortFromSecurityType();
        }
        mCurrentPortViewSetting = mPortView.getText().toString();
        mSubscribedFoldersOnly.setChecked(mAccount.isSubscribedFoldersOnly());
    } catch (Exception e) {
        failure(e);
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) ServerSettings(com.fsck.k9.mail.ServerSettings) TextInputLayout(com.google.android.material.textfield.TextInputLayout) CompoundButton(android.widget.CompoundButton)

Example 19 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project fdroidclient by f-droid.

the class RepoDetailsActivity method showChangePasswordDialog.

public void showChangePasswordDialog(final View parentView) {
    final View view = getLayoutInflater().inflate(R.layout.login, null);
    final AlertDialog credentialsDialog = new AlertDialog.Builder(this).setView(view).create();
    final TextInputLayout nameInputLayout = view.findViewById(R.id.edit_name);
    final TextInputLayout passwordInputLayout = view.findViewById(R.id.edit_password);
    final EditText nameInput = nameInputLayout.getEditText();
    final EditText passwordInput = passwordInputLayout.getEditText();
    nameInput.setText(repo.username);
    passwordInput.requestFocus();
    credentialsDialog.setTitle(R.string.repo_edit_credentials);
    credentialsDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    credentialsDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String name = nameInput.getText().toString();
            final String password = passwordInput.getText().toString();
            if (!TextUtils.isEmpty(name)) {
                final ContentValues values = new ContentValues(2);
                values.put(RepoTable.Cols.USERNAME, name);
                values.put(RepoTable.Cols.PASSWORD, password);
                RepoProvider.Helper.update(RepoDetailsActivity.this, repo, values);
                updateRepoView();
                dialog.dismiss();
            } else {
                Toast.makeText(RepoDetailsActivity.this, R.string.repo_error_empty_username, Toast.LENGTH_LONG).show();
            }
        }
    });
    credentialsDialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) EditText(android.widget.EditText) ContentValues(android.content.ContentValues) DialogInterface(android.content.DialogInterface) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView)

Example 20 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project Signal-Android by signalapp.

the class PaymentsRecoveryPhraseConfirmFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_toolbar);
    EditText word1 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word_1);
    EditText word2 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word_2);
    View seePhraseAgain = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_see_again);
    View done = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_done);
    TextInputLayout wordWrapper1 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word1_wrapper);
    TextInputLayout wordWrapper2 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word2_wrapper);
    PaymentsRecoveryPhraseConfirmFragmentArgs args = PaymentsRecoveryPhraseConfirmFragmentArgs.fromBundle(requireArguments());
    validWordCheckMark = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_check_circle_24);
    invalidWordX = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_circle_x_24);
    DrawableCompat.setTint(validWordCheckMark, ContextCompat.getColor(requireContext(), R.color.signal_accent_green));
    DrawableCompat.setTint(invalidWordX, ContextCompat.getColor(requireContext(), R.color.signal_alert_primary));
    PaymentsRecoveryPhraseConfirmViewModel viewModel = ViewModelProviders.of(requireActivity()).get(PaymentsRecoveryPhraseConfirmViewModel.class);
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(requireView()).popBackStack());
    word1.addTextChangedListener(new AfterTextChanged(e -> viewModel.validateWord1(e.toString())));
    word2.addTextChangedListener(new AfterTextChanged(e -> viewModel.validateWord2(e.toString())));
    seePhraseAgain.setOnClickListener(v -> Navigation.findNavController(requireView()).popBackStack());
    done.setOnClickListener(v -> {
        SignalStore.paymentsValues().setUserConfirmedMnemonic(true);
        ViewUtil.hideKeyboard(requireContext(), view);
        Toast.makeText(requireContext(), R.string.PaymentRecoveryPhraseConfirmFragment__recovery_phrase_confirmed, Toast.LENGTH_SHORT).show();
        if (args.getFinishOnConfirm()) {
            requireActivity().setResult(Activity.RESULT_OK);
            requireActivity().finish();
        } else {
            Navigation.findNavController(view).popBackStack(R.id.paymentsHome, false);
        }
    });
    viewModel.getViewState().observe(getViewLifecycleOwner(), viewState -> {
        updateValidity(word1, viewState.isWord1Valid());
        updateValidity(word2, viewState.isWord2Valid());
        done.setEnabled(viewState.areAllWordsValid());
        String hint1 = getString(R.string.PaymentRecoveryPhraseConfirmFragment__word_d, viewState.getWord1Index() + 1);
        String hint2 = getString(R.string.PaymentRecoveryPhraseConfirmFragment__word_d, viewState.getWord2Index() + 1);
        wordWrapper1.setHint(hint1);
        wordWrapper2.setHint(hint2);
    });
    viewModel.updateRandomIndices();
}
Also used : EditText(android.widget.EditText) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toast(android.widget.Toast) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Navigation(androidx.navigation.Navigation) Activity(android.app.Activity) ContextCompat(androidx.core.content.ContextCompat) EditText(android.widget.EditText) TextInputLayout(com.google.android.material.textfield.TextInputLayout) TextView(android.widget.TextView) View(android.view.View) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) Toolbar(androidx.appcompat.widget.Toolbar)

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