java类android.text.method.PasswordTransformationMethod的实例源码

AndroidTextFieldUI.java 文件源码 项目:AMPASIDE 阅读 17 收藏 0 点赞 0 评论 0
public void setConstraints(final int constraints) {
    activity.post(new Runnable() {
        public void run() {
               if ((constraints & TextField.CONSTRAINT_MASK) == TextField.URL) {
                   editView.setSingleLine(true);
               } else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.NUMERIC) {
                   editView.setSingleLine(true);
                   editView.setInputType(InputType.TYPE_CLASS_NUMBER);
               } else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.DECIMAL) {
                   editView.setSingleLine(true);
                   editView.setInputType(
                           InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
               } else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.PHONENUMBER) {
                   editView.setSingleLine(true);
                   editView.setInputType(InputType.TYPE_CLASS_PHONE);
               }
               if ((constraints & TextField.PASSWORD) != 0) {
                   editView.setTransformationMethod(PasswordTransformationMethod.getInstance());
                   editView.setTypeface(Typeface.MONOSPACE);
               }
        }
    });
}
FxAccountAbstractSetupActivity.java 文件源码 项目:mc_backup 阅读 24 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
protected void setPasswordButtonShown(boolean shouldShow) {
  // Changing input type loses position in edit text; let's try to maintain it.
  int start = passwordEdit.getSelectionStart();
  int stop = passwordEdit.getSelectionEnd();

  if (!shouldShow) {
    passwordEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
    showPasswordButton.setText(R.string.fxaccount_password_show);
    showPasswordButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.fxaccount_password_button_show_background));
    showPasswordButton.setTextColor(ColorUtils.getColor(this, R.color.fxaccount_password_show_textcolor));
  } else {
    passwordEdit.setTransformationMethod(SingleLineTransformationMethod.getInstance());
    showPasswordButton.setText(R.string.fxaccount_password_hide);
    showPasswordButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.fxaccount_password_button_hide_background));
    showPasswordButton.setTextColor(ColorUtils.getColor(this, R.color.fxaccount_password_hide_textcolor));
  }
  passwordEdit.setSelection(start, stop);
}
PasswordDialog.java 文件源码 项目:TimberdoodleApp 阅读 29 收藏 0 点赞 0 评论 0
private void showPasswordDialog(@StringRes int title,
                                final OnPasswordEnteredListener okListener,
                                final DialogInterface.OnClickListener cancelListener) {
    // Create EditText for entering the password
    final EditText input = new EditText(context);
    input.setSingleLine();
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());

    // Create and show dialog
    showDialog(new AlertDialog.Builder(context)
            .setTitle(title)
            .setView(input)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    okListener.onPasswordEntered(dialog, which, input.getText().toString());
                }
            })
            .setNegativeButton(android.R.string.cancel, cancelListener));
}
DetailFragment.java 文件源码 项目:Passbook 阅读 28 收藏 0 点赞 0 评论 0
void changeDisplay(View view, int pos) {
    if(mShowPwd) {
        return;
    }
    Account.Entry entry = mItems.get(pos);
    if(entry.mType == AccountManager.EntryType.PASSWORD ||
            entry.mType == AccountManager.EntryType.PIN) {
        boolean showed = mPwdShowed.get(pos);
        ViewHolder holder = (ViewHolder)view.getTag();
        if(showed) {
            holder.mValue.setTransformationMethod(
                    PasswordTransformationMethod.getInstance());
        } else {
            holder.mValue.setTransformationMethod(
                    SingleLineTransformationMethod.getInstance());
        }
        mPwdShowed.set(pos, !showed);
    }
}
TextInputLayout.java 文件源码 项目:iosched 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Returns whether the password visibility toggle functionality is enabled or not.
 *
 * <p>When enabled, a button is placed at the end of the EditText which enables the user to switch
 * between the field's input being visibly disguised or not.
 *
 * @param enabled true to enable the functionality
 * @attr ref android.support.design.R.styleable#TextInputLayout_passwordToggleEnabled
 */
public void setPasswordVisibilityToggleEnabled(final boolean enabled) {
  if (mPasswordToggleEnabled != enabled) {
    mPasswordToggleEnabled = enabled;

    if (!enabled && mPasswordToggledVisible && mEditText != null) {
      // If the toggle is no longer enabled, but we remove the PasswordTransformation
      // to make the password visible, add it back
      mEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }

    // Reset the visibility tracking flag
    mPasswordToggledVisible = false;

    updatePasswordToggleView();
  }
}
TextInputLayout.java 文件源码 项目:iosched 阅读 19 收藏 0 点赞 0 评论 0
void passwordVisibilityToggleRequested() {
  if (mPasswordToggleEnabled) {
    // Store the current cursor position
    final int selection = mEditText.getSelectionEnd();

    if (hasPasswordTransformation()) {
      mEditText.setTransformationMethod(null);
      mPasswordToggledVisible = true;
    } else {
      mEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
      mPasswordToggledVisible = false;
    }

    mPasswordToggleView.setChecked(mPasswordToggledVisible);

    // And restore the cursor position
    mEditText.setSelection(selection);
  }
}
PasswordEdt.java 文件源码 项目:Nepenthes-Android 阅读 25 收藏 0 点赞 0 评论 0
@Override
public boolean onTouchEvent(MotionEvent event) {
    final int lens = this.getText().toString().length();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN: {
            boolean isClean = (event.getX() > (getWidth() - getTotalPaddingRight())) && (event.getX() < (getWidth() - getPaddingRight()));
            if (isClean) {
                this.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                setSelection(lens);
            }
        }
        break;
        case MotionEvent.ACTION_UP: {
            this.setTransformationMethod(PasswordTransformationMethod.getInstance());
            setSelection(lens);
        }
        break;
        default:
            break;
    }
    return super.onTouchEvent(event);
}
MainActivity.java 文件源码 项目:AutoAP 阅读 16 收藏 0 点赞 0 评论 0
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.ap_button:
            if (isChecked) {
                //Turn on AP
                enableAP();
            } else {
                //Turn off AP
                disableAP();
            }
            break;
        case R.id.checkBox:
            if (!isChecked) {
                passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                passwordEditText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
    }
}
Regist3Activity.java 文件源码 项目:GomeOnline 阅读 25 收藏 0 点赞 0 评论 0
@AfterViews
    protected void init() {
        setTitle(R.string.regist3);
//      phone="11112345685";
        passwdCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
//                  mEditTextPw.setInputType(InputType.TYPE_TEXT_VARIATION_NORMAL);
                    mEditTextPw.setTransformationMethod(HideReturnsTransformationMethod.getInstance());  
                    mEditTextPw.setSelection(mEditTextPw.getText().length());
                }else{
                    mEditTextPw.setTransformationMethod(PasswordTransformationMethod.getInstance());  
                    mEditTextPw.setSelection(mEditTextPw.getText().length());
//                  mEditTextPw.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                }
            }
        });
    }
PasswordActivity.java 文件源码 项目:prey-android-client-master 阅读 18 收藏 0 点赞 0 评论 0
protected void bindPasswordControls() {
    Button checkPasswordOkButton = (Button) findViewById(R.id.password_btn_login);
    final EditText pass1 = ((EditText) findViewById(R.id.password_pass_txt));
    checkPasswordOkButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            final String passwordtyped = pass1.getText().toString();
            if (passwordtyped.equals(""))
                Toast.makeText(PasswordActivity.this, R.string.preferences_password_length_error, Toast.LENGTH_LONG).show();
            else
                new CheckPassword().execute(passwordtyped);

        }
    });

    //Hack to fix hint's typeface: http://stackoverflow.com/questions/3406534/password-hint-font-in-android
    EditText password = (EditText) findViewById(R.id.password_pass_txt);
    password.setTypeface(Typeface.DEFAULT);
    password.setTransformationMethod(new PasswordTransformationMethod());
}


问题


面经


文章

微信
公众号

扫码关注公众号