Java Code Examples for android.text.method.PasswordTransformationMethod

The following are top voted examples for showing how to use android.text.method.PasswordTransformationMethod. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: wirtualnaApteczka   File: LogInActivity.java   Source Code and License 6 votes vote down vote up
private void initializeViewComponents() {
    logInGoogleBtn = (Button) findViewById(R.id.log_in_google_btn);
    logInDefaultBtn = (Button) findViewById(R.id.log_in_default_btn);
    registerBtn = (TextView) findViewById(R.id.register_btn);
    forgotPasswordBtn = (TextView) findViewById(R.id.forgot_password_btn);
    regulations = (TextView) findViewById(R.id.regulations_btn);

    emailText = (EditText) findViewById(R.id.email_login_text);
    emailText.setSelected(false);

    updateRememberedEmail();

    passwordText = (EditText) findViewById(R.id.password_login_text);
    passwordText.setTypeface(Typeface.DEFAULT);
    passwordText.setTransformationMethod(new PasswordTransformationMethod());
    passwordText.setSelected(false);
}
 
Example 2
Project: wirtualnaApteczka   File: RegistrationActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);

    registerRegulationsBtn = (TextView) findViewById(R.id.register_regulations_btn);
    registerRegulationsBtn.setOnClickListener(new RegulationsOnClickListener());

    registerNewUserBtn = (Button) findViewById(R.id.register_new_user_btn);
    registerNewUserBtn.setOnClickListener(new RegisterNewUserOnClickListener());

    passwordEditText = (EditText) findViewById(R.id.register_password_text);
    passwordEditText.setTypeface(Typeface.DEFAULT);
    passwordEditText.setTransformationMethod(new PasswordTransformationMethod());

    repeatPasswordEditText = (EditText) findViewById(R.id.register_password_repeat_text);
    repeatPasswordEditText.setTypeface(Typeface.DEFAULT);
    repeatPasswordEditText.setTransformationMethod(new PasswordTransformationMethod());
}
 
Example 3
Project: africastalking-android   File: PinTextInputLayout.java   Source Code and 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 4
Project: airgram   File: PasscodeActivity.java   Source Code and License 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 && UserConfig.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 && UserConfig.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 5
Project: letv   File: LoginActivity.java   Source Code and License 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 6
Project: CustomFormViews   File: CustomTextView.java   Source Code and License 6 votes vote down vote up
private void init(Context context, String hint, String text, int inputType, boolean editable,
        boolean password) {
    mHint = hint;
    View rootView = getView(context);
    ButterKnife.bind(this, rootView);
    txtHint.setText(hint);
    txtHintLayout.setVisibility(GONE);
    inputEditText.setHint(hint);
    inputEditText.setEnabled(editable);
    inputEditText.setText(text);
    if (password) {
        inputEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    } else {
        inputEditText.setInputType(inputType);
    }
}
 
Example 7
Project: cwac-crossport   File: TextInputLayout.java   Source Code and License 6 votes vote down vote up
/**
 * 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.</p>
 *
 * @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();
  }
}
 
Example 8
Project: cwac-crossport   File: TextInputLayout.java   Source Code and License 6 votes vote down vote up
private void passwordVisibilityToggleRequested(boolean shouldSkipAnimations) {
  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);
          if (shouldSkipAnimations) {
              mPasswordToggleView.jumpDrawablesToCurrentState();
          }

    // And restore the cursor position
    mEditText.setSelection(selection);
  }
}
 
Example 9
Project: Luhn   File: PinTextInputLayout.java   Source Code and 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 10
Project: PlusGram   File: PasscodeActivity.java   Source Code and License 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 && UserConfig.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 && UserConfig.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 11
Project: boohee_v5.6   File: PasscodeView.java   Source Code and License 6 votes vote down vote up
private void findView() {
    this.titleText = (TextView) findViewById(R.id.title);
    this.password1 = (EditText) findViewById(R.id.password1);
    this.password2 = (EditText) findViewById(R.id.password2);
    this.password3 = (EditText) findViewById(R.id.password3);
    this.password4 = (EditText) findViewById(R.id.password4);
    setFocusable(1);
    this.password1.setTransformationMethod(PasswordTransformationMethod.getInstance());
    this.password2.setTransformationMethod(PasswordTransformationMethod.getInstance());
    this.password3.setTransformationMethod(PasswordTransformationMethod.getInstance());
    this.password4.setTransformationMethod(PasswordTransformationMethod.getInstance());
    setTextChangeListener(this.password1, 2);
    setTextChangeListener(this.password2, 3);
    setTextChangeListener(this.password3, 4);
    setTextChangeListener(this.password4, 0);
}
 
Example 12
Project: okwallet   File: ShowPasswordCheckListener.java   Source Code and License 6 votes vote down vote up
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
    final TransformationMethod transformationMethod = isChecked ? null : PasswordTransformationMethod.getInstance();

    for (final EditText passwordView : passwordViews)
        passwordView.setTransformationMethod(transformationMethod);
}
 
Example 13
Project: appinventor-extensions   File: PasswordTextBox.java   Source Code and License 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()));

  // Disable auto-suggestion.
  view.setRawInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);

  // 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);

}
 
Example 14
Project: oversec_crypto   File: EditTextPasswordWithVisibilityToggle.java   Source Code and License 6 votes vote down vote up
private void updatePasswordVisibility() {

        if (mPasswordVisible) {
            setTransformationMethod(HideReturnsTransformationMethod.getInstance());
        } else {
            setTransformationMethod(PasswordTransformationMethod.getInstance());
        }


        Drawable drawable = ContextCompat.getDrawable(getContext(),R.drawable.ic_remove_red_eye_black_18dp);
        Drawable wrap = DrawableCompat.wrap(drawable);
        if (mPasswordVisible) {

            DrawableCompat.setTint(wrap, ContextCompat.getColor(getContext(), R.color.colorPrimary));
            DrawableCompat.setTintMode(wrap, PorterDuff.Mode.SRC_IN);
            wrap = wrap.mutate();
        } else {
            DrawableCompat.setTint(wrap, Color.BLACK);
            DrawableCompat.setTintMode(wrap, PorterDuff.Mode.SRC_IN);
            wrap = wrap.mutate();
        }
        setCompoundDrawablesWithIntrinsicBounds(null, null, wrap, null);
        setCompoundDrawablePadding(10);
    }
 
Example 15
Project: EncuentraloFacil-Android   File: LoginActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    String font_path = "font/FredokaOne-Regular.ttf";
    Typeface TF = Typeface.createFromAsset(getAssets(), font_path);
    TextView app_name1 = (TextView) findViewById(R.id.app_name1);
    app_name1.setTypeface(TF);
    TextView app_name2 = (TextView) findViewById(R.id.app_name2);
    app_name2.setTypeface(TF);
    TextView app_name3 = (TextView) findViewById(R.id.app_name3);
    app_name3.setTypeface(TF);

    input_user = (EditText) findViewById(R.id.input_user);
    input_password = (EditText) findViewById(R.id.input_password);
    input_password.setTypeface(Typeface.DEFAULT);
    input_password.setTransformationMethod(new PasswordTransformationMethod());

    RelativeLayout text_register = (RelativeLayout) findViewById(R.id.text_register);
    text_register.setOnClickListener(this);
    Button button_log_in = (Button) findViewById(R.id.button_log_in);
    button_log_in.setOnClickListener(this);
    Button button_log_in_facebook = (Button) findViewById(R.id.button_log_in_facebook);
    button_log_in_facebook.setOnClickListener(this);
}
 
Example 16
Project: LeanoteAndroid   File: RegisterActivity.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.img_pwd_visible)
public void pwdVisible() {
    if (mPwdVisible) {
        mPwdVisible = false;
        mEditUsername.setTransformationMethod(PasswordTransformationMethod.getInstance());
        mEditPasswordConfim.setTransformationMethod(PasswordTransformationMethod.getInstance());
        mImgPwdVisible.setImageResource(R.drawable.ic_login_not_show_pwd);
    } else {
        mPwdVisible = true;
        mEditUsername.setTransformationMethod(null);
        mEditPasswordConfim.setTransformationMethod(null);
        mImgPwdVisible.setImageResource(R.drawable.ic_login_show_pwd);
    }
    mEditPassword.setSelection(mEditPassword.length());
    mEditPasswordConfim.setSelection(mEditPasswordConfim.length());
}
 
Example 17
Project: RenewPass   File: IntroActivity.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.credential_slide, container, false);

    final EditText editText = (EditText) view.findViewById(R.id.password_field);

    CheckBox checkBox = (CheckBox) view.findViewById(R.id.password_checkbox);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                editText.setTransformationMethod(null);
            } else {
                editText.setTransformationMethod(new PasswordTransformationMethod());
            }
        }
    });

    return view;
}
 
Example 18
Project: RenewPass   File: PasswordPreference.java   Source Code and License 6 votes vote down vote up
private CheckBox makePasswordCheckbox(View view) {
    final EditText editText = getEditText();

    CheckBox checkBox = new CheckBox(view.getContext());
    checkBox.setText(R.string.checkbox_show_password);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                editText.setTransformationMethod(null);
            }
            else {
                editText.setTransformationMethod(new PasswordTransformationMethod());
            }
        }
    });
    return checkBox;
}
 
Example 19
Project: cocos2dx-explode-animation   File: Cocos2dxEditBox.java   Source Code and License 6 votes vote down vote up
public void setInputFlag(int inputFlag) {

        switch (inputFlag) {
            case kEditBoxInputFlagPassword:
                this.mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
                this.setTypeface(Typeface.DEFAULT);
                this.setTransformationMethod(new PasswordTransformationMethod());
                break;
            case kEditBoxInputFlagSensitive:
                this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
                break;
            case kEditBoxInputFlagInitialCapsWord:
                this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
                break;
            case kEditBoxInputFlagInitialCapsSentence:
                this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
                break;
            case kEditBoxInputFlagInitialCapsAllCharacters:
                this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
                break;
            default:
                break;
        }

        this.setInputType(this.mInputFlagConstraints | this.mInputModeConstraints);
    }
 
Example 20
Project: BufferTextInputLayout   File: BufferTextInputLayout.java   Source Code and License 6 votes vote down vote up
void passwordVisibilityToggleRequested() {
    if (passwordToggleEnabled) {
        // Store the current cursor position
        final int selection = editText.getSelectionEnd();
        if (hasPasswordTransformation()) {
            editText.setTransformationMethod(null);
            passwordToggledVisible = true;
        } else {
            editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
            passwordToggledVisible = false;
        }
        passwordToggleView.setChecked(passwordToggledVisible);
        // And restore the cursor position
        editText.setSelection(selection);
    }
}
 
Example 21
Project: Eulen   File: login.java   Source Code and License 6 votes vote down vote up
private void clearForm() {
    EditText editTextPassphrase = (EditText) findViewById(R.id.editTextPassphraseLogin);
    EditText editTextPin = (EditText) findViewById(R.id.editTextPinLogin);
    CheckBox checkRemember = (CheckBox) findViewById(R.id.checkRemember);

    savedPassphrase = null;
    NFCResult = null;
    prefs.edit().remove(CONST.PREFS_PASSPHRASE).apply();
    checkRemember.setChecked(false);
    checkRemember.setEnabled(true);
    editTextPassphrase.setText(null);
    editTextPassphrase.setEnabled(true);
    editTextPin.setText(null);
    editTextPassphrase.setTransformationMethod(new PasswordTransformationMethod());
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    editTextPin.clearFocus();
    editTextPassphrase.clearFocus();
    enableGUI();
}
 
Example 22
Project: material-components-android   File: TextInputLayout.java   Source Code and License 6 votes vote down vote up
/**
 * 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 (passwordToggleEnabled != enabled) {
    passwordToggleEnabled = enabled;

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

    // Reset the visibility tracking flag
    passwordToggledVisible = false;

    updatePasswordToggleView();
  }
}
 
Example 23
Project: material-components-android   File: TextInputLayout.java   Source Code and License 6 votes vote down vote up
private void passwordVisibilityToggleRequested(boolean shouldSkipAnimations) {
  if (passwordToggleEnabled) {
    // Store the current cursor position
    final int selection = editText.getSelectionEnd();

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

    passwordToggleView.setChecked(passwordToggledVisible);
    if (shouldSkipAnimations) {
      passwordToggleView.jumpDrawablesToCurrentState();
    }

    // And restore the cursor position
    editText.setSelection(selection);
  }
}
 
Example 24
Project: LoginRegisterFramework   File: LoginActivity.java   Source Code and License 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 25
Project: MartialStudySelf   File: RegisterActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.register_see:
            if (!isChecked) {
                password.setTransformationMethod(new PasswordTransformationMethod());
            }else {
                password.setTransformationMethod(null);
            }
            break;
        case R.id.register_see_see:
            if (!isChecked) {
                passwordConfirm.setTransformationMethod(new PasswordTransformationMethod());
            }else {
                passwordConfirm.setTransformationMethod(null);
            }
            break;
    }
}
 
Example 26
Project: Android-Shortify   File: Views.java   Source Code and License 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 27
Project: A-week-to-develop-android-app-plan   File: LoginActivity.java   Source Code and License 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 28
Project: A-week-to-develop-android-app-plan   File: LoginActivity.java   Source Code and License 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 29
Project: wordpress_app_android   File: AbstractFragment.java   Source Code and License 6 votes vote down vote up
protected void initPasswordVisibilityButton(View rootView, final EditText passwordEditText) {
    final ImageView passwordVisibility = (ImageView) rootView.findViewById(R.id.password_visibility);
    if (passwordVisibility == null) {
        return;
    }
    passwordVisibility.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPasswordVisible = !mPasswordVisible;
            if (mPasswordVisible) {
                passwordVisibility.setImageResource(R.drawable.dashicon_eye_open);
                passwordVisibility.setColorFilter(v.getContext().getResources().getColor(R.color.nux_eye_icon_color_open));
                passwordEditText.setTransformationMethod(null);
            } else {
                passwordVisibility.setImageResource(R.drawable.dashicon_eye_closed);
                passwordVisibility.setColorFilter(v.getContext().getResources().getColor(R.color.nux_eye_icon_color_closed));
                passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
            }
            passwordEditText.setSelection(passwordEditText.length());
        }
    });
}
 
Example 30
Project: AndroidUI   File: PasswordEditText.java   Source Code and 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 31
Project: AMPASIDE   File: AndroidTextFieldUI.java   Source Code and License 6 votes vote down vote up
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);
               }
		}
	});
}
 
Example 32
Project: mc_backup   File: FxAccountAbstractSetupActivity.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 33
Project: TimberdoodleApp   File: PasswordDialog.java   Source Code and License 6 votes vote down vote up
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));
}
 
Example 34
Project: Passbook   File: DetailFragment.java   Source Code and License 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 35
Project: iosched   File: TextInputLayout.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
  }
}
 
Example 36
Project: iosched   File: TextInputLayout.java   Source Code and License 6 votes vote down vote up
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);
  }
}
 
Example 37
Project: Nepenthes-Android   File: PasswordEdt.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 38
Project: AutoAP   File: MainActivity.java   Source Code and License 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 39
Project: GomeOnline   File: Regist3Activity.java   Source Code and License 6 votes vote down vote up
@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);
				}
			}
		});
	}
 
Example 40
Project: prey-android-client-master   File: PasswordActivity.java   Source Code and License 6 votes vote down vote up
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());
}
 
Example 41
Project: transdroid   File: KeyBoundPreferencesActivity.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("deprecation")
protected void showValueOnSummary(String prefKey) {
	Preference pref = findPreference(prefKey);
	if (sharedPrefs.contains(prefKey)
			&& pref instanceof EditTextPreference
			&& !TextUtils.isEmpty(sharedPrefs.getString(prefKey, ""))
			&& !(((EditTextPreference) pref).getEditText().getTransformationMethod() instanceof PasswordTransformationMethod)) {
		// Non-password edit preferences show the user-entered value
		pref.setSummary(sharedPrefs.getString(prefKey, ""));
		return;
	} else if (sharedPrefs.contains(prefKey) && pref instanceof ListPreference
			&& ((ListPreference) pref).getValue() != null) {
		// List preferences show the selected list value
		ListPreference listPreference = (ListPreference) pref;
		pref.setSummary(listPreference.getEntries()[listPreference.findIndexOfValue(listPreference.getValue())]);
		return;
	}
	if (originalSummaries.containsKey(prefKey))
		pref.setSummary(originalSummaries.get(prefKey));
}
 
Example 42
Project: open-note   File: SignUpFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	mRootView = inflater.inflate(R.layout.fragment_signup, container, false);

	Button button = (Button) mRootView.findViewById(R.id.signUpBt);
	CheckBox checkBox = (CheckBox) mRootView.findViewById(R.id.passUpChBx);
	
	button.setOnClickListener(new SignUpAction());
	checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			EditText passEdit = (EditText) mRootView.findViewById(R.id.passUpEdit);
			if (isChecked) {
				passEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
				passEdit.setTypeface( Typeface.SANS_SERIF );
			} else {
				passEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
			}
		}
	});

	return mRootView;
}
 
Example 43
Project: open-note   File: SignInFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	mRootView = inflater.inflate(R.layout.fragment_signin, container, false);
	
	Button button = (Button) mRootView.findViewById(R.id.signInBt);
	CheckBox checkBox = (CheckBox) mRootView.findViewById(R.id.passInChBx);
	// Add onClick listener
	button.setOnClickListener(new SignInAction());
	checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			EditText passEdit = (EditText) mRootView.findViewById(R.id.passInEdit);
			if (isChecked) {
				passEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
				passEdit.setTypeface( Typeface.SANS_SERIF );
			} else {
				passEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
			}
		}
	});
	
	return mRootView;
}
 
Example 44
Project: Telegram   File: PasscodeActivity.java   Source Code and License 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 && UserConfig.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 && UserConfig.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 45
Project: BombusMod   File: AndroidTextFieldUI.java   Source Code and License 6 votes vote down vote up
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);
               }
               if ((constraints & TextField.INITIAL_CAPS_SENTENCE) != 0) {
                   editView.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
               }
		}
	});
}
 
Example 46
Project: Mizuu   File: AddNetworkFilesourceDialog.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

	setContentView(R.layout.addnetwork);

	server = (EditText) findViewById(R.id.server);
	domain = (EditText) findViewById(R.id.domain);
	username = (EditText) findViewById(R.id.username);
	password  = (EditText) findViewById(R.id.password);
	password.setTypeface(Typeface.DEFAULT);
	password.setTransformationMethod(new PasswordTransformationMethod());
	anonymous = (CheckBox) findViewById(R.id.checkBox);
	guest = (CheckBox) findViewById(R.id.checkBox2);

	guest.setOnCheckedChangeListener(changeListener);
	anonymous.setOnCheckedChangeListener(changeListener);

	isMovie = getIntent().getExtras().getString("type").equals("movie");

	LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("mizuu-network-search"));
}
 
Example 47
Project: GitHub   File: DialogInit.java   Source Code and License 5 votes vote down vote up
private static void setupInputDialog(final MaterialDialog dialog) {
    final MaterialDialog.Builder builder = dialog.builder;
    dialog.input = (EditText) dialog.view.findViewById(android.R.id.input);
    if (dialog.input == null) return;
    dialog.setTypeface(dialog.input, builder.regularFont);
    if (builder.inputPrefill != null)
        dialog.input.setText(builder.inputPrefill);
    dialog.setInternalInputCallback();
    dialog.input.setHint(builder.inputHint);
    dialog.input.setSingleLine();
    dialog.input.setTextColor(builder.contentColor);
    dialog.input.setHintTextColor(DialogUtils.adjustAlpha(builder.contentColor, 0.3f));
    MDTintHelper.setTint(dialog.input, dialog.builder.widgetColor);

    if (builder.inputType != -1) {
        dialog.input.setInputType(builder.inputType);
        if (builder.inputType != InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD &&
                (builder.inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD) {
            // If the flags contain TYPE_TEXT_VARIATION_PASSWORD, apply the password transformation method automatically
            dialog.input.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
    }

    dialog.inputMinMax = (TextView) dialog.view.findViewById(R.id.md_minMax);
    if (builder.inputMinLength > 0 || builder.inputMaxLength > -1) {
        dialog.invalidateInputMinMaxIndicator(dialog.input.getText().toString().length(),
                !builder.inputAllowEmpty);
    } else {
        dialog.inputMinMax.setVisibility(View.GONE);
        dialog.inputMinMax = null;
    }
}
 
Example 48
Project: airgram   File: PasscodeView.java   Source Code and License 5 votes vote down vote up
public void onShow() {
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        if (passwordEditText != null) {
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }
    } else {
        if (parentActivity != null) {
            View currentFocus = parentActivity.getCurrentFocus();
            if (currentFocus != null) {
                currentFocus.clearFocus();
                AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
            }
        }
    }
    checkFingerprint();
    if (getVisibility() == View.VISIBLE) {
        return;
    }
    setAlpha(1.0f);
    setTranslationY(0);
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
    int selectedBackground = preferences.getInt("selectedBackground", 1000001);
    if (selectedBackground == 1000001) {
        backgroundFrameLayout.setBackgroundColor(0xff517c9e);
    } else {
        backgroundDrawable = ApplicationLoader.getCachedWallpaper();
        if (backgroundDrawable != null) {
            backgroundFrameLayout.setBackgroundColor(0xbf000000);
        } else {
            backgroundFrameLayout.setBackgroundColor(0xff517c9e);
        }
    }

    passcodeTextView.setText(LocaleController.getString("EnterYourPasscode", R.string.EnterYourPasscode));

    if (UserConfig.passcodeType == 0) {
        //InputFilter[] filterArray = new InputFilter[1];
        //filterArray[0] = new InputFilter.LengthFilter(4);
        //passwordEditText.setFilters(filterArray);
        //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        //passwordEditText.setFocusable(false);
        //passwordEditText.setFocusableInTouchMode(false);
        numbersFrameLayout.setVisibility(VISIBLE);
        passwordEditText.setVisibility(GONE);
        passwordEditText2.setVisibility(VISIBLE);
        checkImage.setVisibility(GONE);
    } else if (UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        numbersFrameLayout.setVisibility(GONE);
        passwordEditText.setFocusable(true);
        passwordEditText.setFocusableInTouchMode(true);
        passwordEditText.setVisibility(VISIBLE);
        passwordEditText2.setVisibility(GONE);
        checkImage.setVisibility(VISIBLE);
    }
    setVisibility(VISIBLE);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setText("");
    passwordEditText2.eraseAllCharacters(false);

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}
 
Example 49
Project: MultiFuncViewLibrary   File: MultiFuncEditText.java   Source Code and License 5 votes vote down vote up
/**
 * 因为我们不能直接给EditText设置点击事件,所以我们用记住我们按下的位置来模拟点击事件
 * 当我们按下的位置在 EditText的宽度 - 图标到控件右侧的间距 - 图标的宽度 和
 * EditText的宽度 - 图标到控件右侧的间距 之间我们就算点击了图标,竖直方向没有考虑
 * @param event
 * @return
 */
@Override
public boolean onTouchEvent(MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_UP){
        if(getCompoundDrawables()[2] != null){
            boolean isTouched = event.getX() > (getWidth() - getTotalPaddingRight())
                    && (event.getX() < (getWidth() - getPaddingLeft()));
            if(isTouched){
                if(mRightClickListener == null){
                    if(funcType == TYPE_CAN_CLEAR){
                        this.setText("");
                    }else if(funcType == TYPE_CAN_WATCH_PWD){
                        if(eyeOpen){
                            //变为密文,TYPE_CLASS_TEXT 和 TYPE_TEXT_VARIATION_PASSWORD 必须一起使用
                            this.setTransformationMethod(PasswordTransformationMethod.getInstance());
                            eyeOpen = false;
                        }else{
                            //变为明文
                            this.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                            eyeOpen = true;
                        }
                        switchWatchPwdIcon();
                    }
                }else {
                    //如果没有则回调
                    mRightClickListener.onClick(this);
                }
            }
        }
    }
    return super.onTouchEvent(event);
}
 
Example 50
Project: argus-android   File: EmailLoginProvider.java   Source Code and License 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 51
Project: weex-3d-map   File: AbstractEditComponent.java   Source Code and License 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_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE;
      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_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME;
      break;
    case Constants.Value.URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example 52
Project: ucar-weex-core   File: AbstractEditComponent.java   Source Code and License 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 53
Project: buildAPKsApps   File: AppLockActivity.java   Source Code and License 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());
}
 
Example 54
Project: Huochexing12306   File: RegisterActivity.java   Source Code and License 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 55
Project: encdroidMC   File: FileProviderActivity.java   Source Code and License 5 votes vote down vote up
private void showDialog(List<EncdroidProviderParameter> questions){
	
	if (questions==null || questions.size()==0) {
       	//if (activity instanceof Fillable){
       		try {
       			//this.init("/");*
       			finishFileProviderInit();
       		} catch (Exception e){
       			e.printStackTrace();
       			String exceptionLabel = e.getMessage();
       			if (exceptionLabel==null) exceptionLabel=e.toString();
       			Toast.makeText(this.getApplicationContext(),exceptionLabel, Toast.LENGTH_LONG).show();
       			//ask again parameters question to the user
       			if (instance.getParamsToAsk()!=null && instance.getParamsToAsk().size()>0){
       				this.showDialog( instance.getParamsToAsk());
       			}
       			return;
       		}
       	//}			
   		//this.ready=true;
  			//((Fillable)activity).launchFillTask();			
		return;
	}
	
    AlertDialog.Builder alert = new AlertDialog.Builder(this);                 
    alert.setTitle(questions.get(0).getTitle());  
    alert.setMessage(questions.get(0).getLabel());
     

     // Set an EditText view to get user input   
     final EditText input = new EditText(this);
     if (questions.get(0).isPassword()) {
    	 input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    	 input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); 
     }
     alert.setView(input);
        alert.setPositiveButton("Ok", new ClickListener(this,instance,input,questions));  
        alert.show();
}
 
Example 56
Project: encdroidMC   File: ConfigSyncActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_config_sync);
	

	
	volumeName = (EditText) findViewById(R.id.volumeName);
	//volumeName.setFocusable(false);
	
	volumePath = (EditText) findViewById(R.id.volumePath);
	//volumePath.setFocusable(false);
	
	password = (EditText) findViewById(R.id.volumePassword);
	password.setTransformationMethod(PasswordTransformationMethod.getInstance());
	password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); 
	
	onlyWifiCheckBox = ((CheckBox) findViewById(R.id.onlyWifi));
	removeAfterCheckBox = ((CheckBox) findViewById(R.id.removeAfter));
	localFolder = ((EditText) findViewById(R.id.localFolder));
	syncID = ((EditText) findViewById(R.id.syncID));
	syncID.setFocusable(false);
	
	
	spin1=(Spinner) findViewById(R.id.selectedRule);
	ArrayAdapter<String> adapter=new ArrayAdapter<String>(ConfigSyncActivity.this, android.R.layout.simple_spinner_item, rules);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spin1.setAdapter(adapter);
	spin1.setOnTouchListener(this);
	spin1.setOnItemSelectedListener((OnItemSelectedListener) this);
	
	refresh(null);

	
}
 
Example 57
Project: ChenYan   File: RegisterActivity.java   Source Code and License 5 votes vote down vote up
@OnClick(R.id.iv_pwd)
    public void showPwd() {
//        明文显示
        if (isShow) {
            etPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            ivPwd.setImageResource(R.drawable.ic_visibility_blue_500_24dp);
        } else {
//         密码显示
            etPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
            ivPwd.setImageResource(R.drawable.ic_visibility_off_grey_500_24dp);
        }
        isShow = !isShow;
    }
 
Example 58
Project: ChenYan   File: ForgetPwdActivity.java   Source Code and License 5 votes vote down vote up
@OnClick(R.id.iv_pwd)
    public void showPwd() {
//        明文显示
        if (isShow) {
            etPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            ivPwd.setImageResource(R.drawable.ic_visibility_blue_500_24dp);
        } else {
//         密码显示
            etPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
            ivPwd.setImageResource(R.drawable.ic_visibility_off_grey_500_24dp);
        }
        isShow = !isShow;
    }
 
Example 59
Project: ChenYan   File: LoginActivity.java   Source Code and License 5 votes vote down vote up
@OnClick(R.id.iv_pwd)
    public void showPwd() {
//        明文显示
        if (isShow) {
            etPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            ivPwd.setImageResource(R.drawable.ic_visibility_blue_500_24dp);
        } else {
//         密码显示
            etPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
            ivPwd.setImageResource(R.drawable.ic_visibility_off_grey_500_24dp);
        }
        isShow = !isShow;
    }
 
Example 60
Project: PlusGram   File: PasscodeView.java   Source Code and License 5 votes vote down vote up
public void onShow() {
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        if (passwordEditText != null) {
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }
    } else {
        if (parentActivity != null) {
            View currentFocus = parentActivity.getCurrentFocus();
            if (currentFocus != null) {
                currentFocus.clearFocus();
                AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
            }
        }
    }
    checkFingerprint();
    if (getVisibility() == View.VISIBLE) {
        return;
    }
    setAlpha(1.0f);
    setTranslationY(0);
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
    int selectedBackground = preferences.getInt("selectedBackground", 1000001);
    if (selectedBackground == 1000001) {
        backgroundFrameLayout.setBackgroundColor(0xff517c9e);
    } else {
        backgroundDrawable = ApplicationLoader.getCachedWallpaper();
        if (backgroundDrawable != null) {
            backgroundFrameLayout.setBackgroundColor(0xbf000000);
        } else {
            backgroundFrameLayout.setBackgroundColor(0xff517c9e);
        }
    }

    passcodeTextView.setText(LocaleController.getString("EnterYourPasscode", R.string.EnterYourPasscode));

    if (UserConfig.passcodeType == 0) {
        //InputFilter[] filterArray = new InputFilter[1];
        //filterArray[0] = new InputFilter.LengthFilter(4);
        //passwordEditText.setFilters(filterArray);
        //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        //passwordEditText.setFocusable(false);
        //passwordEditText.setFocusableInTouchMode(false);
        numbersFrameLayout.setVisibility(VISIBLE);
        passwordEditText.setVisibility(GONE);
        passwordEditText2.setVisibility(VISIBLE);
        checkImage.setVisibility(GONE);
    } else if (UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        numbersFrameLayout.setVisibility(GONE);
        passwordEditText.setFocusable(true);
        passwordEditText.setFocusableInTouchMode(true);
        passwordEditText.setVisibility(VISIBLE);
        passwordEditText2.setVisibility(GONE);
        checkImage.setVisibility(VISIBLE);
    }
    setVisibility(VISIBLE);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setText("");
    passwordEditText2.eraseAllCharacters(false);

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}