From f12743827cc5c87c350a9fdcd4018441fc83c92c Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 2 Nov 2017 16:59:21 +0200 Subject: [PATCH] Switch to next field due to accuracy --- .../CoordinateInputDialogFragment.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 389e479be5..f723b865dc 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -355,13 +355,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private void registerInputTextViews() { TextWatcher textWatcher = new TextWatcher() { - int len = 0; - String strBeforeChanging = ""; @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { - len = charSequence.length(); - strBeforeChanging = charSequence.toString(); + } @Override @@ -371,10 +368,19 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void afterTextChanged(Editable editable) { - View focusedView = getDialog().getCurrentFocus(); - if (focusedView != null && focusedView instanceof EditText) { - EditText focusedEditText = (EditText) focusedView; - String str = focusedEditText.getText().toString(); + if (goToNextField) { + View focusedView = getDialog().getCurrentFocus(); + if (focusedView != null && focusedView instanceof EditText) { + EditText focusedEditText = (EditText) focusedView; + String str = focusedEditText.getText().toString(); + int pointIndex = str.indexOf("."); + if (pointIndex != -1) { + int currentAccuracy = str.substring(pointIndex + 1).length(); + if (currentAccuracy >= accuracy) { + switchToNextInput(focusedEditText.getId()); + } + } + } } } };