use of android.text.InputFilter in project platform_frameworks_base by android.
the class TextView method onInitializeAccessibilityNodeInfoInternal.
/** @hide */
@Override
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfoInternal(info);
final boolean isPassword = hasPasswordTransformationMethod();
info.setPassword(isPassword);
info.setText(getTextForAccessibility());
if (mBufferType == BufferType.EDITABLE) {
info.setEditable(true);
if (isEnabled()) {
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT);
}
}
if (mEditor != null) {
info.setInputType(mEditor.mInputType);
if (mEditor.mError != null) {
info.setContentInvalid(true);
info.setError(mEditor.mError);
}
}
if (!TextUtils.isEmpty(mText)) {
info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION);
}
if (isFocused()) {
if (canCopy()) {
info.addAction(AccessibilityNodeInfo.ACTION_COPY);
}
if (canPaste()) {
info.addAction(AccessibilityNodeInfo.ACTION_PASTE);
}
if (canCut()) {
info.addAction(AccessibilityNodeInfo.ACTION_CUT);
}
if (canShare()) {
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACCESSIBILITY_ACTION_SHARE, getResources().getString(com.android.internal.R.string.share)));
}
if (canProcessText()) {
// also implies mEditor is not null.
mEditor.mProcessTextIntentActionsHandler.onInitializeAccessibilityNodeInfo(info);
}
}
// Check for known input filter types.
final int numFilters = mFilters.length;
for (int i = 0; i < numFilters; i++) {
final InputFilter filter = mFilters[i];
if (filter instanceof InputFilter.LengthFilter) {
info.setMaxTextLength(((InputFilter.LengthFilter) filter).getMax());
}
}
if (!isSingleLine()) {
info.setMultiLine(true);
}
}
use of android.text.InputFilter in project Conversations by siacs.
the class EditMessage method onTextContextMenuItem.
@Override
public boolean onTextContextMenuItem(int id) {
if (id == android.R.id.paste) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return super.onTextContextMenuItem(android.R.id.pasteAsPlainText);
} else {
Editable editable = getEditableText();
InputFilter[] filters = editable.getFilters();
InputFilter[] tempFilters = new InputFilter[filters != null ? filters.length + 1 : 1];
if (filters != null) {
System.arraycopy(filters, 0, tempFilters, 1, filters.length);
}
tempFilters[0] = SPAN_FILTER;
editable.setFilters(tempFilters);
try {
return super.onTextContextMenuItem(id);
} finally {
editable.setFilters(filters);
}
}
} else {
return super.onTextContextMenuItem(id);
}
}
use of android.text.InputFilter in project android_frameworks_base by AOSPA.
the class TextView method setFilters.
/**
* Sets the list of input filters on the specified Editable,
* and includes mInput in the list if it is an InputFilter.
*/
private void setFilters(Editable e, InputFilter[] filters) {
if (mEditor != null) {
final boolean undoFilter = mEditor.mUndoInputFilter != null;
final boolean keyFilter = mEditor.mKeyListener instanceof InputFilter;
int num = 0;
if (undoFilter)
num++;
if (keyFilter)
num++;
if (num > 0) {
InputFilter[] nf = new InputFilter[filters.length + num];
System.arraycopy(filters, 0, nf, 0, filters.length);
num = 0;
if (undoFilter) {
nf[filters.length] = mEditor.mUndoInputFilter;
num++;
}
if (keyFilter) {
nf[filters.length + num] = (InputFilter) mEditor.mKeyListener;
}
e.setFilters(nf);
return;
}
}
e.setFilters(filters);
}
use of android.text.InputFilter in project android_frameworks_base by crdroidandroid.
the class TextView method onInitializeAccessibilityNodeInfoInternal.
/** @hide */
@Override
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfoInternal(info);
final boolean isPassword = hasPasswordTransformationMethod();
info.setPassword(isPassword);
info.setText(getTextForAccessibility());
if (mBufferType == BufferType.EDITABLE) {
info.setEditable(true);
if (isEnabled()) {
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT);
}
}
if (mEditor != null) {
info.setInputType(mEditor.mInputType);
if (mEditor.mError != null) {
info.setContentInvalid(true);
info.setError(mEditor.mError);
}
}
if (!TextUtils.isEmpty(mText)) {
info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION);
}
if (isFocused()) {
if (canCopy()) {
info.addAction(AccessibilityNodeInfo.ACTION_COPY);
}
if (canPaste()) {
info.addAction(AccessibilityNodeInfo.ACTION_PASTE);
}
if (canCut()) {
info.addAction(AccessibilityNodeInfo.ACTION_CUT);
}
if (canShare()) {
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACCESSIBILITY_ACTION_SHARE, getResources().getString(com.android.internal.R.string.share)));
}
if (canProcessText()) {
// also implies mEditor is not null.
mEditor.mProcessTextIntentActionsHandler.onInitializeAccessibilityNodeInfo(info);
}
}
// Check for known input filter types.
final int numFilters = mFilters.length;
for (int i = 0; i < numFilters; i++) {
final InputFilter filter = mFilters[i];
if (filter instanceof InputFilter.LengthFilter) {
info.setMaxTextLength(((InputFilter.LengthFilter) filter).getMax());
}
}
if (!isSingleLine()) {
info.setMultiLine(true);
}
}
use of android.text.InputFilter in project CreditCardView by Movile.
the class CreditCardFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewHolder = view;
bindAttr();
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
backFinish.set(false);
Step step = pages.get(position);
if (step == Step.FLAG) {
hideKeyboard();
}
if (step != Step.CVV) {
cardRestored = false;
}
setNavigationButtons(step, false);
lastStep = step;
pageChanged();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
setIssuerCode(IssuerCode.OTHER);
btNext.setVisibility(View.INVISIBLE);
btNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (btNext.isActivated()) {
nextPage();
} else {
shakeField();
}
}
});
editNumberCard.addTextChangedListener(this);
editNumberCard.setOnEditorActionListener(this);
editNumberCard.setTag(new FieldValidator() {
@Override
public boolean isValid() {
return validator.validateCreditCardNumber(editNumberCard, false);
}
});
editExpireCard.addTextChangedListener(this);
editExpireCard.setOnEditorActionListener(this);
editExpireCard.setTag(new FieldValidator() {
@Override
public boolean isValid() {
return validator.validateExpiredDate(editExpireCard, false);
}
});
editCVVCard.addTextChangedListener(this);
editCVVCard.setOnEditorActionListener(this);
editCVVCard.setOnFocusChangeListener(this);
editCVVCard.setTag(new FieldValidator() {
@Override
public boolean isValid() {
return validator.validateSecurityCode(selectedPurchaseOption.getIssuerCode(), editCVVCard, false);
}
});
editNameCard.addTextChangedListener(this);
editNameCard.setOnFocusChangeListener(this);
editNameCard.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
editNameCard.setTag(new FieldValidator() {
@Override
public boolean isValid() {
return validator.validateCreditCardName(editNameCard, false);
}
});
btEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cardRestored = false;
showEditCardLayout(true);
}
});
btPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Integer installments = (Integer) spInstallments.getSelectedItem();
if (validator.validateSecurityCode(selectedPurchaseOption.getIssuerCode(), editCVVCard, false)) {
if (validator.validateCreditCardFlag(selectedPurchaseOption, installments)) {
CreditCardPaymentMethod creditCardMethod = new CreditCardPaymentMethod();
creditCardMethod.setCreditCardNumber(editNumberCard.getText().toString().replaceAll(" ", ""));
creditCardMethod.setIssuerCode(selectedPurchaseOption.getIssuerCode());
creditCardMethod.setSecurityCode(editCVVCard.getText().toString());
creditCardMethod.setCreditCardName(editNameCard.getText().toString());
creditCardMethod.setInstallments(installments);
applyExpiredDate(creditCardMethod);
if (actionOnPayListener != null) {
actionOnPayListener.onComplete(creditCardMethod, switchSaveCard.isChecked());
}
} else {
// TODO: soft bug
Toast.makeText(getActivity(), R.string.invalid_credit_card_flag, Toast.LENGTH_LONG).show();
}
} else {
pager.setCurrentItem(pages.indexOf(Step.CVV));
showEditCardLayout(false);
showKeyboard(editCVVCard);
}
}
});
}
Aggregations