From a9b957e8a2b9cb7729ed0d2cc8b5efa1bee50c79 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 16 Feb 2016 09:57:59 +0100 Subject: [PATCH] added setting to opt-out of message correction. renamed preferences and options to settings --- .../generator/AbstractGenerator.java | 7 +++- .../conversations/parser/MessageParser.java | 2 +- .../services/XmppConnectionService.java | 4 +++ .../conversations/ui/SettingsActivity.java | 3 +- src/main/res/values/strings.xml | 32 ++++++++++--------- src/main/res/xml/preferences.xml | 7 +++- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index d223ab842afee0b20f8b21e9d59448f7a558a640..05fa0b82e3c8a34c5db8d40720f94e9ecda40a38 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -31,7 +31,6 @@ public abstract class AbstractGenerator { "urn:xmpp:avatar:metadata+notify", "http://jabber.org/protocol/nick+notify", "urn:xmpp:ping", - "urn:xmpp:message-correct:0", "jabber:iq:version", "http://jabber.org/protocol/chatstates", AxolotlService.PEP_DEVICE_LIST+"+notify"}; @@ -39,6 +38,9 @@ public abstract class AbstractGenerator { "urn:xmpp:chat-markers:0", "urn:xmpp:receipts" }; + private final String[] MESSAGE_CORRECTION_FEATURES = { + "urn:xmpp:message-correct:0" + }; private String mVersion = null; protected final String IDENTITY_NAME = "Conversations"; protected final String IDENTITY_TYPE = "phone"; @@ -90,6 +92,9 @@ public abstract class AbstractGenerator { if (mXmppConnectionService.confirmMessages()) { features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES)); } + if (mXmppConnectionService.allowMessageCorrection()) { + features.addAll(Arrays.asList(MESSAGE_CORRECTION_FEATURES)); + } Collections.sort(features); return features; } diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 18edfdeb5d75122fc059344c9f4fec27cbc6cf95..620039a1524a279fc149c226ef3c8b6515f54147 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -393,7 +393,7 @@ public class MessageParser extends AbstractParser implements updateLastseen(timestamp, account, packet.getFrom(), true); } - if (replacementId != null) { + if (replacementId != null && mXmppConnectionService.allowMessageCorrection()) { Message replacedMessage = conversation.findMessageWithRemoteIdAndCounterpart(replacementId, counterpart); if (replacedMessage != null) { final boolean fingerprintsMatch = replacedMessage.getAxolotlFingerprint() == null diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index a8fe7586f46826280bf1e4fcf701719662fa2ca8..0c8f0b8b2b9b1e015a593191c5f16ba8b8be0dcf 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2615,6 +2615,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return getPreferences().getBoolean("confirm_messages", true); } + public boolean allowMessageCorrection() { + return getPreferences().getBoolean("allow_message_correction", true); + } + public boolean sendChatStates() { return getPreferences().getBoolean("chat_states", false); } diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index aa23e36db78434ab332857eb86891e4c1d626b81..07c328b9a7ffb742a5debda3a5b6224fd5e12574 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -162,7 +162,8 @@ public class SettingsActivity extends XmppActivity implements xmppConnectionService.toggleForegroundService(); } else if (name.equals("confirm_messages") || name.equals("xa_on_silent_mode") - || name.equals("away_when_screen_off")) { + || name.equals("away_when_screen_off") + || name.equals("allow_message_correction")) { if (xmppConnectionServiceBound) { if (name.equals("away_when_screen_off")) { xmppConnectionService.toggleScreenEventReceiver(); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 15322e046537775ffc19c6a40556e8a9274e0d11..da29bfe698ccd18b5bcf8c83014bfa378fa5910b 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -104,7 +104,7 @@ The name this client identifies itself with Accept files Automatically accept files smaller than… - Notification Settings + Notification Notifications Notify when a new message arrives Vibrate @@ -113,12 +113,12 @@ Play ringtone with notification Notification grace period Disable notifications for a short time after a carbon copy was received - Advanced Options + Advanced Never send crash reports By sending in stack traces you are helping the ongoing development of Conversations Confirm Messages Let your contact know when you have received and read a message - UI Options + UI OpenKeychain reported an error I/O Error decrypting file Accept @@ -278,12 +278,14 @@ Are you sure you would like to delete this fingerprint? Ignore Warning: Sending this without mutual presence updates could cause unexpected problems.\n\nGo to contact details to verify your presence subscriptions. - Encryption settings + Security Force end-to-end encryption Always send messages encrypted (except for conferences) + Allow message correction + Allow your contacts to retroactively edit their messages Don’t save encrypted messages Warning: This could lead to message loss - Expert options + Expert settings Please be careful with these About Conversations Build and licensing information @@ -464,7 +466,7 @@ 2 hours 8 hours Until further notice - Input options + Input Enter is send Use enter key to send message Show enter key @@ -528,20 +530,20 @@ Show received messages as black text on a white background Tor network unavailable Broken - Presence settings + Presence Away when screen is off Marks your resource as away when the screen is turned off Not available in silent mode Marks your resource as not available when device is in silent mode - Extended connection options - Show hostname and port options when setting up an account + Extended connection settings + Show hostname and port settings when setting up an account xmpp.example.com Add account with certificate Unable to parse certificate Leave empty to authenticate w/ certificate - Archiving preferences - Fetching archiving preferences. Please wait… - Unable to fetch archiving preferences + Archiving settting + Fetching archiving settings. Please wait… + Unable to fetch archiving setting Captcha text Captcha required enter the text from the image @@ -551,7 +553,7 @@ Error fetching OMEMO key! Verified OMEMO key with certificate! Your device does not support the selection of client certificates! - Connection options + Connection Connect via Tor Tunnel all connections through the Tor network. Requires Orbot Hostname @@ -575,7 +577,7 @@ Issuer Common Name Organization - SHA1 + SHA-1 (Not available) No certificate found Notify on all messages @@ -583,7 +585,7 @@ Notifications disabled Notifications paused Compress Pictures - Resize and compressed pictures + Resize and compress pictures Always Automatically Battery optimizations enabled diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 382b31993546cc6606bfa45fbc1043996b101797..e8747a8bb94437449095418cbc37d13e9058198f 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -131,7 +131,7 @@ android:key="expert" android:summary="@string/pref_expert_options_summary" android:title="@string/pref_expert_options"> - + +