From 39d48e727039bc6c81ab04694fb7929f8414df8d Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Tue, 9 May 2017 21:00:04 +0200 Subject: unified copy text and share with context menu entries --- .../pixart/messenger/ui/ConversationFragment.java | 26 +++++----------------- src/main/res/menu/message_context.xml | 14 +++++------- src/main/res/values-de/strings.xml | 1 - src/main/res/values/strings.xml | 2 +- 4 files changed, 12 insertions(+), 31 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index e7526e315..4ba88d49a 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -623,7 +623,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa && t == null; activity.getMenuInflater().inflate(R.menu.message_context, menu); menu.setHeaderTitle(R.string.message_options); - MenuItem copyText = menu.findItem(R.id.copy_text); MenuItem selectText = menu.findItem(R.id.select_text); MenuItem retryDecryption = menu.findItem(R.id.retry_decryption); MenuItem correctMessage = menu.findItem(R.id.correct_message); @@ -634,11 +633,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa MenuItem downloadFile = menu.findItem(R.id.download_file); MenuItem deleteFile = menu.findItem(R.id.delete_file); MenuItem showErrorMessage = menu.findItem(R.id.show_error_message); - if (!treatAsFile - && !GeoHelper.isGeoUri(m.getBody()) - && !XmppUri.isXmppUri(m.getBody()) - && !m.treatAsDownloadable()) { - copyText.setVisible(true); + if (!treatAsFile && !GeoHelper.isGeoUri(m.getBody()) && !m.treatAsDownloadable()) { selectText.setVisible(ListSelectionManager.isSupported()); } if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { @@ -654,10 +649,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa && !(GeoHelper.isGeoUri(m.getBody()) || XmppUri.isXmppUri(m.getBody()))) { correctMessage.setVisible(true); } - if (treatAsFile - || GeoHelper.isGeoUri(m.getBody()) - || XmppUri.isXmppUri(m.getBody())) { + if (treatAsFile || (m.getType() == Message.TYPE_TEXT && !m.treatAsDownloadable())) { shareWith.setVisible(true); + } if (m.getStatus() == Message.STATUS_SEND_FAILED && !m.isFileOrImage()) { sendAgain.setVisible(true); @@ -699,9 +693,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa case R.id.share_with: shareWith(selectedMessage); return true; - case R.id.copy_text: - copyText(selectedMessage); - return true; case R.id.select_text: selectText(selectedMessage); return true; @@ -748,6 +739,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa if (GeoHelper.isGeoUri(message.getBody())) { shareIntent.putExtra(Intent.EXTRA_TEXT, message.getBody()); shareIntent.setType("text/plain"); + } else if (!message.isFileOrImage()) { + shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMergedBody().toString()); + shareIntent.setType("text/plain"); } else { final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); try { @@ -771,14 +765,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } - private void copyText(Message message) { - if (activity.copyTextToClipboard(message.getMergedBody().toString(), - R.string.message_text)) { - Toast.makeText(activity, R.string.message_copied_to_clipboard, - Toast.LENGTH_SHORT).show(); - } - } - private void selectText(Message message) { final int index; synchronized (this.messageList) { diff --git a/src/main/res/menu/message_context.xml b/src/main/res/menu/message_context.xml index 0c3220683..a7e46bc7f 100644 --- a/src/main/res/menu/message_context.xml +++ b/src/main/res/menu/message_context.xml @@ -1,26 +1,22 @@ - + - Nicht verbunden, bitte später versuchen %s-Größe prüfen Nachrichtenoptionen - Text kopieren Original-URL kopieren Erneut senden Datei-URL diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 299be7392..0dbf82efd 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -349,7 +349,6 @@ Check %s size Check %1$s size on %2$s Message options - Copy text Copy original URL Send again File URL @@ -775,4 +774,5 @@ delivery failed, resending… Show hostname and port settings when setting up an account Extended connection settings + Retry decryption -- cgit v1.2.3