forked from organicmaps/organicmaps
Add new type of error for buildings levels field
Signed-off-by: Jean-Baptiste CHARRON <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
parent
e86142a15e
commit
6944b25c01
2 changed files with 9 additions and 8 deletions
|
@ -181,12 +181,8 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||
{
|
||||
final Context context = mInputBuildingLevels.getContext();
|
||||
final EditText editText = mInputBuildingLevels.getEditText();
|
||||
final boolean isValid = Editor.nativeIsLevelValid(s.toString());
|
||||
mInputBuildingLevels.setError(isValid ? null
|
||||
: context.getString(R.string.error_enter_correct_storey_number, Editor.nativeGetMaxEditableBuildingLevels()));
|
||||
editText.setTextColor(isValid ? ThemeUtils.getColor(context, android.R.attr.textColorPrimary)
|
||||
: ContextCompat.getColor(context, R.color.base_red));
|
||||
UiUtils.setInputError(mInputBuildingLevels, isValid ? null : context.getString(R.string.error_enter_correct_storey_number, Editor.nativeGetMaxEditableBuildingLevels()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -335,9 +335,14 @@ public final class UiUtils
|
|||
|
||||
public static void setInputError(@NonNull TextInputLayout layout, @StringRes int error)
|
||||
{
|
||||
|
||||
layout.getEditText().setError(error == 0 ? null : layout.getContext().getString(error));
|
||||
layout.getEditText().setTextColor(error == 0 ? ThemeUtils.getColor(layout.getContext(), android.R.attr.textColorPrimary)
|
||||
setInputError(layout, error == 0 ? null : layout.getContext().getString(error));
|
||||
}
|
||||
|
||||
public static void setInputError(@NonNull TextInputLayout layout, String error)
|
||||
{
|
||||
layout.getEditText().setError(error);
|
||||
final Context ctx = layout.getContext();
|
||||
layout.getEditText().setTextColor(error == null ? ThemeUtils.getColor(layout.getContext(), android.R.attr.textColorPrimary)
|
||||
: ContextCompat.getColor(layout.getContext(), R.color.base_red));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue