diff --git a/OsmAnd/res/layout/coordinate_input_data_area.xml b/OsmAnd/res/layout/coordinate_input_data_area.xml index 746e73203f..e6a4818f2d 100644 --- a/OsmAnd/res/layout/coordinate_input_data_area.xml +++ b/OsmAnd/res/layout/coordinate_input_data_area.xml @@ -164,7 +164,6 @@ screenHeight * 0.15) { + isSoftKeyboardShown = true; + showHideKeyboardIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_keyboard_hide)); + } else { + isSoftKeyboardShown = false; + } + } + }); } private void setupKeyboardItems(View keyboardView, View.OnClickListener listener, @IdRes int... itemsIds) { @@ -615,6 +626,15 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm if (focusedView != null && focusedView instanceof EditTextEx) { EditTextEx et = (EditTextEx) focusedView; int currentLength = et.getText().length(); + String lonFirstInput; + if (et.getId() == R.id.lon_first_input_et) { + lonFirstInput = editable.toString(); + if (currentLength == 2) { + if (lonFirstInput.charAt(0) != '1' && lonFirstInput.charAt(0) != '0') { + switchEditText(et.getId(), true); + } + } + } if (et.getMaxSymbolsCount() > 0 && currentLength > strLength && currentLength >= et.getMaxSymbolsCount()) { switchEditText(et.getId(), true); } @@ -718,7 +738,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm clearInputs(); int format = getMyApplication().getSettings().COORDS_INPUT_FORMAT.get(); - + boolean useTwoDigitsLongtitude = getMyApplication().getSettings().COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get(); setupEditTextEx(R.id.lat_first_input_et, CoordinateInputFormats.getFirstPartSymbolsCount(format, true, useTwoDigitsLongtitude), true); setupEditTextEx(R.id.lon_first_input_et, CoordinateInputFormats.getFirstPartSymbolsCount(format, false, useTwoDigitsLongtitude), false); @@ -755,6 +775,16 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm if (et.getId() != R.id.point_name_et) { et.addTextChangedListener(textWatcher); } + if (et.getId() == R.id.point_name_et) { + et.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + if (!hasFocus && isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) { + AndroidUtils.hideSoftKeyboard(getActivity(), v); + } + } + }); + } et.setOnTouchListener(inputEditTextOnTouchListener); et.setOnLongClickListener(inputEditTextOnLongClickListener); et.setOnEditorActionListener(inputTextViewOnEditorActionListener); @@ -815,7 +845,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onTwoDigitsLongtitudeChanged() { - changeTwoDigitsLongtitude(); + registerInputs(); } @Override @@ -841,13 +871,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm registerMainView(); } - private void changeTwoDigitsLongtitude() { - editTexts.get(3).setMaxSymbolsCount(getMyApplication().getSettings().COORDS_INPUT_TWO_DIGITS_LONGTITUDE.get() ? 2 : 3); - ((LinearLayout)mainView.findViewById(R.id.longitude_row)).removeView(editTexts.get(3)); -// editTexts.get(3).invalidate(); - registerMainView(); - } - private void changeEditTextSelections() { for (EditText et : editTexts) { et.setSelection(et.getText().length());