mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 13:03:54 +00:00
[android] Use error in textfield instead alert dialog
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
@@ -34,6 +34,10 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
|
||||
@NonNull
|
||||
private TextInputEditText mEditDescView;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private TextInputLayout mEditCategoryNameLayout;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private TextInputEditText mEditCategoryNameView;
|
||||
@@ -61,8 +65,8 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
|
||||
private void initViews(@NonNull View root)
|
||||
{
|
||||
mEditCategoryNameView = root.findViewById(R.id.edit_list_name_view);
|
||||
TextInputLayout clearNameBtn = root.findViewById(R.id.edit_list_name_input);
|
||||
clearNameBtn.setEndIconOnClickListener(v -> clearAndFocus(mEditCategoryNameView));
|
||||
mEditCategoryNameLayout = root.findViewById(R.id.edit_list_name_input);
|
||||
mEditCategoryNameLayout.setEndIconOnClickListener(v -> clearAndFocus(mEditCategoryNameView));
|
||||
mEditCategoryNameView.setText(mCategory.getName());
|
||||
InputFilter[] f = {new InputFilter.LengthFilter(TEXT_LENGTH_LIMIT)};
|
||||
mEditCategoryNameView.setFilters(f);
|
||||
@@ -75,7 +79,19 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
|
||||
{
|
||||
clearNameBtn.setEndIconVisible(charSequence.length() > 0);
|
||||
if (charSequence.length() > 0)
|
||||
{
|
||||
mEditCategoryNameLayout.setEndIconVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mEditCategoryNameLayout.setEndIconVisible(false);
|
||||
mEditCategoryNameLayout.setError(getString(R.string.bookmarks_error_title_empty_list_name));
|
||||
}
|
||||
if (BookmarkManager.INSTANCE.isUsedCategoryName(charSequence.toString()) && !TextUtils.equals(charSequence.toString(), mCategory.getName()))
|
||||
{
|
||||
mEditCategoryNameLayout.setError(getString(R.string.bookmarks_error_title_list_name_already_taken));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user