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 File: PasswordTextBox.java    From appinventor-extensions with 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 #2
Source File: MainActivity.java    From AutoAP with 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 #3
Source File: DetailFragment.java    From Passbook with 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 #4
Source File: EditTextUtils.java    From DevUtils with 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 #5
Source File: RegisterActivity.java    From Android-SDK with 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 #6
Source File: PasswordEditText.java    From AndroidUI with 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 #7
Source File: LoginActivity.java    From A-week-to-develop-android-app-plan with 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 #8
Source File: InputView.java    From alpha-wallet-android with 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 #9
Source File: LoginActivity.java    From A-week-to-develop-android-app-plan with 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 #10
Source File: PasscodeActivity.java    From Telegram-FOSS with 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 #11
Source File: Views.java    From Android-Shortify with 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 #12
Source File: LoginActivity.java    From letv with 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 #13
Source File: PinTextInputLayout.java    From africastalking-android with 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 #14
Source File: PinTextInputLayout.java    From Luhn with 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 #15
Source File: TextInputLayoutIconsTest.java    From material-components-android with 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 #16
Source File: DecimalWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void setTextInputType(EditText mAnswer) {
    if (secret) {
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
        mAnswer.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
}
 
Example #17
Source File: PasswordShow.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private void passwordHiddenState() {
    isPasswordVisible = false;
    showPasswordButton.setVisibility(View.VISIBLE);
    showPasswordButton.setText(showText);
    passwordField.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordField.setSelection(passwordField.getText().length());
}
 
Example #18
Source File: PinViewBaseHelper.java    From PinView with Apache License 2.0 5 votes vote down vote up
/**
 * Set a PinBox with all attributes
 *
 * @param editText to set attributes
 */
private void setStylePinBox(EditText editText) {
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)});

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

    if (mNativePinBox) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            //noinspection deprecation
            editText.setBackgroundDrawable(new EditText(getContext()).getBackground());
        } else {
            editText.setBackground(new EditText(getContext()).getBackground());
        }
    } else {
        editText.setBackgroundResource(mCustomDrawablePinBox);
    }

    if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) {
        editText.setTextColor(mColorTextPinBoxes);
    }
    editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes));
}
 
Example #19
Source File: PasswordEditText.java    From AndroidUI with MIT License 5 votes vote down vote up
private void init(Context context) {
    setSingleLine();
    //设置EditText文本为隐藏的(注意!需要在setSingleLine()之后调用)
    setTransformationMethod(PasswordTransformationMethod.getInstance());

    mWidth = getmWidth_clear();
    Interval = getInterval();
    addRight(mWidth+Interval);
    mBitmap_invisible = createBitmap(INVISIBLE,context);
    mBitmap_visible = createBitmap(VISIBLE,context);

}
 
Example #20
Source File: PasswordToggleEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onEndIconChanged(@NonNull TextInputLayout textInputLayout, int previousIcon) {
  EditText editText = textInputLayout.getEditText();
  if (editText != null && previousIcon == TextInputLayout.END_ICON_PASSWORD_TOGGLE) {
    // If the end icon was the password toggle add it back the PasswordTransformation
    // in case it might have been removed to make the password visible.
    editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    // Remove any listeners set on the edit text.
    editText.removeTextChangedListener(textWatcher);
  }
}
 
Example #21
Source File: FormEditPasswordFieldCell.java    From QMBForm with MIT License 5 votes vote down vote up
@Override
protected void init() {
    super.init();

    EditText editView = getEditView();
    editView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
    editView.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example #22
Source File: IntegerWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void setTextInputType(EditText mAnswer) {
    if (secret) {
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
        mAnswer.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
}
 
Example #23
Source File: TextInputLayoutIconsTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private static ViewAssertion isPasswordToggledVisible(final boolean isToggledVisible) {
  return (view, noViewFoundException) -> {
    assertTrue(view instanceof TextInputLayout);
    EditText editText = ((TextInputLayout) view).getEditText();
    TransformationMethod transformationMethod = editText.getTransformationMethod();
    if (isToggledVisible) {
      assertNull(transformationMethod);
    } else {
      assertEquals(PasswordTransformationMethod.getInstance(), transformationMethod);
    }
  };
}
 
Example #24
Source File: StringWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
protected void setTextInputType(EditText mAnswer) {
    if (secret) {
        mAnswer.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        mAnswer.setTransformationMethod(PasswordTransformationMethod.getInstance());
    } else {
        mAnswer.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
    }
}
 
Example #25
Source File: Settings.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Sets the default values for the the preferences
 */
private void initPreferences() {

    // Health worker username for OpenMRS
    EditTextPreference prefEmrUsername = (EditTextPreference) findPreference(Constants.PREFERENCE_EMR_USERNAME);
    if (TextUtils.isEmpty(prefEmrUsername.getText())) {
        prefEmrUsername.setText(Constants.DEFAULT_USERNAME);
    }

    // Health worker password for OpenMRS
    EditTextPreference prefEmrPassword = (EditTextPreference) findPreference(Constants.PREFERENCE_EMR_PASSWORD);
    prefEmrPassword.getEditText().setTransformationMethod(
            new PasswordTransformationMethod());
    if (TextUtils.isEmpty(prefEmrPassword.getText())) {
        prefEmrPassword.setText(Constants.DEFAULT_PASSWORD);
    }

    // Whether barcode reading is enabled on the phone
    /*
     * CheckBoxPreference barcodeEnabled = new CheckBoxPreference(this);
     * barcodeEnabled.setKey(Constants.PREFERENCE_BARCODE_ENABLED);
     * barcodeEnabled.setTitle("Enable barcode reading");
     * barcodeEnabled.setSummary
     * ("Enable barcode reading of patient and physician ids");
     * barcodeEnabled.setDefaultValue(false);
     * dialogBasedPrefCat.addPreference(barcodeEnabled);
     */

    // Launches network preferences
    PreferenceScreen prefNetwork = (PreferenceScreen) findPreference("s_network_settings");
    if (prefNetwork != null) {
        prefNetwork.setIntent(new Intent(this, NetworkSettings.class));
    }

    // Launches resource preferences
    PreferenceScreen prefResource = (PreferenceScreen) findPreference("s_resource_settings");
    if (prefResource != null) {
        prefResource.setIntent(new Intent(this, ResourceSettings.class));
    }
}
 
Example #26
Source File: PayPwdEditText.java    From PayPwdEditText with Apache License 2.0 5 votes vote down vote up
/**
 * 是否显示明文
 * @param showPwd
 */
public void setShowPwd(boolean showPwd) {
    int length = textViews.length;
    for(int i = 0; i < length; i++) {
        if (showPwd) {
            textViews[i].setTransformationMethod(PasswordTransformationMethod.getInstance());
        } else {
            textViews[i].setTransformationMethod(HideReturnsTransformationMethod.getInstance());
        }
    }
}
 
Example #27
Source File: WXInput.java    From weex with Apache License 2.0 5 votes vote down vote up
private int getInputType(String type) {
  int inputType;
  switch (type) {
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_DATE:
      inputType = InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_TIME:
      inputType = InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example #28
Source File: ManagerUserServices.java    From logmein-android with 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 #29
Source File: DialogInit.java    From talk-android with MIT License 5 votes vote down vote up
private static void setupInputDialog(final TalkDialog dialog) {
    final TalkDialog.Builder builder = dialog.mBuilder;
    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.mBuilder.widgetColor);

    if (builder.inputType != -1) {
        dialog.input.setInputType(builder.inputType);
        if ((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.minMax);
    if (builder.inputMaxLength > -1) {
        dialog.invalidateInputMinMaxIndicator(dialog.input.getText().toString().length(),
                !builder.inputAllowEmpty);
    } else {
        dialog.inputMinMax.setVisibility(View.GONE);
        dialog.inputMinMax = null;
    }
}
 
Example #30
Source File: PasswordEntry.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
/**
 * Want to monitor when password mode is set but #setTransformationMethod is final :( Instead
 * override #setText (which it calls through to) & check the transformation method.
 */
@Override
public void setText(CharSequence text, BufferType type) {
    super.setText(text, type);
    boolean isMasked = getTransformationMethod() instanceof PasswordTransformationMethod;
    if (isMasked != passwordMasked) {
        passwordMasked = isMasked;
        passwordVisibilityToggled(isMasked, text);
    }
}