mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-31 01:53:46 +00:00
[android] Show error message behind text field instead in a floating view
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
committed by
jeanbaptisteC
parent
6e8a0f22e6
commit
47f959ec07
@@ -152,7 +152,7 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment
|
||||
if (mInputValidator != null)
|
||||
{
|
||||
final String maybeError = mInputValidator.validate(activity, input);
|
||||
mEtInputLayout.getEditText().setError(maybeError);
|
||||
mEtInputLayout.setError(maybeError);
|
||||
mEtInputLayout.requestFocus();
|
||||
return maybeError == null;
|
||||
}
|
||||
|
||||
@@ -196,10 +196,8 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
||||
{
|
||||
final Context context = mInputBuildingLevels.getContext();
|
||||
final boolean isValid = Editor.nativeIsLevelValid(s.toString());
|
||||
UiUtils.setInputError(mInputBuildingLevels,
|
||||
isValid ? null
|
||||
: context.getString(R.string.error_enter_correct_storey_number,
|
||||
Editor.nativeGetMaxEditableBuildingLevels()));
|
||||
mInputBuildingLevels.setError(isValid ? null : context.getString(R.string.error_enter_correct_storey_number,
|
||||
Editor.nativeGetMaxEditableBuildingLevels()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.WindowCompat;
|
||||
@@ -209,15 +208,7 @@ public final class UiUtils
|
||||
}
|
||||
public static void setInputError(@NonNull TextInputLayout layout, @StringRes int error)
|
||||
{
|
||||
setInputError(layout, error == 0 ? null : layout.getContext().getString(error));
|
||||
}
|
||||
|
||||
public static void setInputError(@NonNull TextInputLayout layout, String error)
|
||||
{
|
||||
layout.getEditText().setError(error);
|
||||
layout.getEditText().setTextColor(error == null
|
||||
? ThemeUtils.getColor(layout.getContext(), android.R.attr.textColorPrimary)
|
||||
: ContextCompat.getColor(layout.getContext(), R.color.base_red));
|
||||
layout.setError(error == 0 ? null : layout.getContext().getString(error));
|
||||
}
|
||||
|
||||
public static void setFullscreen(@NonNull Activity activity, boolean fullscreen)
|
||||
|
||||
Reference in New Issue
Block a user