@OnClick(R.id.customView)
  public void showCustomView() {
    MaterialDialog dialog =
        new MaterialDialog.Builder(this)
            .title(R.string.googleWifi)
            .customView(R.layout.dialog_customview, true)
            .positiveText(R.string.connect)
            .negativeText(android.R.string.cancel)
            .onPositive(
                new MaterialDialog.SingleButtonCallback() {
                  @Override
                  public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    showToast("Password: " + passwordInput.getText().toString());
                  }
                })
            .build();

    positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
    //noinspection ConstantConditions
    passwordInput = (EditText) dialog.getCustomView().findViewById(R.id.password);
    passwordInput.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            positiveAction.setEnabled(s.toString().trim().length() > 0);
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    // Toggling the show password CheckBox will mask or unmask the password input EditText
    CheckBox checkbox = (CheckBox) dialog.getCustomView().findViewById(R.id.showPassword);
    checkbox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            passwordInput.setInputType(
                !isChecked ? InputType.TYPE_TEXT_VARIATION_PASSWORD : InputType.TYPE_CLASS_TEXT);
            passwordInput.setTransformationMethod(
                !isChecked ? PasswordTransformationMethod.getInstance() : null);
          }
        });

    int widgetColor = ThemeSingleton.get().widgetColor;
    MDTintHelper.setTint(
        checkbox,
        widgetColor == 0 ? ContextCompat.getColor(this, R.color.material_teal_500) : widgetColor);

    MDTintHelper.setTint(
        passwordInput,
        widgetColor == 0 ? ContextCompat.getColor(this, R.color.material_teal_500) : widgetColor);

    dialog.show();
    positiveAction.setEnabled(false); // disabled by default
  }
  public void notifyPasswordValidation(boolean valid) {
    final MaterialDialog dialog = (MaterialDialog) getDialog();
    final View positive = dialog.getActionButton(DialogAction.POSITIVE);
    final View negative = dialog.getActionButton(DialogAction.NEGATIVE);
    toggleButtonsEnabled(true);

    if (valid) {
      if (mStage == Stage.NEW_FINGERPRINT_ENROLLED && mUseFingerprintFutureCheckBox.isChecked()) {
        // Re-create the key so that fingerprints including new ones are validated.
        Digitus.get().recreateKey();
        mStage = Stage.FINGERPRINT;
      }
      mPassword.setText("");
      mCallback.onFingerprintDialogAuthenticated();
      dismiss();
    } else {
      mPasswordDescriptionTextView.setText(R.string.password_not_recognized);
      final int red = ContextCompat.getColor(getActivity(), R.color.material_red_500);
      MDTintHelper.setTint(mPassword, red);
      ((TextView) positive).setTextColor(red);
      ((TextView) negative).setTextColor(red);
    }
  }