Refactor
This commit is contained in:
parent
d05645d702
commit
fc88d4d2db
1 changed files with 4 additions and 59 deletions
|
@ -203,12 +203,9 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
textFieldBoxes.add(nameBox);
|
textFieldBoxes.add(nameBox);
|
||||||
|
|
||||||
registerTextFieldBoxes();
|
registerInputs();
|
||||||
|
|
||||||
registerInputEditTexts();
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
latitudeBox.select();
|
latitudeBox.select();
|
||||||
|
@ -360,7 +357,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerTextFieldBoxes() {
|
private void registerInputs() {
|
||||||
View.OnTouchListener textFieldBoxOnTouchListener = new View.OnTouchListener() {
|
View.OnTouchListener textFieldBoxOnTouchListener = new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
|
@ -375,13 +372,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
|
||||||
textFieldBox.getPanel().setOnTouchListener(textFieldBoxOnTouchListener);
|
|
||||||
}
|
|
||||||
changeKeyboardInBoxes();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerInputEditTexts() {
|
|
||||||
TextWatcher textWatcher = new TextWatcher() {
|
TextWatcher textWatcher = new TextWatcher() {
|
||||||
|
|
||||||
private int strLength;
|
private int strLength;
|
||||||
|
@ -527,6 +517,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
};
|
};
|
||||||
|
|
||||||
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
|
||||||
|
textFieldBox.getPanel().setOnTouchListener(textFieldBoxOnTouchListener);
|
||||||
EditText editText = textFieldBox.getEditText();
|
EditText editText = textFieldBox.getEditText();
|
||||||
if (editText.getId() != R.id.name_edit_text) {
|
if (editText.getId() != R.id.name_edit_text) {
|
||||||
editText.addTextChangedListener(textWatcher);
|
editText.addTextChangedListener(textWatcher);
|
||||||
|
@ -536,9 +527,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
editText.setOnEditorActionListener(inputTextViewOnEditorActionListener);
|
editText.setOnEditorActionListener(inputTextViewOnEditorActionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeInputEditTextHints();
|
changeKeyboardInBoxes();
|
||||||
changeInputEditTextLengths();
|
|
||||||
changeKeyboardInEditTexts();
|
|
||||||
changeEditTextSelections();
|
changeEditTextSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +536,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
changeOsmandKeyboardVisibility(false);
|
changeOsmandKeyboardVisibility(false);
|
||||||
}
|
}
|
||||||
changeKeyboardInBoxes();
|
changeKeyboardInBoxes();
|
||||||
changeKeyboardInEditTexts();
|
|
||||||
changeEditTextSelections();
|
changeEditTextSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,8 +561,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
@Override
|
@Override
|
||||||
public void onAccuracyChanged(int accuracy) {
|
public void onAccuracyChanged(int accuracy) {
|
||||||
CoordinateInputDialogFragment.this.accuracy = accuracy;
|
CoordinateInputDialogFragment.this.accuracy = accuracy;
|
||||||
changeInputEditTextHints();
|
|
||||||
changeInputEditTextLengths();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -610,47 +596,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeKeyboardInEditTexts() {
|
|
||||||
// int coordinateInputType = useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_NUMBER;
|
|
||||||
// int nameInputType = useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT;
|
|
||||||
// for (TextView inputTextView : inputEditTexts) {
|
|
||||||
// inputTextView.setInputType(inputTextView.getId() == R.id.name_edit_text ? nameInputType : coordinateInputType);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeInputEditTextLengths() {
|
|
||||||
// int maxLength;
|
|
||||||
// if (accuracy == PointDescription.FORMAT_DEGREES) {
|
|
||||||
// maxLength = DEGREES_MAX_LENGTH;
|
|
||||||
// } else if (accuracy == PointDescription.FORMAT_MINUTES) {
|
|
||||||
// maxLength = MINUTES_MAX_LENGTH;
|
|
||||||
// } else {
|
|
||||||
// maxLength = SECONDS_MAX_LENGTH;
|
|
||||||
// }
|
|
||||||
// InputFilter[] filtersArray = new InputFilter[] {new InputFilter.LengthFilter(maxLength)};
|
|
||||||
// for (EditText editText : inputEditTexts) {
|
|
||||||
// if (editText.getId() != R.id.name_edit_text) {
|
|
||||||
// editText.setFilters(filtersArray);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeInputEditTextHints() {
|
|
||||||
// String hint;
|
|
||||||
// if (accuracy == PointDescription.FORMAT_DEGREES) {
|
|
||||||
// hint = DEGREES_HINT;
|
|
||||||
// } else if (accuracy == PointDescription.FORMAT_MINUTES) {
|
|
||||||
// hint = MINUTES_HINT;
|
|
||||||
// } else {
|
|
||||||
// hint = SECONDS_HINT;
|
|
||||||
// }
|
|
||||||
// for (EditText editText : inputEditTexts) {
|
|
||||||
// if (editText.getId() != R.id.name_edit_text) {
|
|
||||||
// editText.setHint(hint);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void switchToNextInput(int id) {
|
private void switchToNextInput(int id) {
|
||||||
if (id == R.id.latitude_edit_text) {
|
if (id == R.id.latitude_edit_text) {
|
||||||
((OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box)).select();
|
((OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box)).select();
|
||||||
|
|
Loading…
Reference in a new issue