[android][editor] fix: Turn invalid building number into red.

This commit is contained in:
Alexander Marchuk 2016-05-10 12:42:42 +03:00 committed by Vladimir Byko-Ianko
parent 317a9c0d2d
commit 91a2089542
2 changed files with 11 additions and 3 deletions

View file

@ -98,7 +98,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
private final SparseArray<View> mMetaBlocks = new SparseArray<>(7);
private TextView mReset;
protected EditorHostFragment mParent;
private EditorHostFragment mParent;
@Nullable
@Override
@ -130,11 +130,11 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
if (!Editor.nativeIsHouseValid(text))
{
mInputHouseNumber.setError(getString(R.string.error_enter_correct_house_number));
UiUtils.setInputError(mInputHouseNumber, R.string.error_enter_correct_house_number);
return;
}
mInputHouseNumber.setError(null);
UiUtils.setInputError(mInputHouseNumber, 0);
}
});
mZipcode.setText(Editor.nativeGetZipCode());

View file

@ -15,6 +15,7 @@ import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
@ -315,6 +316,13 @@ public final class UiUtils
+ resources.getResourceEntryName(resId));
}
public static void setInputError(@NonNull TextInputLayout layout, @StringRes int error)
{
layout.setError(error == 0 ? null : layout.getContext().getString(error));
layout.getEditText().setTextColor(error == 0 ? ThemeUtils.getColor(layout.getContext(), android.R.attr.textColorPrimary)
: layout.getContext().getResources().getColor(R.color.base_red));
}
// utility class
private UiUtils() {}
}