Make address addable in the editor

Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
map-per
2025-08-19 21:29:29 +02:00
committed by map-per
parent cd29eda949
commit 00d3f9a370
10 changed files with 109 additions and 3 deletions

View File

@@ -236,6 +236,11 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
return true;
}
boolean saveEdits()
{
return setEdits() && beforeSavingValidation();
}
@NonNull
protected String getDescription()
{
@@ -282,6 +287,18 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
return validateNames();
}
private boolean beforeSavingValidation() {
// Validation to make sure address features have a house number
if (!Editor.nativeCheckHouseNumberWhenIsAddress())
{
mHouseNumber.requestFocus();
UiUtils.setInputError(mInputHouseNumber, R.string.error_enter_correct_house_number);
InputUtils.showKeyboard(mHouseNumber);
return false;
}
return true;
}
private boolean validateNames()
{
for (int pos = 0; pos < mNamesAdapter.getItemCount(); pos++)

View File

@@ -276,6 +276,11 @@ public class EditorHostFragment
return ((EditorFragment) getChildFragmentManager().findFragmentByTag(EditorFragment.class.getName())).setEdits();
}
private boolean saveEdits()
{
return ((EditorFragment) getChildFragmentManager().findFragmentByTag(EditorFragment.class.getName())).saveEdits();
}
@Override
public void onClick(View v)
{
@@ -310,7 +315,7 @@ public class EditorHostFragment
case LANGUAGE -> editMapObject();
case MAP_OBJECT ->
{
if (!setEdits())
if (!saveEdits())
return;
// Save object edits

View File

@@ -112,6 +112,7 @@ public final class Editor
public static native String nativeGetHouseNumber();
public static native void nativeSetHouseNumber(String houseNumber);
public static native boolean nativeIsHouseValid(String houseNumber);
public static native boolean nativeCheckHouseNumberWhenIsAddress();
public static boolean nativeIsLevelValid(String level)
{
return nativeIsMetadataValid(Metadata.MetadataType.FMD_BUILDING_LEVELS.toInt(), level);