aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/utils
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-05-31 21:38:06 +0200
committerChristian Schneppe <christian@pix-art.de>2016-05-31 21:38:06 +0200
commitc23642b8cd2c06c5f3e9cf7f88d31ed5c6f78614 (patch)
treea7c53e5dd6dd6e85213cff834d35316a29617753 /src/main/java/eu/siacs/conversations/utils
parent2cdc31a6887f242dfe4faca91af63ffd4e74ef67 (diff)
parentea6a008b39b0f669f66f3c8aec08b4deb3ece154 (diff)
Merge remote-tracking branch 'refs/remotes/siacs/master'
Diffstat (limited to 'src/main/java/eu/siacs/conversations/utils')
-rw-r--r--src/main/java/eu/siacs/conversations/utils/PhoneHelper.java4
-rw-r--r--src/main/java/eu/siacs/conversations/utils/ReplacingSerialSingleThreadExecutor.java14
-rw-r--r--src/main/java/eu/siacs/conversations/utils/SerialSingleThreadExecutor.java19
-rw-r--r--src/main/java/eu/siacs/conversations/utils/XmlHelper.java1
-rw-r--r--src/main/java/eu/siacs/conversations/utils/XmppUri.java1
5 files changed, 37 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java b/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
index 48c9104f9..e77b2bae3 100644
--- a/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
@@ -13,12 +13,14 @@ import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Profile;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
public class PhoneHelper {
- public static void loadPhoneContacts(Context context, final List<Bundle> phoneContacts, final OnPhoneContactsLoadedListener listener) {
+ public static void loadPhoneContacts(Context context, final OnPhoneContactsLoadedListener listener) {
+ final List<Bundle> phoneContacts = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
listener.onPhoneContactsLoaded(phoneContacts);
diff --git a/src/main/java/eu/siacs/conversations/utils/ReplacingSerialSingleThreadExecutor.java b/src/main/java/eu/siacs/conversations/utils/ReplacingSerialSingleThreadExecutor.java
new file mode 100644
index 000000000..dc8a0a825
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/utils/ReplacingSerialSingleThreadExecutor.java
@@ -0,0 +1,14 @@
+package eu.siacs.conversations.utils;
+
+public class ReplacingSerialSingleThreadExecutor extends SerialSingleThreadExecutor {
+
+ public ReplacingSerialSingleThreadExecutor(boolean prepareLooper) {
+ super(prepareLooper);
+ }
+
+ @Override
+ public synchronized void execute(final Runnable r) {
+ tasks.clear();
+ super.execute(r);
+ }
+}
diff --git a/src/main/java/eu/siacs/conversations/utils/SerialSingleThreadExecutor.java b/src/main/java/eu/siacs/conversations/utils/SerialSingleThreadExecutor.java
index bfb4668db..55489ee30 100644
--- a/src/main/java/eu/siacs/conversations/utils/SerialSingleThreadExecutor.java
+++ b/src/main/java/eu/siacs/conversations/utils/SerialSingleThreadExecutor.java
@@ -1,5 +1,7 @@
package eu.siacs.conversations.utils;
+import android.os.Looper;
+
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.concurrent.Executor;
@@ -8,9 +10,24 @@ import java.util.concurrent.Executors;
public class SerialSingleThreadExecutor implements Executor {
final Executor executor = Executors.newSingleThreadExecutor();
- final Queue<Runnable> tasks = new ArrayDeque();
+ protected final Queue<Runnable> tasks = new ArrayDeque();
Runnable active;
+ public SerialSingleThreadExecutor() {
+ this(false);
+ }
+
+ public SerialSingleThreadExecutor(boolean prepareLooper) {
+ if (prepareLooper) {
+ execute(new Runnable() {
+ @Override
+ public void run() {
+ Looper.prepare();
+ }
+ });
+ }
+ }
+
public synchronized void execute(final Runnable r) {
tasks.offer(new Runnable() {
public void run() {
diff --git a/src/main/java/eu/siacs/conversations/utils/XmlHelper.java b/src/main/java/eu/siacs/conversations/utils/XmlHelper.java
index 4dee07cf7..198ce28b9 100644
--- a/src/main/java/eu/siacs/conversations/utils/XmlHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/XmlHelper.java
@@ -7,6 +7,7 @@ public class XmlHelper {
content = content.replace(">", "&gt;");
content = content.replace("\"", "&quot;");
content = content.replace("'", "&apos;");
+ content = content.replaceAll("\\p{Cc}", "");
return content;
}
}
diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java
index 9d42a639b..4039f8b0a 100644
--- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java
+++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java
@@ -47,6 +47,7 @@ public class XmppUri {
// sample : https://conversations.im/i/foo/bar.com
jid = segments.get(1) + "@" + segments.get(2);
}
+ muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0));
} else if ("xmpp".equalsIgnoreCase(scheme)) {
// sample: xmpp:foo@bar.com
muc = "join".equalsIgnoreCase(uri.getQuery());