From 0443bdfeb1f8aa7d94f3793233a71ec1a4d846fd Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 2 Nov 2017 15:55:26 +0200 Subject: [PATCH] Fix long press --- .../CoordinateInputDialogFragment.java | 105 +++++++++--------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 0b19eab745..5ac7c86d8c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -403,59 +403,62 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { - final EditText inputEditText = (EditText) view; - PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText); - Menu menu = popupMenu.getMenu(); - popupMenu.getMenuInflater().inflate(R.menu.copy_paste_menu, menu); - final ClipboardManager clipboardManager = ((ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE)); - MenuItem pasteMenuItem = menu.findItem(R.id.action_paste); - if (clipboardManager == null || !clipboardManager.hasPrimaryClip() || - !clipboardManager.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) { - pasteMenuItem.setEnabled(false); - } else { - pasteMenuItem.setEnabled(true); - } - if (clipboardManager != null) { - popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.action_copy: - String labelText; - switch (view.getId()) { - case R.id.latitude_edit_text: - labelText = LATITUDE_LABEL; - break; - case R.id.longitude_edit_text: - labelText = LONGITUDE_LABEL; - break; - case R.id.name_edit_text: - labelText = NAME_LABEL; - break; - default: - labelText = ""; - break; - } - ClipData clip = ClipData.newPlainText(labelText, inputEditText.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 = inputEditText.getText().toString(); - inputEditText.setText(str + pasteData.toString()); - inputEditText.setSelection(inputEditText.getText().length()); - } - return true; + if (useOsmandKeyboard || !orientationPortrait) { + final EditText inputEditText = (EditText) view; + PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText); + Menu menu = popupMenu.getMenu(); + popupMenu.getMenuInflater().inflate(R.menu.copy_paste_menu, menu); + final ClipboardManager clipboardManager = ((ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE)); + MenuItem pasteMenuItem = menu.findItem(R.id.action_paste); + if (clipboardManager == null || !clipboardManager.hasPrimaryClip() || + !clipboardManager.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) { + pasteMenuItem.setEnabled(false); + } else { + pasteMenuItem.setEnabled(true); + } + if (clipboardManager != null) { + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + switch (item.getItemId()) { + case R.id.action_copy: + String labelText; + switch (view.getId()) { + case R.id.latitude_edit_text: + labelText = LATITUDE_LABEL; + break; + case R.id.longitude_edit_text: + labelText = LONGITUDE_LABEL; + break; + case R.id.name_edit_text: + labelText = NAME_LABEL; + break; + default: + labelText = ""; + break; + } + ClipData clip = ClipData.newPlainText(labelText, inputEditText.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 = inputEditText.getText().toString(); + inputEditText.setText(str + pasteData.toString()); + inputEditText.setSelection(inputEditText.getText().length()); + } + return true; + } + return false; } - return false; - } - }); - popupMenu.show(); + }); + popupMenu.show(); + } + return true; + } else { + return false; } - return true; - } };