use of android.text.InputFilter in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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 Lightning-Browser by anthonycr.
the class GeneralSettingsFragment method manualProxyPicker.
private void manualProxyPicker() {
View v = mActivity.getLayoutInflater().inflate(R.layout.dialog_manual_proxy, null);
final EditText eProxyHost = (EditText) v.findViewById(R.id.proxyHost);
final EditText eProxyPort = (EditText) v.findViewById(R.id.proxyPort);
// Limit the number of characters since the port needs to be of type int
// Use input filters to limite the EditText length and determine the max
// length by using length of integer MAX_VALUE
int maxCharacters = Integer.toString(Integer.MAX_VALUE).length();
InputFilter[] filterArray = new InputFilter[1];
filterArray[0] = new InputFilter.LengthFilter(maxCharacters - 1);
eProxyPort.setFilters(filterArray);
eProxyHost.setText(mPreferenceManager.getProxyHost());
eProxyPort.setText(Integer.toString(mPreferenceManager.getProxyPort()));
Dialog dialog = new AlertDialog.Builder(mActivity).setTitle(R.string.manual_proxy).setView(v).setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String proxyHost = eProxyHost.getText().toString();
int proxyPort;
try {
// Try/Catch in case the user types an empty string or a number
// larger than max integer
proxyPort = Integer.parseInt(eProxyPort.getText().toString());
} catch (NumberFormatException ignored) {
proxyPort = mPreferenceManager.getProxyPort();
}
mPreferenceManager.setProxyHost(proxyHost);
mPreferenceManager.setProxyPort(proxyPort);
proxy.setSummary(proxyHost + ':' + proxyPort);
}
}).show();
BrowserDialog.setDialogSize(mActivity, dialog);
}
use of android.text.InputFilter in project platform_frameworks_base by android.
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 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);
}
Aggregations