Fix keyboard in landscape

This commit is contained in:
PavelRatushny 2017-11-06 14:08:20 +02:00
parent 039e212666
commit 0bda792186
2 changed files with 41 additions and 38 deletions

View file

@ -189,7 +189,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
final OsmandTextFieldBoxes longitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box);
textFieldBoxes.add(longitudeBox);
final OsmandTextFieldBoxes nameBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_box);
if (orientationPortrait) {
nameBox.setEndIcon(iconsCache.getIcon(R.drawable.ic_action_keyboard, R.color.coordinate_input_keyboard_icon_color));
nameBox.getEndIconImageButton().setOnClickListener(new View.OnClickListener() {
@Override
@ -202,7 +201,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
}
}
});
}
textFieldBoxes.add(nameBox);
registerTextFieldBoxes();
@ -287,6 +286,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
keyboardGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (useOsmandKeyboard) {
View focusedView = getDialog().getCurrentFocus();
if (focusedView != null && focusedView instanceof EditText) {
EditText focusedEditText = (EditText) focusedView;
@ -311,6 +311,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
}
}
}
}
});
if (orientationPortrait) {
@ -423,7 +424,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
View.OnTouchListener inputEditTextOnTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (useOsmandKeyboard || !orientationPortrait) {
if (useOsmandKeyboard) {
if (orientationPortrait && !isOsmandKeyboardCurrentlyVisible()) {
changeOsmandKeyboardVisibility(true);
}
@ -438,7 +439,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
editText.setInputType(inputType);
return true;
} else {
if (isOsmandKeyboardCurrentlyVisible()) {
if (orientationPortrait && isOsmandKeyboardCurrentlyVisible()) {
changeOsmandKeyboardVisibility(false);
}
return false;
@ -449,7 +450,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(final View view) {
if (useOsmandKeyboard || !orientationPortrait) {
if (useOsmandKeyboard) {
final EditText inputEditText = (EditText) view;
PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText);
Menu menu = popupMenu.getMenu();
@ -495,9 +496,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
inputEditText.setSelection(inputEditText.getText().length());
}
return true;
}
default:
return false;
}
}
});
popupMenu.show();
}

View file

@ -41,6 +41,7 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
});
this.iconImageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
select();
}