List of usage examples for android.text InputType TYPE_NUMBER_VARIATION_PASSWORD
int TYPE_NUMBER_VARIATION_PASSWORD
To view the source code for android.text InputType TYPE_NUMBER_VARIATION_PASSWORD.
Click Source Link
From source file:org.mitre.svmp.auth.module.SecurityTokenModule.java
public View generateUI(Context context) { // create the token input EditText input = new EditText(context); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); input.setHint("Security Token"); return input; }
From source file:com.alimuzaffar.lib.widgets.PinEntryEditText.java
private void init(Context context, AttributeSet attrs) { float multi = context.getResources().getDisplayMetrics().density; mLineStroke = multi * mLineStroke;/*from ww w . ja v a 2s . c o m*/ mLineStrokeSelected = multi * mLineStrokeSelected; mSpace = multi * mSpace; //convert to pixels for our density mTextBottomPadding = multi * mTextBottomPadding; //convert to pixels for our density TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PinEntryEditText, 0, 0); try { TypedValue outValue = new TypedValue(); ta.getValue(R.styleable.PinEntryEditText_pinAnimationType, outValue); mAnimatedType = outValue.data; mMask = ta.getString(R.styleable.PinEntryEditText_pinCharacterMask); mLineStroke = ta.getDimension(R.styleable.PinEntryEditText_pinLineStroke, mLineStroke); mLineStrokeSelected = ta.getDimension(R.styleable.PinEntryEditText_pinLineStrokeSelected, mLineStrokeSelected); mSpace = ta.getDimension(R.styleable.PinEntryEditText_pinCharacterSpacing, mSpace); mTextBottomPadding = ta.getDimension(R.styleable.PinEntryEditText_pinTextBottomPadding, mTextBottomPadding); mIsDigitSquare = ta.getBoolean(R.styleable.PinEntryEditText_pinBackgroundIsSquare, mIsDigitSquare); mPinBackground = ta.getDrawable(R.styleable.PinEntryEditText_pinBackgroundDrawable); ColorStateList colors = ta.getColorStateList(R.styleable.PinEntryEditText_pinLineColors); if (colors != null) { mColorStates = colors; } } finally { ta.recycle(); } mCharPaint = new Paint(getPaint()); mLastCharPaint = new Paint(getPaint()); mLinesPaint = new Paint(getPaint()); mLinesPaint.setStrokeWidth(mLineStroke); TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorControlActivated, outValue, true); int colorSelected = outValue.data; mColors[0] = colorSelected; int colorFocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal); mColors[1] = colorFocused; int colorUnfocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal); mColors[2] = colorUnfocused; setBackgroundResource(0); mMaxLength = attrs.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 4); mNumChars = mMaxLength; //Disable copy paste super.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); // When tapped, move cursor to end of text. super.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setSelection(getText().length()); if (mClickListener != null) { mClickListener.onClick(v); } } }); super.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { setSelection(getText().length()); return true; } }); //If input type is password and no mask is set, use a default mask if ((getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD && TextUtils.isEmpty(mMask)) { mMask = "\u25CF"; } else if ((getInputType() & InputType.TYPE_NUMBER_VARIATION_PASSWORD) == InputType.TYPE_NUMBER_VARIATION_PASSWORD && TextUtils.isEmpty(mMask)) { mMask = "\u25CF"; } if (!TextUtils.isEmpty(mMask)) { mMaskChars = getMaskChars(); } //Height of the characters, used if there is a background drawable getPaint().getTextBounds("|", 0, 1, mTextHeight); }
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void init(Context context, AttributeSet attrs) { float multi = context.getResources().getDisplayMetrics().density; mLineStroke = multi * mLineStroke;/*from w ww .jav a 2 s .c o m*/ mLineStrokeSelected = multi * mLineStrokeSelected; mSpace = multi * mSpace; //convert to pixels for our density mTextBottomPadding = multi * mTextBottomPadding; //convert to pixels for our density TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PinEntryEditText, 0, 0); try { TypedValue outValue = new TypedValue(); ta.getValue(R.styleable.PinEntryEditText_pinAnimationType, outValue); mAnimatedType = outValue.data; mMask = ta.getString(R.styleable.PinEntryEditText_pinCharacterMask); mSingleCharHint = ta.getString(R.styleable.PinEntryEditText_pinRepeatedHint); mLineStroke = ta.getDimension(R.styleable.PinEntryEditText_pinLineStroke, mLineStroke); mLineStrokeSelected = ta.getDimension(R.styleable.PinEntryEditText_pinLineStrokeSelected, mLineStrokeSelected); mSpace = ta.getDimension(R.styleable.PinEntryEditText_pinCharacterSpacing, mSpace); mTextBottomPadding = ta.getDimension(R.styleable.PinEntryEditText_pinTextBottomPadding, mTextBottomPadding); mIsDigitSquare = ta.getBoolean(R.styleable.PinEntryEditText_pinBackgroundIsSquare, mIsDigitSquare); mPinBackground = ta.getDrawable(R.styleable.PinEntryEditText_pinBackgroundDrawable); ColorStateList colors = ta.getColorStateList(R.styleable.PinEntryEditText_pinLineColors); if (colors != null) { mColorStates = colors; } } finally { ta.recycle(); } mCharPaint = new Paint(getPaint()); mLastCharPaint = new Paint(getPaint()); mSingleCharPaint = new Paint(getPaint()); mLinesPaint = new Paint(getPaint()); mLinesPaint.setStrokeWidth(mLineStroke); TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorControlActivated, outValue, true); int colorSelected = outValue.data; mColors[0] = colorSelected; int colorFocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal); mColors[1] = colorFocused; int colorUnfocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal); mColors[2] = colorUnfocused; setBackgroundResource(0); mMaxLength = attrs.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 4); mNumChars = mMaxLength; //Disable copy paste super.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); // When tapped, move cursor to end of text. super.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setSelection(getText().length()); if (mClickListener != null) { mClickListener.onClick(v); } } }); super.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { setSelection(getText().length()); return true; } }); //If input type is password and no mask is set, use a default mask if ((getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD && TextUtils.isEmpty(mMask)) { mMask = "\u25CF"; } else if ((getInputType() & InputType.TYPE_NUMBER_VARIATION_PASSWORD) == InputType.TYPE_NUMBER_VARIATION_PASSWORD && TextUtils.isEmpty(mMask)) { mMask = "\u25CF"; } if (!TextUtils.isEmpty(mMask)) { mMaskChars = getMaskChars(); } //Height of the characters, used if there is a background drawable getPaint().getTextBounds("|", 0, 1, mTextHeight); mAnimate = mAnimatedType > -1; }
From source file:com.mario22gmail.license.nfc_project.FragmentPinDialog.java
@Nullable @Override//from w ww.j a v a2s.co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_pin_dialog, container); getDialog().requestWindowFeature(STYLE_NO_TITLE); final EditText pinTextDialog = (EditText) view.findViewById(R.id.editTextPinDialog); final NavigationDrawerActivity mainActivity = (NavigationDrawerActivity) getActivity(); disableSoftInputFromAppearing(pinTextDialog); Button buttonEnter = (Button) view.findViewById(R.id.buttonEnterPinDialog); buttonEnter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String pinNumberText = pinTextDialog.getText().toString(); AuthResponse cardResponse = mainActivity.AuthenticateOnDesfire(pinNumberText); if (cardResponse.isValid()) { Toast.makeText(getContext(), "Autentificat", Toast.LENGTH_SHORT).show(); getDialog().dismiss(); Log.i("nfc_debug", "Card is valid"); Intent goToWebCredentialPage = new Intent("goToWebCredentialPage"); NavigationDrawerActivity.getAppContext().sendBroadcast(goToWebCredentialPage); } else { Toast.makeText(getDialog().getContext(), "Pin invalid", Toast.LENGTH_SHORT).show(); } } }); Button cancelDialog = (Button) view.findViewById(R.id.buttonPinDialogCancel); cancelDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getDialog().dismiss(); } }); Button buttonNumarul1 = (Button) view.findViewById(R.id.buttonNumarul1); buttonNumarul1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "1"); } }); Button buttonNumarul2 = (Button) view.findViewById(R.id.buttonNumarul2); buttonNumarul2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "2"); } }); Button buttonNumarul3 = (Button) view.findViewById(R.id.buttonNumarul3); buttonNumarul3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "3"); } }); Button buttonNumarul4 = (Button) view.findViewById(R.id.buttonNumarul4); buttonNumarul4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "4"); } }); Button buttonNumarul5 = (Button) view.findViewById(R.id.buttonNumarul5); buttonNumarul5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "5"); } }); Button buttonNumarul6 = (Button) view.findViewById(R.id.buttonNumarul6); buttonNumarul6.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "6"); } }); Button buttonNumarul7 = (Button) view.findViewById(R.id.buttonNumarul7); buttonNumarul7.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "7"); } }); Button buttonNumarul8 = (Button) view.findViewById(R.id.buttonNumarul8); buttonNumarul8.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "8"); } }); Button buttonNumarul9 = (Button) view.findViewById(R.id.buttonNumarul9); buttonNumarul9.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "9"); } }); Button buttonNumarul0 = (Button) view.findViewById(R.id.buttonNumarul0); buttonNumarul0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); pinTextDialog.getText().insert(position, "0"); } }); ImageButton buttonDeleteLastChar = (ImageButton) view.findViewById(R.id.buttonDeleteLastCharPinDialog); buttonDeleteLastChar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = pinTextDialog.getSelectionStart(); if (position > 0) { Log.i("nfc_debug", "pozitia e " + position); pinTextDialog.getText().delete(position - 1, position); } } }); final Button pinVisibility = (Button) view.findViewById(R.id.pinVisibility); pinTextDialog.setInputType(InputType.TYPE_CLASS_NUMBER); pinVisibility.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isPinVisible) { int position = pinTextDialog.getSelectionStart(); pinVisibility.setBackgroundResource(R.drawable.ic_visibility_black_24dp); pinTextDialog .setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); pinTextDialog.setTypeface(Typeface.DEFAULT); pinTextDialog.setSelection(position); isPinVisible = false; } else { int position = pinTextDialog.getSelectionStart(); pinVisibility.setBackgroundResource(R.drawable.ic_visibility_off_black_24dp); pinTextDialog.setInputType(InputType.TYPE_CLASS_NUMBER); pinTextDialog.setSelection(position); isPinVisible = true; } } }); return view; }
From source file:com.sigilance.CardEdit.MainActivity.java
private void promptForChangePin(final int mode) { AlertDialog.Builder builder = new AlertDialog.Builder(this); if (mode == 0x83) builder.setTitle(R.string.action_change_pw3); else/*from w w w . java2 s. c om*/ builder.setTitle(R.string.action_change_pw1); final String typeString = mode == 0x83 ? "Admin" : "User"; String defaultString = mode == 0x83 ? "12345678" : "123456"; builder.setMessage(String.format("REMINDER: The default %s PIN is %s", typeString, defaultString)); final EditText oldPinInput = new EditText(this); oldPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); oldPinInput.setHint(String.format("Old %s PIN", mode == 0x83 ? "Admin" : "User")); final EditText newPinInput = new EditText(this); newPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); newPinInput.setHint(String.format("New %s PIN", mode == 0x83 ? "Admin" : "User")); final EditText confirmPinInput = new EditText(this); confirmPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); confirmPinInput.setHint("Repeat New PIN"); LinearLayout fields = new LinearLayout(this); fields.setOrientation(LinearLayout.VERTICAL); fields.addView(oldPinInput); fields.addView(newPinInput); fields.addView(confirmPinInput); builder.setView(fields); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Placeholder; we will override this } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldPinInput.getText().toString().length() == 0 || newPinInput.getText().toString().length() == 0) { Toast.makeText(MainActivity.this, "Enter a PIN!", Toast.LENGTH_SHORT).show(); return; } if (!(confirmPinInput.getText().toString().equals(newPinInput.getText().toString()))) { newPinInput.setText(""); confirmPinInput.setText(""); Toast.makeText(MainActivity.this, "PINs did not match.", Toast.LENGTH_SHORT).show(); return; } int minPinLength = (mode == 0x83) ? 8 : 6; if (oldPinInput.getText().toString().length() < minPinLength || newPinInput.getText().toString().length() < minPinLength) { newPinInput.setText(""); confirmPinInput.setText(""); Toast.makeText(MainActivity.this, String.format("%s PIN must be at least %d digits.", typeString, minPinLength), Toast.LENGTH_SHORT).show(); return; } // Once we have valid PINs, add the pending operation. mPendingOperations.add(new PendingChangePinOperation(mode, oldPinInput.getText().toString(), newPinInput.getText().toString())); // And prompt the user to change the PIN. hideUi(); findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_change); dialog.dismiss(); } }); }
From source file:com.tozny.e3db.android.DefaultKeyAuthenticator.java
@Override public void getPassword(final PasswordHandler handler) { this.activity.runOnUiThread(new Runnable() { @Override/*from ww w . j a v a 2 s .com*/ public void run() { Context ctx = DefaultKeyAuthenticator.this.activity; final EditText input = new EditText(ctx); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); new AlertDialog.Builder(DefaultKeyAuthenticator.this.activity) .setMessage(ctx.getString(R.string.key_provider_please_enter_pin)) .setPositiveButton(ctx.getString(R.string.key_provider_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { handler.handlePassword(input.getText().toString()); } catch (UnrecoverableKeyException e) { wrongPasswordCount[0]++; if (wrongPasswordCount[0] >= 3) { handler.handleError( new RuntimeException("Too many password tries.")); } else { Toast.makeText(DefaultKeyAuthenticator.this.activity, e.getMessage(), Toast.LENGTH_SHORT).show(); getPassword(handler); } } } }) .setNegativeButton(ctx.getString(R.string.key_provider_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { handler.handleCancel(); } }) .setView(input).show(); input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if (input.isEnabled() && input.isFocusable()) { input.post(new Runnable() { @Override public void run() { final InputMethodManager imm = (InputMethodManager) DefaultKeyAuthenticator.this.activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); } }); } } }); } }); }
From source file:com.sigilance.CardEdit.MainActivity.java
private void promptForVerifyPin(final int mode) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.action_enable_edit_mode); builder.setMessage(//from w ww . j av a 2 s . com "Enter the Admin PIN to edit data on the card.\nREMINDER: The default Admin PIN is 12345678"); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); builder.setView(input); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().length() == 0) { Toast.makeText(MainActivity.this, "Enter a PIN!", Toast.LENGTH_SHORT).show(); return; } int minPinLength = (mode == 0x83) ? 8 : 6; if (input.getText().toString().length() < minPinLength) { input.setText(""); Toast.makeText(MainActivity.this, String.format("PIN is at least %d digits.", minPinLength), Toast.LENGTH_SHORT).show(); return; } mPendingOperations.add(new PendingVerifyPinOperation(mode, input.getText().toString())); hideUi(); findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_verify); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.create().show(); }
From source file:com.facebook.react.views.textinput.ReactTextInputManager.java
@ReactProp(name = "secureTextEntry", defaultBoolean = false) public void setSecureTextEntry(ReactEditText view, boolean password) { updateStagedInputTypeFlag(view,//from ww w . j av a 2s. c o m password ? 0 : InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_PASSWORD, password ? InputType.TYPE_TEXT_VARIATION_PASSWORD : 0); checkPasswordType(view); }
From source file:com.facebook.react.views.textinput.ReactTextInputManager.java
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); }//from w w w . j a v a2s . co m }