com.google.android.material.textfield.TextInputEditText Java Examples

The following examples show how to use com.google.android.material.textfield.TextInputEditText. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataSetInitialActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void showCatComboSelector(String catOptionUid, List<CategoryOption> data) {
    if (data.size() == 1 && data.get(0).name().equals("default")) {
        if (selectedCatOptions == null)
            selectedCatOptions = new HashMap<>();
        selectedCatOptions.put(catOptionUid, data.get(0));
    } else {

        CategoryOptionPopUp.getInstance()
                .setCategoryName(((TextInputEditText) selectedView).getHint().toString())
                .setCatOptions(data)
                .setDate(selectedPeriod)
                .setOnClick(item -> {
                    if (item != null)
                        selectedCatOptions.put(catOptionUid, item);
                    else
                        selectedCatOptions.remove(catOptionUid);
                    ((TextInputEditText) selectedView).setText(item != null ? item.displayName() : null);
                    checkActionVisivbility();
                })
                .show(this, selectedView);
    }
}
 
Example #2
Source File: AgeView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private AlertDialog getYearsDialog() {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_age, null);
    TextInputEditText yearPicker = view.findViewById(R.id.input_year);
    TextInputEditText monthPicker = view.findViewById(R.id.input_month);
    TextInputEditText dayPicker = view.findViewById(R.id.input_days);
    yearPicker.setText(year.getText());
    monthPicker.setText(month.getText());
    dayPicker.setText(day.getText());

    return new AlertDialog.Builder(getContext(), R.style.CustomDialog)
            .setView(view)
            .setPositiveButton(R.string.action_accept, (dialog, which) -> handleSingleInputs(
                    isEmpty(yearPicker.getText().toString()) ? 0 : -Integer.valueOf(yearPicker.getText().toString()),
                    isEmpty(monthPicker.getText().toString()) ? 0 : -Integer.valueOf(monthPicker.getText().toString()),
                    isEmpty(dayPicker.getText().toString()) ? 0 : -Integer.valueOf(dayPicker.getText().toString())))
            .setNegativeButton(R.string.clear, (dialog, which) -> {
                clearValues();
                listener.onAgeSet(null);
            })
            .create();
}
 
Example #3
Source File: AlarmDescriptionStep.java    From VerticalStepperForm with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected View createStepContentLayout() {

    // We create this step view programmatically
    alarmDescriptionEditText = new TextInputEditText(getContext());
    alarmDescriptionEditText.setHint(R.string.form_hint_description);
    alarmDescriptionEditText.setSingleLine(true);
    alarmDescriptionEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            getFormView().goToNextStep(true);
            return false;
        }
    });

    return alarmDescriptionEditText;
}
 
Example #4
Source File: DataSetInitialActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void clearCatOptionCombo(){
    if(!binding.getDataSetModel().categoryComboName().equals("default")){
        for(int i=0; i<binding.catComboContainer.getChildCount();i++){
            View catView = binding.catComboContainer.getChildAt(i);
            ((TextInputEditText)catView.findViewById(R.id.input_editText)).setText(null);
        }
        for (Category categories : binding.getDataSetModel().getCategories()) {
            selectedCatOptions.put(categories.uid(), null);
        }
    }
}
 
Example #5
Source File: RegistrationActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void setConfig(@IdRes int viewId, String configTarget, boolean doTrim) {
    TextInputEditText view = findViewById(viewId);
    String value = view.getText().toString();
    if(doTrim) {
        value = value.trim();
    }
    DcHelper.getContext(this).setConfig(configTarget, value.isEmpty()? null : value);
}
 
Example #6
Source File: RegistrationActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void verifyPort(TextInputEditText view) {
    String error = getString(R.string.login_error_port);
    String portString = view.getText().toString();
    if (!portString.isEmpty()) {
        try {
            int port = Integer.valueOf(portString);
            if (port < 1 || port > 65535) {
                view.setError(error);
            }
        } catch (NumberFormatException exception) {
            view.setError(error);
        }
    }
}
 
Example #7
Source File: ImportSpreadsheetDialog.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * Validates column index lol
 *
 * @param editable
 * @param view
 */
private void validateColumnIndex(Editable editable, TextInputEditText view) {
    if (!Validator.validateColumnIndex(editable.toString())) {
        view.setError(getString(R.string.error_column_index));
    } else {
        view.setError(null);
    }
}
 
Example #8
Source File: RegistrationActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void verifyServer(TextInputEditText view) {
    String error = getString(R.string.login_error_server);
    String server = view.getText().toString();
    if (!TextUtils.isEmpty(server) && !Patterns.DOMAIN_NAME.matcher(server).matches()
            && !Patterns.IP_ADDRESS.matcher(server).matches()
            && !Patterns.WEB_URL.matcher(server).matches()) {
        view.setError(error);
    }
}
 
Example #9
Source File: RegistrationActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void verifyEmail(TextInputEditText view) {
    String error = getString(R.string.login_error_mail);
    String email = view.getText().toString();
    if (!matchesEmailPattern(email)) {
        view.setError(error);
    }
}
 
Example #10
Source File: RegistrationActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void focusListener(View view, boolean focused, VerificationType type) {

        if (!focused) {
            TextInputEditText inputEditText = (TextInputEditText) view;
            switch (type) {
                case EMAIL:
                    verifyEmail(inputEditText);
                    if (!oauth2DeclinedByUser) {
                        checkOauth2start().addListener(new ListenableFuture.Listener<Boolean>() {
                            @Override
                            public void onSuccess(Boolean oauth2started) {
                                if (!oauth2started) {
                                    updateProviderInfo();
                                }
                            }

                            @Override
                            public void onFailure(ExecutionException e) {
                                updateProviderInfo();
                            }
                        });
                    } else {
                        updateProviderInfo();
                    }
                    break;
                case SERVER:
                    verifyServer(inputEditText);
                    break;
                case PORT:
                    verifyPort(inputEditText);
                    break;
            }
        }
    }
 
Example #11
Source File: ControllerBrick.java    From brickkit-android with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for ControllerBrickHolder.
 *
 * @param itemView view for this brick
 */
private ControllerBrickHolder(View itemView) {
    super(itemView);

    textInputLayout = (TextInputLayout) itemView.findViewById(R.id.text_input_layout);
    editText = (TextInputEditText) itemView.findViewById(R.id.text_input_edit_text);
    downButton = (Button) itemView.findViewById(R.id.down_button);
    upButton = (Button) itemView.findViewById(R.id.up_button);
}
 
Example #12
Source File: SearchFragment.java    From ArchPackages with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FragmentSearchBinding fragmentSearchBinding = FragmentSearchBinding.inflate(inflater, container, false);
    textInputLayout = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsTextInputLayout;
    // keywords radio group
    radioGroupKeywords = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsRadioGroup;
    // repo check boxes
    checkBoxRepoCore = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoCore;
    checkBoxRepoExtra = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoExtra;
    checkBoxRepoTesting = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoTesting;
    checkBoxRepoMultilib = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoMultilib;
    checkBoxRepoMultilibTesting = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoMultilibTesting;
    checkBoxRepoCommunity = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoCommunity;
    checkBoxRepoCommunityTesting = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoCommunityTesting;
    // arch check boxes
    checkBoxArchAny = fragmentSearchBinding.fragmentSearchArchLayout.searchCheckBoxArchAny;
    checkBoxArchX84_64 = fragmentSearchBinding.fragmentSearchArchLayout.searchCheckBoxArchX8664;
    // flagged radio buttons
    radioGroupFlag = fragmentSearchBinding.fragmentSearchFlagLayout.searchFlagRadioGroup;
    // search ime action
    TextInputEditText textInputEditText = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsTextInputEditText;
    textInputEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    textInputEditText.setOnEditorActionListener((editTextView, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            if (searchFragmentCallback != null) {
                searchFragmentCallback.onSearchFragmentCallbackOnFabClicked(
                        getKeywordsParameter(),
                        getQuery(),
                        getListRepo(),
                        getListArch(),
                        getFlagged());
            }
            InputMethodManager inputMethodManager = (InputMethodManager) editTextView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            if (inputMethodManager != null)
                inputMethodManager.hideSoftInputFromWindow(editTextView.getWindowToken(), 0);
            return true;
        }
        return false;
    });
    return fragmentSearchBinding.getRoot();
}
 
Example #13
Source File: CardForm.java    From android-card-form with MIT License 4 votes vote down vote up
/**
 * Sets up the card form for display to the user using the values provided in {@link CardForm#cardRequired(boolean)},
 * {@link CardForm#expirationRequired(boolean)}, ect. If {@link CardForm#setup(AppCompatActivity)} is not called,
 * the form will not be visible.
 *
 * @param activity Used to set {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to prevent screenshots
 */
public void setup(AppCompatActivity activity) {
    mCardScanningFragment = (CardScanningFragment)activity
            .getSupportFragmentManager()
            .findFragmentByTag(CardScanningFragment.TAG);

    if (mCardScanningFragment != null) {
        mCardScanningFragment.setCardForm(this);
    }

    activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
            WindowManager.LayoutParams.FLAG_SECURE);

    boolean cardHolderNameVisible = mCardholderNameStatus != FIELD_DISABLED;
    boolean isDarkBackground = ViewUtils.isDarkBackground(activity);
    mCardholderNameIcon.setImageResource(isDarkBackground ? R.drawable.bt_ic_cardholder_name_dark: R.drawable.bt_ic_cardholder_name);
    mCardNumberIcon.setImageResource(isDarkBackground ? R.drawable.bt_ic_card_dark : R.drawable.bt_ic_card);
    mPostalCodeIcon.setImageResource(isDarkBackground ? R.drawable.bt_ic_postal_code_dark : R.drawable.bt_ic_postal_code);
    mMobileNumberIcon.setImageResource(isDarkBackground? R.drawable.bt_ic_mobile_number_dark : R.drawable.bt_ic_mobile_number);

    mExpiration.useDialogForExpirationDateEntry(activity, true);

    setViewVisibility(mCardholderNameIcon,  cardHolderNameVisible);
    setFieldVisibility(mCardholderName, cardHolderNameVisible);
    setViewVisibility(mCardNumberIcon, mCardNumberRequired);
    setFieldVisibility(mCardNumber, mCardNumberRequired);
    setFieldVisibility(mExpiration, mExpirationRequired);
    setFieldVisibility(mCvv, mCvvRequired);
    setViewVisibility(mPostalCodeIcon, mPostalCodeRequired);
    setFieldVisibility(mPostalCode, mPostalCodeRequired);
    setViewVisibility(mMobileNumberIcon, mMobileNumberRequired);
    setFieldVisibility(mCountryCode, mMobileNumberRequired);
    setFieldVisibility(mMobileNumber, mMobileNumberRequired);
    setViewVisibility(mMobileNumberExplanation, mMobileNumberRequired);
    setViewVisibility(mSaveCardCheckBox, mSaveCardCheckBoxVisible);

    TextInputEditText editText;
    for (int i = 0; i < mVisibleEditTexts.size(); i++) {
        editText = mVisibleEditTexts.get(i);
        if (i == mVisibleEditTexts.size() - 1) {
            editText.setImeOptions(EditorInfo.IME_ACTION_GO);
            editText.setImeActionLabel(mActionLabel, EditorInfo.IME_ACTION_GO);
            editText.setOnEditorActionListener(this);
        } else {
            editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            editText.setImeActionLabel(null, EditorInfo.IME_ACTION_NONE);
            editText.setOnEditorActionListener(null);
        }
    }

    mSaveCardCheckBox.setInitiallyChecked(mSaveCardCheckBoxChecked);

    setVisibility(VISIBLE);
}
 
Example #14
Source File: DetailActionUtil.java    From geopackage-mapcache-android with MIT License 4 votes vote down vote up
/**
     * Open a copy GeoPackage dialog view
     * @param context Context for opening dialog
     * @param gpName GeoPackage name
     * @param listener Click listener to callback to the mapfragment
     */
    public void openCopyDialog(Context context, String gpName,
                                 final OnDialogButtonClickListener listener){
        // Create Alert window with basic input text layout
        LayoutInflater inflater = LayoutInflater.from(context);
        View alertView = inflater.inflate(R.layout.basic_edit_alert, null);
        // Logo and title
        ImageView alertLogo = (ImageView) alertView.findViewById(R.id.alert_logo);
        alertLogo.setBackgroundResource(R.drawable.material_copy);
        TextView titleText = (TextView) alertView.findViewById(R.id.alert_title);
        titleText.setText("Copy GeoPackage");

        final TextInputEditText inputName = (TextInputEditText) alertView.findViewById(R.id.edit_text_input);
        inputName.setText(gpName + context.getString(R.string.geopackage_copy_suffix));
        inputName.setHint("GeoPackage Name");

        AlertDialog.Builder copyDialogBuilder = new AlertDialog.Builder(context, R.style.AppCompatAlertDialogStyle)
                .setView(alertView)
                .setPositiveButton("Copy", (dialog, which)->{
                            String newName = inputName.getText().toString();
                            if (newName != null && !newName.isEmpty()
                                    && !newName.equals(gpName)) {
                                dialog.dismiss();
                                listener.onCopyGP(gpName, newName);
                            }
                })

                .setNegativeButton(context.getString(R.string.button_cancel_label),
                        (dialog, which)->{
                            dialog.dismiss();
                });
        AlertDialog alertDialog = copyDialogBuilder.create();

//        // Validate the input before allowing the rename to happen
//        inputName.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
//            @Override
//            public void afterTextChanged(Editable editable) {}
//
//            @Override
//            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//                String givenName = inputName.getText().toString();
//                alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
//
//                if(givenName.isEmpty()){
//                    inputName.setError("Name is required");
//                    alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
//                } else {
//                    boolean allowed = Pattern.matches("[a-zA-Z_0-9]+", givenName);
//                    if (!allowed) {
//                        inputName.setError("Names must be alphanumeric only");
//                        alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
//                    }
//                }
//            }
//        });
        alertDialog.show();
    }
 
Example #15
Source File: NameExperimentDialog.java    From science-journal with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  String previousTitle = getResources().getString(R.string.default_experiment_name);
  if (savedInstanceState != null) {
    previousTitle = savedInstanceState.getString(KEY_SAVED_TITLE);
  }

  appAccount = WhistlePunkApplication.getAccount(getContext(), getArguments(), KEY_ACCOUNT_KEY);

  experimentId = getArguments().getString(KEY_EXPERIMENT_ID);

  final AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
  ViewGroup rootView =
      (ViewGroup)
          LayoutInflater.from(getActivity()).inflate(R.layout.name_experiment_dialog, null);
  input = (TextInputEditText) rootView.findViewById(R.id.title);
  inputLayout = (TextInputLayout) rootView.findViewById(R.id.title_input_layout);
  input.setText(previousTitle);
  if (savedInstanceState == null) {
    input.selectAll();
  }
  // TODO: Max char count?
  // TODO: Pop up the keyboard immediately.

  alertDialog.setView(rootView);

  alertDialog.setTitle(R.string.name_experiment_dialog_title);
  alertDialog.setCancelable(true);
  alertDialog.setPositiveButton(
      android.R.string.ok, (dialogInterface, i) -> saveNewTitle(alertDialog.getContext()));
  AlertDialog result = alertDialog.create();
  RxTextView.afterTextChangeEvents(input)
      .subscribe(
          event -> {
            Button button = result.getButton(DialogInterface.BUTTON_POSITIVE);
            if (input.getText().toString().length() == 0) {
              if (getActivity() != null) {
                inputLayout.setError(
                    getActivity()
                        .getResources()
                        .getString(R.string.empty_experiment_title_error));
              }
              if (button != null) {
                button.setEnabled(false);
              }
            } else if (button != null) {
              inputLayout.setErrorEnabled(false);
              button.setEnabled(true);
            }
          });

  return result;
}
 
Example #16
Source File: BookInfoActivity.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
private String getTextString(TextInputEditText editText) {
    return editText.getText() == null ? null : editText.getText().toString();
}
 
Example #17
Source File: BindingAdapters.java    From ground-android with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("errorText")
public static void bindError(TextInputEditText view, Optional<String> error) {
  if (error != null) {
    error.ifPresentOrElse(view::setError, () -> view.setError(null));
  }
}
 
Example #18
Source File: DateTimeView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public TextInputEditText getEditText() {
    return editText;
}
 
Example #19
Source File: TimeView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public TextInputEditText getEditText() {
    return editText;
}
 
Example #20
Source File: DateView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public TextInputEditText getEditText() {
    return editText;
}
 
Example #21
Source File: BindingAdapters.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("editorAction")
public static void setEditorAction(final TextInputEditText editText, final TextView.OnEditorActionListener listener) {
    editText.setOnEditorActionListener(listener);
}
 
Example #22
Source File: EditTextBindingAdapters.java    From brickkit-android with Apache License 2.0 2 votes vote down vote up
/**
 * Bind the {@link android.text.TextWatcher} to the {@link TextInputEditText}.
 *
 * @param editText the {@link TextInputEditText}
 * @param controllerViewModel the {@link ControllerViewModel} that provides
 *                            a {@link android.text.TextWatcher}
 */
@BindingAdapter("textChangedListener")
public static void bindTextWatcher(TextInputEditText editText, ControllerViewModel controllerViewModel) {
    editText.addTextChangedListener(controllerViewModel.getTextWatcher());
    editText.setSelection(controllerViewModel.getValue().length());
}
 
Example #23
Source File: SaveTestAdapter.java    From QuranyApp with Apache License 2.0 votes vote down vote up
void onClickTestCheck(AyahItem item, TextInputEditText editText);