android.text.method.PasswordTransformationMethod Java Examples

The following examples show how to use android.text.method.PasswordTransformationMethod. 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 Project: DevUtils   Author: afkT   File: EditTextUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置密码文本视图显示转换
 * @param editText          {@link EditText}
 * @param isDisplayPassword 是否显示密码
 * @param isSelectBottom    是否设置光标到最后
 * @param <T>               泛型
 * @return {@link EditText}
 */
public static <T extends EditText> T setTransformationMethod(final T editText, final boolean isDisplayPassword, final boolean isSelectBottom) {
    if (editText != null) {
        // 获取光标位置
        int curSelect = 0;
        if (!isSelectBottom) {
            curSelect = getSelectionStart(editText);
        }
        editText.setTransformationMethod(isDisplayPassword ?
                HideReturnsTransformationMethod.getInstance() : PasswordTransformationMethod.getInstance());
        if (isSelectBottom) { // 设置光标到最后
            setSelectionToBottom(editText);
        } else { // 设置光标到之前的位置
            setSelection(editText, curSelect);
        }
    }
    return editText;
}
 
Example #2
Source Project: alpha-wallet-android   Author: AlphaWallet   File: InputView.java    License: MIT License 6 votes vote down vote up
private void setInputType() {
    if (inputType != null) {
        switch (inputType) {
            case "textPassword": {
                editText.setInputType(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
                togglePassword.setVisibility(View.VISIBLE);
                editText.setPadding(
                        Utils.dp2px(context, 15),
                        Utils.dp2px(context, 5),
                        Utils.dp2px(context, 50),
                        Utils.dp2px(context, 5)
                );
                editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
                break;
            }
            case "number": {
                editText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                break;
            }
        }
    }
}
 
Example #3
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: PasscodeActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && SharedConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (type == 1 && currentPasswordType == 1 || type == 2 && SharedConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example #4
Source Project: letv   Author: JackChan1999   File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void beautyView() {
    beautyEditText(this.mInputAccount, L10NString.getString("umgr_please_input_username"), this.mAccountTextWatcher);
    beautyCleanButton(this.mClearInputAccount, this);
    this.mInputAccountLayout.setOnClickListener(this);
    beautyCleanButton(this.mClearInputPassword, this);
    this.mInputPassword.setOnClickListener(this);
    beautyEditText(this.mInputPassword, L10NString.getString("umgr_please_input_password"), this.mPasswordTextWatcher);
    beautyColorTextView(this.mRegister, "#007dc4", false, L10NString.getString("umgr_whether_register_ornot"), this);
    beautyColorTextView(this.mFindpwd, "#007dc4", false, L10NString.getString("umgr_whether_forget_password"), this);
    beautyColorTextView(this.mSwitchAccount, "#007dc4", false, L10NString.getString("umgr_third_login_qihoo_tip"), this);
    beautyButtonGreen(this.mLogin, L10NString.getString("umgr_login"), this);
    beautyTextView(this.mAgreeClause1, L10NString.getString("umgr_login_agree_clause_1"));
    beautyTextView(this.mAgreeClauseUser, L10NString.getString("umgr_agree_clause_2_user"));
    beautyColorTextView(this.mAgreement, "#0099e5", true, L10NString.getString("umgr_agree_clause_2_agreement"), this);
    beautyTextView(this.mAnd, L10NString.getString("umgr_agree_clause_2_and"));
    beautyColorTextView(this.mPrivacy, "#0099e5", true, L10NString.getString("umgr_agree_clause_2_privacy"), this);
    beautyCheckButton(this.mShowPwd, new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            LoginActivity.this.mInputPassword.setTransformationMethod(LoginActivity.this.mShowPwd.isChecked() ? HideReturnsTransformationMethod.getInstance() : PasswordTransformationMethod.getInstance());
        }
    });
    loadPrivateConfig();
}
 
Example #5
Source Project: africastalking-android   Author: AfricasTalkingLtd   File: PinTextInputLayout.java    License: MIT License 6 votes vote down vote up
public void passwordVisibilityToggleRequested() throws NoSuchFieldException, IllegalAccessException {
    // Store the current cursor position
    int selection = getEditText().getSelectionEnd();

    if (!getEditText().getText().toString().isEmpty()) {
        getEditText().setTransformationMethod(PasswordTransformationMethod.getInstance());
        toggleEnabled("mPasswordToggledVisible", false);
        mPasswordToggleView.setChecked(false);
    } else {
        getEditText().setTransformationMethod(null);
        toggleEnabled("mPasswordToggledVisible", true);
        mPasswordToggleView.setChecked(true);
    }
    // And restore the cursor position
    getEditText().setSelection(selection);

}
 
Example #6
Source Project: Luhn   Author: KingsMentor   File: PinTextInputLayout.java    License: MIT License 6 votes vote down vote up
public void passwordVisibilityToggleRequested() throws NoSuchFieldException, IllegalAccessException {
    // Store the current cursor position
    int selection = getEditText().getSelectionEnd();

    if (!getEditText().getText().toString().isEmpty()) {
        getEditText().setTransformationMethod(PasswordTransformationMethod.getInstance());
        toggleEnabled("mPasswordToggledVisible", false);
        mPasswordToggleView.setChecked(false);
    } else {
        getEditText().setTransformationMethod(null);
        toggleEnabled("mPasswordToggledVisible", true);
        mPasswordToggleView.setChecked(true);
    }
    // And restore the cursor position
    getEditText().setSelection(selection);

}
 
Example #7
Source Project: appinventor-extensions   Author: mit-cml   File: PasswordTextBox.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new PasswordTextBox component.
 *
 * @param container  container, component will be placed in
 */
public PasswordTextBox(ComponentContainer container) {
  super(container, new EditText(container.$context()));

  // make the box single line
  view.setSingleLine(true);
  // Add a transformation method to hide password text.   This must
  // be done after the SingleLine command
  view.setTransformationMethod(new PasswordTransformationMethod());

  // make sure the done action is Done and not Next.  See comment in Textbox.java
  view.setImeOptions(EditorInfo.IME_ACTION_DONE);

  PasswordVisible(false);
  
}
 
Example #8
Source Project: material-components-android   Author: material-components   File: TextInputLayoutIconsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSetPasswordToggleProgrammatically() {
  // Set edit text input type to be password
  onView(withId(R.id.textinput_no_icon))
      .perform(setTransformationMethod(PasswordTransformationMethod.getInstance()));
  // Set end icon as the password toggle
  onView(withId(R.id.textinput_no_icon))
      .perform(setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE));

  final Activity activity = activityTestRule.getActivity();
  final TextInputLayout textInputLayout =
      activity.findViewById(R.id.textinput_no_icon);

  // Assert the end icon is the password toggle icon
  assertEquals(TextInputLayout.END_ICON_PASSWORD_TOGGLE, textInputLayout.getEndIconMode());
}
 
Example #9
Source Project: Android-Shortify   Author: dhruv1110   File: Views.java    License: Apache License 2.0 6 votes vote down vote up
public static $ pwd(boolean option){
    try{
        if(mView instanceof TextView){
            TextView textView = (TextView) mView;
            if(option)
                textView.setTransformationMethod(new PasswordTransformationMethod());
            else
                textView.setTransformationMethod(null);
        }
        else if(mView instanceof EditText){
            EditText editText = (EditText) mView;
            if(option)
                editText.setTransformationMethod(new PasswordTransformationMethod());
            else
                editText.setTransformationMethod(null);
        }
    }catch (Exception e){
        Log.d(TAG, e.getMessage());
    }
    return  $.getInstance();
}
 
Example #10
Source Project: A-week-to-develop-android-app-plan   Author: fanatic-mobile-developer-for-android   File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化视图
 */
private void initViews() {
    accountEdit = (CleanEditText) this.findViewById(R.id.et_email_phone);
    accountEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    accountEdit.setTransformationMethod(HideReturnsTransformationMethod
            .getInstance());
    passwordEdit = (CleanEditText) this.findViewById(R.id.et_password);
    passwordEdit.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEdit.setImeOptions(EditorInfo.IME_ACTION_GO);
    passwordEdit.setTransformationMethod(PasswordTransformationMethod
            .getInstance());
    passwordEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId,
                                      KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE
                    || actionId == EditorInfo.IME_ACTION_GO) {
                clickLogin();
            }
            return false;
        }
    });
}
 
Example #11
Source Project: A-week-to-develop-android-app-plan   Author: fanatic-mobile-developer-for-android   File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化视图
 */
private void initViews() {
    accountEdit = (CleanEditText) this.findViewById(R.id.et_email_phone);
    accountEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    accountEdit.setTransformationMethod(HideReturnsTransformationMethod
            .getInstance());
    passwordEdit = (CleanEditText) this.findViewById(R.id.et_password);
    passwordEdit.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEdit.setImeOptions(EditorInfo.IME_ACTION_GO);
    passwordEdit.setTransformationMethod(PasswordTransformationMethod
            .getInstance());
    passwordEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId,
                                      KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE
                    || actionId == EditorInfo.IME_ACTION_GO) {
                clickLogin();
            }
            return false;
        }
    });
}
 
Example #12
Source Project: AndroidUI   Author: tyzlmjj   File: PasswordEditText.java    License: MIT License 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        boolean touchable = ( getWidth() - mWidth - Interval < event.getX() ) && (event.getX() < getWidth() - Interval);
        if (touchable) {
            isVisible = !isVisible;
            if (isVisible){
                //设置EditText文本为可见的
                setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }else{
                //设置EditText文本为隐藏的
                setTransformationMethod(PasswordTransformationMethod.getInstance());
            }
        }
    }
    return super.onTouchEvent(event);
}
 
Example #13
Source Project: Passbook   Author: zhuqianqian   File: DetailFragment.java    License: Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #14
Source Project: AutoAP   Author: hoang8f   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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());
            }
    }
}
 
Example #15
Source Project: Android-SDK   Author: Backendless   File: RegisterActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onCreate( Bundle savedInstanceState )
{
  super.onCreate( savedInstanceState );
  setContentView( R.layout.registration );

  userDate = Calendar.getInstance();
  userDate.set( 1970, Calendar.DECEMBER, 31 );
  nameField = (EditText) findViewById( R.id.nameField );
  passwordField = (EditText) findViewById( R.id.passwordField );
  passwordField.setTypeface( Typeface.DEFAULT );
  passwordField.setTransformationMethod( new PasswordTransformationMethod() );
  verifyPasswordField = (EditText) findViewById( R.id.verifyPasswordField );
  verifyPasswordField.setTypeface( Typeface.DEFAULT );
  verifyPasswordField.setTransformationMethod( new PasswordTransformationMethod() );
  emailField = (EditText) findViewById( R.id.emailField );
  birthdateField = (EditText) findViewById( R.id.birthdateField );
  birthdateField.setFocusable( false );
  birthdateField.setOnClickListener( birthdateFieldListener );
  genderRadio = (RadioGroup) findViewById( R.id.genderGroup );
  findViewById( R.id.cancelButton ).setOnClickListener( cancelListener );
  Button registerButton = (Button) findViewById( R.id.registerButton );
  registerButton.setOnClickListener( registerListener );
}
 
Example #16
Source Project: logmein-android   Author: DevelopFreedom   File: ManagerUserServices.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Takes care if checked/unchecked box for showing/not showing password
 */
private void show_password() {
    if (mChbShowPwd.isChecked()) {
        mTextboxPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
        return;
    }
    mTextboxPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example #17
Source Project: TelePlus-Android   Author: TelePlusDev   File: PasscodeActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void updateDropDownTextView()
{
    if (dropDown != null)
    {
        if (currentPasswordType == 0)
        {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        }
        else if (currentPasswordType == 1)
        {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && SharedConfig.passcodeType == 0)
    {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    }
    else if (type == 1 && currentPasswordType == 1 || type == 2 && SharedConfig.passcodeType == 1)
    {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example #18
Source Project: tysq-android   Author: tysqapp   File: ForgetActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.tv_send_code:
            sendCode();
            break;

        case R.id.tv_next_step:
            nextStep();
            break;

        case R.id.iv_back:
            onBackPressed();
            break;

        case R.id.iv_pwd_state:
            isHidePwd = !isHidePwd;
            int startNew = etPwdNew.getSelectionStart();
            int startConfirm = etPwdConfirm.getSelectionStart();
            if (isHidePwd) {
                ivPwdState.setImageDrawable(
                        ContextCompat.getDrawable(this, R.drawable.ic_pwd_show));
                etPwdNew.setTransformationMethod(PasswordTransformationMethod.getInstance());
                etPwdConfirm.setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                ivPwdState.setImageDrawable(
                        ContextCompat.getDrawable(this, R.drawable.ic_pwd_hide));
                etPwdNew.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                etPwdConfirm.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
            etPwdNew.setSelection(startNew);
            etPwdConfirm.setSelection(startConfirm);
            break;

        case R.id.tv_confirm:
            resetPwd();
            break;
    }
}
 
Example #19
Source Project: tysq-android   Author: tysqapp   File: LoginActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.iv_back:
            finishPage(false);
            break;
        case R.id.iv_refresh:
            loadCode();
            break;
        case R.id.iv_pwd_state:
            isHidePwd = !isHidePwd;

            int start = etPwd.getSelectionStart();
            if (isHidePwd) {
                ivPwdState.setImageDrawable(
                        ContextCompat.getDrawable(this, R.drawable.ic_pwd_show));
                etPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                ivPwdState.setImageDrawable(
                        ContextCompat.getDrawable(this, R.drawable.ic_pwd_hide));
                etPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
            etPwd.setSelection(start);

            break;
        case R.id.tv_login:
            login();
            break;
        case R.id.tv_register:
            RegisterActivity.startActivity(this, getEmailInfo());
            break;
        case R.id.tv_forget_pwd:
            ForgetActivity.startActivity(this, getEmailInfo());
            break;
    }
}
 
Example #20
Source Project: tysq-android   Author: tysqapp   File: ResetPwdFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void setPwdState(ImageView imageView,
                         EditText editText,
                         boolean isHidePwd) {
    int start = editText.getSelectionStart();

    if (isHidePwd) {
        imageView.setImageDrawable(hidePwdDrawable);
        editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    } else {
        imageView.setImageDrawable(showPwdDrawable);
        editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    }

    editText.setSelection(start);
}
 
Example #21
Source Project: tysq-android   Author: tysqapp   File: RegisterActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 设置是否要显示密码
 *
 * @param isHidePwd true:隐藏密码
 *                  false: 显示密码
 */
private void setPwdState(boolean isHidePwd) {
    int start = etPwd.getSelectionStart();
    if (isHidePwd) {
        ivPwdState.setImageDrawable(
                ContextCompat.getDrawable(this, R.drawable.ic_pwd_show));
        etPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
    } else {
        ivPwdState.setImageDrawable(
                ContextCompat.getDrawable(this, R.drawable.ic_pwd_hide));
        etPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    }
    etPwd.setSelection(start);
}
 
Example #22
Source Project: DevUtils   Author: afkT   File: TextViewUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置密码文本视图显示转换
 * @param textView          {@link TextView}
 * @param isDisplayPassword 是否显示密码
 * @param <T>               泛型
 * @return {@link TextView}
 */
public static <T extends TextView> T setTransformationMethod(final T textView, final boolean isDisplayPassword) {
    if (textView != null) {
        textView.setTransformationMethod(isDisplayPassword ?
                HideReturnsTransformationMethod.getInstance() : PasswordTransformationMethod.getInstance());
    }
    return textView;
}
 
Example #23
Source Project: AndroidFrame   Author: DaleSmith   File: PwdClearableLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
     * 隐藏密码
     */
    private void hidePassword() {
        et_password.setTransformationMethod(PasswordTransformationMethod.getInstance());
        et_password.postInvalidate();
//		et_password.setInputType(InputType.TYPE_CLASS_TEXT
//				| InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
 
Example #24
Source Project: alpha-wallet-android   Author: AlphaWallet   File: PasswordInputView.java    License: MIT License 5 votes vote down vote up
private void setViews()
{
    label.setText(labelResId);
    if (labelResId != R.string.empty) label.setVisibility(View.VISIBLE);
    togglePassword.setOnCheckedChangeListener((buttonView, isChecked) -> {
        if (isChecked) {
            editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
        } else {
            editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
        editText.setSelection(editText.getText().length());
    });
}
 
Example #25
Source Project: alpha-wallet-android   Author: AlphaWallet   File: PasswordInputView.java    License: MIT License 5 votes vote down vote up
private void setInputType() {
    if (inputType != null) {
        switch (inputType) {
            case "textPassword": {
                editText.setInputType(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
                togglePassword.setVisibility(View.VISIBLE);
                editText.setPadding(
                        Utils.dp2px(context, 15),
                        Utils.dp2px(context, 5),
                        Utils.dp2px(context, 50),
                        Utils.dp2px(context, 5)
                );
                editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
                break;
            }
            case "number": {
                editText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                break;
            }
            case "textNoSuggestions":{
                editText.setInputType(editText.getInputType() |
                        EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS |
                        EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE |
                        EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                break;
            }
        }
    }
    editText.setTypeface(Typeface.DEFAULT);
}
 
Example #26
Source Project: TelePlus-Android   Author: TelePlusDev   File: PasscodeActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void updateDropDownTextView()
{
    if (dropDown != null)
    {
        if (currentPasswordType == 0)
        {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        }
        else if (currentPasswordType == 1)
        {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && SharedConfig.passcodeType == 0)
    {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    }
    else if (type == 1 && currentPasswordType == 1 || type == 2 && SharedConfig.passcodeType == 1)
    {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example #27
Source Project: argus-android   Author: moldedbits   File: EmailLoginProvider.java    License: Apache License 2.0 5 votes vote down vote up
protected void toggleShowPwd() {
    if (passwordInput.getTransformationMethod() != null) {
        passwordInput.setTransformationMethod(null);
        passwordInput.setSelection(passwordInput.getText().length());
        ivShowPassword.setImageResource(R.drawable.ic_hide_pwd);
    } else {
        passwordInput.setTransformationMethod(new PasswordTransformationMethod());
        passwordInput.setSelection(passwordInput.getText().length());
        ivShowPassword.setImageResource(R.drawable.icn_show_pwd);
    }
}
 
Example #28
Source Project: ucar-weex-core   Author: weexext   File: AbstractEditComponent.java    License: Apache License 2.0 5 votes vote down vote up
private int getInputType(String type) {
  int inputType;
  switch (type) {
    case Constants.Value.TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case Constants.Value.DATE:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case Constants.Value.EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case Constants.Value.PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getHostView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case Constants.Value.TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case Constants.Value.TIME:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    case Constants.Value.NUMBER:
      inputType = InputType.TYPE_CLASS_NUMBER;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example #29
Source Project: Huochexing12306   Author: SShineTeam   File: RegisterActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void setPwdVisible(boolean b) {
	if (!b){
		ivEye.setBackgroundResource(R.drawable.eye_close);
		ivEye.setTag(false);
		etPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
	}else{
		ivEye.setBackgroundResource(R.drawable.eye_open);
		ivEye.setTag(true);
		etPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
	}
	etPwd.invalidate();
}
 
Example #30
Source Project: AppLocker   Author: balrampandey19   File: LockActivity.java    License: Apache License 2.0 5 votes vote down vote up
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}