aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconAbstractSpan.java36
-rw-r--r--libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java11
-rw-r--r--libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconImageSpan.java6
-rw-r--r--libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconSpan.java24
-rw-r--r--libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconTextView.java8
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java3
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java1
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/main/res/layout/fragment_conversation.xml2
9 files changed, 61 insertions, 32 deletions
diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconAbstractSpan.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconAbstractSpan.java
new file mode 100644
index 00000000..1ee4599a
--- /dev/null
+++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconAbstractSpan.java
@@ -0,0 +1,36 @@
+package github.ankushsachdeva.emojicon;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.text.style.DynamicDrawableSpan;
+
+/**
+ * Created by lookshe on 29.03.16.
+ */
+public abstract class EmojiconAbstractSpan extends DynamicDrawableSpan {
+ private final Context mContext;
+ private final int mResourceId;
+ private final int mSize;
+ private Drawable mDrawable;
+
+ public EmojiconAbstractSpan(Context context, int resourceId, int size) {
+ super();
+ mContext = context;
+ mResourceId = resourceId;
+ mSize = size;
+ }
+
+ @Override
+ public Drawable getDrawable() {
+ if (mDrawable == null) {
+ try {
+ mDrawable = mContext.getResources().getDrawable(mResourceId);
+ int size = mSize;
+ mDrawable.setBounds(0, 0, size, size);
+ } catch (Exception e) {
+ // swallow
+ }
+ }
+ return mDrawable;
+ }
+}
diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java
index f611a263..b6804b6d 100644
--- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java
+++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java
@@ -1445,7 +1445,7 @@ public final class EmojiconHandler {
map.put(Pattern.compile(smile), resource);
}
- private static boolean getSmiledText(Context context, Spannable spannable) {
+ private static boolean getSmiledText(Context context, Spannable spannable, int size) {
// remove spans throughout all text
EmojiconImageSpan[] oldSpans = spannable.getSpans(0, spannable.length(), EmojiconImageSpan.class);
for (int i = 0; i < oldSpans.length; i++) {
@@ -1495,7 +1495,7 @@ public final class EmojiconHandler {
}
}
if (set) {
- spannable.setSpan(new EmojiconImageSpan(context, entry.getValue()),
+ spannable.setSpan(new EmojiconImageSpan(context, entry.getValue(), size),
matcher.start(), matcher.end(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
hasChanges = true;
@@ -1514,9 +1514,10 @@ public final class EmojiconHandler {
* @param index
* @param length
*/
- public static void addEmojis(Context context, Spannable text, int emojiSize, int index, int length) {
+ public static boolean addEmojis(Context context, Spannable text, int emojiSize, int index, int length) {
+ boolean hasChanges = false;
if (isParseEmoticons()) {
- getSmiledText(context, text);
+ hasChanges = getSmiledText(context, text, emojiSize);
}
int textLength = text.length();
int textLengthToProcessMax = textLength - index;
@@ -1633,7 +1634,9 @@ public final class EmojiconHandler {
if (icon > 0) {
text.setSpan(new EmojiconSpan(context, icon, emojiSize), i, i + skip, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ hasChanges = true;
}
}
+ return hasChanges;
}
}
diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconImageSpan.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconImageSpan.java
index 8ad8fbb5..17ed779f 100644
--- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconImageSpan.java
+++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconImageSpan.java
@@ -6,9 +6,9 @@ import android.text.style.ImageSpan;
/**
* Created by lookshe on 16.08.2015.
*/
-public class EmojiconImageSpan extends ImageSpan {
+public class EmojiconImageSpan extends EmojiconAbstractSpan {
- EmojiconImageSpan(Context context, int resourceId) {
- super(context, resourceId);
+ EmojiconImageSpan(Context context, int resourceId, int size) {
+ super(context, resourceId, size);
}
}
diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconSpan.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconSpan.java
index 1afeea95..0fb43139 100644
--- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconSpan.java
+++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconSpan.java
@@ -23,29 +23,9 @@ import android.text.style.DynamicDrawableSpan;
/**
* @author Hieu Rocker (rockerhieu@gmail.com)
*/
-class EmojiconSpan extends DynamicDrawableSpan {
- private final Context mContext;
- private final int mResourceId;
- private final int mSize;
- private Drawable mDrawable;
+class EmojiconSpan extends EmojiconAbstractSpan {
public EmojiconSpan(Context context, int resourceId, int size) {
- super();
- mContext = context;
- mResourceId = resourceId;
- mSize = size;
- }
-
- public Drawable getDrawable() {
- if (mDrawable == null) {
- try {
- mDrawable = mContext.getResources().getDrawable(mResourceId);
- int size = mSize;
- mDrawable.setBounds(0, 0, size, size);
- } catch (Exception e) {
- // swallow
- }
- }
- return mDrawable;
+ super(context, resourceId, size);
}
} \ No newline at end of file
diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconTextView.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconTextView.java
index 5822e478..4f63c30a 100644
--- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconTextView.java
+++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconTextView.java
@@ -63,8 +63,12 @@ public class EmojiconTextView extends TextView {
@Override
public void setText(CharSequence text, BufferType type) {
SpannableStringBuilder builder = new SpannableStringBuilder(text);
- EmojiconHandler.addEmojis(getContext(), builder, mEmojiconSize, mTextStart, mTextLength);
- super.setText(builder, type);
+ boolean hasChanges = EmojiconHandler.addEmojis(getContext(), builder, mEmojiconSize, mTextStart, mTextLength);
+ if (hasChanges) {
+ super.setText(builder, BufferType.SPANNABLE);
+ } else {
+ super.setText(text, type);
+ }
}
/**
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index 073cc849..89d84cb2 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -52,6 +52,7 @@ public class MessageParser extends AbstractParser implements
if (from.toBareJid().equals(account.getJid().toBareJid())) {
conversation.setOutgoingChatState(state);
if (state == ChatState.ACTIVE || state == ChatState.COMPOSING) {
+ Logging.d("markRead", "MessageParser.extractChatState (" + conversation.getName() + ")");
mXmppConnectionService.markRead(conversation);
account.activateGracePeriod();
}
@@ -427,6 +428,7 @@ public class MessageParser extends AbstractParser implements
if (query == null || query.getWith() == null) { //either no mam or catchup
if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) {
+ Logging.d("markRead", "MessageParser.onMessagePacketReceived1 (" + conversation.getName() + ")");
mXmppConnectionService.markRead(conversation);
if (query == null) {
account.activateGracePeriod();
@@ -515,6 +517,7 @@ public class MessageParser extends AbstractParser implements
if (packet.fromAccount(account)) {
Conversation conversation = mXmppConnectionService.find(account,counterpart.toBareJid());
if (conversation != null) {
+ Logging.d("markRead", "MessageParser.onMessagePacketReceived2 (" + conversation.getName() + ")");
mXmppConnectionService.markRead(conversation);
}
} else {
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 1f537172..f6ab7b72 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -2574,6 +2574,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void sendReadMarker(final Conversation conversation) {
final Message markable = conversation.getLatestMarkableMessage();
+ Logging.d("markRead", "XmppConnectionService.sendReadMarker (" + conversation.getName() + ")");
if (this.markRead(conversation)) {
updateConversationUi();
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 175df041..02a9cb0f 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -43,6 +43,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.ui.dialogs.UserDecisionDialog;
import de.thedevstack.conversationsplus.ui.listeners.ResizePictureUserDecisionListener;
@@ -229,6 +230,7 @@ public class ConversationActivity extends XmppActivity
return null;
}
listAdapter.remove(swipedConversation);
+ Logging.d("markRead", "EnhancedListView.OnDismissCallback.onDismiss (" + swipedConversation.getName() + ")");
xmppConnectionService.markRead(swipedConversation);
final boolean formerlySelected = (getSelectedConversation() == swipedConversation);
diff --git a/src/main/res/layout/fragment_conversation.xml b/src/main/res/layout/fragment_conversation.xml
index dd102177..4145afb8 100644
--- a/src/main/res/layout/fragment_conversation.xml
+++ b/src/main/res/layout/fragment_conversation.xml
@@ -49,7 +49,7 @@
android:ems="10"
android:imeOptions="flagNoExtractUi|actionSend"
android:inputType="textShortMessage|textMultiLine|textCapSentences"
- android:minHeight="48dp"
+ android:minHeight="56dp"
android:minLines="1"
android:paddingBottom="12dp"
android:paddingLeft="8dp"