use of com.danh32.fontify.EditText in project android-app by spark.
the class SmartConfigFragment method setUpTextInputFieldWatchers.
private void setUpTextInputFieldWatchers() {
for (final Integer viewId : list(R.id.custom_aes_key_text, R.id.wifi_credentials_text)) {
EditText field = Ui.findView(this, viewId);
field.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// NO-OP
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// NO-OP
}
@Override
public void afterTextChanged(Editable s) {
validateForm(viewId);
}
});
}
}
use of com.danh32.fontify.EditText in project android-app by spark.
the class SmartConfigFragment method validateForm.
private void validateForm(int viewId) {
EditText wifiCredentialsText = Ui.findView(this, R.id.wifi_credentials_text);
CharSequence customKey = customKeyEntry.getText();
CharSequence wifiCreds = wifiCredentialsText.getText();
float alpha = 0.5f;
boolean enabled = false;
if ((customKey.length() == 16 || !customKeyCheckbox.isChecked()) && (wifiCreds.length() == 0 || (wifiCreds.length() >= 8 && wifiCreds.length() <= 32))) {
alpha = 1.0f;
enabled = true;
}
connectButton.setEnabled(enabled);
connectButton.setAlpha(alpha);
// "greater than" shouldn't be possible, but...
if (wifiCreds.length() >= 32 && viewId == R.id.wifi_credentials_text) {
new AlertDialog.Builder(getActivity()).setMessage(R.string.the_spark_core_can_only_accept_passwords_up_to_32_characters_).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create().show();
}
}
Aggregations