Fixes
This commit is contained in:
parent
704ab9d457
commit
e75ff85aba
7 changed files with 77 additions and 71 deletions
|
@ -54,10 +54,9 @@
|
|||
|
||||
<net.osmand.plus.widgets.CursorTextView
|
||||
android:imeOptions="actionNext"
|
||||
android:id="@+id/latitude_edit_text"
|
||||
android:id="@+id/latitude_input_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextViewFieldBoxes>
|
||||
|
||||
|
@ -72,10 +71,9 @@
|
|||
|
||||
<net.osmand.plus.widgets.CursorTextView
|
||||
android:imeOptions="actionNext"
|
||||
android:id="@+id/longitude_edit_text"
|
||||
android:id="@+id/longitude_input_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextViewFieldBoxes>
|
||||
|
||||
|
@ -90,11 +88,10 @@
|
|||
|
||||
<net.osmand.plus.widgets.CursorTextView
|
||||
android:imeOptions="actionDone"
|
||||
android:id="@+id/name_edit_text"
|
||||
android:id="@+id/name_input_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/access_hint_enter_name"
|
||||
android:inputType="text"/>
|
||||
android:hint="@string/access_hint_enter_name"/>
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextViewFieldBoxes>
|
||||
|
||||
|
|
|
@ -96,8 +96,7 @@
|
|||
|
||||
<net.osmand.plus.widgets.CursorTextView
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="number"
|
||||
android:id="@+id/latitude_edit_text"
|
||||
android:id="@+id/latitude_input_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
@ -112,8 +111,7 @@
|
|||
|
||||
<net.osmand.plus.widgets.CursorTextView
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="number"
|
||||
android:id="@+id/longitude_edit_text"
|
||||
android:id="@+id/longitude_input_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
@ -138,9 +136,8 @@
|
|||
|
||||
<net.osmand.plus.widgets.CursorTextView
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:hint="@string/access_hint_enter_name"
|
||||
android:id="@+id/name_edit_text"
|
||||
android:id="@+id/name_input_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import android.view.WindowManager;
|
|||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -204,17 +203,21 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
registerTextFieldBoxes();
|
||||
|
||||
inputTextViews = new ArrayList<>();
|
||||
final TextView latitudeEditText = (TextView) mainView.findViewById(R.id.latitude_edit_text);
|
||||
inputTextViews.add(latitudeEditText);
|
||||
final TextView longitudeEditText = (TextView) mainView.findViewById(R.id.longitude_edit_text);
|
||||
inputTextViews.add(longitudeEditText);
|
||||
final TextView nameEditText = (TextView) mainView.findViewById(R.id.name_edit_text);
|
||||
inputTextViews.add(nameEditText);
|
||||
final TextView latitudeInputTextView = (TextView) mainView.findViewById(R.id.latitude_input_text_view);
|
||||
inputTextViews.add(latitudeInputTextView);
|
||||
final TextView longitudeInputTextView = (TextView) mainView.findViewById(R.id.longitude_input_text_view);
|
||||
inputTextViews.add(longitudeInputTextView);
|
||||
final TextView nameInputTextView = (TextView) mainView.findViewById(R.id.name_input_text_view);
|
||||
inputTextViews.add(nameInputTextView);
|
||||
|
||||
registerEditTexts();
|
||||
registerInputTextViews();
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
latitudeBox.select();
|
||||
} else {
|
||||
changeInputTextViewHints();
|
||||
changeInputTextViewLengths();
|
||||
changeKeyboardInInputTextViews();
|
||||
}
|
||||
|
||||
final View mapMarkersLayout = mainView.findViewById(R.id.map_markers_layout);
|
||||
|
@ -356,7 +359,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
changeKeyboardInBoxes();
|
||||
}
|
||||
|
||||
private void registerEditTexts() {
|
||||
private void registerInputTextViews() {
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
int len = 0;
|
||||
String strBeforeChanging = "";
|
||||
|
@ -375,7 +378,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
View focusedView = getDialog().getCurrentFocus();
|
||||
if (focusedView != null && focusedView instanceof EditText) {
|
||||
if (focusedView != null && focusedView instanceof TextView) {
|
||||
TextView focusedTextView = (TextView) focusedView;
|
||||
String str = focusedTextView.getText().toString();
|
||||
int strLength = str.length();
|
||||
|
@ -416,34 +419,30 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
}
|
||||
};
|
||||
|
||||
View.OnTouchListener editTextOnTouchListener = new View.OnTouchListener() {
|
||||
View.OnTouchListener inputTextViewOnTouchListener = new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
if (useOsmandKeyboard || !orientationPortrait) {
|
||||
if (orientationPortrait && !isOsmandKeyboardCurrentlyVisible()) {
|
||||
changeOsmandKeyboardVisibility(true);
|
||||
}
|
||||
EditText editText = (EditText) view;
|
||||
int inType = editText.getInputType(); // Backup the input type
|
||||
editText.setInputType(InputType.TYPE_NULL); // Disable standard keyboard
|
||||
editText.onTouchEvent(motionEvent); // Call native handler
|
||||
editText.setInputType(inType); // Restore input type
|
||||
return true; // Consume touch event
|
||||
AndroidUtils.hideSoftKeyboard(getActivity(), view);
|
||||
return false;
|
||||
} else {
|
||||
if (isOsmandKeyboardCurrentlyVisible()) {
|
||||
changeOsmandKeyboardVisibility(false);
|
||||
}
|
||||
AndroidUtils.showSoftKeyboard(view);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
View.OnLongClickListener editTextOnLongClickListener = new View.OnLongClickListener() {
|
||||
View.OnLongClickListener inputTextViewOnLongClickListener = new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(final View view) {
|
||||
if (useOsmandKeyboard) {
|
||||
final EditText editText = (EditText) view;
|
||||
PopupMenu popupMenu = new PopupMenu(getContext(), editText);
|
||||
final TextView inputTextView = (TextView) view;
|
||||
PopupMenu popupMenu = new PopupMenu(getContext(), inputTextView);
|
||||
Menu menu = popupMenu.getMenu();
|
||||
popupMenu.getMenuInflater().inflate(R.menu.copy_paste_menu, menu);
|
||||
final ClipboardManager clipboardManager = ((ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE));
|
||||
|
@ -462,29 +461,28 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
case R.id.action_copy:
|
||||
String labelText;
|
||||
switch (view.getId()) {
|
||||
case R.id.latitude_edit_text:
|
||||
case R.id.latitude_input_text_view:
|
||||
labelText = LATITUDE_LABEL;
|
||||
break;
|
||||
case R.id.longitude_edit_text:
|
||||
case R.id.longitude_input_text_view:
|
||||
labelText = LONGITUDE_LABEL;
|
||||
break;
|
||||
case R.id.name_edit_text:
|
||||
case R.id.name_input_text_view:
|
||||
labelText = NAME_LABEL;
|
||||
break;
|
||||
default:
|
||||
labelText = "";
|
||||
break;
|
||||
}
|
||||
ClipData clip = ClipData.newPlainText(labelText, editText.getText().toString());
|
||||
ClipData clip = ClipData.newPlainText(labelText, inputTextView.getText().toString());
|
||||
clipboardManager.setPrimaryClip(clip);
|
||||
return true;
|
||||
case R.id.action_paste:
|
||||
ClipData.Item pasteItem = clipboardManager.getPrimaryClip().getItemAt(0);
|
||||
CharSequence pasteData = pasteItem.getText();
|
||||
if (pasteData != null) {
|
||||
String str = editText.getText().toString();
|
||||
editText.setText(str + pasteData.toString());
|
||||
editText.setSelection(editText.getText().length());
|
||||
String str = inputTextView.getText().toString();
|
||||
inputTextView.setText(str + pasteData.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -494,9 +492,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
popupMenu.show();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -505,13 +501,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
public void onFocusChange(View view, boolean b) {
|
||||
int resId;
|
||||
switch (view.getId()) {
|
||||
case R.id.latitude_edit_text:
|
||||
case R.id.latitude_input_text_view:
|
||||
resId = R.id.latitude_box;
|
||||
break;
|
||||
case R.id.longitude_edit_text:
|
||||
case R.id.longitude_input_text_view:
|
||||
resId = R.id.longitude_box;
|
||||
break;
|
||||
case R.id.name_edit_text:
|
||||
case R.id.name_input_text_view:
|
||||
resId = R.id.name_box;
|
||||
break;
|
||||
default:
|
||||
|
@ -533,7 +529,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
}
|
||||
};
|
||||
|
||||
TextView.OnEditorActionListener editTextOnEditorActionListener = new TextView.OnEditorActionListener() {
|
||||
TextView.OnEditorActionListener inputTextViewOnEditorActionListener = new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
if (i == EditorInfo.IME_ACTION_NEXT) {
|
||||
|
@ -546,13 +542,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
};
|
||||
|
||||
for (TextView textView : inputTextViews) {
|
||||
if (textView.getId() != R.id.name_edit_text) {
|
||||
textView.addTextChangedListener(textWatcher);
|
||||
}
|
||||
textView.setOnTouchListener(editTextOnTouchListener);
|
||||
textView.setOnLongClickListener(editTextOnLongClickListener);
|
||||
// if (textView.getId() != R.id.name_input_text_view) {
|
||||
// textView.addTextChangedListener(textWatcher);
|
||||
// }
|
||||
textView.setOnTouchListener(inputTextViewOnTouchListener);
|
||||
textView.setOnLongClickListener(inputTextViewOnLongClickListener);
|
||||
textView.setOnFocusChangeListener(focusChangeListener);
|
||||
textView.setOnEditorActionListener(editTextOnEditorActionListener);
|
||||
textView.setOnEditorActionListener(inputTextViewOnEditorActionListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,8 +557,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
@Override
|
||||
public void onCoordinateFormatChanged(int format) {
|
||||
coordinateFormat = format;
|
||||
changeEditTextHints();
|
||||
changeEditTextLengths();
|
||||
changeInputTextViewHints();
|
||||
changeInputTextViewLengths();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -572,6 +568,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
changeOsmandKeyboardVisibility(false);
|
||||
}
|
||||
changeKeyboardInBoxes();
|
||||
changeKeyboardInInputTextViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -593,13 +590,21 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
.setImageDrawable(iconsCache.getThemedIcon(show ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
|
||||
}
|
||||
|
||||
public void changeKeyboardInBoxes() {
|
||||
private void changeKeyboardInBoxes() {
|
||||
for (OsmandTextViewFieldBoxes textFieldBox : textFieldBoxes) {
|
||||
textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeEditTextLengths() {
|
||||
private void changeKeyboardInInputTextViews() {
|
||||
int coordinateInputType = useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_NUMBER;
|
||||
int nameInputType = useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT;
|
||||
for (TextView inputTextView : inputTextViews) {
|
||||
inputTextView.setInputType(inputTextView.getId() == R.id.name_input_text_view ? nameInputType : coordinateInputType);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeInputTextViewLengths() {
|
||||
int maxLength;
|
||||
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
|
||||
maxLength = DEGREES_MAX_LENGTH;
|
||||
|
@ -610,13 +615,13 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
}
|
||||
InputFilter[] filtersArray = new InputFilter[] {new InputFilter.LengthFilter(maxLength)};
|
||||
for (TextView textView : inputTextViews) {
|
||||
if (textView.getId() != R.id.name_edit_text) {
|
||||
if (textView.getId() != R.id.name_input_text_view) {
|
||||
textView.setFilters(filtersArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void changeEditTextHints() {
|
||||
private void changeInputTextViewHints() {
|
||||
String hint;
|
||||
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
|
||||
hint = DEGREES_HINT;
|
||||
|
@ -626,14 +631,14 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
hint = SECONDS_HINT;
|
||||
}
|
||||
for (TextView textView : inputTextViews) {
|
||||
if (textView.getId() != R.id.name_edit_text) {
|
||||
if (textView.getId() != R.id.name_input_text_view) {
|
||||
textView.setHint(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void switchToNextInput(int id) {
|
||||
if (id == R.id.latitude_edit_text) {
|
||||
if (id == R.id.latitude_input_text_view) {
|
||||
((OsmandTextViewFieldBoxes) mainView.findViewById(R.id.longitude_box)).select();
|
||||
} else {
|
||||
((OsmandTextViewFieldBoxes) mainView.findViewById(R.id.name_box)).select();
|
||||
|
@ -641,12 +646,12 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
}
|
||||
|
||||
private void addMapMarker() {
|
||||
String latitude = ((EditText) mainView.findViewById(R.id.latitude_edit_text)).getText().toString();
|
||||
String longitude = ((EditText) mainView.findViewById(R.id.longitude_edit_text)).getText().toString();
|
||||
String latitude = ((TextView) mainView.findViewById(R.id.latitude_input_text_view)).getText().toString();
|
||||
String longitude = ((TextView) mainView.findViewById(R.id.longitude_input_text_view)).getText().toString();
|
||||
String locPhrase = latitude + ", " + longitude;
|
||||
LatLon latLon = MapUtils.parseLocation(locPhrase);
|
||||
if (latLon != null) {
|
||||
String name = ((EditText) mainView.findViewById(R.id.name_edit_text)).getText().toString();
|
||||
String name = ((TextView) mainView.findViewById(R.id.name_input_text_view)).getText().toString();
|
||||
addMapMarker(latLon, name);
|
||||
} else {
|
||||
Toast.makeText(getContext(), getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RenameMarkerBottomSheetDialogFragment extends BottomSheetDialogFrag
|
|||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
}
|
||||
|
||||
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text);
|
||||
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_input_text_view);
|
||||
nameEditText.setText(marker.getName(mapActivity));
|
||||
nameEditText.requestFocus();
|
||||
final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
|
|||
displayedName = suggestedName + "_" + (++ind);
|
||||
fout = new File(dir, displayedName + GPX_SUFFIX);
|
||||
}
|
||||
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text);
|
||||
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_input_text_view);
|
||||
nameEditText.setText(displayedName);
|
||||
View textBox = mainView.findViewById(R.id.name_text_box);
|
||||
if (textBox instanceof OsmandEditTextFieldBoxes) {
|
||||
|
|
|
@ -34,6 +34,13 @@ public class CursorTextView extends AppCompatTextView {
|
|||
linePaint.setFilterBitmap(true);
|
||||
linePaint.setColor(Color.RED);
|
||||
bounds = new Rect();
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFreezesText() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -115,13 +115,13 @@ public class OsmandTextViewFieldBoxes extends FrameLayout {
|
|||
themeArray.recycle();
|
||||
}
|
||||
|
||||
protected AppCompatTextView findEditTextChild() {
|
||||
protected AppCompatTextView findTextViewChild() {
|
||||
return this.getChildCount() > 0 && this.getChildAt(0) instanceof AppCompatTextView?(AppCompatTextView) this.getChildAt(0):null;
|
||||
}
|
||||
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
this.inputText = this.findEditTextChild();
|
||||
this.inputText = this.findTextViewChild();
|
||||
if(this.inputText != null) {
|
||||
this.addView(LayoutInflater.from(this.getContext()).inflate(studio.carbonylgroup.textfieldboxes.R.layout.text_field_boxes_layout, this, false));
|
||||
this.removeView(this.inputText);
|
||||
|
|
Loading…
Reference in a new issue