From 093b576e0d97d13b6aa71ac5d8ca1e80d996ee39 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Tue, 30 Jul 2019 15:33:38 +0200 Subject: [PATCH 1/3] Errors: language selection for error description --- .../smack/packet/AbstractError.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java index d6a0d56a2..5a4621bb6 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java @@ -66,15 +66,23 @@ public class AbstractError { * @return the descriptive text or null. */ public String getDescriptiveText() { - String defaultLocale = Locale.getDefault().getLanguage(); - String descriptiveText = getDescriptiveText(defaultLocale); - if (descriptiveText == null) { - descriptiveText = getDescriptiveText("en"); - if (descriptiveText == null) { - descriptiveText = getDescriptiveText(""); - } + if (descriptiveTexts.isEmpty()) + return null; + // attempt to obtain the text in the user's locale, the English text, or the "" default + Locale l = Locale.getDefault(); + String[] tags = new String[] { + l.getLanguage() + "-" + l.getCountry() + "-" + l.getVariant(), + l.getLanguage() + "-" + l.getCountry(), + l.getLanguage(), + "en", + "" + }; + for (String tag : tags) { + String descriptiveText = getDescriptiveText(tag); + if (descriptiveText != null) + return descriptiveText; } - return descriptiveText; + return descriptiveTexts.values().iterator().next(); } /** From 80793910b88f0b57437d5d32ef140c145961eaef Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 2 Sep 2019 17:39:27 +0200 Subject: [PATCH 2/3] Make adding originId by default configurable --- .../smackx/sid/StableUniqueStanzaIdManager.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdManager.java index b43cc6078..fbe507e4e 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdManager.java @@ -51,6 +51,8 @@ public final class StableUniqueStanzaIdManager extends Manager { private static final Map INSTANCES = new WeakHashMap<>(); + private static boolean enabledByDefault = true; + // Filter for outgoing stanzas. private static final StanzaFilter OUTGOING_FILTER = new AndFilter( MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE, @@ -72,7 +74,9 @@ public final class StableUniqueStanzaIdManager extends Manager { XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() { @Override public void connectionCreated(XMPPConnection connection) { - getInstanceFor(connection); + if (enabledByDefault) { + getInstanceFor(connection).enable(); + } } }); } @@ -83,7 +87,10 @@ public final class StableUniqueStanzaIdManager extends Manager { */ private StableUniqueStanzaIdManager(XMPPConnection connection) { super(connection); - enable(); + } + + public static void setEnabledByDefault(boolean enabled) { + enabledByDefault = enabled; } /** From 4ed4e8f71ca2c1a74751dd87e9b911fe597b7fa8 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 13 Sep 2019 14:33:58 +0200 Subject: [PATCH 3/3] Don't compile android.jar contents into smack-android jar gradles compile command (which is deprecated and should be replaced with implementation) includes the arguments resources into the result jar. That means that smack-android will contain resources found at the android boot classpath. This results in a +~11mb increase in size of the resulting apk when including Smack as a composite build. The increase comes from 11mb of Android resources, mainly drawables. compileOnly (formerly provided) on the other hand will assert that the android.jar classes are provided by the system, which is probably what we want in this case. --- smack-android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-android/build.gradle b/smack-android/build.gradle index 97fd7c120..46d83633d 100644 --- a/smack-android/build.gradle +++ b/smack-android/build.gradle @@ -24,5 +24,5 @@ dependencies { } // Add the Android jar to the Eclipse .classpath. - compile files(androidBootClasspath) + compileOnly files(androidBootClasspath) }