aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-23 14:30:55 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-23 14:30:55 +0100
commit37ad10abe5d170e72e853b8d18dbfb32b2bad84a (patch)
treef07f9f15c67e21b90998fdefcb2b7b99dfea4479
parentcd947bd22544fcade1598420855cf981e94b5c50 (diff)
offer to copy error message to clipboard
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java12
-rw-r--r--src/main/res/values/strings.xml1
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index cebc0f189..949dba90d 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1334,10 +1334,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
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);
+ final boolean showError = m.getStatus() == Message.STATUS_SEND_FAILED && m.getErrorMessage() != null && !Message.ERROR_MESSAGE_CANCELLED.equals(m.getErrorMessage());
deleteMessage.setVisible(true);
if (!m.isFileOrImage() && !encrypted && !m.isGeoUri() && !m.treatAsDownloadable()) {
copyMessage.setVisible(true);
- quoteMessage.setVisible(MessageUtils.prepareQuote(m).length() > 0);
+ quoteMessage.setVisible(!showError && MessageUtils.prepareQuote(m).length() > 0);
String body = m.getMergedBody().toString();
if (ShareUtil.containsXmppUri(body)) {
copyLink.setTitle(R.string.copy_jabber_id);
@@ -1349,7 +1350,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
retryDecryption.setVisible(true);
}
- if (relevantForCorrection.getType() == Message.TYPE_TEXT
+ if (!showError
+ && relevantForCorrection.getType() == Message.TYPE_TEXT
&& relevantForCorrection.isLastCorrectableMessage()
&& m.getConversation() instanceof Conversation
&& (((Conversation) m.getConversation()).getMucOptions().nonanonymous() || m.getConversation().getMode() == Conversation.MODE_SINGLE)) {
@@ -1388,7 +1390,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
deleteFile.setTitle(activity.getString(R.string.delete_x_file, UIHelper.getFileDescriptionString(activity, m)));
}
}
- if (m.getStatus() == Message.STATUS_SEND_FAILED && m.getErrorMessage() != null && !Message.ERROR_MESSAGE_CANCELLED.equals(m.getErrorMessage())) {
+ if (showError) {
showErrorMessage.setVisible(true);
}
}
@@ -1883,6 +1885,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.error_message);
builder.setMessage(message.getErrorMessage());
+ builder.setNegativeButton(R.string.copy_to_clipboard, (dialog, which) -> {
+ activity.copyTextToClipboard(message.getErrorMessage(), R.string.error_message);
+ Toast.makeText(activity, R.string.error_message_copied_to_clipboard, Toast.LENGTH_SHORT).show();
+ });
builder.setPositiveButton(R.string.ok, null);
builder.create().show();
}
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 7aeef797f..427739015 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -842,5 +842,6 @@
<string name="feature_not_implemented">Feature not implemented</string>
<string name="device_does_not_support_unknown_source_op">Your device does not support allowing app installs from unknon sources.</string>
<string name="reject_request">Reject request</string>
+ <string name="error_message_copied_to_clipboard">Copied error message to clipboard</string>
</resources>