aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java1
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java15
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java42
-rw-r--r--src/main/java/eu/siacs/conversations/utils/zlib/ZLibInputStream.java54
-rw-r--r--src/main/java/eu/siacs/conversations/utils/zlib/ZLibOutputStream.java95
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java56
8 files changed, 8 insertions, 263 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java
index 7af29451..d777e5cc 100644
--- a/src/main/java/eu/siacs/conversations/Config.java
+++ b/src/main/java/eu/siacs/conversations/Config.java
@@ -18,7 +18,6 @@ public final class Config {
public static final int MESSAGE_MERGE_WINDOW = 20;
- public static final boolean PARSE_EMOTICONS = false;
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;
public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
index ad8ba3da..f46e7ba4 100644
--- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
@@ -20,7 +20,7 @@ public abstract class AbstractGenerator {
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
"urn:xmpp:ping"};
- public final String IDENTITY_NAME = "Conversations 0.9.2";
+ public final String IDENTITY_NAME = "Conversations 0.9.3";
public final String IDENTITY_TYPE = "phone";
protected XmppConnectionService mXmppConnectionService;
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index b81544e6..f728e800 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -2,7 +2,6 @@ package eu.siacs.conversations.ui.adapter;
import java.util.List;
-import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
@@ -139,10 +138,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
} else {
if ((message.getEncryption() != Message.ENCRYPTION_PGP)
&& (message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
- String body = Config.PARSE_EMOTICONS ? UIHelper
- .transformAsciiEmoticons(message.getBody()) : message
- .getBody();
- mLastMessage.setText(body);
+ mLastMessage.setText(message.getBody());
} else {
mLastMessage.setText(R.string.encrypted_message_received);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index e3265a27..32062699 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -23,7 +23,6 @@ import android.widget.Toast;
import java.util.List;
-import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
@@ -225,10 +224,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setVisibility(View.VISIBLE);
if (message.getBody() != null) {
if (message.getType() != Message.TYPE_PRIVATE) {
- String body = Config.PARSE_EMOTICONS ? UIHelper
- .transformAsciiEmoticons(message.getMergedBody())
- : message.getMergedBody();
- viewHolder.messageBody.setText(body);
+ viewHolder.messageBody.setText(message.getMergedBody());
} else {
String privateMarker;
if (message.getStatus() <= Message.STATUS_RECEIVED) {
@@ -343,7 +339,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
final Message message = getItem(position);
final Conversation conversation = message.getConversation();
final Account account = conversation.getAccount();
- int type = getItemViewType(position);
+ final int type = getItemViewType(position);
ViewHolder viewHolder;
if (view == null) {
viewHolder = new ViewHolder();
@@ -371,7 +367,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
.findViewById(R.id.message_time);
viewHolder.indicatorReceived = (ImageView) view
.findViewById(R.id.indicator_received);
- view.setTag(viewHolder);
break;
case RECEIVED:
view = activity.getLayoutInflater().inflate(
@@ -392,21 +387,23 @@ public class MessageAdapter extends ArrayAdapter<Message> {
.findViewById(R.id.message_time);
viewHolder.indicatorReceived = (ImageView) view
.findViewById(R.id.indicator_received);
- view.setTag(viewHolder);
break;
case STATUS:
view = activity.getLayoutInflater().inflate(
R.layout.message_status, parent, false);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
- view.setTag(viewHolder);
break;
default:
viewHolder = null;
break;
}
+ view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
+ if (viewHolder == null) {
+ return view;
+ }
}
if (type == STATUS) {
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index 28a2bb4c..2f1383b8 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -2,7 +2,6 @@ package eu.siacs.conversations.utils;
import java.util.Calendar;
import java.util.Date;
-import java.util.regex.Pattern;
import eu.siacs.conversations.R;
import android.content.Context;
@@ -86,47 +85,6 @@ public class UIHelper {
}
}
- private final static class EmoticonPattern {
- Pattern pattern;
- String replacement;
-
- EmoticonPattern(String ascii, int unicode) {
- this.pattern = Pattern.compile("(?<=(^|\\s))" + ascii
- + "(?=(\\s|$))");
- this.replacement = new String(new int[] { unicode, }, 0, 1);
- }
-
- String replaceAll(String body) {
- return pattern.matcher(body).replaceAll(replacement);
- }
- }
-
- private static final EmoticonPattern[] patterns = new EmoticonPattern[] {
- new EmoticonPattern(":-?D", 0x1f600),
- new EmoticonPattern("\\^\\^", 0x1f601),
- new EmoticonPattern(":'D", 0x1f602),
- new EmoticonPattern("\\]-?D", 0x1f608),
- new EmoticonPattern(";-?\\)", 0x1f609),
- new EmoticonPattern(":-?\\)", 0x1f60a),
- new EmoticonPattern("[B8]-?\\)", 0x1f60e),
- new EmoticonPattern(":-?\\|", 0x1f610),
- new EmoticonPattern(":-?[/\\\\]", 0x1f615),
- new EmoticonPattern(":-?\\*", 0x1f617),
- new EmoticonPattern(":-?[Ppb]", 0x1f61b),
- new EmoticonPattern(":-?\\(", 0x1f61e),
- new EmoticonPattern(":-?[0Oo]", 0x1f62e),
- new EmoticonPattern("\\\\o/", 0x1F631), };
-
- public static String transformAsciiEmoticons(String body) {
- if (body != null) {
- for (EmoticonPattern p : patterns) {
- body = p.replaceAll(body);
- }
- body = body.trim();
- }
- return body;
- }
-
public static int getColorForName(String name) {
if (name.isEmpty()) {
return 0xFF202020;
diff --git a/src/main/java/eu/siacs/conversations/utils/zlib/ZLibInputStream.java b/src/main/java/eu/siacs/conversations/utils/zlib/ZLibInputStream.java
deleted file mode 100644
index b777c10c..00000000
--- a/src/main/java/eu/siacs/conversations/utils/zlib/ZLibInputStream.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package eu.siacs.conversations.utils.zlib;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.Inflater;
-import java.util.zip.InflaterInputStream;
-
-/**
- * ZLibInputStream is a zlib and input stream compatible version of an
- * InflaterInputStream. This class solves the incompatibility between
- * {@link InputStream#available()} and {@link InflaterInputStream#available()}.
- */
-public class ZLibInputStream extends InflaterInputStream {
-
- /**
- * Construct a ZLibInputStream, reading data from the underlying stream.
- *
- * @param is
- * The {@code InputStream} to read data from.
- * @throws IOException
- * If an {@code IOException} occurs.
- */
- public ZLibInputStream(InputStream is) throws IOException {
- super(is, new Inflater(), 512);
- }
-
- /**
- * Provide a more InputStream compatible version of available. A return
- * value of 1 means that it is likly to read one byte without blocking, 0
- * means that the system is known to block for more input.
- *
- * @return 0 if no data is available, 1 otherwise
- * @throws IOException
- */
- @Override
- public int available() throws IOException {
- /*
- * This is one of the funny code blocks. InflaterInputStream.available
- * violates the contract of InputStream.available, which breaks kXML2.
- *
- * I'm not sure who's to blame, oracle/sun for a broken api or the
- * google guys for mixing a sun bug with a xml reader that can't handle
- * it....
- *
- * Anyway, this simple if breaks suns distorted reality, but helps to
- * use the api as intended.
- */
- if (inf.needsInput()) {
- return 0;
- }
- return super.available();
- }
-
-}
diff --git a/src/main/java/eu/siacs/conversations/utils/zlib/ZLibOutputStream.java b/src/main/java/eu/siacs/conversations/utils/zlib/ZLibOutputStream.java
deleted file mode 100644
index 8b3f5e68..00000000
--- a/src/main/java/eu/siacs/conversations/utils/zlib/ZLibOutputStream.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package eu.siacs.conversations.utils.zlib;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.NoSuchAlgorithmException;
-import java.util.zip.Deflater;
-import java.util.zip.DeflaterOutputStream;
-
-/**
- * <p>
- * Android 2.2 includes Java7 FLUSH_SYNC option, which will be used by this
- * Implementation, preferable via reflection. The @hide was remove in API level
- * 19. This class might thus go away in the future.
- * </p>
- * <p>
- * Please use {@link ZLibOutputStream#SUPPORTED} to check for flush
- * compatibility.
- * </p>
- */
-public class ZLibOutputStream extends DeflaterOutputStream {
-
- /**
- * The reflection based flush method.
- */
-
- private final static Method method;
- /**
- * SUPPORTED is true if a flush compatible method exists.
- */
- public final static boolean SUPPORTED;
-
- /**
- * Static block to initialize {@link #SUPPORTED} and {@link #method}.
- */
- static {
- Method m = null;
- try {
- m = Deflater.class.getMethod("deflate", byte[].class, int.class,
- int.class, int.class);
- } catch (SecurityException e) {
- } catch (NoSuchMethodException e) {
- }
- method = m;
- SUPPORTED = (method != null);
- }
-
- /**
- * Create a new ZLib compatible output stream wrapping the given low level
- * stream. ZLib compatiblity means we will send a zlib header.
- *
- * @param os
- * OutputStream The underlying stream.
- * @throws IOException
- * In case of a lowlevel transfer problem.
- * @throws NoSuchAlgorithmException
- * In case of a {@link Deflater} error.
- */
- public ZLibOutputStream(OutputStream os) throws IOException,
- NoSuchAlgorithmException {
- super(os, new Deflater(Deflater.BEST_COMPRESSION));
- }
-
- /**
- * Flush the given stream, preferring Java7 FLUSH_SYNC if available.
- *
- * @throws IOException
- * In case of a lowlevel exception.
- */
- @Override
- public void flush() throws IOException {
- if (!SUPPORTED) {
- super.flush();
- return;
- }
- try {
- int count = 0;
- do {
- count = (Integer) method.invoke(def, buf, 0, buf.length, 3);
- if (count > 0) {
- out.write(buf, 0, count);
- }
- } while (count > 0);
- } catch (IllegalArgumentException e) {
- throw new IOException("Can't flush");
- } catch (IllegalAccessException e) {
- throw new IOException("Can't flush");
- } catch (InvocationTargetException e) {
- throw new IOException("Can't flush");
- }
- super.flush();
- }
-
-}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index fb151427..adb96fa2 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -50,8 +50,6 @@ import eu.siacs.conversations.crypto.sasl.ScramSha1;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.DNSHelper;
-import eu.siacs.conversations.utils.zlib.ZLibInputStream;
-import eu.siacs.conversations.utils.zlib.ZLibOutputStream;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Tag;
import eu.siacs.conversations.xml.TagWriter;
@@ -92,7 +90,6 @@ public class XmppConnection implements Runnable {
private int smVersion = 3;
private SparseArray<String> messageReceipts = new SparseArray<>();
- private boolean enabledCompression = false;
private boolean enabledEncryption = false;
private boolean enabledCarbons = false;
@@ -144,7 +141,6 @@ public class XmppConnection implements Runnable {
protected void connect() {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting");
- enabledCompression = false;
enabledEncryption = false;
lastConnect = SystemClock.elapsedRealtime();
lastPingSent = SystemClock.elapsedRealtime();
@@ -261,8 +257,6 @@ public class XmppConnection implements Runnable {
processStreamFeatures(nextTag);
} else if (nextTag.isStart("proceed")) {
switchOverToTls(nextTag);
- } else if (nextTag.isStart("compressed")) {
- switchOverToZLib(nextTag);
} else if (nextTag.isStart("success")) {
final String challenge = tagReader.readElement(nextTag).getContent();
try {
@@ -498,28 +492,6 @@ public class XmppConnection implements Runnable {
}
}
- private void sendCompressionZlib() throws IOException {
- Element compress = new Element("compress");
- compress.setAttribute("xmlns", "http://jabber.org/protocol/compress");
- compress.addChild("method").setContent("zlib");
- tagWriter.writeElement(compress);
- }
-
- private void switchOverToZLib(final Tag currentTag)
- throws XmlPullParserException, IOException,
- NoSuchAlgorithmException {
- tagReader.readTag(); // read tag close
- tagWriter.setOutputStream(new ZLibOutputStream(tagWriter
- .getOutputStream()));
- tagReader
- .setInputStream(new ZLibInputStream(tagReader.getInputStream()));
-
- sendStartStream();
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": compression enabled");
- enabledCompression = true;
- processStream(tagReader.readTag());
- }
-
private void sendStartTLS() throws IOException {
Tag startTLS = Tag.empty("starttls");
startTLS.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-tls");
@@ -601,8 +573,6 @@ public class XmppConnection implements Runnable {
this.streamFeatures = tagReader.readElement(currentTag);
if (this.streamFeatures.hasChild("starttls") && !enabledEncryption) {
sendStartTLS();
- } else if (compressionAvailable()) {
- sendCompressionZlib();
} else if (this.streamFeatures.hasChild("register")
&& account.isOptionSet(Account.OPTION_REGISTER)
&& enabledEncryption) {
@@ -658,28 +628,6 @@ public class XmppConnection implements Runnable {
}
}
- private boolean compressionAvailable() {
- if (!this.streamFeatures.hasChild("compression",
- "http://jabber.org/features/compress"))
- return false;
- if (!ZLibOutputStream.SUPPORTED)
- return false;
- if (!account.isOptionSet(Account.OPTION_USECOMPRESSION))
- return false;
-
- Element compression = this.streamFeatures.findChild("compression",
- "http://jabber.org/features/compress");
- for (Element child : compression.getChildren()) {
- if (!"method".equals(child.getName()))
- continue;
-
- if ("zlib".equalsIgnoreCase(child.getContent())) {
- return true;
- }
- }
- return false;
- }
-
private List<String> extractMechanisms(Element stream) {
ArrayList<String> mechanisms = new ArrayList<>(stream
.getChildren().size());
@@ -1147,9 +1095,5 @@ public class XmppConnection implements Runnable {
return connection
.findDiscoItemByFeature("http://jabber.org/protocol/bytestreams") != null;
}
-
- public boolean compression() {
- return connection.enabledCompression;
- }
}
}