mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Make address addable in the editor
Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
@@ -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++)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -493,6 +493,12 @@ JNIEXPORT jboolean JNICALL Java_app_organicmaps_sdk_editor_Editor_nativeIsHouseV
|
||||
return osm::EditableMapObject::ValidateHouseNumber(jni::ToNativeString(env, houseNumber));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_app_organicmaps_sdk_editor_Editor_nativeCheckHouseNumberWhenIsAddress(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
return g_editableMapObject.CheckHouseNumberWhenIsAddress();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_app_organicmaps_sdk_editor_Editor_nativeIsNameValid(JNIEnv * env, jclass clazz,
|
||||
jstring name)
|
||||
{
|
||||
|
||||
@@ -10162,6 +10162,48 @@ sw:Jengo
|
||||
fa:ساختمان
|
||||
mr:इमारत|बिल्डिंग|वाडा
|
||||
|
||||
building-address
|
||||
en:Address
|
||||
ar:العنوان
|
||||
be:Адрас
|
||||
bg:Адрес
|
||||
ca:Adreça
|
||||
cs:Adresa
|
||||
da:Adresse
|
||||
de:Adresse
|
||||
el:Διεύθυνση
|
||||
es:Dirección
|
||||
et:Aadress
|
||||
eu:Helbidea
|
||||
fa:آدرس
|
||||
fi:Osoite
|
||||
fr:Adresse
|
||||
he:כתובת
|
||||
hi:पता
|
||||
hu:Cím
|
||||
id:Alamat
|
||||
it:Indirizzo
|
||||
ja:住所
|
||||
ko:주소
|
||||
mr:पत्ता
|
||||
nb:Adresse
|
||||
nl:Adres
|
||||
pl:Adres
|
||||
pt:Morada|Endereço
|
||||
pt-BR:Endereço
|
||||
ro:Adresă
|
||||
ru:Адрес
|
||||
sk:Adresa
|
||||
sr:Адреса
|
||||
sv:Adress
|
||||
sw:Anwani
|
||||
th:ที่อยู่
|
||||
tr:Adres
|
||||
uk:Адреса
|
||||
vi:Địa chỉ
|
||||
zh-Hans:地址
|
||||
zh-Hant:地址
|
||||
|
||||
# First keyword should match [police] definition in strings.txt!
|
||||
@category_police
|
||||
en:4Police|cops
|
||||
|
||||
@@ -1449,8 +1449,7 @@
|
||||
<type id="building" can_add="no">
|
||||
<include group="address" />
|
||||
</type>
|
||||
<!-- No consensus yet, see https://github.com/organicmaps/organicmaps/issues/6394 -->
|
||||
<type id="building-address" can_add="no">
|
||||
<type id="building-address" can_add="yes">
|
||||
<include group="address" />
|
||||
</type>
|
||||
<!-- Uncomment this after a map style is added
|
||||
|
||||
@@ -222,6 +222,31 @@ void registerCellsForTableView(std::vector<MWMEditorCellID> const & cells, UITab
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation to make sure address features have a house number
|
||||
if (!m_mapObject.CheckHouseNumberWhenIsAddress())
|
||||
{
|
||||
// Find indexPath for the house number cell and mark it as invalid
|
||||
auto const sectionIt = std::find(m_sections.begin(), m_sections.end(), MWMEditorSectionAddress);
|
||||
if (sectionIt != m_sections.end())
|
||||
{
|
||||
NSInteger const section = std::distance(m_sections.begin(), sectionIt);
|
||||
auto const & cells = m_cells[MWMEditorSectionAddress];
|
||||
auto const it = std::find(cells.begin(), cells.end(), MWMEditorCellTypeBuilding);
|
||||
if (it != cells.end())
|
||||
{
|
||||
NSInteger const row = std::distance(cells.begin(), it);
|
||||
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row inSection:section];
|
||||
[self markCellAsInvalid:indexPath];
|
||||
|
||||
// Focus the text field to draw the user's attention.
|
||||
MWMEditorTextTableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath];
|
||||
[cell.textField becomeFirstResponder];
|
||||
}
|
||||
}
|
||||
// Stop the save process
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self showPersonalInfoWarningAlertIfNeeded])
|
||||
return;
|
||||
|
||||
|
||||
@@ -855,6 +855,10 @@ XMLFeature TypeToXML(uint32_t type, feature::GeomType geomType, m2::PointD merca
|
||||
toFeature.SetTagValue("amenity", "recycling");
|
||||
toFeature.SetTagValue("recycling_type", "container");
|
||||
}
|
||||
else if (ftypes::IsAddressChecker::Instance()(type))
|
||||
{
|
||||
// Addresses don't have a category tag
|
||||
}
|
||||
else
|
||||
{
|
||||
string const strType = classif().GetReadableObjectName(type);
|
||||
|
||||
@@ -433,6 +433,12 @@ bool EditableMapObject::ValidateHouseNumber(string const & houseNumber)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditableMapObject::CheckHouseNumberWhenIsAddress() const
|
||||
{
|
||||
// House number is mandatory for the address type. For other types it's optional.
|
||||
return !m_houseNumber.empty() || !m_types.Has(classif().GetTypeByReadableObjectName("building-address"));
|
||||
}
|
||||
|
||||
// static
|
||||
bool EditableMapObject::ValidateFlats(string const & flats)
|
||||
{
|
||||
|
||||
@@ -127,6 +127,7 @@ public:
|
||||
|
||||
static bool ValidateBuildingLevels(std::string const & buildingLevels);
|
||||
static bool ValidateHouseNumber(std::string const & houseNumber);
|
||||
bool CheckHouseNumberWhenIsAddress() const;
|
||||
static bool ValidateFlats(std::string const & flats);
|
||||
static bool ValidatePostCode(std::string const & postCode);
|
||||
static bool ValidatePhoneList(std::string const & phone);
|
||||
|
||||
Reference in New Issue
Block a user