use of android.text.InputFilter in project android_packages_apps_Dialer by LineageOS.
the class MessageFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_message, container, false);
sendMessage = view.findViewById(R.id.send_message);
sendMessageContainer = view.findViewById(R.id.count_and_send_container);
if (getArguments().getBoolean(SHOW_SEND_ICON_KEY, false)) {
sendMessage.setVisibility(View.VISIBLE);
sendMessage.setEnabled(false);
sendMessageContainer.setOnClickListener(this);
}
customMessage = view.findViewById(R.id.custom_message);
customMessage.addTextChangedListener(this);
customMessage.setOnEditorActionListener(this);
charLimit = getArguments().getInt(CHAR_LIMIT_KEY, NO_CHAR_LIMIT);
if (charLimit != NO_CHAR_LIMIT) {
remainingChar = view.findViewById(R.id.remaining_characters);
remainingChar.setVisibility(View.VISIBLE);
remainingChar = view.findViewById(R.id.remaining_characters);
remainingChar.setText(Integer.toString(charLimit));
customMessage.setFilters(new InputFilter[] { new InputFilter.LengthFilter(charLimit) });
}
LinearLayout messageContainer = view.findViewById(R.id.message_container);
for (String message : getArguments().getStringArray(MESSAGE_LIST_KEY)) {
TextView textView = (TextView) inflater.inflate(R.layout.selectable_text_view, null);
textView.setOnClickListener(this);
textView.setText(message);
messageContainer.addView(textView);
}
return view;
}
use of android.text.InputFilter in project openScale by oliexdev.
the class MainActivity method enterScaleUserConsent.
private void enterScaleUserConsent(Message msg) {
final int appUserId = msg.arg1;
final int scaleUserIndex = msg.arg2;
final int[] consentCode = { -1 };
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
mBuilder.setTitle(getResources().getString(R.string.info_enter_consent_code_for_scale_user, Integer.toString(scaleUserIndex)));
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
InputFilter[] filterArray = new InputFilter[1];
filterArray[0] = new InputFilter.LengthFilter(4);
input.setFilters(filterArray);
mBuilder.setView(input);
mBuilder.setPositiveButton(getResources().getString(R.string.label_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialoginterface, int i) {
OpenScale.getInstance().setBluetoothDeviceUserConsent(appUserId, consentCode[0], callbackBtHandler);
dialoginterface.dismiss();
}
});
mBuilder.setNegativeButton(getResources().getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
OpenScale.getInstance().setBluetoothDeviceUserConsent(appUserId, -1, callbackBtHandler);
dialoginterface.dismiss();
}
});
AlertDialog mDialog = mBuilder.create();
mDialog.show();
mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
input.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
try {
consentCode[0] = Integer.parseInt(s.toString());
Timber.d("consent code set to " + consentCode[0] + "(" + s.toString() + ")");
mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
} catch (NumberFormatException nfe) {
Timber.d("Could not parse " + nfe);
mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
}
});
}
use of android.text.InputFilter in project android_packages_apps_Dialer by MoKee.
the class MessageComposerFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
charLimit = getArguments().getInt(CHAR_LIMIT_KEY, NO_CHAR_LIMIT);
View view = inflater.inflate(R.layout.fragment_message_composer, container, false);
TextView urgent = (TextView) view.findViewById(R.id.message_urgent);
customMessage = (EditText) view.findViewById(R.id.custom_message);
urgent.setOnClickListener(this);
customMessage.addTextChangedListener(this);
customMessage.setOnEditorActionListener(this);
if (charLimit != NO_CHAR_LIMIT) {
TextView remainingChar = (TextView) view.findViewById(R.id.remaining_characters);
remainingChar.setText("" + charLimit);
customMessage.setFilters(new InputFilter[] { new InputFilter.LengthFilter(charLimit) });
customMessage.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
remainingChar.setText("" + (charLimit - editable.length()));
}
});
}
view.findViewById(R.id.message_chat).setOnClickListener(this);
view.findViewById(R.id.message_question).setOnClickListener(this);
return view;
}
Aggregations