From b73e45eb6195eda93662333d2ad73c7dc14ad0a1 Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Wed, 18 May 2016 17:42:55 +0300 Subject: [PATCH 1/3] [android][editor] fix: Typo. --- strings.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings.txt b/strings.txt index d2faaa3cb1..187aeebf09 100644 --- a/strings.txt +++ b/strings.txt @@ -16275,7 +16275,7 @@ [error_enter_correct_storey_number] tags = ios, android - en = Buildigns at highest of 25 levels can be edited + en = Buildings at highest of 25 levels can be edited ru = Редактируйте здания высотой максимум 25 этажей fr = Modifier l'immeuble avec un maximum de 25 étages da = Rediger bygningen med maksimum 25 etager From e2aa5bc45602f1c81d7b495dbd5f525b0df3868b Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Wed, 18 May 2016 17:44:14 +0300 Subject: [PATCH 2/3] [android][editor] fix: Generated strings. --- android/res/values/strings.xml | 2 +- iphone/Maps/en.lproj/Localizable.strings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 6294c616c8..ae8ef5da41 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -836,7 +836,7 @@ This could be considerably expensive with some plans or if roaming. Enter correct house number Building levels (max %d) - Buildigns at highest of 25 levels can be edited + Buildings at highest of 25 levels can be edited ZIP Code Enter the correct ZIP Code diff --git a/iphone/Maps/en.lproj/Localizable.strings b/iphone/Maps/en.lproj/Localizable.strings index ecf91202ee..1786961a35 100644 --- a/iphone/Maps/en.lproj/Localizable.strings +++ b/iphone/Maps/en.lproj/Localizable.strings @@ -1378,7 +1378,7 @@ "editor_storey_number" = "Building levels (max %d)"; -"error_enter_correct_storey_number" = "Buildigns at highest of 25 levels can be edited"; +"error_enter_correct_storey_number" = "Buildings at highest of 25 levels can be edited"; "editor_zip_code" = "ZIP Code"; From 862c170ee8d425b6af2cd63982048ad7e1467a7c Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Wed, 18 May 2016 17:46:30 +0300 Subject: [PATCH 3/3] [android][editor] fix: Validate floor count in editor. --- .../jni/com/mapswithme/maps/editor/Editor.cpp | 7 ++++ .../com/mapswithme/maps/editor/Editor.java | 1 + .../maps/editor/EditorFragment.java | 38 ++++++++++++------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/android/jni/com/mapswithme/maps/editor/Editor.cpp b/android/jni/com/mapswithme/maps/editor/Editor.cpp index 8384ca5dd7..6a718dc077 100644 --- a/android/jni/com/mapswithme/maps/editor/Editor.cpp +++ b/android/jni/com/mapswithme/maps/editor/Editor.cpp @@ -510,6 +510,13 @@ Java_com_mapswithme_maps_editor_Editor_nativeIsHouseValid(JNIEnv * env, jclass c return osm::EditableMapObject::ValidateHouseNumber(jni::ToNativeString(env, houseNumber)); } +// static boolean nativeIsLevelValid(String level); +JNIEXPORT jboolean JNICALL +Java_com_mapswithme_maps_editor_Editor_nativeIsLevelValid(JNIEnv * env, jclass clazz, jstring level) +{ + return osm::EditableMapObject::ValidateBuildingLevels(jni::ToNativeString(env, level)); +} + JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_editor_Editor_nativeGetCategory(JNIEnv * env, jclass clazz) { diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java index c3ca815328..0144da4526 100644 --- a/android/src/com/mapswithme/maps/editor/Editor.java +++ b/android/src/com/mapswithme/maps/editor/Editor.java @@ -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 nativeIsLevelValid(String level); public static native boolean nativeHasSomethingToUpload(); @WorkerThread diff --git a/android/src/com/mapswithme/maps/editor/EditorFragment.java b/android/src/com/mapswithme/maps/editor/EditorFragment.java index 5a05741508..eeac05af1e 100644 --- a/android/src/com/mapswithme/maps/editor/EditorFragment.java +++ b/android/src/com/mapswithme/maps/editor/EditorFragment.java @@ -43,7 +43,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe private EditText mName; private RecyclerView mLocalizedNames; - private RecyclerView.AdapterDataObserver mLocalizedNamesObserver = new RecyclerView.AdapterDataObserver() + private final RecyclerView.AdapterDataObserver mLocalizedNamesObserver = new RecyclerView.AdapterDataObserver() { @Override public void onChanged() @@ -85,6 +85,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe private View mBlockLevels; private EditText mBuildingLevels; private TextInputLayout mInputHouseNumber; + private TextInputLayout mInputBuildingLevels; private EditText mPhone; private EditText mWebsite; private EditText mEmail; @@ -120,25 +121,28 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe mName.setText(Editor.nativeGetDefaultName()); final LocalizedStreet street = Editor.nativeGetStreet(); mStreet.setText(street.defaultName); + mHouseNumber.setText(Editor.nativeGetHouseNumber()); mHouseNumber.addTextChangedListener(new StringUtils.SimpleTextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { - final String text = s.toString(); - - if (!Editor.nativeIsHouseValid(text)) - { - UiUtils.setInputError(mInputHouseNumber, R.string.error_enter_correct_house_number); - return; - } - - UiUtils.setInputError(mInputHouseNumber, 0); + UiUtils.setInputError(mInputHouseNumber, Editor.nativeIsHouseValid(s.toString()) ? 0 : R.string.error_enter_correct_house_number); } }); + mZipcode.setText(Editor.nativeGetZipCode()); mBuildingLevels.setText(Editor.nativeGetBuildingLevels()); + mBuildingLevels.addTextChangedListener(new StringUtils.SimpleTextWatcher() + { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) + { + UiUtils.setInputError(mInputBuildingLevels, Editor.nativeIsLevelValid(s.toString()) ? 0 : R.string.error_enter_correct_storey_number); + } + }); + mPhone.setText(Editor.nativeGetPhone()); mWebsite.setText(Editor.nativeGetWebsite()); mEmail.setText(Editor.nativeGetEmail()); @@ -157,7 +161,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe setEdits(); } - protected boolean setEdits() + boolean setEdits() { if (!validateFields()) return false; @@ -191,6 +195,13 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe return false; } + if (!Editor.nativeIsLevelValid(mBuildingLevels.getText().toString())) + { + mBuildingLevels.requestFocus(); + InputUtils.showKeyboard(mBuildingLevels); + return false; + } + return true; } @@ -271,6 +282,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe View blockZipcode = view.findViewById(R.id.block_zipcode); mZipcode = findInputAndInitBlock(blockZipcode, 0, R.string.editor_zip_code); mBlockLevels = view.findViewById(R.id.block_levels); + mInputBuildingLevels = (TextInputLayout) mBlockLevels.findViewById(R.id.custom_input); // TODO set level limits from core mBuildingLevels = findInputAndInitBlock(mBlockLevels, 0, getString(R.string.editor_storey_number, 25)); // Details @@ -310,7 +322,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe mMetaBlocks.append(MetadataType.FMD_INTERNET.toInt(), blockWifi); } - private EditText findInput(View blockWithInput) + private static EditText findInput(View blockWithInput) { return (EditText) blockWithInput.findViewById(R.id.input); } @@ -320,7 +332,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe return findInputAndInitBlock(blockWithInput, icon, getString(hint)); } - private EditText findInputAndInitBlock(View blockWithInput, @DrawableRes int icon, String hint) + private static EditText findInputAndInitBlock(View blockWithInput, @DrawableRes int icon, String hint) { ((ImageView) blockWithInput.findViewById(R.id.icon)).setImageResource(icon); final TextInputLayout input = (TextInputLayout) blockWithInput.findViewById(R.id.custom_input);