From d8901441f630465def67c5d5b77dd7580e7de2b2 Mon Sep 17 00:00:00 2001 From: cijo-saju Date: Tue, 28 Mar 2017 20:41:08 +0530 Subject: [PATCH 1/6] Deleted unused variable --- src/main/java/eu/siacs/conversations/entities/Conversation.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 94c5f9c35..3eff50c6c 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -37,7 +37,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public static final int STATUS_AVAILABLE = 0; public static final int STATUS_ARCHIVED = 1; - public static final int STATUS_DELETED = 2; public static final int MODE_MULTI = 1; public static final int MODE_SINGLE = 0; From cb96911da37205773a5331d0864e0fc93241d0de Mon Sep 17 00:00:00 2001 From: cijo-saju Date: Tue, 28 Mar 2017 20:43:14 +0530 Subject: [PATCH 2/6] Saves some memory --- src/main/java/eu/siacs/conversations/entities/Conversation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 3eff50c6c..771136bca 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -346,7 +346,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public List getAcceptedCryptoTargets() { if (mode == MODE_SINGLE) { - return Arrays.asList(getJid().toBareJid()); + return Collections.singletonList(getJid().toBareJid()); } else { return getJidListAttribute(ATTRIBUTE_CRYPTO_TARGETS); } From 024dbd1c32e2a801f0b67bb263320239fd72a8b3 Mon Sep 17 00:00:00 2001 From: cijo-saju Date: Tue, 28 Mar 2017 20:46:20 +0530 Subject: [PATCH 3/6] Removed unused import and fixed some annotations --- .../java/eu/siacs/conversations/entities/Conversation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 771136bca..0a3e71e8d 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.entities; import android.content.ContentValues; import android.database.Cursor; +import android.support.annotation.NonNull; import net.java.otr4j.OtrException; import net.java.otr4j.crypto.OtrCryptoException; @@ -15,7 +16,6 @@ import org.json.JSONObject; import java.security.interfaces.DSAPublicKey; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; @@ -370,7 +370,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } @Override - public int compareTo(Conversation another) { + public int compareTo(@NonNull Conversation another) { final Message left = getLatestMessage(); final Message right = another.getLatestMessage(); if (left.getTimeSent() > right.getTimeSent()) { From 37465db817384e4b19972e9d3381d8306cea73ee Mon Sep 17 00:00:00 2001 From: cijo-saju Date: Tue, 28 Mar 2017 21:02:20 +0530 Subject: [PATCH 4/6] Fixed package access --- .../siacs/conversations/entities/Conversation.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 0a3e71e8d..edba9cf3c 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -50,13 +50,15 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public static final String MODE = "mode"; public static final String ATTRIBUTES = "attributes"; - public static final String ATTRIBUTE_NEXT_ENCRYPTION = "next_encryption"; - public static final String ATTRIBUTE_MUC_PASSWORD = "muc_password"; public static final String ATTRIBUTE_MUTED_TILL = "muted_till"; public static final String ATTRIBUTE_ALWAYS_NOTIFY = "always_notify"; - public static final String ATTRIBUTE_CRYPTO_TARGETS = "crypto_targets"; public static final String ATTRIBUTE_LAST_CLEAR_HISTORY = "last_clear_history"; + private static final String ATTRIBUTE_CRYPTO_TARGETS = "crypto_targets"; + + private static final String ATTRIBUTE_NEXT_ENCRYPTION = "next_encryption"; + static final String ATTRIBUTE_MUC_PASSWORD = "muc_password"; + private String draftMessage; private String name; private String contactUuid; @@ -870,7 +872,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } - public List getJidListAttribute(String key) { + private List getJidListAttribute(String key) { ArrayList list = new ArrayList<>(); synchronized (this.attributes) { try { @@ -889,7 +891,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return list; } - public int getIntAttribute(String key, int defaultValue) { + private int getIntAttribute(String key, int defaultValue) { String value = this.getAttribute(key); if (value == null) { return defaultValue; @@ -915,7 +917,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } - public boolean getBooleanAttribute(String key, boolean defaultValue) { + private boolean getBooleanAttribute(String key, boolean defaultValue) { String value = this.getAttribute(key); if (value == null) { return defaultValue; From 4e898fa4f29e25cbd2fb7c4e0cdcc6342e88e417 Mon Sep 17 00:00:00 2001 From: cijo-saju Date: Tue, 28 Mar 2017 22:14:05 +0530 Subject: [PATCH 5/6] Run in background instead of writing instantaneously --- .../java/eu/siacs/conversations/ui/ConversationActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index a93a12151..2765d332a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -1487,7 +1487,7 @@ public class ConversationActivity extends XmppActivity } private void setNeverAskForBatteryOptimizationsAgain() { - getPreferences().edit().putBoolean("show_battery_optimization", false).commit(); + getPreferences().edit().putBoolean("show_battery_optimization", false).apply(); } private void openBatteryOptimizationDialogIfNeeded() { From 3171dcac8d34b527f36188f22f59e4336c7afb68 Mon Sep 17 00:00:00 2001 From: cijo-saju Date: Tue, 28 Mar 2017 23:32:35 +0530 Subject: [PATCH 6/6] Fixed deprecated call --- .../java/eu/siacs/conversations/parser/MessageParser.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index ca173c363..7d6e79018 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -1,5 +1,6 @@ package eu.siacs.conversations.parser; +import android.os.Build; import android.text.Html; import android.util.Log; import android.util.Pair; @@ -116,7 +117,11 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } if (clientMightSendHtml(conversation.getAccount(), from)) { Log.d(Config.LOGTAG,conversation.getAccount().getJid().toBareJid()+": received OTR message from bad behaving client. escaping HTML…"); - body = Html.fromHtml(body).toString(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + body = Html.fromHtml(body,Html.FROM_HTML_MODE_LEGACY).toString(); + } else { + body = Html.fromHtml(body).toString(); + } } final OtrService otrService = conversation.getAccount().getOtrService();