本文整理汇总了Java中android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD属性的典型用法代码示例。如果您正苦于以下问题:Java InputType.TYPE_TEXT_VARIATION_PASSWORD属性的具体用法?Java InputType.TYPE_TEXT_VARIATION_PASSWORD怎么用?Java InputType.TYPE_TEXT_VARIATION_PASSWORD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.InputType
的用法示例。
在下文中一共展示了InputType.TYPE_TEXT_VARIATION_PASSWORD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
private int getType(EditType editType) {
int type;
switch (editType) {
case phone:
type = InputType.TYPE_CLASS_PHONE;
break;
case number:
type = InputType.TYPE_CLASS_NUMBER;
break;
case numberDecimal:
type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL;
break;
case textPassword:
type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
break;
case numberPassword:
type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
break;
default:
type = InputType.TYPE_CLASS_TEXT;
}
return type;
}
示例2: init
private void init(Context context) {
mBitmap_clear = createBitmap(ConfigUtils.CLEAR_BUTTON_RES, context);
mBitmap_visible = createBitmap(ConfigUtils.VISIBLE_BUTTON_RES, context);
mBitmap_invisible = createBitmap(ConfigUtils.INVISIBLE_BUTTON_RES, context);
mInterval = getResources().getDimensionPixelSize(R.dimen.btn_in_edittext_interval);
mBtnWidth = getResources().getDimensionPixelSize(R.dimen.btn_in_edittext_width);
mPaddingRight = mInterval * 4 + mBtnWidth * 2;
mGoneAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(ANIMATOR_TIME);
mVisibleAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_TIME);
isPassword =
getInputType() == (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);
Log.d(TAG, "init: isPassword = "+isPassword+", type = "+getInputType());
}
示例3: setInputType
@Override
public void setInputType(int type) {
if (type == -1) {
type = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD;
}
if (type == InputType.TYPE_CLASS_NUMBER ||
type == InputType.TYPE_NUMBER_FLAG_SIGNED ||
type == InputType.TYPE_NUMBER_FLAG_DECIMAL ||
type == InputType.TYPE_CLASS_PHONE) {
final String symbolExceptions = getSymbolExceptions();
this.setKeyListener(DigitsKeyListener.getInstance("0123456789." + symbolExceptions));
} else {
super.setInputType(type);
}
}
示例4: onSelectionChanged
@Override
protected void onSelectionChanged(int selStart, int selEnd) {
super.onSelectionChanged(selStart, selEnd);
if (getLayout() == null)
return;
String line = getText().subSequence(getLayout().getLineStart(getLayout()
.getLineForOffset(selStart)), selEnd).toString();
boolean isPassword = getPasswordStart(line) != -1;
boolean wasPassword = (getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0;
if (isPassword && !wasPassword) {
Typeface tf = getTypeface();
setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE |
InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
setTypeface(tf);
setSelection(selStart, selEnd);
} else if (!isPassword && wasPassword) {
createPasswordSpans();
setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
}
}
示例5: setupInputDialog
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;
}
}
示例6: getInputType
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;
}
示例7: getInputType
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;
}
示例8: togglePasswordVisibility
private void togglePasswordVisibility(boolean showPassword) {
int inputType;
if (showPassword) {
inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
} else {
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
}
passwordBox.setInputType(inputType);
}
示例9: checkPasswordType
private static void checkPasswordType(ReactEditText view) {
if ((view.getStagedInputType() & INPUT_TYPE_KEYBOARD_NUMBERED) != 0 &&
(view.getStagedInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0) {
// Text input type is numbered password, remove text password variation, add numeric one
updateStagedInputTypeFlag(
view,
InputType.TYPE_TEXT_VARIATION_PASSWORD,
InputType.TYPE_NUMBER_VARIATION_PASSWORD);
}
}
示例10: toTextVariationString
private static String toTextVariationString(final int variation) {
switch (variation) {
case InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
return " TYPE_TEXT_VARIATION_EMAIL_ADDRESS";
case InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT:
return "TYPE_TEXT_VARIATION_EMAIL_SUBJECT";
case InputType.TYPE_TEXT_VARIATION_FILTER:
return "TYPE_TEXT_VARIATION_FILTER";
case InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE:
return "TYPE_TEXT_VARIATION_LONG_MESSAGE";
case InputType.TYPE_TEXT_VARIATION_NORMAL:
return "TYPE_TEXT_VARIATION_NORMAL";
case InputType.TYPE_TEXT_VARIATION_PASSWORD:
return "TYPE_TEXT_VARIATION_PASSWORD";
case InputType.TYPE_TEXT_VARIATION_PERSON_NAME:
return "TYPE_TEXT_VARIATION_PERSON_NAME";
case InputType.TYPE_TEXT_VARIATION_PHONETIC:
return "TYPE_TEXT_VARIATION_PHONETIC";
case InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS:
return "TYPE_TEXT_VARIATION_POSTAL_ADDRESS";
case InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE:
return "TYPE_TEXT_VARIATION_SHORT_MESSAGE";
case InputType.TYPE_TEXT_VARIATION_URI:
return "TYPE_TEXT_VARIATION_URI";
case InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD:
return "TYPE_TEXT_VARIATION_VISIBLE_PASSWORD";
case InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT:
return "TYPE_TEXT_VARIATION_WEB_EDIT_TEXT";
case InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS:
return "TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS";
case InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD:
return "TYPE_TEXT_VARIATION_WEB_PASSWORD";
default:
return String.format("unknownVariation<0x%08x>", variation);
}
}
示例11: toggleVisibility
@OnClick(R.id.copy_btn_toggle_visible)
public void toggleVisibility() {
switch (text.getInputType()) {
case InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD:
text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
toggle.setImageDrawable(getResources().getDrawable(R.drawable.ic_eye_off_grey));
break;
case InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD:
text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
toggle.setImageDrawable(getResources().getDrawable(R.drawable.ic_eye_grey));
break;
}
}
示例12: getInputType
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;
default:
inputType = InputType.TYPE_CLASS_TEXT;
}
return inputType;
}
示例13: setAuthType
/**
* 设置验证类型
*
* @param authType {@link AuthType}
*/
public void setAuthType(AuthType authType)
{
if(this.authType == authType)
{
return;
}
/**
* 在 {@link #authType} 值被改变之前,判断是不是需要清空文本.
*/
boolean needClearText = needClearText(authType);
this.authType = authType;
int inputType = InputType.TYPE_CLASS_NUMBER;
switch(this.authType)
{
case NUMBER:
inputType = InputType.TYPE_CLASS_NUMBER;
break;
case PASSWORD:
inputType = InputType.TYPE_TEXT_VARIATION_PASSWORD;
break;
case VISIBLE_PASSWORD:
inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
break;
case NUMBER_PASSWORD:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
inputType = InputType.TYPE_NUMBER_VARIATION_PASSWORD;
}
break;
case DEFAULT:
/**
* 这里的 InputType 不设置为 {@link InputType.TYPE_NULL},是因为设置这个后,
* {@link AuthEditText} 的点击事件失效
*/
inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
break;
}
etInput.setInputType(inputType);
if(needClearText)
{
clearText();
}
/**
* 输入类型变化时,需要手动更改文本。直接调用 {@link TextView#setInputType(int)} 没有作用.
*/
for(int i = 0; i < list.size(); i++)
{
if(string.length() > i)
{
fillTextByIndex(i);
}
}
}
示例14: init
private void init(Context context, AttributeSet attrs) {
//抗锯齿和位图滤波
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
//读取xml文件中的配置
if (attrs != null) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PowerfulEditText);
for (int i = 0; i < array.getIndexCount(); i++) {
int attr = array.getIndex(i);
switch (attr) {
case R.styleable.PowerfulEditText_clearDrawable:
mClearResId = array.getResourceId(attr, DEFAULT_CLEAR_RES);
break;
case R.styleable.PowerfulEditText_visibleDrawable:
mVisibleResId = array.getResourceId(attr, DEFAULT_VISIBLE_RES);
break;
case R.styleable.PowerfulEditText_invisibleDrawable:
mInvisibleResId = array.getResourceId(attr, DEFAULT_INVISIBLE_RES);
break;
case R.styleable.PowerfulEditText_BtnWidth:
mBtnWidth = array.getDimensionPixelSize(attr, DEFAULT_BUTTON_WIDTH);
break;
case R.styleable.PowerfulEditText_BtnSpacing:
mBtnPadding = array.getDimensionPixelSize(attr, DEFAULT_BUTTON_PADDING);
break;
case R.styleable.PowerfulEditText_borderStyle:
mBorderStyle = array.getString(attr);
break;
case R.styleable.PowerfulEditText_styleColor:
mStyleColor = array.getColor(attr, DEFAULT_STYLE_COLOR);
break;
}
}
array.recycle();
}
//初始化按钮显示的Bitmap
mBitmapClear = createBitmap(context, mClearResId, DEFAULT_CLEAR_RES);
mBitmapVisible = createBitmap(context, mVisibleResId, DEFAULT_VISIBLE_RES);
mBitmapInvisible = createBitmap(context, mInvisibleResId, DEFAULT_INVISIBLE_RES);
//如果自定义,则使用自定义的值,否则使用默认值
if (mBtnPadding == 0) {
mBtnPadding = DEFAULT_BUTTON_PADDING;
}
if (mBtnWidth == 0) {
mBtnWidth = DEFAULT_BUTTON_WIDTH;
}
//给文字设置一个padding,避免文字和按钮重叠了
mTextPaddingRight = mBtnPadding * 4 + mBtnWidth * 2;
//按钮出现和消失的动画
mGoneAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(ANIMATOR_TIME);
mVisibleAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_TIME);
//是否是密码样式
isPassword =
getInputType() == (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);
}
示例15: onStartInput
/**
* This is the main point where we do our initialization of the input method
* to begin operating on an application. At this point we have been
* bound to the client, and are now receiving all of the detailed information
* about the target of our edits.
*/
@Override public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
// Reset our state. We want to do this even if restarting, because
// the underlying state of the text editor could have changed in any way.
mComposing.setLength(0);
updateCandidates();
mPredictionOn = false;
mCompletionOn = false;
mCompletions = null;
// We are now going to initialize our state based on the type of
// text being edited.
switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
case InputType.TYPE_CLASS_NUMBER:
case InputType.TYPE_CLASS_DATETIME:
// Numbers and dates default to the symbols keyboard, with
// no extra features.
mCurKeyboard = mSymbolsKeyboard;
break;
case InputType.TYPE_CLASS_PHONE:
// Phones will also default to the symbols keyboard, though
// often you will want to have a dedicated phone keyboard.
mCurKeyboard = mSymbolsKeyboard;
break;
case InputType.TYPE_CLASS_TEXT:
// This is general text editing. We will default to the
// normal alphabetic keyboard, and assume that we should
// be doing predictive text (showing candidates as the
// user types).
mCurKeyboard = mArabicKeyboard;
mPredictionOn = true;
// We now look for a few special variations of text that will
// modify our behavior.
int variation = attribute.inputType & InputType.TYPE_MASK_VARIATION;
if (variation == InputType.TYPE_TEXT_VARIATION_PASSWORD ||
variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) {
// Do not display predictions / what the user is typing
// when they are entering a password.
mPredictionOn = false;
}
if (variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|| variation == InputType.TYPE_TEXT_VARIATION_URI
|| variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
// Our predictions are not useful for e-mail addresses
// or URIs.
mPredictionOn = false;
}
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
// If this is an auto-complete text view, then our predictions
// will not be shown and instead we will allow the editor
// to supply their own. We only show the editor's
// candidates when in fullscreen mode, otherwise relying
// own it displaying its own UI.
mPredictionOn = false;
mCompletionOn = isFullscreenMode();
}
break;
default:
// For all unknown input types, default to the alphabetic
// keyboard with no special features.
mCurKeyboard = mArabicKeyboard;
}
// Update the label on the enter key, depending on what the application
// says it will do.
mCurKeyboard.setImeOptions(this, attribute.imeOptions);
}