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

View file

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